diff --git a/dist/pom.xml b/dist/pom.xml index 6e33bff05..e60f38787 100644 --- a/dist/pom.xml +++ b/dist/pom.xml @@ -5,7 +5,7 @@ net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT citizens pom @@ -84,7 +84,7 @@ ${project.groupId} - citizens-v1_21_R1 + citizens-v1_21_R2 ${project.version} jar compile @@ -187,7 +187,7 @@ ${project.groupId} - citizens-v1_21_R1 + citizens-v1_21_R2 ${project.version} jar compile @@ -206,7 +206,7 @@ ${project.groupId} - citizens-v1_21_R1 + citizens-v1_21_R2 ${project.version} jar compile diff --git a/main/pom.xml b/main/pom.xml index a3da9f783..e94f85b01 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -6,12 +6,12 @@ net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT citizens-main UTF-8 - 1.21.1-R0.1-SNAPSHOT + 1.21.2-R0.1-SNAPSHOT 2.11.5 ${project.version} 7.1.0-SNAPSHOT diff --git a/main/src/main/java/net/citizensnpcs/EventListen.java b/main/src/main/java/net/citizensnpcs/EventListen.java index 72d32b9f3..7f26a1ca3 100644 --- a/main/src/main/java/net/citizensnpcs/EventListen.java +++ b/main/src/main/java/net/citizensnpcs/EventListen.java @@ -453,7 +453,7 @@ public class EventListen implements Listener { targetNPCEvent.setCancelled(!npc.data().get(NPC.Metadata.TARGETABLE, !npc.isProtected())); Bukkit.getPluginManager().callEvent(targetNPCEvent); if (targetNPCEvent.isCancelled()) { - targetNPCEvent.setCancelled(true); + event.setCancelled(true); } } diff --git a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java index e06561f8c..3ffbf321a 100644 --- a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -36,7 +36,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Ageable; import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Boat; import org.bukkit.entity.Damageable; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -123,7 +122,6 @@ import net.citizensnpcs.trait.Anchors; import net.citizensnpcs.trait.ArmorStandTrait; import net.citizensnpcs.trait.AttributeTrait; import net.citizensnpcs.trait.BatTrait; -import net.citizensnpcs.trait.BoatTrait; import net.citizensnpcs.trait.BoundingBoxTrait; import net.citizensnpcs.trait.ClickRedirectTrait; import net.citizensnpcs.trait.CommandTrait; @@ -449,24 +447,6 @@ public class NPCCommands { Messaging.sendTr(sender, awake ? Messages.BAT_AWAKE_SET : Messages.BAT_AWAKE_UNSET, npc.getName()); } - @Command( - aliases = { "npc" }, - usage = "boat --type [type]", - desc = "", - modifiers = { "boat" }, - min = 1, - max = 1, - permission = "citizens.npc.boat") - public void boat(CommandContext args, CommandSender sender, NPC npc, - @Flag(value = "type", completionsProvider = OptionalBoatTypeCompletions.class) String stype) - throws CommandException { - if (stype == null) - throw new CommandUsageException(); - Boat.Type type = Boat.Type.valueOf(stype); - npc.getOrAddTrait(BoatTrait.class).setType(type); - Messaging.sendTr(sender, Messages.BOAT_TYPE_SET, type); - } - @Command( aliases = { "npc" }, usage = "breakblock --location [x,y,z] --radius [radius]", @@ -2479,8 +2459,7 @@ public class NPCCommands { permission = "citizens.npc.playerlist") @Requirements(selected = true, ownership = true, types = EntityType.PLAYER) public void playerlist(CommandContext args, CommandSender sender, NPC npc) { - boolean remove = !npc.data().get(NPC.Metadata.REMOVE_FROM_PLAYERLIST, - Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean()); + boolean remove = !npc.shouldRemoveFromPlayerList(); if (args.hasFlag('a')) { remove = false; } else if (args.hasFlag('r')) { @@ -3415,7 +3394,7 @@ public class NPCCommands { npc.data().setPersistent(NPC.Metadata.TARGETABLE, targetable); } if (targetable && npc.getOrAddTrait(MobType.class).getType() == EntityType.PLAYER - && npc.data().get(NPC.Metadata.REMOVE_FROM_PLAYERLIST, true)) { + && npc.shouldRemoveFromPlayerList()) { Messaging.sendTr(sender, Messages.TARGETABLE_PLAYERLIST_WARNING); if (args.hasFlag('t')) { npc.data().set(NPC.Metadata.REMOVE_FROM_PLAYERLIST, false); diff --git a/main/src/main/java/net/citizensnpcs/npc/AbstractEntityController.java b/main/src/main/java/net/citizensnpcs/npc/AbstractEntityController.java index 2e9b3bc41..7e2ab1303 100644 --- a/main/src/main/java/net/citizensnpcs/npc/AbstractEntityController.java +++ b/main/src/main/java/net/citizensnpcs/npc/AbstractEntityController.java @@ -15,10 +15,6 @@ public abstract class AbstractEntityController implements EntityController { public AbstractEntityController() { } - public AbstractEntityController(Class clazz) { - NMS.registerEntityClass(clazz); - } - @Override public void create(Location at, NPC npc) { bukkitEntity = createEntity(at, npc); diff --git a/main/src/main/java/net/citizensnpcs/npc/CitizensTraitFactory.java b/main/src/main/java/net/citizensnpcs/npc/CitizensTraitFactory.java index 50f32ce38..b185e1f16 100644 --- a/main/src/main/java/net/citizensnpcs/npc/CitizensTraitFactory.java +++ b/main/src/main/java/net/citizensnpcs/npc/CitizensTraitFactory.java @@ -25,7 +25,6 @@ import net.citizensnpcs.trait.Anchors; import net.citizensnpcs.trait.ArmorStandTrait; import net.citizensnpcs.trait.AttributeTrait; import net.citizensnpcs.trait.BatTrait; -import net.citizensnpcs.trait.BoatTrait; import net.citizensnpcs.trait.BoundingBoxTrait; import net.citizensnpcs.trait.ClickRedirectTrait; import net.citizensnpcs.trait.CommandTrait; @@ -83,7 +82,6 @@ public class CitizensTraitFactory implements TraitFactory { registerTrait(TraitInfo.create(AttributeTrait.class)); registerTrait(TraitInfo.create(Anchors.class)); registerTrait(TraitInfo.create(BatTrait.class)); - registerTrait(TraitInfo.create(BoatTrait.class)); registerTrait(TraitInfo.create(BoundingBoxTrait.class)); registerTrait(TraitInfo.create(ClickRedirectTrait.class)); registerTrait(TraitInfo.create(CommandTrait.class).optInToStats()); diff --git a/main/src/main/java/net/citizensnpcs/npc/EntityControllers.java b/main/src/main/java/net/citizensnpcs/npc/EntityControllers.java index 88db2bfc3..3f4fc7818 100644 --- a/main/src/main/java/net/citizensnpcs/npc/EntityControllers.java +++ b/main/src/main/java/net/citizensnpcs/npc/EntityControllers.java @@ -37,5 +37,6 @@ public class EntityControllers { } } - private static Map> TYPES = Maps.newEnumMap(EntityType.class); + private static final Map> TYPES = Maps + .newEnumMap(EntityType.class); } diff --git a/main/src/main/java/net/citizensnpcs/trait/versioned/BoatTrait.java b/main/src/main/java/net/citizensnpcs/trait/versioned/BoatTrait.java new file mode 100644 index 000000000..26a37330b --- /dev/null +++ b/main/src/main/java/net/citizensnpcs/trait/versioned/BoatTrait.java @@ -0,0 +1,68 @@ +package net.citizensnpcs.trait.versioned; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Boat; + +import net.citizensnpcs.api.command.Command; +import net.citizensnpcs.api.command.CommandContext; +import net.citizensnpcs.api.command.Flag; +import net.citizensnpcs.api.command.exception.CommandException; +import net.citizensnpcs.api.command.exception.CommandUsageException; +import net.citizensnpcs.api.npc.NPC; +import net.citizensnpcs.api.persistence.Persist; +import net.citizensnpcs.api.trait.Trait; +import net.citizensnpcs.api.trait.TraitName; +import net.citizensnpcs.api.util.Messaging; +import net.citizensnpcs.api.util.SpigotUtil; +import net.citizensnpcs.commands.NPCCommands.OptionalBoatTypeCompletions; +import net.citizensnpcs.util.Messages; + +@TraitName("boattrait") +public class BoatTrait extends Trait { + @Persist + private Boat.Type type; + + public BoatTrait() { + super("boattrait"); + } + + @Command( + aliases = { "npc" }, + usage = "boat --type [type]", + desc = "", + modifiers = { "boat" }, + min = 1, + max = 1, + permission = "citizens.npc.boat") + public void boat(CommandContext args, CommandSender sender, NPC npc, + @Flag(value = "type", completionsProvider = OptionalBoatTypeCompletions.class) String stype) + throws CommandException { + if (stype == null) + throw new CommandUsageException(); + Boat.Type type = Boat.Type.valueOf(stype); + npc.getOrAddTrait(BoatTrait.class).setType(type); + Messaging.sendTr(sender, Messages.BOAT_TYPE_SET, type); + } + + public Boat.Type getType() { + return type; + } + + @Override + public void onSpawn() { + int[] version = SpigotUtil.getVersion(); + if (version[1] > 21 || (version[1] == 21 && version[2] >= 2)) + return; + if (npc.getEntity() instanceof Boat) { + if (type != null) { + ((Boat) npc.getEntity()).setBoatType(type); + } + } + } + + public void setType(Boat.Type type) { + this.type = type; + onSpawn(); + } + +} \ No newline at end of file diff --git a/main/src/main/java/net/citizensnpcs/util/NMS.java b/main/src/main/java/net/citizensnpcs/util/NMS.java index 17a5bcbff..c9169bfd6 100644 --- a/main/src/main/java/net/citizensnpcs/util/NMS.java +++ b/main/src/main/java/net/citizensnpcs/util/NMS.java @@ -497,6 +497,15 @@ public class NMS { return null; } + public static T getFirstStaticObject(Class clazz, Class type) { + try { + return (T) getFirstStaticGetter(clazz, type).invoke(); + } catch (Throwable e) { + e.printStackTrace(); + } + return null; + } + public static MethodHandle getGetter(Class clazz, String name) { return getGetter(clazz, name, true); } @@ -635,6 +644,15 @@ public class NMS { return BRIDGE.getSpeedFor(npc); } + public static T getStaticObject(Class clazz, String name) { + try { + return (T) getGetter(clazz, name).invoke(); + } catch (Throwable e) { + e.printStackTrace(); + } + return null; + } + public static float getStepHeight(org.bukkit.entity.Entity entity) { return BRIDGE.getStepHeight(entity); } @@ -770,8 +788,9 @@ public class NMS { BRIDGE.positionInteractionText(player, interaction, mount, height); } - public static void registerEntityClass(Class clazz) { - BRIDGE.registerEntityClass(clazz); + public static void registerEntityClass(Class clazz, Object type) { + // TODO: is this used outside of Citizens? could remove this abstraction + BRIDGE.registerEntityClass(clazz, type); } public static void remove(Entity entity) { diff --git a/main/src/main/java/net/citizensnpcs/util/NMSBridge.java b/main/src/main/java/net/citizensnpcs/util/NMSBridge.java index 9f5e1c379..c829c7ca4 100644 --- a/main/src/main/java/net/citizensnpcs/util/NMSBridge.java +++ b/main/src/main/java/net/citizensnpcs/util/NMSBridge.java @@ -179,7 +179,7 @@ public interface NMSBridge { public default void positionInteractionText(Player player, Entity interaction, Entity mount, double height) { } - public void registerEntityClass(Class clazz); + public void registerEntityClass(Class clazz, Object type); public void remove(Entity entity); diff --git a/pom.xml b/pom.xml index 7c2455592..ccb78ca68 100644 --- a/pom.xml +++ b/pom.xml @@ -6,10 +6,10 @@ pom net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT Unknown - 2.0.35 + 2.0.36 3.6.3 3.7.1 3.1.1 @@ -43,7 +43,7 @@ main v1_19_R3 v1_20_R4 - v1_21_R1 + v1_21_R2 dist @@ -63,7 +63,7 @@ v1_18_R2 v1_19_R3 v1_20_R4 - v1_21_R1 + v1_21_R2 dist @@ -71,7 +71,7 @@ dev main - v1_21_R1 + v1_21_R2 dist diff --git a/v1_10_R1/pom.xml b/v1_10_R1/pom.xml index 9eeb6ae25..641f6c753 100644 --- a/v1_10_R1/pom.xml +++ b/v1_10_R1/pom.xml @@ -6,7 +6,7 @@ net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT citizens-v1_10_R1 diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/MobEntityController.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/MobEntityController.java index 384efa321..41e033fd5 100644 --- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/MobEntityController.java +++ b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/MobEntityController.java @@ -23,7 +23,7 @@ public abstract class MobEntityController extends AbstractEntityController { private final Constructor constructor; protected MobEntityController(Class clazz) { - super(clazz); + NMS.registerEntityClass(clazz, null); this.constructor = getConstructor(clazz); } diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/EggController.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/EggController.java index c4dbffc51..16161cf05 100644 --- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/EggController.java +++ b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/EggController.java @@ -25,9 +25,7 @@ import net.minecraft.server.v1_10_R1.World; import net.minecraft.server.v1_10_R1.WorldServer; public class EggController extends AbstractEntityController { - public EggController() { - super(EntityEggNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/FallingBlockController.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/FallingBlockController.java index 6bc910a59..22738083b 100644 --- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/FallingBlockController.java +++ b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/FallingBlockController.java @@ -29,9 +29,7 @@ import net.minecraft.server.v1_10_R1.World; import net.minecraft.server.v1_10_R1.WorldServer; public class FallingBlockController extends AbstractEntityController { - public FallingBlockController() { - super(EntityFallingBlockNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/ItemController.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/ItemController.java index ba27a70cc..91aad6fa9 100644 --- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/ItemController.java +++ b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/nonliving/ItemController.java @@ -25,9 +25,6 @@ import net.minecraft.server.v1_10_R1.NBTTagCompound; import net.minecraft.server.v1_10_R1.World; public class ItemController extends AbstractEntityController { - public ItemController() { - super(EntityItemNPC.class); - } @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java index f43be7676..90ffe572c 100644 --- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java +++ b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java @@ -161,6 +161,7 @@ import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.AreaEffectCloudTrait; +import net.citizensnpcs.trait.versioned.BoatTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.EnderDragonTrait; import net.citizensnpcs.trait.versioned.PolarBearTrait; @@ -722,6 +723,7 @@ public class NMSImpl implements NMSBridge { @Override public void load(CommandManager manager) { + registerTraitWithCommand(manager, BoatTrait.class); registerTraitWithCommand(manager, AreaEffectCloudTrait.class); registerTraitWithCommand(manager, EnderDragonTrait.class); registerTraitWithCommand(manager, BossBarTrait.class); @@ -991,7 +993,7 @@ public class NMSImpl implements NMSBridge { } @Override - public void registerEntityClass(Class clazz) { + public void registerEntityClass(Class clazz, Object raw) { if (ENTITY_CLASS_TO_INT == null || ENTITY_CLASS_TO_INT.containsKey(clazz)) return; Class search = clazz; diff --git a/v1_11_R1/pom.xml b/v1_11_R1/pom.xml index ae0c4ef30..299fd0e9e 100644 --- a/v1_11_R1/pom.xml +++ b/v1_11_R1/pom.xml @@ -6,7 +6,7 @@ net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT citizens-v1_11_R1 diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/MobEntityController.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/MobEntityController.java index ac5824c27..fb6a29346 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/MobEntityController.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/MobEntityController.java @@ -23,7 +23,7 @@ public abstract class MobEntityController extends AbstractEntityController { private final Constructor constructor; protected MobEntityController(Class clazz) { - super(clazz); + NMS.registerEntityClass(clazz, null); this.constructor = getConstructor(clazz); } diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/EggController.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/EggController.java index 717f4268e..8fee2004c 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/EggController.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/EggController.java @@ -25,9 +25,7 @@ import net.minecraft.server.v1_11_R1.World; import net.minecraft.server.v1_11_R1.WorldServer; public class EggController extends AbstractEntityController { - public EggController() { - super(EntityEggNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/FallingBlockController.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/FallingBlockController.java index 1d2de5ba3..213957e19 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/FallingBlockController.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/FallingBlockController.java @@ -30,9 +30,7 @@ import net.minecraft.server.v1_11_R1.World; import net.minecraft.server.v1_11_R1.WorldServer; public class FallingBlockController extends AbstractEntityController { - public FallingBlockController() { - super(EntityFallingBlockNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/ItemController.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/ItemController.java index a2f286d85..68e6ecfe8 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/ItemController.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/ItemController.java @@ -25,9 +25,6 @@ import net.minecraft.server.v1_11_R1.NBTTagCompound; import net.minecraft.server.v1_11_R1.World; public class ItemController extends AbstractEntityController { - public ItemController() { - super(EntityItemNPC.class); - } @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/LlamaSpitController.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/LlamaSpitController.java index 759d94daf..42bd3e87d 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/LlamaSpitController.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/nonliving/LlamaSpitController.java @@ -26,9 +26,6 @@ import net.minecraft.server.v1_11_R1.World; import net.minecraft.server.v1_11_R1.WorldServer; public class LlamaSpitController extends AbstractEntityController { - public LlamaSpitController() { - super(EntityLlamaSpitNPC.class); - } @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java index 7abc08e57..4b76224a3 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java @@ -176,6 +176,7 @@ import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.AreaEffectCloudTrait; +import net.citizensnpcs.trait.versioned.BoatTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.EnderDragonTrait; import net.citizensnpcs.trait.versioned.LlamaTrait; @@ -758,6 +759,7 @@ public class NMSImpl implements NMSBridge { @Override public void load(CommandManager manager) { + registerTraitWithCommand(manager, BoatTrait.class); registerTraitWithCommand(manager, AreaEffectCloudTrait.class); registerTraitWithCommand(manager, EnderDragonTrait.class); registerTraitWithCommand(manager, BossBarTrait.class); @@ -1044,15 +1046,14 @@ public class NMSImpl implements NMSBridge { } @Override - public void registerEntityClass(Class clazz) { + public void registerEntityClass(Class clazz, Object raw) { if (ENTITY_REGISTRY == null) return; Class search = clazz; while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) { MinecraftKey key = ENTITY_REGISTRY.b(search); - if (key == null) { + if (key == null) continue; - } int code = ENTITY_REGISTRY.a(search); ENTITY_REGISTRY.put(code, key, (Class) clazz); return; diff --git a/v1_12_R1/pom.xml b/v1_12_R1/pom.xml index f440f4bec..ffc10aee1 100644 --- a/v1_12_R1/pom.xml +++ b/v1_12_R1/pom.xml @@ -6,7 +6,7 @@ net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT citizens-v1_12_R1 diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/MobEntityController.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/MobEntityController.java index 68fb585b6..bccfdcafc 100644 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/MobEntityController.java +++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/MobEntityController.java @@ -23,7 +23,7 @@ public abstract class MobEntityController extends AbstractEntityController { private final Constructor constructor; protected MobEntityController(Class clazz) { - super(clazz); + NMS.registerEntityClass(clazz, null); this.constructor = getConstructor(clazz); } diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/EggController.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/EggController.java index 36f2cbeea..72ffc3524 100644 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/EggController.java +++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/EggController.java @@ -26,9 +26,7 @@ import net.minecraft.server.v1_12_R1.World; import net.minecraft.server.v1_12_R1.WorldServer; public class EggController extends AbstractEntityController { - public EggController() { - super(EntityEggNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/FallingBlockController.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/FallingBlockController.java index d4d94fcd1..3d62675ba 100644 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/FallingBlockController.java +++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/FallingBlockController.java @@ -31,9 +31,7 @@ import net.minecraft.server.v1_12_R1.World; import net.minecraft.server.v1_12_R1.WorldServer; public class FallingBlockController extends AbstractEntityController { - public FallingBlockController() { - super(EntityFallingBlockNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/ItemController.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/ItemController.java index af35eafb3..4e2f77590 100644 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/ItemController.java +++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/ItemController.java @@ -26,9 +26,6 @@ import net.minecraft.server.v1_12_R1.NBTTagCompound; import net.minecraft.server.v1_12_R1.World; public class ItemController extends AbstractEntityController { - public ItemController() { - super(EntityItemNPC.class); - } @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/LlamaSpitController.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/LlamaSpitController.java index d4ef7c9c4..43b7c795c 100644 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/LlamaSpitController.java +++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/nonliving/LlamaSpitController.java @@ -27,9 +27,6 @@ import net.minecraft.server.v1_12_R1.World; import net.minecraft.server.v1_12_R1.WorldServer; public class LlamaSpitController extends AbstractEntityController { - public LlamaSpitController() { - super(EntityLlamaSpitNPC.class); - } @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java index 5e17d429b..653075bb2 100644 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java +++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java @@ -179,6 +179,7 @@ import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.AreaEffectCloudTrait; +import net.citizensnpcs.trait.versioned.BoatTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.EnderDragonTrait; import net.citizensnpcs.trait.versioned.LlamaTrait; @@ -760,6 +761,7 @@ public class NMSImpl implements NMSBridge { @Override public void load(CommandManager manager) { + registerTraitWithCommand(manager, BoatTrait.class); registerTraitWithCommand(manager, AreaEffectCloudTrait.class); registerTraitWithCommand(manager, EnderDragonTrait.class); registerTraitWithCommand(manager, BossBarTrait.class); @@ -1052,15 +1054,14 @@ public class NMSImpl implements NMSBridge { } @Override - public void registerEntityClass(Class clazz) { + public void registerEntityClass(Class clazz, Object raw) { if (ENTITY_REGISTRY == null) return; Class search = clazz; while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) { MinecraftKey key = ENTITY_REGISTRY.b(search); - if (key == null) { + if (key == null) continue; - } int code = ENTITY_REGISTRY.a(search); ENTITY_REGISTRY.put(code, key, (Class) clazz); return; diff --git a/v1_13_R2/pom.xml b/v1_13_R2/pom.xml index 471f0789e..7a357e7ba 100644 --- a/v1_13_R2/pom.xml +++ b/v1_13_R2/pom.xml @@ -6,7 +6,7 @@ net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT citizens-v1_13_R2 diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/MobEntityController.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/MobEntityController.java index 11ee8c777..0cd5c912f 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/MobEntityController.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/MobEntityController.java @@ -23,7 +23,7 @@ public abstract class MobEntityController extends AbstractEntityController { private final Constructor constructor; protected MobEntityController(Class clazz) { - super(clazz); + NMS.registerEntityClass(clazz, null); this.constructor = getConstructor(clazz); } diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/EggController.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/EggController.java index 77ac782a2..aaac0bced 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/EggController.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/EggController.java @@ -28,9 +28,7 @@ import net.minecraft.server.v1_13_R2.World; import net.minecraft.server.v1_13_R2.WorldServer; public class EggController extends AbstractEntityController { - public EggController() { - super(EntityEggNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/FallingBlockController.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/FallingBlockController.java index b0cb25270..775fb48f5 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/FallingBlockController.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/FallingBlockController.java @@ -33,9 +33,7 @@ import net.minecraft.server.v1_13_R2.World; import net.minecraft.server.v1_13_R2.WorldServer; public class FallingBlockController extends AbstractEntityController { - public FallingBlockController() { - super(EntityFallingBlockNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/ItemController.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/ItemController.java index c935910c6..46ebf61ff 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/ItemController.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/ItemController.java @@ -28,9 +28,6 @@ import net.minecraft.server.v1_13_R2.Tag; import net.minecraft.server.v1_13_R2.World; public class ItemController extends AbstractEntityController { - public ItemController() { - super(EntityItemNPC.class); - } @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/LlamaSpitController.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/LlamaSpitController.java index 3237cc00c..2e075d794 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/LlamaSpitController.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/nonliving/LlamaSpitController.java @@ -29,9 +29,6 @@ import net.minecraft.server.v1_13_R2.World; import net.minecraft.server.v1_13_R2.WorldServer; public class LlamaSpitController extends AbstractEntityController { - public LlamaSpitController() { - super(EntityLlamaSpitNPC.class); - } @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java index 8099ebb82..343127328 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java @@ -189,6 +189,7 @@ import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.AreaEffectCloudTrait; +import net.citizensnpcs.trait.versioned.BoatTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.EnderDragonTrait; import net.citizensnpcs.trait.versioned.LlamaTrait; @@ -790,6 +791,7 @@ public class NMSImpl implements NMSBridge { @Override public void load(CommandManager manager) { + registerTraitWithCommand(manager, BoatTrait.class); registerTraitWithCommand(manager, AreaEffectCloudTrait.class); registerTraitWithCommand(manager, EnderDragonTrait.class); registerTraitWithCommand(manager, BossBarTrait.class); @@ -1094,12 +1096,12 @@ public class NMSImpl implements NMSBridge { } @Override - public void registerEntityClass(Class clazz) { + public void registerEntityClass(Class clazz, Object raw) { if (ENTITY_REGISTRY == null) return; + EntityTypes type = (EntityTypes) raw; Class search = clazz; while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) { - EntityTypes type = ENTITY_REGISTRY.findType(search); MinecraftKey key = ENTITY_REGISTRY.getKey(type); if (key == null) { continue; diff --git a/v1_14_R1/pom.xml b/v1_14_R1/pom.xml index 853e2fb4e..6822f1672 100644 --- a/v1_14_R1/pom.xml +++ b/v1_14_R1/pom.xml @@ -6,7 +6,7 @@ net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT citizens-v1_14_R1 diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/MobEntityController.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/MobEntityController.java index 4b4d92a34..51e34a4de 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/MobEntityController.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/MobEntityController.java @@ -25,8 +25,7 @@ import net.minecraft.server.v1_14_R1.World; public abstract class MobEntityController extends AbstractEntityController { private final Class clazz; - protected MobEntityController(Class clazz) { - super(clazz); +protected MobEntityController(Class clazz) {NMS.registerEntityClass(clazz, NMSImpl.getEntityType(clazz)); this.clazz = clazz; } diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/EggController.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/EggController.java index fb096fe42..c227c5482 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/EggController.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/EggController.java @@ -31,9 +31,7 @@ import net.minecraft.server.v1_14_R1.World; import net.minecraft.server.v1_14_R1.WorldServer; public class EggController extends AbstractEntityController { - public EggController() { - super(EntityEggNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/FallingBlockController.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/FallingBlockController.java index b1a00cc5b..b4515ca7e 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/FallingBlockController.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/FallingBlockController.java @@ -35,9 +35,7 @@ import net.minecraft.server.v1_14_R1.World; import net.minecraft.server.v1_14_R1.WorldServer; public class FallingBlockController extends AbstractEntityController { - public FallingBlockController() { - super(EntityFallingBlockNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/ItemController.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/ItemController.java index 5883d947c..95fad8025 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/ItemController.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/ItemController.java @@ -31,9 +31,6 @@ import net.minecraft.server.v1_14_R1.Vec3D; import net.minecraft.server.v1_14_R1.World; public class ItemController extends AbstractEntityController { - public ItemController() { - super(EntityItemNPC.class); - } @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/LlamaSpitController.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/LlamaSpitController.java index b11193288..1f48ca312 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/LlamaSpitController.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/nonliving/LlamaSpitController.java @@ -32,15 +32,11 @@ import net.minecraft.server.v1_14_R1.World; import net.minecraft.server.v1_14_R1.WorldServer; public class LlamaSpitController extends AbstractEntityController { - public LlamaSpitController() { - super(EntityLlamaSpitNPC.class); - } @Override protected Entity createEntity(Location at, NPC npc) { WorldServer ws = ((CraftWorld) at.getWorld()).getHandle(); - final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC( - NMSImpl. getEntityType(EntityLlamaSpitNPC.class), ws, npc); + final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC(EntityTypes.LLAMA_SPIT, ws, npc); handle.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getPitch(), at.getYaw()); return handle.getBukkitEntity(); } diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java index fdf24c8f0..1ec859862 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java @@ -193,6 +193,7 @@ import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.AreaEffectCloudTrait; +import net.citizensnpcs.trait.versioned.BoatTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.CatTrait; import net.citizensnpcs.trait.versioned.EnderDragonTrait; @@ -848,6 +849,7 @@ public class NMSImpl implements NMSBridge { @Override public void load(CommandManager manager) { + registerTraitWithCommand(manager, BoatTrait.class); registerTraitWithCommand(manager, AreaEffectCloudTrait.class); registerTraitWithCommand(manager, EnderDragonTrait.class); registerTraitWithCommand(manager, BossBarTrait.class); @@ -1137,12 +1139,12 @@ public class NMSImpl implements NMSBridge { } @Override - public void registerEntityClass(Class clazz) { + public void registerEntityClass(Class clazz, Object raw) { if (ENTITY_REGISTRY == null) return; + EntityTypes type = (EntityTypes) raw; Class search = clazz; while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) { - EntityTypes type = ENTITY_REGISTRY.findType(search); MinecraftKey key = ENTITY_REGISTRY.getKey(type); if (key == null || type == null) { continue; diff --git a/v1_15_R1/pom.xml b/v1_15_R1/pom.xml index c7381e887..4481a6b1b 100644 --- a/v1_15_R1/pom.xml +++ b/v1_15_R1/pom.xml @@ -4,7 +4,7 @@ net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT citizens-v1_15_R1 diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/MobEntityController.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/MobEntityController.java index 36de1644b..4545025b5 100644 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/MobEntityController.java +++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/MobEntityController.java @@ -25,8 +25,7 @@ import net.minecraft.server.v1_15_R1.World; public abstract class MobEntityController extends AbstractEntityController { private final Class clazz; - protected MobEntityController(Class clazz) { - super(clazz); +protected MobEntityController(Class clazz) {NMS.registerEntityClass(clazz, NMSImpl.getEntityType(clazz)); this.clazz = clazz; } diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/EggController.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/EggController.java index 5fc1b4b73..af13f4de0 100644 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/EggController.java +++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/EggController.java @@ -32,9 +32,7 @@ import net.minecraft.server.v1_15_R1.World; import net.minecraft.server.v1_15_R1.WorldServer; public class EggController extends AbstractEntityController { - public EggController() { - super(EntityEggNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/FallingBlockController.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/FallingBlockController.java index 77d8d6c59..fbdf45c37 100644 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/FallingBlockController.java +++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/FallingBlockController.java @@ -35,9 +35,7 @@ import net.minecraft.server.v1_15_R1.World; import net.minecraft.server.v1_15_R1.WorldServer; public class FallingBlockController extends AbstractEntityController { - public FallingBlockController() { - super(EntityFallingBlockNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/ItemController.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/ItemController.java index 3afe1c70c..17c44f438 100644 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/ItemController.java +++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/ItemController.java @@ -31,9 +31,6 @@ import net.minecraft.server.v1_15_R1.Vec3D; import net.minecraft.server.v1_15_R1.World; public class ItemController extends AbstractEntityController { - public ItemController() { - super(EntityItemNPC.class); - } @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/LlamaSpitController.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/LlamaSpitController.java index 6417f7c97..72e62cf3f 100644 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/LlamaSpitController.java +++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/nonliving/LlamaSpitController.java @@ -33,15 +33,11 @@ import net.minecraft.server.v1_15_R1.World; import net.minecraft.server.v1_15_R1.WorldServer; public class LlamaSpitController extends AbstractEntityController { - public LlamaSpitController() { - super(EntityLlamaSpitNPC.class); - } @Override protected Entity createEntity(Location at, NPC npc) { WorldServer ws = ((CraftWorld) at.getWorld()).getHandle(); - final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC( - NMSImpl. getEntityType(EntityLlamaSpitNPC.class), ws, npc); + final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC(EntityTypes.LLAMA_SPIT, ws, npc); handle.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getPitch(), at.getYaw()); return handle.getBukkitEntity(); } diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java index 35f0af201..06f4da842 100644 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java +++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java @@ -195,6 +195,7 @@ import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.AreaEffectCloudTrait; import net.citizensnpcs.trait.versioned.BeeTrait; +import net.citizensnpcs.trait.versioned.BoatTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.CatTrait; import net.citizensnpcs.trait.versioned.EnderDragonTrait; @@ -863,6 +864,7 @@ public class NMSImpl implements NMSBridge { @Override public void load(CommandManager manager) { + registerTraitWithCommand(manager, BoatTrait.class); registerTraitWithCommand(manager, AreaEffectCloudTrait.class); registerTraitWithCommand(manager, EnderDragonTrait.class); registerTraitWithCommand(manager, BeeTrait.class); @@ -1154,12 +1156,12 @@ public class NMSImpl implements NMSBridge { } @Override - public void registerEntityClass(Class clazz) { + public void registerEntityClass(Class clazz, Object raw) { if (ENTITY_REGISTRY == null) return; + EntityTypes type = (EntityTypes) raw; Class search = clazz; while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) { - EntityTypes type = ENTITY_REGISTRY.findType(search); MinecraftKey key = ENTITY_REGISTRY.getKey(type); if (key == null || type == null) { continue; diff --git a/v1_16_R3/pom.xml b/v1_16_R3/pom.xml index ddbc14133..0635c14c5 100644 --- a/v1_16_R3/pom.xml +++ b/v1_16_R3/pom.xml @@ -4,7 +4,7 @@ net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT citizens-v1_16_R3 diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/MobEntityController.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/MobEntityController.java index 3be5737df..287534043 100644 --- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/MobEntityController.java +++ b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/MobEntityController.java @@ -25,8 +25,7 @@ import net.minecraft.server.v1_16_R3.World; public abstract class MobEntityController extends AbstractEntityController { private final Class clazz; - protected MobEntityController(Class clazz) { - super(clazz); +protected MobEntityController(Class clazz) {NMS.registerEntityClass(clazz, NMSImpl.getEntityType(clazz)); this.clazz = clazz; } diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/EggController.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/EggController.java index 8073de70c..25cc1e710 100644 --- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/EggController.java +++ b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/EggController.java @@ -32,9 +32,7 @@ import net.minecraft.server.v1_16_R3.World; import net.minecraft.server.v1_16_R3.WorldServer; public class EggController extends AbstractEntityController { - public EggController() { - super(EntityEggNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/FallingBlockController.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/FallingBlockController.java index 0f06b752f..22e6c3cea 100644 --- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/FallingBlockController.java +++ b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/FallingBlockController.java @@ -35,9 +35,7 @@ import net.minecraft.server.v1_16_R3.World; import net.minecraft.server.v1_16_R3.WorldServer; public class FallingBlockController extends AbstractEntityController { - public FallingBlockController() { - super(EntityFallingBlockNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/ItemController.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/ItemController.java index 36843e666..e438a0b08 100644 --- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/ItemController.java +++ b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/ItemController.java @@ -31,9 +31,6 @@ import net.minecraft.server.v1_16_R3.Vec3D; import net.minecraft.server.v1_16_R3.World; public class ItemController extends AbstractEntityController { - public ItemController() { - super(EntityItemNPC.class); - } @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/LlamaSpitController.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/LlamaSpitController.java index 738fb2e26..3edf66552 100644 --- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/LlamaSpitController.java +++ b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/nonliving/LlamaSpitController.java @@ -33,15 +33,11 @@ import net.minecraft.server.v1_16_R3.World; import net.minecraft.server.v1_16_R3.WorldServer; public class LlamaSpitController extends AbstractEntityController { - public LlamaSpitController() { - super(EntityLlamaSpitNPC.class); - } @Override protected Entity createEntity(Location at, NPC npc) { WorldServer ws = ((CraftWorld) at.getWorld()).getHandle(); - final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC( - NMSImpl. getEntityType(EntityLlamaSpitNPC.class), ws, npc); + final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC(EntityTypes.LLAMA_SPIT, ws, npc); handle.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getPitch(), at.getYaw()); return handle.getBukkitEntity(); } diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java index 817a5d572..192e6df43 100644 --- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java +++ b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java @@ -201,6 +201,7 @@ import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.AreaEffectCloudTrait; import net.citizensnpcs.trait.versioned.BeeTrait; +import net.citizensnpcs.trait.versioned.BoatTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.CatTrait; import net.citizensnpcs.trait.versioned.EnderDragonTrait; @@ -886,6 +887,7 @@ public class NMSImpl implements NMSBridge { @Override public void load(CommandManager manager) { + registerTraitWithCommand(manager, BoatTrait.class); registerTraitWithCommand(manager, AreaEffectCloudTrait.class); registerTraitWithCommand(manager, EnderDragonTrait.class); registerTraitWithCommand(manager, BeeTrait.class); @@ -1177,12 +1179,12 @@ public class NMSImpl implements NMSBridge { } @Override - public void registerEntityClass(Class clazz) { + public void registerEntityClass(Class clazz, Object raw) { if (ENTITY_REGISTRY == null) return; + EntityTypes type = (EntityTypes) raw; Class search = clazz; while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) { - EntityTypes type = ENTITY_REGISTRY.findType(search); MinecraftKey key = ENTITY_REGISTRY.getKey(type); if (key == null || type == null) { continue; @@ -2367,7 +2369,8 @@ public class NMSImpl implements NMSBridge { private static final MethodHandle NAVIGATION_S = NMS.getFinalSetter(NavigationAbstract.class, "s"); private static final MethodHandle NAVIGATION_WORLD_FIELD = NMS.getSetter(NavigationAbstract.class, "b"); public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0); - // Player.mobCounts: workaround for an issue which suppresses mobs being spawn near NPC players on Paper. Need to check for every update. + // Player.mobCounts: workaround for an issue which suppresses mobs being spawn near NPC players on Paper. Need to + // check for every update. public static final MethodHandle PAPER_PLAYER_MOB_COUNTS = NMS.getGetter(EntityPlayer.class, "mobCounts", false); private static final MethodHandle PLAYER_CHUNK_MAP_VIEW_DISTANCE_GETTER = NMS.getGetter(PlayerChunkMap.class, "viewDistance"); diff --git a/v1_17_R1/pom.xml b/v1_17_R1/pom.xml index c5799d8e7..45c523b23 100644 --- a/v1_17_R1/pom.xml +++ b/v1_17_R1/pom.xml @@ -6,7 +6,7 @@ net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT citizens-v1_17_R1 diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/MobEntityController.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/MobEntityController.java index a973f482f..0dbe5ce39 100644 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/MobEntityController.java +++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/MobEntityController.java @@ -15,6 +15,7 @@ import net.citizensnpcs.nms.v1_17_R1.util.NMSImpl; import net.citizensnpcs.nms.v1_17_R1.util.PitchableLookControl; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.trait.ScoreboardTrait; +import net.citizensnpcs.util.NMS; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.control.LookControl; @@ -24,7 +25,7 @@ public abstract class MobEntityController extends AbstractEntityController { private final Class clazz; protected MobEntityController(Class clazz) { - super(clazz); + NMS.registerEntityClass(clazz, NMSImpl.getEntityType(clazz)); this.clazz = clazz; } diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/EggController.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/EggController.java index daa0d6207..727a853b3 100644 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/EggController.java +++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/EggController.java @@ -31,9 +31,7 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class EggController extends AbstractEntityController { - public EggController() { - super(EntityEggNPC.class); - } + @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/FallingBlockController.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/FallingBlockController.java index b2dbef6a5..d1e065a2b 100644 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/FallingBlockController.java +++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/FallingBlockController.java @@ -35,9 +35,7 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class FallingBlockController extends AbstractEntityController { - public FallingBlockController() { - super(EntityFallingBlockNPC.class); - } + @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/ItemController.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/ItemController.java index 401eb84f4..83e08d540 100644 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/ItemController.java +++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/ItemController.java @@ -32,9 +32,6 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ItemController extends AbstractEntityController { - public ItemController() { - super(EntityItemNPC.class); - } @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/LlamaSpitController.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/LlamaSpitController.java index cf414174c..7e6dc6fe4 100644 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/LlamaSpitController.java +++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/nonliving/LlamaSpitController.java @@ -32,15 +32,11 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class LlamaSpitController extends AbstractEntityController { - public LlamaSpitController() { - super(EntityLlamaSpitNPC.class); - } @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { ServerLevel ws = ((CraftWorld) at.getWorld()).getHandle(); - final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC( - NMSImpl. getEntityType(EntityLlamaSpitNPC.class), ws, npc); + final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC(EntityType.LLAMA_SPIT, ws, npc); handle.absMoveTo(at.getX(), at.getY(), at.getZ(), at.getPitch(), at.getYaw()); return handle.getBukkitEntity(); } diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java index 4d0712eac..4849932a3 100644 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java +++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java @@ -203,6 +203,7 @@ import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.AreaEffectCloudTrait; import net.citizensnpcs.trait.versioned.AxolotlTrait; import net.citizensnpcs.trait.versioned.BeeTrait; +import net.citizensnpcs.trait.versioned.BoatTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.CatTrait; import net.citizensnpcs.trait.versioned.EnderDragonTrait; @@ -889,6 +890,7 @@ public class NMSImpl implements NMSBridge { @Override public void load(CommandManager manager) { + registerTraitWithCommand(manager, BoatTrait.class); registerTraitWithCommand(manager, AreaEffectCloudTrait.class); registerTraitWithCommand(manager, EnderDragonTrait.class); registerTraitWithCommand(manager, AxolotlTrait.class); @@ -1183,12 +1185,12 @@ public class NMSImpl implements NMSBridge { } @Override - public void registerEntityClass(Class clazz) { + public void registerEntityClass(Class clazz, Object raw) { if (ENTITY_REGISTRY == null) return; + net.minecraft.world.entity.EntityType type = (net.minecraft.world.entity.EntityType) raw; Class search = clazz; while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) { - net.minecraft.world.entity.EntityType type = ENTITY_REGISTRY.findType(search); ResourceLocation key = ENTITY_REGISTRY.getKey(type); if (key == null || type == null) { continue; @@ -2314,11 +2316,11 @@ public class NMSImpl implements NMSBridge { private static final Map, net.minecraft.world.entity.EntityType> CITIZENS_ENTITY_TYPES = Maps .newHashMap(); private static final MethodHandle CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getSetter(CraftBossBar.class, "handle"); - private static EntityDataAccessor DATA_POSE = null; + private static final EntityDataAccessor DATA_POSE = NMS.getStaticObject(Entity.class, "ad"); 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 ENDERMAN_CREEPY = null; + public static final MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EnderDragon.class, + true, boolean.class, AABB.class); + private static final EntityDataAccessor ENDERMAN_CREEPY = NMS.getStaticObject(EnderMan.class, "bV"); 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", true, int.class); @@ -2341,17 +2343,19 @@ public class NMSImpl implements NMSBridge { private static MethodHandle MOVE_CONTROLLER_MOVING = NMS.getSetter(MoveControl.class, "k"); private static final MethodHandle NAVIGATION_CREATE_PATHFINDER = NMS.getMethodHandle(PathNavigation.class, "a", true, int.class); - private static MethodHandle NAVIGATION_PATH = NMS.getGetter(PathNavigation.class, "c"); + private static final MethodHandle NAVIGATION_PATH = NMS.getGetter(PathNavigation.class, "c"); private static final MethodHandle NAVIGATION_PATHFINDER = NMS.getFinalSetter(PathNavigation.class, "t"); private static final MethodHandle NAVIGATION_WORLD_FIELD = NMS.getFirstSetter(PathNavigation.class, Level.class); public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0); - // Player.mobCounts: workaround for an issue which suppresses mobs being spawn near NPC players on Paper. Need to check for every update. + // Player.mobCounts: workaround for an issue which suppresses mobs being spawn near NPC players on Paper. Need to + // check for every update. public static final MethodHandle PAPER_PLAYER_MOB_COUNTS = NMS.getGetter(ServerPlayer.class, "mobCounts", false); private static final MethodHandle PLAYER_CHUNK_MAP_VIEW_DISTANCE_GETTER = NMS.getGetter(ChunkMap.class, "J"); private static final MethodHandle PLAYER_CHUNK_MAP_VIEW_DISTANCE_SETTER = NMS.getSetter(ChunkMap.class, "J"); private static final MethodHandle PUFFERFISH_C = NMS.getSetter(Pufferfish.class, "bU"); private static final MethodHandle PUFFERFISH_D = NMS.getSetter(Pufferfish.class, "bT"); - private static EntityDataAccessor RABBIT_TYPE_DATAWATCHER = null; + private static final EntityDataAccessor RABBIT_TYPE_DATAWATCHER = NMS.getFirstStaticObject(Rabbit.class, + EntityDataAccessor.class); private static final Random RANDOM = Util.getFastRandom(); private static final MethodHandle SERVER_ENTITY_GETTER = NMS.getFirstGetter(TrackedEntity.class, ServerEntity.class); @@ -2368,19 +2372,5 @@ public class NMSImpl implements NMSBridge { } catch (Throwable e) { Messaging.logTr(Messages.ERROR_GETTING_ID_MAPPING, e.getMessage()); } - try { - ENDERMAN_CREEPY = (EntityDataAccessor) NMS.getField(EnderMan.class, "bV").get(null); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - try { - RABBIT_TYPE_DATAWATCHER = (EntityDataAccessor) NMS - .getFirstStaticGetter(Rabbit.class, EntityDataAccessor.class).invoke(); - DATA_POSE = (EntityDataAccessor) NMS.getGetter(Entity.class, "ad").invoke(); - } catch (Throwable e) { - e.printStackTrace(); - } } } diff --git a/v1_18_R2/pom.xml b/v1_18_R2/pom.xml index 0ef34839a..2d77356fa 100644 --- a/v1_18_R2/pom.xml +++ b/v1_18_R2/pom.xml @@ -6,7 +6,7 @@ net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT citizens-v1_18_R2 diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/MobEntityController.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/MobEntityController.java index c317c3bbf..ed718b19d 100644 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/MobEntityController.java +++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/MobEntityController.java @@ -15,6 +15,7 @@ import net.citizensnpcs.nms.v1_18_R2.util.NMSImpl; import net.citizensnpcs.nms.v1_18_R2.util.PitchableLookControl; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.trait.ScoreboardTrait; +import net.citizensnpcs.util.NMS; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.control.LookControl; @@ -24,7 +25,7 @@ public abstract class MobEntityController extends AbstractEntityController { private final Class clazz; protected MobEntityController(Class clazz) { - super(clazz); + NMS.registerEntityClass(clazz, NMSImpl.getEntityType(clazz)); this.clazz = clazz; } diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/EggController.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/EggController.java index da192e26e..409b2777f 100644 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/EggController.java +++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/EggController.java @@ -32,9 +32,7 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class EggController extends AbstractEntityController { - public EggController() { - super(EntityEggNPC.class); - } + @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/FallingBlockController.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/FallingBlockController.java index 25b75cc7b..08a399122 100644 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/FallingBlockController.java +++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/FallingBlockController.java @@ -36,9 +36,7 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class FallingBlockController extends AbstractEntityController { - public FallingBlockController() { - super(EntityFallingBlockNPC.class); - } + @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/ItemController.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/ItemController.java index bad03461c..516c3d3de 100644 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/ItemController.java +++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/ItemController.java @@ -34,9 +34,6 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ItemController extends AbstractEntityController { - public ItemController() { - super(EntityItemNPC.class); - } @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/LlamaSpitController.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/LlamaSpitController.java index 463c54d95..37d5f017f 100644 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/LlamaSpitController.java +++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/nonliving/LlamaSpitController.java @@ -33,15 +33,11 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class LlamaSpitController extends AbstractEntityController { - public LlamaSpitController() { - super(EntityLlamaSpitNPC.class); - } @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { ServerLevel ws = ((CraftWorld) at.getWorld()).getHandle(); - final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC( - NMSImpl. getEntityType(EntityLlamaSpitNPC.class), ws, npc); + final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC(EntityType.LLAMA_SPIT, ws, npc); handle.absMoveTo(at.getX(), at.getY(), at.getZ(), at.getPitch(), at.getYaw()); return handle.getBukkitEntity(); } diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java index 144a502cf..61cd0d47c 100644 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java +++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java @@ -204,6 +204,7 @@ import net.citizensnpcs.trait.RotationTrait; import net.citizensnpcs.trait.versioned.AreaEffectCloudTrait; import net.citizensnpcs.trait.versioned.AxolotlTrait; import net.citizensnpcs.trait.versioned.BeeTrait; +import net.citizensnpcs.trait.versioned.BoatTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.CatTrait; import net.citizensnpcs.trait.versioned.EnderDragonTrait; @@ -896,6 +897,7 @@ public class NMSImpl implements NMSBridge { @Override public void load(CommandManager manager) { + registerTraitWithCommand(manager, BoatTrait.class); registerTraitWithCommand(manager, AreaEffectCloudTrait.class); registerTraitWithCommand(manager, EnderDragonTrait.class); registerTraitWithCommand(manager, AxolotlTrait.class); @@ -1192,12 +1194,12 @@ public class NMSImpl implements NMSBridge { } @Override - public void registerEntityClass(Class clazz) { + public void registerEntityClass(Class clazz, Object raw) { if (ENTITY_REGISTRY == null) return; + net.minecraft.world.entity.EntityType type = (net.minecraft.world.entity.EntityType) raw; Class search = clazz; while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) { - net.minecraft.world.entity.EntityType type = ENTITY_REGISTRY.findType(search); ResourceLocation key = ENTITY_REGISTRY.getKey(type); if (key == null || type == null) { continue; @@ -2358,11 +2360,11 @@ public class NMSImpl implements NMSBridge { private static final Map, net.minecraft.world.entity.EntityType> CITIZENS_ENTITY_TYPES = Maps .newHashMap(); private static final MethodHandle CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getSetter(CraftBossBar.class, "handle"); - private static EntityDataAccessor DATA_POSE = null; + private static final EntityDataAccessor DATA_POSE = NMS.getStaticObject(Entity.class, "ad"); 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 ENDERMAN_CREEPY = null; + private static final EntityDataAccessor ENDERMAN_CREEPY = NMS.getStaticObject(EnderMan.class, "bX"); private static final MethodHandle ENTITY_FISH_NUM_IN_SCHOOL = NMS.getFirstSetter(AbstractSchoolingFish.class, int.class); private static final MethodHandle ENTITY_GET_SOUND_FALL = NMS.getMethodHandle(LivingEntity.class, "c", true, @@ -2394,7 +2396,8 @@ public class NMSImpl implements NMSBridge { private static final MethodHandle NAVIGATION_PATHFINDER = NMS.getFinalSetter(PathNavigation.class, "t"); private static final MethodHandle NAVIGATION_WORLD_FIELD = NMS.getFirstSetter(PathNavigation.class, Level.class); public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0); - // Player.mobCounts: workaround for an issue which suppresses mobs being spawn near NPC players on Paper. Need to check for every update. + // Player.mobCounts: workaround for an issue which suppresses mobs being spawn near NPC players on Paper. Need to + // check for every update. public static final MethodHandle PAPER_PLAYER_MOB_COUNTS = NMS.getGetter(ServerPlayer.class, "mobCounts", false); private static final MethodHandle PLAYER_CHUNK_MAP_VIEW_DISTANCE_GETTER = NMS.getGetter(ChunkMap.class, "N"); private static final MethodHandle PLAYER_CHUNK_MAP_VIEW_DISTANCE_SETTER = NMS.getSetter(ChunkMap.class, "N"); @@ -2402,7 +2405,8 @@ public class NMSImpl implements NMSBridge { private static MethodHandle PORTAL_ENTRANCE_POS_SETTER = NMS.getSetter(Entity.class, "ai"); private static final MethodHandle PUFFERFISH_C = NMS.getSetter(Pufferfish.class, "bV"); private static final MethodHandle PUFFERFISH_D = NMS.getSetter(Pufferfish.class, "bW"); - private static EntityDataAccessor RABBIT_TYPE_DATAWATCHER = null; + private static final EntityDataAccessor RABBIT_TYPE_DATAWATCHER = NMS.getFirstStaticObject(Rabbit.class, + EntityDataAccessor.class); private static final Random RANDOM = Util.getFastRandom(); private static final MethodHandle SERVER_ENTITY_GETTER = NMS.getFirstGetter(TrackedEntity.class, ServerEntity.class); @@ -2419,19 +2423,5 @@ public class NMSImpl implements NMSBridge { } catch (Throwable e) { Messaging.logTr(Messages.ERROR_GETTING_ID_MAPPING, e.getMessage()); } - try { - ENDERMAN_CREEPY = (EntityDataAccessor) NMS.getField(EnderMan.class, "bX").get(null); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - try { - RABBIT_TYPE_DATAWATCHER = (EntityDataAccessor) NMS - .getFirstStaticGetter(Rabbit.class, EntityDataAccessor.class).invoke(); - DATA_POSE = (EntityDataAccessor) NMS.getGetter(Entity.class, "ad").invoke(); - } catch (Throwable e) { - e.printStackTrace(); - } } } diff --git a/v1_19_R3/pom.xml b/v1_19_R3/pom.xml index 045001567..0a1ff3ad6 100644 --- a/v1_19_R3/pom.xml +++ b/v1_19_R3/pom.xml @@ -4,7 +4,7 @@ net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT citizens-v1_19_R3 diff --git a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/MobEntityController.java b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/MobEntityController.java index 2cc93d43c..38e814614 100644 --- a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/MobEntityController.java +++ b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/MobEntityController.java @@ -15,6 +15,7 @@ import net.citizensnpcs.nms.v1_19_R3.util.NMSImpl; import net.citizensnpcs.nms.v1_19_R3.util.PitchableLookControl; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.trait.ScoreboardTrait; +import net.citizensnpcs.util.NMS; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.control.LookControl; @@ -24,7 +25,7 @@ public abstract class MobEntityController extends AbstractEntityController { private final Class clazz; protected MobEntityController(Class clazz) { - super(clazz); + NMS.registerEntityClass(clazz, NMSImpl.getEntityType(clazz)); this.clazz = clazz; } diff --git a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/EggController.java b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/EggController.java index 211808072..56f5c19e2 100644 --- a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/EggController.java +++ b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/EggController.java @@ -32,9 +32,7 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class EggController extends AbstractEntityController { - public EggController() { - super(EntityEggNPC.class); - } + @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/FallingBlockController.java b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/FallingBlockController.java index 18eb9d3ca..f3ca3dd93 100644 --- a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/FallingBlockController.java +++ b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/FallingBlockController.java @@ -35,9 +35,7 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class FallingBlockController extends AbstractEntityController { - public FallingBlockController() { - super(EntityFallingBlockNPC.class); - } + @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/ItemController.java b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/ItemController.java index 7d34261eb..596a34830 100644 --- a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/ItemController.java +++ b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/ItemController.java @@ -34,9 +34,6 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ItemController extends AbstractEntityController { - public ItemController() { - super(EntityItemNPC.class); - } @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/LlamaSpitController.java b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/LlamaSpitController.java index 8f23682b0..cb5363a3a 100644 --- a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/LlamaSpitController.java +++ b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/nonliving/LlamaSpitController.java @@ -33,15 +33,11 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class LlamaSpitController extends AbstractEntityController { - public LlamaSpitController() { - super(EntityLlamaSpitNPC.class); - } @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { ServerLevel ws = ((CraftWorld) at.getWorld()).getHandle(); - final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC( - NMSImpl. getEntityType(EntityLlamaSpitNPC.class), ws, npc); + final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC(EntityType.LLAMA_SPIT, ws, npc); handle.absMoveTo(at.getX(), at.getY(), at.getZ(), at.getPitch(), at.getYaw()); return handle.getBukkitEntity(); } diff --git a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java index 4d1e7f20b..632c8b2d2 100644 --- a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java +++ b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/NMSImpl.java @@ -224,6 +224,7 @@ import net.citizensnpcs.trait.versioned.AllayTrait; import net.citizensnpcs.trait.versioned.AreaEffectCloudTrait; import net.citizensnpcs.trait.versioned.AxolotlTrait; import net.citizensnpcs.trait.versioned.BeeTrait; +import net.citizensnpcs.trait.versioned.BoatTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.CamelTrait; import net.citizensnpcs.trait.versioned.CamelTrait.CamelPose; @@ -945,6 +946,7 @@ public class NMSImpl implements NMSBridge { @Override public void load(CommandManager manager) { + registerTraitWithCommand(manager, BoatTrait.class); registerTraitWithCommand(manager, AreaEffectCloudTrait.class); registerTraitWithCommand(manager, EnderDragonTrait.class); registerTraitWithCommand(manager, AllayTrait.class); @@ -1331,12 +1333,12 @@ public class NMSImpl implements NMSBridge { } @Override - public void registerEntityClass(Class clazz) { + public void registerEntityClass(Class clazz, Object raw) { if (ENTITY_REGISTRY == null) return; + net.minecraft.world.entity.EntityType type = (net.minecraft.world.entity.EntityType) raw; Class search = clazz; while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) { - net.minecraft.world.entity.EntityType type = ENTITY_REGISTRY.findType(search); ResourceLocation key = ENTITY_REGISTRY.getKey(type); if (key == null || type == null) { continue; @@ -2577,7 +2579,6 @@ public class NMSImpl implements NMSBridge { } 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); private static final MethodHandle ATTRIBUTE_SUPPLIER = NMS.getFirstGetter(AttributeMap.class, @@ -2594,15 +2595,15 @@ public class NMSImpl implements NMSBridge { .newHashMap(); private static final MethodHandle CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getFirstSetter(CraftBossBar.class, ServerBossEvent.class); - private static EntityDataAccessor DATA_NAME_VISIBLE = null; - private static EntityDataAccessor DATA_POSE = null; + private static final EntityDataAccessor DATA_NAME_VISIBLE = NMS.getStaticObject(Entity.class, "aS"); + private static final EntityDataAccessor DATA_POSE = NMS.getStaticObject(Entity.class, "ar"); 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 ENDERMAN_CREEPY = null; + public static final MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EnderDragon.class, + true, boolean.class, AABB.class); + private static final EntityDataAccessor ENDERMAN_CREEPY = NMS.getStaticObject(EnderMan.class, "bU"); private static final MethodHandle ENTITY_FISH_NUM_IN_SCHOOL = NMS.getFirstSetter(AbstractSchoolingFish.class, int.class); - private static MethodHandle ENTITY_NAVIGATION = NMS.getFirstSetter(Mob.class, PathNavigation.class); + private static final MethodHandle ENTITY_NAVIGATION = NMS.getFirstSetter(Mob.class, PathNavigation.class); private static CustomEntityRegistry ENTITY_REGISTRY; private static MethodHandle ENTITY_REGISTRY_SETTER; private static final MethodHandle FALLING_BLOCK_STATE_SETTER = NMS.getFirstSetter(FallingBlockEntity.class, @@ -2619,8 +2620,8 @@ public class NMSImpl implements NMSBridge { private static final MethodHandle HEAD_HEIGHT = NMS.getSetter(Entity.class, "bf"); private static final MethodHandle HEAD_HEIGHT_METHOD = NMS.getFirstMethodHandle(Entity.class, true, Pose.class, EntityDimensions.class); - private static EntityDataAccessor INTERACTION_HEIGHT = null; - private static EntityDataAccessor INTERACTION_WIDTH = null; + private static final EntityDataAccessor INTERACTION_HEIGHT = NMS.getStaticObject(Interaction.class, "d"); + private static final EntityDataAccessor INTERACTION_WIDTH = NMS.getStaticObject(Interaction.class, "c"); private static final MethodHandle JUMP_FIELD = NMS.getGetter(LivingEntity.class, "bi"); private static final MethodHandle LOOK_CONTROL_SETTER = NMS.getFirstSetter(Mob.class, LookControl.class); private static final MethodHandle MAKE_REQUEST = NMS.getMethodHandle(YggdrasilAuthenticationService.class, @@ -2632,7 +2633,8 @@ public class NMSImpl implements NMSBridge { private static final MethodHandle NAVIGATION_PATHFINDER = NMS.getFirstFinalSetter(PathNavigation.class, PathFinder.class); private static final MethodHandle NAVIGATION_WORLD_FIELD = NMS.getFirstSetter(PathNavigation.class, Level.class); - // Player.mobCounts: workaround for an issue which suppresses mobs being spawn near NPC players on Paper. Need to check for every update. + // Player.mobCounts: workaround for an issue which suppresses mobs being spawn near NPC players on Paper. Need to + // check for every update. public static final MethodHandle PAPER_PLAYER_MOB_COUNTS = NMS.getGetter(ServerPlayer.class, "mobCounts", false); private static final MethodHandle PLAYER_CHUNK_MAP_VIEW_DISTANCE_GETTER = NMS.getFirstGetter(ChunkMap.class, int.class); @@ -2641,13 +2643,14 @@ public class NMSImpl implements NMSBridge { private static final MethodHandle PLAYER_INFO_ENTRIES_LIST = NMS .getFirstFinalSetter(ClientboundPlayerInfoUpdatePacket.class, List.class); private static final MethodHandle PLAYERINFO_ENTRIES = PLAYER_INFO_ENTRIES_LIST; - private static MethodHandle PORTAL_ENTRANCE_POS_GETTER = NMS.getGetter(Entity.class, "aw"); - private static MethodHandle PORTAL_ENTRANCE_POS_SETTER = NMS.getSetter(Entity.class, "aw"); + private static final MethodHandle PORTAL_ENTRANCE_POS_GETTER = NMS.getGetter(Entity.class, "aw"); + private static final MethodHandle PORTAL_ENTRANCE_POS_SETTER = NMS.getSetter(Entity.class, "aw"); private static final MethodHandle POSITION_CODEC_GETTER = NMS.getFirstGetter(ServerEntity.class, VecDeltaCodec.class); private static final MethodHandle PUFFERFISH_C = NMS.getSetter(Pufferfish.class, "bS"); private static final MethodHandle PUFFERFISH_D = NMS.getSetter(Pufferfish.class, "bT"); - private static EntityDataAccessor RABBIT_TYPE_DATAWATCHER = null; + private static final EntityDataAccessor RABBIT_TYPE_DATAWATCHER = NMS.getFirstStaticObject(Rabbit.class, + EntityDataAccessor.class); private static final Random RANDOM = Util.getFastRandom(); private static final MethodHandle SERVER_ENTITY_GETTER = NMS.getFirstGetter(TrackedEntity.class, ServerEntity.class); @@ -2665,33 +2668,5 @@ public class NMSImpl implements NMSBridge { Messaging.logTr(Messages.ERROR_GETTING_ID_MAPPING, e.getMessage()); e.printStackTrace(); } - try { - // Middle one - ENDERMAN_CREEPY = (EntityDataAccessor) NMS.getField(EnderMan.class, "bU").get(null); - } catch (Exception e) { - e.printStackTrace(); - } - try { - RABBIT_TYPE_DATAWATCHER = (EntityDataAccessor) NMS - .getFirstStaticGetter(Rabbit.class, EntityDataAccessor.class).invoke(); - } catch (Throwable e) { - e.printStackTrace(); - } - try { - INTERACTION_HEIGHT = (EntityDataAccessor) NMS.getGetter(Interaction.class, "d").invoke(); - } catch (Throwable e) { - e.printStackTrace(); - } - try { - INTERACTION_WIDTH = (EntityDataAccessor) NMS.getGetter(Interaction.class, "c").invoke(); - } catch (Throwable e) { - e.printStackTrace(); - } - try { - DATA_POSE = (EntityDataAccessor) NMS.getGetter(Entity.class, "ar").invoke(); - DATA_NAME_VISIBLE = (EntityDataAccessor) NMS.getGetter(Entity.class, "aS").invoke(); - } catch (Throwable e) { - e.printStackTrace(); - } } } diff --git a/v1_20_R4/pom.xml b/v1_20_R4/pom.xml index 1c0ab862b..ec40aebef 100644 --- a/v1_20_R4/pom.xml +++ b/v1_20_R4/pom.xml @@ -4,7 +4,7 @@ net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT citizens-v1_20_R4 diff --git a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/MobEntityController.java b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/MobEntityController.java index d4a7c490e..58ce91e37 100644 --- a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/MobEntityController.java +++ b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/MobEntityController.java @@ -15,6 +15,7 @@ import net.citizensnpcs.nms.v1_20_R4.util.NMSImpl; import net.citizensnpcs.nms.v1_20_R4.util.PitchableLookControl; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.trait.ScoreboardTrait; +import net.citizensnpcs.util.NMS; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.control.LookControl; @@ -24,7 +25,7 @@ public abstract class MobEntityController extends AbstractEntityController { private final Class clazz; protected MobEntityController(Class clazz) { - super(clazz); + NMS.registerEntityClass(clazz, NMSImpl.getEntityType(clazz)); this.clazz = clazz; } diff --git a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/EggController.java b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/EggController.java index fe5f4e4e6..51a71b893 100644 --- a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/EggController.java +++ b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/EggController.java @@ -30,10 +30,6 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class EggController extends AbstractEntityController { - public EggController() { - super(EntityEggNPC.class); - } - @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { ServerLevel ws = ((CraftWorld) at.getWorld()).getHandle(); diff --git a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/FallingBlockController.java b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/FallingBlockController.java index 37b28e770..7f0d8e47f 100644 --- a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/FallingBlockController.java +++ b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/FallingBlockController.java @@ -33,9 +33,7 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class FallingBlockController extends AbstractEntityController { - public FallingBlockController() { - super(EntityFallingBlockNPC.class); - } + @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/ItemController.java b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/ItemController.java index 147fff823..6e71bf427 100644 --- a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/ItemController.java +++ b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/ItemController.java @@ -32,9 +32,6 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ItemController extends AbstractEntityController { - public ItemController() { - super(EntityItemNPC.class); - } @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/LlamaSpitController.java b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/LlamaSpitController.java index 15eaf9faa..5c03a2878 100644 --- a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/LlamaSpitController.java +++ b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/nonliving/LlamaSpitController.java @@ -31,15 +31,10 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class LlamaSpitController extends AbstractEntityController { - public LlamaSpitController() { - super(EntityLlamaSpitNPC.class); - } - @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { ServerLevel ws = ((CraftWorld) at.getWorld()).getHandle(); - final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC( - NMSImpl. getEntityType(EntityLlamaSpitNPC.class), ws, npc); + final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC(EntityType.LLAMA_SPIT, ws, npc); handle.absMoveTo(at.getX(), at.getY(), at.getZ(), at.getPitch(), at.getYaw()); return handle.getBukkitEntity(); } diff --git a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/util/NMSImpl.java b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/util/NMSImpl.java index aa54b4b51..368c373c7 100644 --- a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/util/NMSImpl.java +++ b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/util/NMSImpl.java @@ -228,6 +228,7 @@ import net.citizensnpcs.trait.versioned.ArmadilloTrait; import net.citizensnpcs.trait.versioned.ArmadilloTrait.ArmadilloState; import net.citizensnpcs.trait.versioned.AxolotlTrait; import net.citizensnpcs.trait.versioned.BeeTrait; +import net.citizensnpcs.trait.versioned.BoatTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.CamelTrait; import net.citizensnpcs.trait.versioned.CamelTrait.CamelPose; @@ -968,6 +969,7 @@ public class NMSImpl implements NMSBridge { @Override public void load(CommandManager manager) { + registerTraitWithCommand(manager, BoatTrait.class); registerTraitWithCommand(manager, AreaEffectCloudTrait.class); registerTraitWithCommand(manager, EnderDragonTrait.class); registerTraitWithCommand(manager, AllayTrait.class); @@ -1363,16 +1365,16 @@ public class NMSImpl implements NMSBridge { } @Override - public void registerEntityClass(Class clazz) { + public void registerEntityClass(Class clazz, Object raw) { if (ENTITY_REGISTRY == null) return; + net.minecraft.world.entity.EntityType type = (net.minecraft.world.entity.EntityType) raw; Class search = clazz; while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) { - net.minecraft.world.entity.EntityType type = ENTITY_REGISTRY.findType(search); ResourceLocation key = ENTITY_REGISTRY.getKey(type); - if (key == null || type == null) { + if (key == null || type == null) continue; - } + CITIZENS_ENTITY_TYPES.put(clazz, type); int code = ENTITY_REGISTRY.getId(type); ENTITY_REGISTRY.put(code, key, type); @@ -2661,12 +2663,9 @@ public class NMSImpl implements NMSBridge { } private static final MethodHandle ARMADILLO_SCUTE_TIME = NMS.getSetter(Armadillo.class, "cj"); - 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); - private static final MethodHandle ATTRIBUTE_SUPPLIER = NMS.getFirstGetter(AttributeMap.class, AttributeSupplier.class); private static final MethodHandle AVAILABLE_BEHAVIORS_BY_PRIORITY = NMS.getGetter(Brain.class, "f"); @@ -2683,15 +2682,15 @@ public class NMSImpl implements NMSBridge { public static final MethodHandle CONNECTION_PACKET_LISTENER = NMS.getSetter(Connection.class, "q"); private static final MethodHandle CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getFirstSetter(CraftBossBar.class, ServerBossEvent.class); - private static EntityDataAccessor DATA_NAME_VISIBLE = null; - private static EntityDataAccessor DATA_POSE = null; + private static final EntityDataAccessor DATA_NAME_VISIBLE = NMS.getStaticObject(Entity.class, "aT"); + private static final EntityDataAccessor DATA_POSE = NMS.getStaticObject(Entity.class, "at"); private static final float DEFAULT_SPEED = 1F; public static final MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EnderDragon.class, true, boolean.class, AABB.class); public static final MethodHandle ENDERDRAGON_HURT = NMS.getMethodHandle(EnderDragon.class, "c", true, List.class); public static final MethodHandle ENDERDRAGON_KNOCKBACK = NMS.getMethodHandle(EnderDragon.class, "b", true, List.class); - private static EntityDataAccessor ENDERMAN_CREEPY = null; + private static final EntityDataAccessor ENDERMAN_CREEPY = NMS.getStaticObject(EnderMan.class, "ca"); private static final MethodHandle ENTITY_FISH_NUM_IN_SCHOOL = NMS.getFirstSetter(AbstractSchoolingFish.class, int.class); private static MethodHandle ENTITY_NAVIGATION = NMS.getFirstSetter(Mob.class, PathNavigation.class); @@ -2709,8 +2708,8 @@ public class NMSImpl implements NMSBridge { boolean.class); private static final Location FROM_LOCATION = new Location(null, 0, 0, 0); private static final MethodHandle HEAD_HEIGHT = NMS.getSetter(Entity.class, "bg"); - private static EntityDataAccessor INTERACTION_HEIGHT = null; - private static EntityDataAccessor INTERACTION_WIDTH = null; + private static final EntityDataAccessor INTERACTION_HEIGHT = NMS.getStaticObject(Interaction.class, "d"); + private static final EntityDataAccessor INTERACTION_WIDTH = NMS.getStaticObject(Interaction.class, "c"); private static final MethodHandle JUMP_FIELD = NMS.getGetter(LivingEntity.class, "bn"); private static final MethodHandle LOOK_CONTROL_SETTER = NMS.getFirstSetter(Mob.class, LookControl.class); private static MethodHandle META_COMPOUND_TAG; @@ -2723,7 +2722,8 @@ public class NMSImpl implements NMSBridge { private static final MethodHandle NAVIGATION_PATHFINDER = NMS.getFirstFinalSetter(PathNavigation.class, PathFinder.class); private static final MethodHandle NAVIGATION_WORLD_FIELD = NMS.getFirstSetter(PathNavigation.class, Level.class); - // Player.mobCounts: workaround for an issue which suppresses mobs being spawn near NPC players on Paper. Need to check for every update. + // Player.mobCounts: workaround for an issue which suppresses mobs being spawn near NPC players on Paper. Need to + // check for every update. public static final MethodHandle PAPER_PLAYER_MOB_COUNTS = NMS.getGetter(ServerPlayer.class, "mobCounts", false); private static final MethodHandle PLAYER_INFO_ENTRIES_LIST = NMS @@ -2735,7 +2735,8 @@ public class NMSImpl implements NMSBridge { VecDeltaCodec.class); private static final MethodHandle PUFFERFISH_DEFLATE = NMS.getSetter(Pufferfish.class, "bZ"); private static final MethodHandle PUFFERFISH_INFLATE = NMS.getSetter(Pufferfish.class, "bY"); - public static EntityDataAccessor RABBIT_TYPE_DATAWATCHER = null; + public static EntityDataAccessor RABBIT_TYPE_DATAWATCHER = NMS.getFirstStaticObject(Rabbit.class, + EntityDataAccessor.class); private static final Random RANDOM = Util.getFastRandom(); private static final MethodHandle SERVER_ENTITY_GETTER = NMS.getFirstGetter(TrackedEntity.class, ServerEntity.class); @@ -2753,28 +2754,5 @@ public class NMSImpl implements NMSBridge { } catch (Throwable e) { Messaging.logTr(Messages.ERROR_GETTING_ID_MAPPING, e.getMessage()); } - try { - // Middle one - ENDERMAN_CREEPY = (EntityDataAccessor) NMS.getField(EnderMan.class, "ca").get(null); - } catch (Exception e) { - } - try { - RABBIT_TYPE_DATAWATCHER = (EntityDataAccessor) NMS - .getFirstStaticGetter(Rabbit.class, EntityDataAccessor.class).invoke(); - } catch (Throwable e) { - } - try { - INTERACTION_HEIGHT = (EntityDataAccessor) NMS.getGetter(Interaction.class, "d").invoke(); - } catch (Throwable e) { - } - try { - INTERACTION_WIDTH = (EntityDataAccessor) NMS.getGetter(Interaction.class, "c").invoke(); - } catch (Throwable e) { - } - try { - DATA_POSE = (EntityDataAccessor) NMS.getGetter(Entity.class, "at").invoke(); - DATA_NAME_VISIBLE = (EntityDataAccessor) NMS.getGetter(Entity.class, "aT").invoke(); - } catch (Throwable e) { - } } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/CustomEntityRegistry.java b/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/CustomEntityRegistry.java deleted file mode 100644 index d60d95168..000000000 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/CustomEntityRegistry.java +++ /dev/null @@ -1,481 +0,0 @@ -package net.citizensnpcs.nms.v1_21_R1.util; - -import java.lang.invoke.MethodHandle; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Optional; -import java.util.Set; -import java.util.function.Supplier; -import java.util.stream.Stream; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import com.google.common.collect.Maps; -import com.mojang.datafixers.util.Pair; -import com.mojang.serialization.Lifecycle; - -import net.citizensnpcs.util.NMS; -import net.minecraft.core.DefaultedMappedRegistry; -import net.minecraft.core.DefaultedRegistry; -import net.minecraft.core.Holder; -import net.minecraft.core.Holder.Reference; -import net.minecraft.core.HolderGetter; -import net.minecraft.core.HolderLookup.RegistryLookup; -import net.minecraft.core.HolderOwner; -import net.minecraft.core.HolderSet.Named; -import net.minecraft.core.MappedRegistry; -import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.util.RandomSource; -import net.minecraft.world.entity.AreaEffectCloud; -import net.minecraft.world.entity.Display; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.ExperienceOrb; -import net.minecraft.world.entity.GlowSquid; -import net.minecraft.world.entity.Interaction; -import net.minecraft.world.entity.LightningBolt; -import net.minecraft.world.entity.Marker; -import net.minecraft.world.entity.OminousItemSpawner; -import net.minecraft.world.entity.ambient.Bat; -import net.minecraft.world.entity.animal.Bee; -import net.minecraft.world.entity.animal.Cat; -import net.minecraft.world.entity.animal.Chicken; -import net.minecraft.world.entity.animal.Cod; -import net.minecraft.world.entity.animal.Cow; -import net.minecraft.world.entity.animal.Dolphin; -import net.minecraft.world.entity.animal.Fox; -import net.minecraft.world.entity.animal.IronGolem; -import net.minecraft.world.entity.animal.MushroomCow; -import net.minecraft.world.entity.animal.Ocelot; -import net.minecraft.world.entity.animal.Panda; -import net.minecraft.world.entity.animal.Parrot; -import net.minecraft.world.entity.animal.Pig; -import net.minecraft.world.entity.animal.PolarBear; -import net.minecraft.world.entity.animal.Pufferfish; -import net.minecraft.world.entity.animal.Rabbit; -import net.minecraft.world.entity.animal.Salmon; -import net.minecraft.world.entity.animal.Sheep; -import net.minecraft.world.entity.animal.SnowGolem; -import net.minecraft.world.entity.animal.Squid; -import net.minecraft.world.entity.animal.TropicalFish; -import net.minecraft.world.entity.animal.Turtle; -import net.minecraft.world.entity.animal.Wolf; -import net.minecraft.world.entity.animal.allay.Allay; -import net.minecraft.world.entity.animal.armadillo.Armadillo; -import net.minecraft.world.entity.animal.axolotl.Axolotl; -import net.minecraft.world.entity.animal.camel.Camel; -import net.minecraft.world.entity.animal.frog.Frog; -import net.minecraft.world.entity.animal.frog.Tadpole; -import net.minecraft.world.entity.animal.goat.Goat; -import net.minecraft.world.entity.animal.horse.Donkey; -import net.minecraft.world.entity.animal.horse.Horse; -import net.minecraft.world.entity.animal.horse.Llama; -import net.minecraft.world.entity.animal.horse.Mule; -import net.minecraft.world.entity.animal.horse.SkeletonHorse; -import net.minecraft.world.entity.animal.horse.TraderLlama; -import net.minecraft.world.entity.animal.horse.ZombieHorse; -import net.minecraft.world.entity.animal.sniffer.Sniffer; -import net.minecraft.world.entity.boss.enderdragon.EndCrystal; -import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.entity.boss.wither.WitherBoss; -import net.minecraft.world.entity.decoration.ArmorStand; -import net.minecraft.world.entity.decoration.GlowItemFrame; -import net.minecraft.world.entity.decoration.ItemFrame; -import net.minecraft.world.entity.decoration.LeashFenceKnotEntity; -import net.minecraft.world.entity.decoration.Painting; -import net.minecraft.world.entity.item.FallingBlockEntity; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.item.PrimedTnt; -import net.minecraft.world.entity.monster.Blaze; -import net.minecraft.world.entity.monster.Bogged; -import net.minecraft.world.entity.monster.CaveSpider; -import net.minecraft.world.entity.monster.Creeper; -import net.minecraft.world.entity.monster.Drowned; -import net.minecraft.world.entity.monster.ElderGuardian; -import net.minecraft.world.entity.monster.EnderMan; -import net.minecraft.world.entity.monster.Endermite; -import net.minecraft.world.entity.monster.Evoker; -import net.minecraft.world.entity.monster.Ghast; -import net.minecraft.world.entity.monster.Giant; -import net.minecraft.world.entity.monster.Guardian; -import net.minecraft.world.entity.monster.Husk; -import net.minecraft.world.entity.monster.Illusioner; -import net.minecraft.world.entity.monster.MagmaCube; -import net.minecraft.world.entity.monster.Phantom; -import net.minecraft.world.entity.monster.Pillager; -import net.minecraft.world.entity.monster.Ravager; -import net.minecraft.world.entity.monster.Shulker; -import net.minecraft.world.entity.monster.Silverfish; -import net.minecraft.world.entity.monster.Skeleton; -import net.minecraft.world.entity.monster.Slime; -import net.minecraft.world.entity.monster.Spider; -import net.minecraft.world.entity.monster.Stray; -import net.minecraft.world.entity.monster.Strider; -import net.minecraft.world.entity.monster.Vex; -import net.minecraft.world.entity.monster.Vindicator; -import net.minecraft.world.entity.monster.Witch; -import net.minecraft.world.entity.monster.WitherSkeleton; -import net.minecraft.world.entity.monster.Zoglin; -import net.minecraft.world.entity.monster.Zombie; -import net.minecraft.world.entity.monster.ZombieVillager; -import net.minecraft.world.entity.monster.ZombifiedPiglin; -import net.minecraft.world.entity.monster.breeze.Breeze; -import net.minecraft.world.entity.monster.hoglin.Hoglin; -import net.minecraft.world.entity.monster.piglin.Piglin; -import net.minecraft.world.entity.monster.piglin.PiglinBrute; -import net.minecraft.world.entity.monster.warden.Warden; -import net.minecraft.world.entity.npc.Villager; -import net.minecraft.world.entity.npc.WanderingTrader; -import net.minecraft.world.entity.projectile.Arrow; -import net.minecraft.world.entity.projectile.DragonFireball; -import net.minecraft.world.entity.projectile.EvokerFangs; -import net.minecraft.world.entity.projectile.EyeOfEnder; -import net.minecraft.world.entity.projectile.FireworkRocketEntity; -import net.minecraft.world.entity.projectile.FishingHook; -import net.minecraft.world.entity.projectile.LargeFireball; -import net.minecraft.world.entity.projectile.LlamaSpit; -import net.minecraft.world.entity.projectile.ShulkerBullet; -import net.minecraft.world.entity.projectile.SmallFireball; -import net.minecraft.world.entity.projectile.Snowball; -import net.minecraft.world.entity.projectile.SpectralArrow; -import net.minecraft.world.entity.projectile.ThrownEgg; -import net.minecraft.world.entity.projectile.ThrownEnderpearl; -import net.minecraft.world.entity.projectile.ThrownExperienceBottle; -import net.minecraft.world.entity.projectile.ThrownPotion; -import net.minecraft.world.entity.projectile.ThrownTrident; -import net.minecraft.world.entity.projectile.WitherSkull; -import net.minecraft.world.entity.projectile.windcharge.BreezeWindCharge; -import net.minecraft.world.entity.projectile.windcharge.WindCharge; -import net.minecraft.world.entity.vehicle.Boat; -import net.minecraft.world.entity.vehicle.ChestBoat; -import net.minecraft.world.entity.vehicle.Minecart; -import net.minecraft.world.entity.vehicle.MinecartChest; -import net.minecraft.world.entity.vehicle.MinecartCommandBlock; -import net.minecraft.world.entity.vehicle.MinecartFurnace; -import net.minecraft.world.entity.vehicle.MinecartHopper; -import net.minecraft.world.entity.vehicle.MinecartSpawner; -import net.minecraft.world.entity.vehicle.MinecartTNT; - -@SuppressWarnings("rawtypes") -public class CustomEntityRegistry extends DefaultedMappedRegistry> - implements Supplier>> { - private final BiMap entities = HashBiMap.create(); - private final BiMap entityClasses = this.entities.inverse(); - private final Map entityIds = Maps.newHashMap(); - private final MappedRegistry> wrapped; - - public CustomEntityRegistry(DefaultedRegistry> original) throws Throwable { - super(original.getDefaultKey().getNamespace(), - (ResourceKey>>) IREGISTRY_RESOURCE_KEY.invoke(original), - (Lifecycle) IREGISTRY_LIFECYCLE.invoke(original), true); - this.wrapped = (MappedRegistry>) original; - } - - @Override - public RegistryLookup> asLookup() { - return wrapped.asLookup(); - } - - @Override - public void bindTags(Map>, List>>> map) { - wrapped.bindTags(map); - } - - @Override - public EntityType byId(int var0) { - return this.wrapped.byId(var0); - } - - @Override - public EntityType byIdOrThrow(int var0) { - return this.wrapped.byIdOrThrow(var0); - } - - @Override - public boolean containsKey(ResourceKey> var0) { - return this.wrapped.containsKey(var0); - } - - @Override - public boolean containsKey(ResourceLocation var0) { - return this.wrapped.containsKey(var0); - } - - @Override - public HolderGetter> createRegistrationLookup() { - return wrapped.createRegistrationLookup(); - } - - @Override - public Set>, EntityType>> entrySet() { - return wrapped.entrySet(); - } - - public EntityType findType(Class search) { - return minecraftClassMap.inverse().get(search); - } - - @Override - public MappedRegistry> get() { - return wrapped; - } - - @Override - public EntityType get(ResourceKey> key) { - return wrapped.get(key); - } - - @Override - public EntityType get(ResourceLocation key) { - if (entities.containsKey(key)) - return entities.get(key); - return wrapped.get(key); - } - - @Override - public Optional>> getHolder(int var0) { - return this.wrapped.getHolder(var0); - } - - @Override - public Optional>> getHolder(ResourceKey> var0) { - return this.wrapped.getHolder(var0); - } - - @Override - public int getId(EntityType key) { - if (entityIds.containsKey(key)) - return entityIds.get(key); - return wrapped.getId(key); - } - - @Override - public ResourceLocation getKey(EntityType value) { - if (entityClasses.containsKey(value)) - return entityClasses.get(value); - return wrapped.getKey(value); - } - - @Override - public Optional> getOptional(ResourceKey> var0) { - return this.wrapped.getOptional(var0); - } - - @Override - public Optional> getOptional(ResourceLocation var0) { - if (entities.containsKey(var0)) - return Optional.of(entities.get(var0)); - return this.wrapped.getOptional(var0); - } - - @Override - public Optional>> getRandom(RandomSource paramRandom) { - return wrapped.getRandom(paramRandom); - } - - @Override - public Optional>> getResourceKey(EntityType var0) { - return wrapped.getResourceKey(var0); - } - - @Override - public Optional>> getTag(TagKey> var0) { - return this.wrapped.getTag(var0); - } - - @Override - public Stream>> getTagNames() { - return wrapped.getTagNames(); - } - - @Override - public Stream>, Named>>> getTags() { - return wrapped.getTags(); - } - - @Override - public HolderOwner> holderOwner() { - return wrapped.holderOwner(); - } - - @Override - public Stream>> holders() { - return wrapped.holders(); - } - - @Override - public boolean isEmpty() { - return wrapped.isEmpty(); - } - - @Override - public Iterator> iterator() { - return wrapped.iterator(); - } - - @Override - public Set keySet() { - return wrapped.keySet(); - } - - public void put(int entityId, ResourceLocation key, EntityType entityClass) { - entities.put(key, entityClass); - entityIds.put(entityClass, entityId); - } - - @Override - public Set>> registryKeySet() { - return wrapped.registryKeySet(); - } - - @Override - public void resetTags() { - wrapped.resetTags(); - } - - @Override - public int size() { - return wrapped.size(); - } - - private static final MethodHandle IREGISTRY_LIFECYCLE = NMS.getFirstGetter(MappedRegistry.class, Lifecycle.class); - // replace regex ([A-Z_]+) =.*?of\((.*?)::new.*?$ minecraftClassMap.put(EntityType.\1, \2.class); - private static final MethodHandle IREGISTRY_RESOURCE_KEY = NMS.getFirstGetter(MappedRegistry.class, - ResourceKey.class); - private static final BiMap> minecraftClassMap = HashBiMap.create(); - static { - minecraftClassMap.put(EntityType.ALLAY, Allay.class); - minecraftClassMap.put(EntityType.AREA_EFFECT_CLOUD, AreaEffectCloud.class); - minecraftClassMap.put(EntityType.ARMADILLO, Armadillo.class); - minecraftClassMap.put(EntityType.ARMOR_STAND, ArmorStand.class); - minecraftClassMap.put(EntityType.ARROW, Arrow.class); - minecraftClassMap.put(EntityType.AXOLOTL, Axolotl.class); - minecraftClassMap.put(EntityType.BAT, Bat.class); - minecraftClassMap.put(EntityType.BEE, Bee.class); - minecraftClassMap.put(EntityType.BLAZE, Blaze.class); - minecraftClassMap.put(EntityType.BLOCK_DISPLAY, Display.BlockDisplay.class); - minecraftClassMap.put(EntityType.BOAT, Boat.class); - minecraftClassMap.put(EntityType.BOGGED, Bogged.class); - minecraftClassMap.put(EntityType.BREEZE, Breeze.class); - minecraftClassMap.put(EntityType.BREEZE_WIND_CHARGE, BreezeWindCharge.class); - minecraftClassMap.put(EntityType.CAMEL, Camel.class); - minecraftClassMap.put(EntityType.CAT, Cat.class); - minecraftClassMap.put(EntityType.CAVE_SPIDER, CaveSpider.class); - minecraftClassMap.put(EntityType.CHEST_BOAT, ChestBoat.class); - minecraftClassMap.put(EntityType.CHEST_MINECART, MinecartChest.class); - minecraftClassMap.put(EntityType.CHICKEN, Chicken.class); - minecraftClassMap.put(EntityType.COD, Cod.class); - minecraftClassMap.put(EntityType.COMMAND_BLOCK_MINECART, MinecartCommandBlock.class); - minecraftClassMap.put(EntityType.COW, Cow.class); - minecraftClassMap.put(EntityType.CREEPER, Creeper.class); - minecraftClassMap.put(EntityType.DOLPHIN, Dolphin.class); - minecraftClassMap.put(EntityType.DONKEY, Donkey.class); - minecraftClassMap.put(EntityType.DRAGON_FIREBALL, DragonFireball.class); - minecraftClassMap.put(EntityType.DROWNED, Drowned.class); - minecraftClassMap.put(EntityType.EGG, ThrownEgg.class); - minecraftClassMap.put(EntityType.ELDER_GUARDIAN, ElderGuardian.class); - minecraftClassMap.put(EntityType.END_CRYSTAL, EndCrystal.class); - minecraftClassMap.put(EntityType.ENDER_DRAGON, EnderDragon.class); - minecraftClassMap.put(EntityType.ENDER_PEARL, ThrownEnderpearl.class); - minecraftClassMap.put(EntityType.ENDERMAN, EnderMan.class); - minecraftClassMap.put(EntityType.ENDERMITE, Endermite.class); - minecraftClassMap.put(EntityType.EVOKER, Evoker.class); - minecraftClassMap.put(EntityType.EVOKER_FANGS, EvokerFangs.class); - minecraftClassMap.put(EntityType.EXPERIENCE_BOTTLE, ThrownExperienceBottle.class); - minecraftClassMap.put(EntityType.EXPERIENCE_ORB, ExperienceOrb.class); - minecraftClassMap.put(EntityType.EYE_OF_ENDER, EyeOfEnder.class); - minecraftClassMap.put(EntityType.FALLING_BLOCK, FallingBlockEntity.class); - minecraftClassMap.put(EntityType.FIREWORK_ROCKET, FireworkRocketEntity.class); - minecraftClassMap.put(EntityType.FOX, Fox.class); - minecraftClassMap.put(EntityType.FROG, Frog.class); - minecraftClassMap.put(EntityType.FURNACE_MINECART, MinecartFurnace.class); - minecraftClassMap.put(EntityType.GHAST, Ghast.class); - minecraftClassMap.put(EntityType.GIANT, Giant.class); - minecraftClassMap.put(EntityType.GLOW_ITEM_FRAME, GlowItemFrame.class); - minecraftClassMap.put(EntityType.GLOW_SQUID, GlowSquid.class); - minecraftClassMap.put(EntityType.GOAT, Goat.class); - minecraftClassMap.put(EntityType.GUARDIAN, Guardian.class); - minecraftClassMap.put(EntityType.HOGLIN, Hoglin.class); - minecraftClassMap.put(EntityType.HOPPER_MINECART, MinecartHopper.class); - minecraftClassMap.put(EntityType.HORSE, Horse.class); - minecraftClassMap.put(EntityType.HUSK, Husk.class); - minecraftClassMap.put(EntityType.ILLUSIONER, Illusioner.class); - minecraftClassMap.put(EntityType.INTERACTION, Interaction.class); - minecraftClassMap.put(EntityType.IRON_GOLEM, IronGolem.class); - minecraftClassMap.put(EntityType.ITEM, ItemEntity.class); - minecraftClassMap.put(EntityType.ITEM_DISPLAY, Display.ItemDisplay.class); - minecraftClassMap.put(EntityType.ITEM_FRAME, ItemFrame.class); - minecraftClassMap.put(EntityType.OMINOUS_ITEM_SPAWNER, OminousItemSpawner.class); - minecraftClassMap.put(EntityType.FIREBALL, LargeFireball.class); - minecraftClassMap.put(EntityType.LEASH_KNOT, LeashFenceKnotEntity.class); - minecraftClassMap.put(EntityType.LIGHTNING_BOLT, LightningBolt.class); - minecraftClassMap.put(EntityType.LLAMA, Llama.class); - minecraftClassMap.put(EntityType.LLAMA_SPIT, LlamaSpit.class); - minecraftClassMap.put(EntityType.MAGMA_CUBE, MagmaCube.class); - minecraftClassMap.put(EntityType.MARKER, Marker.class); - minecraftClassMap.put(EntityType.MINECART, Minecart.class); - minecraftClassMap.put(EntityType.MOOSHROOM, MushroomCow.class); - minecraftClassMap.put(EntityType.MULE, Mule.class); - minecraftClassMap.put(EntityType.OCELOT, Ocelot.class); - minecraftClassMap.put(EntityType.PAINTING, Painting.class); - minecraftClassMap.put(EntityType.PANDA, Panda.class); - minecraftClassMap.put(EntityType.PARROT, Parrot.class); - minecraftClassMap.put(EntityType.PHANTOM, Phantom.class); - minecraftClassMap.put(EntityType.PIG, Pig.class); - minecraftClassMap.put(EntityType.PIGLIN, Piglin.class); - minecraftClassMap.put(EntityType.PIGLIN_BRUTE, PiglinBrute.class); - minecraftClassMap.put(EntityType.PILLAGER, Pillager.class); - minecraftClassMap.put(EntityType.POLAR_BEAR, PolarBear.class); - minecraftClassMap.put(EntityType.POTION, ThrownPotion.class); - minecraftClassMap.put(EntityType.PUFFERFISH, Pufferfish.class); - minecraftClassMap.put(EntityType.RABBIT, Rabbit.class); - minecraftClassMap.put(EntityType.RAVAGER, Ravager.class); - minecraftClassMap.put(EntityType.SALMON, Salmon.class); - minecraftClassMap.put(EntityType.SHEEP, Sheep.class); - minecraftClassMap.put(EntityType.SHULKER, Shulker.class); - minecraftClassMap.put(EntityType.SHULKER_BULLET, ShulkerBullet.class); - minecraftClassMap.put(EntityType.SILVERFISH, Silverfish.class); - minecraftClassMap.put(EntityType.SKELETON, Skeleton.class); - minecraftClassMap.put(EntityType.SKELETON_HORSE, SkeletonHorse.class); - minecraftClassMap.put(EntityType.SLIME, Slime.class); - minecraftClassMap.put(EntityType.SMALL_FIREBALL, SmallFireball.class); - minecraftClassMap.put(EntityType.SNIFFER, Sniffer.class); - minecraftClassMap.put(EntityType.SNOW_GOLEM, SnowGolem.class); - minecraftClassMap.put(EntityType.SNOWBALL, Snowball.class); - minecraftClassMap.put(EntityType.SPAWNER_MINECART, MinecartSpawner.class); - minecraftClassMap.put(EntityType.SPECTRAL_ARROW, SpectralArrow.class); - minecraftClassMap.put(EntityType.SPIDER, Spider.class); - minecraftClassMap.put(EntityType.SQUID, Squid.class); - minecraftClassMap.put(EntityType.STRAY, Stray.class); - minecraftClassMap.put(EntityType.STRIDER, Strider.class); - minecraftClassMap.put(EntityType.TADPOLE, Tadpole.class); - minecraftClassMap.put(EntityType.TEXT_DISPLAY, Display.TextDisplay.class); - minecraftClassMap.put(EntityType.TNT, PrimedTnt.class); - minecraftClassMap.put(EntityType.TNT_MINECART, MinecartTNT.class); - minecraftClassMap.put(EntityType.TRADER_LLAMA, TraderLlama.class); - minecraftClassMap.put(EntityType.TRIDENT, ThrownTrident.class); - minecraftClassMap.put(EntityType.TROPICAL_FISH, TropicalFish.class); - minecraftClassMap.put(EntityType.TURTLE, Turtle.class); - minecraftClassMap.put(EntityType.VEX, Vex.class); - minecraftClassMap.put(EntityType.VILLAGER, Villager.class); - minecraftClassMap.put(EntityType.VINDICATOR, Vindicator.class); - minecraftClassMap.put(EntityType.WANDERING_TRADER, WanderingTrader.class); - minecraftClassMap.put(EntityType.WARDEN, Warden.class); - minecraftClassMap.put(EntityType.WIND_CHARGE, WindCharge.class); - minecraftClassMap.put(EntityType.WITCH, Witch.class); - minecraftClassMap.put(EntityType.WITHER, WitherBoss.class); - minecraftClassMap.put(EntityType.WITHER_SKELETON, WitherSkeleton.class); - minecraftClassMap.put(EntityType.WITHER_SKULL, WitherSkull.class); - minecraftClassMap.put(EntityType.WOLF, Wolf.class); - minecraftClassMap.put(EntityType.ZOGLIN, Zoglin.class); - minecraftClassMap.put(EntityType.ZOMBIE, Zombie.class); - minecraftClassMap.put(EntityType.ZOMBIE_HORSE, ZombieHorse.class); - minecraftClassMap.put(EntityType.ZOMBIE_VILLAGER, ZombieVillager.class); - minecraftClassMap.put(EntityType.ZOMBIFIED_PIGLIN, ZombifiedPiglin.class); - minecraftClassMap.put(EntityType.FISHING_BOBBER, FishingHook.class); - } -} \ No newline at end of file diff --git a/v1_21_R1/pom.xml b/v1_21_R2/pom.xml similarity index 96% rename from v1_21_R1/pom.xml rename to v1_21_R2/pom.xml index d67ee6096..cac4eac4d 100644 --- a/v1_21_R1/pom.xml +++ b/v1_21_R2/pom.xml @@ -4,12 +4,12 @@ net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT - citizens-v1_21_R1 + citizens-v1_21_R2 UTF-8 - 1.21.1-R0.1-SNAPSHOT + 1.21.2-R0.1-SNAPSHOT diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/AllayController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/AllayController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/AllayController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/AllayController.java index 3a89037cd..e6f14b49d 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/AllayController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/AllayController.java @@ -1,18 +1,18 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftAllay; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftAllay; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import com.google.common.collect.Lists; import com.mojang.datafixers.util.Pair; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -20,6 +20,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -37,13 +38,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class AllayController extends MobEntityController { public AllayController() { - super(EntityAllayNPC.class); + super(EntityAllayNPC.class, EntityType.ALLAY); } @Override @@ -61,6 +62,7 @@ public class AllayController extends MobEntityController { private final CitizensNPC npc; private int taskId = -1; + public EntityAllayNPC(EntityType types, Level level) { this(types, level, null); } @@ -89,13 +91,6 @@ public class AllayController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -111,8 +106,8 @@ public class AllayController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -229,12 +224,19 @@ public class AllayController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ArmadilloController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ArmadilloController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ArmadilloController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ArmadilloController.java index 2bb10e161..a51ec8225 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ArmadilloController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ArmadilloController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftArmadillo; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftArmadillo; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -34,13 +35,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ArmadilloController extends MobEntityController { public ArmadilloController() { - super(EntityArmadilloNPC.class); + super(EntityArmadilloNPC.class, EntityType.ARMADILLO); } @Override @@ -85,13 +86,6 @@ public class ArmadilloController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -107,8 +101,8 @@ public class ArmadilloController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -225,12 +219,19 @@ public class ArmadilloController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ArmorStandController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ArmorStandController.java similarity index 86% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ArmorStandController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ArmorStandController.java index c432ebaf4..f9007c19c 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ArmorStandController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ArmorStandController.java @@ -1,17 +1,17 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftArmorStand; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftArmorStand; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import org.bukkit.event.player.PlayerInteractEntityEvent; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.MobAI; -import net.citizensnpcs.nms.v1_21_R1.util.MobAI.ForwardingMobAI; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.MobAI; +import net.citizensnpcs.nms.v1_21_R2.util.MobAI.ForwardingMobAI; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -27,13 +27,13 @@ import net.minecraft.world.entity.decoration.ArmorStand; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ArmorStandController extends MobEntityController { public ArmorStandController() { - super(EntityArmorStandNPC.class); + super(EntityArmorStandNPC.class, EntityType.ARMOR_STAND); } @Override @@ -69,13 +69,6 @@ public class ArmorStandController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public MobAI getAI() { return ai; @@ -130,6 +123,13 @@ public class ArmorStandController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/AxolotlController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/AxolotlController.java similarity index 92% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/AxolotlController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/AxolotlController.java index 31a95438d..79ede8e5f 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/AxolotlController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/AxolotlController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftAxolotl; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftAxolotl; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -35,13 +35,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class AxolotlController extends MobEntityController { public AxolotlController() { - super(EntityAxolotlNPC.class); + super(EntityAxolotlNPC.class, EntityType.AXOLOTL); } @Override @@ -59,6 +59,7 @@ public class AxolotlController extends MobEntityController { private final CitizensNPC npc; private MoveControl oldMoveController; + public EntityAxolotlNPC(EntityType types, Level level) { this(types, level, null); } @@ -93,13 +94,6 @@ public class AxolotlController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -212,6 +206,13 @@ public class AxolotlController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); @@ -238,7 +239,7 @@ public class AxolotlController extends MobEntityController { super.travel(vec3d); } } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/BatController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/BatController.java similarity index 87% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/BatController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/BatController.java index 043a87ed8..de3f66594 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/BatController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/BatController.java @@ -1,19 +1,20 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftBat; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftBat; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -26,13 +27,13 @@ import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class BatController extends MobEntityController { public BatController() { - super(EntityBatNPC.class); + super(EntityBatNPC.class, EntityType.BAT); } @Override @@ -73,13 +74,6 @@ public class BatController extends MobEntityController { return super.canRide(entity); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -88,13 +82,13 @@ public class BatController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc == null) { - super.customServerAiStep(); + super.customServerAiStep(level); } else { NMSImpl.updateMinecraftAIState(npc, this); if (npc.useMinecraftAI()) { - super.customServerAiStep(); + super.customServerAiStep(level); } npc.update(); } @@ -180,6 +174,13 @@ public class BatController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public boolean updateFluidHeightAndDoFluidPushing(TagKey tagkey, double d0) { if (npc == null) diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/BeeController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/BeeController.java similarity index 87% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/BeeController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/BeeController.java index ae3d27c26..6bdb7c558 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/BeeController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/BeeController.java @@ -1,19 +1,20 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftBee; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftBee; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -26,13 +27,13 @@ import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class BeeController extends MobEntityController { public BeeController() { - super(EntityBeeNPC.class); + super(EntityBeeNPC.class, EntityType.BEE); } @Override @@ -70,13 +71,6 @@ public class BeeController extends MobEntityController { return super.canRide(entity); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -85,13 +79,13 @@ public class BeeController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc == null) { - super.customServerAiStep(); + super.customServerAiStep(level); } else { NMSImpl.updateMinecraftAIState(npc, this); if (npc.useMinecraftAI()) { - super.customServerAiStep(); + super.customServerAiStep(level); } npc.update(); } @@ -177,6 +171,13 @@ public class BeeController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public boolean updateFluidHeightAndDoFluidPushing(TagKey tagkey, double d0) { if (npc == null) diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/BlazeController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/BlazeController.java similarity index 88% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/BlazeController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/BlazeController.java index 4d44bc7ef..e9dc7a411 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/BlazeController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/BlazeController.java @@ -1,19 +1,20 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftBlaze; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftBlaze; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -26,13 +27,13 @@ import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class BlazeController extends MobEntityController { public BlazeController() { - super(EntityBlazeNPC.class); + super(EntityBlazeNPC.class, EntityType.BLAZE); } @Override @@ -70,13 +71,6 @@ public class BlazeController extends MobEntityController { return super.canRide(entity); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -85,7 +79,7 @@ public class BlazeController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -172,6 +166,13 @@ public class BlazeController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public boolean updateFluidHeightAndDoFluidPushing(TagKey tagkey, double d0) { if (npc == null) diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/BoggedController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/BoggedController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/BoggedController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/BoggedController.java index dab7679d9..242cacdc6 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/BoggedController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/BoggedController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftBogged; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftBogged; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -29,13 +30,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class BoggedController extends MobEntityController { public BoggedController() { - super(EntityBoggedNPC.class); + super(EntityBoggedNPC.class, EntityType.BOGGED); } @Override @@ -80,13 +81,6 @@ public class BoggedController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -102,8 +96,8 @@ public class BoggedController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -207,12 +201,19 @@ public class BoggedController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/BreezeController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/BreezeController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/BreezeController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/BreezeController.java index 804687a4e..078db7139 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/BreezeController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/BreezeController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftBreeze; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftBreeze; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -29,13 +30,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class BreezeController extends MobEntityController { public BreezeController() { - super(EntityBreezeNPC.class); + super(EntityBreezeNPC.class, EntityType.BREEZE); } @Override @@ -80,13 +81,6 @@ public class BreezeController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -102,8 +96,8 @@ public class BreezeController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -207,12 +201,19 @@ public class BreezeController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CamelController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CamelController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CamelController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CamelController.java index 4e7b7d492..b89d15417 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CamelController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CamelController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftCamel; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftCamel; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.Controllable; @@ -19,6 +19,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -33,13 +34,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class CamelController extends MobEntityController { public CamelController() { - super(EntityCamelNPC.class); + super(EntityCamelNPC.class, EntityType.CAMEL); } @Override @@ -64,6 +65,7 @@ public class CamelController extends MobEntityController { private final CitizensNPC npc; private boolean riding; + public EntityCamelNPC(EntityType types, Level level) { this(types, level, null); } @@ -97,13 +99,6 @@ public class CamelController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -119,8 +114,8 @@ public class CamelController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) { @@ -251,12 +246,19 @@ public class CamelController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CatController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CatController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CatController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CatController.java index 21ce73bb5..420cefd62 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CatController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CatController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftCat; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftCat; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -29,13 +30,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class CatController extends MobEntityController { public CatController() { - super(EntityCatNPC.class); + super(EntityCatNPC.class, EntityType.CAT); } @Override @@ -80,13 +81,6 @@ public class CatController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -102,8 +96,8 @@ public class CatController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -207,12 +201,19 @@ public class CatController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CaveSpiderController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CaveSpiderController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CaveSpiderController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CaveSpiderController.java index ccf45c4e1..239b6cfbd 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CaveSpiderController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CaveSpiderController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftCaveSpider; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftCaveSpider; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class CaveSpiderController extends MobEntityController { public CaveSpiderController() { - super(EntityCaveSpiderNPC.class); + super(EntityCaveSpiderNPC.class, EntityType.CAVE_SPIDER); } @Override @@ -79,13 +80,6 @@ public class CaveSpiderController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -101,8 +95,8 @@ public class CaveSpiderController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -206,12 +200,19 @@ public class CaveSpiderController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ChickenController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ChickenController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ChickenController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ChickenController.java index 8d0d66d24..edc6b8308 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ChickenController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ChickenController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftChicken; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftChicken; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -29,13 +30,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ChickenController extends MobEntityController { public ChickenController() { - super(EntityChickenNPC.class); + super(EntityChickenNPC.class, EntityType.CHICKEN); } @Override @@ -88,13 +89,6 @@ public class ChickenController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -110,8 +104,8 @@ public class ChickenController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -215,12 +209,19 @@ public class ChickenController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CodController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CodController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CodController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CodController.java index f8e5b7f50..7af2bdc02 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CodController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CodController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftCod; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftCod; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -34,13 +35,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class CodController extends MobEntityController { public CodController() { - super(EntityCodNPC.class); + super(EntityCodNPC.class, EntityType.COD); } @Override @@ -58,6 +59,7 @@ public class CodController extends MobEntityController { private final CitizensNPC npc; private MoveControl oldMoveController; + public EntityCodNPC(EntityType types, Level level) { this(types, level, null); } @@ -102,13 +104,6 @@ public class CodController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -124,7 +119,7 @@ public class CodController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc != null) { if (!npc.useMinecraftAI()) { NMSImpl.setNotInSchool(this); @@ -137,7 +132,7 @@ public class CodController extends MobEntityController { this.moveControl = new MoveControl(this); } } - super.customServerAiStep(); + super.customServerAiStep(level); if (npc != null) { npc.update(); } @@ -241,6 +236,13 @@ public class CodController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { @@ -248,7 +250,7 @@ public class CodController extends MobEntityController { super.travel(vec3d); } } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CowController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CowController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CowController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CowController.java index e8be1ccdb..0b36bb1e8 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CowController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CowController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftCow; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftCow; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -34,13 +35,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class CowController extends MobEntityController { public CowController() { - super(EntityCowNPC.class); + super(EntityCowNPC.class, EntityType.COW); } @Override @@ -85,13 +86,6 @@ public class CowController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -107,8 +101,8 @@ public class CowController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -222,12 +216,19 @@ public class CowController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CreakingController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CreakingController.java new file mode 100644 index 000000000..3012f90b5 --- /dev/null +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CreakingController.java @@ -0,0 +1,250 @@ +package net.citizensnpcs.nms.v1_21_R2.entity; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftCreaking; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; + +import net.citizensnpcs.api.npc.NPC; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; +import net.citizensnpcs.npc.CitizensNPC; +import net.citizensnpcs.npc.ai.NPCHolder; +import net.citizensnpcs.util.NMS; +import net.citizensnpcs.util.Util; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.tags.TagKey; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.monster.creaking.Creaking; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.level.portal.TeleportTransition; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; + +public class CreakingController extends MobEntityController { + public CreakingController() { + super(EntityCreakingNPC.class, EntityType.CREAKING); + } + + @Override + public org.bukkit.entity.Creaking getBukkitEntity() { + return (org.bukkit.entity.Creaking) super.getBukkitEntity(); + } + + public static class CreakingNPC extends CraftCreaking implements ForwardingNPCHolder { + public CreakingNPC(EntityCreakingNPC entity) { + super((CraftServer) Bukkit.getServer(), entity); + } + } + + public static class EntityCreakingNPC extends Creaking implements NPCHolder { + private final CitizensNPC npc; + + public EntityCreakingNPC(EntityType types, Level level) { + this(types, level, null); + } + + public EntityCreakingNPC(EntityType types, Level level, NPC npc) { + super(types, level); + this.npc = (CitizensNPC) npc; + } + + @Override + public boolean broadcastToPlayer(ServerPlayer player) { + return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); + } + + @Override + protected boolean canRide(Entity entity) { + if (npc != null && (entity instanceof Boat || entity instanceof AbstractMinecart)) + return !npc.isProtected(); + return super.canRide(entity); + } + + @Override + public boolean causeFallDamage(float f, float f1, DamageSource damagesource) { + if (npc == null || !npc.isFlyable()) + return super.causeFallDamage(f, f1, damagesource); + return false; + } + + @Override + public void checkDespawn() { + if (npc == null) { + super.checkDespawn(); + } + } + + @Override + protected void checkFallDamage(double d0, boolean flag, BlockState iblockdata, BlockPos blockposition) { + if (npc == null || !npc.isFlyable()) { + super.checkFallDamage(d0, flag, iblockdata, blockposition); + } + } + + @Override + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); + if (npc != null) { + NMSImpl.updateMinecraftAIState(npc, this); + npc.update(); + if (npc.isProtected()) { + NMSImpl.setScuteTime(this, 2); + } + } + } + + @Override + protected SoundEvent getAmbientSound() { + return NMSImpl.getSoundEffect(npc, super.getAmbientSound(), NPC.Metadata.AMBIENT_SOUND); + } + + @Override + public CraftEntity getBukkitEntity() { + if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { + NMSImpl.setBukkitEntity(this, new CreakingNPC(this)); + } + return super.getBukkitEntity(); + } + + @Override + protected SoundEvent getDeathSound() { + return NMSImpl.getSoundEffect(npc, super.getDeathSound(), NPC.Metadata.DEATH_SOUND); + } + + @Override + protected SoundEvent getHurtSound(DamageSource damagesource) { + return NMSImpl.getSoundEffect(npc, super.getHurtSound(damagesource), NPC.Metadata.HURT_SOUND); + } + + @Override + public float getJumpPower() { + return NMS.getJumpPower(npc, super.getJumpPower()); + } + + @Override + public int getMaxFallDistance() { + return NMS.getFallDistance(npc, super.getMaxFallDistance()); + } + + @Override + public NPC getNPC() { + return npc; + } + + @Override + public PushReaction getPistonPushReaction() { + return Util.callPistonPushEvent(npc) ? PushReaction.IGNORE : super.getPistonPushReaction(); + } + + @Override + public boolean isLeashed() { + return NMSImpl.isLeashed(npc, super::isLeashed, this); + } + + @Override + public boolean isPushable() { + return npc == null ? super.isPushable() + : npc.data(). get(NPC.Metadata.COLLIDABLE, !npc.isProtected()); + } + + @Override + public void knockback(double strength, double dx, double dz) { + NMS.callKnockbackEvent(npc, (float) strength, dx, dz, evt -> super.knockback((float) evt.getStrength(), + evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ())); + } + + @Override + protected AABB makeBoundingBox() { + return NMSBoundingBox.makeBB(npc, super.makeBoundingBox()); + } + + @Override + public InteractionResult mobInteract(Player entityhuman, InteractionHand enumhand) { + if (npc == null || !npc.isProtected()) + return super.mobInteract(entityhuman, enumhand); + ItemStack itemstack = entityhuman.getItemInHand(enumhand); + if (itemstack.getItem() == Items.BRUSH) + return InteractionResult.FAIL; + return super.mobInteract(entityhuman, enumhand); + } + + @Override + public boolean onClimbable() { + if (npc == null || !npc.isFlyable()) + return super.onClimbable(); + else + return false; + } + + @Override + public void onSyncedDataUpdated(EntityDataAccessor datawatcherobject) { + if (npc == null) { + super.onSyncedDataUpdated(datawatcherobject); + return; + } + NMSImpl.checkAndUpdateHeight(this, datawatcherobject, super::onSyncedDataUpdated); + } + + @Override + public void push(Entity entity) { + // this method is called by both the entities involved - cancelling + // it will not stop the NPC from moving. + super.push(entity); + if (npc != null) { + Util.callCollisionEvent(npc, entity.getBukkitEntity()); + } + } + + @Override + public boolean save(CompoundTag save) { + return npc == null ? super.save(save) : false; + } + + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + + @Override + public void travel(Vec3 vec3d) { + if (npc == null || !npc.isFlyable()) { + super.travel(vec3d); + } else { + NMSImpl.moveLogic(this, vec3d); + } + } + + @Override + public boolean updateFluidHeightAndDoFluidPushing(TagKey tagkey, double d0) { + if (npc == null) + return super.updateFluidHeightAndDoFluidPushing(tagkey, d0); + Vec3 old = getDeltaMovement().add(0, 0, 0); + boolean res = super.updateFluidHeightAndDoFluidPushing(tagkey, d0); + if (!npc.isPushableByFluids()) { + setDeltaMovement(old); + } + return res; + } + } +} diff --git a/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CreakingTransientController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CreakingTransientController.java new file mode 100644 index 000000000..e9fef9777 --- /dev/null +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CreakingTransientController.java @@ -0,0 +1,250 @@ +package net.citizensnpcs.nms.v1_21_R2.entity; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftCreakingTransient; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; + +import net.citizensnpcs.api.npc.NPC; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; +import net.citizensnpcs.npc.CitizensNPC; +import net.citizensnpcs.npc.ai.NPCHolder; +import net.citizensnpcs.util.NMS; +import net.citizensnpcs.util.Util; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.tags.TagKey; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.monster.creaking.CreakingTransient; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.level.portal.TeleportTransition; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; + +public class CreakingTransientController extends MobEntityController { + public CreakingTransientController() { + super(EntityCreakingTransientNPC.class, EntityType.CREAKING_TRANSIENT); + } + + @Override + public org.bukkit.entity.CreakingTransient getBukkitEntity() { + return (org.bukkit.entity.CreakingTransient) super.getBukkitEntity(); + } + + public static class CreakingTransientNPC extends CraftCreakingTransient implements ForwardingNPCHolder { + public CreakingTransientNPC(EntityCreakingTransientNPC entity) { + super((CraftServer) Bukkit.getServer(), entity); + } + } + + public static class EntityCreakingTransientNPC extends CreakingTransient implements NPCHolder { + private final CitizensNPC npc; + + public EntityCreakingTransientNPC(EntityType types, Level level) { + this(types, level, null); + } + + public EntityCreakingTransientNPC(EntityType types, Level level, NPC npc) { + super(types, level); + this.npc = (CitizensNPC) npc; + } + + @Override + public boolean broadcastToPlayer(ServerPlayer player) { + return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); + } + + @Override + protected boolean canRide(Entity entity) { + if (npc != null && (entity instanceof Boat || entity instanceof AbstractMinecart)) + return !npc.isProtected(); + return super.canRide(entity); + } + + @Override + public boolean causeFallDamage(float f, float f1, DamageSource damagesource) { + if (npc == null || !npc.isFlyable()) + return super.causeFallDamage(f, f1, damagesource); + return false; + } + + @Override + public void checkDespawn() { + if (npc == null) { + super.checkDespawn(); + } + } + + @Override + protected void checkFallDamage(double d0, boolean flag, BlockState iblockdata, BlockPos blockposition) { + if (npc == null || !npc.isFlyable()) { + super.checkFallDamage(d0, flag, iblockdata, blockposition); + } + } + + @Override + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); + if (npc != null) { + NMSImpl.updateMinecraftAIState(npc, this); + npc.update(); + if (npc.isProtected()) { + NMSImpl.setScuteTime(this, 2); + } + } + } + + @Override + protected SoundEvent getAmbientSound() { + return NMSImpl.getSoundEffect(npc, super.getAmbientSound(), NPC.Metadata.AMBIENT_SOUND); + } + + @Override + public CraftEntity getBukkitEntity() { + if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { + NMSImpl.setBukkitEntity(this, new CreakingTransientNPC(this)); + } + return super.getBukkitEntity(); + } + + @Override + protected SoundEvent getDeathSound() { + return NMSImpl.getSoundEffect(npc, super.getDeathSound(), NPC.Metadata.DEATH_SOUND); + } + + @Override + protected SoundEvent getHurtSound(DamageSource damagesource) { + return NMSImpl.getSoundEffect(npc, super.getHurtSound(damagesource), NPC.Metadata.HURT_SOUND); + } + + @Override + public float getJumpPower() { + return NMS.getJumpPower(npc, super.getJumpPower()); + } + + @Override + public int getMaxFallDistance() { + return NMS.getFallDistance(npc, super.getMaxFallDistance()); + } + + @Override + public NPC getNPC() { + return npc; + } + + @Override + public PushReaction getPistonPushReaction() { + return Util.callPistonPushEvent(npc) ? PushReaction.IGNORE : super.getPistonPushReaction(); + } + + @Override + public boolean isLeashed() { + return NMSImpl.isLeashed(npc, super::isLeashed, this); + } + + @Override + public boolean isPushable() { + return npc == null ? super.isPushable() + : npc.data(). get(NPC.Metadata.COLLIDABLE, !npc.isProtected()); + } + + @Override + public void knockback(double strength, double dx, double dz) { + NMS.callKnockbackEvent(npc, (float) strength, dx, dz, evt -> super.knockback((float) evt.getStrength(), + evt.getKnockbackVector().getX(), evt.getKnockbackVector().getZ())); + } + + @Override + protected AABB makeBoundingBox() { + return NMSBoundingBox.makeBB(npc, super.makeBoundingBox()); + } + + @Override + public InteractionResult mobInteract(Player entityhuman, InteractionHand enumhand) { + if (npc == null || !npc.isProtected()) + return super.mobInteract(entityhuman, enumhand); + ItemStack itemstack = entityhuman.getItemInHand(enumhand); + if (itemstack.getItem() == Items.BRUSH) + return InteractionResult.FAIL; + return super.mobInteract(entityhuman, enumhand); + } + + @Override + public boolean onClimbable() { + if (npc == null || !npc.isFlyable()) + return super.onClimbable(); + else + return false; + } + + @Override + public void onSyncedDataUpdated(EntityDataAccessor datawatcherobject) { + if (npc == null) { + super.onSyncedDataUpdated(datawatcherobject); + return; + } + NMSImpl.checkAndUpdateHeight(this, datawatcherobject, super::onSyncedDataUpdated); + } + + @Override + public void push(Entity entity) { + // this method is called by both the entities involved - cancelling + // it will not stop the NPC from moving. + super.push(entity); + if (npc != null) { + Util.callCollisionEvent(npc, entity.getBukkitEntity()); + } + } + + @Override + public boolean save(CompoundTag save) { + return npc == null ? super.save(save) : false; + } + + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + + @Override + public void travel(Vec3 vec3d) { + if (npc == null || !npc.isFlyable()) { + super.travel(vec3d); + } else { + NMSImpl.moveLogic(this, vec3d); + } + } + + @Override + public boolean updateFluidHeightAndDoFluidPushing(TagKey tagkey, double d0) { + if (npc == null) + return super.updateFluidHeightAndDoFluidPushing(tagkey, d0); + Vec3 old = getDeltaMovement().add(0, 0, 0); + boolean res = super.updateFluidHeightAndDoFluidPushing(tagkey, d0); + if (!npc.isPushableByFluids()) { + setDeltaMovement(old); + } + return res; + } + } +} diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CreeperController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CreeperController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CreeperController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CreeperController.java index 57bd19706..857774aee 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/CreeperController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/CreeperController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftCreeper; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftCreeper; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -30,13 +30,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class CreeperController extends MobEntityController { public CreeperController() { - super(EntityCreeperNPC.class); + super(EntityCreeperNPC.class, EntityType.CREEPER); } @Override @@ -83,13 +83,6 @@ public class CreeperController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -105,8 +98,8 @@ public class CreeperController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -221,6 +214,13 @@ public class CreeperController extends MobEntityController { this.allowPowered = allowPowered; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void thunderHit(ServerLevel worldserver, LightningBolt entitylightning) { if (npc == null || allowPowered) { @@ -233,7 +233,7 @@ public class CreeperController extends MobEntityController { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/DolphinController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/DolphinController.java similarity index 92% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/DolphinController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/DolphinController.java index 33b98a730..a1e928bdf 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/DolphinController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/DolphinController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftDolphin; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftDolphin; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -30,13 +30,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class DolphinController extends MobEntityController { public DolphinController() { - super(EntityDolphinNPC.class); + super(EntityDolphinNPC.class, EntityType.DOLPHIN); } @Override @@ -55,6 +55,7 @@ public class DolphinController extends MobEntityController { private final CitizensNPC npc; private MoveControl oldMoveController; + public EntityDolphinNPC(EntityType types, Level level) { this(types, level, null); } @@ -89,13 +90,6 @@ public class DolphinController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -203,6 +197,13 @@ public class DolphinController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null && npc.isProtected()) { @@ -233,7 +234,7 @@ public class DolphinController extends MobEntityController { super.travel(vec3d); } } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/DrownedController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/DrownedController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/DrownedController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/DrownedController.java index 731a47aba..0c062cf8a 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/DrownedController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/DrownedController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftDrowned; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftDrowned; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class DrownedController extends MobEntityController { public DrownedController() { - super(EntityDrownedNPC.class); + super(EntityDrownedNPC.class, EntityType.DROWNED); } @Override @@ -79,13 +80,6 @@ public class DrownedController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -101,8 +95,8 @@ public class DrownedController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -197,12 +191,19 @@ public class DrownedController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/EnderDragonController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/EnderDragonController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/EnderDragonController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/EnderDragonController.java index ea1cfec10..f54967bb2 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/EnderDragonController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/EnderDragonController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEnderDragon; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEnderDragon; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_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.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -22,6 +23,7 @@ import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntitySelector; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.boss.enderdragon.DragonFlightHistory.Sample; import net.minecraft.world.entity.boss.enderdragon.EnderDragon; import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase; import net.minecraft.world.entity.vehicle.AbstractMinecart; @@ -29,13 +31,13 @@ import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class EnderDragonController extends MobEntityController { public EnderDragonController() { - super(EntityEnderDragonNPC.class); + super(EntityEnderDragonNPC.class, EntityType.ENDER_DRAGON); } @Override @@ -73,21 +75,12 @@ public class EnderDragonController extends MobEntityController { setHealth(0F); return; } - if (this.posPointer < 0) { - for (int i = 0; i < this.positions.length; ++i) { - this.positions[i][0] = this.getYRot(); - this.positions[i][1] = this.getY(); - } - } - if (++this.posPointer == this.positions.length) { - this.posPointer = 0; - } - this.positions[this.posPointer][0] = this.getYRot(); - this.positions[this.posPointer][1] = this.getY(); + flightHistory.record(getY(), getYRot()); float[][] pos = NMS.calculateDragonPositions(getYRot(), - new double[][] { getLatencyPos(0, 1F), getLatencyPos(5, 1F), getLatencyPos(10, 1F), - getLatencyPos(12, 1F), getLatencyPos(14, 1F), getLatencyPos(16, 1F) }); + new double[][] { toa(flightHistory.get(0, 1F)), toa(flightHistory.get(5, 1F)), + toa(flightHistory.get(10, 1F)), toa(flightHistory.get(12, 1F)), + toa(flightHistory.get(14, 1F)), toa(flightHistory.get(16, 1F)) }); for (int j = 0; j < subEntities.length; ++j) { Vec3 vec3 = new Vec3(this.subEntities[j].getX(), this.subEntities[j].getY(), this.subEntities[j].getZ()); @@ -129,9 +122,9 @@ public class EnderDragonController extends MobEntityController { this.level().getEntities(this, subEntities[7].getBoundingBox().inflate(4.0, 2.0, 4.0).move(0.0, -2.0, 0.0), EntitySelector.NO_CREATIVE_OR_SPECTATOR)); - NMSImpl.ENDERDRAGON_HURT.invoke(this, this.level().getEntities(this, + NMSImpl.ENDERDRAGON_HURT.invoke(this, this.level(), this.level().getEntities(this, subEntities[0].getBoundingBox().inflate(1.0), EntitySelector.NO_CREATIVE_OR_SPECTATOR)); - NMSImpl.ENDERDRAGON_HURT.invoke(this, this.level().getEntities(this, + NMSImpl.ENDERDRAGON_HURT.invoke(this, this.level(), this.level().getEntities(this, subEntities[1].getBoundingBox().inflate(1.0), EntitySelector.NO_CREATIVE_OR_SPECTATOR)); } catch (Throwable t) { t.printStackTrace(); @@ -154,13 +147,6 @@ public class EnderDragonController extends MobEntityController { return super.canRide(entity); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -244,16 +230,15 @@ public class EnderDragonController extends MobEntityController { } @Override - protected boolean reallyHurt(DamageSource source, float f) { + protected void reallyHurt(ServerLevel level, DamageSource source, float f) { if (npc == null) - return super.reallyHurt(source, f); + return; Vec3 old = getDeltaMovement(); - boolean res = super.reallyHurt(source, f); + super.reallyHurt(level, source, f); if (getPhaseManager().getCurrentPhase().getPhase() == EnderDragonPhase.HOVERING) { setDeltaMovement(old); } - return res; } @Override @@ -261,6 +246,17 @@ public class EnderDragonController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + + private double[] toa(Sample sample) { + return new double[] { sample.y(), sample.yRot() }; + } + @Override public boolean updateFluidHeightAndDoFluidPushing(TagKey tagkey, double d0) { if (npc == null) diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/EndermanController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/EndermanController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/EndermanController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/EndermanController.java index 0392e415b..2a607d2f4 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/EndermanController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/EndermanController.java @@ -1,23 +1,24 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import java.util.Optional; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEnderman; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEnderman; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import org.bukkit.event.player.PlayerTeleportEvent; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -31,13 +32,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class EndermanController extends MobEntityController { public EndermanController() { - super(EntityEndermanNPC.class); + super(EntityEndermanNPC.class, EntityType.ENDERMAN); } @Override @@ -82,13 +83,6 @@ public class EndermanController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -104,8 +98,8 @@ public class EndermanController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -217,12 +211,19 @@ public class EndermanController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/EndermiteController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/EndermiteController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/EndermiteController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/EndermiteController.java index 9e962b5fa..a8d7ce4d1 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/EndermiteController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/EndermiteController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEndermite; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEndermite; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class EndermiteController extends MobEntityController { public EndermiteController() { - super(EntityEndermiteNPC.class); + super(EntityEndermiteNPC.class, EntityType.ENDERMITE); } @Override @@ -79,13 +80,6 @@ public class EndermiteController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -101,8 +95,8 @@ public class EndermiteController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -206,12 +200,19 @@ public class EndermiteController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/EntityHumanNPC.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/EntityHumanNPC.java similarity index 95% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/EntityHumanNPC.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/EntityHumanNPC.java index c9fc3d80a..78a3da4f6 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/EntityHumanNPC.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/EntityHumanNPC.java @@ -1,12 +1,12 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import java.io.IOException; import java.lang.invoke.MethodHandle; import java.util.List; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.Plugin; @@ -19,13 +19,13 @@ import net.citizensnpcs.api.npc.NPC.NPCUpdate; import net.citizensnpcs.api.trait.trait.Inventory; import net.citizensnpcs.api.util.Messaging; import net.citizensnpcs.api.util.SpigotUtil; -import net.citizensnpcs.nms.v1_21_R1.network.EmptyConnection; -import net.citizensnpcs.nms.v1_21_R1.network.EmptyPacketListener; -import net.citizensnpcs.nms.v1_21_R1.util.EmptyAdvancementDataPlayer; -import net.citizensnpcs.nms.v1_21_R1.util.EmptyServerStatsCounter; -import net.citizensnpcs.nms.v1_21_R1.util.MobAI; -import net.citizensnpcs.nms.v1_21_R1.util.MobAI.ForwardingMobAI; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.network.EmptyConnection; +import net.citizensnpcs.nms.v1_21_R2.network.EmptyPacketListener; +import net.citizensnpcs.nms.v1_21_R2.util.EmptyAdvancementDataPlayer; +import net.citizensnpcs.nms.v1_21_R2.util.EmptyServerStatsCounter; +import net.citizensnpcs.nms.v1_21_R2.util.MobAI; +import net.citizensnpcs.nms.v1_21_R2.util.MobAI.ForwardingMobAI; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.npc.skin.SkinPacketTracker; @@ -246,11 +246,11 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable } @Override - public boolean hurt(DamageSource damagesource, float f) { + public boolean hurtServer(ServerLevel level, DamageSource damagesource, float f) { // knock back velocity is cancelled and sent to client for handling when // the entity is a player. there is no client so make this happen // manually. - boolean damaged = super.hurt(damagesource, f); + boolean damaged = super.hurtServer(level, damagesource, f); if (damaged && hurtMarked) { hurtMarked = false; Bukkit.getScheduler().runTask(CitizensAPI.getPlugin(), () -> EntityHumanNPC.this.hurtMarked = true); @@ -400,7 +400,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/EvokerController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/EvokerController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/EvokerController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/EvokerController.java index 2c5f7a86b..7c933f85a 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/EvokerController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/EvokerController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEvoker; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEvoker; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class EvokerController extends MobEntityController { public EvokerController() { - super(EntityEvokerNPC.class); + super(EntityEvokerNPC.class, EntityType.EVOKER); } @Override @@ -73,13 +74,6 @@ public class EvokerController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class EvokerController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -191,12 +185,19 @@ public class EvokerController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/FoxController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/FoxController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/FoxController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/FoxController.java index 2a77035ff..ed0a383df 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/FoxController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/FoxController.java @@ -1,16 +1,16 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import java.lang.invoke.MethodHandle; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftFox; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftFox; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.versioned.FoxTrait; @@ -19,6 +19,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -32,13 +33,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class FoxController extends MobEntityController { public FoxController() { - super(EntityFoxNPC.class); + super(EntityFoxNPC.class, EntityType.FOX); } @Override @@ -77,13 +78,6 @@ public class FoxController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -99,8 +93,8 @@ public class FoxController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -214,12 +208,19 @@ public class FoxController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/FrogController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/FrogController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/FrogController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/FrogController.java index c4aa71f8f..618e31db6 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/FrogController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/FrogController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftFrog; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftFrog; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -29,13 +30,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class FrogController extends MobEntityController { public FrogController() { - super(EntityFrogNPC.class); + super(EntityFrogNPC.class, EntityType.FROG); } @Override @@ -77,13 +78,6 @@ public class FrogController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -99,8 +93,8 @@ public class FrogController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -204,12 +198,19 @@ public class FrogController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GhastController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GhastController.java similarity index 88% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GhastController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GhastController.java index ba2e4cb18..bfeb7aa50 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GhastController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GhastController.java @@ -1,19 +1,20 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftGhast; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftGhast; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -26,13 +27,13 @@ import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class GhastController extends MobEntityController { public GhastController() { - super(EntityGhastNPC.class); + super(EntityGhastNPC.class, EntityType.GHAST); } @Override @@ -64,13 +65,6 @@ public class GhastController extends MobEntityController { return super.canRide(entity); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -79,12 +73,12 @@ public class GhastController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc != null) { npc.update(); NMSImpl.updateMinecraftAIState(npc, this); } - super.customServerAiStep(); + super.customServerAiStep(level); } @Override @@ -172,6 +166,13 @@ public class GhastController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public boolean updateFluidHeightAndDoFluidPushing(TagKey tagkey, double d0) { if (npc == null) diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GiantController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GiantController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GiantController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GiantController.java index 40f81d466..12b3b88a9 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GiantController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GiantController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftGiant; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftGiant; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class GiantController extends MobEntityController { public GiantController() { - super(EntityGiantNPC.class); + super(EntityGiantNPC.class, EntityType.GIANT); } @Override @@ -73,13 +74,6 @@ public class GiantController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class GiantController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -200,12 +194,19 @@ public class GiantController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GlowSquidController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GlowSquidController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GlowSquidController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GlowSquidController.java index 814146615..8713533f0 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GlowSquidController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GlowSquidController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftGlowSquid; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftGlowSquid; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class GlowSquidController extends MobEntityController { public GlowSquidController() { - super(EntityGlowSquidNPC.class); + super(EntityGlowSquidNPC.class, EntityType.GLOW_SQUID); } @Override @@ -73,13 +74,6 @@ public class GlowSquidController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class GlowSquidController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -200,12 +194,19 @@ public class GlowSquidController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GoatController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GoatController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GoatController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GoatController.java index 6453d0a5e..709d59c64 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GoatController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GoatController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftGoat; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftGoat; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -29,13 +30,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class GoatController extends MobEntityController { public GoatController() { - super(EntityGoatNPC.class); + super(EntityGoatNPC.class, EntityType.GOAT); } @Override @@ -74,13 +75,6 @@ public class GoatController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -96,8 +90,8 @@ public class GoatController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -201,12 +195,19 @@ public class GoatController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GuardianController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GuardianController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GuardianController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GuardianController.java index 118610e0e..1a06cede9 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GuardianController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GuardianController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftGuardian; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftGuardian; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -28,13 +28,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class GuardianController extends MobEntityController { public GuardianController() { - super(EntityGuardianNPC.class); + super(EntityGuardianNPC.class, EntityType.GUARDIAN); } @Override @@ -88,13 +88,6 @@ public class GuardianController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -206,12 +199,19 @@ public class GuardianController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GuardianElderController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GuardianElderController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GuardianElderController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GuardianElderController.java index 0bb27be5e..e5d90585c 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/GuardianElderController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/GuardianElderController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftElderGuardian; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftElderGuardian; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -28,13 +28,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class GuardianElderController extends MobEntityController { public GuardianElderController() { - super(EntityGuardianElderNPC.class); + super(EntityGuardianElderNPC.class, EntityType.ELDER_GUARDIAN); } @Override @@ -88,13 +88,6 @@ public class GuardianElderController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -206,12 +199,19 @@ public class GuardianElderController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HoglinController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HoglinController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HoglinController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HoglinController.java index fa5310b55..e8b21cf66 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HoglinController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HoglinController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftHoglin; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftHoglin; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class HoglinController extends MobEntityController { public HoglinController() { - super(EntityHoglinNPC.class); + super(EntityHoglinNPC.class, EntityType.HOGLIN); } @Override @@ -76,13 +77,6 @@ public class HoglinController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -98,12 +92,12 @@ public class HoglinController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); setImmuneToZombification(true); } - super.customServerAiStep(); + super.customServerAiStep(level); if (npc != null) { npc.update(); } @@ -197,12 +191,19 @@ public class HoglinController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HorseController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HorseController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HorseController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HorseController.java index d4dbaf88e..0ee55e971 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HorseController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HorseController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftHorse; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftHorse; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.Controllable; @@ -19,6 +19,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -33,13 +34,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class HorseController extends MobEntityController { public HorseController() { - super(EntityHorseNPC.class); + super(EntityHorseNPC.class, EntityType.HORSE); } @Override @@ -55,9 +56,9 @@ public class HorseController extends MobEntityController { public static class EntityHorseNPC extends Horse implements NPCHolder { private double baseMovementSpeed; - private final CitizensNPC npc; private boolean riding; + public EntityHorseNPC(EntityType types, Level level) { this(types, level, null); } @@ -91,13 +92,6 @@ public class HorseController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -113,8 +107,8 @@ public class HorseController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc == null) return; NMSImpl.updateMinecraftAIState(npc, this); @@ -245,12 +239,19 @@ public class HorseController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HorseDonkeyController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HorseDonkeyController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HorseDonkeyController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HorseDonkeyController.java index ae74e60ee..553f247c4 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HorseDonkeyController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HorseDonkeyController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftDonkey; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftDonkey; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.Controllable; @@ -19,6 +19,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -33,13 +34,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class HorseDonkeyController extends MobEntityController { public HorseDonkeyController() { - super(EntityHorseDonkeyNPC.class); + super(EntityHorseDonkeyNPC.class, EntityType.DONKEY); } @Override @@ -55,9 +56,7 @@ public class HorseDonkeyController extends MobEntityController { public static class EntityHorseDonkeyNPC extends Donkey implements NPCHolder { private double baseMovementSpeed; - private final CitizensNPC npc; - private boolean riding; public EntityHorseDonkeyNPC(EntityType types, Level level) { @@ -93,13 +92,6 @@ public class HorseDonkeyController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -115,8 +107,8 @@ public class HorseDonkeyController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) { @@ -247,12 +239,19 @@ public class HorseDonkeyController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HorseMuleController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HorseMuleController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HorseMuleController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HorseMuleController.java index ee784591b..48c1ddcf7 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HorseMuleController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HorseMuleController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftMule; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftMule; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.Controllable; @@ -19,6 +19,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -33,13 +34,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class HorseMuleController extends MobEntityController { public HorseMuleController() { - super(EntityHorseMuleNPC.class); + super(EntityHorseMuleNPC.class, EntityType.MULE); } @Override @@ -55,9 +56,7 @@ public class HorseMuleController extends MobEntityController { public static class EntityHorseMuleNPC extends Mule implements NPCHolder { private double baseMovementSpeed; - private final CitizensNPC npc; - private boolean riding; public EntityHorseMuleNPC(EntityType types, Level level) { @@ -93,13 +92,6 @@ public class HorseMuleController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -115,8 +107,8 @@ public class HorseMuleController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) { @@ -247,12 +239,19 @@ public class HorseMuleController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HorseSkeletonController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HorseSkeletonController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HorseSkeletonController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HorseSkeletonController.java index 596606c9e..0bfe72733 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HorseSkeletonController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HorseSkeletonController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftSkeletonHorse; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftSkeletonHorse; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.Controllable; @@ -19,6 +19,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -33,13 +34,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class HorseSkeletonController extends MobEntityController { public HorseSkeletonController() { - super(EntityHorseSkeletonNPC.class); + super(EntityHorseSkeletonNPC.class, EntityType.SKELETON); } @Override @@ -55,10 +56,9 @@ public class HorseSkeletonController extends MobEntityController { public static class EntityHorseSkeletonNPC extends SkeletonHorse implements NPCHolder { private double baseMovementSpeed; - private final CitizensNPC npc; - private boolean riding; + public EntityHorseSkeletonNPC(EntityType types, Level level) { this(types, level, null); } @@ -92,13 +92,6 @@ public class HorseSkeletonController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -114,8 +107,8 @@ public class HorseSkeletonController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) { @@ -246,12 +239,19 @@ public class HorseSkeletonController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HorseZombieController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HorseZombieController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HorseZombieController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HorseZombieController.java index 6ed0553e6..6d6ee9e19 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HorseZombieController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HorseZombieController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftZombieHorse; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftZombieHorse; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.Controllable; @@ -19,6 +19,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -33,13 +34,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class HorseZombieController extends MobEntityController { public HorseZombieController() { - super(EntityHorseZombieNPC.class); + super(EntityHorseZombieNPC.class, EntityType.ZOMBIE_HORSE); } @Override @@ -55,9 +56,7 @@ public class HorseZombieController extends MobEntityController { public static class EntityHorseZombieNPC extends ZombieHorse implements NPCHolder { private double baseMovementSpeed; - private final CitizensNPC npc; - private boolean riding; public EntityHorseZombieNPC(EntityType types, Level level) { @@ -93,13 +92,6 @@ public class HorseZombieController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -115,8 +107,8 @@ public class HorseZombieController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) { @@ -247,12 +239,19 @@ public class HorseZombieController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HumanController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HumanController.java similarity index 94% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HumanController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HumanController.java index 309c122d8..00b0378e6 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/HumanController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/HumanController.java @@ -1,10 +1,8 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; - -import java.util.UUID; +package net.citizensnpcs.nms.v1_21_R2.entity; import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/IllusionerController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/IllusionerController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/IllusionerController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/IllusionerController.java index c29d7dea7..ed4f2aa3e 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/IllusionerController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/IllusionerController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftIllusioner; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftIllusioner; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class IllusionerController extends MobEntityController { public IllusionerController() { - super(EntityIllusionerNPC.class); + super(EntityIllusionerNPC.class, EntityType.ILLUSIONER); } @Override @@ -73,13 +74,6 @@ public class IllusionerController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class IllusionerController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -191,12 +185,19 @@ public class IllusionerController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/IronGolemController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/IronGolemController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/IronGolemController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/IronGolemController.java index fa1f92d26..7d924ea36 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/IronGolemController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/IronGolemController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftIronGolem; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftIronGolem; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class IronGolemController extends MobEntityController { public IronGolemController() { - super(EntityIronGolemNPC.class); + super(EntityIronGolemNPC.class, EntityType.IRON_GOLEM); } @Override @@ -73,13 +74,6 @@ public class IronGolemController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class IronGolemController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -200,12 +194,19 @@ public class IronGolemController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/LlamaController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/LlamaController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/LlamaController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/LlamaController.java index c46a17348..94ebf940e 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/LlamaController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/LlamaController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftLlama; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftLlama; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.Controllable; @@ -19,6 +19,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -33,13 +34,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class LlamaController extends MobEntityController { public LlamaController() { - super(EntityLlamaNPC.class); + super(EntityLlamaNPC.class, EntityType.LLAMA); } @Override @@ -55,9 +56,7 @@ public class LlamaController extends MobEntityController { public static class EntityLlamaNPC extends Llama implements NPCHolder { private double baseMovementSpeed; - private final CitizensNPC npc; - private boolean riding; public EntityLlamaNPC(EntityType types, Level level) { @@ -93,13 +92,6 @@ public class LlamaController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -115,8 +107,8 @@ public class LlamaController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) { @@ -247,12 +239,19 @@ public class LlamaController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/MagmaCubeController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/MagmaCubeController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/MagmaCubeController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/MagmaCubeController.java index 6cc3fca58..118f0eba3 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/MagmaCubeController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/MagmaCubeController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftMagmaCube; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftMagmaCube; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.EntityMoveControl; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.EntityMoveControl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -31,13 +31,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class MagmaCubeController extends MobEntityController { public MagmaCubeController() { - super(EntityMagmaCubeNPC.class); + super(EntityMagmaCubeNPC.class, EntityType.MAGMA_CUBE); } @Override @@ -83,13 +83,6 @@ public class MagmaCubeController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -208,6 +201,13 @@ public class MagmaCubeController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); @@ -228,7 +228,7 @@ public class MagmaCubeController extends MobEntityController { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/MobEntityController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/MobEntityController.java similarity index 87% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/MobEntityController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/MobEntityController.java index b4efb2ebc..7d6689dc2 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/MobEntityController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/MobEntityController.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import java.lang.reflect.Constructor; import java.util.Map; @@ -6,15 +6,16 @@ import java.util.WeakHashMap; import org.bukkit.Location; import org.bukkit.block.BlockFace; -import org.bukkit.craftbukkit.v1_21_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; import org.bukkit.entity.Entity; import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; -import net.citizensnpcs.nms.v1_21_R1.util.PitchableLookControl; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.PitchableLookControl; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.trait.ScoreboardTrait; +import net.citizensnpcs.util.NMS; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.control.LookControl; @@ -22,15 +23,16 @@ import net.minecraft.world.level.Level; public abstract class MobEntityController extends AbstractEntityController { private final Class clazz; + private final EntityType type; - protected MobEntityController(Class clazz) { - super(clazz); + protected MobEntityController(Class clazz, EntityType type) { + NMS.registerEntityClass(clazz, type); this.clazz = clazz; + this.type = type; } @Override protected Entity createEntity(Location at, NPC npc) { - EntityType type = NMSImpl.getEntityType(clazz); net.minecraft.world.entity.Entity entity = createEntityFromClass(type, ((CraftWorld) at.getWorld()).getHandle(), npc); if (entity instanceof Mob) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/MushroomCowController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/MushroomCowController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/MushroomCowController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/MushroomCowController.java index 7e4770bdd..d709af22c 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/MushroomCowController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/MushroomCowController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftMushroomCow; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftMushroomCow; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -32,13 +33,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class MushroomCowController extends MobEntityController { public MushroomCowController() { - super(EntityMushroomCowNPC.class); + super(EntityMushroomCowNPC.class, EntityType.MOOSHROOM); } @Override @@ -77,13 +78,6 @@ public class MushroomCowController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -99,8 +93,8 @@ public class MushroomCowController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -211,12 +205,19 @@ public class MushroomCowController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/OcelotController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/OcelotController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/OcelotController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/OcelotController.java index b3c244ccc..f4a97d47b 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/OcelotController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/OcelotController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftOcelot; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftOcelot; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -30,13 +31,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class OcelotController extends MobEntityController { public OcelotController() { - super(EntityOcelotNPC.class); + super(EntityOcelotNPC.class, EntityType.OCELOT); } @Override @@ -75,13 +76,6 @@ public class OcelotController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -97,10 +91,10 @@ public class OcelotController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { Pose old = this.getPose(); boolean restorePose = !this.getMoveControl().hasWanted(); - super.customServerAiStep(); + super.customServerAiStep(level); if (restorePose) { this.setPose(old); } @@ -207,12 +201,19 @@ public class OcelotController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PandaController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PandaController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PandaController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PandaController.java index 1cf921a94..58921ea52 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PandaController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PandaController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPanda; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPanda; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -29,13 +30,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class PandaController extends MobEntityController { public PandaController() { - super(EntityPandaNPC.class); + super(EntityPandaNPC.class, EntityType.PANDA); } @Override @@ -74,13 +75,6 @@ public class PandaController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -96,8 +90,8 @@ public class PandaController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -201,12 +195,19 @@ public class PandaController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ParrotController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ParrotController.java similarity index 88% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ParrotController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ParrotController.java index dc1561b4b..82058eddf 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ParrotController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ParrotController.java @@ -1,19 +1,20 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftParrot; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftParrot; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -30,13 +31,13 @@ import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ParrotController extends MobEntityController { public ParrotController() { - super(EntityParrotNPC.class); + super(EntityParrotNPC.class, EntityType.PARROT); } @Override @@ -71,13 +72,6 @@ public class ParrotController extends MobEntityController { return super.canRide(entity); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -86,13 +80,13 @@ public class ParrotController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc == null) { - super.customServerAiStep(); + super.customServerAiStep(level); } else { NMSImpl.updateMinecraftAIState(npc, this); if (npc.useMinecraftAI()) { - super.customServerAiStep(); + super.customServerAiStep(level); } npc.update(); } @@ -186,6 +180,13 @@ public class ParrotController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public boolean updateFluidHeightAndDoFluidPushing(TagKey tagkey, double d0) { if (npc == null) diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PhantomController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PhantomController.java similarity index 92% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PhantomController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PhantomController.java index 16e8828f5..2d84f094f 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PhantomController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PhantomController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPhantom; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPhantom; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.EntityMoveControl; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.EntityMoveControl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -32,13 +32,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class PhantomController extends MobEntityController { public PhantomController() { - super(EntityPhantomNPC.class); + super(EntityPhantomNPC.class, EntityType.PHANTOM); } @Override @@ -48,9 +48,7 @@ public class PhantomController extends MobEntityController { public static class EntityPhantomNPC extends Phantom implements NPCHolder { private final CitizensNPC npc; - private LookControl oldLookController; - private MoveControl oldMoveController; public EntityPhantomNPC(EntityType types, Level level) { @@ -108,13 +106,6 @@ public class PhantomController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -238,12 +229,19 @@ public class PhantomController extends MobEntityController { return npc != null ? false : super.shouldDespawnInPeaceful(); } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PigController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PigController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PigController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PigController.java index 7d0e39b97..7669f0391 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PigController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PigController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPig; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPig; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -31,13 +31,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class PigController extends MobEntityController { public PigController() { - super(EntityPigNPC.class); + super(EntityPigNPC.class, EntityType.PIG); } @Override @@ -76,13 +76,6 @@ public class PigController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -98,8 +91,8 @@ public class PigController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -209,6 +202,13 @@ public class PigController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void thunderHit(ServerLevel worldserver, LightningBolt entitylightning) { if (npc == null) { @@ -221,7 +221,7 @@ public class PigController extends MobEntityController { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PigZombieController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PigZombieController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PigZombieController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PigZombieController.java index 674de211c..0aa32f7be 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PigZombieController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PigZombieController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPigZombie; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPigZombie; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class PigZombieController extends MobEntityController { public PigZombieController() { - super(EntityPigZombieNPC.class); + super(EntityPigZombieNPC.class, EntityType.ZOMBIFIED_PIGLIN); } @Override @@ -73,13 +74,6 @@ public class PigZombieController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class PigZombieController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -191,12 +185,19 @@ public class PigZombieController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PiglinBruteController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PiglinBruteController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PiglinBruteController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PiglinBruteController.java index 9afb79c1b..3367eeee1 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PiglinBruteController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PiglinBruteController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPiglinBrute; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPiglinBrute; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class PiglinBruteController extends MobEntityController { public PiglinBruteController() { - super(EntityPiglinBruteNPC.class); + super(EntityPiglinBruteNPC.class, EntityType.PIGLIN_BRUTE); } @Override @@ -73,13 +74,6 @@ public class PiglinBruteController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,12 +89,12 @@ public class PiglinBruteController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); setImmuneToZombification(true); } - super.customServerAiStep(); + super.customServerAiStep(level); if (npc != null) { npc.update(); } @@ -194,12 +188,19 @@ public class PiglinBruteController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PiglinController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PiglinController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PiglinController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PiglinController.java index e98773268..6a03ed141 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PiglinController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PiglinController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPiglin; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPiglin; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -33,13 +34,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class PiglinController extends MobEntityController { public PiglinController() { - super(EntityPiglinNPC.class); + super(EntityPiglinNPC.class, EntityType.PIGLIN); } @Override @@ -78,13 +79,6 @@ public class PiglinController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -100,12 +94,12 @@ public class PiglinController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); setImmuneToZombification(true); } - super.customServerAiStep(); + super.customServerAiStep(level); if (npc != null) { npc.update(); } @@ -209,12 +203,19 @@ public class PiglinController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PillagerController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PillagerController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PillagerController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PillagerController.java index f5332f030..08590237e 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PillagerController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PillagerController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPillager; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPillager; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -29,13 +30,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class PillagerController extends MobEntityController { public PillagerController() { - super(EntityPillagerNPC.class); + super(EntityPillagerNPC.class, EntityType.PILLAGER); } @Override @@ -74,13 +75,6 @@ public class PillagerController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -96,8 +90,8 @@ public class PillagerController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -201,12 +195,19 @@ public class PillagerController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PolarBearController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PolarBearController.java similarity index 88% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PolarBearController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PolarBearController.java index 694d34205..f89117107 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PolarBearController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PolarBearController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPolarBear; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPolarBear; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -27,13 +28,13 @@ import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class PolarBearController extends MobEntityController { public PolarBearController() { - super(EntityPolarBearNPC.class); + super(EntityPolarBearNPC.class, EntityType.POLAR_BEAR); } @Override @@ -65,13 +66,6 @@ public class PolarBearController extends MobEntityController { return super.canRide(entity); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -80,8 +74,8 @@ public class PolarBearController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -177,6 +171,13 @@ public class PolarBearController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public boolean updateFluidHeightAndDoFluidPushing(TagKey tagkey, double d0) { if (npc == null) diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PufferFishController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PufferFishController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PufferFishController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PufferFishController.java index ace913da7..4d586d5cd 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/PufferFishController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/PufferFishController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPufferFish; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPufferFish; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.EntityMoveControl; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.EntityMoveControl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.versioned.PufferFishTrait; @@ -17,6 +17,7 @@ import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -38,13 +39,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class PufferFishController extends MobEntityController { public PufferFishController() { - super(EntityPufferFishNPC.class); + super(EntityPufferFishNPC.class, EntityType.PUFFERFISH); } @Override @@ -54,7 +55,6 @@ public class PufferFishController extends MobEntityController { public static class EntityPufferFishNPC extends Pufferfish implements NPCHolder { private final CitizensNPC npc; - private MoveControl oldMoveController; public EntityPufferFishNPC(EntityType types, Level level) { @@ -104,13 +104,6 @@ public class PufferFishController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -126,8 +119,8 @@ public class PufferFishController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); if (npc.useMinecraftAI() && this.moveControl != this.oldMoveController) { @@ -245,6 +238,13 @@ public class PufferFishController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { @@ -264,7 +264,7 @@ public class PufferFishController extends MobEntityController { super.travel(vec3d); } } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/RabbitController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/RabbitController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/RabbitController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/RabbitController.java index 9b90bd956..11211c440 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/RabbitController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/RabbitController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftRabbit; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftRabbit; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -30,13 +31,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class RabbitController extends MobEntityController { public RabbitController() { - super(EntityRabbitNPC.class); + super(EntityRabbitNPC.class, EntityType.RABBIT); } @Override @@ -75,13 +76,6 @@ public class RabbitController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -97,8 +91,8 @@ public class RabbitController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); if (npc.getNavigator().isNavigating()) { @@ -227,12 +221,19 @@ public class RabbitController extends MobEntityController { } } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/RavagerController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/RavagerController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/RavagerController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/RavagerController.java index 81c1923e0..389080d5d 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/RavagerController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/RavagerController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftRavager; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftRavager; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -29,13 +30,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class RavagerController extends MobEntityController { public RavagerController() { - super(EntityRavagerNPC.class); + super(EntityRavagerNPC.class, EntityType.RAVAGER); } @Override @@ -74,13 +75,6 @@ public class RavagerController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -96,8 +90,8 @@ public class RavagerController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -206,12 +200,19 @@ public class RavagerController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SalmonController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SalmonController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SalmonController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SalmonController.java index 56cb2d962..63e1b344a 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SalmonController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SalmonController.java @@ -1,21 +1,22 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftSalmon; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftSalmon; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.EntityMoveControl; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.EntityMoveControl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -35,13 +36,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class SalmonController extends MobEntityController { public SalmonController() { - super(EntitySalmonNPC.class); + super(EntitySalmonNPC.class, EntityType.SALMON); } @Override @@ -51,7 +52,6 @@ public class SalmonController extends MobEntityController { public static class EntitySalmonNPC extends Salmon implements NPCHolder { private final CitizensNPC npc; - private MoveControl oldMoveController; public EntitySalmonNPC(EntityType types, Level level) { @@ -98,13 +98,6 @@ public class SalmonController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -120,7 +113,7 @@ public class SalmonController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc != null) { NMSImpl.setNotInSchool(this); NMSImpl.updateMinecraftAIState(npc, this); @@ -131,7 +124,7 @@ public class SalmonController extends MobEntityController { this.moveControl = new EntityMoveControl(this); } } - super.customServerAiStep(); + super.customServerAiStep(level); if (npc != null) { npc.update(); } @@ -235,6 +228,13 @@ public class SalmonController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { @@ -242,7 +242,7 @@ public class SalmonController extends MobEntityController { super.travel(vec3d); } } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SheepController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SheepController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SheepController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SheepController.java index 3764a42aa..a64fbf008 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SheepController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SheepController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftSheep; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftSheep; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -29,13 +30,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class SheepController extends MobEntityController { public SheepController() { - super(EntitySheepNPC.class); + super(EntitySheepNPC.class, EntityType.SHEEP); } @Override @@ -74,13 +75,6 @@ public class SheepController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -96,8 +90,8 @@ public class SheepController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -201,12 +195,19 @@ public class SheepController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ShulkerController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ShulkerController.java similarity index 92% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ShulkerController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ShulkerController.java index 4865aab25..e135e4ccb 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ShulkerController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ShulkerController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftShulker; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftShulker; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -29,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ShulkerController extends MobEntityController { public ShulkerController() { - super(EntityShulkerNPC.class); + super(EntityShulkerNPC.class, EntityType.SHULKER); } @Override @@ -81,13 +81,6 @@ public class ShulkerController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -204,6 +197,13 @@ public class ShulkerController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override protected boolean teleportSomewhere() { return npc == null || npc.useMinecraftAI() ? super.teleportSomewhere() : false; @@ -223,7 +223,7 @@ public class ShulkerController extends MobEntityController { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SilverfishController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SilverfishController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SilverfishController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SilverfishController.java index b4ac6b7f7..c9662c91d 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SilverfishController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SilverfishController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftSilverfish; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftSilverfish; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class SilverfishController extends MobEntityController { public SilverfishController() { - super(EntitySilverfishNPC.class); + super(EntitySilverfishNPC.class, EntityType.SILVERFISH); } @Override @@ -73,13 +74,6 @@ public class SilverfishController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class SilverfishController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -200,12 +194,19 @@ public class SilverfishController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SkeletonController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SkeletonController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SkeletonController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SkeletonController.java index b53277cf9..76dc1e395 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SkeletonController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SkeletonController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftSkeleton; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftSkeleton; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class SkeletonController extends MobEntityController { public SkeletonController() { - super(EntitySkeletonNPC.class); + super(EntitySkeletonNPC.class, EntityType.SKELETON); } @Override @@ -73,13 +74,6 @@ public class SkeletonController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class SkeletonController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -200,12 +194,19 @@ public class SkeletonController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SkeletonStrayController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SkeletonStrayController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SkeletonStrayController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SkeletonStrayController.java index d77f5fd4a..de3375b7b 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SkeletonStrayController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SkeletonStrayController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftStray; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftStray; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class SkeletonStrayController extends MobEntityController { public SkeletonStrayController() { - super(EntityStrayNPC.class); + super(EntityStrayNPC.class, EntityType.STRAY); } @Override @@ -73,13 +74,6 @@ public class SkeletonStrayController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class SkeletonStrayController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -200,12 +194,19 @@ public class SkeletonStrayController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SkeletonWitherController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SkeletonWitherController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SkeletonWitherController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SkeletonWitherController.java index 9a940f474..22f1b8267 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SkeletonWitherController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SkeletonWitherController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftWitherSkeleton; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftWitherSkeleton; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class SkeletonWitherController extends MobEntityController { public SkeletonWitherController() { - super(EntitySkeletonWitherNPC.class); + super(EntitySkeletonWitherNPC.class, EntityType.WITHER_SKELETON); } @Override @@ -73,13 +74,6 @@ public class SkeletonWitherController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class SkeletonWitherController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -200,12 +194,19 @@ public class SkeletonWitherController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SlimeController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SlimeController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SlimeController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SlimeController.java index 4b3210b73..6d258bd5d 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SlimeController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SlimeController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftSlime; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftSlime; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.EntityMoveControl; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.EntityMoveControl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -31,13 +31,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class SlimeController extends MobEntityController { public SlimeController() { - super(EntitySlimeNPC.class); + super(EntitySlimeNPC.class, EntityType.SLIME); } @Override @@ -85,13 +85,6 @@ public class SlimeController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -210,6 +203,13 @@ public class SlimeController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); @@ -230,7 +230,7 @@ public class SlimeController extends MobEntityController { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SnifferController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SnifferController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SnifferController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SnifferController.java index d4686c0fd..c0b7a4a51 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SnifferController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SnifferController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftSniffer; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftSniffer; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -34,13 +35,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class SnifferController extends MobEntityController { public SnifferController() { - super(EntitySnifferNPC.class); + super(EntitySnifferNPC.class, EntityType.SNIFFER); } @Override @@ -79,13 +80,6 @@ public class SnifferController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -101,8 +95,8 @@ public class SnifferController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -216,12 +210,19 @@ public class SnifferController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SnowmanController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SnowmanController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SnowmanController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SnowmanController.java index 06f849aad..a2413fa64 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SnowmanController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SnowmanController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftSnowman; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftSnowman; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class SnowmanController extends MobEntityController { public SnowmanController() { - super(EntitySnowmanNPC.class); + super(EntitySnowmanNPC.class, EntityType.SNOW_GOLEM); } @Override @@ -73,13 +74,6 @@ public class SnowmanController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class SnowmanController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -200,12 +194,19 @@ public class SnowmanController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SpiderController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SpiderController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SpiderController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SpiderController.java index b74ca9b69..569e9d44c 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SpiderController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SpiderController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftSpider; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftSpider; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class SpiderController extends MobEntityController { public SpiderController() { - super(EntitySpiderNPC.class); + super(EntitySpiderNPC.class, EntityType.SPIDER); } @Override @@ -73,13 +74,6 @@ public class SpiderController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class SpiderController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -200,12 +194,19 @@ public class SpiderController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SquidController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SquidController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SquidController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SquidController.java index 9c68d4945..cb3402104 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/SquidController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/SquidController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftSquid; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftSquid; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class SquidController extends MobEntityController { public SquidController() { - super(EntitySquidNPC.class); + super(EntitySquidNPC.class, EntityType.SQUID); } @Override @@ -73,13 +74,6 @@ public class SquidController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class SquidController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -200,12 +194,19 @@ public class SquidController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/StriderController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/StriderController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/StriderController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/StriderController.java index f52df5f01..14e003013 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/StriderController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/StriderController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftStrider; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftStrider; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class StriderController extends MobEntityController { public StriderController() { - super(EntityStriderNPC.class); + super(EntityStriderNPC.class, EntityType.STRIDER); } @Override @@ -73,13 +74,6 @@ public class StriderController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class StriderController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -191,12 +185,19 @@ public class StriderController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/TadpoleController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/TadpoleController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/TadpoleController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/TadpoleController.java index 03ed8fcbe..f3a706452 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/TadpoleController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/TadpoleController.java @@ -1,21 +1,22 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftTadpole; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftTadpole; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.EntityMoveControl; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.EntityMoveControl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.ItemTags; @@ -36,13 +37,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class TadpoleController extends MobEntityController { public TadpoleController() { - super(EntityTadpoleNPC.class); + super(EntityTadpoleNPC.class, EntityType.TADPOLE); } @Override @@ -99,13 +100,6 @@ public class TadpoleController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -121,7 +115,7 @@ public class TadpoleController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); if (npc.useMinecraftAI() && this.moveControl != this.oldMoveController) { @@ -131,7 +125,7 @@ public class TadpoleController extends MobEntityController { this.moveControl = new EntityMoveControl(this); } } - super.customServerAiStep(); + super.customServerAiStep(level); if (npc != null) { npc.update(); } @@ -235,6 +229,13 @@ public class TadpoleController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { @@ -242,7 +243,7 @@ public class TadpoleController extends MobEntityController { super.travel(vec3d); } } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/TraderLlamaController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/TraderLlamaController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/TraderLlamaController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/TraderLlamaController.java index 8d2925616..b17182688 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/TraderLlamaController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/TraderLlamaController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftTraderLlama; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftTraderLlama; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.HorseModifiers; @@ -18,6 +18,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -31,13 +32,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class TraderLlamaController extends MobEntityController { public TraderLlamaController() { - super(EntityTraderLlamaNPC.class); + super(EntityTraderLlamaNPC.class, EntityType.TRADER_LLAMA); } @Override @@ -86,13 +87,6 @@ public class TraderLlamaController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -108,13 +102,13 @@ public class TraderLlamaController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc == null) { - super.customServerAiStep(); + super.customServerAiStep(level); } else { NMSImpl.updateMinecraftAIState(npc, this); if (npc.useMinecraftAI()) { - super.customServerAiStep(); + super.customServerAiStep(level); } setDespawnDelay(10); NMS.setStepHeight(getBukkitEntity(), 1); @@ -219,12 +213,19 @@ public class TraderLlamaController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/TropicalFishController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/TropicalFishController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/TropicalFishController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/TropicalFishController.java index 9009da7b9..43a7fe5b3 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/TropicalFishController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/TropicalFishController.java @@ -1,21 +1,22 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftTropicalFish; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftTropicalFish; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.EntityMoveControl; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.EntityMoveControl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -35,13 +36,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class TropicalFishController extends MobEntityController { public TropicalFishController() { - super(EntityTropicalFishNPC.class); + super(EntityTropicalFishNPC.class, EntityType.TROPICAL_FISH); } @Override @@ -98,13 +99,6 @@ public class TropicalFishController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -120,7 +114,7 @@ public class TropicalFishController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc != null) { if (!npc.useMinecraftAI()) { NMSImpl.setNotInSchool(this); @@ -133,7 +127,7 @@ public class TropicalFishController extends MobEntityController { this.moveControl = new EntityMoveControl(this); } } - super.customServerAiStep(); + super.customServerAiStep(level); if (npc != null) { npc.update(); } @@ -237,6 +231,13 @@ public class TropicalFishController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { @@ -244,7 +245,7 @@ public class TropicalFishController extends MobEntityController { super.travel(vec3d); } } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/TurtleController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/TurtleController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/TurtleController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/TurtleController.java index de395a6b9..7dfd2bbfd 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/TurtleController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/TurtleController.java @@ -1,21 +1,22 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftTurtle; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftTurtle; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.EntityMoveControl; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.EntityMoveControl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -32,13 +33,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class TurtleController extends MobEntityController { public TurtleController() { - super(EntityTurtleNPC.class); + super(EntityTurtleNPC.class, EntityType.TURTLE); } @Override @@ -87,13 +88,6 @@ public class TurtleController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -109,8 +103,8 @@ public class TurtleController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); if (npc.useMinecraftAI() && this.moveControl != this.oldMoveController) { @@ -213,6 +207,13 @@ public class TurtleController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { @@ -220,7 +221,7 @@ public class TurtleController extends MobEntityController { super.travel(vec3d); } } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/VexController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/VexController.java similarity index 88% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/VexController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/VexController.java index 9f7888076..75ddc6e83 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/VexController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/VexController.java @@ -1,19 +1,20 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftVex; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftVex; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -26,13 +27,13 @@ import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class VexController extends MobEntityController { public VexController() { - super(EntityVexNPC.class); + super(EntityVexNPC.class, EntityType.VEX); } @Override @@ -67,13 +68,6 @@ public class VexController extends MobEntityController { return super.canRide(entity); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -82,8 +76,8 @@ public class VexController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -170,6 +164,13 @@ public class VexController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public boolean updateFluidHeightAndDoFluidPushing(TagKey tagkey, double d0) { if (npc == null) diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/VillagerController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/VillagerController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/VillagerController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/VillagerController.java index e35121814..f2e34f832 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/VillagerController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/VillagerController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftVillager; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftVillager; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -36,13 +36,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class VillagerController extends MobEntityController { public VillagerController() { - super(EntityVillagerNPC.class); + super(EntityVillagerNPC.class, EntityType.VILLAGER); } @Override @@ -86,13 +86,6 @@ public class VillagerController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -108,11 +101,11 @@ public class VillagerController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); } - super.customServerAiStep(); + super.customServerAiStep(level); if (npc != null) { npc.update(); } @@ -236,6 +229,13 @@ public class VillagerController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void thunderHit(ServerLevel worldserver, LightningBolt entitylightning) { if (npc == null) { @@ -248,7 +248,7 @@ public class VillagerController extends MobEntityController { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/VindicatorController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/VindicatorController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/VindicatorController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/VindicatorController.java index 706ceba80..df66bb4c4 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/VindicatorController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/VindicatorController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftVindicator; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftVindicator; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -16,6 +16,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -29,13 +30,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class VindicatorController extends MobEntityController { public VindicatorController() { - super(EntityVindicatorNPC.class); + super(EntityVindicatorNPC.class, EntityType.VINDICATOR); } @Override @@ -74,13 +75,6 @@ public class VindicatorController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -96,8 +90,8 @@ public class VindicatorController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -201,12 +195,19 @@ public class VindicatorController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/WanderingTraderController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/WanderingTraderController.java similarity index 91% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/WanderingTraderController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/WanderingTraderController.java index cdcacf95e..6f31d8afd 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/WanderingTraderController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/WanderingTraderController.java @@ -1,14 +1,14 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftWanderingTrader; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftWanderingTrader; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -35,13 +35,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class WanderingTraderController extends MobEntityController { public WanderingTraderController() { - super(EntityWanderingTraderNPC.class); + super(EntityWanderingTraderNPC.class, EntityType.WANDERING_TRADER); } @Override @@ -51,9 +51,7 @@ public class WanderingTraderController extends MobEntityController { public static class EntityWanderingTraderNPC extends WanderingTrader implements NPCHolder { private boolean blockingATrade; - private boolean blockTrades = true; - private final CitizensNPC npc; public EntityWanderingTraderNPC(EntityType types, Level level) { @@ -84,13 +82,6 @@ public class WanderingTraderController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -106,11 +97,11 @@ public class WanderingTraderController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); } - super.customServerAiStep(); + super.customServerAiStep(level); if (npc != null) { setDespawnDelay(10); npc.update(); @@ -243,6 +234,13 @@ public class WanderingTraderController extends MobEntityController { this.blockTrades = blocked; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void thunderHit(ServerLevel worldserver, LightningBolt entitylightning) { if (npc == null) { @@ -255,7 +253,7 @@ public class WanderingTraderController extends MobEntityController { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/WardenController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/WardenController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/WardenController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/WardenController.java index 80083f961..c1c521668 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/WardenController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/WardenController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftWarden; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftWarden; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -30,13 +31,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class WardenController extends MobEntityController { public WardenController() { - super(EntityWardenNPC.class); + super(EntityWardenNPC.class, EntityType.WARDEN); } @Override @@ -76,13 +77,6 @@ public class WardenController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -98,15 +92,15 @@ public class WardenController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc == null) { - super.customServerAiStep(); + super.customServerAiStep(level); return; } NMSImpl.updateMinecraftAIState(npc, this); npc.update(); if (npc.useMinecraftAI()) { - super.customServerAiStep(); + super.customServerAiStep(level); } } @@ -198,12 +192,19 @@ public class WardenController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/WitchController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/WitchController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/WitchController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/WitchController.java index 3ed19e8c6..0a1c518cb 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/WitchController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/WitchController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftWitch; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftWitch; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class WitchController extends MobEntityController { public WitchController() { - super(EntityWitchNPC.class); + super(EntityWitchNPC.class, EntityType.WITCH); } @Override @@ -73,13 +74,6 @@ public class WitchController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class WitchController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -200,12 +194,19 @@ public class WitchController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/WitherController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/WitherController.java similarity index 88% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/WitherController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/WitherController.java index a46704842..359aa68f5 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/WitherController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/WitherController.java @@ -1,19 +1,20 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftWither; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftWither; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -26,13 +27,13 @@ import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class WitherController extends MobEntityController { public WitherController() { - super(EntityWitherNPC.class); + super(EntityWitherNPC.class, EntityType.WITHER); } @Override @@ -64,13 +65,6 @@ public class WitherController extends MobEntityController { return super.canRide(entity); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -79,13 +73,13 @@ public class WitherController extends MobEntityController { } @Override - protected void customServerAiStep() { + protected void customServerAiStep(ServerLevel level) { if (npc == null) { - super.customServerAiStep(); + super.customServerAiStep(level); } else { NMSImpl.updateMinecraftAIState(npc, this); if (npc.useMinecraftAI()) { - super.customServerAiStep(); + super.customServerAiStep(level); } npc.update(); } @@ -182,6 +176,13 @@ public class WitherController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public boolean updateFluidHeightAndDoFluidPushing(TagKey tagkey, double d0) { if (npc == null) diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/WolfController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/WolfController.java similarity index 90% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/WolfController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/WolfController.java index 83cef68a1..d59c3abcc 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/WolfController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/WolfController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftWolf; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftWolf; import org.bukkit.event.entity.EntityTargetEvent; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -17,6 +17,7 @@ import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -31,13 +32,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class WolfController extends MobEntityController { public WolfController() { - super(EntityWolfNPC.class); + super(EntityWolfNPC.class, EntityType.WOLF); } @Override @@ -76,13 +77,6 @@ public class WolfController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -98,8 +92,8 @@ public class WolfController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -208,12 +202,19 @@ public class WolfController extends MobEntityController { return npc == null || this.equals(entityliving) ? super.setTarget(entityliving, reason, fire) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ZoglinController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ZoglinController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ZoglinController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ZoglinController.java index e8fe0103d..d98d4fbf0 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ZoglinController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ZoglinController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftZoglin; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftZoglin; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ZoglinController extends MobEntityController { public ZoglinController() { - super(EntityZoglinNPC.class); + super(EntityZoglinNPC.class, EntityType.ZOGLIN); } @Override @@ -73,13 +74,6 @@ public class ZoglinController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,11 +89,11 @@ public class ZoglinController extends MobEntityController { } @Override - public void customServerAiStep() { + public void customServerAiStep(ServerLevel level) { if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); } - super.customServerAiStep(); + super.customServerAiStep(level); if (npc != null) { npc.update(); } @@ -193,12 +187,19 @@ public class ZoglinController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ZombieController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ZombieController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ZombieController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ZombieController.java index fd0392de0..768781e65 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ZombieController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ZombieController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftZombie; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftZombie; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ZombieController extends MobEntityController { public ZombieController() { - super(EntityZombieNPC.class); + super(EntityZombieNPC.class, EntityType.ZOMBIE); } @Override @@ -73,13 +74,6 @@ public class ZombieController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class ZombieController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -191,12 +185,19 @@ public class ZombieController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ZombieHuskController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ZombieHuskController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ZombieHuskController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ZombieHuskController.java index 2072ea664..4feabd9f3 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ZombieHuskController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ZombieHuskController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftHusk; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftHusk; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ZombieHuskController extends MobEntityController { public ZombieHuskController() { - super(EntityZombieHuskNPC.class); + super(EntityZombieHuskNPC.class, EntityType.HUSK); } @Override @@ -73,13 +74,6 @@ public class ZombieHuskController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class ZombieHuskController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -191,12 +185,19 @@ public class ZombieHuskController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ZombieVillagerController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ZombieVillagerController.java similarity index 89% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ZombieVillagerController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ZombieVillagerController.java index 5d2cce3d7..810e9b1ff 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/ZombieVillagerController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/ZombieVillagerController.java @@ -1,20 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity; +package net.citizensnpcs.nms.v1_21_R2.entity; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftVillagerZombie; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftVillagerZombie; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; @@ -28,13 +29,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ZombieVillagerController extends MobEntityController { public ZombieVillagerController() { - super(EntityZombieVillagerNPC.class); + super(EntityZombieVillagerNPC.class, EntityType.ZOMBIE_VILLAGER); } @Override @@ -73,13 +74,6 @@ public class ZombieVillagerController extends MobEntityController { return false; } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public void checkDespawn() { if (npc == null) { @@ -95,8 +89,8 @@ public class ZombieVillagerController extends MobEntityController { } @Override - public void customServerAiStep() { - super.customServerAiStep(); + public void customServerAiStep(ServerLevel level) { + super.customServerAiStep(level); if (npc != null) { NMSImpl.updateMinecraftAIState(npc, this); npc.update(); @@ -191,12 +185,19 @@ public class ZombieVillagerController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void travel(Vec3 vec3d) { if (npc == null || !npc.isFlyable()) { super.travel(vec3d); } else { - NMSImpl.flyingMoveLogic(this, vec3d); + NMSImpl.moveLogic(this, vec3d); } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/AreaEffectCloudController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/AreaEffectCloudController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/AreaEffectCloudController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/AreaEffectCloudController.java index 6ad9630a1..910042073 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/AreaEffectCloudController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/AreaEffectCloudController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftAreaEffectCloud; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftAreaEffectCloud; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class AreaEffectCloudController extends MobEntityController { public AreaEffectCloudController() { - super(EntityAreaEffectCloudNPC.class); + super(EntityAreaEffectCloudNPC.class, EntityType.AREA_EFFECT_CLOUD); } @Override @@ -60,13 +60,6 @@ public class AreaEffectCloudController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -111,6 +104,13 @@ public class AreaEffectCloudController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/BlockDisplayController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/BlockDisplayController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/BlockDisplayController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/BlockDisplayController.java index 824a99812..0a1ddd332 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/BlockDisplayController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/BlockDisplayController.java @@ -1,17 +1,17 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftBlockDisplay; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftBlockDisplay; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -25,13 +25,13 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class BlockDisplayController extends MobEntityController { public BlockDisplayController() { - super(EntityBlockDisplayNPC.class); + super(EntityBlockDisplayNPC.class, EntityType.BLOCK_DISPLAY); } @Override @@ -73,14 +73,6 @@ public class BlockDisplayController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -125,6 +117,14 @@ public class BlockDisplayController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/BoatController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/BoatController.java similarity index 80% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/BoatController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/BoatController.java index b5250b251..0916bbe89 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/BoatController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/BoatController.java @@ -1,16 +1,21 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; + +import java.util.function.Supplier; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftBoat; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftBoat; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import org.bukkit.entity.Player; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.api.trait.trait.MobType; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; +import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -25,17 +30,59 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MoverType; import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; -public class BoatController extends MobEntityController { - public BoatController() { - super(EntityBoatNPC.class); +public class BoatController extends AbstractEntityController { + @Override + protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { + EntityType type = EntityType.OAK_BOAT; + Item item = Items.OAK_BOAT; + switch (npc.getOrAddTrait(MobType.class).getType()) { + case ACACIA_BOAT: + type = EntityType.ACACIA_BOAT; + item = Items.ACACIA_BOAT; + break; + case BIRCH_BOAT: + type = EntityType.BIRCH_BOAT; + item = Items.BIRCH_BOAT; + break; + case CHERRY_BOAT: + type = EntityType.CHERRY_BOAT; + item = Items.CHERRY_BOAT; + break; + case DARK_OAK_BOAT: + type = EntityType.DARK_OAK_BOAT; + item = Items.DARK_OAK_BOAT; + break; + case JUNGLE_BOAT: + type = EntityType.JUNGLE_BOAT; + item = Items.JUNGLE_BOAT; + break; + case MANGROVE_BOAT: + type = EntityType.MANGROVE_BOAT; + item = Items.MANGROVE_BOAT; + break; + case OAK_BOAT: + break; + case SPRUCE_BOAT: + type = EntityType.SPRUCE_BOAT; + item = Items.SPRUCE_BOAT; + break; + default: + break; + } + final Item fitem = item; + final EntityBoatNPC handle = new EntityBoatNPC(type, ((CraftWorld) at.getWorld()).getHandle(), () -> fitem, + npc); + return handle.getBukkitEntity(); } @Override @@ -51,18 +98,18 @@ public class BoatController extends MobEntityController { public static class EntityBoatNPC extends Boat implements NPCHolder { private float invFriction; - private float landFriction; private Status lastStatus; private final CitizensNPC npc; private Status status; private double waterLevel; - public EntityBoatNPC(EntityType types, Level level) { - this(types, level, null); + + public EntityBoatNPC(EntityType types, Level level, Supplier supplier) { + this(types, level, supplier, null); } - public EntityBoatNPC(EntityType types, Level level, NPC npc) { - super(types, level); + public EntityBoatNPC(EntityType types, Level level, Supplier supplier, NPC npc) { + super(types, level, supplier); this.npc = (CitizensNPC) npc; } @@ -71,13 +118,6 @@ public class BoatController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - private boolean checkInWater() { AABB axisalignedbb = this.getBoundingBox(); int i = Mth.floor(axisalignedbb.minX); @@ -246,6 +286,13 @@ public class BoatController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { @@ -265,7 +312,7 @@ public class BoatController extends MobEntityController { status = getStatus(); floatBoat(); move(MoverType.SELF, getDeltaMovement()); - checkInsideBlocks(); + applyEffectsFromBlocks(); } else { super.tick(); } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/BreezeWindChargeController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/BreezeWindChargeController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/BreezeWindChargeController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/BreezeWindChargeController.java index fa9f9a72b..49e626669 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/BreezeWindChargeController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/BreezeWindChargeController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftBreezeWindCharge; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftBreezeWindCharge; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.projectile.windcharge.BreezeWindCharge; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class BreezeWindChargeController extends MobEntityController { public BreezeWindChargeController() { - super(EntityBreezeWindChargeNPC.class); + super(EntityBreezeWindChargeNPC.class, EntityType.BREEZE_WIND_CHARGE); } @Override @@ -60,13 +60,6 @@ public class BreezeWindChargeController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -111,6 +104,13 @@ public class BreezeWindChargeController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ChestBoatController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ChestBoatController.java similarity index 75% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ChestBoatController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ChestBoatController.java index 1230844a1..2fe488956 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ChestBoatController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ChestBoatController.java @@ -1,15 +1,20 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; + +import java.util.function.Supplier; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftChestBoat; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftChestBoat; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.api.trait.trait.MobType; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; +import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,19 +28,60 @@ import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MoverType; -import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.entity.vehicle.ChestBoat; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; -public class ChestBoatController extends MobEntityController { - public ChestBoatController() { - super(EntityChestBoatNPC.class); +public class ChestBoatController extends AbstractEntityController { + @Override + protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { + EntityType type = EntityType.OAK_CHEST_BOAT; + Item item = Items.OAK_CHEST_BOAT; + switch (npc.getOrAddTrait(MobType.class).getType()) { + case ACACIA_CHEST_BOAT: + type = EntityType.ACACIA_CHEST_BOAT; + item = Items.ACACIA_CHEST_BOAT; + break; + case BIRCH_CHEST_BOAT: + type = EntityType.BIRCH_CHEST_BOAT; + item = Items.BIRCH_CHEST_BOAT; + break; + case CHERRY_CHEST_BOAT: + type = EntityType.CHERRY_CHEST_BOAT; + item = Items.CHERRY_CHEST_BOAT; + break; + case DARK_OAK_CHEST_BOAT: + type = EntityType.DARK_OAK_CHEST_BOAT; + item = Items.DARK_OAK_CHEST_BOAT; + break; + case JUNGLE_CHEST_BOAT: + type = EntityType.JUNGLE_CHEST_BOAT; + item = Items.JUNGLE_CHEST_BOAT; + break; + case MANGROVE_CHEST_BOAT: + type = EntityType.MANGROVE_CHEST_BOAT; + item = Items.MANGROVE_CHEST_BOAT; + break; + case OAK_BOAT: + break; + case SPRUCE_CHEST_BOAT: + type = EntityType.SPRUCE_CHEST_BOAT; + item = Items.SPRUCE_CHEST_BOAT; + break; + default: + break; + } + final Item fitem = item; + final EntityChestBoatNPC handle = new EntityChestBoatNPC(type, ((CraftWorld) at.getWorld()).getHandle(), + () -> fitem, npc); + return handle.getBukkitEntity(); } @Override @@ -51,20 +97,20 @@ public class ChestBoatController extends MobEntityController { public static class EntityChestBoatNPC extends ChestBoat implements NPCHolder { private double aC; - private float aD; - private Status aE; private Status aF; private double ap; private double ar; private final CitizensNPC npc; - public EntityChestBoatNPC(EntityType types, Level level) { - this(types, level, null); + + public EntityChestBoatNPC(EntityType types, Level level, Supplier supplier) { + this(types, level, supplier, null); } - public EntityChestBoatNPC(EntityType types, Level level, NPC npc) { - super(types, level); + public EntityChestBoatNPC(EntityType types, Level level, Supplier supplier, + NPC npc) { + super(types, level, supplier); this.npc = (CitizensNPC) npc; } @@ -73,13 +119,6 @@ public class ChestBoatController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -177,6 +216,13 @@ public class ChestBoatController extends MobEntityController { return m; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ChestRaftController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ChestRaftController.java new file mode 100644 index 000000000..70d3713bd --- /dev/null +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ChestRaftController.java @@ -0,0 +1,278 @@ +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; + +import java.util.function.Supplier; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftChestBoat; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; + +import net.citizensnpcs.api.npc.NPC; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; +import net.citizensnpcs.npc.AbstractEntityController; +import net.citizensnpcs.npc.CitizensNPC; +import net.citizensnpcs.npc.ai.NPCHolder; +import net.citizensnpcs.util.NMS; +import net.citizensnpcs.util.Util; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.tags.FluidTags; +import net.minecraft.tags.TagKey; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.MoverType; +import net.minecraft.world.entity.vehicle.ChestRaft; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.level.portal.TeleportTransition; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; + +public class ChestRaftController extends AbstractEntityController { + + @Override + protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { + final EntityChestRaftNPC handle = new EntityChestRaftNPC(EntityType.BAMBOO_CHEST_RAFT, + ((CraftWorld) at.getWorld()).getHandle(), () -> Items.BAMBOO_CHEST_RAFT, npc); + return handle.getBukkitEntity(); + } + + @Override + public org.bukkit.entity.ChestBoat getBukkitEntity() { + return (org.bukkit.entity.ChestBoat) super.getBukkitEntity(); + } + + public static class ChestRaftNPC extends CraftChestBoat implements ForwardingNPCHolder { + public ChestRaftNPC(EntityChestRaftNPC entity) { + super((CraftServer) Bukkit.getServer(), entity); + } + } + + public static class EntityChestRaftNPC extends ChestRaft implements NPCHolder { + private double aC; + private float aD; + private Status aE; + private Status aF; + private double ap; + private double ar; + private final CitizensNPC npc; + + public EntityChestRaftNPC(EntityType types, Level level, Supplier supplier) { + this(types, level, supplier, null); + } + + public EntityChestRaftNPC(EntityType types, Level level, Supplier supplier, + NPC npc) { + super(types, level, supplier); + this.npc = (CitizensNPC) npc; + } + + @Override + public boolean broadcastToPlayer(ServerPlayer player) { + return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); + } + + @Override + public CraftEntity getBukkitEntity() { + if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { + NMSImpl.setBukkitEntity(this, new ChestRaftNPC(this)); + } + return super.getBukkitEntity(); + } + + @Override + public NPC getNPC() { + return npc; + } + + @Override + public PushReaction getPistonPushReaction() { + return Util.callPistonPushEvent(npc) ? PushReaction.IGNORE : super.getPistonPushReaction(); + } + + private Status getStatus() { + Status entityRaft_Status = u(); + if (entityRaft_Status != null) { + this.aC = getBoundingBox().maxY; + return entityRaft_Status; + } + if (t()) + return Status.IN_WATER; + float f = getGroundFriction(); + if (f > 0.0F) { + this.aD = f; + return Status.ON_LAND; + } + return Status.IN_AIR; + } + + @Override + public boolean isPushable() { + return npc == null ? super.isPushable() + : npc.data(). get(NPC.Metadata.COLLIDABLE, !npc.isProtected()); + } + + @Override + protected AABB makeBoundingBox() { + return NMSBoundingBox.makeBB(npc, super.makeBoundingBox()); + } + + @Override + public void push(Entity entity) { + // this method is called by both the entities involved - cancelling + // it will not stop the NPC from moving. + super.push(entity); + if (npc != null) { + Util.callCollisionEvent(npc, entity.getBukkitEntity()); + } + } + + @Override + public void refreshDimensions() { + if (npc == null) { + super.refreshDimensions(); + } else { + NMSImpl.setSize(this, firstTick); + } + } + + @Override + public boolean save(CompoundTag save) { + return npc == null ? super.save(save) : false; + } + + private boolean t() { + boolean m = false; + AABB axisalignedbb = getBoundingBox(); + int i = Mth.floor(axisalignedbb.minX); + int j = Mth.ceil(axisalignedbb.maxX); + int k = Mth.floor(axisalignedbb.minY); + int l = Mth.ceil(axisalignedbb.minY + 0.001D); + int i1 = Mth.floor(axisalignedbb.minZ); + int j1 = Mth.ceil(axisalignedbb.maxZ); + boolean flag = false; + this.aC = Double.MIN_VALUE; + BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); + for (int k1 = i; k1 < j; k1++) { + for (int l1 = k; l1 < l; l1++) { + for (int i2 = i1; i2 < j1; i2++) { + blockposition_mutableblockposition.set(k1, l1, i2); + FluidState fluid = this.level().getFluidState(blockposition_mutableblockposition); + if (fluid.is(FluidTags.WATER)) { + float f = l1 + fluid.getHeight(this.level(), blockposition_mutableblockposition); + this.aC = Math.max(f, this.aC); + m = flag | (axisalignedbb.minY < f ? true : false); + } + } + } + } + return m; + } + + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + + @Override + public void tick() { + if (npc != null) { + npc.update(); + this.aF = this.aE; + aE = getStatus(); + double d1 = isNoGravity() ? 0.0D : -0.04D; + double d2 = 0.0D; + this.ap = 0.05F; + if (this.aF == Status.IN_AIR && this.aE != Status.IN_AIR && this.aE != Status.ON_LAND) { + this.aC = getY(1.0D); + setPos(getX(), getWaterLevelAbove() - getBbHeight() + 0.101D, getZ()); + setDeltaMovement(getDeltaMovement().multiply(1.0D, 0.0D, 1.0D)); + this.aE = Status.IN_WATER; + } else { + if (this.aE == Status.IN_WATER) { + d2 = (this.aC - getY()) / getBbHeight(); + this.ap = 0.9F; + } else if (this.aE == Status.UNDER_FLOWING_WATER) { + d1 = -7.0E-4D; + this.ap = 0.9F; + } else if (this.aE == Status.UNDER_WATER) { + d2 = 0.01D; + this.ap = 0.45F; + } else if (this.aE == Status.IN_AIR) { + this.ap = 0.9F; + } else if (this.aE == Status.ON_LAND) { + this.ap = this.aD; + if (getControllingPassenger() instanceof ServerPlayer) { + this.aD /= 2.0F; + } + } + Vec3 vec3d = getDeltaMovement(); + setDeltaMovement(vec3d.x * this.ap, vec3d.y + d1, vec3d.z * this.ap); + this.ar *= this.ap; + if (d2 > 0.0D) { + Vec3 vec3d1 = getDeltaMovement(); + setDeltaMovement(vec3d1.x, vec3d1.y + d2 * 0.0615D, vec3d1.z); + } + } + move(MoverType.SELF, getDeltaMovement()); + if (isVehicle()) { + setYRot((float) (getYRot() + this.ar)); + } + } else { + super.tick(); + } + } + + private Status u() { + AABB axisalignedbb = getBoundingBox(); + double d0 = axisalignedbb.maxY + 0.001D; + int i = Mth.floor(axisalignedbb.minX); + int j = Mth.ceil(axisalignedbb.maxX); + int k = Mth.floor(axisalignedbb.maxY); + int l = Mth.ceil(d0); + int i1 = Mth.floor(axisalignedbb.minZ); + int j1 = Mth.ceil(axisalignedbb.maxZ); + boolean flag = false; + BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); + for (int k1 = i; k1 < j; k1++) { + for (int l1 = k; l1 < l; l1++) { + for (int i2 = i1; i2 < j1; i2++) { + blockposition_mutableblockposition.set(k1, l1, i2); + FluidState fluid = this.level().getFluidState(blockposition_mutableblockposition); + if (fluid.is(FluidTags.WATER) && d0 < blockposition_mutableblockposition.getY() + + fluid.getHeight(this.level(), blockposition_mutableblockposition)) { + if (!fluid.isSource()) + return Status.UNDER_FLOWING_WATER; + flag = true; + } + } + } + } + return flag ? Status.UNDER_WATER : null; + } + + @Override + public boolean updateFluidHeightAndDoFluidPushing(TagKey tagkey, double d0) { + if (npc == null) + return super.updateFluidHeightAndDoFluidPushing(tagkey, d0); + Vec3 old = getDeltaMovement().add(0, 0, 0); + boolean res = super.updateFluidHeightAndDoFluidPushing(tagkey, d0); + if (!npc.isPushableByFluids()) { + setDeltaMovement(old); + } + return res; + } + } +} diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/DragonFireballController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/DragonFireballController.java similarity index 86% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/DragonFireballController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/DragonFireballController.java index bee398339..e1e15684a 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/DragonFireballController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/DragonFireballController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftDragonFireball; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftDragonFireball; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.projectile.DragonFireball; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class DragonFireballController extends MobEntityController { public DragonFireballController() { - super(EntityDragonFireballNPC.class); + super(EntityDragonFireballNPC.class, EntityType.DRAGON_FIREBALL); } @Override @@ -60,13 +60,6 @@ public class DragonFireballController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -120,6 +113,13 @@ public class DragonFireballController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/EggController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/EggController.java similarity index 84% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/EggController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/EggController.java index 6bf62b5bd..539b5f21c 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/EggController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/EggController.java @@ -1,16 +1,16 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEgg; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEgg; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; @@ -23,22 +23,19 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.projectile.ThrownEgg; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class EggController extends AbstractEntityController { - public EggController() { - super(EntityEggNPC.class); - } - @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { ServerLevel ws = ((CraftWorld) at.getWorld()).getHandle(); - final EntityEggNPC handle = new EntityEggNPC(ws, npc, at.getX(), at.getY(), at.getZ()); + final EntityEggNPC handle = new EntityEggNPC(ws, npc, at.getX(), at.getY(), at.getZ(), null); return handle.getBukkitEntity(); } @@ -65,8 +62,8 @@ public class EggController extends AbstractEntityController { this.npc = (CitizensNPC) npc; } - public EntityEggNPC(Level level, NPC npc, double d0, double d1, double d2) { - super(level, d0, d1, d2); + public EntityEggNPC(Level level, NPC npc, double d0, double d1, double d2, ItemStack stack) { + super(level, d0, d1, d2, stack); this.npc = (CitizensNPC) npc; } @@ -75,13 +72,6 @@ public class EggController extends AbstractEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -126,6 +116,13 @@ public class EggController extends AbstractEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/EnderCrystalController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/EnderCrystalController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/EnderCrystalController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/EnderCrystalController.java index 340e58262..947f8e873 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/EnderCrystalController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/EnderCrystalController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEnderCrystal; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEnderCrystal; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.boss.enderdragon.EndCrystal; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class EnderCrystalController extends MobEntityController { public EnderCrystalController() { - super(EntityEnderCrystalNPC.class); + super(EntityEnderCrystalNPC.class, EntityType.END_CRYSTAL); } @Override @@ -60,13 +60,6 @@ public class EnderCrystalController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -111,6 +104,13 @@ public class EnderCrystalController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/EnderPearlController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/EnderPearlController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/EnderPearlController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/EnderPearlController.java index 5e88a5dff..824d316a1 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/EnderPearlController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/EnderPearlController.java @@ -1,16 +1,16 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEnderPearl; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEnderPearl; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import org.bukkit.entity.EnderPearl; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -24,13 +24,13 @@ import net.minecraft.world.entity.projectile.ThrownEnderpearl; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class EnderPearlController extends MobEntityController { public EnderPearlController() { - super(EntityEnderPearlNPC.class); + super(EntityEnderPearlNPC.class, EntityType.ENDER_PEARL); } @Override @@ -61,13 +61,6 @@ public class EnderPearlController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -112,6 +105,13 @@ public class EnderPearlController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/EvokerFangsController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/EvokerFangsController.java similarity index 87% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/EvokerFangsController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/EvokerFangsController.java index 1944c57ee..390399e68 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/EvokerFangsController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/EvokerFangsController.java @@ -1,16 +1,16 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEvokerFangs; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEvokerFangs; import org.bukkit.event.player.PlayerInteractEntityEvent; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -27,13 +27,13 @@ import net.minecraft.world.entity.projectile.EvokerFangs; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class EvokerFangsController extends MobEntityController { public EvokerFangsController() { - super(EntityEvokerFangsNPC.class); + super(EntityEvokerFangsNPC.class, EntityType.EVOKER_FANGS); } @Override @@ -58,13 +58,6 @@ public class EvokerFangsController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -119,6 +112,13 @@ public class EvokerFangsController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ExperienceOrbController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ExperienceOrbController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ExperienceOrbController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ExperienceOrbController.java index 197141b0d..54508be2c 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ExperienceOrbController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ExperienceOrbController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftExperienceOrb; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftExperienceOrb; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.ExperienceOrb; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ExperienceOrbController extends MobEntityController { public ExperienceOrbController() { - super(EntityExperienceOrbNPC.class); + super(EntityExperienceOrbNPC.class, EntityType.EXPERIENCE_ORB); } @Override @@ -54,13 +54,6 @@ public class ExperienceOrbController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -105,6 +98,13 @@ public class ExperienceOrbController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/EyeOfEnderController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/EyeOfEnderController.java similarity index 78% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/EyeOfEnderController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/EyeOfEnderController.java index 50eb8b341..19bce1e1e 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/EyeOfEnderController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/EyeOfEnderController.java @@ -1,16 +1,16 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEnderSignal; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEnderSignal; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import org.bukkit.entity.EnderSignal; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -24,13 +24,13 @@ import net.minecraft.world.entity.projectile.EyeOfEnder; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class EyeOfEnderController extends MobEntityController { public EyeOfEnderController() { - super(EntityEnderSignalNPC.class); + super(EntityEyeOfEnderNPC.class, EntityType.EYE_OF_ENDER); } @Override @@ -39,19 +39,19 @@ public class EyeOfEnderController extends MobEntityController { } public static class EnderSignalNPC extends CraftEnderSignal implements ForwardingNPCHolder { - public EnderSignalNPC(EntityEnderSignalNPC entity) { + public EnderSignalNPC(EntityEyeOfEnderNPC entity) { super((CraftServer) Bukkit.getServer(), entity); } } - public static class EntityEnderSignalNPC extends EyeOfEnder implements NPCHolder { + public static class EntityEyeOfEnderNPC extends EyeOfEnder implements NPCHolder { private final CitizensNPC npc; - public EntityEnderSignalNPC(EntityType types, Level level) { + public EntityEyeOfEnderNPC(EntityType types, Level level) { this(types, level, null); } - public EntityEnderSignalNPC(EntityType types, Level level, NPC npc) { + public EntityEyeOfEnderNPC(EntityType types, Level level, NPC npc) { super(types, level); this.npc = (CitizensNPC) npc; } @@ -61,13 +61,6 @@ public class EyeOfEnderController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -112,6 +105,13 @@ public class EyeOfEnderController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/FallingBlockController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/FallingBlockController.java similarity index 88% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/FallingBlockController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/FallingBlockController.java index 5e3fc91b9..992f8ef24 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/FallingBlockController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/FallingBlockController.java @@ -1,17 +1,17 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftFallingBlock; -import org.bukkit.craftbukkit.v1_21_R1.util.CraftMagicNumbers; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftFallingBlock; +import org.bukkit.craftbukkit.v1_21_R2.util.CraftMagicNumbers; import org.bukkit.entity.FallingBlock; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; @@ -29,15 +29,11 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class FallingBlockController extends AbstractEntityController { - public FallingBlockController() { - super(EntityFallingBlockNPC.class); - } - @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { ServerLevel ws = ((CraftWorld) at.getWorld()).getHandle(); @@ -71,13 +67,6 @@ public class FallingBlockController extends AbstractEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -131,6 +120,13 @@ public class FallingBlockController extends AbstractEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/FireworkController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/FireworkController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/FireworkController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/FireworkController.java index db69b7db4..8069439b7 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/FireworkController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/FireworkController.java @@ -1,16 +1,16 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftFirework; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftFirework; import org.bukkit.entity.Firework; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -24,13 +24,13 @@ import net.minecraft.world.entity.projectile.FireworkRocketEntity; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class FireworkController extends MobEntityController { public FireworkController() { - super(EntityFireworkNPC.class); + super(EntityFireworkNPC.class, EntityType.FIREWORK_ROCKET); } @Override @@ -55,13 +55,6 @@ public class FireworkController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -106,6 +99,13 @@ public class FireworkController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/FishingHookController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/FishingHookController.java similarity index 83% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/FishingHookController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/FishingHookController.java index bf6167542..797f54ff1 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/FishingHookController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/FishingHookController.java @@ -1,22 +1,22 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftFishHook; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftFishHook; import org.bukkit.entity.FishHook; import com.mojang.authlib.GameProfile; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -34,13 +34,13 @@ import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class FishingHookController extends MobEntityController { public FishingHookController() { - super(EntityFishingHookNPC.class); + super(EntityFishingHookNPC.class, EntityType.FISHING_BOBBER); } @Override @@ -54,7 +54,8 @@ public class FishingHookController extends MobEntityController { sp.setXRot(at.getPitch()); sp.setHealth(20F); sp.getInventory().items.set(sp.getInventory().selected, new ItemStack(Items.FISHING_ROD, 1)); - final EntityFishingHookNPC handle = new EntityFishingHookNPC(EntityType.FISHING_BOBBER, level, npc, sp); + final EntityFishingHookNPC handle = new EntityFishingHookNPC(EntityType.FISHING_BOBBER, level, npc); + handle.setOwner(sp); return handle.getBukkitEntity(); } @@ -66,12 +67,8 @@ public class FishingHookController extends MobEntityController { public static class EntityFishingHookNPC extends FishingHook implements NPCHolder { private final CitizensNPC npc; - public EntityFishingHookNPC(EntityType types, Level level) { - this(types, level, null, null); - } - - public EntityFishingHookNPC(EntityType types, Level level, NPC npc, ServerPlayer sp) { - super(sp, level, 0, 0); + public EntityFishingHookNPC(EntityType types, Level level, NPC npc) { + super(types, level); this.npc = (CitizensNPC) npc; } @@ -80,13 +77,6 @@ public class FishingHookController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public double distanceToSqr(Entity entity) { if (entity == getPlayerOwner()) @@ -138,6 +128,13 @@ public class FishingHookController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/GlowItemFrameController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/GlowItemFrameController.java similarity index 88% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/GlowItemFrameController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/GlowItemFrameController.java index 3d9a4f688..110a82469 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/GlowItemFrameController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/GlowItemFrameController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftGlowItemFrame; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftGlowItemFrame; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -24,13 +24,13 @@ import net.minecraft.world.entity.decoration.GlowItemFrame; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class GlowItemFrameController extends MobEntityController { public GlowItemFrameController() { - super(EntityGlowItemFrameNPC.class); + super(EntityGlowItemFrameNPC.class, EntityType.GLOW_ITEM_FRAME); } @Override @@ -64,13 +64,6 @@ public class GlowItemFrameController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -120,6 +113,13 @@ public class GlowItemFrameController extends MobEntityController { return npc == null || !npc.isProtected() ? super.survives() : true; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/InteractionController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/InteractionController.java similarity index 84% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/InteractionController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/InteractionController.java index 4b7ceabe9..8f0bdca9e 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/InteractionController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/InteractionController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftInteraction; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftInteraction; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.Interaction; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class InteractionController extends MobEntityController { public InteractionController() { - super(EntityInteractionNPC.class); + super(EntityInteractionNPC.class, EntityType.INTERACTION); } @Override @@ -54,13 +54,6 @@ public class InteractionController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -105,6 +98,13 @@ public class InteractionController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ItemController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ItemController.java similarity index 86% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ItemController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ItemController.java index 447c1faf2..c5de67c63 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ItemController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ItemController.java @@ -1,17 +1,17 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftItem; -import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftItem; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; import org.bukkit.entity.Item; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; @@ -27,15 +27,11 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ItemController extends AbstractEntityController { - public ItemController() { - super(EntityItemNPC.class); - } - @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { final EntityItemNPC handle = new EntityItemNPC(((CraftWorld) at.getWorld()).getHandle(), npc, at.getX(), @@ -66,13 +62,6 @@ public class ItemController extends AbstractEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -117,6 +106,13 @@ public class ItemController extends AbstractEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ItemDisplayController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ItemDisplayController.java similarity index 84% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ItemDisplayController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ItemDisplayController.java index 4fc19b2e5..1f3c29520 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ItemDisplayController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ItemDisplayController.java @@ -1,18 +1,18 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftItemDisplay; -import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftItemDisplay; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -26,13 +26,13 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ItemDisplayController extends MobEntityController { public ItemDisplayController() { - super(EntityItemDisplayNPC.class); + super(EntityItemDisplayNPC.class, EntityType.ITEM_DISPLAY); } @Override @@ -67,13 +67,6 @@ public class ItemDisplayController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -118,6 +111,13 @@ public class ItemDisplayController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ItemFrameController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ItemFrameController.java similarity index 88% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ItemFrameController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ItemFrameController.java index 4b9777e57..444c95b90 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ItemFrameController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ItemFrameController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftItemFrame; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftItemFrame; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -24,13 +24,13 @@ import net.minecraft.world.entity.decoration.ItemFrame; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ItemFrameController extends MobEntityController { public ItemFrameController() { - super(EntityItemFrameNPC.class); + super(EntityItemFrameNPC.class, EntityType.ITEM_FRAME); } @Override @@ -64,13 +64,6 @@ public class ItemFrameController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -120,6 +113,13 @@ public class ItemFrameController extends MobEntityController { return npc == null || !npc.isProtected() ? super.survives() : true; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/LargeFireballController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/LargeFireballController.java similarity index 86% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/LargeFireballController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/LargeFireballController.java index b7e90a118..907946fa1 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/LargeFireballController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/LargeFireballController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftLargeFireball; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftLargeFireball; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.projectile.LargeFireball; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class LargeFireballController extends MobEntityController { public LargeFireballController() { - super(EntityLargeFireballNPC.class); + super(EntityLargeFireballNPC.class, EntityType.FIREBALL); } @Override @@ -54,13 +54,6 @@ public class LargeFireballController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -114,6 +107,13 @@ public class LargeFireballController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/LeashController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/LeashController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/LeashController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/LeashController.java index 3b5f1c57b..13f8e8926 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/LeashController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/LeashController.java @@ -1,16 +1,16 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftLeash; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftLeash; import org.bukkit.entity.LeashHitch; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -24,13 +24,13 @@ import net.minecraft.world.entity.decoration.LeashFenceKnotEntity; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class LeashController extends MobEntityController { public LeashController() { - super(EntityLeashNPC.class); + super(EntityLeashNPC.class, EntityType.LEASH_KNOT); } @Override @@ -55,13 +55,6 @@ public class LeashController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -111,6 +104,13 @@ public class LeashController extends MobEntityController { return npc == null || !npc.isProtected() ? super.survives() : true; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/LlamaSpitController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/LlamaSpitController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/LlamaSpitController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/LlamaSpitController.java index e7df8e39a..fe321a918 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/LlamaSpitController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/LlamaSpitController.java @@ -1,16 +1,16 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftLlamaSpit; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftLlamaSpit; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.AbstractEntityController; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; @@ -27,20 +27,15 @@ import net.minecraft.world.entity.projectile.LlamaSpit; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class LlamaSpitController extends AbstractEntityController { - public LlamaSpitController() { - super(EntityLlamaSpitNPC.class); - } - @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { ServerLevel ws = ((CraftWorld) at.getWorld()).getHandle(); - final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC( - NMSImpl. getEntityType(EntityLlamaSpitNPC.class), ws, npc); + final EntityLlamaSpitNPC handle = new EntityLlamaSpitNPC(EntityType.LLAMA_SPIT, ws, npc); handle.absMoveTo(at.getX(), at.getY(), at.getZ(), at.getPitch(), at.getYaw()); return handle.getBukkitEntity(); } @@ -72,13 +67,6 @@ public class LlamaSpitController extends AbstractEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -123,6 +111,13 @@ public class LlamaSpitController extends AbstractEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MarkerController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MarkerController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MarkerController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MarkerController.java index 8d7d41f58..09c0657df 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MarkerController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MarkerController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftMarker; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftMarker; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.Marker; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class MarkerController extends MobEntityController { public MarkerController() { - super(EntityMarkerNPC.class); + super(EntityMarkerNPC.class, EntityType.MARKER); } @Override @@ -54,13 +54,6 @@ public class MarkerController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -105,6 +98,13 @@ public class MarkerController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartChestController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartChestController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartChestController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartChestController.java index c7eaa9a2a..8ad9d45b0 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartChestController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartChestController.java @@ -1,16 +1,16 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftMinecartChest; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftMinecartChest; import org.bukkit.entity.Minecart; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -24,13 +24,13 @@ import net.minecraft.world.entity.vehicle.MinecartChest; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class MinecartChestController extends MobEntityController { public MinecartChestController() { - super(EntityMinecartChestNPC.class); + super(EntityMinecartChestNPC.class, EntityType.CHEST_MINECART); } @Override @@ -55,13 +55,6 @@ public class MinecartChestController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -106,6 +99,13 @@ public class MinecartChestController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartCommandController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartCommandController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartCommandController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartCommandController.java index d96de8c08..5f00eb355 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartCommandController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartCommandController.java @@ -1,16 +1,16 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftMinecartCommand; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftMinecartCommand; import org.bukkit.entity.Minecart; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -24,13 +24,13 @@ import net.minecraft.world.entity.vehicle.MinecartCommandBlock; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class MinecartCommandController extends MobEntityController { public MinecartCommandController() { - super(EntityMinecartCommandNPC.class); + super(EntityMinecartCommandNPC.class, EntityType.COMMAND_BLOCK_MINECART); } @Override @@ -55,13 +55,6 @@ public class MinecartCommandController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -106,6 +99,13 @@ public class MinecartCommandController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartFurnaceController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartFurnaceController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartFurnaceController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartFurnaceController.java index dc2aa13c1..95d6db33c 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartFurnaceController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartFurnaceController.java @@ -1,16 +1,16 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftMinecartFurnace; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftMinecartFurnace; import org.bukkit.entity.Minecart; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -24,13 +24,13 @@ import net.minecraft.world.entity.vehicle.MinecartFurnace; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class MinecartFurnaceController extends MobEntityController { public MinecartFurnaceController() { - super(EntityMinecartFurnaceNPC.class); + super(EntityMinecartFurnaceNPC.class, EntityType.FURNACE_MINECART); } @Override @@ -55,13 +55,6 @@ public class MinecartFurnaceController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -106,6 +99,13 @@ public class MinecartFurnaceController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartHopperController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartHopperController.java similarity index 88% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartHopperController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartHopperController.java index 51dc537f1..1c498858e 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartHopperController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartHopperController.java @@ -1,11 +1,11 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.entity.Minecart; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -19,13 +19,13 @@ import net.minecraft.world.entity.vehicle.MinecartHopper; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class MinecartHopperController extends MobEntityController { public MinecartHopperController() { - super(EntityMinecartHopperNPC.class); + super(EntityMinecartHopperNPC.class, EntityType.HOPPER_MINECART); } @Override @@ -50,13 +50,6 @@ public class MinecartHopperController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public NPC getNPC() { return npc; @@ -93,6 +86,13 @@ public class MinecartHopperController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartRideableController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartRideableController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartRideableController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartRideableController.java index 397f236a1..900f11ddd 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartRideableController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartRideableController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftMinecartRideable; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftMinecartRideable; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.vehicle.Minecart; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class MinecartRideableController extends MobEntityController { public MinecartRideableController() { - super(EntityMinecartRideableNPC.class); + super(EntityMinecartRideableNPC.class, EntityType.MINECART); } @Override @@ -54,13 +54,6 @@ public class MinecartRideableController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -105,6 +98,13 @@ public class MinecartRideableController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartSpawnerController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartSpawnerController.java similarity index 88% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartSpawnerController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartSpawnerController.java index 8f4bb73d0..d8720ef20 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartSpawnerController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartSpawnerController.java @@ -1,11 +1,11 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.entity.Minecart; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -19,13 +19,13 @@ import net.minecraft.world.entity.vehicle.MinecartSpawner; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class MinecartSpawnerController extends MobEntityController { public MinecartSpawnerController() { - super(EntityMinecartSpawnerNPC.class); + super(EntityMinecartSpawnerNPC.class, EntityType.SPAWNER_MINECART); } @Override @@ -50,13 +50,6 @@ public class MinecartSpawnerController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public NPC getNPC() { return npc; @@ -93,6 +86,13 @@ public class MinecartSpawnerController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartTNTController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartTNTController.java similarity index 88% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartTNTController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartTNTController.java index 5833b1594..582ba73b0 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/MinecartTNTController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/MinecartTNTController.java @@ -1,11 +1,11 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.entity.Minecart; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -19,13 +19,13 @@ import net.minecraft.world.entity.vehicle.MinecartTNT; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class MinecartTNTController extends MobEntityController { public MinecartTNTController() { - super(EntityMinecartTNTNPC.class); + super(EntityMinecartTNTNPC.class, EntityType.TNT_MINECART); } @Override @@ -50,13 +50,6 @@ public class MinecartTNTController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public NPC getNPC() { return npc; @@ -93,6 +86,13 @@ public class MinecartTNTController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/OminousItemSpawnerController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/OminousItemSpawnerController.java similarity index 86% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/OminousItemSpawnerController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/OminousItemSpawnerController.java index 6aeb4f1d1..eaef9893a 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/OminousItemSpawnerController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/OminousItemSpawnerController.java @@ -1,17 +1,17 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftOminousItemSpawner; -import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftOminousItemSpawner; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -25,13 +25,13 @@ import net.minecraft.world.entity.OminousItemSpawner; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class OminousItemSpawnerController extends MobEntityController { public OminousItemSpawnerController() { - super(EntityOminousItemSpawnerNPC.class); + super(EntityOminousItemSpawnerNPC.class, EntityType.OMINOUS_ITEM_SPAWNER); } @Override @@ -66,13 +66,6 @@ public class OminousItemSpawnerController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -117,6 +110,13 @@ public class OminousItemSpawnerController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/PaintingController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/PaintingController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/PaintingController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/PaintingController.java index 772b7bf28..bf7c3fbbf 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/PaintingController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/PaintingController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPainting; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPainting; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.decoration.Painting; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class PaintingController extends MobEntityController { public PaintingController() { - super(EntityPaintingNPC.class); + super(EntityPaintingNPC.class, EntityType.PAINTING); } @Override @@ -54,13 +54,6 @@ public class PaintingController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -110,6 +103,13 @@ public class PaintingController extends MobEntityController { return npc == null || !npc.isProtected() ? super.survives() : true; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/RaftController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/RaftController.java new file mode 100644 index 000000000..8a0eb0e32 --- /dev/null +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/RaftController.java @@ -0,0 +1,290 @@ +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; + +import java.util.function.Supplier; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftBoat; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.entity.Player; + +import net.citizensnpcs.api.npc.NPC; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; +import net.citizensnpcs.npc.AbstractEntityController; +import net.citizensnpcs.npc.CitizensNPC; +import net.citizensnpcs.npc.ai.NPCHolder; +import net.citizensnpcs.util.NMS; +import net.citizensnpcs.util.Util; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.tags.FluidTags; +import net.minecraft.tags.TagKey; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.MoverType; +import net.minecraft.world.entity.vehicle.Raft; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.PushReaction; +import net.minecraft.world.level.portal.TeleportTransition; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; + +public class RaftController extends AbstractEntityController { + @Override + protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { + final EntityRaftNPC handle = new EntityRaftNPC(EntityType.BAMBOO_RAFT, ((CraftWorld) at.getWorld()).getHandle(), + () -> Items.BAMBOO_RAFT, npc); + return handle.getBukkitEntity(); + } + + public static class EntityRaftNPC extends Raft implements NPCHolder { + private float invFriction; + private float landFriction; + private Status lastStatus; + private final CitizensNPC npc; + private Status status; + private double waterLevel; + + public EntityRaftNPC(EntityType types, Level level, Supplier supplier) { + this(types, level, supplier, null); + } + + public EntityRaftNPC(EntityType types, Level level, Supplier supplier, NPC npc) { + super(types, level, supplier); + this.npc = (CitizensNPC) npc; + } + + @Override + public boolean broadcastToPlayer(ServerPlayer player) { + return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); + } + + private boolean checkInWater() { + AABB axisalignedbb = this.getBoundingBox(); + int i = Mth.floor(axisalignedbb.minX); + int j = Mth.ceil(axisalignedbb.maxX); + int k = Mth.floor(axisalignedbb.minY); + int l = Mth.ceil(axisalignedbb.minY + 0.001); + int i1 = Mth.floor(axisalignedbb.minZ); + int j1 = Mth.ceil(axisalignedbb.maxZ); + boolean flag = false; + this.waterLevel = -1.7976931348623157E308; + BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); + + for (int k1 = i; k1 < j; ++k1) { + for (int l1 = k; l1 < l; ++l1) { + for (int i2 = i1; i2 < j1; ++i2) { + blockposition_mutableblockposition.set(k1, l1, i2); + FluidState fluid = this.level().getFluidState(blockposition_mutableblockposition); + if (fluid.is(FluidTags.WATER)) { + float f = l1 + fluid.getHeight(this.level(), blockposition_mutableblockposition); + this.waterLevel = Math.max(f, this.waterLevel); + flag |= axisalignedbb.minY < f; + } + } + } + } + return flag; + } + + private void floatRaft() { + double d0 = -this.getGravity(); + double d1 = 0.0; + this.invFriction = 0.05F; + if (this.lastStatus == net.minecraft.world.entity.vehicle.Raft.Status.IN_AIR + && this.status != net.minecraft.world.entity.vehicle.Raft.Status.IN_AIR + && this.status != net.minecraft.world.entity.vehicle.Raft.Status.ON_LAND) { + this.waterLevel = this.getY(1.0); + double d2 = this.getWaterLevelAbove() - this.getBbHeight() + 0.101; + if (this.level().noCollision(this, this.getBoundingBox().move(0.0, d2 - this.getY(), 0.0))) { + this.move(MoverType.SELF, new Vec3(0.0, d2 - this.getY(), 0.0)); + this.setDeltaMovement(this.getDeltaMovement().multiply(1.0, 0.0, 1.0)); + } + this.status = net.minecraft.world.entity.vehicle.Raft.Status.IN_WATER; + } else { + if (this.status == net.minecraft.world.entity.vehicle.Raft.Status.IN_WATER) { + d1 = (this.waterLevel - this.getY()) / this.getBbHeight(); + this.invFriction = 0.9F; + } else if (this.status == net.minecraft.world.entity.vehicle.Raft.Status.UNDER_FLOWING_WATER) { + d0 = -7.0E-4; + this.invFriction = 0.9F; + } else if (this.status == net.minecraft.world.entity.vehicle.Raft.Status.UNDER_WATER) { + d1 = 0.009999999776482582; + this.invFriction = 0.45F; + } else if (this.status == net.minecraft.world.entity.vehicle.Raft.Status.IN_AIR) { + this.invFriction = 0.9F; + } else if (this.status == net.minecraft.world.entity.vehicle.Raft.Status.ON_LAND) { + this.invFriction = this.landFriction; + if (this.getControllingPassenger() instanceof Player) { + this.landFriction /= 2.0F; + } + } + Vec3 vec3d = this.getDeltaMovement(); + this.setDeltaMovement(vec3d.x * this.invFriction, vec3d.y + d0, vec3d.z * this.invFriction); + if (d1 > 0.0) { + Vec3 vec3d1 = this.getDeltaMovement(); + this.setDeltaMovement(vec3d1.x, (vec3d1.y + d1 * (this.getDefaultGravity() / 0.65)) * 0.75, + vec3d1.z); + } + } + } + + @Override + public CraftEntity getBukkitEntity() { + if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { + NMSImpl.setBukkitEntity(this, new RaftNPC(this)); + } + return super.getBukkitEntity(); + } + + @Override + public NPC getNPC() { + return npc; + } + + @Override + public PushReaction getPistonPushReaction() { + return Util.callPistonPushEvent(npc) ? PushReaction.IGNORE : super.getPistonPushReaction(); + } + + private Status getStatus() { + Status entityRaft_Status = isUnderwater(); + if (entityRaft_Status != null) { + this.waterLevel = getBoundingBox().maxY; + return entityRaft_Status; + } + if (checkInWater()) + return Status.IN_WATER; + float f = getGroundFriction(); + if (f > 0.0F) { + this.landFriction = f; + return Status.ON_LAND; + } + return Status.IN_AIR; + } + + @Override + public boolean isPushable() { + return npc == null ? super.isPushable() + : npc.data(). get(NPC.Metadata.COLLIDABLE, !npc.isProtected()); + } + + private Status isUnderwater() { + AABB axisalignedbb = this.getBoundingBox(); + double d0 = axisalignedbb.maxY + 0.001; + int i = Mth.floor(axisalignedbb.minX); + int j = Mth.ceil(axisalignedbb.maxX); + int k = Mth.floor(axisalignedbb.maxY); + int l = Mth.ceil(d0); + int i1 = Mth.floor(axisalignedbb.minZ); + int j1 = Mth.ceil(axisalignedbb.maxZ); + boolean flag = false; + BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); + + for (int k1 = i; k1 < j; ++k1) { + for (int l1 = k; l1 < l; ++l1) { + for (int i2 = i1; i2 < j1; ++i2) { + blockposition_mutableblockposition.set(k1, l1, i2); + FluidState fluid = this.level().getFluidState(blockposition_mutableblockposition); + if (fluid.is(FluidTags.WATER) && d0 < blockposition_mutableblockposition.getY() + + fluid.getHeight(this.level(), blockposition_mutableblockposition)) { + if (!fluid.isSource()) + return net.minecraft.world.entity.vehicle.Raft.Status.UNDER_FLOWING_WATER; + flag = true; + } + } + } + } + return flag ? Status.UNDER_WATER : null; + } + + @Override + protected AABB makeBoundingBox() { + return NMSBoundingBox.makeBB(npc, super.makeBoundingBox()); + } + + @Override + public void push(Entity entity) { + // this method is called by both the entities involved - cancelling + // it will not stop the NPC from moving. + super.push(entity); + if (npc != null) { + Util.callCollisionEvent(npc, entity.getBukkitEntity()); + } + } + + @Override + public void refreshDimensions() { + if (npc == null) { + super.refreshDimensions(); + } else { + NMSImpl.setSize(this, firstTick); + } + } + + @Override + public boolean save(CompoundTag save) { + return npc == null ? super.save(save) : false; + } + + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + + @Override + public void tick() { + if (npc != null) { + baseTick(); + if (getControllingPassenger() instanceof NPCHolder + && ((NPCHolder) getControllingPassenger()).getNPC().getNavigator().isNavigating()) { + setDeltaMovement(getControllingPassenger().getDeltaMovement().multiply(20, 0, 20)); + } + npc.update(); + if (getHurtTime() > 0) { + setHurtTime(getHurtTime() - 1); + } + if (getDamage() > 0.0F) { + setDamage(getDamage() - 1.0F); + } + lastStatus = status; + status = getStatus(); + floatRaft(); + move(MoverType.SELF, getDeltaMovement()); + applyEffectsFromBlocks(); + } else { + super.tick(); + } + } + + @Override + public boolean updateFluidHeightAndDoFluidPushing(TagKey tagkey, double d0) { + if (npc == null) + return super.updateFluidHeightAndDoFluidPushing(tagkey, d0); + Vec3 old = getDeltaMovement().add(0, 0, 0); + boolean res = super.updateFluidHeightAndDoFluidPushing(tagkey, d0); + if (!npc.isPushableByFluids()) { + setDeltaMovement(old); + } + return res; + } + } + + public static class RaftNPC extends CraftBoat implements ForwardingNPCHolder { + public RaftNPC(EntityRaftNPC entity) { + super((CraftServer) Bukkit.getServer(), entity); + } + } +} diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ShulkerBulletController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ShulkerBulletController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ShulkerBulletController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ShulkerBulletController.java index 87c833a88..3b8057055 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ShulkerBulletController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ShulkerBulletController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftShulkerBullet; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftShulkerBullet; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.projectile.ShulkerBullet; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ShulkerBulletController extends MobEntityController { public ShulkerBulletController() { - super(EntityShulkerBulletNPC.class); + super(EntityShulkerBulletNPC.class, EntityType.SHULKER_BULLET); } @Override @@ -54,13 +54,6 @@ public class ShulkerBulletController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -105,6 +98,13 @@ public class ShulkerBulletController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/SmallFireballController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/SmallFireballController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/SmallFireballController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/SmallFireballController.java index 83f278fe3..d24076361 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/SmallFireballController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/SmallFireballController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftSmallFireball; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftSmallFireball; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.projectile.SmallFireball; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class SmallFireballController extends MobEntityController { public SmallFireballController() { - super(EntitySmallFireballNPC.class); + super(EntitySmallFireballNPC.class, EntityType.SMALL_FIREBALL); } @Override @@ -54,13 +54,6 @@ public class SmallFireballController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -105,6 +98,13 @@ public class SmallFireballController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/SnowballController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/SnowballController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/SnowballController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/SnowballController.java index a9a11851e..d9a9ce641 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/SnowballController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/SnowballController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftSnowball; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftSnowball; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.projectile.Snowball; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class SnowballController extends MobEntityController { public SnowballController() { - super(EntitySnowballNPC.class); + super(EntitySnowballNPC.class, EntityType.SNOWBALL); } @Override @@ -54,13 +54,6 @@ public class SnowballController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -105,6 +98,13 @@ public class SnowballController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/SpectralArrowController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/SpectralArrowController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/SpectralArrowController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/SpectralArrowController.java index 73cd320be..82cdc6544 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/SpectralArrowController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/SpectralArrowController.java @@ -1,16 +1,16 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftSpectralArrow; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftSpectralArrow; import org.bukkit.entity.Arrow; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -24,13 +24,13 @@ import net.minecraft.world.entity.projectile.SpectralArrow; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class SpectralArrowController extends MobEntityController { public SpectralArrowController() { - super(EntitySpectralArrowNPC.class); + super(EntitySpectralArrowNPC.class, EntityType.SPECTRAL_ARROW); } @Override @@ -55,13 +55,6 @@ public class SpectralArrowController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -106,6 +99,13 @@ public class SpectralArrowController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/TNTPrimedController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/TNTPrimedController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/TNTPrimedController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/TNTPrimedController.java index 3a9efb2e8..8226b8340 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/TNTPrimedController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/TNTPrimedController.java @@ -1,16 +1,16 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftTNTPrimed; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftTNTPrimed; import org.bukkit.entity.TNTPrimed; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -24,13 +24,13 @@ import net.minecraft.world.entity.item.PrimedTnt; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class TNTPrimedController extends MobEntityController { public TNTPrimedController() { - super(EntityTNTPrimedNPC.class); + super(EntityTNTPrimedNPC.class, EntityType.TNT); } @Override @@ -55,13 +55,6 @@ public class TNTPrimedController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -106,6 +99,13 @@ public class TNTPrimedController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/TextDisplayController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/TextDisplayController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/TextDisplayController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/TextDisplayController.java index 4715d77ea..8d16d0082 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/TextDisplayController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/TextDisplayController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftTextDisplay; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftTextDisplay; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class TextDisplayController extends MobEntityController { public TextDisplayController() { - super(EntityTextDisplayNPC.class); + super(EntityTextDisplayNPC.class, EntityType.TEXT_DISPLAY); } @Override @@ -54,13 +54,6 @@ public class TextDisplayController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -105,6 +98,13 @@ public class TextDisplayController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { super.tick(); diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ThrownExpBottleController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ThrownExpBottleController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ThrownExpBottleController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ThrownExpBottleController.java index f9d931acf..ff39221a9 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ThrownExpBottleController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ThrownExpBottleController.java @@ -1,16 +1,16 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftThrownExpBottle; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftThrownExpBottle; import org.bukkit.entity.ThrownExpBottle; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -24,13 +24,13 @@ import net.minecraft.world.entity.projectile.ThrownExperienceBottle; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ThrownExpBottleController extends MobEntityController { public ThrownExpBottleController() { - super(EntityThrownExpBottleNPC.class); + super(EntityThrownExpBottleNPC.class, EntityType.EXPERIENCE_BOTTLE); } @Override @@ -55,13 +55,6 @@ public class ThrownExpBottleController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -106,6 +99,13 @@ public class ThrownExpBottleController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ThrownPotionController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ThrownPotionController.java similarity index 87% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ThrownPotionController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ThrownPotionController.java index 64a3305d3..8c3ccd16b 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ThrownPotionController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ThrownPotionController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftThrownPotion; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftThrownPotion; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -24,13 +24,13 @@ import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ThrownPotionController extends MobEntityController { public ThrownPotionController() { - super(EntityThrownPotionNPC.class); + super(EntityThrownPotionNPC.class, EntityType.POTION); } @Override @@ -55,13 +55,6 @@ public class ThrownPotionController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -110,6 +103,13 @@ public class ThrownPotionController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ThrownTridentController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ThrownTridentController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ThrownTridentController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ThrownTridentController.java index 923657868..87a340db9 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/ThrownTridentController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/ThrownTridentController.java @@ -1,16 +1,16 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftTrident; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftTrident; import org.bukkit.entity.Trident; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -24,13 +24,13 @@ import net.minecraft.world.entity.projectile.ThrownTrident; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class ThrownTridentController extends MobEntityController { public ThrownTridentController() { - super(EntityThrownTridentNPC.class); + super(EntityThrownTridentNPC.class, EntityType.TRIDENT); } @Override @@ -55,13 +55,6 @@ public class ThrownTridentController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -106,6 +99,13 @@ public class ThrownTridentController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/TippedArrowController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/TippedArrowController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/TippedArrowController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/TippedArrowController.java index 2b9348558..583379466 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/TippedArrowController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/TippedArrowController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftArrow; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftArrow; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.projectile.Arrow; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class TippedArrowController extends MobEntityController { public TippedArrowController() { - super(EntityTippedArrowNPC.class); + super(EntityTippedArrowNPC.class, EntityType.ARROW); } @Override @@ -54,13 +54,6 @@ public class TippedArrowController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -105,6 +98,13 @@ public class TippedArrowController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/WindChargeController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/WindChargeController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/WindChargeController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/WindChargeController.java index a3a6dc7df..d34cd8baa 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/WindChargeController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/WindChargeController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftWindCharge; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftWindCharge; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.projectile.windcharge.WindCharge; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class WindChargeController extends MobEntityController { public WindChargeController() { - super(EntityWindChargeNPC.class); + super(EntityWindChargeNPC.class, EntityType.WIND_CHARGE); } @Override @@ -54,13 +54,6 @@ public class WindChargeController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -105,6 +98,13 @@ public class WindChargeController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/WitherSkullController.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/WitherSkullController.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/WitherSkullController.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/WitherSkullController.java index 17a26cb31..2e4d1ff94 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/entity/nonliving/WitherSkullController.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/entity/nonliving/WitherSkullController.java @@ -1,15 +1,15 @@ -package net.citizensnpcs.nms.v1_21_R1.entity.nonliving; +package net.citizensnpcs.nms.v1_21_R2.entity.nonliving; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftWitherSkull; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftWitherSkull; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.MobEntityController; -import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder; -import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.entity.MobEntityController; +import net.citizensnpcs.nms.v1_21_R2.util.ForwardingNPCHolder; +import net.citizensnpcs.nms.v1_21_R2.util.NMSBoundingBox; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.npc.CitizensNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; @@ -23,13 +23,13 @@ import net.minecraft.world.entity.projectile.WitherSkull; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.PushReaction; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; public class WitherSkullController extends MobEntityController { public WitherSkullController() { - super(EntityWitherSkullNPC.class); + super(EntityWitherSkullNPC.class, EntityType.WITHER_SKULL); } @Override @@ -54,13 +54,6 @@ public class WitherSkullController extends MobEntityController { return NMS.shouldBroadcastToPlayer(npc, () -> super.broadcastToPlayer(player)); } - @Override - public Entity changeDimension(DimensionTransition transition) { - if (npc == null) - return super.changeDimension(transition); - return NMSImpl.teleportAcrossWorld(this, transition); - } - @Override public CraftEntity getBukkitEntity() { if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) { @@ -105,6 +98,13 @@ public class WitherSkullController extends MobEntityController { return npc == null ? super.save(save) : false; } + @Override + public Entity teleport(TeleportTransition transition) { + if (npc == null) + return super.teleport(transition); + return NMSImpl.teleportAcrossWorld(this, transition); + } + @Override public void tick() { if (npc != null) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/network/EmptyConnection.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/network/EmptyConnection.java similarity index 93% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/network/EmptyConnection.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/network/EmptyConnection.java index 478e5fa9a..f5af70f8b 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/network/EmptyConnection.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/network/EmptyConnection.java @@ -1,9 +1,9 @@ -package net.citizensnpcs.nms.v1_21_R1.network; +package net.citizensnpcs.nms.v1_21_R2.network; import java.io.IOException; import java.net.SocketAddress; -import net.citizensnpcs.nms.v1_21_R1.util.NMSImpl; +import net.citizensnpcs.nms.v1_21_R2.util.NMSImpl; import net.citizensnpcs.util.EmptyChannel; import net.minecraft.network.Connection; import net.minecraft.network.PacketListener; diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/network/EmptyPacketListener.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/network/EmptyPacketListener.java similarity index 93% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/network/EmptyPacketListener.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/network/EmptyPacketListener.java index cceb825f7..3b86d8c77 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/network/EmptyPacketListener.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/network/EmptyPacketListener.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.network; +package net.citizensnpcs.nms.v1_21_R2.network; import net.minecraft.network.Connection; import net.minecraft.network.protocol.Packet; diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/CitizensBlockBreaker.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/CitizensBlockBreaker.java similarity index 97% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/CitizensBlockBreaker.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/CitizensBlockBreaker.java index 752289b15..157393434 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/CitizensBlockBreaker.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/CitizensBlockBreaker.java @@ -1,6 +1,6 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; -import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; import net.citizensnpcs.util.AbstractBlockBreaker; import net.minecraft.core.BlockPos; diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/CitizensEntityTracker.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/CitizensEntityTracker.java similarity index 95% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/CitizensEntityTracker.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/CitizensEntityTracker.java index c2f61f003..5464333b4 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/CitizensEntityTracker.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/CitizensEntityTracker.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; import java.lang.invoke.MethodHandle; import java.util.Collection; @@ -13,7 +13,7 @@ import net.citizensnpcs.api.event.NPCLinkToPlayerEvent; import net.citizensnpcs.api.event.NPCSeenByPlayerEvent; import net.citizensnpcs.api.event.NPCUnlinkFromPlayerEvent; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.nms.v1_21_R1.entity.EntityHumanNPC; +import net.citizensnpcs.nms.v1_21_R2.entity.EntityHumanNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.Util; @@ -148,11 +148,11 @@ public class CitizensEntityTracker extends ChunkMap.TrackedEntity { } private static volatile Boolean REQUIRES_SYNC; - private static final MethodHandle TRACK_DELTA = NMS.getGetter(ServerEntity.class, "i"); + private static final MethodHandle TRACK_DELTA = NMSImpl.SERVER_ENTITY_TRACK_DELTA; private static final MethodHandle TRACKER = NMS.getFirstGetter(TrackedEntity.class, Entity.class); private static final MethodHandle TRACKER_ENTRY = NMS.getFirstGetter(TrackedEntity.class, ServerEntity.class); private static final MethodHandle TRACKING_RANGE = NMS.getFirstGetter(TrackedEntity.class, int.class); private static final MethodHandle TRACKING_RANGE_SETTER = NMS.getFirstFinalSetter(TrackedEntity.class, int.class); private static final MethodHandle TRACKING_SET_SETTER = NMS.getFirstFinalSetter(TrackedEntity.class, Set.class); - private static final MethodHandle UPDATE_INTERVAL = NMS.getGetter(ServerEntity.class, "h"); + private static final MethodHandle UPDATE_INTERVAL = NMSImpl.SERVER_ENTITY_UPDATE_INTERVAL; } diff --git a/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/CustomEntityRegistry.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/CustomEntityRegistry.java new file mode 100644 index 000000000..7f512bafc --- /dev/null +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/CustomEntityRegistry.java @@ -0,0 +1,197 @@ +package net.citizensnpcs.nms.v1_21_R2.util; + +import java.lang.invoke.MethodHandle; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; +import java.util.Set; +import java.util.function.Supplier; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.Maps; +import com.mojang.serialization.Lifecycle; + +import net.citizensnpcs.util.NMS; +import net.minecraft.core.DefaultedMappedRegistry; +import net.minecraft.core.DefaultedRegistry; +import net.minecraft.core.Holder; +import net.minecraft.core.Holder.Reference; +import net.minecraft.core.HolderGetter; +import net.minecraft.core.IdMap; +import net.minecraft.core.MappedRegistry; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; +import net.minecraft.util.RandomSource; +import net.minecraft.world.entity.EntityType; + +@SuppressWarnings("rawtypes") +public class CustomEntityRegistry extends DefaultedMappedRegistry> + implements Supplier>> { + private final Reference> defaultReference; + private final BiMap>> entities = HashBiMap.create(); + private final BiMap>, ResourceLocation> entityClasses = this.entities.inverse(); + private final Map entityIds = Maps.newHashMap(); + private final MappedRegistry> wrapped; + + public CustomEntityRegistry(DefaultedRegistry> original) throws Throwable { + super(original.getDefaultKey().getNamespace(), + (ResourceKey>>) IREGISTRY_RESOURCE_KEY.invoke(original), + (Lifecycle) IREGISTRY_LIFECYCLE.invoke(original), true); + defaultReference = EntityType.PIG.builtInRegistryHolder(); + this.wrapped = (MappedRegistry>) original; + } + + @Override + public IdMap>> asHolderIdMap() { + return wrapped.asHolderIdMap(); + } + + @Override + public void bindAllTagsToEmpty() { + wrapped.bindAllTagsToEmpty(); + } + + @Override + public void bindTag(TagKey> tag, List>> list) { + wrapped.bindTag(tag, list); + } + + @Override + public EntityType byId(int var0) { + return this.wrapped.byId(var0); + } + + @Override + public EntityType byIdOrThrow(int var0) { + return this.wrapped.byIdOrThrow(var0); + } + + @Override + public boolean containsKey(ResourceKey> var0) { + return this.wrapped.containsKey(var0); + } + + @Override + public boolean containsKey(ResourceLocation var0) { + return this.wrapped.containsKey(var0); + } + + @Override + public HolderGetter> createRegistrationLookup() { + return wrapped.createRegistrationLookup(); + } + + @Override + public Set>, EntityType>> entrySet() { + return wrapped.entrySet(); + } + + @Override + public MappedRegistry> get() { + return wrapped; + } + + @Override + public Optional>> get(ResourceKey> key) { + return wrapped.get(key); + } + + @Override + public Optional>> get(ResourceLocation key) { + if (entities.containsKey(key)) + return Optional.ofNullable(entities.get(key)); + return wrapped.get(key); + } + + @Override + public int getId(EntityType key) { + if (entityIds.containsKey(key)) + return entityIds.get(key); + return wrapped.getId(key); + } + + @Override + public ResourceLocation getKey(EntityType value) { + if (entityClasses.containsKey(value)) + return entityClasses.get(value); + return wrapped.getKey(value); + } + + @Override + public Optional> getOptional(ResourceKey> var0) { + return this.wrapped.getOptional(var0); + } + + @Override + public Optional> getOptional(ResourceLocation var0) { + if (entities.containsKey(var0)) + return Optional.ofNullable(getValue(var0)); + return this.wrapped.getOptional(var0); + } + + @Override + public Optional>> getRandom(RandomSource paramRandom) { + return wrapped.getRandom(paramRandom); + } + + @Override + public Optional>> getResourceKey(EntityType var0) { + return wrapped.getResourceKey(var0); + } + + @Override + public EntityType getValue(ResourceKey> key) { + return wrapped.getValue(key); + } + + @Override + public EntityType getValue(ResourceLocation key) { + if (entities.containsKey(key)) + return entities.getOrDefault(key, defaultReference).value(); + return wrapped.getValue(key); + } + + @Override + public boolean isEmpty() { + return wrapped.isEmpty(); + } + + @Override + public Iterator> iterator() { + return wrapped.iterator(); + } + + @Override + public Set keySet() { + return wrapped.keySet(); + } + + public void put(int entityId, ResourceLocation key, EntityType entityClass) { + entities.put(key, entityClass.builtInRegistryHolder()); + entityIds.put(entityClass, entityId); + } + + @Override + public Set>> registryKeySet() { + return wrapped.registryKeySet(); + } + + @Override + public Lifecycle registryLifecycle() { + return wrapped.registryLifecycle(); + } + + @Override + public int size() { + return wrapped.size(); + } + + private static final MethodHandle IREGISTRY_LIFECYCLE = NMS.getFirstGetter(MappedRegistry.class, Lifecycle.class); + private static final MethodHandle IREGISTRY_RESOURCE_KEY = NMS.getFirstGetter(MappedRegistry.class, + ResourceKey.class); +} \ No newline at end of file diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EmptyAdvancementDataPlayer.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EmptyAdvancementDataPlayer.java similarity index 74% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EmptyAdvancementDataPlayer.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EmptyAdvancementDataPlayer.java index cd9cc1f65..31f395d00 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EmptyAdvancementDataPlayer.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EmptyAdvancementDataPlayer.java @@ -1,18 +1,26 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; import java.lang.invoke.MethodHandle; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; +import java.util.stream.Stream; import com.mojang.datafixers.DataFixer; +import com.mojang.serialization.DynamicOps; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.util.NMS; import net.minecraft.advancements.AdvancementHolder; import net.minecraft.advancements.AdvancementProgress; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.HolderLookup.RegistryLookup; +import net.minecraft.core.Registry; +import net.minecraft.resources.RegistryOps; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.PlayerAdvancements; import net.minecraft.server.ServerAdvancementManager; @@ -67,9 +75,26 @@ public class EmptyAdvancementDataPlayer extends PlayerAdvancements { super.stopListening(); } + private static class EmptyProvider implements HolderLookup.Provider { + @Override + public RegistryOps createSerializationContext(DynamicOps var0) { + return null; + } + + @Override + public Stream>> listRegistryKeys() { + return Stream.empty(); + } + + @Override + public Optional> lookup(ResourceKey> arg0) { + return Optional.empty(); + } + } + private static class EmptyServerAdvancementManager extends ServerAdvancementManager { public EmptyServerAdvancementManager() { - super(null); + super(new EmptyProvider()); } @Override diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EmptyServerStatsCounter.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EmptyServerStatsCounter.java similarity index 95% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EmptyServerStatsCounter.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EmptyServerStatsCounter.java index 07ba4d7c7..1f2389135 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EmptyServerStatsCounter.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EmptyServerStatsCounter.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; import com.mojang.datafixers.DataFixer; diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityJumpControl.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityJumpControl.java similarity index 93% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityJumpControl.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityJumpControl.java index 55d2f14c0..fe8f2c4d3 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityJumpControl.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityJumpControl.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityMoveControl.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityMoveControl.java similarity index 98% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityMoveControl.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityMoveControl.java index e2682b8b0..816829ef4 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityMoveControl.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityMoveControl.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; import java.util.Random; diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityNavigation.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityNavigation.java similarity index 92% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityNavigation.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityNavigation.java index 78b1e7f92..fcdbe59c4 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityNavigation.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityNavigation.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; import java.util.Set; import java.util.stream.Collectors; @@ -8,6 +8,7 @@ import com.google.common.collect.ImmutableSet; import net.citizensnpcs.Settings.Setting; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.core.SectionPos; import net.minecraft.core.Vec3i; import net.minecraft.tags.BlockTags; @@ -148,27 +149,33 @@ public class EntityNavigation extends PathNavigation { SectionPos.blockToSectionCoord(var0.getZ())); if (var2 == null) return null; - else { - BlockPos var3; - if (var2.getBlockState(var0).isAir()) { - for (var3 = var0.below(); var3.getY() > this.level.getMinBuildHeight() - && var2.getBlockState(var3).isAir(); var3 = var3.below()) { - } - if (var3.getY() > this.level.getMinBuildHeight()) - return supercreatePath(var3.above(), var1); - while (var3.getY() < this.level.getMaxBuildHeight() && var2.getBlockState(var3).isAir()) { - var3 = var3.above(); - } - var0 = var3; + + BlockPos.MutableBlockPos var3; + if (var2.getBlockState(var0).isAir()) { + var3 = var0.mutable().move(Direction.DOWN); + + while (var3.getY() > this.level.getMinY() && var2.getBlockState(var3).isAir()) { + var3.move(Direction.DOWN); } - if (!var2.getBlockState(var0).isSolid()) - return supercreatePath(var0, var1); - else { - for (var3 = var0.above(); var3.getY() < this.level.getMaxBuildHeight() - && var2.getBlockState(var3).isSolid(); var3 = var3.above()) { - } - return supercreatePath(var3, var1); + if (var3.getY() > this.level.getMinY()) { + return supercreatePath(var3.above(), var1); } + var3.setY(var0.getY() + 1); + + while (var3.getY() <= this.level.getMaxY() && var2.getBlockState(var3).isAir()) { + var3.move(Direction.UP); + } + var0 = var3; + } + if (!var2.getBlockState(var0).isSolid()) { + return supercreatePath(var0, var1); + } else { + var3 = var0.mutable().move(Direction.UP); + + while (var3.getY() <= this.level.getMaxY() && var2.getBlockState(var3).isSolid()) { + var3.move(Direction.UP); + } + return supercreatePath(var3.immutable(), var1); } } @@ -194,7 +201,7 @@ public class EntityNavigation extends PathNavigation { @Override protected Path createPath(Set var0, int var1, boolean headAbove, int reachRange, float range) { - if (var0.isEmpty() || this.mob.getY() < this.level.getMinBuildHeight() || !canUpdatePath()) + if (var0.isEmpty() || this.mob.getY() < this.level.getMinY() || !canUpdatePath()) return null; if (this.path != null && !this.path.isDone() && var0.contains(this.targetPos)) return this.path; @@ -344,7 +351,7 @@ public class EntityNavigation extends PathNavigation { @Override public boolean isStableDestination(BlockPos var0) { BlockPos var1 = var0.below(); - return this.level.getBlockState(var1).isSolidRender(this.level, var1); + return this.level.getBlockState(var1).isSolidRender(); } @Override @@ -441,12 +448,11 @@ public class EntityNavigation extends PathNavigation { public boolean shouldRecomputePath(BlockPos var0) { if (this.hasDelayedRecomputation || this.path == null || this.path.isDone() || this.path.getNodeCount() == 0) return false; - else { - Node var1 = this.path.getEndNode(); - Vec3 var2 = new Vec3((var1.x + this.mob.getX()) / 2.0D, (var1.y + this.mob.getY()) / 2.0D, - (var1.z + this.mob.getZ()) / 2.0D); - return var0.closerToCenterThan(var2, this.path.getNodeCount() - this.path.getNextNodeIndex()); - } + Node var1 = this.path.getEndNode(); + Vec3 var2 = new Vec3((var1.x + this.mob.getX()) / 2.0D, (var1.y + this.mob.getY()) / 2.0D, + (var1.z + this.mob.getZ()) / 2.0D); + return var0.closerToCenterThan(var2, this.path.getNodeCount() - this.path.getNextNodeIndex()); + } private boolean shouldTargetNextNodeInDirection(Vec3 var0) { diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityNodeEvaluator.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityNodeEvaluator.java similarity index 99% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityNodeEvaluator.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityNodeEvaluator.java index 887b951e3..3343e7218 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityNodeEvaluator.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityNodeEvaluator.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; import java.util.EnumSet; import java.util.Iterator; @@ -282,7 +282,7 @@ public class EntityNodeEvaluator extends EntityNodeEvaluatorBase { } else { var1.set(this.mob.getX(), this.mob.getY() + 1.0, this.mob.getZ()); - while (var1.getY() > this.currentContext.level().getMinBuildHeight()) { + while (var1.getY() > this.currentContext.level().getMinY()) { var0 = var1.getY(); var1.setY(var1.getY() - 1); BlockState var3 = this.currentContext.getBlockState(var1); @@ -371,7 +371,7 @@ public class EntityNodeEvaluator extends EntityNodeEvaluatorBase { } private Node tryFindFirstGroundNodeBelow(int var0, int var1, int var2) { - for (int var3 = var1 - 1; var3 >= this.mob.level().getMinBuildHeight(); --var3) { + for (int var3 = var1 - 1; var3 >= this.mob.level().getMinY(); --var3) { if (var1 - var3 > this.mob.getMaxFallDistance()) return this.getBlockedNode(var0, var3, var2); PathType var4 = this.getCachedPathType(var0, var3, var2); @@ -388,7 +388,7 @@ public class EntityNodeEvaluator extends EntityNodeEvaluatorBase { private Node tryFindFirstNonWaterBelow(int var0, int var1, int var2, Node var3) { --var1; - while (var1 > this.mob.level().getMinBuildHeight()) { + while (var1 > this.mob.level().getMinY()) { PathType var4 = this.getCachedPathType(var0, var1, var2); if (var4 != PathType.WATER) return var3; @@ -454,7 +454,7 @@ public class EntityNodeEvaluator extends EntityNodeEvaluatorBase { int var3 = var1.getY(); int var4 = var1.getZ(); PathType var5 = var0.getPathTypeFromState(var2, var3, var4); - if (var5 == PathType.OPEN && var3 >= var0.level().getMinBuildHeight() + 1) { + if (var5 == PathType.OPEN && var3 >= var0.level().getMinY() + 1) { PathType var10000; switch (var0.getPathTypeFromState(var2, var3 - 1, var4)) { case OPEN: diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityNodeEvaluatorBase.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityNodeEvaluatorBase.java similarity index 98% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityNodeEvaluatorBase.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityNodeEvaluatorBase.java index aa092d87f..4db2b9757 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityNodeEvaluatorBase.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityNodeEvaluatorBase.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityPathfinder.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityPathfinder.java similarity index 68% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityPathfinder.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityPathfinder.java index 7ac740d6d..e2a150543 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityPathfinder.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityPathfinder.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; import java.util.Comparator; import java.util.Iterator; @@ -15,7 +15,9 @@ import com.google.common.collect.Sets; import net.citizensnpcs.Settings.Setting; import net.minecraft.core.BlockPos; +import net.minecraft.util.profiling.Profiler; import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.util.profiling.metrics.MetricCategory; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; import net.minecraft.world.level.PathNavigationRegion; @@ -38,54 +40,20 @@ public class EntityPathfinder extends PathFinder { this.maxVisitedNodes = var1; } - public Path findPath(PathNavigationRegion var0, LivingEntity var1, Set var2, float var3, int var4, - float var5) { + private Path findPath(Node var0, Map var1, float var2, int var3, float var4) { + ProfilerFiller var5 = Profiler.get(); + var5.push("find_path"); + var5.markForCharting(MetricCategory.PATH_FINDING); + Set var6 = var1.keySet(); + var0.g = 0.0F; + var0.h = this.getBestH(var0, var6); + var0.f = var0.h; this.openSet.clear(); - this.nodeEvaluator.prepare(var0, var1); - Node var6 = this.nodeEvaluator.getStart(); - if (var6 == null) - return null; - else { - Map var7 = var2.stream() - .collect(Collectors.toMap( - var0x -> this.nodeEvaluator.getTarget(var0x.getX(), var0x.getY(), var0x.getZ()), - Function.identity())); - Path var8 = this.findPath(var0.getProfiler(), var6, var7, var3, var4, var5); - this.nodeEvaluator.done(); - return var8; - } - } - - @Override - public Path findPath(PathNavigationRegion var0, Mob var1, Set var2, float var3, int var4, float var5) { - this.openSet.clear(); - this.nodeEvaluator.prepare(var0, var1); - Node var6 = this.nodeEvaluator.getStart(); - if (var6 == null) - return null; - else { - Map var7 = var2.stream() - .collect(Collectors.toMap( - var0x -> this.nodeEvaluator.getTarget(var0x.getX(), var0x.getY(), var0x.getZ()), - Function.identity())); - Path var8 = this.findPath(var0.getProfiler(), var6, var7, var3, var4, var5); - this.nodeEvaluator.done(); - return var8; - } - } - - private Path findPath(ProfilerFiller var0, Node var1, Map var2, float range, int reachRange, - float var5) { - Set var6 = var2.keySet(); - var1.g = 0.0F; - var1.h = this.getBestH(var1, var6); - var1.f = var1.h; - this.openSet.clear(); - this.openSet.insert(var1); - Set var7 = ImmutableSet.of(); + this.openSet.insert(var0); + Set var7 = ImmutableSet.of(); int var8 = 0; Set var9 = Sets.newHashSetWithExpectedSize(var6.size()); - int var10 = (int) (this.maxVisitedNodes * var5); + int var10 = (int) (this.maxVisitedNodes * var4); while (!this.openSet.isEmpty()) { ++var8; @@ -97,24 +65,24 @@ public class EntityPathfinder extends PathFinder { Iterator var13 = var6.iterator(); while (var13.hasNext()) { - Target var13t = (Target) var13.next(); - if (var11.distanceManhattan(var13t) <= reachRange) { - var13t.setReached(); - var9.add(var13t); + Target var133 = (Target) var13.next(); + if (var11.distanceManhattan(var133) <= var3) { + var133.setReached(); + var9.add(var133); } } if (!var9.isEmpty()) { break; } - if (var11.distanceTo(var1) < range) { + if (!(var11.distanceTo(var0) >= var2)) { int var12 = this.nodeEvaluator.getNeighbors(this.neighbors, var11); - for (int i = 0; i < var12; ++i) { - Node var14 = this.neighbors[i]; + for (int var133 = 0; var133 < var12; ++var133) { + Node var14 = this.neighbors[var133]; float var15 = this.distance(var11, var14); var14.walkedDistance = var11.walkedDistance + var15; float var16 = var11.g + var15 + var14.costMalus; - if (var14.walkedDistance < range && (!var14.inOpenSet() || var16 < var14.g)) { + if (var14.walkedDistance < var2 && (!var14.inOpenSet() || var16 < var14.g)) { var14.cameFrom = var11; var14.g = var16; var14.h = this.getBestH(var14, var6) * 1.5F; @@ -129,9 +97,10 @@ public class EntityPathfinder extends PathFinder { } } Optional var11 = !var9.isEmpty() - ? var9.stream().map(var1x -> this.reconstructPath(var1x.getBestNode(), var2.get(var1x), true)).min( + ? var9.stream().map(var1x -> this.reconstructPath(var1x.getBestNode(), var1.get(var1x), true)).min( Comparator.comparingInt(Path::getNodeCount)) - : getFallbackDestinations(var2, var6); + : getFallbackDestinations(var1, var6); + var5.pop(); /*var6.stream().map((var1x) -> { return this.reconstructPath(var1x.getBestNode(), (BlockPos)var2.get(var1x), false); }).min(Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount))*/ @@ -141,12 +110,47 @@ public class EntityPathfinder extends PathFinder { return var12; } + public Path findPath(PathNavigationRegion var0, LivingEntity var1, Set var2, float var3, int var4, + float var5) { + this.openSet.clear(); + this.nodeEvaluator.prepare(var0, var1); + Node var6 = this.nodeEvaluator.getStart(); + if (var6 == null) { + return null; + } else { + Map var7 = var2.stream().collect(Collectors.toMap((var0x) -> { + return this.nodeEvaluator.getTarget(var0x.getX(), var0x.getY(), var0x.getZ()); + }, Function.identity())); + Path var8 = this.findPath(var6, var7, var3, var4, var5); + this.nodeEvaluator.done(); + return var8; + } + } + + @Override + public Path findPath(PathNavigationRegion var0, Mob var1, Set var2, float var3, int var4, float var5) { + this.openSet.clear(); + this.nodeEvaluator.prepare(var0, var1); + Node var6 = this.nodeEvaluator.getStart(); + if (var6 == null) { + return null; + } else { + Map var7 = var2.stream().collect(Collectors.toMap((var0x) -> { + return this.nodeEvaluator.getTarget(var0x.getX(), var0x.getY(), var0x.getZ()); + }, Function.identity())); + Path var8 = this.findPath(var6, var7, var3, var4, var5); + this.nodeEvaluator.done(); + return var8; + } + } + private float getBestH(Node var0, Set var1) { float var2 = Float.MAX_VALUE; - for (Target var4 : var1) { - float var5 = var0.distanceTo(var4); + float var5; + for (Iterator var44 = var1.iterator(); var44.hasNext(); var2 = Math.min(var5, var2)) { + Target var4 = (Target) var44.next(); + var5 = var0.distanceTo(var4); var4.updateBest(var5, var0); - var2 = Math.min(var5, var2); } return var2; } @@ -159,7 +163,7 @@ public class EntityPathfinder extends PathFinder { } private Path reconstructPath(Node var0, BlockPos var1, boolean var2) { - List var3 = Lists.newArrayList(); + List var3 = Lists.newArrayList(); Node var4 = var0; var3.add(0, var0); diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityPathfindingContext.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityPathfindingContext.java similarity index 97% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityPathfindingContext.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityPathfindingContext.java index d8f60f314..a32ac082a 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/EntityPathfindingContext.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/EntityPathfindingContext.java @@ -1,6 +1,6 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; -import net.citizensnpcs.nms.v1_21_R1.entity.SlimeController.EntitySlimeNPC; +import net.citizensnpcs.nms.v1_21_R2.entity.SlimeController.EntitySlimeNPC; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.tags.BlockTags; diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/ForwardingNPCHolder.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/ForwardingNPCHolder.java similarity index 93% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/ForwardingNPCHolder.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/ForwardingNPCHolder.java index eeee7664b..4e17d0b24 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/ForwardingNPCHolder.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/ForwardingNPCHolder.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; import org.bukkit.entity.Entity; diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/MobAI.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/MobAI.java similarity index 99% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/MobAI.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/MobAI.java index 5c6e57603..d3d8930e7 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/MobAI.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/MobAI.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; import java.util.Map; diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/NMSBoundingBox.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/NMSBoundingBox.java similarity index 94% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/NMSBoundingBox.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/NMSBoundingBox.java index 4308a6195..9b606dbb3 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/NMSBoundingBox.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/NMSBoundingBox.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; import java.util.function.Supplier; diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/NMSImpl.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/NMSImpl.java similarity index 85% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/NMSImpl.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/NMSImpl.java index 979b7424d..5e6acd95d 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/NMSImpl.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/NMSImpl.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; import java.lang.invoke.MethodHandle; import java.net.URL; @@ -27,18 +27,17 @@ import org.bukkit.boss.BarColor; import org.bukkit.boss.BarStyle; import org.bukkit.boss.BossBar; import org.bukkit.command.BlockCommandSender; -import org.bukkit.craftbukkit.v1_21_R1.CraftServer; -import org.bukkit.craftbukkit.v1_21_R1.CraftSound; -import org.bukkit.craftbukkit.v1_21_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_21_R1.block.CraftBlock; -import org.bukkit.craftbukkit.v1_21_R1.block.data.CraftBlockData; -import org.bukkit.craftbukkit.v1_21_R1.boss.CraftBossBar; -import org.bukkit.craftbukkit.v1_21_R1.command.CraftBlockCommandSender; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_21_R1.event.CraftEventFactory; -import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryAnvil; -import org.bukkit.craftbukkit.v1_21_R1.inventory.view.CraftAnvilView; +import org.bukkit.craftbukkit.v1_21_R2.CraftServer; +import org.bukkit.craftbukkit.v1_21_R2.CraftSound; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.block.CraftBlock; +import org.bukkit.craftbukkit.v1_21_R2.block.data.CraftBlockData; +import org.bukkit.craftbukkit.v1_21_R2.boss.CraftBossBar; +import org.bukkit.craftbukkit.v1_21_R2.command.CraftBlockCommandSender; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftInventoryAnvil; +import org.bukkit.craftbukkit.v1_21_R2.inventory.view.CraftAnvilView; import org.bukkit.entity.EntityType; import org.bukkit.entity.FishHook; import org.bukkit.entity.Player; @@ -86,135 +85,139 @@ import net.citizensnpcs.api.util.BoundingBox; import net.citizensnpcs.api.util.EntityDim; import net.citizensnpcs.api.util.Messaging; import net.citizensnpcs.api.util.SpigotUtil.InventoryViewAPI; -import net.citizensnpcs.nms.v1_21_R1.entity.AllayController; -import net.citizensnpcs.nms.v1_21_R1.entity.ArmadilloController; -import net.citizensnpcs.nms.v1_21_R1.entity.ArmorStandController; -import net.citizensnpcs.nms.v1_21_R1.entity.AxolotlController; -import net.citizensnpcs.nms.v1_21_R1.entity.BatController; -import net.citizensnpcs.nms.v1_21_R1.entity.BeeController; -import net.citizensnpcs.nms.v1_21_R1.entity.BlazeController; -import net.citizensnpcs.nms.v1_21_R1.entity.BoggedController; -import net.citizensnpcs.nms.v1_21_R1.entity.BreezeController; -import net.citizensnpcs.nms.v1_21_R1.entity.CamelController; -import net.citizensnpcs.nms.v1_21_R1.entity.CatController; -import net.citizensnpcs.nms.v1_21_R1.entity.CaveSpiderController; -import net.citizensnpcs.nms.v1_21_R1.entity.ChickenController; -import net.citizensnpcs.nms.v1_21_R1.entity.CodController; -import net.citizensnpcs.nms.v1_21_R1.entity.CowController; -import net.citizensnpcs.nms.v1_21_R1.entity.CreeperController; -import net.citizensnpcs.nms.v1_21_R1.entity.DolphinController; -import net.citizensnpcs.nms.v1_21_R1.entity.DrownedController; -import net.citizensnpcs.nms.v1_21_R1.entity.EnderDragonController; -import net.citizensnpcs.nms.v1_21_R1.entity.EndermanController; -import net.citizensnpcs.nms.v1_21_R1.entity.EndermiteController; -import net.citizensnpcs.nms.v1_21_R1.entity.EvokerController; -import net.citizensnpcs.nms.v1_21_R1.entity.FoxController; -import net.citizensnpcs.nms.v1_21_R1.entity.FrogController; -import net.citizensnpcs.nms.v1_21_R1.entity.GhastController; -import net.citizensnpcs.nms.v1_21_R1.entity.GiantController; -import net.citizensnpcs.nms.v1_21_R1.entity.GlowSquidController; -import net.citizensnpcs.nms.v1_21_R1.entity.GoatController; -import net.citizensnpcs.nms.v1_21_R1.entity.GuardianController; -import net.citizensnpcs.nms.v1_21_R1.entity.GuardianElderController; -import net.citizensnpcs.nms.v1_21_R1.entity.HoglinController; -import net.citizensnpcs.nms.v1_21_R1.entity.HorseController; -import net.citizensnpcs.nms.v1_21_R1.entity.HorseDonkeyController; -import net.citizensnpcs.nms.v1_21_R1.entity.HorseMuleController; -import net.citizensnpcs.nms.v1_21_R1.entity.HorseSkeletonController; -import net.citizensnpcs.nms.v1_21_R1.entity.HorseZombieController; -import net.citizensnpcs.nms.v1_21_R1.entity.HumanController; -import net.citizensnpcs.nms.v1_21_R1.entity.IllusionerController; -import net.citizensnpcs.nms.v1_21_R1.entity.IronGolemController; -import net.citizensnpcs.nms.v1_21_R1.entity.LlamaController; -import net.citizensnpcs.nms.v1_21_R1.entity.MagmaCubeController; -import net.citizensnpcs.nms.v1_21_R1.entity.MushroomCowController; -import net.citizensnpcs.nms.v1_21_R1.entity.OcelotController; -import net.citizensnpcs.nms.v1_21_R1.entity.PandaController; -import net.citizensnpcs.nms.v1_21_R1.entity.ParrotController; -import net.citizensnpcs.nms.v1_21_R1.entity.PhantomController; -import net.citizensnpcs.nms.v1_21_R1.entity.PigController; -import net.citizensnpcs.nms.v1_21_R1.entity.PigZombieController; -import net.citizensnpcs.nms.v1_21_R1.entity.PiglinBruteController; -import net.citizensnpcs.nms.v1_21_R1.entity.PiglinController; -import net.citizensnpcs.nms.v1_21_R1.entity.PillagerController; -import net.citizensnpcs.nms.v1_21_R1.entity.PolarBearController; -import net.citizensnpcs.nms.v1_21_R1.entity.PufferFishController; -import net.citizensnpcs.nms.v1_21_R1.entity.RabbitController; -import net.citizensnpcs.nms.v1_21_R1.entity.RavagerController; -import net.citizensnpcs.nms.v1_21_R1.entity.SalmonController; -import net.citizensnpcs.nms.v1_21_R1.entity.SheepController; -import net.citizensnpcs.nms.v1_21_R1.entity.ShulkerController; -import net.citizensnpcs.nms.v1_21_R1.entity.SilverfishController; -import net.citizensnpcs.nms.v1_21_R1.entity.SkeletonController; -import net.citizensnpcs.nms.v1_21_R1.entity.SkeletonStrayController; -import net.citizensnpcs.nms.v1_21_R1.entity.SkeletonWitherController; -import net.citizensnpcs.nms.v1_21_R1.entity.SlimeController; -import net.citizensnpcs.nms.v1_21_R1.entity.SnifferController; -import net.citizensnpcs.nms.v1_21_R1.entity.SnowmanController; -import net.citizensnpcs.nms.v1_21_R1.entity.SpiderController; -import net.citizensnpcs.nms.v1_21_R1.entity.SquidController; -import net.citizensnpcs.nms.v1_21_R1.entity.StriderController; -import net.citizensnpcs.nms.v1_21_R1.entity.TadpoleController; -import net.citizensnpcs.nms.v1_21_R1.entity.TraderLlamaController; -import net.citizensnpcs.nms.v1_21_R1.entity.TropicalFishController; -import net.citizensnpcs.nms.v1_21_R1.entity.TurtleController; -import net.citizensnpcs.nms.v1_21_R1.entity.VexController; -import net.citizensnpcs.nms.v1_21_R1.entity.VillagerController; -import net.citizensnpcs.nms.v1_21_R1.entity.VindicatorController; -import net.citizensnpcs.nms.v1_21_R1.entity.WanderingTraderController; -import net.citizensnpcs.nms.v1_21_R1.entity.WardenController; -import net.citizensnpcs.nms.v1_21_R1.entity.WitchController; -import net.citizensnpcs.nms.v1_21_R1.entity.WitherController; -import net.citizensnpcs.nms.v1_21_R1.entity.WolfController; -import net.citizensnpcs.nms.v1_21_R1.entity.ZoglinController; -import net.citizensnpcs.nms.v1_21_R1.entity.ZombieController; -import net.citizensnpcs.nms.v1_21_R1.entity.ZombieHuskController; -import net.citizensnpcs.nms.v1_21_R1.entity.ZombieVillagerController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.AreaEffectCloudController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.BlockDisplayController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.BoatController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.BreezeWindChargeController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.ChestBoatController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.DragonFireballController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.EggController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.EnderCrystalController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.EnderPearlController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.EvokerFangsController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.ExperienceOrbController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.EyeOfEnderController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.FallingBlockController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.FireworkController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.FishingHookController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.GlowItemFrameController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.InteractionController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.ItemController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.ItemDisplayController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.ItemFrameController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.LargeFireballController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.LeashController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.LlamaSpitController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.MarkerController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.MinecartChestController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.MinecartCommandController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.MinecartFurnaceController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.MinecartHopperController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.MinecartRideableController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.MinecartSpawnerController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.MinecartTNTController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.OminousItemSpawnerController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.PaintingController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.ShulkerBulletController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.SmallFireballController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.SnowballController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.SpectralArrowController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.TNTPrimedController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.TextDisplayController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.ThrownExpBottleController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.ThrownPotionController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.ThrownTridentController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.TippedArrowController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.WindChargeController; -import net.citizensnpcs.nms.v1_21_R1.entity.nonliving.WitherSkullController; +import net.citizensnpcs.nms.v1_21_R2.entity.AllayController; +import net.citizensnpcs.nms.v1_21_R2.entity.ArmadilloController; +import net.citizensnpcs.nms.v1_21_R2.entity.ArmorStandController; +import net.citizensnpcs.nms.v1_21_R2.entity.AxolotlController; +import net.citizensnpcs.nms.v1_21_R2.entity.BatController; +import net.citizensnpcs.nms.v1_21_R2.entity.BeeController; +import net.citizensnpcs.nms.v1_21_R2.entity.BlazeController; +import net.citizensnpcs.nms.v1_21_R2.entity.BoggedController; +import net.citizensnpcs.nms.v1_21_R2.entity.BreezeController; +import net.citizensnpcs.nms.v1_21_R2.entity.CamelController; +import net.citizensnpcs.nms.v1_21_R2.entity.CatController; +import net.citizensnpcs.nms.v1_21_R2.entity.CaveSpiderController; +import net.citizensnpcs.nms.v1_21_R2.entity.ChickenController; +import net.citizensnpcs.nms.v1_21_R2.entity.CodController; +import net.citizensnpcs.nms.v1_21_R2.entity.CowController; +import net.citizensnpcs.nms.v1_21_R2.entity.CreakingController; +import net.citizensnpcs.nms.v1_21_R2.entity.CreakingTransientController; +import net.citizensnpcs.nms.v1_21_R2.entity.CreeperController; +import net.citizensnpcs.nms.v1_21_R2.entity.DolphinController; +import net.citizensnpcs.nms.v1_21_R2.entity.DrownedController; +import net.citizensnpcs.nms.v1_21_R2.entity.EnderDragonController; +import net.citizensnpcs.nms.v1_21_R2.entity.EndermanController; +import net.citizensnpcs.nms.v1_21_R2.entity.EndermiteController; +import net.citizensnpcs.nms.v1_21_R2.entity.EvokerController; +import net.citizensnpcs.nms.v1_21_R2.entity.FoxController; +import net.citizensnpcs.nms.v1_21_R2.entity.FrogController; +import net.citizensnpcs.nms.v1_21_R2.entity.GhastController; +import net.citizensnpcs.nms.v1_21_R2.entity.GiantController; +import net.citizensnpcs.nms.v1_21_R2.entity.GlowSquidController; +import net.citizensnpcs.nms.v1_21_R2.entity.GoatController; +import net.citizensnpcs.nms.v1_21_R2.entity.GuardianController; +import net.citizensnpcs.nms.v1_21_R2.entity.GuardianElderController; +import net.citizensnpcs.nms.v1_21_R2.entity.HoglinController; +import net.citizensnpcs.nms.v1_21_R2.entity.HorseController; +import net.citizensnpcs.nms.v1_21_R2.entity.HorseDonkeyController; +import net.citizensnpcs.nms.v1_21_R2.entity.HorseMuleController; +import net.citizensnpcs.nms.v1_21_R2.entity.HorseSkeletonController; +import net.citizensnpcs.nms.v1_21_R2.entity.HorseZombieController; +import net.citizensnpcs.nms.v1_21_R2.entity.HumanController; +import net.citizensnpcs.nms.v1_21_R2.entity.IllusionerController; +import net.citizensnpcs.nms.v1_21_R2.entity.IronGolemController; +import net.citizensnpcs.nms.v1_21_R2.entity.LlamaController; +import net.citizensnpcs.nms.v1_21_R2.entity.MagmaCubeController; +import net.citizensnpcs.nms.v1_21_R2.entity.MushroomCowController; +import net.citizensnpcs.nms.v1_21_R2.entity.OcelotController; +import net.citizensnpcs.nms.v1_21_R2.entity.PandaController; +import net.citizensnpcs.nms.v1_21_R2.entity.ParrotController; +import net.citizensnpcs.nms.v1_21_R2.entity.PhantomController; +import net.citizensnpcs.nms.v1_21_R2.entity.PigController; +import net.citizensnpcs.nms.v1_21_R2.entity.PigZombieController; +import net.citizensnpcs.nms.v1_21_R2.entity.PiglinBruteController; +import net.citizensnpcs.nms.v1_21_R2.entity.PiglinController; +import net.citizensnpcs.nms.v1_21_R2.entity.PillagerController; +import net.citizensnpcs.nms.v1_21_R2.entity.PolarBearController; +import net.citizensnpcs.nms.v1_21_R2.entity.PufferFishController; +import net.citizensnpcs.nms.v1_21_R2.entity.RabbitController; +import net.citizensnpcs.nms.v1_21_R2.entity.RavagerController; +import net.citizensnpcs.nms.v1_21_R2.entity.SalmonController; +import net.citizensnpcs.nms.v1_21_R2.entity.SheepController; +import net.citizensnpcs.nms.v1_21_R2.entity.ShulkerController; +import net.citizensnpcs.nms.v1_21_R2.entity.SilverfishController; +import net.citizensnpcs.nms.v1_21_R2.entity.SkeletonController; +import net.citizensnpcs.nms.v1_21_R2.entity.SkeletonStrayController; +import net.citizensnpcs.nms.v1_21_R2.entity.SkeletonWitherController; +import net.citizensnpcs.nms.v1_21_R2.entity.SlimeController; +import net.citizensnpcs.nms.v1_21_R2.entity.SnifferController; +import net.citizensnpcs.nms.v1_21_R2.entity.SnowmanController; +import net.citizensnpcs.nms.v1_21_R2.entity.SpiderController; +import net.citizensnpcs.nms.v1_21_R2.entity.SquidController; +import net.citizensnpcs.nms.v1_21_R2.entity.StriderController; +import net.citizensnpcs.nms.v1_21_R2.entity.TadpoleController; +import net.citizensnpcs.nms.v1_21_R2.entity.TraderLlamaController; +import net.citizensnpcs.nms.v1_21_R2.entity.TropicalFishController; +import net.citizensnpcs.nms.v1_21_R2.entity.TurtleController; +import net.citizensnpcs.nms.v1_21_R2.entity.VexController; +import net.citizensnpcs.nms.v1_21_R2.entity.VillagerController; +import net.citizensnpcs.nms.v1_21_R2.entity.VindicatorController; +import net.citizensnpcs.nms.v1_21_R2.entity.WanderingTraderController; +import net.citizensnpcs.nms.v1_21_R2.entity.WardenController; +import net.citizensnpcs.nms.v1_21_R2.entity.WitchController; +import net.citizensnpcs.nms.v1_21_R2.entity.WitherController; +import net.citizensnpcs.nms.v1_21_R2.entity.WolfController; +import net.citizensnpcs.nms.v1_21_R2.entity.ZoglinController; +import net.citizensnpcs.nms.v1_21_R2.entity.ZombieController; +import net.citizensnpcs.nms.v1_21_R2.entity.ZombieHuskController; +import net.citizensnpcs.nms.v1_21_R2.entity.ZombieVillagerController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.AreaEffectCloudController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.BlockDisplayController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.BoatController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.BreezeWindChargeController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.ChestBoatController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.ChestRaftController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.DragonFireballController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.EggController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.EnderCrystalController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.EnderPearlController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.EvokerFangsController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.ExperienceOrbController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.EyeOfEnderController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.FallingBlockController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.FireworkController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.FishingHookController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.GlowItemFrameController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.InteractionController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.ItemController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.ItemDisplayController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.ItemFrameController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.LargeFireballController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.LeashController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.LlamaSpitController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.MarkerController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.MinecartChestController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.MinecartCommandController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.MinecartFurnaceController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.MinecartHopperController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.MinecartRideableController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.MinecartSpawnerController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.MinecartTNTController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.OminousItemSpawnerController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.PaintingController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.RaftController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.ShulkerBulletController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.SmallFireballController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.SnowballController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.SpectralArrowController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.TNTPrimedController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.TextDisplayController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.ThrownExpBottleController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.ThrownPotionController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.ThrownTridentController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.TippedArrowController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.WindChargeController; +import net.citizensnpcs.nms.v1_21_R2.entity.nonliving.WitherSkullController; import net.citizensnpcs.npc.EntityControllers; import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; @@ -228,6 +231,7 @@ import net.citizensnpcs.trait.versioned.ArmadilloTrait; import net.citizensnpcs.trait.versioned.ArmadilloTrait.ArmadilloState; import net.citizensnpcs.trait.versioned.AxolotlTrait; import net.citizensnpcs.trait.versioned.BeeTrait; +import net.citizensnpcs.trait.versioned.BoatTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; import net.citizensnpcs.trait.versioned.CamelTrait; import net.citizensnpcs.trait.versioned.CamelTrait.CamelPose; @@ -263,6 +267,7 @@ import net.citizensnpcs.util.PlayerAnimation; import net.citizensnpcs.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; +import net.minecraft.core.Holder.Reference; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.ByteArrayTag; import net.minecraft.nbt.CompoundTag; @@ -310,6 +315,7 @@ import net.minecraft.tags.FluidTags; import net.minecraft.util.Mth; import net.minecraft.world.Container; import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity.RemovalReason; @@ -338,6 +344,7 @@ import net.minecraft.world.entity.animal.AbstractFish; import net.minecraft.world.entity.animal.AbstractSchoolingFish; import net.minecraft.world.entity.animal.Cat; import net.minecraft.world.entity.animal.Dolphin; +import net.minecraft.world.entity.animal.FlyingAnimal; import net.minecraft.world.entity.animal.Fox; import net.minecraft.world.entity.animal.Panda; import net.minecraft.world.entity.animal.PolarBear; @@ -365,6 +372,8 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.level.EmptyBlockGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.PowderSnowBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.dimension.end.EndDragonFight; import net.minecraft.world.level.material.FluidState; @@ -372,7 +381,7 @@ import net.minecraft.world.level.pathfinder.Node; import net.minecraft.world.level.pathfinder.Path; import net.minecraft.world.level.pathfinder.PathFinder; import net.minecraft.world.level.pathfinder.PathType; -import net.minecraft.world.level.portal.DimensionTransition; +import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; @@ -448,13 +457,13 @@ public class NMSImpl implements NMSBridge { } boolean hasAttackDamage = source.getAttributes().hasAttribute(Attributes.ATTACK_DAMAGE); if (source instanceof Mob && hasAttackDamage) { - ((Mob) source).doHurtTarget(target); + ((Mob) source).doHurtTarget((ServerLevel) source.level(), target); return; } float f = (float) (hasAttackDamage ? source.getAttributeValue(Attributes.ATTACK_DAMAGE) : 1f); DamageSource ds = target.damageSources().mobAttack(source); f = EnchantmentHelper.modifyDamage((ServerLevel) source.level(), source.getWeaponItem(), target, ds, f); - boolean flag = target.hurt(target.damageSources().mobAttack(source), f); + boolean flag = target.hurtServer((ServerLevel) source.level(), target.damageSources().mobAttack(source), f); if (!flag) return; float k = EnchantmentHelper.modifyKnockback((ServerLevel) source.level(), source.getWeaponItem(), target, ds, @@ -747,7 +756,7 @@ public class NMSImpl implements NMSBridge { SoundEvent effect = CraftSound.bukkitToMinecraft(flag); if (effect == null) throw new CommandException(Messages.INVALID_SOUND); - return effect.getLocation().getPath(); + return effect.location().getPath(); } catch (Throwable e) { throw new CommandException(Messages.INVALID_SOUND); } @@ -954,6 +963,7 @@ public class NMSImpl implements NMSBridge { registerTraitWithCommand(manager, AxolotlTrait.class); registerTraitWithCommand(manager, ArmadilloTrait.class); registerTraitWithCommand(manager, BeeTrait.class); + registerTraitWithCommand(manager, BoatTrait.class); registerTraitWithCommand(manager, BossBarTrait.class); registerTraitWithCommand(manager, CamelTrait.class); registerTraitWithCommand(manager, CatTrait.class); @@ -989,14 +999,25 @@ public class NMSImpl implements NMSBridge { EntityControllers.setEntityControllerForType(EntityType.BEE, BeeController.class); EntityControllers.setEntityControllerForType(EntityType.BLAZE, BlazeController.class); EntityControllers.setEntityControllerForType(EntityType.BLOCK_DISPLAY, BlockDisplayController.class); - EntityControllers.setEntityControllerForType(EntityType.BOAT, BoatController.class); EntityControllers.setEntityControllerForType(EntityType.BOGGED, BoggedController.class); EntityControllers.setEntityControllerForType(EntityType.BREEZE, BreezeController.class); EntityControllers.setEntityControllerForType(EntityType.BREEZE_WIND_CHARGE, BreezeWindChargeController.class); EntityControllers.setEntityControllerForType(EntityType.CAMEL, CamelController.class); EntityControllers.setEntityControllerForType(EntityType.CAT, CatController.class); EntityControllers.setEntityControllerForType(EntityType.CAVE_SPIDER, CaveSpiderController.class); - EntityControllers.setEntityControllerForType(EntityType.CHEST_BOAT, ChestBoatController.class); + for (EntityType type : EntityType.values()) { + String name = type.name(); + if (name.endsWith("_CHEST_BOAT")) { + EntityControllers.setEntityControllerForType(type, ChestBoatController.class); + } else if (name.endsWith("_BOAT")) { + EntityControllers.setEntityControllerForType(type, BoatController.class); + } + if (name.endsWith("_CHEST_RAFT")) { + EntityControllers.setEntityControllerForType(type, ChestRaftController.class); + } else if (name.endsWith("_RAFT")) { + EntityControllers.setEntityControllerForType(type, RaftController.class); + } + } EntityControllers.setEntityControllerForType(EntityType.CHEST_MINECART, MinecartChestController.class); EntityControllers.setEntityControllerForType(EntityType.CHICKEN, ChickenController.class); EntityControllers.setEntityControllerForType(EntityType.COD, CodController.class); @@ -1004,6 +1025,8 @@ public class NMSImpl implements NMSBridge { MinecartCommandController.class); EntityControllers.setEntityControllerForType(EntityType.COW, CowController.class); EntityControllers.setEntityControllerForType(EntityType.CREEPER, CreeperController.class); + EntityControllers.setEntityControllerForType(EntityType.CREAKING, CreakingController.class); + EntityControllers.setEntityControllerForType(EntityType.CREAKING_TRANSIENT, CreakingTransientController.class); EntityControllers.setEntityControllerForType(EntityType.DOLPHIN, DolphinController.class); EntityControllers.setEntityControllerForType(EntityType.DONKEY, HorseDonkeyController.class); EntityControllers.setEntityControllerForType(EntityType.DRAGON_FIREBALL, DragonFireballController.class); @@ -1225,7 +1248,8 @@ public class NMSImpl implements NMSBridge { list.set(i, new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), npcInfo.profile(), !disableTablist, npcInfo.latency(), npcInfo.gameMode(), - !disableTablist ? npcInfo.displayName() : Component.empty(), npcInfo.chatSession())); + !disableTablist ? npcInfo.displayName() : Component.empty(), npcInfo.listOrder(), + npcInfo.chatSession())); changed = true; } if (playerProfile == null) { @@ -1236,7 +1260,7 @@ public class NMSImpl implements NMSBridge { new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), playerProfile, !disableTablist, npcInfo.latency(), npcInfo.gameMode(), Component.literal(Util .possiblyStripBedrockPrefix(playerProfile.getName(), playerProfile.getId())), - npcInfo.chatSession())); + npcInfo.listOrder(), npcInfo.chatSession())); changed = true; continue; } @@ -1319,17 +1343,16 @@ public class NMSImpl implements NMSBridge { } @Override - public void registerEntityClass(Class clazz) { + public void registerEntityClass(Class clazz, Object raw) { if (ENTITY_REGISTRY == null) return; + net.minecraft.world.entity.EntityType type = (net.minecraft.world.entity.EntityType) raw; Class search = clazz; while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) { - net.minecraft.world.entity.EntityType type = ENTITY_REGISTRY.findType(search); ResourceLocation key = ENTITY_REGISTRY.getKey(type); - if (key == null || type == null) { + if (key == null || type == null) continue; - } - CITIZENS_ENTITY_TYPES.put(clazz, type); + int code = ENTITY_REGISTRY.getId(type); ENTITY_REGISTRY.put(code, key, type); return; @@ -1411,7 +1434,7 @@ public class NMSImpl implements NMSBridge { boolean list = from instanceof NPCHolder ? !((NPCHolder) from).getNPC().shouldRemoveFromTabList() : true; ClientboundPlayerInfoUpdatePacket.Entry entry = new ClientboundPlayerInfoUpdatePacket.Entry(from.getUUID(), from.getGameProfile(), list, from.connection.latency(), from.gameMode.getGameModeForPlayer(), - list ? from.getTabListDisplayName() : Component.empty(), + list ? from.getTabListDisplayName() : Component.empty(), from.listOrder, from.getChatSession() == null ? null : from.getChatSession().asData()); try { PLAYERINFO_ENTRIES.invoke(packet, Lists.newArrayList(entry)); @@ -1545,9 +1568,9 @@ public class NMSImpl implements NMSBridge { @Override public void setEndermanAngry(org.bukkit.entity.Enderman enderman, boolean angry) { - if (ENDERMAN_CREEPY == null) + if (ENDERMAN_DATA_CREEPY == null) return; - getHandle(enderman).getEntityData().set(ENDERMAN_CREEPY, angry); + getHandle(enderman).getEntityData().set(ENDERMAN_DATA_CREEPY, angry); } @Override @@ -2181,134 +2204,6 @@ public class NMSImpl implements NMSBridge { throw new IllegalArgumentException(); } - public static void flyingMoveLogic(LivingEntity entity, Vec3 vec3d) { - if (entity.isEffectiveAi() || entity.isControlledByLocalInstance()) { - double d0 = 0.08D; - boolean flag = entity.getDeltaMovement().y <= 0.0D; - if (flag && entity.hasEffect(MobEffects.SLOW_FALLING)) { - d0 = 0.01D; - entity.fallDistance = 0.0F; - } - FluidState fluid = entity.level().getFluidState(entity.blockPosition()); - if (entity.isInWater() && !entity.canStandOnFluid(fluid)) { - double d1 = entity.getY(); - float f = entity.isSprinting() ? 0.9F : 0.8F; - float f1 = 0.02F; - float f2 = (float) entity.getAttributeValue(Attributes.WATER_MOVEMENT_EFFICIENCY); - if (f2 > 3.0F) { - f2 = 3.0F; - } - if (!entity.onGround()) { - f2 *= 0.5F; - } - if (f2 > 0.0F) { - f += (0.546F - f) * f2 / 3.0F; - f1 += (entity.getSpeed() - f1) * f2 / 3.0F; - } - if (entity.hasEffect(MobEffects.DOLPHINS_GRACE)) { - f = 0.96F; - } - entity.moveRelative(f1, vec3d); - entity.move(MoverType.SELF, entity.getDeltaMovement()); - Vec3 vec3d1 = entity.getDeltaMovement(); - if (entity.horizontalCollision && entity.onClimbable()) { - vec3d1 = new Vec3(vec3d1.x, 0.2D, vec3d1.z); - } - entity.setDeltaMovement(vec3d1.multiply(f, 0.8D, f)); - Vec3 vec3d2 = entity.getFluidFallingAdjustedMovement(d0, flag, entity.getDeltaMovement()); - entity.setDeltaMovement(vec3d2); - if (entity.horizontalCollision - && entity.isFree(vec3d2.x, vec3d2.y + 0.6D - entity.getY() + d1, vec3d2.z)) { - entity.setDeltaMovement(vec3d2.x, 0.3D, vec3d2.z); - } - } else if (entity.isInLava() && !entity.canStandOnFluid(fluid)) { - double d1 = entity.getY(); - entity.moveRelative(0.02F, vec3d); - entity.move(MoverType.SELF, entity.getDeltaMovement()); - if (entity.getFluidHeight(FluidTags.LAVA) <= entity.getFluidJumpThreshold()) { - entity.setDeltaMovement(entity.getDeltaMovement().multiply(0.5D, 0.8D, 0.5D)); - Vec3 vec3 = entity.getFluidFallingAdjustedMovement(d0, flag, entity.getDeltaMovement()); - entity.setDeltaMovement(vec3); - } else { - entity.setDeltaMovement(entity.getDeltaMovement().scale(0.5D)); - } - if (!entity.isNoGravity()) { - entity.setDeltaMovement(entity.getDeltaMovement().add(0.0D, -d0 / 4.0D, 0.0D)); - } - Vec3 vec3d3 = entity.getDeltaMovement(); - if (entity.horizontalCollision - && entity.isFree(vec3d3.x, vec3d3.y + 0.6D - entity.getY() + d1, vec3d3.z)) { - entity.setDeltaMovement(vec3d3.x, 0.3D, vec3d3.z); - } - } else if (entity.isFallFlying()) { - Vec3 vec3d4 = entity.getDeltaMovement(); - if (vec3d4.y > -0.5D) { - entity.fallDistance = 1.0F; - } - Vec3 vec3d5 = entity.getLookAngle(); - float f = entity.getXRot() * 0.017453292F; - double d2 = Math.sqrt(vec3d5.x * vec3d5.x + vec3d5.z * vec3d5.z); - double d3 = vec3d4.horizontalDistance(); - double d4 = vec3d5.length(); - float f3 = Mth.cos(f); - f3 = (float) (f3 * f3 * Math.min(1.0D, d4 / 0.4D)); - vec3d4 = entity.getDeltaMovement().add(0.0D, d0 * (-1.0D + f3 * 0.75D), 0.0D); - if (vec3d4.y < 0.0D && d2 > 0.0D) { - double d5 = vec3d4.y * -0.1D * f3; - vec3d4 = vec3d4.add(vec3d5.x * d5 / d2, d5, vec3d5.z * d5 / d2); - } - if (f < 0.0F && d2 > 0.0D) { - double d5 = d3 * -Mth.sin(f) * 0.04D; - vec3d4 = vec3d4.add(-vec3d5.x * d5 / d2, d5 * 3.2D, -vec3d5.z * d5 / d2); - } - if (d2 > 0.0D) { - vec3d4 = vec3d4.add((vec3d5.x / d2 * d3 - vec3d4.x) * 0.1D, 0.0D, - (vec3d5.z / d2 * d3 - vec3d4.z) * 0.1D); - } - entity.setDeltaMovement(vec3d4.multiply(0.99D, 0.98D, 0.99D)); - entity.move(MoverType.SELF, entity.getDeltaMovement()); - if (entity.horizontalCollision && !entity.level().isClientSide) { - double d5 = entity.getDeltaMovement().horizontalDistance(); - double d6 = d3 - d5; - float f4 = (float) (d6 * 10.0D - 3.0D); - if (f4 > 0.0F) { - entity.playSound(entity.getFallDamageSound0((int) f4), 1.0F, 1.0F); - entity.hurt(entity.damageSources().flyIntoWall(), f4); - } - } - if (entity.onGround() && !entity.level().isClientSide && entity.getSharedFlag(7) - && !CraftEventFactory.callToggleGlideEvent(entity, false).isCancelled()) { - entity.setSharedFlag(7, false); - } - } else { - BlockPos blockposition = BlockPos.containing(entity.getX(), entity.getBoundingBox().minY - 0.5D, - entity.getZ()); - float f5 = entity.level().getBlockState(blockposition).getBlock().getFriction(); - float f = entity.onGround() ? f5 * 0.91F : 0.91F; - Vec3 vec3d6 = entity.handleRelativeFrictionAndCalculateMovement(vec3d, f5); - double d7 = vec3d6.y; - if (entity.hasEffect(MobEffects.LEVITATION)) { - d7 += (0.05D * (entity.getEffect(MobEffects.LEVITATION).getAmplifier() + 1) - vec3d6.y) * 0.2D; - entity.fallDistance = 0.0F; - } else if (entity.level().isClientSide && !entity.level().hasChunkAt(blockposition)) { - if (entity.getY() > entity.level().getMinBuildHeight()) { - d7 = -0.1D; - } else { - d7 = 0.0D; - } - } else if (!entity.isNoGravity()) { - d7 -= d0; - } - if (entity.shouldDiscardFriction()) { - entity.setDeltaMovement(vec3d6.x, d7, vec3d6.z); - } else { - entity.setDeltaMovement(vec3d6.x * f, d7 * 0.98D, vec3d6.z * f); - } - } - } - entity.calculateEntityAnimation(entity instanceof net.minecraft.world.entity.animal.FlyingAnimal); - } - public static TreeMap getBehaviorMap(LivingEntity entity) { try { return (TreeMap) AVAILABLE_BEHAVIORS_BY_PRIORITY.invoke(entity.getBrain()); @@ -2318,10 +2213,6 @@ public class NMSImpl implements NMSBridge { return null; } - public static net.minecraft.world.entity.EntityType getEntityType(Class clazz) { - return (net.minecraft.world.entity.EntityType) CITIZENS_ENTITY_TYPES.get(clazz); - } - public static Entity getHandle(org.bukkit.entity.Entity entity) { if (!(entity instanceof CraftEntity)) return null; @@ -2408,7 +2299,10 @@ public class NMSImpl implements NMSBridge { if (npc == null) return snd; String data = npc.data().get(meta); - return data == null ? snd : BuiltInRegistries.SOUND_EVENT.get(ResourceLocation.tryParse(data)); + if (data == null) + return snd; + Reference ref = BuiltInRegistries.SOUND_EVENT.get(ResourceLocation.tryParse(data)).orElse(null); + return ref == null ? snd : ref.value(); } public static boolean isLeashed(NPC npc, Supplier isLeashed, Mob entity) { @@ -2443,6 +2337,145 @@ public class NMSImpl implements NMSBridge { return false; } + public static void moveLogic(LivingEntity entity, Vec3 v) { + if (entity.isEffectiveAi() || entity.isControlledByLocalInstance()) { + double g = 0.08D; + boolean flag = entity.getDeltaMovement().y <= 0.0D; + if (flag && entity.hasEffect(MobEffects.SLOW_FALLING)) { + g = 0.01D; + entity.fallDistance = 0.0F; + } + FluidState fluid = entity.level().getFluidState(entity.blockPosition()); + if ((entity.isInWater() || entity.isInLava()) && !entity.canStandOnFluid(fluid)) { + double d0 = entity.getY(); + double d1 = g; + Vec3 vec3d1; + if (entity.isInWater()) { + float f = entity.isSprinting() ? 0.9F : 0.8F; + float f1 = 0.02F; + float f2 = (float) entity.getAttributeValue(Attributes.WATER_MOVEMENT_EFFICIENCY); + if (!entity.onGround()) { + f2 *= 0.5F; + } + if (f2 > 0.0F) { + f += (0.54600006F - f) * f2; + f1 += (entity.getSpeed() - f1) * f2; + } + if (entity.hasEffect(MobEffects.DOLPHINS_GRACE)) { + f = 0.96F; + } + entity.moveRelative(f1, v); + entity.move(MoverType.SELF, entity.getDeltaMovement()); + Vec3 vec3d2 = entity.getDeltaMovement(); + if (entity.horizontalCollision && entity.onClimbable()) { + vec3d2 = new Vec3(vec3d2.x, 0.2, vec3d2.z); + } + vec3d2 = vec3d2.multiply(f, 0.800000011920929, f); + entity.setDeltaMovement(entity.getFluidFallingAdjustedMovement(d1, flag, vec3d2)); + } else { + entity.moveRelative(0.02F, v); + entity.move(MoverType.SELF, entity.getDeltaMovement()); + if (entity.getFluidHeight(FluidTags.LAVA) <= entity.getFluidJumpThreshold()) { + entity.setDeltaMovement(entity.getDeltaMovement().multiply(0.5, 0.800000011920929, 0.5)); + vec3d1 = entity.getFluidFallingAdjustedMovement(d1, flag, entity.getDeltaMovement()); + entity.setDeltaMovement(vec3d1); + } else { + entity.setDeltaMovement(entity.getDeltaMovement().scale(0.5)); + } + if (d1 != 0.0) { + entity.setDeltaMovement(entity.getDeltaMovement().add(0.0, -d1 / 4.0, 0.0)); + } + } + vec3d1 = entity.getDeltaMovement(); + if (entity.horizontalCollision + && entity.isFree(vec3d1.x, vec3d1.y + 0.6000000238418579 - entity.getY() + d0, vec3d1.z)) { + entity.setDeltaMovement(vec3d1.x, 0.30000001192092896, vec3d1.z); + } + } else if (entity.isFallFlying()) { + Vec3 vec3d = entity.getDeltaMovement(); + Vec3 vec3d1 = entity.getLookAngle(); + float f = entity.getXRot() * 0.017453292F; + double d0 = Math.sqrt(vec3d1.x * vec3d1.x + vec3d1.z * vec3d1.z); + double d1 = vec3d.horizontalDistance(); + double d2 = g; + double d3 = Mth.square(Math.cos(f)); + vec3d = vec3d.add(0.0, d2 * (-1.0 + d3 * 0.75), 0.0); + double d4; + if (vec3d.y < 0.0 && d0 > 0.0) { + d4 = vec3d.y * -0.1 * d3; + vec3d = vec3d.add(vec3d1.x * d4 / d0, d4, vec3d1.z * d4 / d0); + } + if (f < 0.0F && d0 > 0.0) { + d4 = d1 * (-Mth.sin(f)) * 0.04; + vec3d = vec3d.add(-vec3d1.x * d4 / d0, d4 * 3.2, -vec3d1.z * d4 / d0); + } + if (d0 > 0.0) { + vec3d = vec3d.add((vec3d1.x / d0 * d1 - vec3d.x) * 0.1, 0.0, (vec3d1.z / d0 * d1 - vec3d.z) * 0.1); + } + double h = vec3d.horizontalDistance(); + entity.setDeltaMovement(vec3d.multiply(0.99, 0.98, 0.99)); + entity.move(MoverType.SELF, entity.getDeltaMovement()); + if (entity.horizontalCollision) { + double dd = h - entity.getDeltaMovement().horizontalDistance(); + float ff = (float) (dd * 10.0 - 3.0); + if (ff > 0.0F) { + entity.playSound((int) f > 4 ? entity.getFallSounds().big() : entity.getFallSounds().small(), + 1.0F, 1.0F); + entity.hurt(entity.damageSources().flyIntoWall(), f); + } + } + } else { + BlockPos blockposition = entity.getBlockPosBelowThatAffectsMyMovement(); + float f = entity.onGround() ? entity.level().getBlockState(blockposition).getBlock().getFriction() + : 1.0F; + float f1 = f * 0.91F; + entity.moveRelative( + entity.onGround() ? entity.getSpeed() * (0.21600002F / (f * f * f)) + : entity.getControllingPassenger() instanceof Player ? entity.getSpeed() * 0.1F : 0.02F, + v); + if (entity.onClimbable()) { + Vec3 vec3d = entity.getDeltaMovement(); + entity.resetFallDistance(); + double d0 = Mth.clamp(vec3d.x, -0.15, 0.15); + double d1 = Mth.clamp(vec3d.z, -0.15, 0.15); + double d2 = Math.max(vec3d.y, -0.15); + if (d2 < 0.0 && !entity.getInBlockState().is(Blocks.SCAFFOLDING) + && entity.isSuppressingSlidingDownLadder() && entity instanceof Player) { + d2 = 0.0; + } + vec3d = new Vec3(d0, d2, d1); + entity.setDeltaMovement(vec3d); + } + entity.move(MoverType.SELF, entity.getDeltaMovement()); + Vec3 vec3d1 = entity.getDeltaMovement(); + if ((entity.horizontalCollision || NMS.shouldJump(entity.getBukkitEntity())) + && (entity.onClimbable() || entity.getInBlockState().is(Blocks.POWDER_SNOW) + && PowderSnowBlock.canEntityWalkOnPowderSnow(entity))) { + vec3d1 = new Vec3(vec3d1.x, 0.2, vec3d1.z); + } + double d0 = vec3d1.y; + MobEffectInstance mobeffect = entity.getEffect(MobEffects.LEVITATION); + if (mobeffect != null) { + d0 += (0.05 * (mobeffect.getAmplifier() + 1) - vec3d1.y) * 0.2; + } else if (entity.level().isClientSide && !entity.level().hasChunkAt(blockposition)) { + if (entity.getY() > entity.level().getMinY()) { + d0 = -0.1; + } else { + d0 = 0.0; + } + } else { + d0 -= g; + } + if (entity.shouldDiscardFriction()) { + entity.setDeltaMovement(vec3d1.x, d0, vec3d1.z); + } else { + float f2 = entity instanceof FlyingAnimal ? f1 : 0.98F; + entity.setDeltaMovement(vec3d1.x * f1, d0 * f2, vec3d1.z * f1); + } + } + } + } + public static void resetPuffTicks(Pufferfish fish) { try { PUFFERFISH_INFLATE.invoke(fish, 0); @@ -2594,17 +2627,17 @@ public class NMSImpl implements NMSBridge { } } - public static Entity teleportAcrossWorld(Entity entity, DimensionTransition transition) { + public static Entity teleportAcrossWorld(Entity entity, TeleportTransition transition) { if (entity.isRemoved()) return null; NPC npc = ((NPCHolder) entity).getNPC(); if (npc == null) return null; npc.despawn(DespawnReason.PENDING_RESPAWN); - npc.spawn(new Location(transition.newLevel().getWorld(), transition.pos().x, transition.pos().y, - transition.pos().z, transition.yRot(), transition.xRot())); + npc.spawn(new Location(transition.newLevel().getWorld(), transition.position().x, transition.position().y, + transition.position().z, transition.yRot(), transition.xRot())); Entity handle = ((CraftEntity) npc.getEntity()).getHandle(); - handle.setDeltaMovement(transition.speed()); + handle.setDeltaMovement(transition.deltaMovement()); handle.portalCooldown = entity.portalCooldown; return handle; } @@ -2642,16 +2675,12 @@ public class NMSImpl implements NMSBridge { } } - private static final MethodHandle ARMADILLO_SCUTE_TIME = NMS.getSetter(Armadillo.class, "cn"); - + private static final MethodHandle ARMADILLO_SCUTE_TIME = NMS.getSetter(Armadillo.class, "ck"); 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); - private static final MethodHandle ATTRIBUTE_SUPPLIER = NMS.getFirstGetter(AttributeMap.class, AttributeSupplier.class); - private static final MethodHandle AVAILABLE_BEHAVIORS_BY_PRIORITY = NMS.getGetter(Brain.class, "f"); private static final Set BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.BEE, EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, @@ -2660,39 +2689,38 @@ public class NMSImpl implements NMSBridge { 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, ServerPlayer.class, boolean.class); - private static final Map, net.minecraft.world.entity.EntityType> CITIZENS_ENTITY_TYPES = Maps - .newHashMap(); public static final MethodHandle CONNECTION_DISCONNECT_LISTENER = NMS.getSetter(Connection.class, "p"); public static final MethodHandle CONNECTION_PACKET_LISTENER = NMS.getSetter(Connection.class, "q"); private static final MethodHandle CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getFirstSetter(CraftBossBar.class, ServerBossEvent.class); - private static EntityDataAccessor DATA_NAME_VISIBLE = null; - private static EntityDataAccessor DATA_POSE = null; + private static final EntityDataAccessor DATA_NAME_VISIBLE = NMS.getStaticObject(Entity.class, "aR"); + private static final EntityDataAccessor DATA_POSE = NMS.getStaticObject(Entity.class, "aq"); private static final float DEFAULT_SPEED = 1F; public static final MethodHandle ENDERDRAGON_CHECK_WALLS = NMS.getFirstMethodHandleWithReturnType(EnderDragon.class, true, boolean.class, AABB.class); - public static final MethodHandle ENDERDRAGON_HURT = NMS.getMethodHandle(EnderDragon.class, "b", true, List.class); + public static final MethodHandle ENDERDRAGON_HURT = NMS.getMethodHandle(EnderDragon.class, "b", true, + ServerLevel.class, List.class); public static final MethodHandle ENDERDRAGON_KNOCKBACK = NMS.getMethodHandle(EnderDragon.class, "a", true, ServerLevel.class, List.class); - private static EntityDataAccessor ENDERMAN_CREEPY = null; - private static final MethodHandle ENTITY_EYE_HEIGHT = NMS.getSetter(Entity.class, "be"); + private static final EntityDataAccessor ENDERMAN_DATA_CREEPY = NMS.getStaticObject(EnderMan.class, "cc"); + private static final MethodHandle ENTITY_EYE_HEIGHT = NMS.getSetter(Entity.class, "bc"); private static final MethodHandle ENTITY_FISH_NUM_IN_SCHOOL = NMS.getFirstSetter(AbstractSchoolingFish.class, int.class); - private static MethodHandle ENTITY_NAVIGATION = NMS.getFirstSetter(Mob.class, PathNavigation.class); + private static final MethodHandle ENTITY_NAVIGATION = NMS.getFirstSetter(Mob.class, PathNavigation.class); private static CustomEntityRegistry ENTITY_REGISTRY; private static MethodHandle ENTITY_REGISTRY_SETTER; private static final MethodHandle FALLING_BLOCK_STATE_SETTER = NMS.getFirstSetter(FallingBlockEntity.class, BlockState.class); // first int of block of 4 - private static final MethodHandle FISHING_HOOK_LIFE = NMS.getSetter(FishingHook.class, "i"); + private static final MethodHandle FISHING_HOOK_LIFE = NMS.getSetter(FishingHook.class, "h"); private static final MethodHandle FLYING_MOVECONTROL_FLOAT_GETTER = NMS.getFirstGetter(FlyingMoveControl.class, boolean.class); private static final MethodHandle FLYING_MOVECONTROL_FLOAT_SETTER = NMS.getFirstSetter(FlyingMoveControl.class, boolean.class); public static final MethodHandle FOX_SET_FACEPLANTED = NMS.getMethodHandle(Fox.class, "B", true, boolean.class); private static final Location FROM_LOCATION = new Location(null, 0, 0, 0); - private static EntityDataAccessor INTERACTION_HEIGHT = null; - private static EntityDataAccessor INTERACTION_WIDTH = null; + private static final EntityDataAccessor INTERACTION_HEIGHT = NMS.getStaticObject(Interaction.class, "c"); + private static final EntityDataAccessor INTERACTION_WIDTH = NMS.getStaticObject(Interaction.class, "b"); private static final MethodHandle JUMP_FIELD = NMS.getGetter(LivingEntity.class, "bn"); private static final MethodHandle LOOK_CONTROL_SETTER = NMS.getFirstSetter(Mob.class, LookControl.class); private static MethodHandle META_COMPOUND_TAG; @@ -2705,19 +2733,23 @@ public class NMSImpl implements NMSBridge { private static final MethodHandle NAVIGATION_PATHFINDER = NMS.getFirstFinalSetter(PathNavigation.class, PathFinder.class); private static final MethodHandle NAVIGATION_WORLD_FIELD = NMS.getFirstSetter(PathNavigation.class, Level.class); - // Player.mobCounts: workaround for an issue which suppresses mobs being spawn near NPC players on Paper. Need to check for every update. + // Player.mobCounts: workaround for an issue which suppresses mobs being spawn near NPC players on Paper. Need to + // check for every update. public static final MethodHandle PAPER_PLAYER_MOB_COUNTS = NMS.getGetter(ServerPlayer.class, "mobCounts", false); private static final MethodHandle PLAYER_INFO_ENTRIES_LIST = NMS .getFirstFinalSetter(ClientboundPlayerInfoUpdatePacket.class, List.class); private static final MethodHandle PLAYERINFO_ENTRIES = PLAYER_INFO_ENTRIES_LIST; private static final MethodHandle POSITION_CODEC_GETTER = NMS.getFirstGetter(ServerEntity.class, VecDeltaCodec.class); - private static final MethodHandle PUFFERFISH_DEFLATE = NMS.getSetter(Pufferfish.class, "cd"); - private static final MethodHandle PUFFERFISH_INFLATE = NMS.getSetter(Pufferfish.class, "cc"); - public static EntityDataAccessor RABBIT_TYPE_DATAWATCHER = null; + private static final MethodHandle PUFFERFISH_DEFLATE = NMS.getSetter(Pufferfish.class, "cb"); + private static final MethodHandle PUFFERFISH_INFLATE = NMS.getSetter(Pufferfish.class, "ca"); + public static EntityDataAccessor RABBIT_TYPE_DATAWATCHER = NMS.getFirstStaticObject(Rabbit.class, + EntityDataAccessor.class); private static final Random RANDOM = Util.getFastRandom(); private static final MethodHandle SERVER_ENTITY_GETTER = NMS.getFirstGetter(TrackedEntity.class, ServerEntity.class); + public static final MethodHandle SERVER_ENTITY_TRACK_DELTA = NMS.getGetter(ServerEntity.class, "i"); + public static final MethodHandle SERVER_ENTITY_UPDATE_INTERVAL = NMS.getGetter(ServerEntity.class, "h"); private static MethodHandle SET_PROFILE_METHOD; private static final MethodHandle SIZE_FIELD_GETTER = NMS.getFirstGetter(Entity.class, EntityDimensions.class); private static final MethodHandle SIZE_FIELD_SETTER = NMS.getFirstSetter(Entity.class, EntityDimensions.class); @@ -2731,30 +2763,8 @@ public class NMSImpl implements NMSBridge { ENTITY_REGISTRY_SETTER = NMS.getFinalSetter(BuiltInRegistries.class, "f"); ENTITY_REGISTRY_SETTER.invoke(ENTITY_REGISTRY); } catch (Throwable e) { + e.printStackTrace(); Messaging.logTr(Messages.ERROR_GETTING_ID_MAPPING, e.getMessage()); } - try { - // Middle one - ENDERMAN_CREEPY = (EntityDataAccessor) NMS.getField(EnderMan.class, "ce").get(null); - } catch (Exception e) { - } - try { - RABBIT_TYPE_DATAWATCHER = (EntityDataAccessor) NMS - .getFirstStaticGetter(Rabbit.class, EntityDataAccessor.class).invoke(); - } catch (Throwable e) { - } - try { - INTERACTION_HEIGHT = (EntityDataAccessor) NMS.getGetter(Interaction.class, "d").invoke(); - } catch (Throwable e) { - } - try { - INTERACTION_WIDTH = (EntityDataAccessor) NMS.getGetter(Interaction.class, "c").invoke(); - } catch (Throwable e) { - } - try { - DATA_POSE = (EntityDataAccessor) NMS.getGetter(Entity.class, "at").invoke(); - DATA_NAME_VISIBLE = (EntityDataAccessor) NMS.getGetter(Entity.class, "aR").invoke(); - } catch (Throwable e) { - } } } diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/PitchableLookControl.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/PitchableLookControl.java similarity index 94% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/PitchableLookControl.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/PitchableLookControl.java index c05e671b9..75c1a61eb 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/PitchableLookControl.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/PitchableLookControl.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; import java.util.function.Supplier; diff --git a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/PlayerAnimationImpl.java b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/PlayerAnimationImpl.java similarity index 98% rename from v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/PlayerAnimationImpl.java rename to v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/PlayerAnimationImpl.java index 2fccaed26..4e277d759 100644 --- a/v1_21_R1/src/main/java/net/citizensnpcs/nms/v1_21_R1/util/PlayerAnimationImpl.java +++ b/v1_21_R2/src/main/java/net/citizensnpcs/nms/v1_21_R2/util/PlayerAnimationImpl.java @@ -1,4 +1,4 @@ -package net.citizensnpcs.nms.v1_21_R1.util; +package net.citizensnpcs.nms.v1_21_R2.util; import java.util.Map; diff --git a/v1_8_R3/pom.xml b/v1_8_R3/pom.xml index 013232310..f2d8c2a97 100644 --- a/v1_8_R3/pom.xml +++ b/v1_8_R3/pom.xml @@ -6,7 +6,7 @@ net.citizensnpcs citizens-parent - 2.0.35-SNAPSHOT + 2.0.36-SNAPSHOT citizens-v1_8_R3 diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/HumanController.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/HumanController.java index 5994373b2..4d9e297b2 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/HumanController.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/HumanController.java @@ -49,9 +49,7 @@ public class HumanController extends AbstractEntityController { if (getBukkitEntity() == null || !getBukkitEntity().isValid() || getBukkitEntity() != handle.getBukkitEntity()) return; - boolean removeFromPlayerList = npc.data().get(NPC.Metadata.REMOVE_FROM_PLAYERLIST, - Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean()); - NMS.addOrRemoveFromPlayerList(getBukkitEntity(), removeFromPlayerList); + NMS.addOrRemoveFromPlayerList(getBukkitEntity(), npc.shouldRemoveFromPlayerList()); }, 20); handle.getBukkitEntity().setSleepingIgnored(true); return handle.getBukkitEntity(); diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/MobEntityController.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/MobEntityController.java index c72a4bc73..c873c240f 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/MobEntityController.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/MobEntityController.java @@ -23,7 +23,7 @@ public abstract class MobEntityController extends AbstractEntityController { private final Constructor constructor; protected MobEntityController(Class clazz) { - super(clazz); + NMS.registerEntityClass(clazz, null); this.constructor = getConstructor(clazz); } diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/EggController.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/EggController.java index adc1676ec..6b3498eaf 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/EggController.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/EggController.java @@ -25,9 +25,7 @@ import net.minecraft.server.v1_8_R3.World; import net.minecraft.server.v1_8_R3.WorldServer; public class EggController extends AbstractEntityController { - public EggController() { - super(EntityEggNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/FallingBlockController.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/FallingBlockController.java index 05ead4cdd..a36a57fd6 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/FallingBlockController.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/FallingBlockController.java @@ -29,9 +29,7 @@ import net.minecraft.server.v1_8_R3.World; import net.minecraft.server.v1_8_R3.WorldServer; public class FallingBlockController extends AbstractEntityController { - public FallingBlockController() { - super(EntityFallingBlockNPC.class); - } + @Override protected Entity createEntity(Location at, NPC npc) { diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/ItemController.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/ItemController.java index 25c5f1db8..520896a4b 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/ItemController.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/nonliving/ItemController.java @@ -25,9 +25,6 @@ import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.World; public class ItemController extends AbstractEntityController { - public ItemController() { - super(EntityItemNPC.class); - } @Override protected org.bukkit.entity.Entity createEntity(Location at, NPC npc) { diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java index 05da68200..c92f8fcc4 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java @@ -19,10 +19,6 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; -import net.minecraft.server.v1_8_R3.DedicatedPlayerList; -import net.minecraft.server.v1_8_R3.DedicatedServer; -import net.minecraft.server.v1_8_R3.OpList; -import net.minecraft.server.v1_8_R3.OpListEntry; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -82,6 +78,8 @@ import net.citizensnpcs.api.gui.ForwardingInventory; import net.citizensnpcs.api.npc.BlockBreaker; import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration; import net.citizensnpcs.api.npc.NPC; +import net.citizensnpcs.api.trait.Trait; +import net.citizensnpcs.api.trait.TraitInfo; import net.citizensnpcs.api.util.BoundingBox; import net.citizensnpcs.api.util.EntityDim; import net.citizensnpcs.api.util.Messaging; @@ -154,6 +152,7 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.trait.RotationTrait; +import net.citizensnpcs.trait.versioned.BoatTrait; import net.citizensnpcs.util.EmptyChannel; import net.citizensnpcs.util.EntityPacketTracker; import net.citizensnpcs.util.EntityPacketTracker.PacketAggregator; @@ -177,6 +176,8 @@ import net.minecraft.server.v1_8_R3.ControllerMove; import net.minecraft.server.v1_8_R3.CrashReport; import net.minecraft.server.v1_8_R3.CrashReportSystemDetails; import net.minecraft.server.v1_8_R3.DamageSource; +import net.minecraft.server.v1_8_R3.DedicatedPlayerList; +import net.minecraft.server.v1_8_R3.DedicatedServer; import net.minecraft.server.v1_8_R3.EnchantmentManager; import net.minecraft.server.v1_8_R3.Entity; import net.minecraft.server.v1_8_R3.EntityEnderDragon; @@ -199,6 +200,8 @@ import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Navigation; import net.minecraft.server.v1_8_R3.NavigationAbstract; import net.minecraft.server.v1_8_R3.NetworkManager; +import net.minecraft.server.v1_8_R3.OpList; +import net.minecraft.server.v1_8_R3.OpListEntry; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; import net.minecraft.server.v1_8_R3.PacketPlayOutBed; @@ -672,6 +675,7 @@ public class NMSImpl implements NMSBridge { @Override public void load(CommandManager commands) { + registerTraitWithCommand(commands, BoatTrait.class); } private void loadEntityTypes() { @@ -919,14 +923,13 @@ public class NMSImpl implements NMSBridge { } @Override - public void registerEntityClass(Class clazz) { + public void registerEntityClass(Class clazz, Object raw) { if (ENTITY_CLASS_TO_INT == null || ENTITY_CLASS_TO_INT.containsKey(clazz)) return; Class search = clazz; while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) { - if (!ENTITY_CLASS_TO_INT.containsKey(search)) { + if (!ENTITY_CLASS_TO_INT.containsKey(search)) continue; - } int code = ENTITY_CLASS_TO_INT.get(search); ENTITY_CLASS_TO_INT.put(clazz, code); ENTITY_CLASS_TO_NAME.put(clazz, ENTITY_CLASS_TO_NAME.get(search)); @@ -935,6 +938,11 @@ public class NMSImpl implements NMSBridge { throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString()); } + private void registerTraitWithCommand(CommandManager manager, Class clazz) { + CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(clazz)); + manager.register(clazz); + } + @Override public void remove(org.bukkit.entity.Entity entity) { NMSImpl.getHandle(entity).die(); @@ -1169,6 +1177,23 @@ public class NMSImpl implements NMSBridge { entity.setVelocity(vector); } + @Override + public void setOpWithoutSaving(Player player, boolean op) { + if (player.isOp() == op) + return; + final GameProfile profile = ((CraftPlayer) player).getProfile(); + final DedicatedPlayerList playerList = ((CraftServer) player.getServer()).getHandle(); + final DedicatedServer server = playerList.getServer(); + final OpList opList = playerList.getOPs(); + if (op) { + opList.add(new OpListEntry(profile, server.getPropertyManager().getInt("op-permission-level", 4), + opList.b(profile))); + } else { + opList.remove(profile); + } + player.recalculatePermissions(); + } + @Override public void setPitch(org.bukkit.entity.Entity entity, float pitch) { getHandle(entity).pitch = pitch; @@ -1246,21 +1271,6 @@ public class NMSImpl implements NMSBridge { handle.r(ticks); } - @Override - public void setOpWithoutSaving(Player player, boolean op) { - if (player.isOp() == op) return; - final GameProfile profile = ((CraftPlayer) player).getProfile(); - final DedicatedPlayerList playerList = ((CraftServer) player.getServer()).getHandle(); - final DedicatedServer server = playerList.getServer(); - final OpList opList = playerList.getOPs(); - if (op) { - opList.add(new OpListEntry(profile, server.getPropertyManager().getInt("op-permission-level", 4), opList.b(profile))); - } else { - opList.remove(profile); - } - player.recalculatePermissions(); - } - @Override public boolean shouldJump(org.bukkit.entity.Entity entity) { if (JUMP_FIELD == null || !(entity instanceof LivingEntity))