Implement enderman methods

This commit is contained in:
fullwall 2020-06-27 15:41:47 +08:00
parent 59cefadeda
commit c9564c4be2
15 changed files with 169 additions and 22 deletions

View File

@ -88,6 +88,7 @@ import net.citizensnpcs.trait.CommandTrait;
import net.citizensnpcs.trait.CommandTrait.NPCCommandBuilder;
import net.citizensnpcs.trait.Controllable;
import net.citizensnpcs.trait.CurrentLocation;
import net.citizensnpcs.trait.EndermanTrait;
import net.citizensnpcs.trait.FollowTrait;
import net.citizensnpcs.trait.GameModeTrait;
import net.citizensnpcs.trait.Gravity;
@ -560,6 +561,24 @@ public class NPCCommands {
}
}
@Command(
aliases = { "npc" },
usage = "enderman -a[ngry]",
desc = "Set enderman modifiers",
flags = "a",
modifiers = { "enderman" },
min = 1,
max = 2,
permission = "citizens.npc.enderman")
public void enderman(CommandContext args, Player sender, NPC npc) throws CommandException {
if (args.hasFlag('a')) {
boolean angry = npc.getTrait(EndermanTrait.class).toggleAngry();
Messaging.sendTr(sender, angry ? Messages.ENDERMAN_ANGRY_SET : Messages.ENDERMAN_ANGRY_UNSET,
npc.getName());
}
throw new CommandUsageException();
}
@Command(
aliases = { "npc" },
usage = "flyable (true|false)",

View File

@ -27,6 +27,7 @@ import net.citizensnpcs.trait.ArmorStandTrait;
import net.citizensnpcs.trait.CommandTrait;
import net.citizensnpcs.trait.Controllable;
import net.citizensnpcs.trait.CurrentLocation;
import net.citizensnpcs.trait.EndermanTrait;
import net.citizensnpcs.trait.FollowTrait;
import net.citizensnpcs.trait.GameModeTrait;
import net.citizensnpcs.trait.Gravity;
@ -62,6 +63,7 @@ public class CitizensTraitFactory implements TraitFactory {
registerTrait(TraitInfo.create(CommandTrait.class));
registerTrait(TraitInfo.create(Controllable.class));
registerTrait(TraitInfo.create(CurrentLocation.class));
registerTrait(TraitInfo.create(EndermanTrait.class));
registerTrait(TraitInfo.create(Equipment.class));
registerTrait(TraitInfo.create(FollowTrait.class));
registerTrait(TraitInfo.create(GameModeTrait.class));

View File

@ -78,6 +78,8 @@ public class Messages {
public static final String DELAY_TRIGGER_PROMPT = "citizens.editors.waypoints.triggers.delay.prompt";
public static final String ELDER_SET = "citizens.commands.npc.guardian.elder-set";
public static final String ELDER_UNSET = "citizens.commands.npc.guardian.elder-unset";
public static final String ENDERMAN_ANGRY_SET = "citizens.commands.npc.enderman.angry-set";
public static final String ENDERMAN_ANGRY_UNSET = "citizens.commands.npc.enderman.angry-unset";
public static final String ENTITY_TYPE_SET = "citizens.commands.npc.type.set";
public static final String EQUIPMENT_EDITOR_ALL_ITEMS_REMOVED = "citizens.editors.equipment.all-items-removed";
public static final String EQUIPMENT_EDITOR_BEGIN = "citizens.editors.equipment.begin";

View File

@ -10,6 +10,7 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Enderman;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.LivingEntity;
@ -378,6 +379,10 @@ public class NMS {
BRIDGE.setDestination(entity, x, y, z, speed);
}
public static void setEndermanAngry(Enderman enderman, boolean angry) {
BRIDGE.setEndermanAngry(enderman, angry);
}
public static void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
BRIDGE.setHeadYaw(entity, yaw);
}

View File

@ -6,6 +6,7 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Enderman;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.LivingEntity;
@ -125,6 +126,8 @@ public interface NMSBridge {
public void setDestination(Entity entity, double x, double y, double z, float speed);
public void setEndermanAngry(Enderman enderman, boolean angry);
public void setHeadYaw(Entity entity, float yaw);
public void setKnockbackResistance(LivingEntity entity, double d);

View File

@ -61,6 +61,8 @@ citizens.commands.npc.create.invalid-mobtype=[[{0}]] is not a valid mob type.
citizens.commands.npc.create.npc-name-too-long=NPC names cannot be longer than [[{0}]] characters. The name has been shortened.
citizens.commands.npc.create.no-player-for-spawn=No player could be found by that name to spawn an NPC at.
citizens.commands.npc.despawn.despawned=You despawned [[{0}]].
citizens.commands.npc.enderman.angry-set=[[{0}]] is now angry.
citizens.commands.npc.enderman.angry-unset=[[{0}]] is no longer angry.
citizens.commands.npc.flyable.set=[[{0}]] is now flyable.
citizens.commands.npc.flyable.unset=[[{0}]] is no longer flyable.
citizens.commands.npc.fox.crouching-set=[[{0}]] is now crouching.

View File

@ -167,6 +167,7 @@ import net.minecraft.server.v1_10_R1.EnchantmentManager;
import net.minecraft.server.v1_10_R1.EnderDragonBattle;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityEnderDragon;
import net.minecraft.server.v1_10_R1.EntityEnderman;
import net.minecraft.server.v1_10_R1.EntityFishingHook;
import net.minecraft.server.v1_10_R1.EntityHorse;
import net.minecraft.server.v1_10_R1.EntityHuman;
@ -909,6 +910,13 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setEndermanAngry(org.bukkit.entity.Enderman enderman, boolean angry) {
if (ENDERMAN_ANGRY == null)
return;
getHandle(enderman).getDataWatcher().set(ENDERMAN_ANGRY, angry);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity))
@ -1524,11 +1532,11 @@ public class NMSImpl implements NMSBridge {
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME, EntityType.MAGMA_CUBE,
EntityType.HORSE, EntityType.GHAST);
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
private static final float DEFAULT_SPEED = 1F;
private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c");
private static final Field ENDERDRAGON_BATTLE_FIELD = NMS.getField(EntityEnderDragon.class, "bK");
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY;
private static Map<Class<?>, Integer> ENTITY_CLASS_TO_INT;
private static Map<Class<?>, String> ENTITY_CLASS_TO_NAME;
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
@ -1563,5 +1571,13 @@ public class NMSImpl implements NMSBridge {
} catch (Exception ex) {
ex.printStackTrace();
}
try {
ENDERMAN_ANGRY = (DataWatcherObject<Boolean>) NMS.getField(EntityEnderman.class, "by").get(null);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}

View File

@ -183,6 +183,7 @@ import net.minecraft.server.v1_11_R1.Enchantments;
import net.minecraft.server.v1_11_R1.EnderDragonBattle;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityEnderDragon;
import net.minecraft.server.v1_11_R1.EntityEnderman;
import net.minecraft.server.v1_11_R1.EntityFishingHook;
import net.minecraft.server.v1_11_R1.EntityHorse;
import net.minecraft.server.v1_11_R1.EntityHorseAbstract;
@ -965,6 +966,13 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setEndermanAngry(org.bukkit.entity.Enderman enderman, boolean angry) {
if (ENDERMAN_ANGRY == null)
return;
getHandle(enderman).getDataWatcher().set(ENDERMAN_ANGRY, angry);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity))
@ -1587,11 +1595,11 @@ public class NMSImpl implements NMSBridge {
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME, EntityType.MAGMA_CUBE,
EntityType.HORSE, EntityType.GHAST);
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
private static final float DEFAULT_SPEED = 1F;
private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c");
private static final Field ENDERDRAGON_BATTLE_FIELD = NMS.getField(EntityEnderDragon.class, "bJ");
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY;
private static CustomEntityRegistry ENTITY_REGISTRY;
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
@ -1604,11 +1612,8 @@ public class NMSImpl implements NMSBridge {
private static final Field RABBIT_FIELD = NMS.getField(EntityRabbit.class, "bw");
private static final Random RANDOM = Util.getFastRandom();
private static Field SKULL_PROFILE_FIELD;
private static MethodHandle TEAM_FIELD;
private static Field TRACKED_ENTITY_SET = NMS.getField(EntityTracker.class, "c");
private static final Field WITHER_BOSS_BAR_FIELD = NMS.getField(EntityWither.class, "bF");
static {
@ -1629,5 +1634,13 @@ public class NMSImpl implements NMSBridge {
} catch (Exception ex) {
ex.printStackTrace();
}
try {
ENDERMAN_ANGRY = (DataWatcherObject<Boolean>) NMS.getField(EntityEnderman.class, "bx").get(null);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}

View File

@ -187,6 +187,7 @@ import net.minecraft.server.v1_12_R1.EnderDragonBattle;
import net.minecraft.server.v1_12_R1.Entity;
import net.minecraft.server.v1_12_R1.EntityBird;
import net.minecraft.server.v1_12_R1.EntityEnderDragon;
import net.minecraft.server.v1_12_R1.EntityEnderman;
import net.minecraft.server.v1_12_R1.EntityFishingHook;
import net.minecraft.server.v1_12_R1.EntityHorse;
import net.minecraft.server.v1_12_R1.EntityHorseAbstract;
@ -973,6 +974,13 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setEndermanAngry(org.bukkit.entity.Enderman enderman, boolean angry) {
if (ENDERMAN_ANGRY == null)
return;
getHandle(enderman).getDataWatcher().set(ENDERMAN_ANGRY, angry);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity))
@ -1569,11 +1577,11 @@ public class NMSImpl implements NMSBridge {
if ((entity.width > f2) && (!justCreated) && (!entity.world.isClientSide))
entity.move(EnumMoveType.SELF, (f2 - entity.width) / 2, 0.0D, (f2 - entity.width) / 2);
}
}
};
public static void stopNavigation(NavigationAbstract navigation) {
navigation.p();
};
}
public static void updateAI(EntityLiving entity) {
if (entity instanceof EntityInsentient) {
@ -1593,7 +1601,6 @@ public class NMSImpl implements NMSBridge {
}
private static MethodHandle ADVANCEMENT_PLAYER_FIELD = NMS.getFinalSetter(EntityPlayer.class, "bY");
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME,
EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST);
@ -1601,6 +1608,7 @@ public class NMSImpl implements NMSBridge {
private static final float DEFAULT_SPEED = 1F;
private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c");
private static final Field ENDERDRAGON_BATTLE_FIELD = NMS.getField(EntityEnderDragon.class, "bK");
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY;
private static CustomEntityRegistry ENTITY_REGISTRY;
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "b");
@ -1613,11 +1621,8 @@ public class NMSImpl implements NMSBridge {
private static final Field RABBIT_FIELD = NMS.getField(EntityRabbit.class, "bx");
private static final Random RANDOM = Util.getFastRandom();
private static Field SKULL_PROFILE_FIELD;
private static MethodHandle TEAM_FIELD;
private static Field TRACKED_ENTITY_SET = NMS.getField(EntityTracker.class, "c");
private static final Field WITHER_BOSS_BAR_FIELD = NMS.getField(EntityWither.class, "bG");
static {
@ -1638,5 +1643,12 @@ public class NMSImpl implements NMSBridge {
} catch (Exception ex) {
ex.printStackTrace();
}
try {
ENDERMAN_ANGRY = (DataWatcherObject<Boolean>) NMS.getField(EntityEnderman.class, "by").get(null);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}

View File

@ -200,6 +200,7 @@ import net.minecraft.server.v1_13_R2.EnderDragonBattle;
import net.minecraft.server.v1_13_R2.Entity;
import net.minecraft.server.v1_13_R2.EntityBird;
import net.minecraft.server.v1_13_R2.EntityEnderDragon;
import net.minecraft.server.v1_13_R2.EntityEnderman;
import net.minecraft.server.v1_13_R2.EntityFish;
import net.minecraft.server.v1_13_R2.EntityFishingHook;
import net.minecraft.server.v1_13_R2.EntityHorse;
@ -1008,6 +1009,13 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setEndermanAngry(org.bukkit.entity.Enderman enderman, boolean angry) {
if (ENDERMAN_ANGRY == null)
return;
getHandle(enderman).getDataWatcher().set(ENDERMAN_ANGRY, angry);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity))
@ -1712,6 +1720,7 @@ public class NMSImpl implements NMSBridge {
private static final float DEFAULT_SPEED = 1F;
private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c", false);
private static final Field ENDERDRAGON_BATTLE_FIELD = NMS.getField(EntityEnderDragon.class, "bR");
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY;
private static Method ENTITY_FISH_METHOD = NMS.getMethod(EntityFish.class, "t", false, boolean.class);
private static Field ENTITY_FISH_NUM_IN_SCHOOL;
private static CustomEntityRegistry ENTITY_REGISTRY;
@ -1760,5 +1769,13 @@ public class NMSImpl implements NMSBridge {
} catch (Exception ex) {
ex.printStackTrace();
}
try {
ENDERMAN_ANGRY = (DataWatcherObject<Boolean>) NMS.getField(EntityEnderman.class, "bC").get(null);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}

View File

@ -217,6 +217,7 @@ import net.minecraft.server.v1_14_R1.Entity;
import net.minecraft.server.v1_14_R1.EntityBird;
import net.minecraft.server.v1_14_R1.EntityCat;
import net.minecraft.server.v1_14_R1.EntityEnderDragon;
import net.minecraft.server.v1_14_R1.EntityEnderman;
import net.minecraft.server.v1_14_R1.EntityFish;
import net.minecraft.server.v1_14_R1.EntityFishSchool;
import net.minecraft.server.v1_14_R1.EntityFishingHook;
@ -1060,6 +1061,13 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setEndermanAngry(org.bukkit.entity.Enderman enderman, boolean angry) {
if (ENDERMAN_ANGRY == null)
return;
getHandle(enderman).getDataWatcher().set(ENDERMAN_ANGRY, angry);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity))
@ -1785,7 +1793,6 @@ public class NMSImpl implements NMSBridge {
private static final MethodHandle ADVANCEMENT_PLAYER_FIELD = NMS.getFinalSetter(EntityPlayer.class,
"advancementDataPlayer");
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME,
EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST, EntityType.SHULKER,
@ -1798,6 +1805,7 @@ public class NMSImpl implements NMSBridge {
private static final MethodHandle CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getSetter(CraftBossBar.class, "handle");
private static final float DEFAULT_SPEED = 1F;
private static final MethodHandle ENDERDRAGON_BATTLE_FIELD = NMS.getGetter(EntityEnderDragon.class, "bP");
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY;
private static final MethodHandle ENTITY_FISH_NUM_IN_SCHOOL = NMS.getSetter(EntityFishSchool.class, "c", false);
private static final MethodHandle ENTITY_GET_SOUND_FALL = NMS.getMethodHandle(EntityLiving.class, "getSoundFall",
true, int.class);
@ -1839,5 +1847,12 @@ public class NMSImpl implements NMSBridge {
} catch (Throwable e) {
Messaging.logTr(Messages.ERROR_GETTING_ID_MAPPING, e.getMessage());
}
try {
ENDERMAN_ANGRY = (DataWatcherObject<Boolean>) NMS.getField(EntityEnderman.class, "bz").get(null);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}

View File

@ -219,6 +219,7 @@ import net.minecraft.server.v1_15_R1.Entity;
import net.minecraft.server.v1_15_R1.EntityBird;
import net.minecraft.server.v1_15_R1.EntityCat;
import net.minecraft.server.v1_15_R1.EntityEnderDragon;
import net.minecraft.server.v1_15_R1.EntityEnderman;
import net.minecraft.server.v1_15_R1.EntityFish;
import net.minecraft.server.v1_15_R1.EntityFishSchool;
import net.minecraft.server.v1_15_R1.EntityFishingHook;
@ -1070,6 +1071,13 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setEndermanAngry(org.bukkit.entity.Enderman enderman, boolean angry) {
if (ENDERMAN_ANGRY == null)
return;
getHandle(enderman).getDataWatcher().set(ENDERMAN_ANGRY, angry);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity))
@ -1834,6 +1842,7 @@ public class NMSImpl implements NMSBridge {
private static final MethodHandle CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getSetter(CraftBossBar.class, "handle");
private static final float DEFAULT_SPEED = 1F;
private static final MethodHandle ENDERDRAGON_BATTLE_FIELD = NMS.getGetter(EntityEnderDragon.class, "bN");
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY;
private static final MethodHandle ENTITY_FISH_NUM_IN_SCHOOL = NMS.getSetter(EntityFishSchool.class, "c", false);
private static final MethodHandle ENTITY_GET_SOUND_FALL = NMS.getMethodHandle(EntityLiving.class, "getSoundFall",
true, int.class);
@ -1874,5 +1883,12 @@ public class NMSImpl implements NMSBridge {
} catch (Throwable e) {
Messaging.logTr(Messages.ERROR_GETTING_ID_MAPPING, e.getMessage());
}
try {
ENDERMAN_ANGRY = (DataWatcherObject<Boolean>) NMS.getField(EntityEnderman.class, "bw").get(null);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}

View File

@ -1,7 +1,6 @@
package net.citizensnpcs.nms.v1_16_R1.entity;
import org.bukkit.Bukkit;
import net.minecraft.server.v1_16_R1.EntityMinecartAbstract;
import org.bukkit.craftbukkit.v1_16_R1.CraftServer;
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftEnderman;
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftEntity;
@ -20,6 +19,7 @@ import net.minecraft.server.v1_16_R1.DamageSource;
import net.minecraft.server.v1_16_R1.Entity;
import net.minecraft.server.v1_16_R1.EntityBoat;
import net.minecraft.server.v1_16_R1.EntityEnderman;
import net.minecraft.server.v1_16_R1.EntityMinecartAbstract;
import net.minecraft.server.v1_16_R1.EntityTypes;
import net.minecraft.server.v1_16_R1.IBlockData;
import net.minecraft.server.v1_16_R1.NBTTagCompound;
@ -110,15 +110,6 @@ public class EndermanController extends MobEntityController {
return npc == null ? super.d(save) : false;
}
@Override
public void f(Vec3D vec3d) {
if (npc == null || !npc.isFlyable()) {
super.f(vec3d);
} else {
NMSImpl.flyingMoveLogic(this, vec3d);
}
}
@Override
public void enderTeleportTo(double d0, double d1, double d2) {
if (npc == null) {
@ -132,6 +123,15 @@ public class EndermanController extends MobEntityController {
}
}
@Override
public void f(Vec3D vec3d) {
if (npc == null || !npc.isFlyable()) {
super.f(vec3d);
} else {
NMSImpl.flyingMoveLogic(this, vec3d);
}
}
@Override
public CraftEntity getBukkitEntity() {
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
@ -208,6 +208,10 @@ public class EndermanController extends MobEntityController {
public void mobTick() {
super.mobTick();
if (npc != null) {
try {
} catch (Throwable e) {
e.printStackTrace();
}
NMSImpl.updateMinecraftAIState(npc, this);
npc.update();
}

View File

@ -223,6 +223,7 @@ import net.minecraft.server.v1_16_R1.Entity;
import net.minecraft.server.v1_16_R1.EntityBird;
import net.minecraft.server.v1_16_R1.EntityCat;
import net.minecraft.server.v1_16_R1.EntityEnderDragon;
import net.minecraft.server.v1_16_R1.EntityEnderman;
import net.minecraft.server.v1_16_R1.EntityFish;
import net.minecraft.server.v1_16_R1.EntityFishSchool;
import net.minecraft.server.v1_16_R1.EntityFishingHook;
@ -1092,6 +1093,13 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setEndermanAngry(org.bukkit.entity.Enderman enderman, boolean angry) {
if (ENDERMAN_ANGRY == null)
return;
getHandle(enderman).getDataWatcher().set(ENDERMAN_ANGRY, angry);
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity))
@ -1789,6 +1797,7 @@ public class NMSImpl implements NMSBridge {
private static final MethodHandle CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getSetter(CraftBossBar.class, "handle");
private static final float DEFAULT_SPEED = 1F;
private static final MethodHandle ENDERDRAGON_BATTLE_FIELD = NMS.getGetter(EntityEnderDragon.class, "bM");
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY = null;
private static final MethodHandle ENTITY_FISH_NUM_IN_SCHOOL = NMS.getSetter(EntityFishSchool.class, "c", false);
private static final MethodHandle ENTITY_GET_SOUND_FALL = NMS.getMethodHandle(EntityLiving.class, "getSoundFall",
true, int.class);
@ -1829,5 +1838,12 @@ public class NMSImpl implements NMSBridge {
} catch (Throwable e) {
Messaging.logTr(Messages.ERROR_GETTING_ID_MAPPING, e.getMessage());
}
try {
ENDERMAN_ANGRY = (DataWatcherObject<Boolean>) NMS.getField(EntityEnderman.class, "bv").get(null);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}

View File

@ -833,6 +833,11 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setEndermanAngry(org.bukkit.entity.Enderman enderman, boolean angry) {
getHandle(enderman).getDataWatcher().watch(17, Byte.valueOf((byte) (angry ? 1 : 0)));
}
@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
if (!(entity instanceof LivingEntity))