Add /npc enderdragon --destroywalls

This commit is contained in:
fullwall 2023-03-29 20:01:07 +08:00
parent e8a5a1ceb4
commit efff2ff9ab
23 changed files with 182 additions and 14 deletions

View File

@ -17,6 +17,8 @@ import net.citizensnpcs.api.trait.TraitName;
@TraitName("enderdragontrait")
public class EnderDragonTrait extends Trait {
@Persist
private boolean destroyWalls;
@Persist
private EnderDragon.Phase phase;
@ -28,11 +30,19 @@ public class EnderDragonTrait extends Trait {
return phase;
}
public boolean isDestroyWalls() {
return destroyWalls;
}
@Override
public void onSpawn() {
updateModifiers();
}
public void setDestroyWalls(boolean destroyWalls) {
this.destroyWalls = destroyWalls;
}
public void setPhase(Phase phase) {
this.phase = phase;
updateModifiers();
@ -49,7 +59,7 @@ public class EnderDragonTrait extends Trait {
@Command(
aliases = { "npc" },
usage = "enderdragon --phase [phase]",
usage = "enderdragon --phase [phase] --destroywalls [true|false]",
desc = "Control enderdragon modifiers",
modifiers = { "enderdragon" },
min = 1,
@ -57,10 +67,14 @@ public class EnderDragonTrait extends Trait {
permission = "citizens.npc.enderdragon")
@Requirements(ownership = true, selected = true, types = EntityType.ENDER_DRAGON)
public static void enderdragon(CommandContext args, CommandSender sender, NPC npc,
@Flag("phase") EnderDragon.Phase phase) throws CommandException {
@Flag("phase") EnderDragon.Phase phase, @Flag("destroywalls") Boolean destroyWalls)
throws CommandException {
EnderDragonTrait trait = npc.getOrAddTrait(EnderDragonTrait.class);
if (phase != null) {
trait.setPhase(phase);
}
if (destroyWalls != null) {
trait.setDestroyWalls(destroyWalls);
}
}
}

View File

@ -12,6 +12,7 @@ import net.citizensnpcs.nms.v1_10_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
@ -194,6 +195,18 @@ public class EnderDragonController extends MobEntityController {
}
setPosition(locX + motX, locY + motY, locZ + motZ);
}
if (npc.hasTrait(EnderDragonTrait.class) && npc.getOrAddTrait(EnderDragonTrait.class).isDestroyWalls()
&& NMSImpl.ENDERDRAGON_CHECK_WALLS != null) {
for (int i = 0; i < 3; i++) {
try {
this.bG |= (boolean) NMSImpl.ENDERDRAGON_CHECK_WALLS.invoke(this,
children[i].getBoundingBox());
} catch (Throwable e) {
e.printStackTrace();
}
}
}
} else {
super.n();
}

View File

@ -1898,6 +1898,8 @@ 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");
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
true, boolean.class, AxisAlignedBB.class);
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY;
private static Map<Class<?>, Integer> ENTITY_CLASS_TO_INT;
private static Map<Class<?>, String> ENTITY_CLASS_TO_NAME;

View File

@ -12,6 +12,7 @@ import net.citizensnpcs.nms.v1_11_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
@ -195,6 +196,18 @@ public class EnderDragonController extends MobEntityController {
}
setPosition(locX + motX, locY + motY, locZ + motZ);
}
if (npc.hasTrait(EnderDragonTrait.class) && npc.getOrAddTrait(EnderDragonTrait.class).isDestroyWalls()
&& NMSImpl.ENDERDRAGON_CHECK_WALLS != null) {
for (int i = 0; i < 3; i++) {
try {
this.bF |= (boolean) NMSImpl.ENDERDRAGON_CHECK_WALLS.invoke(this,
children[i].getBoundingBox());
} catch (Throwable e) {
e.printStackTrace();
}
}
}
} else {
super.n();
}

View File

@ -1954,11 +1954,12 @@ 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");
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
true, boolean.class, AxisAlignedBB.class);
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY;
private static CustomEntityRegistry ENTITY_REGISTRY;
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);

View File

@ -12,6 +12,7 @@ import net.citizensnpcs.nms.v1_12_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_12_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_12_R1.AxisAlignedBB;
@ -195,6 +196,18 @@ public class EnderDragonController extends MobEntityController {
}
setPosition(locX + motX, locY + motY, locZ + motZ);
}
if (npc.hasTrait(EnderDragonTrait.class) && npc.getOrAddTrait(EnderDragonTrait.class).isDestroyWalls()
&& NMSImpl.ENDERDRAGON_CHECK_WALLS != null) {
for (int i = 0; i < 3; i++) {
try {
this.bG |= (boolean) NMSImpl.ENDERDRAGON_CHECK_WALLS.invoke(this,
children[i].getBoundingBox());
} catch (Throwable e) {
e.printStackTrace();
}
}
}
} else {
super.n();
}

