use of net.minecraft.server.v1_16_R3.ControllerMove in project Citizens2 by CitizensDev.
the class NMSImpl method getDestination.
@Override
public Location getDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
ControllerMove controller = handle instanceof EntityInsentient ? ((EntityInsentient) handle).getControllerMove() : handle instanceof EntityHumanNPC ? ((EntityHumanNPC) handle).getControllerMove() : null;
return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
}
use of net.minecraft.server.v1_16_R3.ControllerMove in project Citizens2 by CitizensDev.
the class NMSImpl method getDestination.
@Override
public Location getDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
ControllerMove controller = handle instanceof EntityInsentient ? ((EntityInsentient) handle).getControllerMove() : handle instanceof EntityHumanNPC ? ((EntityHumanNPC) handle).getControllerMove() : null;
return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
}
use of net.minecraft.server.v1_16_R3.ControllerMove in project Citizens2 by CitizensDev.
the class EntityHumanNPC method initialise.
private void initialise(MinecraftServer minecraftServer) {
Socket socket = new EmptySocket();
NetworkManager conn = null;
try {
conn = new EmptyNetworkManager(EnumProtocolDirection.CLIENTBOUND);
playerConnection = new EmptyNetHandler(minecraftServer, conn, this);
conn.setPacketListener(playerConnection);
socket.close();
} catch (IOException e) {
// swallow
}
AttributeModifiable range = getAttributeInstance(GenericAttributes.FOLLOW_RANGE);
if (range == null) {
try {
AttributeProvider provider = (AttributeProvider) ATTRIBUTE_MAP.invoke(getAttributeMap());
Map<AttributeBase, AttributeModifiable> all = Maps.newHashMap((Map<AttributeBase, AttributeModifiable>) ATTRIBUTE_PROVIDER_MAP.invoke(provider));
all.put(GenericAttributes.FOLLOW_RANGE, new AttributeModifiable(GenericAttributes.FOLLOW_RANGE, new Consumer<AttributeModifiable>() {
@Override
public void accept(AttributeModifiable att) {
throw new UnsupportedOperationException("Tried to change value for default attribute instance FOLLOW_RANGE");
}
}));
ATTRIBUTE_PROVIDER_MAP_SETTER.invoke(provider, ImmutableMap.copyOf(all));
} catch (Throwable e) {
e.printStackTrace();
}
range = getAttributeMap().a(GenericAttributes.FOLLOW_RANGE);
}
range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble());
controllerJump = new PlayerControllerJump(this);
controllerLook = new PlayerControllerLook(this);
controllerMove = new PlayerControllerMove(this);
navigation = new PlayerNavigation(this, world);
invulnerableTicks = 0;
// the default (0) breaks step climbing
NMS.setStepHeight(getBukkitEntity(), 1);
setSkinFlags((byte) 0xFF);
EmptyAdvancementDataPlayer.clear(this.getAdvancementData());
NMSImpl.setAdvancement(this.getBukkitEntity(), new EmptyAdvancementDataPlayer(minecraftServer.getDataFixer(), minecraftServer.getPlayerList(), minecraftServer.getAdvancementData(), CitizensAPI.getDataFolder().getParentFile(), this));
}
use of net.minecraft.server.v1_16_R3.ControllerMove in project Citizens2 by CitizensDev.
the class NMSImpl method getDestination.
@Override
public Location getDestination(org.bukkit.entity.Entity entity) {
Entity handle = getHandle(entity);
ControllerMove controller = handle instanceof EntityInsentient ? ((EntityInsentient) handle).getControllerMove() : handle instanceof EntityHumanNPC ? ((EntityHumanNPC) handle).getControllerMove() : null;
return new Location(entity.getWorld(), controller.d(), controller.e(), controller.f());
}
use of net.minecraft.server.v1_16_R3.ControllerMove in project RoseStacker by Rosewood-Development.
the class NMSHandlerImpl method removeEntityGoals.
@Override
public void removeEntityGoals(LivingEntity livingEntity) {
EntityLiving nmsEntity = ((CraftLivingEntity) livingEntity).getHandle();
if (!(nmsEntity instanceof EntityInsentient))
return;
try {
EntityInsentient insentient = (EntityInsentient) nmsEntity;
// Remove all goal AI other than floating in water
Set<PathfinderGoalWrapped> goals = (Set<PathfinderGoalWrapped>) field_PathfinderGoalSelector_d.get(insentient.goalSelector);
Iterator<PathfinderGoalWrapped> goalsIterator = goals.iterator();
while (goalsIterator.hasNext()) {
PathfinderGoalWrapped goal = goalsIterator.next();
if (goal.j() instanceof PathfinderGoalFloat)
continue;
goalsIterator.remove();
}
// Remove all targetting AI
((Set<PathfinderGoalWrapped>) field_PathfinderGoalSelector_d.get(insentient.targetSelector)).clear();
// Forget any existing targets
insentient.setGoalTarget(null);
// Remove the move controller and replace it with a dummy one
ControllerMove dummyMoveController = new ControllerMove(insentient) {
@Override
public void a() {
}
};
field_EntityInsentient_moveController.set(insentient, dummyMoveController);
} catch (ReflectiveOperationException ex) {
ex.printStackTrace();
}
}
Aggregations