diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c644fc4d..41f44459 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -18,7 +18,7 @@ on: # The branches below must be a subset of the branches above branches: [ v5.0-Recode ] schedule: - - cron: '0 */24 * * *' + - cron: '0 0 * * *' jobs: analyze: @@ -38,7 +38,7 @@ jobs: steps: - name: Setup Java JDK - uses: actions/setup-java@v2.5.0 + uses: actions/setup-java@v4.5.0 with: # The Java version to set up. Takes a whole or semver Java version. See examples of supported syntax in README file java-version: 21 @@ -46,7 +46,7 @@ jobs: distribution: microsoft - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4.2.2 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/nms/master/pom.xml b/nms/master/pom.xml index 1d2f744a..44ad82e5 100644 --- a/nms/master/pom.xml +++ b/nms/master/pom.xml @@ -20,7 +20,7 @@ -NMS_Master-IGNORE - 17 + 21 diff --git a/nms/master/src/simplepets/brainsynder/nms/VersionTranslator.java b/nms/master/src/simplepets/brainsynder/nms/VersionTranslator.java index 95b1387c..f1d45e2e 100644 --- a/nms/master/src/simplepets/brainsynder/nms/VersionTranslator.java +++ b/nms/master/src/simplepets/brainsynder/nms/VersionTranslator.java @@ -3,13 +3,16 @@ import lib.brainsynder.ServerVersion; import lib.brainsynder.nbt.StorageTagCompound; import net.minecraft.core.BlockPos; +import net.minecraft.core.Registry; import net.minecraft.core.Vec3i; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; +import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket; import net.minecraft.network.syncher.EntityDataSerializer; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerEntity; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; @@ -21,6 +24,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.World; import org.bukkit.block.data.BlockData; +import org.bukkit.craftbukkit.v1_21_R2.util.CraftNamespacedKey; import org.bukkit.event.entity.CreatureSpawnEvent; import simplepets.brainsynder.nms.entity.EntityPet; @@ -175,4 +179,18 @@ public static boolean isWalkable (EntityPet entity, BlockPos.MutableBlockPos blo public static void overrideAttributeMap (EntityPet entityPet) { throw new UnsupportedOperationException ("Missing support for "+ ServerVersion.getVersion().name()); } + + // ADDED DURING 1.21.3 DEVELOPMENT + public static T getRegistryValue (Registry registry, NamespacedKey key) { + registry.get(CraftNamespacedKey.toMinecraft(key)); + throw new UnsupportedOperationException ("Missing support for "+ ServerVersion.getVersion().name()); + } + + public static void killEntity (Entity entity, ServerLevel level) { + throw new UnsupportedOperationException ("Missing support for "+ ServerVersion.getVersion().name()); + } + + public static ClientboundTeleportEntityPacket getTeleportPacket (Entity entity) { + throw new UnsupportedOperationException ("Missing support for "+ ServerVersion.getVersion().name()); + } } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/EntityAgeablePet.java b/nms/master/src/simplepets/brainsynder/nms/entity/EntityAgeablePet.java index c0c434d2..cc9d7141 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/EntityAgeablePet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/EntityAgeablePet.java @@ -12,7 +12,7 @@ import simplepets.brainsynder.api.user.PetUser; import simplepets.brainsynder.nms.utils.PetDataAccess; -public abstract class EntityAgeablePet extends EntityPet implements IAgeablePet { +public abstract class EntityAgeablePet extends EntityPetOverride implements IAgeablePet { private static final EntityDataAccessor BABY = SynchedEntityData.defineId(EntityAgeablePet.class, EntityDataSerializers.BOOLEAN); public EntityAgeablePet(EntityType entitytypes, PetType type, PetUser user) { diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/EntityBase.java b/nms/master/src/simplepets/brainsynder/nms/entity/EntityBase.java index 42f0574e..81057507 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/EntityBase.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/EntityBase.java @@ -1,10 +1,8 @@ package simplepets.brainsynder.nms.entity; -import lib.brainsynder.ServerVersion; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.MobCategory; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import simplepets.brainsynder.api.pet.PetType; @@ -13,9 +11,6 @@ import simplepets.brainsynder.nms.entity.list.EntityRabbitPet; import simplepets.brainsynder.nms.entity.list.EntitySlimePet; import simplepets.brainsynder.nms.utils.PetDataAccess; -import simplepets.brainsynder.utils.VersionFields; - -import java.lang.reflect.Field; public class EntityBase extends Mob { protected final EntityType entityType; @@ -89,19 +84,6 @@ public PetUser getUser() { } EntityType getEntityType(EntityType originalType) { - try { - Field field = EntityType.class.getDeclaredField(VersionFields.fromServerVersion(ServerVersion.getVersion()).getEntityFactoryField()); - field.setAccessible(true); - EntityType.Builder builder = EntityType.Builder.of((EntityType.EntityFactory) field.get(originalType), MobCategory.AMBIENT); - builder.sized(0.1f, 0.1f); - return builder.build(petType.name().toLowerCase()); - } catch (IllegalAccessException | NoSuchFieldException e) { - e.printStackTrace(); - return originalType; - } - } - - public boolean alwaysAccepts() { - return super.alwaysAccepts(); + return null; } } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/EntityFishPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/EntityFishPet.java index 3d366ccb..b034b761 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/EntityFishPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/EntityFishPet.java @@ -18,7 +18,7 @@ // Implement Bucketable so the server resends the entity when the client tries // to pick it up with a bucket -public class EntityFishPet extends EntityPet implements IEntityFishPet, Bucketable { +public class EntityFishPet extends EntityPetOverride implements IEntityFishPet, Bucketable { private static final EntityDataAccessor FROM_BUCKET = SynchedEntityData.defineId(EntityFishPet.class, EntityDataSerializers.BOOLEAN); public EntityFishPet(EntityType entitytypes, PetType type, PetUser user) { diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/EntityFlyablePet.java b/nms/master/src/simplepets/brainsynder/nms/entity/EntityFlyablePet.java index 272b1a10..3c047a68 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/EntityFlyablePet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/EntityFlyablePet.java @@ -13,7 +13,7 @@ import simplepets.brainsynder.api.user.PetUser; import simplepets.brainsynder.nms.VersionTranslator; -public abstract class EntityFlyablePet extends EntityPet implements IFlyableEntity { +public abstract class EntityFlyablePet extends EntityPetOverride implements IFlyableEntity { public EntityFlyablePet(EntityType entitytypes, PetType type, PetUser user) { super(entitytypes, type, user); this.moveControl = new FlyingMoveControl(this, 20, false); diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/EntityPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/EntityPet.java index 9ac7d384..7bb5d9ad 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/EntityPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/EntityPet.java @@ -5,6 +5,7 @@ import lib.brainsynder.sounds.SoundMaker; import lib.brainsynder.utils.Colorize; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.EntityType; @@ -25,8 +26,6 @@ import simplepets.brainsynder.api.entity.misc.IEntityControllerPet; import simplepets.brainsynder.api.event.entity.EntityNameChangeEvent; import simplepets.brainsynder.api.event.entity.PetMoveEvent; -import simplepets.brainsynder.api.event.entity.movment.PetJumpEvent; -import simplepets.brainsynder.api.event.entity.movment.PetRideEvent; import simplepets.brainsynder.api.other.ParticleHandler; import simplepets.brainsynder.api.pet.CommandReason; import simplepets.brainsynder.api.pet.IPetConfig; @@ -40,7 +39,6 @@ import simplepets.brainsynder.nms.pathfinder.PathfinderGoalLookAtOwner; import simplepets.brainsynder.nms.utils.EntityUtils; -import java.lang.reflect.Field; import java.util.HashMap; import java.util.Map; import java.util.Optional; @@ -79,7 +77,6 @@ public abstract class EntityPet extends EntityBase implements IEntityPet { protected double rideSpeed = 0.4000000238418579; protected double flySpeed = 0.10000000149011612; private boolean floatDown = false; - private boolean immovable = false; private boolean glowVanishToggle = true; private boolean autoRemoveToggle = true; private boolean displayNameVisibility = true; @@ -107,7 +104,6 @@ public EntityPet(EntityType entitytypes, PetType type, PetUser us VersionTranslator.overrideAttributeMap(this); - immovable = ConfigOption.INSTANCE.PET_TOGGLES_MOB_PUSHER.getValue(); glowVanishToggle = ConfigOption.INSTANCE.PET_TOGGLES_GLOW_VANISH.getValue(); autoRemoveToggle = ConfigOption.INSTANCE.AUTO_REMOVE_ENABLED.getValue(); autoRemoveTick = ConfigOption.INSTANCE.AUTO_REMOVE_TICK.getValue(); @@ -137,12 +133,16 @@ public boolean isJumping() { return jumping; } + public double getJumpHeight() { + return jumpHeight; + } + @Override public void teleportToOwner() { - getPetUser ().getUserLocation().ifPresent(location -> { + getPetUser().getUserLocation().ifPresent(location -> { PaperLib.teleportAsync(getEntity(), location); - SimplePets.getPetUtilities().runPetCommands(CommandReason.TELEPORT, getPetUser (), getPetType()); - SimplePets.getParticleHandler().sendParticle(ParticleHandler.Reason.TELEPORT, getPetUser ().getPlayer(), location); + SimplePets.getPetUtilities().runPetCommands(CommandReason.TELEPORT, getPetUser(), getPetType()); + SimplePets.getParticleHandler().sendParticle(ParticleHandler.Reason.TELEPORT, getPetUser().getPlayer(), location); }); } @@ -157,6 +157,11 @@ public ChatColor getGlowColor() { return glowColor; } + // 1.20.3 - Changed method(s) AGAIN + protected boolean actuallyHurt(ServerLevel worldserver, DamageSource damagesource, float f, EntityDamageEvent event) { + return false; + } + protected boolean damageEntity0(DamageSource damagesource, float f) { return false; } @@ -179,7 +184,7 @@ protected void registerGoals() { if (getPetType() != PetType.SHULKER) { if (ConfigOption.INSTANCE.LEGACY_PATHFINDING_ENABLED.getValue()) { goalSelector.addGoal(2, new LegacyPathfinderFollowPlayer(this, 3, 10)); - }else{ + } else { goalSelector.addGoal(2, new PathfinderFollowPlayer(this)); } } @@ -217,7 +222,7 @@ public void setPetName(String name) { name = config.get().getDisplayName(); } } - String newName = name.replace("%player%", getPetUser ().getPlayer().getName()); + String newName = name.replace("%player%", getPetUser().getPlayer().getName()); EntityNameChangeEvent event = new EntityNameChangeEvent(this, newName); Bukkit.getServer().getPluginManager().callEvent(event); @@ -233,8 +238,8 @@ public void setPetName(String name) { public Optional getPetName() { if (petName != null) return Optional.of(petName); - if (getPetUser ().getPetName(getPetType()).isPresent()) - return getPetUser ().getPetName(getPetType()); + if (getPetUser().getPetName(getPetType()).isPresent()) + return getPetUser().getPetName(getPetType()); return Optional.empty(); } @@ -245,7 +250,7 @@ public void handleAdditionalStorage(String pluginKey, Function { + getPetUser().getPetName(getPetType()).ifPresent(name -> { object.setString("name", name.replace('ยง', '&')); }); object.setBoolean("silent", silent); @@ -344,11 +349,12 @@ public Entity getEntity() { @Override public boolean attachOwner() { ejectPassengers(); - var owner = getPetUser ().getPlayer(); + var owner = getPetUser().getPlayer(); if (owner != null) { - SimplePets.getPetUtilities().runPetCommands(CommandReason.RIDE, getPetUser (), getPetType()); + SimplePets.getPetUtilities().runPetCommands(CommandReason.RIDE, getPetUser(), getPetType()); if (!doIndirectAttach) { - return VersionTranslator.getBukkitEntity(this).addPassenger(owner); + // This was a test to see if using the startRiding method would work instead... + return VersionTranslator.getEntityHandle(owner).startRiding(this); } else { return SeatEntity.attach(VersionTranslator.getEntityHandle(owner), this); } @@ -363,7 +369,7 @@ public PetType getPetType() { @Override public PetUser getPetUser() { - return super.getUser (); + return super.getUser(); } @Override @@ -390,77 +396,6 @@ protected boolean isOwnerRiding() { return getSelfAndPassengers().anyMatch(e -> e.equals(owner)); } - @Override - public void travel(Vec3 vec3d) { - if ((getPetType() == null) || (getPetUser () == null)) return; - - if ((passengers == null) - || (!isOwnerRiding())) { - super.travel(vec3d); - return; - } - - ServerPlayer passenger = VersionTranslator.getEntityHandle(getPetUser().getPlayer()); - - if (doIndirectAttach) { - if (getFirstPassenger() instanceof SeatEntity seat) { - // orient the seat entity correctly. Seems to fix the issue - // where ridden horses are not oriented properly - seat.setYRot(passenger.getYRot()); - seat.yRotO = this.getYRot(); - seat.setXRot(passenger.getXRot() * 0.5F); - seat.setRot(this.getYRot(), this.getXRot()); - seat.yHeadRot = this.yBodyRot = this.getYRot(); - } - } - - this.setYRot(passenger.getYRot()); - this.yRotO = this.getYRot(); - this.setXRot(passenger.getXRot() * 0.5F); - this.setRot(this.getYRot(), this.getXRot()); - this.yHeadRot = this.yBodyRot = this.getYRot(); - - double strafe = passenger.xxa * 0.5; - double vertical = vec3d.y; - double forward = passenger.zza; - if (forward <= 0) { - forward *= 0.25F; - } - - PetMoveEvent moveEvent = new PetRideEvent(this); - Bukkit.getServer().getPluginManager().callEvent(moveEvent); - if (moveEvent.isCancelled()) return; - - double speed = VersionTranslator.getWalkSpeed(this); - - Field jumpField = VersionTranslator.getJumpField(); - if ((jumpField != null) && (!passengers.isEmpty())) { - SimplePets.getPetConfigManager().getPetConfig(getPetType()).ifPresent(config -> { - try { - boolean flight = false; - double height = jumpHeight; - - if (config.canFly(getPetUser().getPlayer())) { - flight = true; - height = 0.3; - } - - PetJumpEvent jumpEvent = new PetJumpEvent(this, height); - Bukkit.getServer().getPluginManager().callEvent(jumpEvent); - if ((!jumpEvent.isCancelled()) && jumpField.getBoolean(passenger)) { - if (flight || this.onGround) { - setDeltaMovement(getDeltaMovement().x, jumpEvent.getJumpHeight(), getDeltaMovement().z); - this.hasImpulse = true; - } - } - } catch (IllegalArgumentException | IllegalStateException | IllegalAccessException ignored) {} - }); - } - - this.setSpeed((float) speed); - super.travel(new Vec3(strafe, vertical, forward)); - } - @Override public void tick() { super.tick(); @@ -478,8 +413,8 @@ public void tick() { if (standStillTicks != 0) standStillTicks = 0; } else { if (standStillTicks == autoRemoveTick) { - if (getPetUser () != null) { - getPetUser ().removePet(getPetType()); + if (getPetUser() != null) { + getPetUser().removePet(getPetType()); } else { bukkitEntity.remove(); } @@ -489,23 +424,25 @@ public void tick() { } // Handles all other Pet Tasks... - if (getPetUser () == null || getPetUser ().getPlayer() == null || !getPetUser ().getPlayer().isOnline()) { + if (getPetUser() == null || getPetUser().getPlayer() == null || !getPetUser().getPlayer().isOnline()) { if (bukkitEntity != null) bukkitEntity.remove(); return; } - if (verticalWorldConfines && ( (getY() > maxHeight) || (minHeight > getY()) )) { - getPetUser ().removePet(getPetType()); + if (verticalWorldConfines && ((getY() > maxHeight) || (minHeight > getY()))) { + getPetUser().removePet(getPetType()); return; } + // Ensures that pets that hover for too long are either removed + // by the player or automatically deleted if they are not associated with any player if (isOnGround()) { if (hoverTickCount != 0) hoverTickCount = 0; } else { if (hoverTickCount == hoverRemoveTick) { - if (getPetUser () != null) { - getPetUser ().removePet(getPetType()); + if (getPetUser() != null) { + getPetUser().removePet(getPetType()); } else { bukkitEntity.remove(); } @@ -513,7 +450,7 @@ public void tick() { hoverTickCount++; } - if (getPetUser ().isPetVehicle(getPetType())) { + if (getPetUser().isPetVehicle(getPetType())) { if (floatDown) { if (!isOnGround(this)) { setDeltaMovement(getDeltaMovement().x, getDeltaMovement().y * 0.4, getDeltaMovement().z); @@ -524,10 +461,10 @@ public void tick() { if (this.frozen && (getTicksFrozen() < 140)) setTicksFrozen(150); if (this.onFire && (getRemainingFireTicks() < 140)) setRemainingFireTicks(150); - if (getPetUser ().getPlayer() != null) { - Player player = getPetUser ().getPlayer(); + if (getPetUser().getPlayer() != null) { + Player player = getPetUser().getPlayer(); boolean shifting = player.isSneaking(); - if ((displayNameVisibility && hideNameShifting) && (getPetType() != PetType.SHULKER)) + if ((displayNameVisibility && hideNameShifting) && (getPetType() != PetType.SHULKER)) getEntity().setCustomNameVisible((!shifting)); // Checks if the pet can actually be toggled to match their owners @@ -538,7 +475,7 @@ public void tick() { ); if (ownerVanish && ConfigOption.INSTANCE.MISC_TOGGLES_REMOVED_VANISH.getValue()) { - getPetUser ().removePet(getPetType()); + getPetUser().removePet(getPetType()); return; } @@ -556,7 +493,7 @@ public void tick() { } } - if (getPetUser ().isPetHat(getPetType())) { + if (getPetUser().isPetHat(getPetType())) { setYRot(player.getLocation().getYaw()); this.yRotO = getYRot(); } @@ -607,7 +544,8 @@ private void glowHandler(Player player, boolean glow) { EntityUtils.getGlowingInstance().unsetGlowing(entity, player); } } - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } @Override diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/EntityPetOverride.java b/nms/master/src/simplepets/brainsynder/nms/entity/EntityPetOverride.java new file mode 100644 index 00000000..b42dd894 --- /dev/null +++ b/nms/master/src/simplepets/brainsynder/nms/entity/EntityPetOverride.java @@ -0,0 +1,12 @@ +package simplepets.brainsynder.nms.entity; + +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; +import simplepets.brainsynder.api.pet.PetType; +import simplepets.brainsynder.api.user.PetUser; + +public class EntityPetOverride extends EntityPet { + public EntityPetOverride(EntityType entitytypes, PetType type, PetUser user) { + super(entitytypes, type, user); + } +} diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/branch/EntityPiglinAbstractPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/branch/EntityPiglinAbstractPet.java index 3ad78c63..3180dd8b 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/branch/EntityPiglinAbstractPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/branch/EntityPiglinAbstractPet.java @@ -9,10 +9,10 @@ import simplepets.brainsynder.api.entity.misc.IShaking; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; import simplepets.brainsynder.nms.utils.PetDataAccess; -public abstract class EntityPiglinAbstractPet extends EntityPet implements IShaking { +public abstract class EntityPiglinAbstractPet extends EntityPetOverride implements IShaking { private static final EntityDataAccessor IMMUNE_TO_ZOMBIFICATION = SynchedEntityData.defineId(EntityPiglinAbstractPet.class, EntityDataSerializers.BOOLEAN); public EntityPiglinAbstractPet(EntityType entitytypes, PetType type, PetUser user) { diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/branch/EntityRaiderPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/branch/EntityRaiderPet.java index ca63cde0..14b42936 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/branch/EntityRaiderPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/branch/EntityRaiderPet.java @@ -9,10 +9,10 @@ import simplepets.brainsynder.api.entity.misc.IRaider; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; import simplepets.brainsynder.nms.utils.PetDataAccess; -public abstract class EntityRaiderPet extends EntityPet implements IRaider { +public abstract class EntityRaiderPet extends EntityPetOverride implements IRaider { private static final EntityDataAccessor CELEBRATING = SynchedEntityData.defineId(EntityRaiderPet.class, EntityDataSerializers.BOOLEAN); public EntityRaiderPet(EntityType entitytypes, PetType type, PetUser user) { diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityArmorStandPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityArmorStandPet.java index b717e43e..1b20fdd9 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityArmorStandPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityArmorStandPet.java @@ -152,7 +152,7 @@ public void tick() { if ((this.pet == null) || (VersionTranslator.getBukkitEntity(pet).isDead()) || (!VersionTranslator.getBukkitEntity(pet).isValid())) { - kill(); + VersionTranslator.killEntity(this, (ServerLevel) level()); return; } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityBoggedPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityBoggedPet.java index 1ed399eb..e229f951 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityBoggedPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityBoggedPet.java @@ -9,16 +9,16 @@ import simplepets.brainsynder.api.entity.hostile.IEntityBoggedPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; import simplepets.brainsynder.nms.utils.PetDataAccess; /** * NMS: {@link net.minecraft.world.entity.monster.Bogged} */ @SupportedVersion(version = ServerVersion.v1_21) -public class EntityBoggedPet extends EntityPet implements IEntityBoggedPet { - private static final EntityDataAccessor DATA_SHEARED = SynchedEntityData.defineId(EntityBoggedPet.class, EntityDataSerializers.BOOLEAN);; - +public class EntityBoggedPet extends EntityPetOverride implements IEntityBoggedPet { + private static final EntityDataAccessor DATA_SHEARED = SynchedEntityData.defineId(EntityBoggedPet.class, EntityDataSerializers.BOOLEAN); + public EntityBoggedPet(PetType type, PetUser user) { super(EntityType.BOGGED, type, user); } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityBreezePet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityBreezePet.java index f634878d..204319ca 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityBreezePet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityBreezePet.java @@ -6,13 +6,13 @@ import simplepets.brainsynder.api.entity.hostile.IEntityBreezePet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; /** * NMS: {@link net.minecraft.world.entity.monster.breeze.Breeze} */ @SupportedVersion(version = ServerVersion.v1_21) -public class EntityBreezePet extends EntityPet implements IEntityBreezePet { +public class EntityBreezePet extends EntityPetOverride implements IEntityBreezePet { public EntityBreezePet(PetType type, PetUser user) { super(EntityType.BREEZE, type, user); } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityCatPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityCatPet.java index 94c9dae3..a6943a50 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityCatPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityCatPet.java @@ -11,12 +11,12 @@ import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.animal.CatVariant; -import org.bukkit.craftbukkit.v1_21_R1.CraftRegistry; -import org.bukkit.craftbukkit.v1_21_R1.util.CraftNamespacedKey; +import org.bukkit.craftbukkit.v1_21_R2.CraftRegistry; import simplepets.brainsynder.api.entity.passive.IEntityCatPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; import simplepets.brainsynder.api.wrappers.CatType; +import simplepets.brainsynder.nms.VersionTranslator; import simplepets.brainsynder.nms.entity.EntityTameablePet; import simplepets.brainsynder.nms.utils.PetDataAccess; @@ -73,7 +73,7 @@ public void setCatType(CatType type) { this.type = type; Registry registry = CraftRegistry.getMinecraftRegistry(Registries.CAT_VARIANT); - entityData.set(TYPE, registry.wrapAsHolder(registry.get(CraftNamespacedKey.toMinecraft(type.getKey())))); + entityData.set(TYPE, registry.wrapAsHolder(VersionTranslator.getRegistryValue(registry, type.getKey()))); } @Override diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityCaveSpiderPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityCaveSpiderPet.java index f91beea0..dd29b0e2 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityCaveSpiderPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityCaveSpiderPet.java @@ -4,12 +4,12 @@ import simplepets.brainsynder.api.entity.hostile.IEntityCaveSpiderPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; /** * NMS: {@link net.minecraft.world.entity.monster.CaveSpider} */ -public class EntityCaveSpiderPet extends EntityPet implements IEntityCaveSpiderPet { +public class EntityCaveSpiderPet extends EntityPetOverride implements IEntityCaveSpiderPet { public EntityCaveSpiderPet(PetType type, PetUser user) { super(EntityType.CAVE_SPIDER, type, user); } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityCreeperPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityCreeperPet.java index c667543a..8c4db69b 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityCreeperPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityCreeperPet.java @@ -8,13 +8,13 @@ import simplepets.brainsynder.api.entity.hostile.IEntityCreeperPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; import simplepets.brainsynder.nms.utils.PetDataAccess; /** * NMS: {@link net.minecraft.world.entity.monster.Creeper} */ -public class EntityCreeperPet extends EntityPet implements IEntityCreeperPet { +public class EntityCreeperPet extends EntityPetOverride implements IEntityCreeperPet { protected static final EntityDataAccessor STATE = SynchedEntityData.defineId(EntityCreeperPet.class, EntityDataSerializers.INT); protected static final EntityDataAccessor POWERED = SynchedEntityData.defineId(EntityCreeperPet.class, EntityDataSerializers.BOOLEAN); protected static final EntityDataAccessor IGNITED = SynchedEntityData.defineId(EntityCreeperPet.class, EntityDataSerializers.BOOLEAN); diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityDolphinPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityDolphinPet.java index 3a27af8f..e495897f 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityDolphinPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityDolphinPet.java @@ -8,13 +8,13 @@ import simplepets.brainsynder.api.entity.hostile.IEntityDolphinPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; import simplepets.brainsynder.nms.utils.PetDataAccess; /** * NMS: {@link net.minecraft.world.entity.animal.Dolphin} */ -public class EntityDolphinPet extends EntityPet implements IEntityDolphinPet { +public class EntityDolphinPet extends EntityPetOverride implements IEntityDolphinPet { private static final EntityDataAccessor TREASURE = SynchedEntityData.defineId(EntityDolphinPet.class, EntityDataSerializers.BLOCK_POS); private static final EntityDataAccessor HAS_FISH = SynchedEntityData.defineId(EntityDolphinPet.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor MOIST = SynchedEntityData.defineId(EntityDolphinPet.class, EntityDataSerializers.INT); diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityEndermanPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityEndermanPet.java index c9baee64..a5ad41e0 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityEndermanPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityEndermanPet.java @@ -16,7 +16,7 @@ import simplepets.brainsynder.debug.DebugBuilder; import simplepets.brainsynder.debug.DebugLevel; import simplepets.brainsynder.nms.VersionTranslator; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; import simplepets.brainsynder.nms.utils.PetDataAccess; import java.util.Optional; @@ -24,7 +24,7 @@ /** * NMS: {@link net.minecraft.world.entity.monster.Enderman} */ -public class EntityEndermanPet extends EntityPet implements IEntityEndermanPet { +public class EntityEndermanPet extends EntityPetOverride implements IEntityEndermanPet { private static final EntityDataAccessor> CARRIED_BLOCK = SynchedEntityData.defineId(EntityEndermanPet.class, VersionTranslator.OPTIONAL_BLOCK_STATE); private static final EntityDataAccessor SCREAMING = SynchedEntityData.defineId(EntityEndermanPet.class, EntityDataSerializers.BOOLEAN); diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityEndermitePet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityEndermitePet.java index 15d44368..83d39321 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityEndermitePet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityEndermitePet.java @@ -4,12 +4,12 @@ import simplepets.brainsynder.api.entity.hostile.IEntityEndermitePet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; /** * NMS: {@link net.minecraft.world.entity.monster.Endermite} */ -public class EntityEndermitePet extends EntityPet implements IEntityEndermitePet { +public class EntityEndermitePet extends EntityPetOverride implements IEntityEndermitePet { public EntityEndermitePet(PetType type, PetUser user) { super(EntityType.ENDERMITE, type, user); } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityFrogPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityFrogPet.java index 58fa2684..c8588ef8 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityFrogPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityFrogPet.java @@ -16,12 +16,12 @@ import net.minecraft.world.entity.Pose; import net.minecraft.world.entity.animal.FrogVariant; import net.minecraft.world.phys.Vec3; -import org.bukkit.craftbukkit.v1_21_R1.CraftRegistry; -import org.bukkit.craftbukkit.v1_21_R1.util.CraftNamespacedKey; +import org.bukkit.craftbukkit.v1_21_R2.CraftRegistry; import simplepets.brainsynder.api.entity.passive.IEntityFrogPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; import simplepets.brainsynder.api.wrappers.FrogType; +import simplepets.brainsynder.nms.VersionTranslator; import simplepets.brainsynder.nms.entity.EntityAgeablePet; import simplepets.brainsynder.nms.utils.PetDataAccess; @@ -120,7 +120,7 @@ public void setVariant(FrogType type) { this.type = type; Registry registry = CraftRegistry.getMinecraftRegistry(Registries.FROG_VARIANT); - entityData.set(DATA_VARIANT, registry.wrapAsHolder(registry.get(CraftNamespacedKey.toMinecraft(type.getKey())))); + entityData.set(DATA_VARIANT, registry.wrapAsHolder(VersionTranslator.getRegistryValue(registry, type.getKey()))); } @Override diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityGhastPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityGhastPet.java index e6640820..1039d45e 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityGhastPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityGhastPet.java @@ -8,13 +8,13 @@ import simplepets.brainsynder.api.entity.hostile.IEntityGhastPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; import simplepets.brainsynder.nms.utils.PetDataAccess; /** * NMS: {@link net.minecraft.world.entity.monster.Ghast} */ -public class EntityGhastPet extends EntityPet implements IEntityGhastPet { +public class EntityGhastPet extends EntityPetOverride implements IEntityGhastPet { private static final EntityDataAccessor ATTACKING = SynchedEntityData.defineId(EntityGhastPet.class, EntityDataSerializers.BOOLEAN); // TODO: Need to figure out why the Ghast pet wont work properly if given the Flight MoveController diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityGiantPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityGiantPet.java index 2546e47c..b9c9c93b 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityGiantPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityGiantPet.java @@ -4,12 +4,12 @@ import simplepets.brainsynder.api.entity.hostile.IEntityGiantPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; /** * NMS: {@link net.minecraft.world.entity.monster.Giant} */ -public class EntityGiantPet extends EntityPet implements IEntityGiantPet { +public class EntityGiantPet extends EntityPetOverride implements IEntityGiantPet { public EntityGiantPet(PetType type, PetUser user) { super(EntityType.GIANT, type, user); } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityGuardianPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityGuardianPet.java index b40b4575..6ecba7f2 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityGuardianPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityGuardianPet.java @@ -8,13 +8,13 @@ import simplepets.brainsynder.api.entity.hostile.IEntityGuardianPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; import simplepets.brainsynder.nms.utils.PetDataAccess; /** * NMS: {@link net.minecraft.world.entity.monster.Guardian} */ -public class EntityGuardianPet extends EntityPet implements IEntityGuardianPet { +public class EntityGuardianPet extends EntityPetOverride implements IEntityGuardianPet { private static final EntityDataAccessor MOVING = SynchedEntityData.defineId(EntityGuardianPet.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor TARGET_ENTITY = SynchedEntityData.defineId(EntityGuardianPet.class, EntityDataSerializers.INT); diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityIronGolemPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityIronGolemPet.java index ba77bd55..9e04e52f 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityIronGolemPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityIronGolemPet.java @@ -4,12 +4,12 @@ import simplepets.brainsynder.api.entity.passive.IEntityIronGolemPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; /** * NMS: {@link net.minecraft.world.entity.animal.IronGolem} */ -public class EntityIronGolemPet extends EntityPet implements IEntityIronGolemPet { +public class EntityIronGolemPet extends EntityPetOverride implements IEntityIronGolemPet { public EntityIronGolemPet(PetType type, PetUser user) { super(EntityType.IRON_GOLEM, type, user); } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityLlamaPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityLlamaPet.java index a81a1434..2b0e13ea 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityLlamaPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityLlamaPet.java @@ -14,12 +14,12 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.WoolCarpetBlock; import org.bukkit.NamespacedKey; -import org.bukkit.craftbukkit.v1_21_R1.util.CraftNamespacedKey; import simplepets.brainsynder.api.entity.passive.IEntityLlamaPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; import simplepets.brainsynder.api.wrappers.ColorWrapper; import simplepets.brainsynder.api.wrappers.LlamaColor; +import simplepets.brainsynder.nms.VersionTranslator; import simplepets.brainsynder.nms.entity.branch.EntityDonkeyAbstractPet; import simplepets.brainsynder.nms.utils.PetDataAccess; @@ -89,7 +89,7 @@ public void setColorWrapper(ColorWrapper color) { return; } DyeColor dyeColor = DyeColor.byId(color.getWoolData()); - Item item = BuiltInRegistries.ITEM.get(CraftNamespacedKey.toMinecraft(NamespacedKey.minecraft(dyeColor.getName()+"_carpet"))); + Item item = VersionTranslator.getRegistryValue(BuiltInRegistries.ITEM, NamespacedKey.minecraft(dyeColor.getName()+"_carpet")); setItemSlot(EquipmentSlot.BODY, new ItemStack(item)); } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityPandaPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityPandaPet.java index 624ba0d6..5551ba76 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityPandaPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityPandaPet.java @@ -8,7 +8,6 @@ import net.minecraft.sounds.SoundEvents; import net.minecraft.util.Mth; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.ai.targeting.TargetingConditions; import net.minecraft.world.phys.Vec3; import simplepets.brainsynder.api.entity.passive.IEntityPandaPet; import simplepets.brainsynder.api.pet.PetType; @@ -134,7 +133,7 @@ private void handleSneeze() { VersionTranslator.getEntityLevel(this).addParticle(ParticleTypes.SNEEZE, x, y, z, var0.x, 0.0D, var0.z); this.playSound(SoundEvents.PANDA_SNEEZE, 1.0F, 1.0F); - List nearby = VersionTranslator.getEntityLevel(this).getNearbyEntities(EntityPandaPet.class, TargetingConditions.forNonCombat(), this, this.getBoundingBox().inflate(10.0D)); + List nearby = VersionTranslator.getEntityLevel(this).getEntitiesOfClass(EntityPandaPet.class, this.getBoundingBox().inflate(10.0D)); nearby.forEach(panda -> { if (panda.onGround && !panda.isInWater() && panda.isSpookedBySneeze()) { panda.jumpFromGround(); diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityRabbitPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityRabbitPet.java index 84caf295..42d2bf78 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityRabbitPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityRabbitPet.java @@ -5,6 +5,7 @@ import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Mth; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.ai.navigation.PathNavigation; @@ -14,7 +15,6 @@ import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; import simplepets.brainsynder.api.wrappers.RabbitType; -import simplepets.brainsynder.nms.VersionTranslator; import simplepets.brainsynder.nms.entity.EntityAgeablePet; import simplepets.brainsynder.nms.entity.controller.ControllerJumpRabbit; import simplepets.brainsynder.nms.entity.controller.ControllerMoveRabbit; @@ -74,7 +74,7 @@ public void tick() { } @Override - public void customServerAiStep() { + protected void customServerAiStep(ServerLevel worldserver) { if (this.ticksUntilJump > 0) { --this.ticksUntilJump; } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityShulkerPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityShulkerPet.java index a1c4c36f..cf224983 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityShulkerPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityShulkerPet.java @@ -177,7 +177,7 @@ public void tick() { if ((this.pet == null) || (VersionTranslator.getBukkitEntity(pet).isDead()) || (!VersionTranslator.getBukkitEntity(pet).isValid())) { - kill(); + VersionTranslator.killEntity(this, (ServerLevel) level()); return; } @@ -382,9 +382,4 @@ protected boolean actuallyHurt(DamageSource damagesource, float f) { protected boolean actuallyHurt(DamageSource damageSource, float f, EntityDamageEvent event) { return false; } - - @Override - public boolean alwaysAccepts() { - return super.alwaysAccepts(); - } } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySilverfishPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySilverfishPet.java index 5e2d5041..e60c4bfc 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySilverfishPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySilverfishPet.java @@ -4,12 +4,12 @@ import simplepets.brainsynder.api.entity.hostile.IEntitySilverfishPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; /** * NMS: {@link net.minecraft.world.entity.monster.Silverfish} */ -public class EntitySilverfishPet extends EntityPet implements IEntitySilverfishPet { +public class EntitySilverfishPet extends EntityPetOverride implements IEntitySilverfishPet { public EntitySilverfishPet(PetType type, PetUser user) { super(EntityType.SILVERFISH, type, user); } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySkeletonPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySkeletonPet.java index ffdb4059..6078b4d5 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySkeletonPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySkeletonPet.java @@ -4,12 +4,12 @@ import simplepets.brainsynder.api.entity.hostile.IEntitySkeletonPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; /** * NMS: {@link net.minecraft.world.entity.monster.Skeleton} */ -public class EntitySkeletonPet extends EntityPet implements IEntitySkeletonPet { +public class EntitySkeletonPet extends EntityPetOverride implements IEntitySkeletonPet { public EntitySkeletonPet(PetType type, PetUser user) { super(EntityType.SKELETON, type, user); } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySlimePet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySlimePet.java index 9d53f47b..1c8e22c7 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySlimePet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySlimePet.java @@ -7,20 +7,19 @@ import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; -import net.minecraft.world.phys.Vec3; import simplepets.brainsynder.api.entity.hostile.IEntitySlimePet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.plugin.SimplePets; import simplepets.brainsynder.api.user.PetUser; import simplepets.brainsynder.nms.VersionTranslator; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; import simplepets.brainsynder.nms.entity.controller.ControllerSlime; import simplepets.brainsynder.nms.utils.PetDataAccess; /** * NMS: {@link net.minecraft.world.entity.monster.Slime} */ -public class EntitySlimePet extends EntityPet implements IEntitySlimePet { +public class EntitySlimePet extends EntityPetOverride implements IEntitySlimePet { private static final EntityDataAccessor SIZE = SynchedEntityData.defineId(EntitySlimePet.class, EntityDataSerializers.INT); public EntitySlimePet(PetType type, PetUser user) { diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySnowmanPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySnowmanPet.java index c4a2317e..a9f9ca7d 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySnowmanPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySnowmanPet.java @@ -8,13 +8,13 @@ import simplepets.brainsynder.api.entity.passive.IEntitySnowmanPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; import simplepets.brainsynder.nms.utils.PetDataAccess; /** * NMS: {@link net.minecraft.world.entity.animal.SnowGolem} */ -public class EntitySnowmanPet extends EntityPet implements IEntitySnowmanPet { +public class EntitySnowmanPet extends EntityPetOverride implements IEntitySnowmanPet { private static final EntityDataAccessor PUMPKIN = SynchedEntityData.defineId(EntitySnowmanPet.class, EntityDataSerializers.BYTE); public EntitySnowmanPet(PetType type, PetUser user) { diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySpiderPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySpiderPet.java index bc293c43..dcb9142d 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySpiderPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySpiderPet.java @@ -9,13 +9,13 @@ import simplepets.brainsynder.api.plugin.config.ConfigOption; import simplepets.brainsynder.api.user.PetUser; import simplepets.brainsynder.nms.VersionTranslator; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; import simplepets.brainsynder.nms.utils.PetDataAccess; /** * NMS: {@link net.minecraft.world.entity.monster.Spider} */ -public class EntitySpiderPet extends EntityPet implements IEntitySpiderPet { +public class EntitySpiderPet extends EntityPetOverride implements IEntitySpiderPet { private static final EntityDataAccessor WALL_CLIMB_FLAG = SynchedEntityData.defineId(EntitySpiderPet.class, EntityDataSerializers.BYTE); private final boolean wallClimbing; diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySquidPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySquidPet.java index c363d4a3..0b3ad165 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySquidPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntitySquidPet.java @@ -5,12 +5,12 @@ import simplepets.brainsynder.api.entity.passive.IEntitySquidPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; /** * NMS: {@link net.minecraft.world.entity.animal.Squid} */ -public class EntitySquidPet extends EntityPet implements IEntitySquidPet { +public class EntitySquidPet extends EntityPetOverride implements IEntitySquidPet { public EntitySquidPet (EntityType entitytypes, PetType type, PetUser user) { super(entitytypes, type, user); } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityStrayPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityStrayPet.java index 33efe3e0..b3e1512c 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityStrayPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityStrayPet.java @@ -4,12 +4,12 @@ import simplepets.brainsynder.api.entity.hostile.IEntityStrayPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; /** * NMS: {@link net.minecraft.world.entity.monster.Stray} */ -public class EntityStrayPet extends EntityPet implements IEntityStrayPet { +public class EntityStrayPet extends EntityPetOverride implements IEntityStrayPet { public EntityStrayPet(PetType type, PetUser user) { super(EntityType.STRAY, type, user); } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWanderingTraderPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWanderingTraderPet.java index 73ca0b71..0d6820b7 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWanderingTraderPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWanderingTraderPet.java @@ -4,12 +4,12 @@ import simplepets.brainsynder.api.entity.passive.IEntityWanderingTraderPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; /** * NMS: {@link net.minecraft.world.entity.npc.WanderingTrader} */ -public class EntityWanderingTraderPet extends EntityPet implements IEntityWanderingTraderPet { +public class EntityWanderingTraderPet extends EntityPetOverride implements IEntityWanderingTraderPet { public EntityWanderingTraderPet(PetType type, PetUser user) { super(EntityType.WANDERING_TRADER, type, user); } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWardenPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWardenPet.java index b8d2485b..b4444efb 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWardenPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWardenPet.java @@ -20,7 +20,7 @@ import simplepets.brainsynder.api.user.PetUser; import simplepets.brainsynder.api.wrappers.AngerLevel; import simplepets.brainsynder.nms.VersionTranslator; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; import simplepets.brainsynder.nms.utils.PetDataAccess; import java.util.concurrent.TimeUnit; @@ -29,7 +29,7 @@ * NMS: {@link net.minecraft.world.entity.monster.warden.Warden} */ @SupportedVersion(version = ServerVersion.v1_19) -public class EntityWardenPet extends EntityPet implements IEntityWardenPet { +public class EntityWardenPet extends EntityPetOverride implements IEntityWardenPet { protected static final EntityDataAccessor ANGER_LEVEL = SynchedEntityData.defineId(EntityWardenPet.class, EntityDataSerializers.INT); private boolean vibrationEffect = false; private int vibrationTick = 0; diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWitherPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWitherPet.java index 545dfd5d..945b98d7 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWitherPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWitherPet.java @@ -8,13 +8,13 @@ import simplepets.brainsynder.api.entity.hostile.IEntityWitherPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; import simplepets.brainsynder.nms.utils.PetDataAccess; /** * NMS: {@link net.minecraft.world.entity.boss.wither.WitherBoss} */ -public class EntityWitherPet extends EntityPet implements IEntityWitherPet { +public class EntityWitherPet extends EntityPetOverride implements IEntityWitherPet { private static final EntityDataAccessor FIRST_HEAD_TARGET = SynchedEntityData.defineId(EntityWitherPet.class, EntityDataSerializers.INT); private static final EntityDataAccessor SECOND_HEAD_TARGET = SynchedEntityData.defineId(EntityWitherPet.class, EntityDataSerializers.INT); private static final EntityDataAccessor THIRD_HEAD_TARGET = SynchedEntityData.defineId(EntityWitherPet.class, EntityDataSerializers.INT); diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWitherSkeletonPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWitherSkeletonPet.java index ddd471ad..566865bc 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWitherSkeletonPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWitherSkeletonPet.java @@ -4,12 +4,12 @@ import simplepets.brainsynder.api.entity.hostile.IEntityWitherSkeletonPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; /** * NMS: {@link net.minecraft.world.entity.monster.WitherSkeleton} */ -public class EntityWitherSkeletonPet extends EntityPet implements IEntityWitherSkeletonPet { +public class EntityWitherSkeletonPet extends EntityPetOverride implements IEntityWitherSkeletonPet { public EntityWitherSkeletonPet(PetType type, PetUser user) { super(EntityType.WITHER_SKELETON, type, user); } diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWolfPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWolfPet.java index 5c9fa084..3d34e693 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWolfPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityWolfPet.java @@ -10,9 +10,9 @@ import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.animal.WolfVariant; -import net.minecraft.world.entity.animal.WolfVariants; -import org.bukkit.craftbukkit.v1_21_R1.CraftRegistry; -import org.bukkit.craftbukkit.v1_21_R1.util.CraftNamespacedKey; +import org.bukkit.craftbukkit.v1_21_R2.CraftRegistry; +import org.bukkit.craftbukkit.v1_21_R2.util.CraftNamespacedKey; +import org.bukkit.entity.Wolf; import simplepets.brainsynder.api.entity.passive.IEntityWolfPet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; @@ -42,7 +42,7 @@ public EntityWolfPet(PetType type, PetUser user) { @Override public void populateDataAccess(PetDataAccess dataAccess) { super.populateDataAccess(dataAccess); - dataAccess.define(DATA_VARIANT_ID, registryAccess().registryOrThrow(Registries.WOLF_VARIANT).getHolderOrThrow(WolfVariants.PALE)); + dataAccess.define(DATA_VARIANT_ID, VersionTranslator.getRegistryValue(CraftRegistry.getMinecraftRegistry(Registries.WOLF_VARIANT), Wolf.Variant.PALE.getKey())); dataAccess.define(BEGGING, false); dataAccess.define(COLLAR_COLOR, DyeColorWrapper.WHITE.getWoolData()); dataAccess.define(ANGER_TIME, 0); diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityZombiePet.java b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityZombiePet.java index 3ba38f1e..f0bc85f0 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityZombiePet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/list/EntityZombiePet.java @@ -9,13 +9,13 @@ import simplepets.brainsynder.api.entity.hostile.IEntityZombiePet; import simplepets.brainsynder.api.pet.PetType; import simplepets.brainsynder.api.user.PetUser; -import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.entity.EntityPetOverride; import simplepets.brainsynder.nms.utils.PetDataAccess; /** * NMS: {@link net.minecraft.world.entity.monster.Zombie} */ -public class EntityZombiePet extends EntityPet implements IEntityZombiePet { +public class EntityZombiePet extends EntityPetOverride implements IEntityZombiePet { private static final EntityDataAccessor BABY = SynchedEntityData.defineId(EntityZombiePet.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor UNKNOWN = SynchedEntityData.defineId(EntityZombiePet.class, EntityDataSerializers.INT); private static final EntityDataAccessor DROWN_CONVERTING = SynchedEntityData.defineId(EntityZombiePet.class, EntityDataSerializers.BOOLEAN); diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/special/EntityControllerPet.java b/nms/master/src/simplepets/brainsynder/nms/entity/special/EntityControllerPet.java index 084d7192..f7a32aff 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/special/EntityControllerPet.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/special/EntityControllerPet.java @@ -3,6 +3,7 @@ import lib.brainsynder.nbt.StorageTagCompound; import lib.brainsynder.sounds.SoundMaker; import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -103,7 +104,7 @@ public void tick() { || (this.displayEntity.isDead()) || (!this.displayEntity.isValid())) { displayEntity = null; - kill(); + VersionTranslator.killEntity(this, (ServerLevel) level()); return; } @@ -116,7 +117,7 @@ public void tick() { } }else{ displayEntity = null; - kill(); + VersionTranslator.killEntity(this, (ServerLevel) level()); return; } }else if (this.displayEntity != null) { @@ -132,7 +133,7 @@ public void tick() { } }else{ displayEntity = null; - kill(); + VersionTranslator.killEntity(this, (ServerLevel) level()); return; } } @@ -219,7 +220,7 @@ public void reloadLocation() { displayEntity.moveTo(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> { if (entity instanceof Player player) { - ClientboundTeleportEntityPacket packet = new ClientboundTeleportEntityPacket(displayEntity); + ClientboundTeleportEntityPacket packet = VersionTranslator.getTeleportPacket(displayEntity); VersionTranslator.getEntityHandle(player).connection.send(packet); } }); @@ -242,7 +243,7 @@ public void reloadLocation() { displayEntity.moveTo(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> { if (entity instanceof Player player) { - ClientboundTeleportEntityPacket packet = new ClientboundTeleportEntityPacket(displayEntity); + ClientboundTeleportEntityPacket packet = VersionTranslator.getTeleportPacket(displayEntity); VersionTranslator.getEntityHandle(player).connection.send(packet); } }); diff --git a/nms/master/src/simplepets/brainsynder/nms/entity/special/EntityGhostStand.java b/nms/master/src/simplepets/brainsynder/nms/entity/special/EntityGhostStand.java index f467df2d..51292cfd 100644 --- a/nms/master/src/simplepets/brainsynder/nms/entity/special/EntityGhostStand.java +++ b/nms/master/src/simplepets/brainsynder/nms/entity/special/EntityGhostStand.java @@ -7,6 +7,7 @@ import lib.brainsynder.reflection.Reflection; import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; @@ -25,7 +26,7 @@ public class EntityGhostStand extends ArmorStand { public EntityGhostStand(EntityType entitytypes, Level world) { super(entitytypes, world); - kill(); + VersionTranslator.killEntity(this, (ServerLevel) world); } public EntityGhostStand(EntityType entitytypes, Level world, EntityControllerPet controllerPet) { @@ -57,7 +58,7 @@ public void tick() { || (this.controllerPet.getEntity().isDead()) || (!this.controllerPet.getEntity().isValid())) { controllerPet = null; - kill(); + VersionTranslator.killEntity(this, (ServerLevel) level()); return; } diff --git a/nms/version-1.20.1/pom.xml b/nms/version-1.20.1/pom.xml index a6aeb623..85eb4c22 100644 --- a/nms/version-1.20.1/pom.xml +++ b/nms/version-1.20.1/pom.xml @@ -102,5 +102,11 @@ ${revision} compile + + + anvil.brainsynder + anvilgui + ${anvilgui.version} + \ No newline at end of file diff --git a/nms/version-1.20.2/pom.xml b/nms/version-1.20.2/pom.xml index 2f14b192..5cd32dc3 100644 --- a/nms/version-1.20.2/pom.xml +++ b/nms/version-1.20.2/pom.xml @@ -102,5 +102,11 @@ ${revision} compile + + + anvil.brainsynder + anvilgui + ${anvilgui.version} + \ No newline at end of file diff --git a/nms/version-1.20.3/pom.xml b/nms/version-1.20.3/pom.xml index 2769a16f..f5c2612c 100644 --- a/nms/version-1.20.3/pom.xml +++ b/nms/version-1.20.3/pom.xml @@ -102,5 +102,11 @@ ${revision} compile + + + anvil.brainsynder + anvilgui + ${anvilgui.version} + \ No newline at end of file diff --git a/nms/version-1.20.4/pom.xml b/nms/version-1.20.4/pom.xml index 984a1b7a..732280a0 100644 --- a/nms/version-1.20.4/pom.xml +++ b/nms/version-1.20.4/pom.xml @@ -116,5 +116,11 @@ NMS_Master ${revision} + + + anvil.brainsynder + anvilgui + ${anvilgui.version} + \ No newline at end of file diff --git a/nms/version-1.20.5/pom.xml b/nms/version-1.20.5/pom.xml index f4dea645..fe84ff52 100644 --- a/nms/version-1.20.5/pom.xml +++ b/nms/version-1.20.5/pom.xml @@ -105,5 +105,11 @@ ${revision} compile + + + anvil.brainsynder + anvilgui + ${anvilgui.version} + \ No newline at end of file diff --git a/nms/version-1.20.6/pom.xml b/nms/version-1.20.6/pom.xml index 7a29a5a2..c24f10ea 100644 --- a/nms/version-1.20.6/pom.xml +++ b/nms/version-1.20.6/pom.xml @@ -105,5 +105,11 @@ ${revision} compile + + + anvil.brainsynder + anvilgui + ${anvilgui.version} + \ No newline at end of file diff --git a/nms/version-1.20/pom.xml b/nms/version-1.20/pom.xml index 42d1b994..c14cf616 100644 --- a/nms/version-1.20/pom.xml +++ b/nms/version-1.20/pom.xml @@ -102,5 +102,11 @@ ${revision} compile + + + anvil.brainsynder + anvilgui + ${anvilgui.version} + \ No newline at end of file diff --git a/nms/version-1.21.1/pom.xml b/nms/version-1.21.1/pom.xml index e56b2645..69e714aa 100644 --- a/nms/version-1.21.1/pom.xml +++ b/nms/version-1.21.1/pom.xml @@ -46,7 +46,8 @@ org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang true - org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang + org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang + true remapped-obf @@ -58,9 +59,12 @@ remap-spigot - ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + + ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot - org.spigotmc:spigot:${spigot.version}:jar:remapped-obf + org.spigotmc:spigot:${spigot.version}:jar:remapped-obf + @@ -105,5 +109,11 @@ ${revision} compile + + + anvil.brainsynder + anvilgui + ${anvilgui.version} + \ No newline at end of file diff --git a/nms/version-1.21.1/src/simplepets/brainsynder/nms/VersionTranslator.java b/nms/version-1.21.1/src/simplepets/brainsynder/nms/VersionTranslator.java index e3dae3a7..48818f0d 100644 --- a/nms/version-1.21.1/src/simplepets/brainsynder/nms/VersionTranslator.java +++ b/nms/version-1.21.1/src/simplepets/brainsynder/nms/VersionTranslator.java @@ -12,6 +12,7 @@ import lib.brainsynder.storage.RandomCollection; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.Registry; import net.minecraft.core.Vec3i; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; @@ -19,11 +20,13 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; +import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket; import net.minecraft.network.syncher.EntityDataSerializer; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerEntity; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeMap; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; @@ -290,4 +293,17 @@ public static Level getEntityLevel(Entity entity) { public static boolean isWalkable (EntityPet entity, BlockPos.MutableBlockPos blockposition) { return WalkNodeEvaluator.getPathTypeStatic(entity, blockposition) == PathType.WALKABLE; } + + // ADDED DURING 1.21.3 DEVELOPMENT + public static T getRegistryValue (Registry registry, NamespacedKey key) { + return registry.get(CraftNamespacedKey.toMinecraft(key)); + } + + public static void killEntity (Entity entity, ServerLevel level) { + entity.kill(); + } + + public static ClientboundTeleportEntityPacket getTeleportPacket (Entity entity) { + return new ClientboundTeleportEntityPacket(entity); + } } \ No newline at end of file diff --git a/nms/version-1.21.1/src/simplepets/brainsynder/nms/entity/EntityPetOverride.java b/nms/version-1.21.1/src/simplepets/brainsynder/nms/entity/EntityPetOverride.java new file mode 100644 index 00000000..415c4546 --- /dev/null +++ b/nms/version-1.21.1/src/simplepets/brainsynder/nms/entity/EntityPetOverride.java @@ -0,0 +1,94 @@ +package simplepets.brainsynder.nms.entity; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.phys.Vec3; +import org.bukkit.Bukkit; +import simplepets.brainsynder.api.event.entity.PetMoveEvent; +import simplepets.brainsynder.api.event.entity.movment.PetJumpEvent; +import simplepets.brainsynder.api.event.entity.movment.PetRideEvent; +import simplepets.brainsynder.api.pet.PetType; +import simplepets.brainsynder.api.plugin.SimplePets; +import simplepets.brainsynder.api.user.PetUser; +import simplepets.brainsynder.nms.VersionTranslator; + +import java.lang.reflect.Field; + +public class EntityPetOverride extends EntityPet { + public EntityPetOverride(EntityType entitytypes, PetType type, PetUser user) { + super(entitytypes, type, user); + } + + @Override + public void travel(Vec3 vec3d) { + if ((getPetType() == null) || (getUser() == null)) return; + + if ((passengers == null) + || (!isOwnerRiding())) { + super.travel(vec3d); + return; + } + + ServerPlayer passenger = VersionTranslator.getEntityHandle(getUser().getPlayer()); + + if (doIndirectAttach) { + if (getFirstPassenger() instanceof SeatEntity seat) { + // orient the seat entity correctly. Seems to fix the issue + // where ridden horses are not oriented properly + seat.setYRot(passenger.getYRot()); + seat.yRotO = this.getYRot(); + seat.setXRot(passenger.getXRot() * 0.5F); + seat.setRot(this.getYRot(), this.getXRot()); + seat.yHeadRot = this.yBodyRot = this.getYRot(); + } + } + + this.setYRot(passenger.getYRot()); + this.yRotO = this.getYRot(); + this.setXRot(passenger.getXRot() * 0.5F); + this.setRot(this.getYRot(), this.getXRot()); + this.yHeadRot = this.yBodyRot = this.getYRot(); + + double strafe = passenger.xxa * 0.5; + double vertical = vec3d.y; + double forward = passenger.zza; + if (forward <= 0) { + forward *= 0.25F; + } + + PetMoveEvent moveEvent = new PetRideEvent(this); + Bukkit.getServer().getPluginManager().callEvent(moveEvent); + if (moveEvent.isCancelled()) return; + + double speed = VersionTranslator.getWalkSpeed(this); + + Field jumpField = VersionTranslator.getJumpField(); + if ((jumpField != null) && (!passengers.isEmpty())) { + SimplePets.getPetConfigManager().getPetConfig(getPetType()).ifPresent(config -> { + try { + boolean flight = false; + double height = getJumpHeight(); + + if (config.canFly(getUser().getPlayer())) { + flight = true; + height = 0.3; + } + + PetJumpEvent jumpEvent = new PetJumpEvent(this, height); + Bukkit.getServer().getPluginManager().callEvent(jumpEvent); + if ((!jumpEvent.isCancelled()) && jumpField.getBoolean(passenger)) { + if (flight || this.onGround) { + setDeltaMovement(getDeltaMovement().x, jumpEvent.getJumpHeight(), getDeltaMovement().z); + this.hasImpulse = true; + } + } + } catch (IllegalArgumentException | IllegalStateException | IllegalAccessException ignored) { + } + }); + } + + this.setSpeed((float) speed); + super.travel(new Vec3(strafe, vertical, forward)); + } +} diff --git a/nms/version-1.21.1/src/simplepets/brainsynder/nms/entity/list/EntityRabbitPet.java b/nms/version-1.21.1/src/simplepets/brainsynder/nms/entity/list/EntityRabbitPet.java new file mode 100644 index 00000000..60b4a581 --- /dev/null +++ b/nms/version-1.21.1/src/simplepets/brainsynder/nms/entity/list/EntityRabbitPet.java @@ -0,0 +1,162 @@ +package simplepets.brainsynder.nms.entity.list; + +import lib.brainsynder.nbt.StorageTagCompound; +import lib.brainsynder.reflection.Reflection; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.ai.navigation.PathNavigation; +import net.minecraft.world.level.pathfinder.Path; +import net.minecraft.world.phys.Vec3; +import simplepets.brainsynder.api.entity.passive.IEntityRabbitPet; +import simplepets.brainsynder.api.pet.PetType; +import simplepets.brainsynder.api.user.PetUser; +import simplepets.brainsynder.api.wrappers.RabbitType; +import simplepets.brainsynder.nms.entity.EntityAgeablePet; +import simplepets.brainsynder.nms.entity.controller.ControllerJumpRabbit; +import simplepets.brainsynder.nms.entity.controller.ControllerMoveRabbit; +import simplepets.brainsynder.nms.utils.PetDataAccess; + +import java.lang.reflect.InvocationTargetException; + +/** + * NMS: {@link net.minecraft.world.entity.animal.Rabbit} + */ +public class EntityRabbitPet extends EntityAgeablePet implements IEntityRabbitPet { + private static final EntityDataAccessor RABBIT_TYPE = SynchedEntityData.defineId(EntityRabbitPet.class, EntityDataSerializers.INT); + private int jumpTicks; + private int jumpDuration; + private boolean onGroundLastTick = false; + private int ticksUntilJump = 0; + + public EntityRabbitPet(PetType type, PetUser user) { + super(EntityType.RABBIT, type, user); + jumpControl = new ControllerJumpRabbit(this); + moveControl = new ControllerMoveRabbit(this); + } + + @Override + public void populateDataAccess(PetDataAccess dataAccess) { + super.populateDataAccess(dataAccess); + dataAccess.define(RABBIT_TYPE, 0); + } + + @Override + public void applyCompound(StorageTagCompound object) { + if (object.hasKey("variant")) setRabbitType(object.getEnum("variant", RabbitType.class, RabbitType.BROWN)); + super.applyCompound(object); + } + + @Override + public StorageTagCompound asCompound() { + StorageTagCompound object = super.asCompound(); + object.setEnum("variant", getRabbitType()); + return object; + } + + @Override + public RabbitType getRabbitType() { + return RabbitType.getByID(this.entityData.get(RABBIT_TYPE)); + } + + @Override + public void setRabbitType(RabbitType type) { + this.entityData.set(RABBIT_TYPE, type.getId()); + } + + @Override + public void tick() { + super.tick(); + this.onGroundLastTick = this.onGround; + } + + @Override + public void customServerAiStep() { + if (this.ticksUntilJump > 0) { + --this.ticksUntilJump; + } + + if (this.onGround) { + if (!this.onGroundLastTick) { + this.setJumping(false); + scheduleJump(); + } + + ControllerJumpRabbit controller = (ControllerJumpRabbit)this.getJumpControl(); + if (!controller.wantJump()) { + if (this.moveControl.hasWanted() && this.ticksUntilJump == 0) { + Path pathentity = getPath(); // Translation: navigation.getCurrentPath() + + // Translation: getTargetX, getTargetY, getTargetZ + Vec3 vec3d = new Vec3(this.moveControl.getWantedX(), this.moveControl.getWantedY(), this.moveControl.getWantedZ()); + if (pathentity != null && !pathentity.isDone()) { + vec3d = pathentity.getNextEntityPos(this); // Translation: getNodePosition () + } + + this.lookTowards(vec3d.x, vec3d.z); + this.reseter(); + } + } else if (!controller.canJump()) { + ((ControllerJumpRabbit) jumpControl).setCanJump(true); + } + } + + this.onGroundLastTick = this.onGround; + } + + private void scheduleJump() { + this.doScheduleJump(); + ((ControllerJumpRabbit)jumpControl).setCanJump(false); + } + + private void doScheduleJump() { + if (this.moveControl.getSpeedModifier() < 2.2D) { + this.ticksUntilJump = 10; + } else { + this.ticksUntilJump = 1; + } + ((ControllerJumpRabbit)this.jumpControl).setCanJump(false); + } + + private void lookTowards(double d0, double d1) { + setYRot((float)(Mth.atan2(d1 - getZ(), d0 - getX()) * 57.2957763671875D) - 90.0F); + } + + @Override + public void aiStep() { + super.aiStep(); + if (jumpTicks != jumpDuration) { + ++this.jumpTicks; + } else if (jumpDuration != 0) { + jumpTicks = 0; + jumpDuration = 0; + setJumping(false); + } + } + + public void setSpeedModifier(double d0) { + getNavigation().setSpeedModifier(d0); + this.moveControl.setWantedPosition(this.moveControl.getWantedX(), this.moveControl.getWantedY(), this.moveControl.getWantedZ(), d0); + } + + private Path getPath() { + try { + return navigation.getPath(); + } catch (NoSuchMethodError ex) { + try { + return (Path) Reflection.getMethod(PathNavigation.class, "getPath").invoke(navigation); + } catch (IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + return null; + } + + public void reseter() { + this.setJumping(true); + this.jumpDuration = 10; + this.jumpTicks = 0; + } +} diff --git a/nms/version-1.21.3/pom.xml b/nms/version-1.21.3/pom.xml new file mode 100644 index 00000000..e99071b2 --- /dev/null +++ b/nms/version-1.21.3/pom.xml @@ -0,0 +1,119 @@ + + + 4.0.0 + + + simplepets.brainsynder + SimplePets + 1 + ../../ + + + Version_1.21.3 + ${revision} + + + 21 + + 1.21.3 + v1_21_3 + v1_21_R2 + + ${minecraft.version}-R0.1-SNAPSHOT + -${minecraft.version} + + + + src/ + + + org.apache.maven.plugins + maven-shade-plugin + + + net.md-5 + specialsource-maven-plugin + ${specialsource.version} + + + package + + remap + + remap-obf + + org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang + true + org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang + + true + remapped-obf + + + + package + + remap + + remap-spigot + + + ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + + org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot + org.spigotmc:spigot:${spigot.version}:jar:remapped-obf + + + + + + + + + + + org.spigotmc + spigot + ${spigot.version} + remapped-mojang + provided + + + + simplepets.brainsynder + API + ${revision} + compile + + + simplepets.brainsynder + MAIN + ${revision} + compile + + + anvil.brainsynder + anvilgui + + + com.jeff_media + SpigotUpdateChecker + + + + + simplepets.brainsynder + NMS_Master + ${revision} + compile + + + + anvil.brainsynder + anvilgui + ${anvilgui.version} + + + \ No newline at end of file diff --git a/nms/version-1.21.3/src/simplepets/brainsynder/nms/VersionTranslator.java b/nms/version-1.21.3/src/simplepets/brainsynder/nms/VersionTranslator.java new file mode 100644 index 00000000..5c935411 --- /dev/null +++ b/nms/version-1.21.3/src/simplepets/brainsynder/nms/VersionTranslator.java @@ -0,0 +1,310 @@ +package simplepets.brainsynder.nms; + +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import lib.brainsynder.ServerVersion; +import lib.brainsynder.internal.nbtapi.nbtapi.NBTContainer; +import lib.brainsynder.internal.nbtapi.nbtapi.NBTReflectionUtil; +import lib.brainsynder.nbt.JsonToNBT; +import lib.brainsynder.nbt.StorageTagCompound; +import lib.brainsynder.nbt.other.NBTException; +import lib.brainsynder.reflection.FieldAccessor; +import lib.brainsynder.storage.RandomCollection; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Registry; +import net.minecraft.core.Vec3i; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.TagParser; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.game.ClientGamePacketListener; +import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; +import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket; +import net.minecraft.network.syncher.EntityDataSerializer; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerEntity; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.*; +import net.minecraft.world.entity.ai.attributes.AttributeMap; +import net.minecraft.world.entity.ai.attributes.AttributeSupplier; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.decoration.ArmorStand; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.pathfinder.PathType; +import net.minecraft.world.level.pathfinder.WalkNodeEvaluator; +import net.minecraft.world.phys.Vec3; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.World; +import org.bukkit.block.data.BlockData; +import org.bukkit.craftbukkit.v1_21_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R2.block.data.CraftBlockData; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_21_R2.util.CraftNamespacedKey; +import org.bukkit.event.entity.CreatureSpawnEvent; +import simplepets.brainsynder.api.entity.misc.IFlyableEntity; +import simplepets.brainsynder.nms.entity.EntityPet; +import simplepets.brainsynder.nms.utils.FieldUtils; +import simplepets.brainsynder.nms.utils.InvalidInputException; +import simplepets.brainsynder.utils.VersionFields; + +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.Optional; + +public class VersionTranslator { + private static final FieldAccessor accessor; + private static Field jumpingField = null; + + static { + accessor = FieldAccessor.getField(LivingEntity.class, VersionFields.v1_21_3.getAttributesField(), AttributeMap.class); + + try { + Field jumpingField = LivingEntity.class.getDeclaredField(VersionFields.v1_21_3.getEntityJumpField()); + jumpingField.setAccessible(true); + VersionTranslator.jumpingField = jumpingField; + } catch (Exception ex) { + throw new UnsupportedOperationException("Unable to find the correct jumpingField name for " + ServerVersion.getVersion().name()); + } + } + + public static Field getJumpField() { + return jumpingField; + } + + public static void overrideAttributeMap (EntityPet entityPet) { + accessor.set(entityPet, new AttributeMap(createAttributes(entityPet).build())); + } + + private static AttributeSupplier.Builder createAttributes (EntityPet entityPet) { + AttributeSupplier.Builder builder = Mob.createMobAttributes(); + if (entityPet instanceof IFlyableEntity) builder.add(Attributes.FLYING_SPEED, 1); + builder.add(Attributes.SCALE, 1); + builder.add(Attributes.STEP_HEIGHT, 1); + return builder.add(Attributes.MOVEMENT_SPEED, 1); + } + + public static org.bukkit.entity.Entity getBukkitEntity(Entity entity) { + org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity craftEntity = entity.getBukkitEntity(); + return craftEntity; + } + + public static void setAttributes(EntityPet entityPet, double walkSpeed, double flySpeed) { + if (walkSpeed != -1) entityPet.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(walkSpeed); + if ((flySpeed != -1) && (entityPet instanceof IFlyableEntity) && entityPet.getAttribute(Attributes.FLYING_SPEED) != null) { + entityPet.getAttribute(Attributes.FLYING_SPEED).setBaseValue(flySpeed); + } + } + + public static void setFollowAttributes (EntityPet entityPet, double value) { + entityPet.getAttribute(Attributes.FOLLOW_RANGE).setBaseValue(value); + } + + public static void setScaleSize (EntityPet entityPet, double value) { + entityPet.getAttribute(Attributes.SCALE).setBaseValue(value); + } + + public static double getWalkSpeed (EntityPet entityPet) { + return entityPet.getAttribute(Attributes.MOVEMENT_SPEED).getValue(); + } + + public static double getFlySpeed (EntityPet entityPet) { + return entityPet.getAttribute(Attributes.FLYING_SPEED).getValue(); + } + + public static double getScaleSize (EntityPet entityPet) { + return entityPet.getAttribute(Attributes.SCALE).getValue(); + } + + public static void setItemSlot(ArmorStand stand, EquipmentSlot enumitemslot, ItemStack itemstack, boolean silent) { + stand.setItemSlot(enumitemslot, itemstack, silent); + } + + // TODO: This is throwing a 'NoSuchElementException: No value present' at CraftEntityType.minecraftToBukkit + public static boolean addEntity(Level level, Entity entity, CreatureSpawnEvent.SpawnReason reason) { + return level.addFreshEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM); + } + + public static T getEntityHandle(org.bukkit.entity.Entity entity) { + return (T) ((CraftEntity) entity).getHandle(); + } + + public static T getWorldHandle(World world) { + return (T) ((CraftWorld) world).getHandle(); + } + + public static BlockState getBlockState(BlockData blockData) { + return ((CraftBlockData) blockData).getState(); + } + + public static BlockData fromNMS(BlockState blockData) { + return CraftBlockData.fromData(blockData); + } + + public static ItemStack toNMSStack(org.bukkit.inventory.ItemStack itemStack) { + return CraftItemStack.asNMSCopy(itemStack); + } + + public static org.bukkit.inventory.ItemStack toBukkit(ItemStack itemStack) { + return CraftItemStack.asBukkitCopy(itemStack); + } + + public static BlockPos subtract(BlockPos blockPos, Vec3i vec) { + return blockPos.subtract(vec); + } + + public static BlockPos relative(BlockPos blockPos) { + return blockPos.relative(RandomCollection.fromCollection(Arrays.asList( + Direction.NORTH, + Direction.EAST, + Direction.SOUTH, + Direction.WEST + )).next()); + } + + public static void modifyGlowData(SynchedEntityData toCloneDataWatcher, SynchedEntityData newDataWatcher, + boolean glow) throws IllegalAccessException { + Int2ObjectMap> newMap = + (Int2ObjectMap>) FieldUtils.readDeclaredField(toCloneDataWatcher, + VersionFields.v1_21_3.getEntityDataMapField(), true); + + SynchedEntityData.DataItem item = newMap.get(0); + byte initialBitMask = item.getValue(); + byte bitMaskIndex = (byte) 6; + if (glow) { + item.setValue((byte) (initialBitMask | 1 << bitMaskIndex)); + } else { + item.setValue((byte) (initialBitMask & ~(1 << bitMaskIndex))); + } + FieldUtils.writeDeclaredField(newDataWatcher, VersionFields.v1_21_3.getEntityDataMapField(), newMap, true); + } + + public static org.bukkit.inventory.ItemStack toItemStack(StorageTagCompound compound) { + if (!compound.hasKey("id")) { // The ID MUST be set, otherwise it will be considered invalid and AIR + return new org.bukkit.inventory.ItemStack(Material.AIR); + } else { + // Item has to be AT LEAST 1 otherwise it will be AIR + if (!compound.hasKey("Count")) compound.setByte("Count", (byte) 1); + + try { + CompoundTag compoundTag = TagParser.parseTag(compound.toString()); + ItemStack nmsItem = (ItemStack) NBTReflectionUtil.convertNBTCompoundtoNMSItem(new NBTContainer(compoundTag)); + return CraftItemStack.asBukkitCopy(nmsItem); + } catch (CommandSyntaxException e) { + throw new InvalidInputException("Failed to parse Item NBT", e); + } + } + } + + public static StorageTagCompound fromItemStack(org.bukkit.inventory.ItemStack item) { + CompoundTag compoundTag = new CompoundTag(); + ItemStack nmsItem = CraftItemStack.asNMSCopy(item); + compoundTag = (CompoundTag) NBTReflectionUtil.convertNMSItemtoNBTCompound(nmsItem).getCompound(); + // compoundTag = nmsItem.save(((CraftServer) Bukkit.getServer()).getServer().registryAccess(), compoundTag); + + try { + return JsonToNBT.getTagFromJson(compoundTag.toString()); + } catch (NBTException exception) { + throw new InvalidInputException("Failed to convert item to NBT", exception); + } + } + + public static float cube(float f) { + return f * f * f; + } + + public static EntityType fetchEntityType(String name) { + // The EntityType.byString() method requires the name to start with `minecraft:` and the name of the mob to + // be lowercase + Optional> optional = EntityType.byString("minecraft:" + name.toLowerCase()); + if (optional.isPresent()) return optional.get(); + + // This is a simple placeholder mob that does not have any datawatchers just in case the code fails + return EntityType.GIANT; + } + + public static Packet getAddEntityPacket(LivingEntity livingEntity, ServerEntity serverEntity, EntityType originalEntityType, BlockPos pos) { + Packet packet; + try { + // y'all here sum'n? + packet = new ClientboundAddEntityPacket(livingEntity, serverEntity); + } catch (Exception ex) { + ex.printStackTrace(); + return new ClientboundAddEntityPacket(livingEntity, 0, pos); + } + + try { + Field type = packet.getClass().getDeclaredField(VersionTranslator.getEntityTypeVariable()); + type.setAccessible(true); + type.set(packet, VersionTranslator.useInteger() ? BuiltInRegistries.ENTITY_TYPE.getId(originalEntityType) : originalEntityType); + return packet; + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + return new ClientboundAddEntityPacket(livingEntity, 0, pos); + } + + // net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity + // private final net.minecraft.world.entity.EntityTypes + public static String getEntityTypeVariable() { + return "f"; + } + + public static boolean useInteger() { + return false; + } + + + // ADDED DURING 1.20.1 DEVELOPMENT + public static final EntityDataSerializer> OPTIONAL_BLOCK_STATE = EntityDataSerializers.OPTIONAL_BLOCK_STATE; + + public static void calculateEntityAnimation(LivingEntity entity, boolean var) { + entity.calculateEntityAnimation(var); + } + + public static void setMapUpStep(Entity entity, float value) { + // Was this even needed? + // entity.setMaxUpStep(value); + } + + public static BlockPos getPosition(Entity entity) { + return BlockPos.containing(new Vec3(entity.getX(), entity.getY(), entity.getZ())); + } + + public static ResourceLocation toMinecraftResource(NamespacedKey key) { + return CraftNamespacedKey.toMinecraft(key); + } + + public static NamespacedKey toBukkitNamespace(ResourceLocation resource) { + return CraftNamespacedKey.fromMinecraft(resource); + } + + // ADDED DURING 1.20.1 DEVELOPMENT + public static Level getEntityLevel(Entity entity) { + return entity.level(); + } + + // ADDED DURING 1.20.5 DEVELOPMENT + public static boolean isWalkable (EntityPet entity, BlockPos.MutableBlockPos blockposition) { + return WalkNodeEvaluator.getPathTypeStatic(entity, blockposition) == PathType.WALKABLE; + } + + // ADDED DURING 1.21.3 DEVELOPMENT + public static T getRegistryValue (Registry registry, NamespacedKey key) { + return registry.getValue(CraftNamespacedKey.toMinecraft(key)); + } + + public static void killEntity (Entity entity, ServerLevel level) { + entity.kill(level); + } + + public static ClientboundTeleportEntityPacket getTeleportPacket (Entity entity) { + return new ClientboundTeleportEntityPacket(entity.getId(), PositionMoveRotation.of(entity), Relative.ALL, entity.onGround); + } +} \ No newline at end of file diff --git a/nms/version-1.21.3/src/simplepets/brainsynder/nms/entity/EntityBase.java b/nms/version-1.21.3/src/simplepets/brainsynder/nms/entity/EntityBase.java new file mode 100644 index 00000000..e7f13b2d --- /dev/null +++ b/nms/version-1.21.3/src/simplepets/brainsynder/nms/entity/EntityBase.java @@ -0,0 +1,173 @@ +package simplepets.brainsynder.nms.entity; + +import lib.brainsynder.reflection.Reflection; +import net.minecraft.core.DefaultedRegistry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.game.ClientGamePacketListener; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerEntity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_21_R2.entity.CraftLivingEntity; +import simplepets.brainsynder.api.pet.PetType; +import simplepets.brainsynder.api.user.PetUser; +import simplepets.brainsynder.nms.CitizensFixer; +import simplepets.brainsynder.nms.VersionTranslator; +import simplepets.brainsynder.nms.entity.list.EntityRabbitPet; +import simplepets.brainsynder.nms.entity.list.EntitySlimePet; +import simplepets.brainsynder.nms.utils.PetDataAccess; +import simplepets.brainsynder.utils.VersionFields; + +import java.lang.reflect.Field; +import java.util.IdentityHashMap; + +public class EntityBase extends Mob { + protected final EntityType entityType; + protected final EntityType originalEntityType; + private PetUser user; + private PetType petType; + private volatile CraftEntity bukkitEntity; + + protected EntityBase(EntityType entitytypes, Level world) { + super(entitytypes, world); + entityType = getEntityType(entitytypes); + originalEntityType = entitytypes; + VersionTranslator.getBukkitEntity(this).remove(); + } + + public EntityBase(EntityType entitytypes, PetType type, PetUser user) { + super(entitytypes, VersionTranslator.getWorldHandle(user.getPlayer().getLocation().getWorld())); + this.user = user; + this.petType = type; + entityType = getEntityType(entitytypes); + originalEntityType = entitytypes; + } + + @Override + public void jumpFromGround() { + if (this instanceof EntitySlimePet) { + Vec3 vec3d = this.getDeltaMovement(); + this.setDeltaMovement(vec3d.x, this.getJumpPower(), vec3d.z); + this.hasImpulse = true; + return; + } + + super.jumpFromGround(); + + if (this instanceof EntityRabbitPet) { + double speed = this.moveControl.getSpeedModifier(); + if (speed > 0.0D) { + double length = getDeltaMovement().horizontalDistanceSqr(); + if (length < 0.01D) { + this.moveRelative(0.1F, new Vec3(0.0D, 0.0D, 1.0D)); + } + } + + if (!VersionTranslator.getEntityLevel(this).isClientSide) VersionTranslator.getEntityLevel(this).broadcastEntityEvent(this, (byte)1); + } + } + + @Override + protected void handlePortal() { + // fuck around and find out + } + + public void populateDataAccess(PetDataAccess dataAccess) {} + + @Override + protected void defineSynchedData(SynchedEntityData.Builder datawatcher) { + super.defineSynchedData(datawatcher); + + PetDataAccess dataAccess = new PetDataAccess(); + populateDataAccess(dataAccess); + dataAccess.getAccessorDefinitions().forEach(datawatcher::define); + } + + // 1.20.1+ Replaces boolean rideableUnderWater() + @Override + public boolean dismountsUnderwater() { + return false; + } + + public PetType getPetType() { + return petType; + } + + public PetUser getUser() { + return user; + } + + EntityType getEntityType(EntityType originalType) { + try { + DefaultedRegistry> registry = CitizensFixer.getVanillaRegistry(BuiltInRegistries.ENTITY_TYPE); + + // Resets the Entity Registry to the vanilla one... + CitizensFixer.overrideRegistry(registry); + + // Melts the frozen status, so we can register the mob... + Field frozen = Reflection.getField(registry.getClass().getSuperclass(), VersionFields.v1_21_3.getRegistryFrozenField()); + if (frozen != null) frozen.set(registry, false); + + // Clears the intrusive holder field to an empty map + Field intrusiveField = Reflection.getField(registry.getClass().getSuperclass(), VersionFields.v1_21_3.getRegistryIntrusiveField()); + if (intrusiveField != null) intrusiveField.set(registry, new IdentityHashMap<>()); + + // Fetch the entity type instance before we resume + EntityType mob = handleMobBuilder(originalType); + + // Puts the registry back in the freezer... (Buuurrrrrr) + if (frozen != null) frozen.set(registry, true); + + // If a custom registry was found before, reset it back so that plugin can continue to work... + // COUGH COUGH... Citizens... COUGH COUGH... + CitizensFixer.resetCustomRegistry(); + return mob; + } catch (IllegalAccessException | NoSuchFieldException e) { + e.printStackTrace(); + return originalType; + } + } + + private EntityType handleMobBuilder(EntityType originalType) throws NoSuchFieldException, IllegalAccessException { + Field field = Reflection.getField(EntityType.class, VersionFields.v1_21_3.getEntityFactoryField()); + + EntityType.Builder builder = EntityType.Builder.of( + (EntityType.EntityFactory) field.get(originalType), + MobCategory.AMBIENT + ); + builder.sized(0.1f, 0.1f); + + return builder.build(ResourceKey.create(Registries.ENTITY_TYPE, ResourceLocation.withDefaultNamespace(petType.name().toLowerCase()))); + } + + @Override + public CraftEntity getBukkitEntity() { + if (this.bukkitEntity == null) { + synchronized (this) { + if (this.bukkitEntity == null) { + return this.bukkitEntity = new CraftLivingEntity(this.level().getCraftServer(), this) {}; + } + } + } + return this.bukkitEntity; + } + + /** + * Overrides the Paper method + */ + public CraftLivingEntity getBukkitLivingEntity() { + return (CraftLivingEntity) this.getBukkitEntity(); + } + + public Packet getAddEntityPacket(ServerEntity entitytrackerentry) { + return VersionTranslator.getAddEntityPacket(this, entitytrackerentry, originalEntityType, VersionTranslator.getPosition(this)); + } +} diff --git a/nms/version-1.21.3/src/simplepets/brainsynder/nms/entity/EntityPetOverride.java b/nms/version-1.21.3/src/simplepets/brainsynder/nms/entity/EntityPetOverride.java new file mode 100644 index 00000000..bebe3a7f --- /dev/null +++ b/nms/version-1.21.3/src/simplepets/brainsynder/nms/entity/EntityPetOverride.java @@ -0,0 +1,96 @@ +package simplepets.brainsynder.nms.entity; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.player.Input; +import net.minecraft.world.phys.Vec3; +import org.bukkit.Bukkit; +import simplepets.brainsynder.api.event.entity.PetMoveEvent; +import simplepets.brainsynder.api.event.entity.movment.PetJumpEvent; +import simplepets.brainsynder.api.event.entity.movment.PetRideEvent; +import simplepets.brainsynder.api.pet.PetType; +import simplepets.brainsynder.api.plugin.SimplePets; +import simplepets.brainsynder.api.user.PetUser; +import simplepets.brainsynder.nms.VersionTranslator; + +public class EntityPetOverride extends EntityPet { + public EntityPetOverride(EntityType entitytypes, PetType type, PetUser user) { + super(entitytypes, type, user); + } + + @Override + public void travel(Vec3 vec3d) { + if ((getPetType() == null) || (getUser() == null)) return; + + if ((passengers == null) + || (!isOwnerRiding())) { + super.travel(vec3d); + return; + } + + ServerPlayer passenger = VersionTranslator.getEntityHandle(getUser().getPlayer()); + + if (doIndirectAttach) { + if (getFirstPassenger() instanceof SeatEntity seat) { + // orient the seat entity correctly. Seems to fix the issue + // where ridden horses are not oriented properly + seat.setYRot(passenger.getYRot()); + seat.yRotO = this.getYRot(); + seat.setXRot(passenger.getXRot() * 0.5F); + seat.setRot(this.getYRot(), this.getXRot()); + seat.yHeadRot = this.yBodyRot = this.getYRot(); + } + } + + this.setYRot(passenger.getYRot()); + this.yRotO = this.getYRot(); + this.setXRot(passenger.getXRot() * 0.5F); + this.setRot(this.getYRot(), this.getXRot()); + this.yHeadRot = this.yBodyRot = this.getYRot(); + + Input clientInput = passenger.getLastClientInput(); + double xxa = (clientInput.left() == clientInput.right() ? 0 : (clientInput.left() ? 1 : -1)); + double zza = (clientInput.forward() == clientInput.backward() ? 0 : (clientInput.forward() ? 1 : -1)); + + double strafe = xxa * 0.5; + double vertical = vec3d.y; + double forward = zza; + if (forward <= 0) { + forward *= 0.25F; + } + + PetMoveEvent moveEvent = new PetRideEvent(this); + Bukkit.getServer().getPluginManager().callEvent(moveEvent); + if (moveEvent.isCancelled()) return; + + double speed = VersionTranslator.getWalkSpeed(this); + + if (!passengers.isEmpty()) { + SimplePets.getPetConfigManager().getPetConfig(getPetType()).ifPresent(config -> { + try { + boolean flight = false; + double height = getJumpHeight(); + + if (config.canFly(getUser().getPlayer())) { + flight = true; + height = 0.3; + } + + PetJumpEvent jumpEvent = new PetJumpEvent(this, height); + Bukkit.getServer().getPluginManager().callEvent(jumpEvent); + if ((!jumpEvent.isCancelled()) && clientInput.jump()) { + if (flight || this.onGround) { + setDeltaMovement(getDeltaMovement().x, jumpEvent.getJumpHeight(), getDeltaMovement().z); + this.hasImpulse = true; + } + } + } catch (IllegalArgumentException | IllegalStateException ignored) { + } + }); + } + + this.setSpeed((float) speed); + super.travel(new Vec3(strafe, vertical, forward)); + } +} diff --git a/nms/version-1.21/pom.xml b/nms/version-1.21/pom.xml index 08e17e72..2d15d930 100644 --- a/nms/version-1.21/pom.xml +++ b/nms/version-1.21/pom.xml @@ -105,5 +105,11 @@ ${revision} compile + + + anvil.brainsynder + anvilgui + ${anvilgui.version} + \ No newline at end of file diff --git a/nms/version-1.21/src/simplepets/brainsynder/nms/VersionTranslator.java b/nms/version-1.21/src/simplepets/brainsynder/nms/VersionTranslator.java index f0637ba7..addad90e 100644 --- a/nms/version-1.21/src/simplepets/brainsynder/nms/VersionTranslator.java +++ b/nms/version-1.21/src/simplepets/brainsynder/nms/VersionTranslator.java @@ -12,6 +12,7 @@ import lib.brainsynder.storage.RandomCollection; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.Registry; import net.minecraft.core.Vec3i; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; @@ -19,11 +20,13 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; +import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket; import net.minecraft.network.syncher.EntityDataSerializer; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerEntity; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeMap; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; @@ -290,4 +293,17 @@ public static Level getEntityLevel(Entity entity) { public static boolean isWalkable (EntityPet entity, BlockPos.MutableBlockPos blockposition) { return WalkNodeEvaluator.getPathTypeStatic(entity, blockposition) == PathType.WALKABLE; } + + // ADDED DURING 1.21.3 DEVELOPMENT + public static T getRegistryValue (Registry registry, NamespacedKey key) { + return registry.get(CraftNamespacedKey.toMinecraft(key)); + } + + public static void killEntity (Entity entity, ServerLevel level) { + entity.kill(); + } + + public static ClientboundTeleportEntityPacket getTeleportPacket (Entity entity) { + return new ClientboundTeleportEntityPacket(entity); + } } \ No newline at end of file diff --git a/nms/version-1.21/src/simplepets/brainsynder/nms/entity/EntityPetOverride.java b/nms/version-1.21/src/simplepets/brainsynder/nms/entity/EntityPetOverride.java new file mode 100644 index 00000000..415c4546 --- /dev/null +++ b/nms/version-1.21/src/simplepets/brainsynder/nms/entity/EntityPetOverride.java @@ -0,0 +1,94 @@ +package simplepets.brainsynder.nms.entity; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.phys.Vec3; +import org.bukkit.Bukkit; +import simplepets.brainsynder.api.event.entity.PetMoveEvent; +import simplepets.brainsynder.api.event.entity.movment.PetJumpEvent; +import simplepets.brainsynder.api.event.entity.movment.PetRideEvent; +import simplepets.brainsynder.api.pet.PetType; +import simplepets.brainsynder.api.plugin.SimplePets; +import simplepets.brainsynder.api.user.PetUser; +import simplepets.brainsynder.nms.VersionTranslator; + +import java.lang.reflect.Field; + +public class EntityPetOverride extends EntityPet { + public EntityPetOverride(EntityType entitytypes, PetType type, PetUser user) { + super(entitytypes, type, user); + } + + @Override + public void travel(Vec3 vec3d) { + if ((getPetType() == null) || (getUser() == null)) return; + + if ((passengers == null) + || (!isOwnerRiding())) { + super.travel(vec3d); + return; + } + + ServerPlayer passenger = VersionTranslator.getEntityHandle(getUser().getPlayer()); + + if (doIndirectAttach) { + if (getFirstPassenger() instanceof SeatEntity seat) { + // orient the seat entity correctly. Seems to fix the issue + // where ridden horses are not oriented properly + seat.setYRot(passenger.getYRot()); + seat.yRotO = this.getYRot(); + seat.setXRot(passenger.getXRot() * 0.5F); + seat.setRot(this.getYRot(), this.getXRot()); + seat.yHeadRot = this.yBodyRot = this.getYRot(); + } + } + + this.setYRot(passenger.getYRot()); + this.yRotO = this.getYRot(); + this.setXRot(passenger.getXRot() * 0.5F); + this.setRot(this.getYRot(), this.getXRot()); + this.yHeadRot = this.yBodyRot = this.getYRot(); + + double strafe = passenger.xxa * 0.5; + double vertical = vec3d.y; + double forward = passenger.zza; + if (forward <= 0) { + forward *= 0.25F; + } + + PetMoveEvent moveEvent = new PetRideEvent(this); + Bukkit.getServer().getPluginManager().callEvent(moveEvent); + if (moveEvent.isCancelled()) return; + + double speed = VersionTranslator.getWalkSpeed(this); + + Field jumpField = VersionTranslator.getJumpField(); + if ((jumpField != null) && (!passengers.isEmpty())) { + SimplePets.getPetConfigManager().getPetConfig(getPetType()).ifPresent(config -> { + try { + boolean flight = false; + double height = getJumpHeight(); + + if (config.canFly(getUser().getPlayer())) { + flight = true; + height = 0.3; + } + + PetJumpEvent jumpEvent = new PetJumpEvent(this, height); + Bukkit.getServer().getPluginManager().callEvent(jumpEvent); + if ((!jumpEvent.isCancelled()) && jumpField.getBoolean(passenger)) { + if (flight || this.onGround) { + setDeltaMovement(getDeltaMovement().x, jumpEvent.getJumpHeight(), getDeltaMovement().z); + this.hasImpulse = true; + } + } + } catch (IllegalArgumentException | IllegalStateException | IllegalAccessException ignored) { + } + }); + } + + this.setSpeed((float) speed); + super.travel(new Vec3(strafe, vertical, forward)); + } +} diff --git a/nms/version-1.21/src/simplepets/brainsynder/nms/entity/list/EntityRabbitPet.java b/nms/version-1.21/src/simplepets/brainsynder/nms/entity/list/EntityRabbitPet.java new file mode 100644 index 00000000..b33e39c9 --- /dev/null +++ b/nms/version-1.21/src/simplepets/brainsynder/nms/entity/list/EntityRabbitPet.java @@ -0,0 +1,163 @@ +package simplepets.brainsynder.nms.entity.list; + +import lib.brainsynder.nbt.StorageTagCompound; +import lib.brainsynder.reflection.Reflection; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.ai.navigation.PathNavigation; +import net.minecraft.world.level.pathfinder.Path; +import net.minecraft.world.phys.Vec3; +import simplepets.brainsynder.api.entity.passive.IEntityRabbitPet; +import simplepets.brainsynder.api.pet.PetType; +import simplepets.brainsynder.api.user.PetUser; +import simplepets.brainsynder.api.wrappers.RabbitType; +import simplepets.brainsynder.nms.entity.EntityAgeablePet; +import simplepets.brainsynder.nms.entity.controller.ControllerJumpRabbit; +import simplepets.brainsynder.nms.entity.controller.ControllerMoveRabbit; +import simplepets.brainsynder.nms.utils.PetDataAccess; + +import java.lang.reflect.InvocationTargetException; + +/** + * NMS: {@link net.minecraft.world.entity.animal.Rabbit} + */ +public class EntityRabbitPet extends EntityAgeablePet implements IEntityRabbitPet { + private static final EntityDataAccessor RABBIT_TYPE = SynchedEntityData.defineId(EntityRabbitPet.class, EntityDataSerializers.INT); + private int jumpTicks; + private int jumpDuration; + private boolean onGroundLastTick = false; + private int ticksUntilJump = 0; + + public EntityRabbitPet(PetType type, PetUser user) { + super(EntityType.RABBIT, type, user); + + jumpControl = new ControllerJumpRabbit(this); + moveControl = new ControllerMoveRabbit(this); + } + + @Override + public void populateDataAccess(PetDataAccess dataAccess) { + super.populateDataAccess(dataAccess); + dataAccess.define(RABBIT_TYPE, 0); + } + + @Override + public void applyCompound(StorageTagCompound object) { + if (object.hasKey("variant")) setRabbitType(object.getEnum("variant", RabbitType.class, RabbitType.BROWN)); + super.applyCompound(object); + } + + @Override + public StorageTagCompound asCompound() { + StorageTagCompound object = super.asCompound(); + object.setEnum("variant", getRabbitType()); + return object; + } + + @Override + public RabbitType getRabbitType() { + return RabbitType.getByID(this.entityData.get(RABBIT_TYPE)); + } + + @Override + public void setRabbitType(RabbitType type) { + this.entityData.set(RABBIT_TYPE, type.getId()); + } + + @Override + public void tick() { + super.tick(); + this.onGroundLastTick = this.onGround; + } + + @Override + public void customServerAiStep() { + if (this.ticksUntilJump > 0) { + --this.ticksUntilJump; + } + + if (this.onGround) { + if (!this.onGroundLastTick) { + this.setJumping(false); + scheduleJump(); + } + + ControllerJumpRabbit controller = (ControllerJumpRabbit)this.getJumpControl(); + if (!controller.wantJump()) { + if (this.moveControl.hasWanted() && this.ticksUntilJump == 0) { + Path pathentity = getPath(); // Translation: navigation.getCurrentPath() + + // Translation: getTargetX, getTargetY, getTargetZ + Vec3 vec3d = new Vec3(this.moveControl.getWantedX(), this.moveControl.getWantedY(), this.moveControl.getWantedZ()); + if (pathentity != null && !pathentity.isDone()) { + vec3d = pathentity.getNextEntityPos(this); // Translation: getNodePosition () + } + + this.lookTowards(vec3d.x, vec3d.z); + this.reseter(); + } + } else if (!controller.canJump()) { + ((ControllerJumpRabbit) jumpControl).setCanJump(true); + } + } + + this.onGroundLastTick = this.onGround; + } + + private void scheduleJump() { + this.doScheduleJump(); + ((ControllerJumpRabbit)jumpControl).setCanJump(false); + } + + private void doScheduleJump() { + if (this.moveControl.getSpeedModifier() < 2.2D) { + this.ticksUntilJump = 10; + } else { + this.ticksUntilJump = 1; + } + ((ControllerJumpRabbit)this.jumpControl).setCanJump(false); + } + + private void lookTowards(double d0, double d1) { + setYRot((float)(Mth.atan2(d1 - getZ(), d0 - getX()) * 57.2957763671875D) - 90.0F); + } + + @Override + public void aiStep() { + super.aiStep(); + if (jumpTicks != jumpDuration) { + ++this.jumpTicks; + } else if (jumpDuration != 0) { + jumpTicks = 0; + jumpDuration = 0; + setJumping(false); + } + } + + public void setSpeedModifier(double d0) { + getNavigation().setSpeedModifier(d0); + this.moveControl.setWantedPosition(this.moveControl.getWantedX(), this.moveControl.getWantedY(), this.moveControl.getWantedZ(), d0); + } + + private Path getPath() { + try { + return navigation.getPath(); + } catch (NoSuchMethodError ex) { + try { + return (Path) Reflection.getMethod(PathNavigation.class, "getPath").invoke(navigation); + } catch (IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + return null; + } + + public void reseter() { + this.setJumping(true); + this.jumpDuration = 10; + this.jumpTicks = 0; + } +} diff --git a/plugin-core/pom.xml b/plugin-core/pom.xml index 0389108a..6619763f 100644 --- a/plugin-core/pom.xml +++ b/plugin-core/pom.xml @@ -95,6 +95,7 @@ anvil.brainsynder anvilgui ${anvilgui.version} + provided diff --git a/plugin-core/src/simplepets/brainsynder/PetCore.java b/plugin-core/src/simplepets/brainsynder/PetCore.java index c5479a5c..6eaa8c6a 100644 --- a/plugin-core/src/simplepets/brainsynder/PetCore.java +++ b/plugin-core/src/simplepets/brainsynder/PetCore.java @@ -109,7 +109,7 @@ public void onEnable() { debug = new Debug(this); SERVER_INFORMATION = new ServerInformation(); - if (ServerVersion.isEqualNew(ServerVersion.v1_21)) { + if (ServerVersion.isEqualNew(ServerVersion.v1_21_3)) { SimplePets.getDebugLogger().debug(DebugBuilder.build() .setLevel(DebugLevel.WARNING).setBroadcast(true) .setMessages( diff --git a/plugin-core/src/simplepets/brainsynder/utils/VersionFields.java b/plugin-core/src/simplepets/brainsynder/utils/VersionFields.java index 6530bf41..f7fe7f2e 100644 --- a/plugin-core/src/simplepets/brainsynder/utils/VersionFields.java +++ b/plugin-core/src/simplepets/brainsynder/utils/VersionFields.java @@ -162,6 +162,17 @@ public enum VersionFields implements FieldValues { "K", // net.minecraft.world.entity.Entity$boardingCooldown "R", // net.minecraft.server.MinecraftServer$running "bU" // net.minecraft.world.entity.LivingEntity$attributes + ), + v1_21_3 ( + "e", // net.minecraft.network.syncher.SynchedEntityData$itemsById + "bZ", // net.minecraft.world.entity.EntityType$factory + "l", // net.minecraft.core.MappedRegistry$frozen + "m", // net.minecraft.core.MappedRegistry$unregisteredIntrusiveHolders + "f", // net.minecraft.core.registries.BuiltInRegistries#ENTITY_TYPE + "bn", // net.minecraft.world.entity.LivingEntity$jumping + "J", // net.minecraft.world.entity.Entity$boardingCooldown + "R", // net.minecraft.server.MinecraftServer$running + "bS" // net.minecraft.world.entity.LivingEntity$attributes ); public static VersionFields fromServerVersion (ServerVersion version) { diff --git a/plugin-distribution/pom.xml b/plugin-distribution/pom.xml index 7a39979f..cd0607af 100644 --- a/plugin-distribution/pom.xml +++ b/plugin-distribution/pom.xml @@ -85,6 +85,14 @@ + + + anvil.brainsynder + anvilgui + ${anvilgui.version} + + + @@ -96,30 +104,60 @@ Version_1.19 ${revision} compile + + + anvil.brainsynder + anvilgui + + simplepets.brainsynder Version_1.19.1 ${revision} compile + + + anvil.brainsynder + anvilgui + + simplepets.brainsynder Version_1.19.2 ${revision} compile + + + anvil.brainsynder + anvilgui + + simplepets.brainsynder Version_1.19.3 ${revision} compile + + + anvil.brainsynder + anvilgui + + simplepets.brainsynder Version_1.19.4 ${revision} compile + + + anvil.brainsynder + anvilgui + + @@ -128,17 +166,89 @@ 1.20 + + simplepets.brainsynder + Version_1.20 + ${revision} + compile + + + anvil.brainsynder + anvilgui + + + + + simplepets.brainsynder + Version_1.20.1 + ${revision} + compile + + + anvil.brainsynder + anvilgui + + + + + simplepets.brainsynder + Version_1.20.2 + ${revision} + compile + + + anvil.brainsynder + anvilgui + + + + + simplepets.brainsynder + Version_1.20.3 + ${revision} + compile + + + anvil.brainsynder + anvilgui + + + simplepets.brainsynder Version_1.20.4 ${revision} compile + + + anvil.brainsynder + anvilgui + + + + + simplepets.brainsynder + Version_1.20.5 + ${revision} + compile + + + anvil.brainsynder + anvilgui + + simplepets.brainsynder Version_1.20.6 ${revision} compile + + + anvil.brainsynder + anvilgui + + @@ -152,12 +262,36 @@ Version_1.21 ${revision} compile + + + anvil.brainsynder + anvilgui + + simplepets.brainsynder Version_1.21.1 ${revision} compile + + + anvil.brainsynder + anvilgui + + + + + simplepets.brainsynder + Version_1.21.3 + ${revision} + compile + + + anvil.brainsynder + anvilgui + + @@ -172,6 +306,12 @@ Version_${minecraft.version} ${revision} compile + + + anvil.brainsynder + anvilgui + + @@ -191,6 +331,12 @@ Version_${target-mc} ${revision} compile + + + anvil.brainsynder + anvilgui + + @@ -205,45 +351,39 @@ simplepets.brainsynder - Version_1.20.2 - ${revision} - compile - - - simplepets.brainsynder - Version_1.20.3 - ${revision} - compile - - - simplepets.brainsynder - Version_1.20.4 - ${revision} - compile - - - simplepets.brainsynder - Version_1.20.5 - ${revision} - compile - - - simplepets.brainsynder - Version_1.20.6 + Version_1.21 ${revision} compile + + + anvil.brainsynder + anvilgui + + simplepets.brainsynder - Version_1.21 + Version_1.21.1 ${revision} compile + + + anvil.brainsynder + anvilgui + + simplepets.brainsynder - Version_1.21.1 + Version_1.21.3 ${revision} compile + + + anvil.brainsynder + anvilgui + + diff --git a/pom.xml b/pom.xml index f076e6bc..e3c0357e 100644 --- a/pom.xml +++ b/pom.xml @@ -18,17 +18,17 @@ 5.0-BUILD-0 17 - B131 - 1.6.20-CUSTOM + B132 + 1.6.22-CUSTOM 3.0.3 5.0.0 2.11.0 2.0.3 3.5.0 - 1.21.1 + 1.21.3 ${minecraft.version}-R0.1-SNAPSHOT - v1_21_R1 + v1_21_R2 ${minecraft.version} @@ -95,20 +95,16 @@ - + + - default - - true - + 1.20 plugin-api plugin-core plugin-distribution - nms/master - nms/version-1.20 nms/version-1.20.1 nms/version-1.20.2 @@ -116,8 +112,26 @@ nms/version-1.20.4 nms/version-1.20.5 nms/version-1.20.6 + + + + + + default + + true + + + + plugin-api + plugin-core + plugin-distribution + + nms/master + nms/version-1.21 nms/version-1.21.1 + nms/version-1.21.3 @@ -163,7 +177,7 @@ jeff-media-public - https://hub.jeff-media.com/nexus/repository/jeff-media-public/ + https://repo.jeff-media.com/public/ devmart-other diff --git a/resources/plugin.yml b/resources/plugin.yml index bef44545..72858054 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -5,9 +5,8 @@ softdepend: [ProtocolLib] loadbefore: [mcMMO, ProtocolSupport] authors: [brainsynder, Thatsmusic99] contributors: [traksag] -api-version: 1.16 +api-version: 1.21 folia-supported: true - commands: pet: description: Main SimplePets command