View File

@ -1958,7 +1958,6 @@ public class NMSImpl implements NMSBridge {
navigation.d();
}
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);
@ -1966,6 +1965,8 @@ 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");
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
true, boolean.class, AxisAlignedBB.class);
private static DataWatcherObject<Boolean> ENDERMAN_ANGRY;
private static CustomEntityRegistry ENTITY_REGISTRY;
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);

View File

@ -14,6 +14,7 @@ import net.citizensnpcs.nms.v1_13_R2.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_13_R2.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_13_R2.AxisAlignedBB;
@ -206,6 +207,18 @@ public class EnderDragonController extends MobEntityController {
}
setPosition(locX + motX, locY + motY, locZ + motZ);
}
if (npc.hasTrait(EnderDragonTrait.class) && npc.getOrAddTrait(EnderDragonTrait.class).isDestroyWalls()
&& NMSImpl.ENDERDRAGON_CHECK_WALLS != null) {
for (int i = 0; i < 3; i++) {
try {
this.bN |= (boolean) NMSImpl.ENDERDRAGON_CHECK_WALLS.invoke(this,
children[i].getBoundingBox());
} catch (Throwable e) {
e.printStackTrace();
}
}
}
} else {
try {
super.movementTick();

View File

@ -2115,6 +2115,8 @@ 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");
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
true, boolean.class, AxisAlignedBB.class);
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;

View File

@ -12,6 +12,7 @@ import net.citizensnpcs.nms.v1_14_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_14_R1.AxisAlignedBB;
@ -203,6 +204,18 @@ public class EnderDragonController extends MobEntityController {
setPosition(locX + mot.getX(), locY + mot.getY(), locZ + mot.getZ());
setMot(mot);
}
if (npc.hasTrait(EnderDragonTrait.class) && npc.getOrAddTrait(EnderDragonTrait.class).isDestroyWalls()
&& NMSImpl.ENDERDRAGON_CHECK_WALLS != null) {
for (int i = 0; i < 3; i++) {
try {
this.bK |= (boolean) NMSImpl.ENDERDRAGON_CHECK_WALLS.invoke(this,
children[i].getBoundingBox());
} catch (Throwable e) {
e.printStackTrace();
}
}
}
} else {
super.movementTick();
}

View File

@ -2180,7 +2180,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,
@ -2195,6 +2194,8 @@ 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");
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
true, boolean.class, AxisAlignedBB.class);
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",

View File

@ -13,6 +13,7 @@ import net.citizensnpcs.nms.v1_15_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_15_R1.AxisAlignedBB;
@ -197,6 +198,17 @@ public class EnderDragonController extends MobEntityController {
setPosition(locX() + mot.getX(), locY() + mot.getY(), locZ() + mot.getZ());
setMot(mot);
}
if (npc.hasTrait(EnderDragonTrait.class) && npc.getOrAddTrait(EnderDragonTrait.class).isDestroyWalls()
&& NMSImpl.ENDERDRAGON_CHECK_WALLS != null) {
for (int i = 0; i < 3; i++) {
try {
this.bz |= (boolean) NMSImpl.ENDERDRAGON_CHECK_WALLS.invoke(this,
children[i].getBoundingBox());
} catch (Throwable e) {
e.printStackTrace();
}
}
}
} else {
super.movementTick();
}

View File

@ -2265,7 +2265,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.BEE,
EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT,
EntityType.SLIME, EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST,
@ -2278,6 +2277,8 @@ 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");
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
true, boolean.class, AxisAlignedBB.class);
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",

View File

@ -13,6 +13,7 @@ import net.citizensnpcs.nms.v1_16_R3.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_16_R3.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_16_R3.AxisAlignedBB;
@ -197,6 +198,18 @@ public class EnderDragonController extends MobEntityController {
setPosition(locX() + mot.getX(), locY() + mot.getY(), locZ() + mot.getZ());
setMot(mot);
}
if (npc.hasTrait(EnderDragonTrait.class) && npc.getOrAddTrait(EnderDragonTrait.class).isDestroyWalls()
&& NMSImpl.ENDERDRAGON_CHECK_WALLS != null) {
for (int i = 0; i < 3; i++) {
try {
this.br |= (boolean) NMSImpl.ENDERDRAGON_CHECK_WALLS.invoke(this,
children[i].getBoundingBox());
} catch (Throwable e) {
e.printStackTrace();
}
}
}
} else {
super.movementTick();
}

