Simplify noDamageTicks

This commit is contained in:
fullwall 2024-12-10 18:51:51 +08:00
parent fb300c38fa
commit d8cc7b6f94

View File

@ -410,11 +410,9 @@ public class CitizensNPC extends AbstractNPC {
} else if (data().has(NPC.Metadata.AGGRESSIVE)) {
NMS.setAggressive(entity, data().<Boolean> get(NPC.Metadata.AGGRESSIVE));
}
if (SUPPORT_NODAMAGE_TICKS) {
entity.setNoDamageTicks(data().get(NPC.Metadata.SPAWN_NODAMAGE_TICKS,
Setting.DEFAULT_SPAWN_NODAMAGE_DURATION.asTicks()));
}
}
if (requiresNameHologram() && !hasTrait(HologramTrait.class)) {
addTrait(HologramTrait.class);
}
@ -614,16 +612,10 @@ public class CitizensNPC extends AbstractNPC {
private static final SetMultimap<ChunkCoord, NPC> CHUNK_LOADERS = HashMultimap.create();
private static boolean SUPPORT_ATTRIBUTES = false;
private static boolean SUPPORT_GLOWING = false;
private static boolean SUPPORT_NODAMAGE_TICKS = false;
private static boolean SUPPORT_PICKUP_ITEMS = false;
private static boolean SUPPORT_SILENT = false;
private static boolean SUPPORT_USE_ITEM = true;
static {
try {
Entity.class.getMethod("setNoDamageTicks", int.class);
SUPPORT_NODAMAGE_TICKS = true;
} catch (NoSuchMethodException | SecurityException e) {
}
try {
Entity.class.getMethod("setGlowing", boolean.class);
SUPPORT_GLOWING = true;