SPIGOT-6992: Add LimitedLife/LifeTicks/Bound APIs to Vex
By: Doc <nachito94@msn.com>
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.entity.monster.EntityVex;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Vex;
|
||||
@@ -35,4 +38,38 @@ public class CraftVex extends CraftMonster implements Vex {
|
||||
public void setCharging(boolean charging) {
|
||||
getHandle().setIsCharging(charging);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBound() {
|
||||
BlockPosition blockPosition = getHandle().getBoundOrigin();
|
||||
return (blockPosition == null) ? null : new Location(getWorld(), blockPosition.getX(), blockPosition.getY(), blockPosition.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBound(Location location) {
|
||||
if (location == null) {
|
||||
getHandle().setBoundOrigin(null);
|
||||
} else {
|
||||
Preconditions.checkArgument(getWorld().equals(location.getWorld()), "The bound world cannot be different to the entity's world.");
|
||||
getHandle().setBoundOrigin(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLifeTicks() {
|
||||
return getHandle().limitedLifeTicks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLifeTicks(int lifeTicks) {
|
||||
getHandle().setLimitedLife(lifeTicks);
|
||||
if (lifeTicks < 0) {
|
||||
getHandle().hasLimitedLife = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLimitedLife() {
|
||||
return getHandle().hasLimitedLife;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user