View File

@ -2287,9 +2287,7 @@ public class NMSImpl implements NMSBridge {
private static final MethodHandle ADVANCEMENT_PLAYER_FIELD = NMS.getFinalSetter(EntityPlayer.class,
"advancementDataPlayer");
private static final MethodHandle ATTRIBUTE_MAP = NMS.getGetter(AttributeMapBase.class, "d");
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP = NMS.getGetter(AttributeProvider.class, "a");
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP_SETTER = NMS.getFinalSetter(AttributeProvider.class, "a");
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.BEE,
@ -2306,6 +2304,8 @@ public class NMSImpl implements NMSBridge {
Sound.class);
private static final float DEFAULT_SPEED = 1F;
private static final MethodHandle ENDERDRAGON_BATTLE_FIELD = NMS.getGetter(EntityEnderDragon.class, "bF");
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
true, boolean.class, AxisAlignedBB.class);
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",

View File

@ -12,6 +12,7 @@ import net.citizensnpcs.nms.v1_17_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_17_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.nbt.CompoundTag;
@ -102,6 +103,18 @@ public class EnderDragonController extends MobEntityController {
setPos(getX() + mot.x, getY() + mot.y, getZ() + mot.z);
setDeltaMovement(mot);
}
if (npc.hasTrait(EnderDragonTrait.class) && npc.getOrAddTrait(EnderDragonTrait.class).isDestroyWalls()
&& NMSImpl.ENDERDRAGON_CHECK_WALLS != null) {
for (int i = 0; i < 3; i++) {
try {
this.inWall |= (boolean) NMSImpl.ENDERDRAGON_CHECK_WALLS.invoke(this,
subEntities[i].getBoundingBox());
} catch (Throwable e) {
e.printStackTrace();
}
}
}
} else {
super.aiStep();
}

View File

