Add customisation of initial no damage ticks

This commit is contained in:
fullwall 2022-04-06 12:39:58 +08:00
parent 41b1ef57c9
commit af08a77b8e
2 changed files with 11 additions and 0 deletions

View File

@ -92,6 +92,7 @@ public class Settings {
DEFAULT_RANDOM_LOOK_DELAY("npc.default.look-close.random-look-delay", 60),
DEFAULT_RANDOM_TALKER("npc.default.random-talker", false),
DEFAULT_REALISTIC_LOOKING("npc.default.realistic-looking", false),
DEFAULT_SPAWN_NODAMAGE_TICKS("npc.default.spawn-nodamage-ticks", 20),
DEFAULT_STATIONARY_TICKS("npc.default.stationary-ticks", -1),
DEFAULT_STRAIGHT_LINE_TARGETING_DISTANCE("npc.pathfinding.straight-line-targeting-distance", 5),
DEFAULT_TALK_CLOSE("npc.default.talk-close.enabled", false),

View File

@ -342,6 +342,14 @@ public class CitizensNPC extends AbstractNPC {
NMS.replaceTrackerEntry((Player) getEntity());
PlayerUpdateTask.registerPlayer(getEntity());
}
if (SUPPORT_NODAMAGE_TICKS && Setting.DEFAULT_SPAWN_NODAMAGE_TICKS.asInt() != 20) {
try {
entity.setNoDamageTicks(data().get(NPC.Metadata.SPAWN_NODAMAGE_TICKS,
Setting.DEFAULT_SPAWN_NODAMAGE_TICKS.asInt()));
} catch (NoSuchMethodError err) {
SUPPORT_NODAMAGE_TICKS = false;
}
}
}
if (requiresNameHologram() && !hasTrait(HologramTrait.class)) {
@ -517,9 +525,11 @@ public class CitizensNPC extends AbstractNPC {
}
private static final Location CACHE_LOCATION = new Location(null, 0, 0, 0);
private static final SetMultimap<ChunkCoord, NPC> CHUNK_LOADERS = HashMultimap.create();
private static final String NPC_METADATA_MARKER = "NPC";
private static boolean SUPPORT_GLOWING = true;
private static boolean SUPPORT_NODAMAGE_TICKS = true;
private static boolean SUPPORT_SILENT = true;
private static boolean SUPPORT_USE_ITEM = true;
}