@ -2275,19 +2275,14 @@ public class NMSImpl implements NMSBridge {
}
private static final MethodHandle ADVANCEMENTS_PLAYER_FIELD = NMS.getFinalSetter(ServerPlayer.class, "cr");
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP = NMS.getFirstGetter(AttributeSupplier.class, Map.class);
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP_SETTER = NMS.getFinalSetter(AttributeSupplier.class, "a");
private static final MethodHandle ATTRIBUTE_SUPPLIER = NMS.getFirstGetter(AttributeMap.class,
AttributeSupplier.class);
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.BEE,
EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT,
EntityType.SLIME, EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST,
EntityType.SHULKER, EntityType.PHANTOM);
private static final MethodHandle BEHAVIOR_MAP = NMS.getGetter(Brain.class, "f");
private static final MethodHandle BUKKITENTITY_FIELD_SETTER = NMS.getSetter(Entity.class, "bukkitEntity");
private static final MethodHandle CHUNKMAP_UPDATE_PLAYER_STATUS = NMS.getMethodHandle(ChunkMap.class, "a", true,
@ -2296,6 +2291,8 @@ public class NMSImpl implements NMSBridge {
.newHashMap();
private static final MethodHandle CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getSetter(CraftBossBar.class, "handle");
private static final float DEFAULT_SPEED = 1F;
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EnderDragon.class, true,
boolean.class, AABB.class);
private static EntityDataAccessor<Boolean> ENDERMAN_CREEPY = null;
private static final MethodHandle ENTITY_FISH_NUM_IN_SCHOOL = NMS.getSetter(AbstractSchoolingFish.class, "c");
private static final MethodHandle ENTITY_GET_SOUND_FALL = NMS.getMethodHandle(LivingEntity.class, "getSoundFall",

View File

@ -12,6 +12,7 @@ import net.citizensnpcs.nms.v1_18_R2.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_18_R2.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.core.BlockPos;
@ -104,6 +105,18 @@ public class EnderDragonController extends MobEntityController {
setPos(getX() + mot.x, getY() + mot.y, getZ() + mot.z);
setDeltaMovement(mot);
}
if (npc.hasTrait(EnderDragonTrait.class) && npc.getOrAddTrait(EnderDragonTrait.class).isDestroyWalls()
&& NMSImpl.ENDERDRAGON_CHECK_WALLS != null) {
for (int i = 0; i < 3; i++) {
try {
this.inWall |= (boolean) NMSImpl.ENDERDRAGON_CHECK_WALLS.invoke(this,
subEntities[i].getBoundingBox());
} catch (Throwable e) {
e.printStackTrace();
}
}
}
} else {
super.aiStep();
}

View File

@ -2335,6 +2335,8 @@ public class NMSImpl implements NMSBridge {
.newHashMap();
private static final MethodHandle CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getSetter(CraftBossBar.class, "handle");
private static final float DEFAULT_SPEED = 1F;
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EnderDragon.class, true,
boolean.class, AABB.class);
private static EntityDataAccessor<Boolean> ENDERMAN_CREEPY = null;
private static final MethodHandle ENTITY_FISH_NUM_IN_SCHOOL = NMS.getFirstSetter(AbstractSchoolingFish.class,
int.class);

View File

@ -12,6 +12,7 @@ import net.citizensnpcs.nms.v1_19_R3.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_19_R3.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.core.PositionImpl;
@ -96,6 +97,7 @@ public class EnderDragonController extends MobEntityController {
if (getFirstPassenger() != null) {
setYRot(getFirstPassenger().getBukkitYaw() - 180);
}
Vec3 mot = getDeltaMovement();
if (mot.x != 0 || mot.y != 0 || mot.z != 0) {
mot = mot.multiply(0.98, 0.91, 0.98);
@ -105,6 +107,18 @@ public class EnderDragonController extends MobEntityController {
setPos(getX() + mot.x, getY() + mot.y, getZ() + mot.z);
setDeltaMovement(mot);
}
if (npc.hasTrait(EnderDragonTrait.class) && npc.getOrAddTrait(EnderDragonTrait.class).isDestroyWalls()
&& NMSImpl.ENDERDRAGON_CHECK_WALLS != null) {
for (int i = 0; i < 3; i++) {
try {
this.inWall |= (boolean) NMSImpl.ENDERDRAGON_CHECK_WALLS.invoke(this,
subEntities[i].getBoundingBox());
} catch (Throwable e) {
e.printStackTrace();
}
}
}
} else {
super.aiStep();
}

View File

@ -2453,6 +2453,7 @@ public class NMSImpl implements NMSBridge {
private static final MethodHandle ADVANCEMENTS_PLAYER_SETTER = NMS.getFirstFinalSetter(ServerPlayer.class,
PlayerAdvancements.class);
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP = NMS.getFirstGetter(AttributeSupplier.class, Map.class);
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP_SETTER = NMS.getFirstFinalSetter(AttributeSupplier.class,
Map.class);
@ -2471,6 +2472,8 @@ public class NMSImpl implements NMSBridge {
private static final MethodHandle CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getFirstSetter(CraftBossBar.class,
ServerBossEvent.class);
private static final float DEFAULT_SPEED = 1F;
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EnderDragon.class, true,
boolean.class, AABB.class);
private static EntityDataAccessor<Boolean> ENDERMAN_CREEPY = null;
private static final MethodHandle ENTITY_FISH_NUM_IN_SCHOOL = NMS.getFirstSetter(AbstractSchoolingFish.class,
int.class);

View File

@ -12,6 +12,7 @@ import net.citizensnpcs.nms.v1_8_R3.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_8_R3.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.versioned.EnderDragonTrait;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
@ -185,6 +186,18 @@ public class EnderDragonController extends MobEntityController {
}
setPosition(locX + motX, locY + motY, locZ + motZ);
}
if (npc.hasTrait(EnderDragonTrait.class) && npc.getOrAddTrait(EnderDragonTrait.class).isDestroyWalls()
&& NMSImpl.ENDERDRAGON_CHECK_WALLS != null) {
for (int i = 0; i < 3; i++) {
try {
this.bx |= (boolean) NMSImpl.ENDERDRAGON_CHECK_WALLS.invoke(this,
children[i].getBoundingBox());
} catch (Throwable e) {
e.printStackTrace();
}
}
}
} else {
super.m();
}

View File

@ -1752,8 +1752,9 @@ public class NMSImpl implements NMSBridge {
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.SILVERFISH, EntityType.ENDERMITE,
EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME, EntityType.MAGMA_CUBE, EntityType.HORSE,
EntityType.GHAST);
private static final float DEFAULT_SPEED = 1F;
public static MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EntityEnderDragon.class,
true, boolean.class, AxisAlignedBB.class);
private static Method ENTITY_ATTACK_A = NMS.getMethod(Entity.class, "a", true, EntityLiving.class, Entity.class);
private static Map<Class<?>, Integer> ENTITY_CLASS_TO_INT;
private static Map<Class<?>, String> ENTITY_CLASS_TO_NAME;