From f865ea3af589ca2f7bc50795da9cffbbe4bb9723 Mon Sep 17 00:00:00 2001 From: Jakllp <57708725+Jakllp@users.noreply.github.com> Date: Mon, 23 Aug 2021 11:39:44 +0200 Subject: [PATCH 1/6] Conversion to Mojang-Mappings - Part 1/? First conversion-push Still a lot to do --- .../api/entity/MyPetMinecraftEntity.java | 19 +- .../compat/v1_16_R1/entity/EntityMyPet.java | 4 +- .../compat/v1_16_R3/entity/EntityMyPet.java | 4 +- modules/v1_17_R1/pom.xml | 41 +- .../MyPet/compat/v1_17_R1/CompatManager.java | 21 +- .../MyPet/compat/v1_17_R1/PlatformHelper.java | 10 +- .../compat/v1_17_R1/entity/CraftMyPet.java | 20 +- .../compat/v1_17_R1/entity/EntityMyPet.java | 499 +++++++++--------- .../v1_17_R1/entity/EntityMyPetPart.java | 36 +- .../v1_17_R1/entity/EntityRegistry.java | 76 ++- .../v1_17_R1/entity/MyAttributeDefaults.java | 296 ++++++----- .../entity/ai/attack/MeleeAttack.java | 43 +- .../entity/ai/attack/RangedAttack.java | 126 ++--- .../v1_17_R1/entity/ai/movement/EatGrass.java | 2 +- .../ai/navigation/VanillaNavigation.java | 34 +- .../v1_17_R1/entity/types/EntityMyBat.java | 22 +- .../v1_17_R1/entity/types/EntityMyBee.java | 34 +- .../v1_17_R1/entity/types/EntityMyBlaze.java | 71 +-- .../v1_17_R1/entity/types/EntityMyCat.java | 83 ++- .../entity/types/EntityMyCaveSpider.java | 15 +- .../entity/types/EntityMyChicken.java | 42 +- .../v1_17_R1/entity/types/EntityMyCod.java | 16 +- .../v1_17_R1/entity/types/EntityMyCow.java | 42 +- .../entity/types/EntityMyCreeper.java | 26 +- .../entity/types/EntityMyDolphin.java | 24 +- .../v1_17_R1/entity/types/EntityMyDonkey.java | 80 +-- .../entity/types/EntityMyDrowned.java | 70 +-- .../entity/types/EntityMyElderGuardian.java | 2 +- .../entity/types/EntityMyEnderDragon.java | 8 +- .../entity/types/EntityMyEnderman.java | 50 +- .../entity/types/EntityMyEndermite.java | 2 +- .../v1_17_R1/entity/types/EntityMyEvoker.java | 20 +- .../v1_17_R1/entity/types/EntityMyFox.java | 72 +-- .../v1_17_R1/entity/types/EntityMyGhast.java | 8 +- .../v1_17_R1/entity/types/EntityMyGiant.java | 34 +- .../entity/types/EntityMyGuardian.java | 2 +- .../v1_17_R1/entity/types/EntityMyHoglin.java | 36 +- .../v1_17_R1/entity/types/EntityMyHorse.java | 80 +-- .../v1_17_R1/entity/types/EntityMyHusk.java | 66 +-- .../entity/types/EntityMyIllusioner.java | 54 +- .../entity/types/EntityMyIronGolem.java | 42 +- .../v1_17_R1/entity/types/EntityMyLlama.java | 92 ++-- .../entity/types/EntityMyMagmaCube.java | 18 +- .../entity/types/EntityMyMooshroom.java | 52 +- .../v1_17_R1/entity/types/EntityMyMule.java | 80 +-- .../v1_17_R1/entity/types/EntityMyOcelot.java | 40 +- .../v1_17_R1/entity/types/EntityMyPanda.java | 64 +-- .../v1_17_R1/entity/types/EntityMyParrot.java | 43 +- .../entity/types/EntityMyPhantom.java | 24 +- .../v1_17_R1/entity/types/EntityMyPig.java | 66 +-- .../v1_17_R1/entity/types/EntityMyPiglin.java | 60 +-- .../entity/types/EntityMyPiglinBrute.java | 60 +-- .../entity/types/EntityMyPillager.java | 64 +-- .../entity/types/EntityMyPolarBear.java | 44 +- .../entity/types/EntityMyPufferfish.java | 22 +- .../v1_17_R1/entity/types/EntityMyRabbit.java | 42 +- .../entity/types/EntityMyRavager.java | 24 +- .../v1_17_R1/entity/types/EntityMySalmon.java | 16 +- .../v1_17_R1/entity/types/EntityMySheep.java | 58 +- .../entity/types/EntityMySilverfish.java | 2 +- .../entity/types/EntityMySkeleton.java | 34 +- .../entity/types/EntityMySkeletonHorse.java | 66 +-- .../v1_17_R1/entity/types/EntityMySlime.java | 18 +- .../entity/types/EntityMySnowman.java | 44 +- .../v1_17_R1/entity/types/EntityMySpider.java | 2 +- .../v1_17_R1/entity/types/EntityMySquid.java | 2 +- .../v1_17_R1/entity/types/EntityMyStray.java | 34 +- .../entity/types/EntityMyStrider.java | 66 +-- .../entity/types/EntityMyTraderLlama.java | 92 ++-- .../entity/types/EntityMyTropicalFish.java | 22 +- .../v1_17_R1/entity/types/EntityMyTurtle.java | 60 +-- .../v1_17_R1/entity/types/EntityMyVex.java | 56 +- .../entity/types/EntityMyVillager.java | 46 +- .../entity/types/EntityMyVindicator.java | 48 +- .../entity/types/EntityMyWanderingTrader.java | 16 +- .../v1_17_R1/entity/types/EntityMyWitch.java | 2 +- .../v1_17_R1/entity/types/EntityMyWither.java | 36 +- .../entity/types/EntityMyWitherSkeleton.java | 34 +- .../v1_17_R1/entity/types/EntityMyWolf.java | 94 ++-- .../v1_17_R1/entity/types/EntityMyZoglin.java | 36 +- .../v1_17_R1/entity/types/EntityMyZombie.java | 68 +-- .../entity/types/EntityMyZombieHorse.java | 66 +-- .../entity/types/EntityMyZombieVillager.java | 78 +-- .../entity/types/EntityMyZombifiedPiglin.java | 60 +-- .../skills/ranged/bukkit/CraftMyPetArrow.java | 9 +- .../bukkit/CraftMyPetDragonFireball.java | 9 +- .../skills/ranged/bukkit/CraftMyPetEgg.java | 9 +- .../ranged/bukkit/CraftMyPetEnderPearl.java | 9 +- .../bukkit/CraftMyPetLargeFireball.java | 9 +- .../ranged/bukkit/CraftMyPetLlamaSpit.java | 9 +- .../bukkit/CraftMyPetSmallFireball.java | 9 +- .../ranged/bukkit/CraftMyPetSnowball.java | 9 +- .../ranged/bukkit/CraftMyPetTrident.java | 19 +- .../ranged/bukkit/CraftMyPetWitherSkull.java | 9 +- .../skill/skills/ranged/nms/MyPetArrow.java | 10 +- .../ranged/nms/MyPetDragonFireball.java | 12 +- .../skill/skills/ranged/nms/MyPetEgg.java | 4 +- .../skills/ranged/nms/MyPetEnderPearl.java | 4 +- .../skills/ranged/nms/MyPetLargeFireball.java | 4 +- .../skills/ranged/nms/MyPetLlamaSpit.java | 4 +- .../skills/ranged/nms/MyPetSmallFireball.java | 4 +- .../skills/ranged/nms/MyPetSnowball.java | 4 +- .../skill/skills/ranged/nms/MyPetTrident.java | 4 +- .../skills/ranged/nms/MyPetWitherSkull.java | 4 +- .../compat/v1_17_R1/util/ConfigItem.java | 29 +- .../util/iconmenu/IconMenuInventory.java | 72 +-- .../util/inventory/CustomInventory.java | 75 ++- .../util/inventory/ItemStackComparator.java | 9 +- .../util/inventory/ItemStackNBTConverter.java | 65 +-- 109 files changed, 2319 insertions(+), 2268 deletions(-) diff --git a/modules/API/src/main/java/de/Keyle/MyPet/api/entity/MyPetMinecraftEntity.java b/modules/API/src/main/java/de/Keyle/MyPet/api/entity/MyPetMinecraftEntity.java index 436ce4957e..fe00d3e7e8 100644 --- a/modules/API/src/main/java/de/Keyle/MyPet/api/entity/MyPetMinecraftEntity.java +++ b/modules/API/src/main/java/de/Keyle/MyPet/api/entity/MyPetMinecraftEntity.java @@ -20,15 +20,16 @@ package de.Keyle.MyPet.api.entity; -import de.Keyle.MyPet.api.entity.ai.AIGoalSelector; -import de.Keyle.MyPet.api.entity.ai.navigation.AbstractNavigation; -import de.Keyle.MyPet.api.entity.ai.target.TargetPriority; -import de.Keyle.MyPet.api.player.MyPetPlayer; +import java.util.UUID; + import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; -import java.util.UUID; +import de.Keyle.MyPet.api.entity.ai.AIGoalSelector; +import de.Keyle.MyPet.api.entity.ai.navigation.AbstractNavigation; +import de.Keyle.MyPet.api.entity.ai.target.TargetPriority; +import de.Keyle.MyPet.api.player.MyPetPlayer; public interface MyPetMinecraftEntity { boolean isMyPet(); @@ -57,12 +58,8 @@ public interface MyPetMinecraftEntity { void updateVisuals(); - LivingEntity getTarget(); - TargetPriority getTargetPriority(); - void setTarget(LivingEntity entity, TargetPriority priority); - void forgetTarget(); boolean hasTarget(); @@ -78,4 +75,8 @@ public interface MyPetMinecraftEntity { boolean isSitting(); UUID getUniqueID(); + + LivingEntity getMyPetTarget(); + + void setMyPetTarget(LivingEntity entity, TargetPriority priority); } \ No newline at end of file diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/EntityMyPet.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/EntityMyPet.java index 5790a8752e..96fcf24553 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/EntityMyPet.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/EntityMyPet.java @@ -228,7 +228,7 @@ public TargetPriority getTargetPriority() { } @Override - public LivingEntity getTarget() { + public LivingEntity getMyPetTarget() { if (target != null) { if (target.isAlive()) { return (LivingEntity) target.getBukkitEntity(); @@ -239,7 +239,7 @@ public LivingEntity getTarget() { } @Override - public void setTarget(LivingEntity entity, TargetPriority priority) { + public void setMyPetTarget(LivingEntity entity, TargetPriority priority) { if (entity == null || entity.isDead() || entity instanceof ArmorStand || !(entity instanceof CraftLivingEntity)) { forgetTarget(); return; diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/EntityMyPet.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/EntityMyPet.java index f9e08afb6d..a576994fea 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/EntityMyPet.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/EntityMyPet.java @@ -228,7 +228,7 @@ public TargetPriority getTargetPriority() { } @Override - public LivingEntity getTarget() { + public LivingEntity getMyPetTarget() { if (target != null) { if (target.isAlive()) { return (LivingEntity) target.getBukkitEntity(); @@ -239,7 +239,7 @@ public LivingEntity getTarget() { } @Override - public void setTarget(LivingEntity entity, TargetPriority priority) { + public void setMyPetTarget(LivingEntity entity, TargetPriority priority) { if (entity == null || entity.isDead() || entity instanceof ArmorStand || !(entity instanceof CraftLivingEntity)) { forgetTarget(); return; diff --git a/modules/v1_17_R1/pom.xml b/modules/v1_17_R1/pom.xml index f42b8156a7..0c0eacdd5a 100644 --- a/modules/v1_17_R1/pom.xml +++ b/modules/v1_17_R1/pom.xml @@ -16,18 +16,12 @@ MyPet-v1_17_R1 - - org.spigotmc - spigot-api - 1.17.1-R0.1-SNAPSHOT - provided - true - org.spigotmc spigot 1.17.1-R0.1-SNAPSHOT provided + remapped-mojang true @@ -73,6 +67,39 @@ true + + net.md-5 + specialsource-maven-plugin + 1.2.2 + + + package + + remap + + remap-obf + + org.spigotmc:minecraft-server:1.17-R0.1-SNAPSHOT:txt:maps-mojang + true + org.spigotmc:spigot:1.17-R0.1-SNAPSHOT:jar:remapped-mojang + true + remapped-obf + + + + package + + remap + + remap-spigot + + ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + org.spigotmc:minecraft-server:1.17-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.17-R0.1-SNAPSHOT:jar:remapped-obf + + + + diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/CompatManager.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/CompatManager.java index 2d9d2f9443..de402f7b38 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/CompatManager.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/CompatManager.java @@ -20,6 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1; +import java.lang.reflect.Method; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityToggleGlideEvent; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.util.Compat; @@ -27,20 +35,13 @@ import de.Keyle.MyPet.compat.v1_17_R1.services.EggIconService; import de.Keyle.MyPet.compat.v1_17_R1.services.EntityConverterService; import de.Keyle.MyPet.compat.v1_17_R1.services.RepositoryMyPetConverterService; -import net.minecraft.world.EnumHand; -import net.minecraft.world.entity.EntityLiving; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityToggleGlideEvent; - -import java.lang.reflect.Method; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.LivingEntity; @Compat("v1_17_R1") public class CompatManager extends de.Keyle.MyPet.api.util.CompatManager implements Listener { - public static Method ENTITY_LIVING_broadcastItemBreak = ReflectionUtil.getMethod(EntityLiving.class, "d", EnumHand.class); + public static Method ENTITY_LIVING_broadcastItemBreak = ReflectionUtil.getMethod(LivingEntity.class, "d", InteractionHand.class); @Override public void init() { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/PlatformHelper.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/PlatformHelper.java index 1b0679d02e..c6734cd26b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/PlatformHelper.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/PlatformHelper.java @@ -74,7 +74,7 @@ import net.minecraft.sounds.SoundCategory; import net.minecraft.sounds.SoundEffects; import net.minecraft.util.MathHelper; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EntityLightning; import net.minecraft.world.entity.EntityLiving; import net.minecraft.world.entity.EntityTypes; @@ -200,7 +200,7 @@ public Boolean canSpawn(Location loc, AxisAlignedBB bb) { return getBlockBBsInBB(mcWorld, bb).isEmpty() && !mcWorld.containsLiquid(bb); } - public List getBlockBBsInBB(net.minecraft.world.level.World world, AxisAlignedBB axisalignedbb) { + public List getBlockBBsInBB(net.minecraft.world.level.Level world, AxisAlignedBB axisalignedbb) { UnsafeList unsafeList = new UnsafeList(); int minX = MathHelper.floor(axisalignedbb.a); @@ -322,7 +322,7 @@ public boolean comparePlayerWithEntity(MyPetPlayer player, Object obj) { public boolean isEquipment(org.bukkit.inventory.ItemStack itemStack) { { ItemStack itemstack = CraftItemStack.asNMSCopy(itemStack); - int slot = EntityInsentient.getEquipmentSlotForItem(itemstack).getSlotFlag(); + int slot = Mob.getEquipmentSlotForItem(itemstack).getSlotFlag(); if (slot == 0) { if (itemstack.getItem() instanceof ItemSword) { return true; @@ -374,7 +374,7 @@ public void doPickupAnimation(Entity entity, Entity target) { } @Override - public Entity getEntity(int id, World world) { + public Entity getEntity(int id, Level world) { net.minecraft.world.entity.Entity e = null; try { e = Bukkit.getScheduler().callSyncMethod(MyPetApi.getPlugin(), () -> @@ -396,7 +396,7 @@ public ItemStack asNmsItemStack(org.bukkit.inventory.ItemStack itemStack) { return CraftItemStack.asNMSCopy(itemStack); } - public net.minecraft.world.level.World getWorldNMS(World world) { + public net.minecraft.world.level.World getWorldNMS(Level world) { return ((CraftWorld) world).getHandle(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/CraftMyPet.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/CraftMyPet.java index 6b36fe7802..bfde17e278 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/CraftMyPet.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/CraftMyPet.java @@ -97,7 +97,7 @@ public MyPetPlayer getOwner() { @Override public void removeEntity() { - getHandle().die(); + getHandle().discard(); } @Override @@ -201,7 +201,7 @@ public void forgetTarget() { @Override public void setTarget(LivingEntity target, TargetPriority priority) { - getHandle().setTarget(target, priority); + getHandle().setMyPetTarget(target, priority); } @Override @@ -218,45 +218,45 @@ public FakeEquipment(CraftLivingEntity entity) { @NotNull @Override public ItemStack getItemInMainHand() { - return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.b); + return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.EMPTY); } @NotNull @Override public ItemStack getItemInOffHand() { - return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.b); + return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.EMPTY); } @NotNull @Override public ItemStack getItemInHand() { - return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.b); + return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.EMPTY); } @Override public ItemStack getHelmet() { - return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.b); + return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.EMPTY); } @Override public ItemStack getChestplate() { - return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.b); + return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.EMPTY); } @Override public ItemStack getLeggings() { - return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.b); + return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.EMPTY); } @Override public ItemStack getBoots() { - return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.b); + return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.EMPTY); } @NotNull @Override public ItemStack[] getArmorContents() { - ItemStack empty = CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.b); + ItemStack empty = CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.EMPTY); return new ItemStack[]{empty, empty, empty, empty}; } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPet.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPet.java index e0937d0bf6..2d8ce5bae4 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPet.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPet.java @@ -36,7 +36,6 @@ import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_17_R1.util.CraftChatMessage; import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; @@ -92,50 +91,55 @@ import de.Keyle.MyPet.compat.v1_17_R1.entity.types.EntityMyHorse; import de.Keyle.MyPet.skill.skills.ControlImpl; import de.Keyle.MyPet.skill.skills.RideImpl; -import net.minecraft.core.BlockPosition; -import net.minecraft.core.IRegistry; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.chat.IChatBaseComponent; -import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity; -import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.resources.MinecraftKey; +import io.lumine.xikage.mythicmobs.utils.shadows.nbt.NBTTagCompound; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Registry; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket; +import net.minecraft.network.protocol.game.ClientboundSoundPacket; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.EntityPlayer; -import net.minecraft.sounds.SoundCategory; -import net.minecraft.sounds.SoundEffect; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundSource; +import net.minecraft.tags.FluidTags; import net.minecraft.tags.TagsFluid; -import net.minecraft.util.MathHelper; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.util.Mth; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.entity.EntityDimensions; import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.EntityPose; -import net.minecraft.world.entity.EntityTypes; -import net.minecraft.world.entity.EnumMoveType; +import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.IJumpable; -import net.minecraft.world.entity.ai.attributes.AttributeMapBase; -import net.minecraft.world.entity.ai.attributes.AttributeProvider; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.MoverType; +import net.minecraft.world.entity.PlayerRideableJumping; +import net.minecraft.world.entity.Pose; +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.ai.attributes.GenericAttributes; -import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.alchemy.PotionUtil; -import net.minecraft.world.level.World; -import net.minecraft.world.level.block.state.IBlockData; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AxisAlignedBB; +import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3D; -public abstract class EntityMyPet extends EntityInsentient implements MyPetMinecraftEntity { +public abstract class EntityMyPet extends Mob implements MyPetMinecraftEntity { - protected static final DataWatcherObject POTION_PARTICLE_WATCHER = EntityInsentient.aB; - + protected static final EntityDataAccessor POTION_PARTICLE_WATCHER = Mob.DATA_SHARED_FLAGS_ID; protected AIGoalSelector petPathfinderSelector, petTargetSelector; - protected EntityLiving target = null; + protected LivingEntity target = null; protected TargetPriority targetPriority = TargetPriority.None; protected double walkSpeed = 0.3F; protected boolean hasRider = false; @@ -155,11 +159,11 @@ public abstract class EntityMyPet extends EntityInsentient implements MyPetMinec protected float limitCounter = 0; protected DamageSource deathReason = null; protected CraftMyPet bukkitEntity = null; - protected AttributeMapBase attributeMap; + protected AttributeMap attributeMap; - private static final Field jump = ReflectionUtil.getField(EntityLiving.class, "jumping"); + private static final Field jump = ReflectionUtil.getField(LivingEntity.class, "jumping"); - public EntityMyPet(World world, MyPet myPet) { + public EntityMyPet(Level world, MyPet myPet) { super(((EntityRegistry) MyPetApi.getEntityRegistry()).getEntityType(myPet.getPetType()), world); try { @@ -167,16 +171,16 @@ public EntityMyPet(World world, MyPet myPet) { this.myPet = myPet; this.isMyPet = true; - this.updateSize(); + this.refreshDimensions(); this.petPathfinderSelector = new AIGoalSelector(0); this.petTargetSelector = new AIGoalSelector(Configuration.Entity.SKIP_TARGET_AI_TICKS); this.walkSpeed = MyPetApi.getMyPetInfo().getSpeed(myPet.getPetType()); this.petNavigation = new VanillaNavigation(this); this.sitPathfinder = new Sit(this); - this.getAttributeInstance(GenericAttributes.a).setValue(Integer.MAX_VALUE); + this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(Integer.MAX_VALUE); this.setHealth((float) myPet.getHealth()); this.updateNameTag(); - this.getAttributeInstance(GenericAttributes.d).setValue(walkSpeed); + this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(walkSpeed); this.setPathfinder(); this.updateVisuals(); } catch (Exception e) { @@ -185,8 +189,8 @@ public EntityMyPet(World world, MyPet myPet) { } protected void replaceCraftAttributes() { - Field craftAttributesField = ReflectionUtil.getField(EntityLiving.class, "craftAttributes"); - CraftAttributeMap craftAttributes = new CraftAttributeMap(this.getAttributeMap()); + Field craftAttributesField = ReflectionUtil.getField(LivingEntity.class, "craftAttributes"); + CraftAttributeMap craftAttributes = new CraftAttributeMap(this.getAttributes()); ReflectionUtil.setFinalFieldValue(craftAttributesField, this, craftAttributes); } @@ -204,7 +208,7 @@ public void setPathfinder() { petPathfinderSelector.addGoal("Sit", sitPathfinder); petPathfinderSelector.addGoal("Sprint", new Sprint(this, 0.25F)); petPathfinderSelector.addGoal("RangedTarget", new RangedAttack(this, -0.1F, 12.0F)); - petPathfinderSelector.addGoal("MeleeAttack", new MeleeAttack(this, 0.1F, this.getWidth() + 1.3, 20)); + petPathfinderSelector.addGoal("MeleeAttack", new MeleeAttack(this, 0.1F, this.getBbWidth() + 1.3, 20)); petPathfinderSelector.addGoal("Control", new Control(this, 0.1F)); petPathfinderSelector.addGoal("FollowOwner", new FollowOwner(this, Configuration.Entity.MYPET_FOLLOW_START_DISTANCE, 2.0F, 16F)); petPathfinderSelector.addGoal("LookAtPlayer", new LookAtPlayer(this, 8.0F)); @@ -218,18 +222,18 @@ public void setPathfinder() { } @Override - public AttributeMapBase getAttributeMap() { + public AttributeMap getAttributes() { if (attributeMap == null) { EntityRegistry entityRegistry = (EntityRegistry) MyPetApi.getEntityRegistry(); MyPetType type = entityRegistry.getMyPetType(this.getClass()); - EntityTypes types = entityRegistry.entityTypes.get(type); - AttributeProvider attributeProvider = MyAttributeDefaults.getAttribute(types); - this.attributeMap = new AttributeMapBase(attributeProvider); + EntityType types = entityRegistry.entityTypes.get(type); + AttributeSupplier attributeProvider = MyAttributeDefaults.getAttribute(types); + this.attributeMap = new AttributeMap(attributeProvider); } return attributeMap; } - public static void setupAttributes(EntityMyPet pet, EntityTypes types) { + public static void setupAttributes(EntityMyPet pet, EntityType types) { pet.initAttributes(); } @@ -250,7 +254,8 @@ public boolean hasRider() { @Override public void setLocation(Location loc) { - this.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getPitch(), loc.getYaw()); + this.setPos(loc.getX(), loc.getY(), loc.getZ()); + this.setRot(loc.getPitch(), loc.getYaw()); } @Override @@ -280,10 +285,10 @@ public TargetPriority getTargetPriority() { } @Override - public LivingEntity getTarget() { + public org.bukkit.entity.LivingEntity getMyPetTarget() { if (target != null) { if (target.isAlive()) { - return (LivingEntity) target.getBukkitEntity(); + return (org.bukkit.entity.LivingEntity) target.getBukkitEntity(); } target = null; } @@ -291,7 +296,7 @@ public LivingEntity getTarget() { } @Override - public void setTarget(LivingEntity entity, TargetPriority priority) { + public void setMyPetTarget(org.bukkit.entity.LivingEntity entity, TargetPriority priority) { if (entity == null || entity.isDead() || entity instanceof ArmorStand || !(entity instanceof CraftLivingEntity)) { forgetTarget(); return; @@ -312,21 +317,21 @@ public void forgetTarget() { } @Override - public void setCustomName(IChatBaseComponent ignored) { + public void setCustomName(Component ignored) { updateNameTag(); } @Override public void updateNameTag() { try { - if (getCustomNameVisible()) { + if (isCustomNameVisible()) { String prefix = Configuration.Name.Tag.PREFIX; String suffix = Configuration.Name.Tag.SUFFIX; prefix = prefix.replace("", getOwner().getName()); prefix = prefix.replace("", "" + getMyPet().getExperience().getLevel()); suffix = suffix.replace("", getOwner().getName()); suffix = suffix.replace("", "" + getMyPet().getExperience().getLevel()); - this.setCustomNameVisible(getCustomNameVisible()); + this.setCustomNameVisible(isCustomNameVisible()); String name = myPet.getPetName(); if (!Permissions.has(getOwner(), "MyPet.command.name.color")) { name = ChatColor.stripColor(name); @@ -339,7 +344,7 @@ public void updateNameTag() { } @Override - public IChatBaseComponent getCustomName() { + public Component getCustomName() { try { return CraftChatMessage.fromStringOrNull(myPet.getPetName()); } catch (Exception e) { @@ -348,7 +353,7 @@ public IChatBaseComponent getCustomName() { } @Override - public boolean getCustomNameVisible() { + public boolean isCustomNameVisible() { return Configuration.Name.Tag.SHOW; } @@ -398,16 +403,16 @@ public boolean playIdleSound() { @Override public void showPotionParticles(Color color) { - getDataWatcher().set(POTION_PARTICLE_WATCHER, (byte) color.asRGB()); + getEntityData().set(POTION_PARTICLE_WATCHER, (byte) color.asRGB()); } @Override public void hidePotionParticles() { int potionEffects = 0; - if (!getEffects().isEmpty()) { - potionEffects = PotionUtil.a(getEffects()); + if (!getActiveEffects().isEmpty()) { + potionEffects = PotionUtils.getColor(getActiveEffects()); } - getDataWatcher().set(POTION_PARTICLE_WATCHER, (byte) potionEffects); + getEntityData().set(POTION_PARTICLE_WATCHER, (byte) potionEffects); } @Override @@ -422,16 +427,16 @@ public boolean attack(Entity entity) { boolean damageEntity = false; try { double damage = isMyPet() ? myPet.getDamage() : 0; - if (entity instanceof EntityPlayer) { + if (entity instanceof ServerPlayer) { Player victim = (Player) entity.getBukkitEntity(); if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), victim, true)) { if (myPet.hasTarget()) { - setGoalTarget(null); + setTarget(null); } return false; } } - damageEntity = entity.damageEntity(DamageSource.mobAttack(this), (float) damage); + damageEntity = entity.hurt(DamageSource.mobAttack(this), (float) damage); } catch (Exception e) { e.printStackTrace(); } @@ -475,14 +480,14 @@ public boolean isSitting() { } @Override - public boolean isPersistent() { + public boolean isPersistenceRequired() { return false; } @Override public CraftMyPet getBukkitEntity() { if (this.bukkitEntity == null) { - this.bukkitEntity = new CraftMyPet(this.t.getCraftServer(), this); + this.bukkitEntity = new CraftMyPet(this.level.getCraftServer(), this); } return this.bukkitEntity; } @@ -495,22 +500,22 @@ public CraftMyPet getBukkitEntity() { * true: there was a reaction on rightclick * false: no reaction on rightclick */ - public EnumInteractionResult handlePlayerInteraction(final EntityHuman entityhuman, EnumHand enumhand, final ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(final net.minecraft.world.entity.player.Player entityhuman, InteractionHand enumhand, final ItemStack itemStack) { new BukkitRunnable() { @Override public void run() { - EntityPlayer player = ((EntityPlayer) entityhuman); + ServerPlayer player = ((ServerPlayer) entityhuman); if (player.getBukkitEntity().isOnline()) { - player.initMenu(entityhuman.bU); + player.initMenu(entityhuman.containerMenu); } } }.runTaskLater(MyPetApi.getPlugin(), 5); - if (itemStack != null && itemStack.getItem() == Items.rP) { - ((EntityPlayer) entityhuman).b.sendPacket(new PacketPlayOutAttachEntity(this, null)); + if (itemStack != null && itemStack.getItem() == Items.rP) { //TODO + ((ServerPlayer) entityhuman).connection.send(new ClientboundSetEntityLinkPacket(this, null)); } - if (enumhand == EnumHand.b) { - return EnumInteractionResult.a; + if (enumhand == InteractionHand.OFF_HAND) { + return InteractionResult.SUCCESS; } Player owner = this.getOwner().getPlayer(); @@ -520,7 +525,7 @@ public void run() { if (myPet.getSkills().isActive(RideImpl.class) && canMove()) { if (Permissions.hasExtended(owner, "MyPet.extended.ride")) { ((CraftPlayer) owner).getHandle().startRiding(this); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else { getOwner().sendMessage(Translation.getString("Message.No.CanUse", myPet.getOwner()), 2000); } @@ -528,21 +533,21 @@ public void run() { } if (Configuration.Skilltree.Skill.CONTROL_ITEM.compare(itemStack)) { if (myPet.getSkills().isActive(ControlImpl.class)) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } if (itemStack != null) { - if (itemStack.getItem() == Items.rQ && itemStack.hasName()) { + if (itemStack.getItem() == Items.NAME_TAG && itemStack.hasCustomHoverName()) { if (Permissions.has(getOwner(), "MyPet.command.name") && Permissions.hasExtended(getOwner(), "MyPet.extended.nametag")) { - final String name = itemStack.getName().getString(); + final String name = itemStack.getHoverName().getString(); getMyPet().setPetName(name); EntityMyPet.super.setCustomName(CraftChatMessage.fromStringOrNull("-")); myPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.Command.Name.New", myPet.getOwner()), name)); - if (!entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (!entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); } if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } new BukkitRunnable() { @Override @@ -550,17 +555,17 @@ public void run() { updateNameTag(); } }.runTaskLater(MyPetApi.getPlugin(), 1L); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } if (canEat(itemStack) && canUseItem()) { if (owner != null && !Permissions.hasExtended(owner, "MyPet.extended.feed")) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (this.petTargetSelector.hasGoal("DuelTarget")) { BehaviorDuelTarget duelTarget = (BehaviorDuelTarget) this.petTargetSelector.getGoal("DuelTarget"); if (duelTarget.getDuelOpponent() != null) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } boolean used = false; @@ -592,15 +597,15 @@ public void run() { } if (used) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - MyPetApi.getPlatformHelper().playParticleEffect(myPet.getLocation().get().add(0, getHeadHeight(), 0), ParticleCompat.HEART.get(), 0.5F, 0.5F, 0.5F, 0.5F, 5, 20); + MyPetApi.getPlatformHelper().playParticleEffect(myPet.getLocation().get().add(0, getEyeHeight(), 0), ParticleCompat.HEART.get(), 0.5F, 0.5F, 0.5F, 0.5F, 5, 20); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } } @@ -614,12 +619,12 @@ public void run() { command = command.replaceAll("%pet_uuid%", myPet.getUUID().toString()); command = command.replaceAll("%pet_world_group%", myPet.getWorldGroup()); command = command.replaceAll("%pet_skilltree_name%", myPet.getSkilltree() != null ? myPet.getSkilltree().getName() : ""); - return owner.performCommand(command) ? EnumInteractionResult.b : EnumInteractionResult.d; // TODO: 2021/06/28 PASS + return owner.performCommand(command) ? InteractionResult.CONSUME : InteractionResult.PASS; } } else { if (itemStack != null) { - if (itemStack.getItem() == Items.rQ) { - if (itemStack.hasName()) { + if (itemStack.getItem() == Items.NAME_TAG) { + if (itemStack.hasCustomHoverName()) { EntityMyPet.super.setCustomName(CraftChatMessage.fromStringOrNull("-")); new BukkitRunnable() { @Override @@ -627,19 +632,19 @@ public void run() { updateNameTag(); } }.runTaskLater(MyPetApi.getPlugin(), 1L); - return EnumInteractionResult.d; + return InteractionResult.PASS; } } } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } public void onLivingUpdate() { if (hasRider) { if (!isVehicle()) { hasRider = false; - this.G = 0.5F; // climb height -> halfslab + this.walkDistO = 0.5F; // climb height -> halfslab Location playerLoc = getOwner().getPlayer().getLocation(); Location petLoc = getBukkitEntity().getLocation(); petLoc.setYaw(playerLoc.getYaw()); @@ -649,9 +654,9 @@ public void onLivingUpdate() { } else { if (isVehicle()) { for (Entity e : this.getPassengers()) { - if (e instanceof EntityPlayer && getOwner().equals(e)) { + if (e instanceof ServerPlayer && getOwner().equals(e)) { hasRider = true; - this.G = 1.0F; // climb height -> 1 block + this.walkDistO = 1.0F; // climb height -> 1 block petTargetSelector.finish(); petPathfinderSelector.finish(); } else { @@ -661,13 +666,13 @@ public void onLivingUpdate() { } } if (sitPathfinder.isSitting() && sitCounter-- <= 0) { - MyPetApi.getPlatformHelper().playParticleEffect(getOwner().getPlayer(), this.getBukkitEntity().getLocation().add(0, getHeadHeight() + 1, 0), ParticleCompat.BARRIER.get(), 0F, 0F, 0F, 5F, 1, 32); + MyPetApi.getPlatformHelper().playParticleEffect(getOwner().getPlayer(), this.getBukkitEntity().getLocation().add(0, getEyeHeight() + 1, 0), ParticleCompat.BARRIER.get(), 0F, 0F, 0F, 5F, 1, 32); sitCounter = 60; } Player p = myPet.getOwner().getPlayer(); if (p != null && p.isOnline() && !p.isDead()) { - if (p.isSneaking() != isSneaking()) { - this.setSneaking(!isSneaking()); + if (p.isSneaking() != isShiftKeyDown()) { + this.setShiftKeyDown(!isShiftKeyDown()); } if (Configuration.Misc.INVISIBLE_LIKE_OWNER) { if (!isInvisible && p.hasPotionEffect(PotionEffectType.INVISIBILITY)) { @@ -701,10 +706,10 @@ public void setHealth(float f) { double deltaHealth = super.getHealth(); double maxHealth = myPet.getMaxHealth(); - boolean silent = this.getAttributeInstance(GenericAttributes.a).getValue() != maxHealth; - this.getAttributeInstance(GenericAttributes.a).setValue(maxHealth); + boolean silent = this.getAttribute(Attributes.MAX_HEALTH).getValue() != maxHealth; + this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(maxHealth); - super.setHealth(MathHelper.a(f, 0.0F, (float) maxHealth)); // Is that right? + super.setHealth(Mth.clamp(f, 0.0F, (float) maxHealth)); // Is that right? double health = getHealth(); if (deltaHealth > maxHealth) { @@ -757,7 +762,7 @@ public float getSoundSpeed() { pitchAddition += 0.5F; } } - return (this.Q.nextFloat() - this.Q.nextFloat()) * 0.2F + 1 + pitchAddition; + return (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1 + pitchAddition; } /** @@ -773,33 +778,33 @@ public float getSoundSpeed() { /** * Returns the sound that is played when the MyPet dies */ - protected abstract String getDeathSound(); + protected abstract String getDeathSound(); //TODO public void playPetStepSound() { } - public void playStepSound(BlockPosition blockposition, IBlockData blockdata) { + public void playMyPetStepSound(BlockPos blockposition, BlockState blockdata) { playPetStepSound(); } private void makeLivingSound() { if (getLivingSound() != null) { - SoundEffect se = IRegistry.T.get(new MinecraftKey(getLivingSound())); + SoundEvent se = Registry.SOUND_EVENT.get(new ResourceLocation(getLivingSound())); if (se != null) { - for (int j = 0; j < this.t.getPlayers().size(); ++j) { - EntityPlayer entityplayer = (EntityPlayer) this.t.getPlayers().get(j); + for (int j = 0; j < this.level.players().size(); ++j) { + ServerPlayer entityplayer = (ServerPlayer) this.level.players().get(j); float volume = 1f; if (MyPetApi.getPlayerManager().isMyPetPlayer(entityplayer.getBukkitEntity())) { volume = MyPetApi.getPlayerManager().getMyPetPlayer(entityplayer.getBukkitEntity()).getPetLivingSoundVolume(); } - double deltaX = locX() - entityplayer.locX(); - double deltaY = locY() - entityplayer.locY(); - double deltaZ = locZ() - entityplayer.locZ(); + double deltaX = getX() - entityplayer.getX(); + double deltaY = getY() - entityplayer.getY(); + double deltaZ = getZ() - entityplayer.getZ(); double maxDistance = volume > 1.0F ? (double) (16.0F * volume) : 16.0D; if (deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ < maxDistance * maxDistance) { - entityplayer.b.sendPacket(new PacketPlayOutNamedSoundEffect(se, SoundCategory.f, locX(), locY(), locZ(), volume, getSoundSpeed())); + entityplayer.connection.send(new ClientboundSoundPacket(se, SoundSource.HOSTILE, getX(), getY(), getZ(), volume, getSoundSpeed())); } } } else { @@ -822,68 +827,68 @@ private void ride(double motionSideways, double motionForward, double motionUpwa float speed; float swimmSpeed; - if (this.a(TagsFluid.b)) { - locY = this.locY(); + if (this.isEyeInFluid(FluidTags.WATER)) { + locY = this.getY(); speed = 0.8F; swimmSpeed = 0.02F; - this.a(swimmSpeed, new Vec3D(motionSideways, motionUpwards, motionForward)); - this.move(EnumMoveType.a, this.getMot()); - double motX = this.getMot().getX() * (double) speed; - double motY = this.getMot().getY() * 0.800000011920929D; - double motZ = this.getMot().getZ() * (double) speed; + this.moveRelative(swimmSpeed, new Vec3(motionSideways, motionUpwards, motionForward)); + this.move(MoverType.SELF, this.getDeltaMovement()); + double motX = this.getDeltaMovement().x() * (double) speed; + double motY = this.getDeltaMovement().y() * 0.800000011920929D; + double motZ = this.getDeltaMovement().z() * (double) speed; motY -= 0.02D; - if (this.A && this.f(this.getMot().getX(), this.getMot().getY() + 0.6000000238418579D - this.locY() + locY, this.getMot().getZ())) { + if (this.horizontalCollision && this.isFree(this.getDeltaMovement().x(), this.getDeltaMovement().y() + 0.6000000238418579D - this.getY() + locY, this.getDeltaMovement().z())) { motY = 0.30000001192092896D; } - this.setMot(motX, motY, motZ); - } else if (this.a(TagsFluid.c)) { - locY = this.locY(); - this.a(0.02F, new Vec3D(motionSideways, motionUpwards, motionForward)); - this.move(EnumMoveType.a, this.getMot()); - double motX = this.getMot().getX() * 0.5D; - double motY = this.getMot().getY() * 0.5D; - double motZ = this.getMot().getZ() * 0.5D; + this.setDeltaMovement(motX, motY, motZ); + } else if (this.isEyeInFluid(FluidTags.LAVA)) { + locY = this.getY(); + this.moveRelative(0.02F, new Vec3(motionSideways, motionUpwards, motionForward)); + this.move(MoverType.SELF, this.getDeltaMovement()); + double motX = this.getDeltaMovement().x() * 0.5D; + double motY = this.getDeltaMovement().y() * 0.5D; + double motZ = this.getDeltaMovement().z() * 0.5D; motY -= 0.02D; - if (this.A && this.f(this.getMot().getX(), this.getMot().getY() + 0.6000000238418579D - this.locY() + locY, this.getMot().getZ())) { + if (this.horizontalCollision && this.isFree(this.getDeltaMovement().x(), this.getDeltaMovement().y() + 0.6000000238418579D - this.getY() + locY, this.getDeltaMovement().z())) { motY = 0.30000001192092896D; } - this.setMot(motX, motY, motZ); + this.setDeltaMovement(motX, motY, motZ); } else { double minY; - minY = this.getBoundingBox().b; + minY = this.getBoundingBox().minY; float friction = 0.91F; - if (this.z) { - friction = this.t.getType(new BlockPosition(MathHelper.floor(this.locX()), MathHelper.floor(minY) - 1, MathHelper.floor(this.locZ()))).getBlock().getFrictionFactor() * 0.91F; + if (this.onGround) { + friction = this.level.getBlockState(new BlockPos(Mth.floor(this.getX()), Mth.floor(minY) - 1, Mth.floor(this.getZ()))).getBlock().getFriction() * 0.91F; } speed = speedModifier * (0.16277136F / (friction * friction * friction)); - this.a(speed, new Vec3D(motionSideways, motionUpwards, motionForward)); + this.moveRelative(speed, new Vec3(motionSideways, motionUpwards, motionForward)); friction = 0.91F; - if (this.z) { - friction = this.t.getType(new BlockPosition(MathHelper.floor(this.locX()), MathHelper.floor(minY) - 1, MathHelper.floor(this.locZ()))).getBlock().getFrictionFactor() * 0.91F; + if (this.onGround) { + friction = this.level.getBlockState(new BlockPos(Mth.floor(this.getX()), Mth.floor(minY) - 1, Mth.floor(this.getZ()))).getBlock().getFriction() * 0.91F; } - double motX = this.getMot().getX(); - double motY = this.getMot().getY(); - double motZ = this.getMot().getZ(); + double motX = this.getDeltaMovement().x(); + double motY = this.getDeltaMovement().y(); + double motZ = this.getDeltaMovement().z(); - if (this.isClimbing()) { + if (this.onClimbable()) { swimmSpeed = 0.16F; - motX = MathHelper.a(motX, -swimmSpeed, swimmSpeed); - motZ = MathHelper.a(motZ, -swimmSpeed, swimmSpeed); - this.J = 0.0F; + motX = Mth.clamp(motX, -swimmSpeed, swimmSpeed); + motZ = Mth.clamp(motZ, -swimmSpeed, swimmSpeed); + this.flyDist = 0.0F; if (motY < -0.16D) { motY = -0.16D; } } - Vec3D mot = new Vec3D(motX, motY, motZ); + Vec3 mot = new Vec3(motX, motY, motZ); - this.move(EnumMoveType.a, mot); - if (this.A && this.isClimbing()) { + this.move(MoverType.SELF, mot); + if (this.horizontalCollision && this.onClimbable()) { motY = 0.2D; } @@ -893,16 +898,16 @@ private void ride(double motionSideways, double motionForward, double motionUpwa motX *= friction; motZ *= friction; - this.setMot(motX, motY, motZ); + this.setDeltaMovement(motX, motY, motZ); } // is bird - this.a(this, false); + this.startRiding(this, false); } @Override public void makeSound(String sound, float volume, float pitch) { if (sound != null) { - SoundEffect se = IRegistry.T.get(new MinecraftKey(sound)); + SoundEvent se = Registry.SOUND_EVENT.get(new ResourceLocation(sound)); if (se != null) { this.playSound(se, volume, pitch); } else { @@ -915,7 +920,7 @@ public void makeSound(String sound, float volume, float pitch) { * do NOT drop anything */ @Override - protected boolean isDropExperience() { + protected boolean shouldDropExperience() { return false; } @@ -923,28 +928,28 @@ protected boolean isDropExperience() { * do NOT drop anything */ @Override - protected void dropDeathLoot(DamageSource damagesource, int i, boolean flag) { + protected void dropCustomDeathLoot(DamageSource damagesource, int i, boolean flag) { } // Obfuscated Methods ------------------------------------------------------------------------------------------- @Override - public net.minecraft.world.entity.EntitySize a(EntityPose entitypose) { + public EntityDimensions getDimensions(Pose entitypose) { EntitySize es = this.getClass().getAnnotation(EntitySize.class); if (es != null) { float width = es.width(); float height = java.lang.Float.isNaN(es.height()) ? width : es.height(); - return new net.minecraft.world.entity.EntitySize(width, height, false); + return new EntityDimensions(width, height, false); } - return super.a(entitypose); + return super.getDimensions(entitypose); } /** * Allows handlePlayerInteraction() to * be fired when a lead is used */ - @Override - public boolean a(EntityHuman entityhuman) { + @Override //TODO + public boolean canBeLeashed(net.minecraft.world.entity.player.Player entityhuman) { return false; } @@ -956,27 +961,27 @@ public boolean a(EntityHuman entityhuman) { * -> handlePlayerInteraction(EntityHuman) */ @Override - public EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) { + public InteractionResult mobInteract(net.minecraft.world.entity.player.Player entityhuman, InteractionHand enumhand) { try { - ItemStack itemstack = entityhuman.b(enumhand); - EnumInteractionResult result = handlePlayerInteraction(entityhuman, enumhand, itemstack); - if (!result.a() && getMyPet().getOwner().equals(entityhuman) && entityhuman.isSneaking()) { - result = EnumInteractionResult.a(toggleSitting()); + ItemStack itemstack = entityhuman.getItemInHand(enumhand); + InteractionResult result = handlePlayerInteraction(entityhuman, enumhand, itemstack); + if (!result.consumesAction() && getMyPet().getOwner().equals(entityhuman) && entityhuman.isShiftKeyDown()) { + result = InteractionResult.sidedSuccess(toggleSitting()); } return result; } catch (Exception e) { e.printStackTrace(); } - return EnumInteractionResult.d; + return InteractionResult.PASS; } /** * -> playStepSound() */ @Override - protected void b(BlockPosition blockposition, IBlockData iblockdata) { + protected void playStepSound(BlockPos blockposition, BlockState iblockdata) { try { - playStepSound(blockposition, iblockdata); + playMyPetStepSound(blockposition, iblockdata); } catch (Exception e) { e.printStackTrace(); } @@ -987,9 +992,9 @@ protected void b(BlockPosition blockposition, IBlockData iblockdata) { * -> getHurtSound() */ @Override - protected SoundEffect getSoundHurt(DamageSource damagesource) { + protected SoundEvent getHurtSound(DamageSource damagesource) { try { - return IRegistry.T.get(new MinecraftKey(getHurtSound())); + return Registry.SOUND_EVENT.get(new ResourceLocation(getHurtSound())); } catch (Exception e) { e.printStackTrace(); } @@ -998,12 +1003,11 @@ protected SoundEffect getSoundHurt(DamageSource damagesource) { /** * Returns the sound that is played when the MyPet dies - * -> getDeathSound() */ @Override - protected SoundEffect getSoundDeath() { + protected SoundEvent getDeathSound() { //TODO try { - return IRegistry.T.get(new MinecraftKey(getDeathSound())); + return Registry.SOUND_EVENT.get(new ResourceLocation(getDeathSound())); } catch (Exception e) { e.printStackTrace(); } @@ -1023,30 +1027,30 @@ protected float sp() { } @Override - public void movementTick() { //Speed-Probleme? + public void aiStep() { //Speed-Probleme? if (this.jumpDelay > 0) { --this.jumpDelay; } - if (this.dn()) { - this.bs = 0; - this.d(this.locX(), this.locY(), this.locZ()); + if (this.isAlwaysTicking()) { + this.lerpX = 0; + this.d(this.getX(), this.getY(), this.getZ()); } - if (this.bs > 0) { - double newX = this.locX() + (this.bA - this.locX()) / this.bs; - double newY = this.locY() + (this.bB - this.locY()) / this.bs; - double newZ = this.locZ() + (this.bC - this.locZ()) / this.bs; - double d3 = MathHelper.g(EntityMyPet.az - (double) this.getYRot()); - this.setYRot((float) ((double) this.getYRot() + d3 / this.bs)); - this.setXRot((float) ((double) this.getXRot() + (this.aT - (double) this.getXRot()) / this.bs)); - --this.bs; - this.setPosition(newX, newY, newZ); - this.setYawPitch(this.getYRot(), this.getXRot()); + if (this.lerpX > 0) { + double newX = this.getX() + (this.useItemRemaining - this.getX()) / this.lerpX; + double newY = this.getY() + (this.fallFlyTicks - this.getY()) / this.lerpX; + double newZ = this.getZ() + (this.autoSpinAttackTicks - this.getZ()) / this.lerpX; + double d3 = Mth.frac(this.az - (double) this.getYRot()); //TODO this area might be wrong in general (aR, aZ, aT) + this.setYRot((float) ((double) this.getYRot() + d3 / this.lerpX)); + this.setXRot((float) ((double) this.getXRot() + (this.animationPosition - (double) this.getXRot()) / this.lerpX)); + --this.lerpX; + this.setPos(newX, newY, newZ); + this.setRot(this.getYRot(), this.getXRot()); } else { - this.setMot(this.getMot().a(0.98D)); + this.setDeltaMovement(this.getDeltaMovement().a(0.98D)); } - Vec3D vec3d = this.getMot(); + Vec3D vec3d = this.getDeltaMovement(); double motX = vec3d.getX(); double motY = vec3d.getY(); double motZ = vec3d.getZ(); @@ -1063,27 +1067,27 @@ public void movementTick() { //Speed-Probleme? motZ = 0.0D; } - this.setMot(motX, motY, motZ); + this.setDeltaMovement(motX, motY, motZ); this.doMyPetTick(); - if (this.bn) { + if (this.jumping) { double d7; - if (this.aX()) { - d7 = this.b(TagsFluid.c); + if (this.isInLava()) { + d7 = this.b(FluidTags.LAVA);//TODO } else { - d7 = this.b(TagsFluid.b); + d7 = this.b(FluidTags.WATER); } boolean flag = this.isInWater() && d7 > 0.0D; - double d8 = this.cN(); - if (flag && (!this.z || d7 > d8)) { - this.c(TagsFluid.b); - } else if (this.aX() && (!this.z || d7 > d8)) { - this.c(TagsFluid.c); - } else if ((this.z || flag && d7 <= d8) && this.jumpDelay == 0) { - this.jump(); + double d8 = this.getFluidJumpThreshold(); + if (flag && (!this.onGround || d7 > d8)) { + this.c(FluidTags.WATER); + } else if (this.aX() && (!this.onGround || d7 > d8)) { + this.c(FluidTags.LAVA); + } else if ((this.onGround || flag && d7 <= d8) && this.jumpDelay == 0) { + this.jumpFromGround(); this.jumpDelay = 10; } } else { @@ -1094,8 +1098,8 @@ public void movementTick() { //Speed-Probleme? this.aT *= 0.98F; // this.n(); //no Elytra flight - this.f(new Vec3D(this.aR, this.aZ, this.aT)); - this.collideNearby(); + this.f(new Vec3(this.aR, this.aZ, this.aT)); + this.pushEntities(); } @Override @@ -1103,7 +1107,7 @@ protected boolean addPassenger(Entity entity) { boolean returnVal = false; // don't allow anything but the owner to ride this entity Ride rideSkill = myPet.getSkills().get(RideImpl.class); - if (rideSkill != null && entity instanceof EntityPlayer && getOwner().equals(entity)) { + if (rideSkill != null && entity instanceof ServerPlayer && getOwner().equals(entity)) { if (entity.getVehicle() != this) { throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)"); } else { @@ -1119,12 +1123,12 @@ protected boolean addPassenger(Entity entity) { } } - if (this instanceof IJumpable) { + if (this instanceof PlayerRideableJumping) { double factor = 1; if (Configuration.HungerSystem.USE_HUNGER_SYSTEM && Configuration.HungerSystem.AFFECT_RIDE_SPEED) { factor = Math.log10(myPet.getSaturation()) / 2; } - getAttributeInstance(GenericAttributes.d).setValue((0.22222F * (1F + (rideSkill.getSpeedIncrease().getValue() / 100F))) * factor); + getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue((0.22222F * (1F + (rideSkill.getSpeedIncrease().getValue() / 100F))) * factor); } } return returnVal; @@ -1146,21 +1150,21 @@ public static boolean callEvent(final CraftEntity player, final CraftMyPet pet) protected boolean removePassenger(Entity entity) { boolean result = super.removePassenger(entity); PlatformHelper platformHelper = (PlatformHelper) MyPetApi.getPlatformHelper(); - AxisAlignedBB bb = entity.getBoundingBox(); - bb = getBBAtPosition(bb, this.locX(), this.locY(), this.locZ()); - if (!platformHelper.canSpawn(getBukkitEntity().getLocation(), bb)) { - entity.a(this, true); + AABB bb = entity.getBoundingBox(); + bb = getBBAtPosition(bb, this.getX(), this.getY(), this.getZ()); + if (!platformHelper.canSpawn(getBukkitEntity().getLocation(), (MyPetMinecraftEntity) bb)) { + entity.startRiding(this, true); } else { - entity.setPosition(locX(), locY(), locZ()); + entity.setPos(getX(), getY(), getZ()); } return result; } - protected AxisAlignedBB getBBAtPosition(AxisAlignedBB bb, double x, double y, double z) { - double width = bb.b() / 2; - double height = bb.c(); - double depth = bb.d() / 2; - return new AxisAlignedBB(x - width, y, z - depth, x + width, y + height, z + width); + protected AABB getBBAtPosition(AABB bb, double x, double y, double z) { + double width = bb.getXsize() / 2; + double height = bb.getYsize(); + double depth = bb.getZsize() / 2; + return new AABB(x - width, y, z - depth, x + width, y + height, z + width); } /** @@ -1169,14 +1173,14 @@ protected AxisAlignedBB getBBAtPosition(AxisAlignedBB bb, double x, double y, do */ protected void doMyPetTick() { try { - ++this.bf; + ++this.noActionTime; if (isAlive()) { - getEntitySenses().a(); // sensing + getSensing().tick(); // sensing Player p = getOwner().getPlayer(); if (p == null || !p.isOnline()) { - this.die(); + this.discard(); return; } @@ -1187,7 +1191,7 @@ protected void doMyPetTick() { } Ride rideSkill = myPet.getSkills().get(RideImpl.class); - if (this.z && rideSkill.getFlyLimit().getValue().doubleValue() > 0) { + if (this.onGround && rideSkill.getFlyLimit().getValue().doubleValue() > 0) { limitCounter += rideSkill.getFlyRegenRate().getValue().doubleValue(); if (limitCounter > rideSkill.getFlyLimit().getValue().doubleValue()) { limitCounter = rideSkill.getFlyLimit().getValue().floatValue(); @@ -1195,12 +1199,12 @@ protected void doMyPetTick() { } } - mobTick(); + customServerAiStep(); // controls - getControllerMove().a(); // move - getControllerLook().a(); // look - getControllerJump().b(); // jump + getMoveControl().tick(); // move + getLookControl().tick(); // look + getJumpControl().tick(); // jump } catch (Exception e) { e.printStackTrace(); } @@ -1210,7 +1214,7 @@ protected void doMyPetTick() { * MyPets are not persistant so no data needs to be saved */ @Override - public boolean d(NBTTagCompound nbttagcompound) { + public boolean saveAsPassenger(CompoundTag nbttagcompound) { return false; } @@ -1218,9 +1222,9 @@ public boolean d(NBTTagCompound nbttagcompound) { * -> falldamage */ @Override - public int d(float f, float f1) { + public int calculateFallDamage(float f, float f1) { if (!this.isFlying) { - return super.d(f, f1); + return super.calculateFallDamage(f, f1); } return 0; } @@ -1229,21 +1233,21 @@ public int d(float f, float f1) { /** * -> travel */ - public void f(Vec3D vec3d) { + public void f(Vec3 vec3d) { if (!hasRider || !this.isVehicle()) { g(vec3d); return; } - if (this.z && this.isFlying) { + if (this.onGround && this.isFlying) { isFlying = false; - this.J = 0; + this.flyDist = 0; } - EntityLiving passenger = (EntityLiving) this.getFirstPassenger(); + LivingEntity passenger = (LivingEntity) this.getFirstPassenger(); - if (this.a(TagsFluid.b)) { - this.setMot(this.getMot().add(0, 0.4, 0)); + if (this.isEyeInFluid(FluidTags.WATER)) { + this.setDeltaMovement(this.getDeltaMovement().add(0, 0.4, 0)); } Ride rideSkill = myPet.getSkills().get(RideImpl.class); @@ -1253,16 +1257,16 @@ public void f(Vec3D vec3d) { } //apply pitch & yaw - this.x = passenger.getYRot(); + this.yRotO = passenger.getYRot(); this.setYRot(passenger.getYRot()); this.setXRot(passenger.getXRot() * 0.5F); - setYawPitch(this.getYRot(), this.getXRot()); - this.bg = (this.aX = this.getYRot()); + setRot(this.getYRot(), this.getXRot()); + this.oRun = (this.yBodyRot = this.getYRot()); //TODO Got the right fields, now speed is something // get motion from passenger (player) - double motionSideways = passenger.bo; - double motionForward = passenger.bq * 2; + double motionSideways = passenger.xxa; + double motionForward = passenger.zza * 2; // backwards is slower if (motionForward <= 0.0F) { @@ -1280,15 +1284,15 @@ public void f(Vec3D vec3d) { ascendSpeed *= factor; } - ride(motionSideways, motionForward, vec3d.getY(), speed); // apply motion + ride(motionSideways, motionForward, vec3d.y(), speed); // apply motion // throw player move event if (Configuration.Misc.THROW_PLAYER_MOVE_EVENT_WHILE_RIDING && !(this instanceof EntityMyHorse)) { - double delta = Math.pow(this.locX() - this.u, 2.0D) + Math.pow(this.locY() - this.v, 2.0D) + Math.pow(this.locZ() - this.w, 2.0D); - float deltaAngle = Math.abs(this.getYRot() - x) + Math.abs(this.getXRot() - y); + double delta = Math.pow(this.getX() - this.xo, 2.0D) + Math.pow(this.getY() - this.yo, 2.0D) + Math.pow(this.getZ() - this.zo, 2.0D); + float deltaAngle = Math.abs(this.getYRot() - yRotO) + Math.abs(this.getXRot() - xRotO); if (delta > 0.00390625D || deltaAngle > 10.0F) { Location to = getBukkitEntity().getLocation(); - Location from = new Location(t.getWorld(), this.u, this.v, this.w, this.x, this.y); + Location from = new Location(level.getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO); if (from.getX() != Double.MAX_VALUE) { Location oldTo = to.clone(); PlayerMoveEvent event = new PlayerMoveEvent((Player) passenger.getBukkitEntity(), from, to); @@ -1306,13 +1310,12 @@ public void f(Vec3D vec3d) { } if (jump != null && this.isVehicle()) { - this.getBlockJumpFactor(); // TODO why? boolean doJump = false; - if (this instanceof IJumpable) { + if (this instanceof PlayerRideableJumping) { if (this.jumpPower > 0.0F) { doJump = true; this.jumpPower = 0.0F; - } else if (!this.z && jump != null) { + } else if (!this.onGround && jump != null) { try { doJump = jump.getBoolean(passenger); } catch (IllegalAccessException ignored) { @@ -1328,15 +1331,15 @@ public void f(Vec3D vec3d) { } if (doJump) { - if (z) { + if (onGround) { jumpHeight = new BigDecimal(jumpHeight).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); String jumpHeightString = JumpHelper.JUMP_FORMAT.format(jumpHeight); Double jumpVelocity = JumpHelper.JUMP_MAP.get(jumpHeightString); jumpVelocity = jumpVelocity == null ? 0.44161199999510264 : jumpVelocity; - if (this instanceof IJumpable) { - getAttributeInstance(GenericAttributes.m).setValue(jumpVelocity); + if (this instanceof PlayerRideableJumping) { + getAttribute(Attributes.JUMP_STRENGTH).setBaseValue(jumpVelocity); } - this.setMot(this.getMot().getX(), jumpVelocity, this.getMot().getZ()); + this.setDeltaMovement(this.getDeltaMovement().x(), jumpVelocity, this.getDeltaMovement().z()); } else if (rideSkill.getCanFly().getValue()) { if (limitCounter <= 0 && rideSkill.getFlyLimit().getValue().doubleValue() > 0) { canFly = false; @@ -1348,9 +1351,9 @@ public void f(Vec3D vec3d) { flyCheckCounter = 5; } if (canFly) { - if (this.getMot().getY() < ascendSpeed) { - this.setMot(this.getMot().getX(), ascendSpeed, this.getMot().getZ()); - this.J = 0; + if (this.getDeltaMovement().y() < ascendSpeed) { + this.setDeltaMovement(this.getDeltaMovement().x(), ascendSpeed, this.getDeltaMovement().z()); + this.flyDist = 0; this.isFlying = true; } } @@ -1395,7 +1398,7 @@ public void tick() { * -> getLivingSound() */ @Override - protected SoundEffect getSoundAmbient() { + protected SoundEvent getAmbientSound() { try { if (getLivingSound() != null && playIdleSound()) { makeLivingSound(); @@ -1408,15 +1411,15 @@ protected SoundEffect getSoundAmbient() { } @Override - protected void d(DamageSource damagesource) { + protected void d(DamageSource damagesource) { //TODO Check LivingEntity! CraftEventFactory.callEntityDeathEvent(this); } @Override - public DamageSource dW() { + public DamageSource getLastDamageSource() { if (deathReason != null) { return deathReason; } - return super.dW(); + return super.getLastDamageSource(); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPetPart.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPetPart.java index 0e973521e3..0659968641 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPetPart.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPetPart.java @@ -23,51 +23,49 @@ import de.Keyle.MyPet.api.entity.MyPetMinecraftEntity; import de.Keyle.MyPet.api.entity.MyPetMinecraftPart; import de.Keyle.MyPet.api.util.ReflectionUtil; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityPose; -import net.minecraft.world.entity.EntitySize; -import net.minecraft.world.entity.EntityTypes; +import net.minecraft.world.entity.EntityDimensions; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Pose; public class EntityMyPetPart extends Entity implements MyPetMinecraftPart { public final EntityMyPet owner; - private final EntitySize size; + private final EntityDimensions size; private final String part; protected CraftMyPetPart bukkitEntity = null; public EntityMyPetPart(EntityMyPet owner, String part, float width, float height) { - super(EntityTypes.v, owner.t); - ReflectionUtil.setFieldValue("bukkitEntity", this, new CraftMyPetPart(this.t.getCraftServer(), this)); + super(EntityType.ENDER_DRAGON, owner.level); + ReflectionUtil.setFieldValue("bukkitEntity", this, new CraftMyPetPart(this.level.getCraftServer(), this)); this.owner = owner; this.part = part; - this.size = EntitySize.b(width, height); + this.size = EntityDimensions.scalable(width, height); } @Override - protected void initDatawatcher() { + protected void defineSynchedData() { } - @Override - public boolean isInteractable() { + public boolean isPickable() { return true; } @Override - protected void loadData(NBTTagCompound nbtTagCompound) { - + public void load(CompoundTag nbtTagCompound) { } @Override - protected void saveData(NBTTagCompound nbtTagCompound) { - + public boolean save(CompoundTag nbtTagCompound) { + return true; } @Override - public boolean damageEntity(DamageSource var1, float var2) { + public boolean hurt(DamageSource var1, float var2) { return false; } @@ -77,12 +75,12 @@ public boolean q(Entity var1) { } @Override - public Packet getPacket() { + public Packet getAddEntityPacket() { throw new UnsupportedOperationException(); } @Override - public EntitySize a(EntityPose entitypose) { + public EntityDimensions getDimensions(Pose entitypose) { return this.size; } @@ -94,7 +92,7 @@ public MyPetMinecraftEntity getPetOwner() { @Override public CraftMyPetPart getBukkitEntity() { if (this.bukkitEntity == null) { - this.bukkitEntity = new CraftMyPetPart(this.t.getCraftServer(), this); + this.bukkitEntity = new CraftMyPetPart(this.level.getCraftServer(), this); } return this.bukkitEntity; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityRegistry.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityRegistry.java index 5b5ddccdc0..8b9be6b43a 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityRegistry.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityRegistry.java @@ -20,8 +20,19 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; +import org.bukkit.event.entity.CreatureSpawnEvent; + import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Util; import de.Keyle.MyPet.api.entity.MyPet; @@ -30,47 +41,32 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.api.util.ReflectionUtil; import lombok.SneakyThrows; -import net.minecraft.core.IRegistry; -import net.minecraft.core.RegistryBlocks; -import net.minecraft.core.RegistryMaterials; -import net.minecraft.resources.MinecraftKey; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.EntitySize; -import net.minecraft.world.entity.EntityTypes; -import net.minecraft.world.entity.EnumCreatureType; -import net.minecraft.world.entity.animal.EntityFox; -import net.minecraft.world.level.World; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; -import org.bukkit.event.entity.CreatureSpawnEvent; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; +import net.minecraft.core.DefaultedRegistry; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.level.Level; @Compat("v1_17_R1") public class EntityRegistry extends de.Keyle.MyPet.api.entity.EntityRegistry { BiMap> entityClasses = HashBiMap.create(); - Map entityTypes = new HashMap<>(); + Map entityTypes = new HashMap<>(); - protected void registerEntityType(MyPetType petType, String key, RegistryBlocks> entityRegistry) { //TODO 2021/08/19 The only thing left: They need to follow the player - EntityTypes types = (EntityTypes) entityRegistry.get(new MinecraftKey(key)); + protected void registerEntityType(MyPetType petType, String key, DefaultedRegistry> entityRegistry) { //TODO 2021/08/19 The only thing left: They need to follow the player + EntityType types = (EntityType) entityRegistry.get(new ResourceLocation(key)); entityTypes.put(petType, types); registerDefaultAttributes(entityTypes.get(petType), types); overwriteEntityID(entityTypes.get(petType), getEntityTypeId(petType, entityRegistry), entityRegistry); } @SneakyThrows - public static void registerDefaultAttributes(EntityTypes customType, EntityTypes rootType) { - MyAttributeDefaults.registerCustomEntityTypes(customType, rootType); + public static void registerDefaultAttributes(EntityType customType, EntityType rootType) { + MyAttributeDefaults.registerCustomEntityType(customType, rootType); } - protected void registerEntity(MyPetType type, RegistryBlocks> entityRegistry) { + protected void registerEntity(MyPetType type, DefaultedRegistry> entityRegistry) { Class entityClass = ReflectionUtil.getClass("de.Keyle.MyPet.compat.v1_17_R1.entity.types.EntityMy" + type.name()); entityClasses.forcePut(type, entityClass); @@ -86,10 +82,10 @@ public MyPetType getMyPetType(Class clazz) { public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bukkitWorld) { EntityMyPet petEntity = null; Class entityClass = entityClasses.get(pet.getPetType()); - World world = ((CraftWorld) bukkitWorld).getHandle(); + Level world = ((CraftWorld) bukkitWorld).getHandle(); try { - Constructor ctor = entityClass.getConstructor(World.class, MyPet.class); + Constructor ctor = entityClass.getConstructor(Level.class, MyPet.class); Object obj = ctor.newInstance(world, pet); if (obj instanceof EntityMyPet) { petEntity = (EntityMyPet) obj; @@ -105,7 +101,7 @@ public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bu @Override public boolean spawnMinecraftEntity(MyPetMinecraftEntity entity, org.bukkit.World bukkitWorld) { if (entity != null) { - World world = ((CraftWorld) bukkitWorld).getHandle(); + Level world = ((CraftWorld) bukkitWorld).getHandle(); return world.addEntity(((EntityMyPet) entity), CreatureSpawnEvent.SpawnReason.CUSTOM); } return false; @@ -113,7 +109,7 @@ public boolean spawnMinecraftEntity(MyPetMinecraftEntity entity, org.bukkit.Worl @Override public void registerEntityTypes() { - RegistryBlocks> entityRegistry = getRegistry(IRegistry.Y); + DefaultedRegistry> entityRegistry = getRegistry(Registry.ENTITY_TYPE); for (MyPetType type : MyPetType.all()) { registerEntity(type, entityRegistry); } @@ -127,16 +123,16 @@ public T getEntityType(MyPetType petType) { public void unregisterEntityTypes() { } - public RegistryBlocks> getRegistry(RegistryBlocks registryMaterials) { - if (!registryMaterials.getClass().getName().equals(RegistryBlocks.class.getName())) { + public DefaultedRegistry> getRegistry(DefaultedRegistry registryMaterials) { + if (!registryMaterials.getClass().getName().equals(DefaultedRegistry.class.getName())) { MyPetApi.getLogger().info("Custom entity registry found: " + registryMaterials.getClass().getName()); for (Field field : registryMaterials.getClass().getDeclaredFields()) { - if (field.getType() == RegistryMaterials.class) { + if (field.getType() == DefaultedRegistry.class) { field.setAccessible(true); try { - RegistryBlocks> reg = (RegistryBlocks>) field.get(registryMaterials); + DefaultedRegistry> reg = (DefaultedRegistry>) field.get(registryMaterials); - if (!reg.getClass().getName().equals(RegistryBlocks.class.getName())) { + if (!reg.getClass().getName().equals(DefaultedRegistry.class.getName())) { reg = getRegistry(reg); } @@ -150,11 +146,11 @@ public RegistryBlocks> getRegistry(RegistryBlocks registryMateria return registryMaterials; } - protected void overwriteEntityID(EntityTypes types, int id, RegistryBlocks> entityRegistry) { + protected void overwriteEntityID(EntityType types, int id, DefaultedRegistry> entityRegistry) { try { - Field bgF = RegistryMaterials.class.getDeclaredField("bw"); + Field bgF = DefaultedRegistry.class.getDeclaredField("bw"); //TODO Might fail. bgF.setAccessible(true); Object map = bgF.get(entityRegistry); Class clazz = map.getClass(); @@ -168,8 +164,8 @@ protected void overwriteEntityID(EntityTypes types, int id, RegistryBlocks> entityRegistry) { - EntityTypes types = entityRegistry.get(new MinecraftKey(type.getTypeID().toString())); + protected int getEntityTypeId(MyPetType type, DefaultedRegistry> entityRegistry) { + EntityType types = entityRegistry.get(new ResourceLocation(type.getTypeID().toString())); return entityRegistry.getId(types); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/MyAttributeDefaults.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/MyAttributeDefaults.java index 0d48472154..d86cee908e 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/MyAttributeDefaults.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/MyAttributeDefaults.java @@ -22,170 +22,178 @@ import java.util.HashMap; -import net.minecraft.world.entity.EntityInsentient; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.EntityTypes; +import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.GlowSquid; -import net.minecraft.world.entity.ai.attributes.AttributeProvider; -import net.minecraft.world.entity.ambient.EntityBat; -import net.minecraft.world.entity.animal.EntityBee; -import net.minecraft.world.entity.animal.EntityCat; -import net.minecraft.world.entity.animal.EntityChicken; -import net.minecraft.world.entity.animal.EntityCow; -import net.minecraft.world.entity.animal.EntityDolphin; -import net.minecraft.world.entity.animal.EntityFish; -import net.minecraft.world.entity.animal.EntityFox; -import net.minecraft.world.entity.animal.EntityIronGolem; -import net.minecraft.world.entity.animal.EntityOcelot; -import net.minecraft.world.entity.animal.EntityPanda; -import net.minecraft.world.entity.animal.EntityParrot; -import net.minecraft.world.entity.animal.EntityPig; -import net.minecraft.world.entity.animal.EntityPolarBear; -import net.minecraft.world.entity.animal.EntityRabbit; -import net.minecraft.world.entity.animal.EntitySheep; -import net.minecraft.world.entity.animal.EntitySnowman; -import net.minecraft.world.entity.animal.EntitySquid; -import net.minecraft.world.entity.animal.EntityTurtle; -import net.minecraft.world.entity.animal.EntityWolf; +import net.minecraft.world.entity.ai.attributes.AttributeSupplier; +import net.minecraft.world.entity.ambient.Bat; +import net.minecraft.world.entity.animal.Bee; +import net.minecraft.world.entity.animal.Cat; +import net.minecraft.world.entity.animal.Chicken; +import net.minecraft.world.entity.animal.Cod; +import net.minecraft.world.entity.animal.Cow; +import net.minecraft.world.entity.animal.Dolphin; +import net.minecraft.world.entity.animal.Fox; +import net.minecraft.world.entity.animal.IronGolem; +import net.minecraft.world.entity.animal.Ocelot; +import net.minecraft.world.entity.animal.Panda; +import net.minecraft.world.entity.animal.Parrot; +import net.minecraft.world.entity.animal.Pig; +import net.minecraft.world.entity.animal.PolarBear; +import net.minecraft.world.entity.animal.Pufferfish; +import net.minecraft.world.entity.animal.Rabbit; +import net.minecraft.world.entity.animal.Salmon; +import net.minecraft.world.entity.animal.Sheep; +import net.minecraft.world.entity.animal.SnowGolem; +import net.minecraft.world.entity.animal.Squid; +import net.minecraft.world.entity.animal.TropicalFish; +import net.minecraft.world.entity.animal.Turtle; +import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.animal.axolotl.Axolotl; import net.minecraft.world.entity.animal.goat.Goat; -import net.minecraft.world.entity.animal.horse.EntityHorse; -import net.minecraft.world.entity.animal.horse.EntityHorseDonkey; -import net.minecraft.world.entity.animal.horse.EntityHorseMule; -import net.minecraft.world.entity.animal.horse.EntityHorseSkeleton; -import net.minecraft.world.entity.animal.horse.EntityHorseZombie; -import net.minecraft.world.entity.animal.horse.EntityLlama; -import net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon; -import net.minecraft.world.entity.boss.wither.EntityWither; -import net.minecraft.world.entity.decoration.EntityArmorStand; -import net.minecraft.world.entity.monster.EntityBlaze; -import net.minecraft.world.entity.monster.EntityCaveSpider; -import net.minecraft.world.entity.monster.EntityCreeper; -import net.minecraft.world.entity.monster.EntityEnderman; -import net.minecraft.world.entity.monster.EntityEndermite; -import net.minecraft.world.entity.monster.EntityEvoker; -import net.minecraft.world.entity.monster.EntityGhast; -import net.minecraft.world.entity.monster.EntityGiantZombie; -import net.minecraft.world.entity.monster.EntityGuardian; -import net.minecraft.world.entity.monster.EntityGuardianElder; -import net.minecraft.world.entity.monster.EntityIllagerIllusioner; -import net.minecraft.world.entity.monster.EntityMagmaCube; -import net.minecraft.world.entity.monster.EntityMonster; -import net.minecraft.world.entity.monster.EntityPigZombie; -import net.minecraft.world.entity.monster.EntityPillager; -import net.minecraft.world.entity.monster.EntityRavager; -import net.minecraft.world.entity.monster.EntityShulker; -import net.minecraft.world.entity.monster.EntitySilverfish; -import net.minecraft.world.entity.monster.EntitySkeletonAbstract; -import net.minecraft.world.entity.monster.EntitySpider; -import net.minecraft.world.entity.monster.EntityStrider; -import net.minecraft.world.entity.monster.EntityVex; -import net.minecraft.world.entity.monster.EntityVindicator; -import net.minecraft.world.entity.monster.EntityWitch; -import net.minecraft.world.entity.monster.EntityZoglin; -import net.minecraft.world.entity.monster.EntityZombie; -import net.minecraft.world.entity.monster.hoglin.EntityHoglin; -import net.minecraft.world.entity.monster.piglin.EntityPiglin; -import net.minecraft.world.entity.monster.piglin.EntityPiglinBrute; -import net.minecraft.world.entity.npc.EntityVillager; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.animal.horse.Donkey; +import net.minecraft.world.entity.animal.horse.Horse; +import net.minecraft.world.entity.animal.horse.Llama; +import net.minecraft.world.entity.animal.horse.Mule; +import net.minecraft.world.entity.animal.horse.SkeletonHorse; +import net.minecraft.world.entity.animal.horse.TraderLlama; +import net.minecraft.world.entity.animal.horse.ZombieHorse; +import net.minecraft.world.entity.boss.enderdragon.EnderDragon; +import net.minecraft.world.entity.boss.wither.WitherBoss; +import net.minecraft.world.entity.decoration.ArmorStand; +import net.minecraft.world.entity.monster.Blaze; +import net.minecraft.world.entity.monster.CaveSpider; +import net.minecraft.world.entity.monster.Creeper; +import net.minecraft.world.entity.monster.ElderGuardian; +import net.minecraft.world.entity.monster.EnderMan; +import net.minecraft.world.entity.monster.Endermite; +import net.minecraft.world.entity.monster.Evoker; +import net.minecraft.world.entity.monster.Ghast; +import net.minecraft.world.entity.monster.Giant; +import net.minecraft.world.entity.monster.Guardian; +import net.minecraft.world.entity.monster.Husk; +import net.minecraft.world.entity.monster.Illusioner; +import net.minecraft.world.entity.monster.MagmaCube; +import net.minecraft.world.entity.monster.Phantom; +import net.minecraft.world.entity.monster.Pillager; +import net.minecraft.world.entity.monster.Ravager; +import net.minecraft.world.entity.monster.Shulker; +import net.minecraft.world.entity.monster.Silverfish; +import net.minecraft.world.entity.monster.Skeleton; +import net.minecraft.world.entity.monster.Slime; +import net.minecraft.world.entity.monster.Spider; +import net.minecraft.world.entity.monster.Stray; +import net.minecraft.world.entity.monster.Strider; +import net.minecraft.world.entity.monster.Vex; +import net.minecraft.world.entity.monster.Vindicator; +import net.minecraft.world.entity.monster.Witch; +import net.minecraft.world.entity.monster.WitherSkeleton; +import net.minecraft.world.entity.monster.Zoglin; +import net.minecraft.world.entity.monster.Zombie; +import net.minecraft.world.entity.monster.ZombieVillager; +import net.minecraft.world.entity.monster.ZombifiedPiglin; +import net.minecraft.world.entity.monster.hoglin.Hoglin; +import net.minecraft.world.entity.monster.piglin.Piglin; +import net.minecraft.world.entity.monster.piglin.PiglinBrute; +import net.minecraft.world.entity.npc.Villager; +import net.minecraft.world.entity.npc.WanderingTrader; +import net.minecraft.world.entity.player.Player; public class MyAttributeDefaults { - private static final FastMap, AttributeProvider> defaultAttribute = new FastMap<>(); + private static final FastMap, AttributeSupplier> defaultAttribute = new FastMap<>(); static { defaultAttribute - .putFast(EntityTypes.c, EntityArmorStand.dq().a()) //Armor-Stand - .putFast(EntityTypes.e, Axolotl.fE().a()) //Axolotl - .putFast(EntityTypes.f, EntityBat.n().a()) //Bat - .putFast(EntityTypes.g, EntityBee.fJ().a()) //Bee - .putFast(EntityTypes.h, EntityBlaze.n().a()) //Blaze - .putFast(EntityTypes.j, EntityCat.fK().a()) //Cat - .putFast(EntityTypes.k, EntityCaveSpider.n().a()) //CaveSpider - .putFast(EntityTypes.l, EntityChicken.p().a()) //Chicken - .putFast(EntityTypes.m, EntityFish.n().a()) //Cod - .putFast(EntityTypes.n, EntityCow.p().a()) //Cow - .putFast(EntityTypes.o, EntityCreeper.n().a()) //Creeper - .putFast(EntityTypes.p, EntityDolphin.fw().a()) //Dolphin - .putFast(EntityTypes.q, EntityHorseDonkey.t().a()) //Donkey - .putFast(EntityTypes.s, EntityZombie.fB().a()) //Drowned - .putFast(EntityTypes.t, EntityGuardianElder.n().a()) //Elder Guardian - .putFast(EntityTypes.w, EntityEnderman.n().a()) //Enderman - .putFast(EntityTypes.x, EntityEndermite.n().a()) //Endermite - .putFast(EntityTypes.v, EntityEnderDragon.n().a()) //Ender Dragon - .putFast(EntityTypes.y, EntityEvoker.p().a()) //Evoker - .putFast(EntityTypes.E, EntityFox.p().a()) //Fox - .putFast(EntityTypes.F, EntityGhast.t().a()) //Ghast - .putFast(EntityTypes.G, EntityGiantZombie.n().a()) //Giant - .putFast(EntityTypes.K, EntityGuardian.fw().a()) //Guardian - .putFast(EntityTypes.J, Goat.p().a()) //Goat - .putFast(EntityTypes.I, GlowSquid.fw().a()) //GlowSquid - .putFast(EntityTypes.L, EntityHoglin.p().a()) //Hoglin - .putFast(EntityTypes.M, EntityHorse.fS().a()) //Horse - .putFast(EntityTypes.N, EntityZombie.fB().a()) //Husk - .putFast(EntityTypes.O, EntityIllagerIllusioner.p().a()) //Illusioner - .putFast(EntityTypes.P, EntityIronGolem.n().a()) //Iron Golem - .putFast(EntityTypes.V, EntityLlama.gg().a()) //Llama - .putFast(EntityTypes.X, EntityMagmaCube.n().a()) //Magma Cube - .putFast(EntityTypes.ah, EntityCow.p().a()) //Mooshroom - .putFast(EntityTypes.ag, EntityHorseMule.t().a()) //Mule - .putFast(EntityTypes.ai, EntityOcelot.p().a()) //Ocelot - .putFast(EntityTypes.ak, EntityPanda.fI().a()) //Panda - .putFast(EntityTypes.al, EntityParrot.fE().a()) //Parrot - .putFast(EntityTypes.am, EntityMonster.fB().a()) //Phantom - .putFast(EntityTypes.an, EntityPig.p().a()) //Pig - .putFast(EntityTypes.ao, EntityPiglin.fB().a()) //Piglin - .putFast(EntityTypes.ap, EntityPiglinBrute.fB().a()) //Piglin Brute - .putFast(EntityTypes.aq, EntityPillager.p().a()) //Pillager - .putFast(EntityTypes.bi, EntityHuman.eY().a()) //Player - .putFast(EntityTypes.ar, EntityPolarBear.p().a()) //PolarBear - .putFast(EntityTypes.at, EntityFish.n().a()) //Pufferfish - .putFast(EntityTypes.au, EntityRabbit.t().a()) //Rabbit - .putFast(EntityTypes.av, EntityRavager.n().a()) //Ravager - .putFast(EntityTypes.aw, EntityFish.n().a()) //Salmon - .putFast(EntityTypes.ax, EntitySheep.p().a()) //Sheep - .putFast(EntityTypes.ay, EntityShulker.n().a()) //Shulker - .putFast(EntityTypes.aA, EntitySilverfish.n().a()) //Silverfish - .putFast(EntityTypes.aB, EntitySkeletonAbstract.n().a()) //Skeleton - .putFast(EntityTypes.aC, EntityHorseSkeleton.t().a()) //Skeleton Horse - .putFast(EntityTypes.aD, EntityMonster.fB().a()) //Slime - .putFast(EntityTypes.aF, EntitySnowman.n().a()) //Snow Golem - .putFast(EntityTypes.aI, EntitySpider.p().a()) //Spider - .putFast(EntityTypes.aJ, EntitySquid.fw().a()) //Squid - .putFast(EntityTypes.aK, EntitySkeletonAbstract.n().a()) //Stray - .putFast(EntityTypes.aL, EntityStrider.fw().a()) //Strider - .putFast(EntityTypes.aR, EntityLlama.gg().a()) //Trader_Llama - .putFast(EntityTypes.aS, EntityFish.n().a()) //Tropical Fish - .putFast(EntityTypes.aT, EntityTurtle.fw().a()) //Turtle - .putFast(EntityTypes.aU, EntityVex.n().a()) //Vex - .putFast(EntityTypes.aV, EntityVillager.fI().a()) //Villager - .putFast(EntityTypes.aW, EntityVindicator.p().a()) //Vindicator - .putFast(EntityTypes.aX, EntityInsentient.w().a()) //Wandering Trader - .putFast(EntityTypes.aY, EntityWitch.p().a()) //Witch - .putFast(EntityTypes.aZ, EntityWither.p().a()) //Wither - .putFast(EntityTypes.ba, EntitySkeletonAbstract.n().a()) //Wither Skeleton - .putFast(EntityTypes.bc, EntityWolf.fE().a()) //Wolf - .putFast(EntityTypes.bd, EntityZoglin.n().a()) //Zoglin - .putFast(EntityTypes.be, EntityZombie.fB().a()) //Zombie - .putFast(EntityTypes.bf, EntityHorseZombie.t().a()) //Zombie Horse - .putFast(EntityTypes.bg, EntityZombie.fB().a()) //Zombie Villager - .putFast(EntityTypes.bh, EntityPigZombie.fG().a()); //Zombie Piglin + .putFast(EntityType.ARMOR_STAND, ArmorStand.createLivingAttributes().build()) //Armor-Stand + .putFast(EntityType.AXOLOTL, Axolotl.createAttributes().build()) //Axolotl + .putFast(EntityType.BAT, Bat.createAttributes().build()) //Bat + .putFast(EntityType.BEE, Bee.createAttributes().build()) //Bee + .putFast(EntityType.BLAZE, Blaze.createAttributes().build()) //Blaze + .putFast(EntityType.CAT, Cat.createAttributes().build()) //Cat + .putFast(EntityType.CAVE_SPIDER, CaveSpider.createAttributes().build()) //CaveSpider + .putFast(EntityType.CHICKEN, Chicken.createAttributes().build()) //Chicken + .putFast(EntityType.COD, Cod.createAttributes().build()) //Cod + .putFast(EntityType.COW, Cow.createAttributes().build()) //Cow + .putFast(EntityType.CREEPER, Creeper.createAttributes().build()) //Creeper + .putFast(EntityType.DOLPHIN, Dolphin.createAttributes().build()) //Dolphin + .putFast(EntityType.DONKEY, Donkey.createLivingAttributes().build()) //Donkey + .putFast(EntityType.ZOMBIE, Zombie.createAttributes().build()) //Drowned + .putFast(EntityType.ELDER_GUARDIAN, ElderGuardian.createAttributes().build()) //Elder Guardian + .putFast(EntityType.ENDERMAN, EnderMan.createAttributes().build()) //Enderman + .putFast(EntityType.ENDERMITE, Endermite.createAttributes().build()) //Endermite + .putFast(EntityType.ENDER_DRAGON, EnderDragon.createAttributes().build()) //Ender Dragon + .putFast(EntityType.EVOKER, Evoker.createAttributes().build()) //Evoker + .putFast(EntityType.FOX, Fox.createAttributes().build()) //Fox + .putFast(EntityType.GHAST, Ghast.createAttributes().build()) //Ghast + .putFast(EntityType.GIANT, Giant.createAttributes().build()) //Giant + .putFast(EntityType.GUARDIAN, Guardian.createAttributes().build()) //Guardian + .putFast(EntityType.GOAT, Goat.createAttributes().build()) //Goat + .putFast(EntityType.GLOW_SQUID, GlowSquid.createAttributes().build()) //GlowSquid + .putFast(EntityType.HOGLIN, Hoglin.createAttributes().build()) //Hoglin + .putFast(EntityType.HORSE, Horse.createBaseHorseAttributes().build()) //Horse + .putFast(EntityType.HUSK, Husk.createAttributes().build()) //Husk + .putFast(EntityType.ILLUSIONER, Illusioner.createAttributes().build()) //Illusioner + .putFast(EntityType.IRON_GOLEM, IronGolem.createAttributes().build()) //Iron Golem + .putFast(EntityType.LLAMA, Llama.createAttributes().build()) //Llama + .putFast(EntityType.MAGMA_CUBE, MagmaCube.createAttributes().build()) //Magma Cube + .putFast(EntityType.COW, Cow.createAttributes().build()) //Mooshroom + .putFast(EntityType.MULE, Mule.createLivingAttributes().build()) //Mule + .putFast(EntityType.OCELOT, Ocelot.createAttributes().build()) //Ocelot + .putFast(EntityType.PANDA, Panda.createAttributes().build()) //Panda + .putFast(EntityType.PARROT, Parrot.createAttributes().build()) //Parrot + .putFast(EntityType.PHANTOM, Phantom.createLivingAttributes().build()) //Phantom + .putFast(EntityType.PIG, Pig.createAttributes().build()) //Pig + .putFast(EntityType.PIGLIN, Piglin.createAttributes().build()) //Piglin + .putFast(EntityType.PIGLIN_BRUTE, PiglinBrute.createAttributes().build()) //Piglin Brute + .putFast(EntityType.PILLAGER, Pillager.createAttributes().build()) //Pillager + .putFast(EntityType.PLAYER, Player.createAttributes().build()) //Player + .putFast(EntityType.POLAR_BEAR, PolarBear.createAttributes().build()) //PolarBear + .putFast(EntityType.PUFFERFISH, Pufferfish.createAttributes().build()) //Pufferfish + .putFast(EntityType.RABBIT, Rabbit.createAttributes().build()) //Rabbit + .putFast(EntityType.RAVAGER, Ravager.createAttributes().build()) //Ravager + .putFast(EntityType.SALMON, Salmon.createAttributes().build()) //Salmon + .putFast(EntityType.SHEEP, Sheep.createAttributes().build()) //Sheep + .putFast(EntityType.SHULKER, Shulker.createAttributes().build()) //Shulker + .putFast(EntityType.SILVERFISH, Silverfish.createAttributes().build()) //Silverfish + .putFast(EntityType.SKELETON, Skeleton.createAttributes().build()) //Skeleton + .putFast(EntityType.SKELETON_HORSE, SkeletonHorse.createAttributes().build()) //Skeleton Horse + .putFast(EntityType.SLIME, Slime.createLivingAttributes().build()) //Slime + .putFast(EntityType.SNOW_GOLEM, SnowGolem.createAttributes().build()) //Snow Golem + .putFast(EntityType.SPIDER, Spider.createAttributes().build()) //Spider + .putFast(EntityType.SQUID, Squid.createAttributes().build()) //Squid + .putFast(EntityType.STRAY, Stray.createAttributes().build()) //Stray + .putFast(EntityType.STRIDER, Strider.createAttributes().build()) //Strider + .putFast(EntityType.TRADER_LLAMA, TraderLlama.createAttributes().build()) //Trader_Llama + .putFast(EntityType.TROPICAL_FISH, TropicalFish.createAttributes().build()) //Tropical Fish + .putFast(EntityType.TURTLE, Turtle.createAttributes().build()) //Turtle + .putFast(EntityType.VEX, Vex.createAttributes().build()) //Vex + .putFast(EntityType.VILLAGER, Villager.createAttributes().build()) //Villager + .putFast(EntityType.VINDICATOR, Vindicator.createAttributes().build()) //Vindicator + .putFast(EntityType.WANDERING_TRADER, WanderingTrader.createLivingAttributes().build()) //Wandering Trader + .putFast(EntityType.WITCH, Witch.createAttributes().build()) //Witch + .putFast(EntityType.WITHER, WitherBoss.createAttributes().build()) //Wither + .putFast(EntityType.WITHER_SKELETON, WitherSkeleton.createAttributes().build()) //Wither Skeleton + .putFast(EntityType.WOLF, Wolf.createAttributes().build()) //Wolf + .putFast(EntityType.ZOGLIN, Zoglin.createAttributes().build()) //Zoglin + .putFast(EntityType.ZOMBIE, Zombie.createAttributes().build()) //Zombie + .putFast(EntityType.ZOMBIE_HORSE, ZombieHorse.createAttributes().build()) //Zombie Horse + .putFast(EntityType.ZOMBIE_VILLAGER, ZombieVillager.createAttributes().build()) //Zombie Villager + .putFast(EntityType.ZOMBIFIED_PIGLIN, ZombifiedPiglin.createAttributes().build()); //Zombie Piglin } - public static AttributeProvider getAttribute(EntityTypes types) { + public static AttributeSupplier getAttribute(EntityType types) { return defaultAttribute.get(types); } - public static void registerCustomEntityTypes(EntityTypes customType, EntityTypes rootType) { + public static void registerCustomEntityType(EntityType customType, EntityType rootType) { defaultAttribute.put(customType, getAttribute(rootType)); } static class FastMap extends HashMap { - public FastMap putFast(K key, V value) { - put(key, value); + public FastMap putFast(K key, AttributeSupplier attributeSupplier) { + put(key, (V) attributeSupplier); return this; } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/MeleeAttack.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/MeleeAttack.java index 756c641d1d..4f4ac3d90a 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/MeleeAttack.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/MeleeAttack.java @@ -20,6 +20,8 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack; +import org.bukkit.entity.LivingEntity; + import de.Keyle.MyPet.api.entity.EquipmentSlot; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.MyPetEquipment; @@ -27,20 +29,17 @@ import de.Keyle.MyPet.api.skill.skills.Behavior; import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.server.level.EntityPlayer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.EntityTameableAnimal; -import net.minecraft.world.entity.decoration.EntityArmorStand; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; -import org.bukkit.entity.LivingEntity; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.decoration.ArmorStand; @Compat("v1_17_R1") public class MeleeAttack implements AIGoal { MyPet myPet; EntityMyPet petEntity; - EntityLiving targetEntity; + net.minecraft.world.entity.LivingEntity targetEntity; double range; float walkSpeedModifier; private int ticksUntilNextHitLeft = 0; @@ -63,12 +62,12 @@ public boolean shouldStart() { if (!this.petEntity.hasTarget()) { return false; } - EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + net.minecraft.world.entity.LivingEntity targetEntity = this.petEntity.getTarget(); - if (targetEntity instanceof EntityArmorStand) { + if (targetEntity instanceof ArmorStand) { return false; } - if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.h(targetEntity.locX(), targetEntity.getBoundingBox().b, targetEntity.locZ()) >= 20) { + if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.distanceToSqr(targetEntity.getX(), targetEntity.getBoundingBox().minY, targetEntity.getY()) >= 20) { return false; } @@ -78,13 +77,13 @@ public boolean shouldStart() { return false; } if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Raid) { - if (targetEntity instanceof EntityTameableAnimal && ((EntityTameableAnimal) targetEntity).isTamed()) { + if (targetEntity instanceof TamableAnimal && ((TamableAnimal) targetEntity).isTame()) { return false; } if (targetEntity instanceof EntityMyPet) { return false; } - if (targetEntity instanceof EntityPlayer) { + if (targetEntity instanceof ServerPlayer) { return false; } } @@ -97,10 +96,10 @@ public boolean shouldStart() { public boolean shouldFinish() { if (!this.petEntity.hasTarget() || !this.petEntity.canMove()) { return true; - } else if (this.targetEntity.getBukkitEntity() != this.petEntity.getTarget()) { + } else if (this.targetEntity.getBukkitEntity() != this.petEntity.getMyPetTarget()) { return true; } - if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.h(targetEntity.locX(), targetEntity.getBoundingBox().b, targetEntity.locZ()) >= 20) { + if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.distanceToSqr(targetEntity.getX(), targetEntity.getBoundingBox().minY, targetEntity.getZ()) >= 20) { return true; } @@ -110,13 +109,13 @@ public boolean shouldFinish() { return true; } if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Raid) { - if (this.targetEntity instanceof EntityTameableAnimal && ((EntityTameableAnimal) this.targetEntity).isTamed()) { + if (this.targetEntity instanceof TamableAnimal && ((TamableAnimal) this.targetEntity).isTame()) { return true; } if (this.targetEntity instanceof EntityMyPet) { return true; } - return this.targetEntity instanceof EntityPlayer; + return this.targetEntity instanceof ServerPlayer; } } return false; @@ -125,7 +124,7 @@ public boolean shouldFinish() { @Override public void start() { this.petEntity.getPetNavigation().getParameters().addSpeedModifier("MeleeAttack", walkSpeedModifier); - this.petEntity.getPetNavigation().navigateTo((LivingEntity) this.targetEntity.getBukkitEntity()); + this.petEntity.getPetNavigation().navigateTo((LivingEntity) this.targetEntity.getBukkitEntity()); //TODO Location? this.timeUntilNextNavigationUpdate = 0; } @@ -138,17 +137,17 @@ public void finish() { @Override public void tick() { - this.petEntity.getControllerLook().a(targetEntity, 30.0F, 30.0F); + this.petEntity.getLookControl().setLookAt(targetEntity, 30.0F, 30.0F); if (--this.timeUntilNextNavigationUpdate <= 0) { this.timeUntilNextNavigationUpdate = (4 + this.petEntity.getRandom().nextInt(7)); this.petEntity.getPetNavigation().navigateTo((LivingEntity) targetEntity.getBukkitEntity()); } - if (this.petEntity.h(targetEntity.locX(), targetEntity.getBoundingBox().b, targetEntity.locZ()) - (targetEntity.getHeight() * (2. / 3.)) <= this.range && this.ticksUntilNextHitLeft-- <= 0) { - if (this.petEntity.getEntitySenses().a(targetEntity)) { + if (this.petEntity.distanceToSqr(targetEntity.getX(), targetEntity.getBoundingBox().minY, targetEntity.getZ()) - (targetEntity.getBbHeight() * (2. / 3.)) <= this.range && this.ticksUntilNextHitLeft-- <= 0) { + if (this.petEntity.getSensing().hasLineOfSight(targetEntity)) { this.ticksUntilNextHitLeft = ticksUntilNextHit; if (this.petEntity instanceof MyPetEquipment) { if (((MyPetEquipment) this.petEntity).getEquipment(EquipmentSlot.MainHand) != null) { - this.petEntity.swingHand(EnumHand.a); // -> swingItem() + this.petEntity.swing(InteractionHand.MAIN_HAND); // -> swingItem() } } this.petEntity.attack(targetEntity); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java index eb42acf194..aa78dee8c6 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java @@ -27,22 +27,30 @@ import de.Keyle.MyPet.api.skill.skills.Ranged.Projectile; import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.*; -import net.minecraft.server.level.EntityPlayer; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.EntityTameableAnimal; -import net.minecraft.world.entity.decoration.EntityArmorStand; -import net.minecraft.world.entity.projectile.EntityArrow; -import net.minecraft.world.level.World; +import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetArrow; +import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetDragonFireball; +import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetEgg; +import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetEnderPearl; +import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetLargeFireball; +import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetLlamaSpit; +import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetSmallFireball; +import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetSnowball; +import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetTrident; +import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetWitherSkull; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.decoration.ArmorStand; +import net.minecraft.world.entity.projectile.Arrow; +import net.minecraft.world.level.Level; import net.royawesome.jlibnoise.MathHelper; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; @Compat("v1_17_R1") public class RangedAttack implements AIGoal { private final MyPet myPet; private final EntityMyPet entityMyPet; - private EntityLiving target; + private LivingEntity target; private int shootTimer; private final float walkSpeedModifier; private int lastSeenTimer; @@ -69,13 +77,13 @@ public boolean shouldStart() { return false; } - EntityLiving target = ((CraftLivingEntity) this.entityMyPet.getTarget()).getHandle(); + LivingEntity target = this.entityMyPet.getTarget(); - if (target instanceof EntityArmorStand) { + if (target instanceof ArmorStand) { return false; } double meleeDamage = myPet.getDamage(); - if (meleeDamage > 0 && this.entityMyPet.h(target.locX(), target.getBoundingBox().b, target.locZ()) < 4) { + if (meleeDamage > 0 && this.entityMyPet.h(target.getX(), target.getBoundingBox().minY, target.getZ()) < 4) { Ranged rangedSkill = myPet.getSkills().get(Ranged.class); if (meleeDamage > rangedSkill.getDamage().getValue().doubleValue()) { return false; @@ -88,13 +96,13 @@ public boolean shouldStart() { return false; } if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Raid) { - if (target instanceof EntityTameableAnimal && ((EntityTameableAnimal) target).isTamed()) { + if (target instanceof TamableAnimal && ((TamableAnimal) target).isTamed()) { return false; } if (target instanceof EntityMyPet) { return false; } - if (target instanceof EntityPlayer) { + if (target instanceof ServerPlayer) { return false; } } @@ -108,11 +116,11 @@ public boolean shouldFinish() { if (!entityMyPet.hasTarget() || myPet.getRangedDamage() <= 0 || !entityMyPet.canMove()) { return true; } - if (this.target.getBukkitEntity() != entityMyPet.getTarget()) { + if (this.target != entityMyPet.getTarget()) { return true; } double meleeDamage = myPet.getDamage(); - if (meleeDamage > 0 && this.entityMyPet.h(target.locX(), this.target.getBoundingBox().b, target.locZ()) < 4) { + if (meleeDamage > 0 && this.entityMyPet.h(target.getX(), this.target.getBoundingBox().minY, target.getZ()) < 4) { Ranged rangedSkill = myPet.getSkills().get(Ranged.class); if (meleeDamage > rangedSkill.getDamage().getValue().doubleValue()) { return true; @@ -125,13 +133,13 @@ public boolean shouldFinish() { return true; } if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Raid) { - if (this.target instanceof EntityTameableAnimal && ((EntityTameableAnimal) this.target).isTamed()) { + if (this.target instanceof TamableAnimal && ((TamableAnimal) this.target).isTamed()) { return true; } if (this.target instanceof EntityMyPet) { return true; } - return this.target instanceof EntityPlayer; + return this.target instanceof ServerPlayer; } } return false; @@ -147,8 +155,8 @@ public void finish() { @Override public void tick() { - double distanceToTarget = this.entityMyPet.h(this.target.locX(), this.target.getBoundingBox().b, this.target.locZ()); - boolean canSee = this.entityMyPet.getEntitySenses().a(this.target); // a -> canSee + double distanceToTarget = this.entityMyPet.h(this.target.getX(), this.target.getBoundingBox().minY, this.target.getZ()); + boolean canSee = this.entityMyPet.getSensing().a(this.target); // a -> canSee if (canSee) { this.lastSeenTimer++; @@ -164,7 +172,7 @@ public void tick() { this.entityMyPet.getPetNavigation().navigateTo(this.target.getBukkitEntity().getLocation()); } - this.entityMyPet.getControllerLook().a(this.target, 30.0F, 30.0F); + this.entityMyPet.getLookControl().a(this.target, 30.0F, 30.0F); if (--this.shootTimer <= 0) { if (distanceToTarget < this.range && canSee) { @@ -183,76 +191,76 @@ private Projectile getProjectile() { return Projectile.Arrow; } - public void shootProjectile(EntityLiving target, float damage, Projectile projectile) { - World world = target.t; + public void shootProjectile(LivingEntity target, float damage, Projectile projectile) { + Level world = target.t; - double minY = this.target.getBoundingBox().b; + double minY = this.target.getBoundingBox().minY; switch (projectile) { case Snowball: { MyPetSnowball snowball = new MyPetSnowball(world, entityMyPet); - double distanceX = target.locX() - entityMyPet.locX(); + double distanceX = target.getX() - entityMyPet.getX(); double distanceY = target.locY() + target.getHeadHeight() - 1.100000023841858D - snowball.locY(); - double distanceZ = target.locZ() - entityMyPet.locZ(); + double distanceZ = target.getZ() - entityMyPet.getZ(); double distance20percent = MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2F; snowball.setDamage(damage); snowball.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1); entityMyPet.makeSound("entity.arrow.shoot", 0.5F, 0.4F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F)); - world.addEntity(snowball); + world.addFreshEntity(snowball); break; } case Egg: { MyPetEgg egg = new MyPetEgg(world, entityMyPet); - double distanceX = target.locX() - entityMyPet.locX(); + double distanceX = target.getX() - entityMyPet.getX(); double distanceY = target.locY() + target.getHeadHeight() - 1.100000023841858D - egg.locY(); - double distanceZ = target.locZ() - entityMyPet.locZ(); + double distanceZ = target.getZ() - entityMyPet.getZ(); double distance20percent = MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2F; egg.setDamage(damage); egg.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1); entityMyPet.makeSound("entity.arrow.shoot", 0.5F, 0.4F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F)); - world.addEntity(egg); + world.addFreshEntity(egg); break; } case LargeFireball: { - double distanceX = this.target.locX() - entityMyPet.locX(); + double distanceX = this.target.getX() - entityMyPet.getX(); double distanceY = minY + (double) (this.target.getHeight() / 2.0F) - (0.5D + entityMyPet.locY() + (double) (entityMyPet.getHeight() / 2.0F)); - double distanceZ = this.target.locZ() - entityMyPet.locZ(); + double distanceZ = this.target.getZ() - entityMyPet.getZ(); MyPetLargeFireball largeFireball = new MyPetLargeFireball(world, entityMyPet, distanceX, distanceY, distanceZ); - largeFireball.setPositionRaw(largeFireball.locX(), (entityMyPet.locY() + entityMyPet.getHeight() / 2.0F + 0.5D), largeFireball.locZ()); + largeFireball.setPositionRaw(largeFireball.getX(), (entityMyPet.locY() + entityMyPet.getHeight() / 2.0F + 0.5D), largeFireball.getZ()); largeFireball.setDamage(damage); - world.addEntity(largeFireball); + world.addFreshEntity(largeFireball); entityMyPet.makeSound("entity.ghast.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F); break; } case SmallFireball: { - double distanceX = this.target.locX() - entityMyPet.locX(); + double distanceX = this.target.getX() - entityMyPet.getX(); double distanceY = minY + (this.target.getHeight() / 2.0F) - (0.5D + entityMyPet.locY() + (entityMyPet.getHeight() / 2.0F)); - double distanceZ = this.target.locZ() - entityMyPet.locZ(); + double distanceZ = this.target.getZ() - entityMyPet.getZ(); MyPetSmallFireball smallFireball = new MyPetSmallFireball(world, entityMyPet, distanceX, distanceY, distanceZ); - smallFireball.setPositionRaw(smallFireball.locX(), (entityMyPet.locY() + entityMyPet.getHeight() / 2.0F + 0.5D), smallFireball.locZ()); + smallFireball.setPositionRaw(smallFireball.getX(), (entityMyPet.locY() + entityMyPet.getHeight() / 2.0F + 0.5D), smallFireball.getZ()); smallFireball.setDamage(damage); - world.addEntity(smallFireball); + world.addFreshEntity(smallFireball); entityMyPet.makeSound("entity.ghast.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F); break; } case WitherSkull: { - double distanceX = this.target.locX() - entityMyPet.locX(); + double distanceX = this.target.getX() - entityMyPet.getX(); double distanceY = minY + (double) (this.target.getHeight() / 2.0F) - (0.5D + entityMyPet.locY() + (double) (entityMyPet.getHeight() / 2.0F)); - double distanceZ = this.target.locZ() - entityMyPet.locZ(); + double distanceZ = this.target.getZ() - entityMyPet.getZ(); MyPetWitherSkull witherSkull = new MyPetWitherSkull(world, entityMyPet, distanceX, distanceY, distanceZ); - witherSkull.setPositionRaw(witherSkull.locX(), (entityMyPet.locY() + entityMyPet.getHeight() / 2.0F + 0.5D), witherSkull.locZ()); + witherSkull.setPositionRaw(witherSkull.getX(), (entityMyPet.locY() + entityMyPet.getHeight() / 2.0F + 0.5D), witherSkull.getZ()); witherSkull.setDamage(damage); - world.addEntity(witherSkull); + world.addFreshEntity(witherSkull); entityMyPet.makeSound("entity.wither.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F); break; } case DragonFireball: { - double distanceX = this.target.locX() - entityMyPet.locX(); + double distanceX = this.target.getX() - entityMyPet.getX(); double distanceY = minY + (double) (this.target.getHeight() / 2.0F) - (0.5D + entityMyPet.locY() + (double) (entityMyPet.getHeight() / 2.0F)); - double distanceZ = this.target.locZ() - entityMyPet.locZ(); + double distanceZ = this.target.getZ() - entityMyPet.getZ(); MyPetDragonFireball dragonFireball = new MyPetDragonFireball(world, entityMyPet, distanceX, distanceY, distanceZ); - dragonFireball.setPositionRaw(dragonFireball.locX(), (entityMyPet.locY() + entityMyPet.getHeight() / 2.0F + 0.5D), dragonFireball.locZ()); + dragonFireball.setPositionRaw(dragonFireball.getX(), (entityMyPet.locY() + entityMyPet.getHeight() / 2.0F + 0.5D), dragonFireball.getZ()); dragonFireball.setDamage(damage); - world.addEntity(dragonFireball); + world.addFreshEntity(dragonFireball); entityMyPet.makeSound("entity.ender_dragon.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F); break; } @@ -261,50 +269,50 @@ public void shootProjectile(EntityLiving target, float damage, Projectile projec trident.setDamage(damage); trident.setCritical(false); entityMyPet.makeSound("item.trident.throw", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F)); - double distanceX = target.locX() - entityMyPet.locX(); + double distanceX = target.getX() - entityMyPet.getX(); double distanceY = target.locY() + target.getHeadHeight() - 1.100000023841858D - trident.locY(); - double distanceZ = target.locZ() - entityMyPet.locZ(); + double distanceZ = target.getZ() - entityMyPet.getZ(); double distance20percent = MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2F; trident.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1); - world.addEntity(trident); + world.addFreshEntity(trident); break; } case EnderPearl: { MyPetEnderPearl enderPearl = new MyPetEnderPearl(world, entityMyPet); enderPearl.setDamage(damage); entityMyPet.makeSound("entity.ender_pearl.throw", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F)); - double distanceX = target.locX() - entityMyPet.locX(); + double distanceX = target.getX() - entityMyPet.getX(); double distanceY = target.locY() + target.getHeadHeight() - 1.100000023841858D - enderPearl.locY(); - double distanceZ = target.locZ() - entityMyPet.locZ(); + double distanceZ = target.getZ() - entityMyPet.getZ(); double distance20percent = MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2F; enderPearl.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1); - world.addEntity(enderPearl); + world.addFreshEntity(enderPearl); break; } case LlamaSpit: { MyPetLlamaSpit llamaSpit = new MyPetLlamaSpit(world, entityMyPet); llamaSpit.setDamage(damage); entityMyPet.makeSound("entity.llama.spit", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F)); - double distanceX = target.locX() - entityMyPet.locX(); + double distanceX = target.getX() - entityMyPet.getX(); double distanceY = target.locY() + (target.getHeadHeight() / 3.0F) - llamaSpit.locY(); - double distanceZ = target.locZ() - entityMyPet.locZ(); + double distanceZ = target.getZ() - entityMyPet.getZ(); double distance20percent = MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2D; llamaSpit.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.5F, 10.0F); - world.addEntity(llamaSpit); + world.addFreshEntity(llamaSpit); break; } case Arrow: default: { - EntityArrow arrow = new MyPetArrow(world, entityMyPet); + MyPetArrow arrow = new MyPetArrow(world, entityMyPet); arrow.setDamage(damage); arrow.setCritical(false); entityMyPet.makeSound("entity.arrow.shoot", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F)); - double distanceX = target.locX() - entityMyPet.locX(); + double distanceX = target.getX() - entityMyPet.getX(); double distanceY = target.locY() + target.getHeadHeight() - 1.100000023841858D - arrow.locY(); - double distanceZ = target.locZ() - entityMyPet.locZ(); + double distanceZ = target.getZ() - entityMyPet.getZ(); double distance20percent = MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2F; arrow.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1); - world.addEntity(arrow); + world.addFreshEntity(arrow); break; } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java index b320548125..86e1da5734 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java @@ -40,7 +40,7 @@ public class EatGrass implements AIGoal { private final EntityMySheep entityMySheep; - private final World world; + private final Level world; int eatTicks = 0; private static final Predicate GRASS = BlockStatePredicate.a(Blocks.aX); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/navigation/VanillaNavigation.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/navigation/VanillaNavigation.java index 1cb9b4240c..61935bfc4d 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/navigation/VanillaNavigation.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/navigation/VanillaNavigation.java @@ -20,42 +20,40 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.ai.navigation; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; +import org.bukkit.entity.LivingEntity; + import de.Keyle.MyPet.api.entity.ai.navigation.AbstractNavigation; import de.Keyle.MyPet.api.entity.ai.navigation.NavigationParameters; import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.ai.attributes.GenericAttributes; -import net.minecraft.world.entity.ai.navigation.Navigation; - -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; -import org.bukkit.entity.LivingEntity; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.ai.navigation.PathNavigation; @Compat("v1_17_R1") public class VanillaNavigation extends AbstractNavigation { - Navigation nav; + PathNavigation nav; public VanillaNavigation(EntityMyPet entityMyPet) { super(entityMyPet); - nav = (Navigation) entityMyPet.getNavigation(); + nav = (PathNavigation) entityMyPet.getNavigation(); } public VanillaNavigation(EntityMyPet entityMyPet, NavigationParameters parameters) { super(entityMyPet, parameters); - nav = (Navigation) entityMyPet.getNavigation(); + nav = (PathNavigation) entityMyPet.getNavigation(); } @Override public void stop() { - nav.q(); + nav.stop(); } @Override public boolean navigateTo(double x, double y, double z) { applyNavigationParameters(); - if (this.nav.a(x, y, z, 1.D)) { + if (this.nav.moveTo(x, y, z, 1.D)) { applyNavigationParameters(); return true; } @@ -67,8 +65,8 @@ public boolean navigateTo(LivingEntity entity) { return navigateTo(((CraftLivingEntity) entity).getHandle()); } - public boolean navigateTo(EntityLiving entity) { - if (this.nav.a(entity, 1.D)) { + public boolean navigateTo(net.minecraft.world.entity.LivingEntity entity) { + if (this.nav.moveTo(entity, 1.D)) { applyNavigationParameters(); return true; } @@ -77,14 +75,14 @@ public boolean navigateTo(EntityLiving entity) { @Override public void tick() { - nav.c(); + nav.tick(); } @Override public void applyNavigationParameters() { - this.nav.a(parameters.avoidWater()); + this.nav.setCanFloat(parameters.avoidWater()); ((EntityMyPet) this.entityMyPet) - .getAttributeInstance(GenericAttributes.d) - .setValue(parameters.speed() + parameters.speedModifier()); + .getAttribute(Attributes.MOVEMENT_SPEED) + .setBaseValue(parameters.speed() + parameters.speedModifier()); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java index efb7892f46..bfb3304916 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java @@ -24,17 +24,17 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.level.World; @EntitySize(width = 0.5F, height = 0.45f) public class EntityMyBat extends EntityMyPet { - private static final DataWatcherObject HANGING_WATCHER = DataWatcher.a(EntityMyBat.class, DataWatcherRegistry.a); + private static final EntityDataAccessor HANGING_WATCHER = SynchedEntityData.defineId(EntityMyBat.class, EntityDataSerializers.BYTE); - public EntityMyBat(World world, MyPet myPet) { + public EntityMyBat(Level world, MyPet myPet) { super(world, myPet); } @@ -67,17 +67,17 @@ public float getSoundSpeed() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(HANGING_WATCHER, (byte) 0xFFFFFFFE); // hanging + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(HANGING_WATCHER, (byte) 0xFFFFFFFE); // hanging } @Override public void onLivingUpdate() { super.onLivingUpdate(); if (Configuration.MyPet.Bat.CAN_GLIDE) { - if (!this.z && this.getMot().getY() < 0.0D) { - this.setMot(getMot().d(1, 0.6D, 1)); + if (!this.onGround && this.getDeltaMovement().y() < 0.0D) { + this.setDeltaMovement(getDeltaMovement().multiply(1, 0.6D, 1)); } } } @@ -86,7 +86,7 @@ public void onLivingUpdate() { * -> disable falldamage */ @Override - public int d(float f, float f1) { + public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Bat.CAN_GLIDE) { super.e(f, f1); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBee.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBee.java index 3a4616225b..d02c8cd44b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBee.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBee.java @@ -27,21 +27,21 @@ import de.Keyle.MyPet.api.skill.skills.Behavior; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.skill.skills.BehaviorImpl; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.level.World; @EntitySize(width = 0.6F, height = 0.6f) public class EntityMyBee extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyBee.class, DataWatcherRegistry.i); - private static final DataWatcherObject BEE_STATUS_WATCHER = DataWatcher.a(EntityMyBee.class, DataWatcherRegistry.a); - private static final DataWatcherObject ANGER_WATCHER = DataWatcher.a(EntityMyBee.class, DataWatcherRegistry.b); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyBee.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor BEE_STATUS_WATCHER = SynchedEntityData.defineId(EntityMyBee.class, EntityDataSerializers.BYTE); + private static final EntityDataAccessor ANGER_WATCHER = SynchedEntityData.defineId(EntityMyBee.class, EntityDataSerializers.INT); protected boolean isAngry = false; - public EntityMyBee(World world, MyPet myPet) { + public EntityMyBee(Level world, MyPet myPet) { super(world, myPet); } @@ -72,17 +72,17 @@ public float getSoundSpeed() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(BEE_STATUS_WATCHER, (byte) 0); - getDataWatcher().register(ANGER_WATCHER, 0); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(BEE_STATUS_WATCHER, (byte) 0); + getEntityData().define(ANGER_WATCHER, 0); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); - this.getDataWatcher().set(ANGER_WATCHER, (getMyPet().isAngry() || isAngry) ? 1 : 0); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(ANGER_WATCHER, (getMyPet().isAngry() || isAngry) ? 1 : 0); this.setBeeStatus(8, getMyPet().hasNectar()); this.setBeeStatus(4, getMyPet().hasStung()); } @@ -111,8 +111,8 @@ public MyBee getMyPet() { public void onLivingUpdate() { super.onLivingUpdate(); if (Configuration.MyPet.Bee.CAN_GLIDE) { - if (!this.z && this.getMot().getY() < 0.0D) { - this.setMot(getMot().d(1, 0.6D, 1)); + if (!this.onGround && this.getDeltaMovement().y() < 0.0D) { + this.setDeltaMovement(getDeltaMovement().multiply(1, 0.6D, 1)); } } } @@ -139,7 +139,7 @@ protected void doMyPetTick() { * -> disable falldamage */ @Override - public int d(float f, float f1) { + public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Bee.CAN_GLIDE) { super.e(f, f1); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBlaze.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBlaze.java index 394433ae3e..548be315e0 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBlaze.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBlaze.java @@ -20,30 +20,31 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.UUID; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyBlaze; import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; - -import java.lang.reflect.InvocationTargetException; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.7F) public class EntityMyBlaze extends EntityMyPet { - private static final DataWatcherObject BURNING_WATCHER = DataWatcher.a(EntityMyBlaze.class, DataWatcherRegistry.a); + private static final EntityDataAccessor BURNING_WATCHER = SynchedEntityData.defineId(EntityMyBlaze.class, EntityDataSerializers.BYTE); - public EntityMyBlaze(World world, MyPet myPet) { + public EntityMyBlaze(Level world, MyPet myPet) { super(world, myPet); } @@ -63,35 +64,35 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack) == EnumInteractionResult.b) { - return EnumInteractionResult.b; + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack) == InteractionResult.CONSUME) { + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { - if (getMyPet().isOnFire() && itemStack.getItem() == Items.nX && getOwner().getPlayer().isSneaking()) { + if (getMyPet().isOnFire() && itemStack.getItem() == Items.WATER_BUCKET && getOwner().getPlayer().isSneaking()) { getMyPet().setOnFire(false); makeSound("block.fire.extinguish", 1.0F, 1.0F); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().flying) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, new ItemStack(Items.nW)); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, new ItemStack(Items.BUCKET)); } else { - if (!entityhuman.getInventory().pickup(new ItemStack(Items.nW))) { - entityhuman.drop(new ItemStack(Items.nW), true); + if (!entityhuman.getInventory().add(new ItemStack(Items.BUCKET))) { + entityhuman.drop(new ItemStack(Items.BUCKET), true); } } } - return EnumInteractionResult.b; - } else if (!getMyPet().isOnFire() && itemStack.getItem() == Items.me && getOwner().getPlayer().isSneaking()) { + return InteractionResult.CONSUME; + } else if (!getMyPet().isOnFire() && itemStack.getItem() == Items.FLINT_AND_STEEL && getOwner().getPlayer().isSneaking()) { getMyPet().setOnFire(true); makeSound("item.flintandsteel.use", 1.0F, 1.0F); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -100,29 +101,29 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En }); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(BURNING_WATCHER, (byte) 0); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(BURNING_WATCHER, (byte) 0); } @Override public void updateVisuals() { - getDataWatcher().set(BURNING_WATCHER, (byte) (getMyPet().isOnFire() ? 1 : 0)); + getEntityData().set(BURNING_WATCHER, (byte) (getMyPet().isOnFire() ? 1 : 0)); } @Override public void onLivingUpdate() { super.onLivingUpdate(); if (Configuration.MyPet.Blaze.CAN_GLIDE) { - if (!this.z && this.getMot().getY() < 0.0D) { - this.setMot(getMot().d(1, 0.6D, 1)); + if (!this.onGround && this.getDeltaMovement().y() < 0.0D) { + this.setDeltaMovement(getDeltaMovement().multiply(1, 0.6D, 1)); } } } @@ -136,9 +137,9 @@ public MyBlaze getMyPet() { * -> disable falldamage */ @Override - public int d(float f, float f1) { + public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Blaze.CAN_GLIDE) { - super.e(f, f1); + super.e(f, f1); //TODO } return 0; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCat.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCat.java index 4f8aa6a5d2..db57a002fb 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCat.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCat.java @@ -25,11 +25,11 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyCat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemDye; import net.minecraft.world.item.ItemStack; @@ -42,24 +42,24 @@ @EntitySize(width = 0.6F, height = 0.8F) public class EntityMyCat extends EntityMyPet { - protected static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyCat.class, DataWatcherRegistry.i); - protected static final DataWatcherObject SIT_WATCHER = DataWatcher.a(EntityMyCat.class, DataWatcherRegistry.a); - protected static final DataWatcherObject> OWNER_WATCHER = DataWatcher.a(EntityMyCat.class, DataWatcherRegistry.o); - protected static final DataWatcherObject TYPE_WATCHER = DataWatcher.a(EntityMyCat.class, DataWatcherRegistry.b); - protected static final DataWatcherObject UNUSED_WATCHER_1 = DataWatcher.a(EntityMyCat.class, DataWatcherRegistry.i); - protected static final DataWatcherObject UNUSED_WATCHER_2 = DataWatcher.a(EntityMyCat.class, DataWatcherRegistry.i); - protected static final DataWatcherObject COLLAR_COLOR_WATCHER = DataWatcher.a(EntityMyCat.class, DataWatcherRegistry.b); + protected static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyCat.class, EntityDataSerializers.BOOLEAN); + protected static final EntityDataAccessor SIT_WATCHER = SynchedEntityData.defineId(EntityMyCat.class, EntityDataSerializers.BYTE); + protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyCat.class, EntityDataSerializers.o); + protected static final EntityDataAccessor TYPE_WATCHER = SynchedEntityData.defineId(EntityMyCat.class, EntityDataSerializers.INT); + protected static final EntityDataAccessor UNUSED_WATCHER_1 = SynchedEntityData.defineId(EntityMyCat.class, EntityDataSerializers.BOOLEAN); + protected static final EntityDataAccessor UNUSED_WATCHER_2 = SynchedEntityData.defineId(EntityMyCat.class, EntityDataSerializers.BOOLEAN); + protected static final EntityDataAccessor COLLAR_COLOR_WATCHER = SynchedEntityData.defineId(EntityMyCat.class, EntityDataSerializers.INT); - public EntityMyCat(World world, MyPet myPet) { + public EntityMyCat(Level world, MyPet myPet) { super(world, myPet); } public void applySitting(boolean sitting) { - byte i = this.getDataWatcher().get(SIT_WATCHER); + byte i = this.getEntityData().get(SIT_WATCHER); if (sitting) { - this.getDataWatcher().set(SIT_WATCHER, (byte) (i | 1)); + this.getEntityData().set(SIT_WATCHER, (byte) (i | 1)); } else { - this.getDataWatcher().set(SIT_WATCHER, (byte) (i & -2)); + this.getEntityData().set(SIT_WATCHER, (byte) (i & -2)); } } @@ -79,9 +79,9 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman)) { @@ -89,52 +89,51 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En if (itemStack.getItem() instanceof ItemDye) { if (((ItemDye) itemStack.getItem()).d().getColorIndex() != getMyPet().getCollarColor().ordinal()) { getMyPet().setCollarColor(DyeColor.values()[((ItemDye) itemStack.getItem()).d().getColorIndex()]); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.a; + return InteractionResult.a; } } else if (Configuration.MyPet.Ocelot.GROW_UP_ITEM.compare(itemStack) && canUseItem() && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(SIT_WATCHER, (byte) 0); - getDataWatcher().register(OWNER_WATCHER, Optional.empty()); - getDataWatcher().register(TYPE_WATCHER, 1); - getDataWatcher().register(UNUSED_WATCHER_1, false); - getDataWatcher().register(UNUSED_WATCHER_2, false); - getDataWatcher().register(COLLAR_COLOR_WATCHER, 14); + protected void defineSynchedData() { + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(SIT_WATCHER, (byte) 0); + getEntityData().define(OWNER_WATCHER, Optional.empty()); + getEntityData().define(TYPE_WATCHER, 1); + getEntityData().define(UNUSED_WATCHER_1, false); + getEntityData().define(UNUSED_WATCHER_2, false); + getEntityData().define(COLLAR_COLOR_WATCHER, 14); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); - this.getDataWatcher().set(TYPE_WATCHER, getMyPet().getCatType().ordinal()); - this.getDataWatcher().set(COLLAR_COLOR_WATCHER, getMyPet().getCollarColor().ordinal()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(TYPE_WATCHER, getMyPet().getCatType().ordinal()); + this.getEntityData().set(COLLAR_COLOR_WATCHER, getMyPet().getCollarColor().ordinal()); - byte b0 = this.getDataWatcher().get(SIT_WATCHER); + byte b0 = this.getEntityData().get(SIT_WATCHER); if (getMyPet().isTamed()) { - this.getDataWatcher().set(SIT_WATCHER, (byte) (b0 | 0x4)); + this.getEntityData().set(SIT_WATCHER, (byte) (b0 | 0x4)); } else { - this.getDataWatcher().set(SIT_WATCHER, (byte) (b0 & 0xFFFFFFFB)); + this.getEntityData().set(SIT_WATCHER, (byte) (b0 & 0xFFFFFFFB)); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCaveSpider.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCaveSpider.java index e8c28e88ac..9dc64158f1 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCaveSpider.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCaveSpider.java @@ -23,17 +23,17 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.level.World; @EntitySize(width = 0.7F, height = 0.45F) public class EntityMyCaveSpider extends EntityMyPet { - private static final DataWatcherObject UNUSED_WATCHER = DataWatcher.a(EntityMyCaveSpider.class, DataWatcherRegistry.a); + private static final EntityDataAccessor UNUSED_WATCHER = SynchedEntityData.defineId(EntityMyCaveSpider.class, EntityDataSerializers.BYTE); - public EntityMyCaveSpider(World world, MyPet myPet) { + public EntityMyCaveSpider(Level world, MyPet myPet) { super(world, myPet); } @@ -53,9 +53,8 @@ protected String getLivingSound() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(UNUSED_WATCHER, (byte) 0); + protected void defineSynchedData() { + getEntityData().define(UNUSED_WATCHER, (byte) 0); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyChicken.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyChicken.java index 8a8a8cb565..6ccee77991 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyChicken.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyChicken.java @@ -25,11 +25,11 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyChicken; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -38,11 +38,11 @@ @EntitySize(width = 0.4F, height = 0.7F) public class EntityMyChicken extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyChicken.class, DataWatcherRegistry.i); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyChicken.class, EntityDataSerializers.BOOLEAN); private int nextEggTimer; - public EntityMyChicken(World world, MyPet myPet) { + public EntityMyChicken(Level world, MyPet myPet) { super(world, myPet); nextEggTimer = (this.Q.nextInt(6000) + 6000); } @@ -63,35 +63,35 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { if (Configuration.MyPet.Chicken.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); } @Override @@ -99,8 +99,8 @@ public void onLivingUpdate() { super.onLivingUpdate(); if (Configuration.MyPet.Chicken.CAN_GLIDE) { - if (!this.z && this.getMot().getY() < 0.0D) { - this.setMot(getMot().d(1, 0.6D, 1)); + if (!this.onGround && this.getDeltaMovement().y() < 0.0D) { + this.setDeltaMovement(getDeltaMovement().multiply(1, 0.6D, 1)); } } @@ -125,7 +125,7 @@ public MyChicken getMyPet() { * -> disable falldamage */ @Override - public int d(float f, float f1) { + public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Chicken.CAN_GLIDE) { super.e(f, f1); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java index 083497ac8e..dcfa4c512b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java @@ -25,17 +25,17 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.level.World; @EntitySize(width = 0.5F, height = 0.3f) public class EntityMyCod extends EntityMyPet { - private static final DataWatcherObject FROM_BUCKET_WATCHER = DataWatcher.a(EntityMyCod.class, DataWatcherRegistry.i); + private static final EntityDataAccessor FROM_BUCKET_WATCHER = SynchedEntityData.defineId(EntityMyCod.class, EntityDataSerializers.BOOLEAN); - public EntityMyCod(World world, MyPet myPet) { + public EntityMyCod(Level world, MyPet myPet) { super(world, myPet); } @@ -63,8 +63,8 @@ public void onLivingUpdate() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(FROM_BUCKET_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(FROM_BUCKET_WATCHER, false); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCow.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCow.java index 4b68459b04..43526b9174 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCow.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCow.java @@ -25,11 +25,11 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyCow; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -38,9 +38,9 @@ @EntitySize(width = 0.7F, height = 1.3F) public class EntityMyCow extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyCow.class, DataWatcherRegistry.i); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyCow.class, EntityDataSerializers.BOOLEAN); - public EntityMyCow(World world, MyPet myPet) { + public EntityMyCow(Level world, MyPet myPet) { super(world, myPet); } @@ -60,40 +60,40 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { - if (itemStack.getItem() == Items.nW && Configuration.MyPet.Cow.CAN_GIVE_MILK) { + if (itemStack.getItem() == Items.BUCKET && Configuration.MyPet.Cow.CAN_GIVE_MILK) { ItemStack milkBucket = new ItemStack(Items.oc); - entityhuman.getInventory().setItem(entityhuman.getInventory().k, milkBucket); - return EnumInteractionResult.b; + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, milkBucket); + return InteractionResult.CONSUME; } else if (Configuration.MyPet.Cow.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCreeper.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCreeper.java index 40cc9bfd19..183362151c 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCreeper.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCreeper.java @@ -24,19 +24,19 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyCreeper; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.level.World; @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyCreeper extends EntityMyPet { - private static final DataWatcherObject FUSE_WATCHER = DataWatcher.a(EntityMyCreeper.class, DataWatcherRegistry.b); - private static final DataWatcherObject POWERED_WATCHER = DataWatcher.a(EntityMyCreeper.class, DataWatcherRegistry.i); - private static final DataWatcherObject UNUSED_WATCHER = DataWatcher.a(EntityMyCreeper.class, DataWatcherRegistry.i); + private static final EntityDataAccessor FUSE_WATCHER = SynchedEntityData.defineId(EntityMyCreeper.class, EntityDataSerializers.INT); + private static final EntityDataAccessor POWERED_WATCHER = SynchedEntityData.defineId(EntityMyCreeper.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor UNUSED_WATCHER = SynchedEntityData.defineId(EntityMyCreeper.class, EntityDataSerializers.BOOLEAN); - public EntityMyCreeper(World world, MyPet myPet) { + public EntityMyCreeper(Level world, MyPet myPet) { super(world, myPet); } @@ -56,16 +56,16 @@ protected String getLivingSound() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(FUSE_WATCHER, -1); - getDataWatcher().register(POWERED_WATCHER, false); - getDataWatcher().register(UNUSED_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(FUSE_WATCHER, -1); + getEntityData().define(POWERED_WATCHER, false); + getEntityData().define(UNUSED_WATCHER, false); } @Override public void updateVisuals() { - getDataWatcher().set(POWERED_WATCHER, getMyPet().isPowered()); + getEntityData().set(POWERED_WATCHER, getMyPet().isPowered()); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDolphin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDolphin.java index 2385a04917..9daf272b65 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDolphin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDolphin.java @@ -26,19 +26,19 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.core.BlockPosition; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.level.World; @EntitySize(width = 0.9F, height = 0.6f) public class EntityMyDolphin extends EntityMyPet { - private static final DataWatcherObject TREASURE_POS_WATCHER = DataWatcher.a(EntityMyDolphin.class, DataWatcherRegistry.l); - private static final DataWatcherObject GOT_FISH_WATCHER = DataWatcher.a(EntityMyDolphin.class, DataWatcherRegistry.i); - private static final DataWatcherObject MOISTNESS_WATCHER = DataWatcher.a(EntityMyDolphin.class, DataWatcherRegistry.b); + private static final EntityDataAccessor TREASURE_POS_WATCHER = SynchedEntityData.defineId(EntityMyDolphin.class, EntityDataSerializers.l); + private static final EntityDataAccessor GOT_FISH_WATCHER = SynchedEntityData.defineId(EntityMyDolphin.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor MOISTNESS_WATCHER = SynchedEntityData.defineId(EntityMyDolphin.class, EntityDataSerializers.INT); - public EntityMyDolphin(World world, MyPet myPet) { + public EntityMyDolphin(Level world, MyPet myPet) { super(world, myPet); } @@ -66,11 +66,11 @@ public void onLivingUpdate() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); + protected void defineSynchedData() { + super.defineSynchedData(); - getDataWatcher().register(TREASURE_POS_WATCHER, BlockPosition.b); - getDataWatcher().register(GOT_FISH_WATCHER, false); - getDataWatcher().register(MOISTNESS_WATCHER, 2400); + getEntityData().define(TREASURE_POS_WATCHER, BlockPosition.b); + getEntityData().define(GOT_FISH_WATCHER, false); + getEntityData().define(MOISTNESS_WATCHER, 2400); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDonkey.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDonkey.java index 2da5f8529d..b925e8cb76 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDonkey.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDonkey.java @@ -26,12 +26,12 @@ import de.Keyle.MyPet.api.entity.types.MyDonkey; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.core.BlockPosition; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.sounds.SoundEffects; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.IJumpable; import net.minecraft.world.entity.item.EntityItem; @@ -54,15 +54,15 @@ @EntitySize(width = 1.4F, height = 1.6F) public class EntityMyDonkey extends EntityMyPet implements IJumpable { - protected static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyDonkey.class, DataWatcherRegistry.i); - protected static final DataWatcherObject SADDLE_WATCHER = DataWatcher.a(EntityMyDonkey.class, DataWatcherRegistry.a); - protected static final DataWatcherObject> OWNER_WATCHER = DataWatcher.a(EntityMyDonkey.class, DataWatcherRegistry.o); - private static final DataWatcherObject CHEST_WATCHER = DataWatcher.a(EntityMyDonkey.class, DataWatcherRegistry.i); + protected static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyDonkey.class, EntityDataSerializers.BOOLEAN); + protected static final EntityDataAccessor SADDLE_WATCHER = SynchedEntityData.defineId(EntityMyDonkey.class, EntityDataSerializers.BYTE); + protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyDonkey.class, EntityDataSerializers.o); + private static final EntityDataAccessor CHEST_WATCHER = SynchedEntityData.defineId(EntityMyDonkey.class, EntityDataSerializers.BOOLEAN); int soundCounter = 0; int rearCounter = -1; - public EntityMyDonkey(World world, MyPet myPet) { + public EntityMyDonkey(Level world, MyPet myPet) { super(world, myPet); } @@ -75,11 +75,11 @@ public EntityMyDonkey(World world, MyPet myPet) { * 128 mouth open */ protected void applyVisual(int value, boolean flag) { - int i = this.getDataWatcher().get(SADDLE_WATCHER); + int i = this.getSynchedEntityData().get(SADDLE_WATCHER); if (flag) { - this.getDataWatcher().set(SADDLE_WATCHER, (byte) (i | value)); + this.getEntityData().set(SADDLE_WATCHER, (byte) (i | value)); } else { - this.getDataWatcher().set(SADDLE_WATCHER, (byte) (i & (~value))); + this.getEntityData().set(SADDLE_WATCHER, (byte) (i & (~value))); } } @@ -100,30 +100,30 @@ public boolean attack(Entity entity) { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (itemStack != null && canUseItem()) { if (itemStack.getItem() == Items.lL && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking() && canEquip()) { getMyPet().setSaddle(CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Item.getItemOf(Blocks.pq) && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && canEquip()) { getMyPet().setChest(CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { if (getMyPet().hasChest()) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getChest())); @@ -141,12 +141,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En makeSound("entity.sheep.shear", 1.0F, 1.0F); getMyPet().setChest(null); getMyPet().setSaddle(null); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -156,34 +156,34 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.Donkey.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(SADDLE_WATCHER, (byte) 0); - getDataWatcher().register(OWNER_WATCHER, Optional.empty()); - getDataWatcher().register(CHEST_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(SADDLE_WATCHER, (byte) 0); + getEntityData().define(OWNER_WATCHER, Optional.empty()); + getEntityData().define(CHEST_WATCHER, false); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); - this.getDataWatcher().set(CHEST_WATCHER, getMyPet().hasChest()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(CHEST_WATCHER, getMyPet().hasChest()); applyVisual(4, getMyPet().hasSaddle()); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDrowned.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDrowned.java index cbc39f4bc6..2d5cba52ec 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDrowned.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDrowned.java @@ -30,13 +30,13 @@ import de.Keyle.MyPet.api.entity.types.MyDrowned; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -54,13 +54,13 @@ @EntitySize(width = 0.6F, height = 1.95F) public class EntityMyDrowned extends EntityMyPet { - private static final DataWatcherObject BABY_WATCHER = DataWatcher.a(EntityMyDrowned.class, DataWatcherRegistry.i); - private static final DataWatcherObject UNUSED_WATCHER_1 = DataWatcher.a(EntityMyDrowned.class, DataWatcherRegistry.b); - private static final DataWatcherObject UNUSED_WATCHER_2 = DataWatcher.a(EntityMyDrowned.class, DataWatcherRegistry.i); - private static final DataWatcherObject UNUSED_WATCHER_3 = DataWatcher.a(EntityMyDrowned.class, DataWatcherRegistry.i); + private static final EntityDataAccessor BABY_WATCHER = SynchedEntityData.defineId(EntityMyDrowned.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor UNUSED_WATCHER_1 = SynchedEntityData.defineId(EntityMyDrowned.class, EntityDataSerializers.INT); + private static final EntityDataAccessor UNUSED_WATCHER_2 = SynchedEntityData.defineId(EntityMyDrowned.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor UNUSED_WATCHER_3 = SynchedEntityData.defineId(EntityMyDrowned.class, EntityDataSerializers.BOOLEAN); - public EntityMyDrowned(World world, MyPet myPet) { + public EntityMyDrowned(Level world, MyPet myPet) { super(world, myPet); } @@ -95,9 +95,9 @@ protected String getLivingSound() { * false: no reaction on rightclick */ @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { @@ -115,12 +115,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -130,50 +130,50 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(EntityInsentient.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.Zombie.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(BABY_WATCHER, false); - getDataWatcher().register(UNUSED_WATCHER_1, 0); - getDataWatcher().register(UNUSED_WATCHER_2, false); - getDataWatcher().register(UNUSED_WATCHER_3, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(BABY_WATCHER, false); + getEntityData().define(UNUSED_WATCHER_1, 0); + getEntityData().define(UNUSED_WATCHER_2, false); + getEntityData().define(UNUSED_WATCHER_3, false); } @Override public void updateVisuals() { - getDataWatcher().set(BABY_WATCHER, getMyPet().isBaby()); + getEntityData().set(BABY_WATCHER, getMyPet().isBaby()); Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> { if (getMyPet().getStatus() == MyPet.PetState.Here) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyElderGuardian.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyElderGuardian.java index 7834eecb18..bc20e471f4 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyElderGuardian.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyElderGuardian.java @@ -29,7 +29,7 @@ @EntitySize(width = 0.7F, height = 0.85F) public class EntityMyElderGuardian extends EntityMyPet { - public EntityMyElderGuardian(World world, MyPet myPet) { + public EntityMyElderGuardian(Level world, MyPet myPet) { super(world, myPet); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderDragon.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderDragon.java index c97b8e2792..bd3533df57 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderDragon.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderDragon.java @@ -42,7 +42,7 @@ public class EntityMyEnderDragon extends EntityMyPet { public EntityMyPetPart[] children; - public EntityMyEnderDragon(World world, MyPet myPet) { + public EntityMyEnderDragon(Level world, MyPet myPet) { super(world, myPet); children = new EntityMyPetPart[]{ @@ -82,8 +82,8 @@ public void setPathfinder() { public void onLivingUpdate() { super.onLivingUpdate(); if (Configuration.MyPet.EnderDragon.CAN_GLIDE) { - if (!this.z && this.getMot().getY() < 0.0D) { - this.setMot(getMot().d(1, 0.6D, 1)); + if (!this.onGround && this.getDeltaMovement().y() < 0.0D) { + this.setDeltaMovement(getDeltaMovement().multiply(1, 0.6D, 1)); } } if (!registered && this.valid) { @@ -100,7 +100,7 @@ public void onLivingUpdate() { * -> disable falldamage */ @Override - public int d(float f, float f1) { + public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.EnderDragon.CAN_GLIDE) { super.e(f, f1); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderman.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderman.java index 2bc208dd16..bfaf4d59a9 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderman.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderman.java @@ -27,11 +27,11 @@ import de.Keyle.MyPet.api.skill.skills.Behavior; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.skill.skills.BehaviorImpl; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.Item; @@ -50,10 +50,10 @@ @EntitySize(width = 0.6F, height = 2.55F) public class EntityMyEnderman extends EntityMyPet { - private static final DataWatcherObject> BLOCK_WATCHER = DataWatcher.a(EntityMyEnderman.class, DataWatcherRegistry.h); - private static final DataWatcherObject SCREAMING_WATCHER = DataWatcher.a(EntityMyEnderman.class, DataWatcherRegistry.i); + private static final EntityDataAccessor> BLOCK_WATCHER = SynchedEntityData.defineId(EntityMyEnderman.class, EntityDataSerializers.h); + private static final EntityDataAccessor SCREAMING_WATCHER = SynchedEntityData.defineId(EntityMyEnderman.class, EntityDataSerializers.BOOLEAN); - public EntityMyEnderman(World world, MyPet myPet) { + public EntityMyEnderman(Level world, MyPet myPet) { super(world, myPet); } @@ -73,9 +73,9 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { @@ -86,12 +86,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En makeSound("entity.sheep.shear", 1.0F, 1.0F); getMyPet().setBlock(null); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -101,26 +101,26 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (getMyPet().getBlock() == null && Util.isBetween(1, 255, Item.getId(itemStack.getItem())) && getOwner().getPlayer().isSneaking()) { getMyPet().setBlock(CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(BLOCK_WATCHER, Optional.empty()); - getDataWatcher().register(SCREAMING_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(BLOCK_WATCHER, Optional.empty()); + getEntityData().define(SCREAMING_WATCHER, false); } @Override @@ -132,8 +132,8 @@ public void updateVisuals() { } else { block = Optional.empty(); } - getDataWatcher().set(BLOCK_WATCHER, block); - getDataWatcher().set(SCREAMING_WATCHER, getMyPet().isScreaming()); + getEntityData().set(BLOCK_WATCHER, block); + getEntityData().set(SCREAMING_WATCHER, getMyPet().isScreaming()); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEndermite.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEndermite.java index a81b2258d3..d7b01cba13 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEndermite.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEndermite.java @@ -28,7 +28,7 @@ @EntitySize(width = 0.4F, height = 0.1F) public class EntityMyEndermite extends EntityMyPet { - public EntityMyEndermite(World world, MyPet myPet) { + public EntityMyEndermite(Level world, MyPet myPet) { super(world, myPet); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEvoker.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEvoker.java index 3555e41902..46600ddc79 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEvoker.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEvoker.java @@ -24,18 +24,18 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyEvoker; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.level.World; @EntitySize(width = 0.6F, height = 1.95F) public class EntityMyEvoker extends EntityMyPet { - protected static final DataWatcherObject RAID_WATCHER = DataWatcher.a(EntityMyEvoker.class, DataWatcherRegistry.i); - protected static final DataWatcherObject SPELL_WATCHER = DataWatcher.a(EntityMyEvoker.class, DataWatcherRegistry.a); + protected static final EntityDataAccessor RAID_WATCHER = SynchedEntityData.defineId(EntityMyEvoker.class, EntityDataSerializers.BOOLEAN); + protected static final EntityDataAccessor SPELL_WATCHER = SynchedEntityData.defineId(EntityMyEvoker.class, EntityDataSerializers.BYTE); - public EntityMyEvoker(World world, MyPet myPet) { + public EntityMyEvoker(Level world, MyPet myPet) { super(world, myPet); } @@ -64,10 +64,10 @@ protected String getLivingSound() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(RAID_WATCHER, false); - getDataWatcher().register(SPELL_WATCHER, (byte) 0); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(RAID_WATCHER, false); + getEntityData().define(SPELL_WATCHER, (byte) 0); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyFox.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyFox.java index 751b7f2c0d..f037069573 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyFox.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyFox.java @@ -30,12 +30,12 @@ import de.Keyle.MyPet.api.entity.types.MyFox; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -55,13 +55,13 @@ @EntitySize(width = 0.6F, height = 0.8F) public class EntityMyFox extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyFox.class, DataWatcherRegistry.i); - private static final DataWatcherObject FOX_TYPE_WATCHER = DataWatcher.a(EntityMyFox.class, DataWatcherRegistry.b); - private static final DataWatcherObject ACTIONS_WATCHER = DataWatcher.a(EntityMyFox.class, DataWatcherRegistry.a); - private static final DataWatcherObject> FRIEND_A_WATCHER = DataWatcher.a(EntityMyFox.class, DataWatcherRegistry.o); - private static final DataWatcherObject> FRIEND_B_WATCHER = DataWatcher.a(EntityMyFox.class, DataWatcherRegistry.o); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyFox.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor FOX_TYPE_WATCHER = SynchedEntityData.defineId(EntityMyFox.class, EntityDataSerializers.INT); + private static final EntityDataAccessor ACTIONS_WATCHER = SynchedEntityData.defineId(EntityMyFox.class, EntityDataSerializers.BYTE); + private static final EntityDataAccessor> FRIEND_A_WATCHER = SynchedEntityData.defineId(EntityMyFox.class, EntityDataSerializers.o); + private static final EntityDataAccessor> FRIEND_B_WATCHER = SynchedEntityData.defineId(EntityMyFox.class, EntityDataSerializers.o); - public EntityMyFox(World world, MyPet myPet) { + public EntityMyFox(Level world, MyPet myPet) { super(world, myPet); this.getControllerLook().a(this, 60.0F, 30.0F); } @@ -82,38 +82,38 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman)) { if (itemStack != null && itemStack.getItem() != Items.a && canUseItem() && getOwner().getPlayer().isSneaking()) { if (itemStack.getItem() != Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(EquipmentSlot.MainHand)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(EquipmentSlot.MainHand, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.Ocelot.GROW_UP_ITEM.compare(itemStack) && canUseItem() && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { @@ -128,12 +128,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -143,27 +143,27 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(FRIEND_A_WATCHER, Optional.empty()); - getDataWatcher().register(FRIEND_B_WATCHER, Optional.empty()); - getDataWatcher().register(FOX_TYPE_WATCHER, 0); - getDataWatcher().register(ACTIONS_WATCHER, (byte) 0); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(FRIEND_A_WATCHER, Optional.empty()); + getEntityData().define(FRIEND_B_WATCHER, Optional.empty()); + getEntityData().define(FOX_TYPE_WATCHER, 0); + getEntityData().define(ACTIONS_WATCHER, (byte) 0); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); - this.getDataWatcher().set(FOX_TYPE_WATCHER, getMyPet().getType().ordinal()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(FOX_TYPE_WATCHER, getMyPet().getType().ordinal()); Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> { if (getMyPet().getStatus() == MyPet.PetState.Here) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGhast.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGhast.java index f8210bcdec..f7dc0cbc68 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGhast.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGhast.java @@ -30,7 +30,7 @@ @EntitySize(width = 4.F, height = 4.F) public class EntityMyGhast extends EntityMyPet { - public EntityMyGhast(World world, MyPet myPet) { + public EntityMyGhast(Level world, MyPet myPet) { super(world, myPet); } @@ -59,8 +59,8 @@ public void setPathfinder() { public void onLivingUpdate() { super.onLivingUpdate(); if (Configuration.MyPet.Ghast.CAN_GLIDE) { - if (!this.z && this.getMot().getY() < 0.0D) { - this.setMot(getMot().d(1, 0.6D, 1)); + if (!this.onGround && this.getDeltaMovement().y() < 0.0D) { + this.setDeltaMovement(getDeltaMovement().multiply(1, 0.6D, 1)); } } } @@ -69,7 +69,7 @@ public void onLivingUpdate() { * -> disable falldamage */ @Override - public int d(float f, float f1) { + public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Ghast.CAN_GLIDE) { super.e(f, f1); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGiant.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGiant.java index 085cdb6541..b73574df59 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGiant.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGiant.java @@ -31,9 +31,9 @@ import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack.MeleeAttack; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -51,7 +51,7 @@ @EntitySize(width = 6.0f, height = 10.440001F) public class EntityMyGiant extends EntityMyPet { - public EntityMyGiant(World world, MyPet myPet) { + public EntityMyGiant(Level world, MyPet myPet) { super(world, myPet); } @@ -84,9 +84,9 @@ public void setPathfinder() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { @@ -104,12 +104,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -119,27 +119,27 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(EntityInsentient.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGuardian.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGuardian.java index 4cc4f82c03..7e12c6729f 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGuardian.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGuardian.java @@ -29,7 +29,7 @@ @EntitySize(width = 0.7F, height = 0.85F) public class EntityMyGuardian extends EntityMyPet { - public EntityMyGuardian(World world, MyPet myPet) { + public EntityMyGuardian(Level world, MyPet myPet) { super(world, myPet); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java index 4a761b4fa8..51194f8c1d 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java @@ -25,11 +25,11 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyHoglin; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.World; @@ -37,9 +37,9 @@ @EntitySize(width = 1.3965F, height = 1.4F) public class EntityMyHoglin extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyHoglin.class, DataWatcherRegistry.i); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyHoglin.class, EntityDataSerializers.BOOLEAN); - public EntityMyHoglin(World world, MyPet myPet) { + public EntityMyHoglin(Level world, MyPet myPet) { super(world, myPet); } @@ -59,35 +59,35 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(final EntityHuman entityhuman, EnumHand enumhand, final ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(final EntityHuman entityhuman, InteractionHand enumhand, final ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { if (Configuration.MyPet.Hoglin.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHorse.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHorse.java index 1ff888167b..6d2faf9e1b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHorse.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHorse.java @@ -31,13 +31,13 @@ import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.core.BlockPosition; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.server.level.WorldServer; import net.minecraft.sounds.SoundEffects; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.IJumpable; @@ -62,15 +62,15 @@ @EntitySize(width = 1.3965F, height = 1.6F) public class EntityMyHorse extends EntityMyPet implements IJumpable { - protected static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyHorse.class, DataWatcherRegistry.i); - protected static final DataWatcherObject SADDLE_CHEST_WATCHER = DataWatcher.a(EntityMyHorse.class, DataWatcherRegistry.a); - protected static final DataWatcherObject> OWNER_WATCHER = DataWatcher.a(EntityMyHorse.class, DataWatcherRegistry.o); - private static final DataWatcherObject VARIANT_WATCHER = DataWatcher.a(EntityMyHorse.class, DataWatcherRegistry.b); + protected static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyHorse.class, EntityDataSerializers.BOOLEAN); + protected static final EntityDataAccessor SADDLE_CHEST_WATCHER = SynchedEntityData.defineId(EntityMyHorse.class, EntityDataSerializers.BYTE); + protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyHorse.class, EntityDataSerializers.o); + private static final EntityDataAccessor VARIANT_WATCHER = SynchedEntityData.defineId(EntityMyHorse.class, EntityDataSerializers.INT); int soundCounter = 0; int rearCounter = -1; - public EntityMyHorse(World world, MyPet myPet) { + public EntityMyHorse(Level world, MyPet myPet) { super(world, myPet); } @@ -82,11 +82,11 @@ public EntityMyHorse(World world, MyPet myPet) { * 64 rear */ protected void applyVisual(int value, boolean flag) { - int i = this.getDataWatcher().get(SADDLE_CHEST_WATCHER); + int i = this.getSynchedEntityData().get(SADDLE_CHEST_WATCHER); if (flag) { - this.getDataWatcher().set(SADDLE_CHEST_WATCHER, (byte) (i | value)); + this.getEntityData().set(SADDLE_CHEST_WATCHER, (byte) (i | value)); } else { - this.getDataWatcher().set(SADDLE_CHEST_WATCHER, (byte) (i & (~value))); + this.getEntityData().set(SADDLE_CHEST_WATCHER, (byte) (i & (~value))); } } @@ -122,31 +122,31 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (itemStack != null && canUseItem()) { org.bukkit.inventory.ItemStack is = CraftItemStack.asBukkitCopy(itemStack); if (itemStack.getItem() == Items.lL && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking() && canEquip()) { getMyPet().setSaddle(is); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (!getMyPet().hasArmor() && getOwner().getPlayer().isSneaking() && canEquip() && isArmor(is)) { getMyPet().setArmor(is); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { if (getMyPet().hasArmor()) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getArmor())); @@ -171,12 +171,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En getMyPet().setChest(null); getMyPet().setSaddle(null); getMyPet().setArmor(null); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -186,19 +186,19 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.Horse.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } protected boolean isArmor(org.bukkit.inventory.ItemStack item) { @@ -215,18 +215,18 @@ protected boolean isArmor(org.bukkit.inventory.ItemStack item) { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(SADDLE_CHEST_WATCHER, (byte) 0); - getDataWatcher().register(OWNER_WATCHER, Optional.empty()); - getDataWatcher().register(VARIANT_WATCHER, 0); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(SADDLE_CHEST_WATCHER, (byte) 0); + getEntityData().define(OWNER_WATCHER, Optional.empty()); + getEntityData().define(VARIANT_WATCHER, 0); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); - this.getDataWatcher().set(VARIANT_WATCHER, getMyPet().getVariant()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(VARIANT_WATCHER, getMyPet().getVariant()); applyVisual(4, getMyPet().hasSaddle()); Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> { if (getMyPet().getStatus() == MyPet.PetState.Here) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java index 393614aa2c..6208ae7325 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java @@ -30,13 +30,13 @@ import de.Keyle.MyPet.api.entity.types.MyHusk; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -54,11 +54,11 @@ @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyHusk extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyHusk.class, DataWatcherRegistry.i); - private static final DataWatcherObject TYPE_WATCHER = DataWatcher.a(EntityMyHusk.class, DataWatcherRegistry.b); - private static final DataWatcherObject UNUSED_WATCHER = DataWatcher.a(EntityMyHusk.class, DataWatcherRegistry.i); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyHusk.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor TYPE_WATCHER = SynchedEntityData.defineId(EntityMyHusk.class, EntityDataSerializers.INT); + private static final EntityDataAccessor UNUSED_WATCHER = SynchedEntityData.defineId(EntityMyHusk.class, EntityDataSerializers.BOOLEAN); - public EntityMyHusk(World world, MyPet myPet) { + public EntityMyHusk(Level world, MyPet myPet) { super(world, myPet); } @@ -94,9 +94,9 @@ protected String getLivingSound() { */ @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { @@ -114,12 +114,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -129,49 +129,49 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(EntityInsentient.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.Zombie.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); // is baby - getDataWatcher().register(TYPE_WATCHER, 0); // type - getDataWatcher().register(UNUSED_WATCHER, false); // N/A + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); // is baby + getEntityData().define(TYPE_WATCHER, 0); // type + getEntityData().define(UNUSED_WATCHER, false); // N/A } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> { if (getMyPet().getStatus() == MyPet.PetState.Here) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java index 36d2a8dd3a..1eb287b017 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java @@ -30,13 +30,13 @@ import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -52,10 +52,10 @@ @EntitySize(width = 0.6F, height = 1.95F) public class EntityMyIllusioner extends EntityMyPet { - protected static final DataWatcherObject RAID_WATCHER = DataWatcher.a(EntityMyIllusioner.class, DataWatcherRegistry.i); - protected static final DataWatcherObject SPELL_WATCHER = DataWatcher.a(EntityMyIllusioner.class, DataWatcherRegistry.a); + protected static final EntityDataAccessor RAID_WATCHER = SynchedEntityData.defineId(EntityMyIllusioner.class, EntityDataSerializers.BOOLEAN); + protected static final EntityDataAccessor SPELL_WATCHER = SynchedEntityData.defineId(EntityMyIllusioner.class, EntityDataSerializers.BYTE); - public EntityMyIllusioner(World world, MyPet myPet) { + public EntityMyIllusioner(Level world, MyPet myPet) { super(world, myPet); } @@ -90,9 +90,9 @@ protected String getLivingSound() { * false: no reaction on rightclick */ @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { @@ -110,12 +110,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -125,41 +125,41 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(EntityInsentient.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); if (slot == EquipmentSlot.MainHand) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(RAID_WATCHER, false); - getDataWatcher().register(SPELL_WATCHER, (byte) 0); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(RAID_WATCHER, false); + getEntityData().define(SPELL_WATCHER, (byte) 0); } @Override public void updateVisuals() { - getDataWatcher().set(SPELL_WATCHER, (byte) (getMyPet().getEquipment(EquipmentSlot.MainHand) != null ? 1 : 0)); + getEntityData().set(SPELL_WATCHER, (byte) (getMyPet().getEquipment(EquipmentSlot.MainHand) != null ? 1 : 0)); Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> { if (getMyPet().getStatus() == MyPet.PetState.Here) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIronGolem.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIronGolem.java index 2f61ef345a..0509a20b1f 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIronGolem.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIronGolem.java @@ -26,11 +26,11 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyIronGolem; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -48,12 +48,12 @@ @EntitySize(width = 1.4F, height = 2.7F) public class EntityMyIronGolem extends EntityMyPet { - protected static final DataWatcherObject UNUSED_WATCHER = DataWatcher.a(EntityMyIronGolem.class, DataWatcherRegistry.a); + protected static final EntityDataAccessor UNUSED_WATCHER = SynchedEntityData.defineId(EntityMyIronGolem.class, EntityDataSerializers.BYTE); int flowerCounter = 0; boolean flower = false; - public EntityMyIronGolem(World world, MyPet myPet) { + public EntityMyIronGolem(Level world, MyPet myPet) { super(world, myPet); } @@ -89,15 +89,15 @@ protected String getLivingSound() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(UNUSED_WATCHER, (byte) 0); // N/A + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(UNUSED_WATCHER, (byte) 0); // N/A } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (itemStack.getItem() == Items.mq) { @@ -115,13 +115,13 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { if (itemStack.getItem() == Blocks.bw.getItem() && !getMyPet().hasFlower() && getOwner().getPlayer().isSneaking()) { getMyPet().setFlower(CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Items.pq && getMyPet().hasFlower() && getOwner().getPlayer().isSneaking()) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getFlower())); entityitem.ap = 10; @@ -130,12 +130,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En makeSound("entity.sheep.shear", 1.0F, 1.0F); getMyPet().setFlower(null); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -145,10 +145,10 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyLlama.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyLlama.java index dd227f10bd..b324624e0b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyLlama.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyLlama.java @@ -25,12 +25,12 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyLlama; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.tags.TagsItem; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; @@ -50,15 +50,15 @@ @EntitySize(width = 0.9F, height = 1.87F) public class EntityMyLlama extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyLlama.class, DataWatcherRegistry.i); - private static final DataWatcherObject SADDLE_CHEST_WATCHER = DataWatcher.a(EntityMyLlama.class, DataWatcherRegistry.a); - private static final DataWatcherObject> OWNER_WATCHER = DataWatcher.a(EntityMyLlama.class, DataWatcherRegistry.o); - private static final DataWatcherObject CHEST_WATCHER = DataWatcher.a(EntityMyLlama.class, DataWatcherRegistry.i); - private static final DataWatcherObject STRENGTH_WATCHER = DataWatcher.a(EntityMyLlama.class, DataWatcherRegistry.b); - private static final DataWatcherObject COLOR_WATCHER = DataWatcher.a(EntityMyLlama.class, DataWatcherRegistry.b); - private static final DataWatcherObject VARIANT_WATCHER = DataWatcher.a(EntityMyLlama.class, DataWatcherRegistry.b); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyLlama.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor SADDLE_CHEST_WATCHER = SynchedEntityData.defineId(EntityMyLlama.class, EntityDataSerializers.BYTE); + private static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyLlama.class, EntityDataSerializers.o); + private static final EntityDataAccessor CHEST_WATCHER = SynchedEntityData.defineId(EntityMyLlama.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor STRENGTH_WATCHER = SynchedEntityData.defineId(EntityMyLlama.class, EntityDataSerializers.INT); + private static final EntityDataAccessor COLOR_WATCHER = SynchedEntityData.defineId(EntityMyLlama.class, EntityDataSerializers.INT); + private static final EntityDataAccessor VARIANT_WATCHER = SynchedEntityData.defineId(EntityMyLlama.class, EntityDataSerializers.INT); - public EntityMyLlama(World world, MyPet myPet) { + public EntityMyLlama(Level world, MyPet myPet) { super(world, myPet); } @@ -78,30 +78,30 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (itemStack != null && canUseItem()) { if (TagsItem.g.isTagged(itemStack.getItem()) && !getMyPet().hasDecor() && getOwner().getPlayer().isSneaking() && canEquip()) { getMyPet().setDecor(CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Blocks.bX.getItem() && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && !getMyPet().isBaby() && canEquip()) { getMyPet().setChest(CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { if (getMyPet().hasChest()) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getChest())); @@ -119,12 +119,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En makeSound("entity.sheep.shear", 1.0F, 1.0F); getMyPet().setChest(null); getMyPet().setDecor(null); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -134,46 +134,46 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.Llama.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(SADDLE_CHEST_WATCHER, (byte) 0); // saddle & chest - getDataWatcher().register(OWNER_WATCHER, Optional.empty()); // owner - getDataWatcher().register(CHEST_WATCHER, true); - getDataWatcher().register(STRENGTH_WATCHER, 0); - getDataWatcher().register(COLOR_WATCHER, 0); - getDataWatcher().register(VARIANT_WATCHER, 0); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(SADDLE_CHEST_WATCHER, (byte) 0); // saddle & chest + getEntityData().define(OWNER_WATCHER, Optional.empty()); // owner + getEntityData().define(CHEST_WATCHER, true); + getEntityData().define(STRENGTH_WATCHER, 0); + getEntityData().define(COLOR_WATCHER, 0); + getEntityData().define(VARIANT_WATCHER, 0); } @Override public void updateVisuals() { - this.getDataWatcher().set(CHEST_WATCHER, getMyPet().hasChest()); - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(CHEST_WATCHER, getMyPet().hasChest()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); if (getMyPet().hasDecor()) { ItemStack is = CraftItemStack.asNMSCopy(getMyPet().getDecor()); Block block = Block.asBlock(is.getItem()); int color = block instanceof BlockCarpet ? ((BlockCarpet) block).c().getColorIndex() : 0; - this.getDataWatcher().set(COLOR_WATCHER, color); + this.getEntityData().set(COLOR_WATCHER, color); } else { - this.getDataWatcher().set(COLOR_WATCHER, -1); + this.getEntityData().set(COLOR_WATCHER, -1); } - this.getDataWatcher().set(VARIANT_WATCHER, getMyPet().getVariant()); + this.getEntityData().set(VARIANT_WATCHER, getMyPet().getVariant()); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMagmaCube.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMagmaCube.java index b5f7a419eb..297b859af4 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMagmaCube.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMagmaCube.java @@ -25,20 +25,20 @@ import de.Keyle.MyPet.api.entity.types.MyMagmaCube; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack.MeleeAttack; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.entity.EntityPose; import net.minecraft.world.level.World; @EntitySize(width = 0.5100001F, height = 0.5100001F) public class EntityMyMagmaCube extends EntityMyPet { - private static final DataWatcherObject SIZE_WATCHER = DataWatcher.a(EntityMyMagmaCube.class, DataWatcherRegistry.b); + private static final EntityDataAccessor SIZE_WATCHER = SynchedEntityData.defineId(EntityMyMagmaCube.class, EntityDataSerializers.INT); int jumpDelay; - public EntityMyMagmaCube(World world, MyPet myPet) { + public EntityMyMagmaCube(Level world, MyPet myPet) { super(world, myPet); } @@ -58,9 +58,9 @@ protected String getLivingSound() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(SIZE_WATCHER, 1); //size + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(SIZE_WATCHER, 1); //size } @Override @@ -77,7 +77,7 @@ public void onLivingUpdate() { @Override public void updateVisuals() { int size = Math.max(1, getMyPet().getSize()); - getDataWatcher().set(SIZE_WATCHER, size); + getEntityData().set(SIZE_WATCHER, size); this.updateSize(); if (petPathfinderSelector != null && petPathfinderSelector.hasGoal("MeleeAttack")) { petPathfinderSelector.replaceGoal("MeleeAttack", new MeleeAttack(this, 0.1F, 3 + (getMyPet().getSize() * 0.51), 20)); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java index 247de36ffe..60008b51b7 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java @@ -26,11 +26,11 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyMooshroom; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -40,10 +40,10 @@ @EntitySize(width = 0.7F, height = 1.3F) public class EntityMyMooshroom extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyMooshroom.class, DataWatcherRegistry.i); - private static final DataWatcherObject COLOR_WATCHER = DataWatcher.a(EntityMyMooshroom.class, DataWatcherRegistry.d); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyMooshroom.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor COLOR_WATCHER = SynchedEntityData.defineId(EntityMyMooshroom.class, EntityDataSerializers.d); - public EntityMyMooshroom(World world, MyPet myPet) { + public EntityMyMooshroom(Level world, MyPet myPet) { super(world, myPet); } @@ -63,59 +63,59 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (itemStack != null) { if (itemStack.getItem().equals(Items.nc)) { if (!getOwner().equals(entityhuman) || !canUseItem() || !Configuration.MyPet.Mooshroom.CAN_GIVE_SOUP) { - final int itemInHandIndex = entityhuman.getInventory().k; + final int itemInHandIndex = entityhuman.getInventory().selected; ItemStack is = new ItemStack(Items.nd); final ItemStack oldIs = entityhuman.getInventory().getItem(itemInHandIndex); entityhuman.getInventory().setItem(itemInHandIndex, is); Bukkit.getScheduler().scheduleSyncDelayedTask(MyPetApi.getPlugin(), () -> entityhuman.getInventory().setItem(itemInHandIndex, oldIs), 2L); } else { - itemStack.subtract(1); + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, new ItemStack(Items.nd)); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, new ItemStack(Items.nd)); } else { - if (!entityhuman.getInventory().pickup(new ItemStack(Items.nd))) { + if (!entityhuman.getInventory().add(new ItemStack(Items.nd))) { entityhuman.drop(new ItemStack(Items.pG), true); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } if (getOwner().equals(entityhuman) && canUseItem()) { if (Configuration.MyPet.Mooshroom.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(COLOR_WATCHER, "red"); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(COLOR_WATCHER, "red"); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); - this.getDataWatcher().set(COLOR_WATCHER, getMyPet().getType().getType()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(COLOR_WATCHER, getMyPet().getType().getType()); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMule.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMule.java index 99a38bf092..2ccbd976e6 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMule.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMule.java @@ -26,12 +26,12 @@ import de.Keyle.MyPet.api.entity.types.MyMule; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.core.BlockPosition; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.sounds.SoundEffects; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.IJumpable; import net.minecraft.world.entity.item.EntityItem; @@ -54,15 +54,15 @@ @EntitySize(width = 1.4F, height = 1.6F) public class EntityMyMule extends EntityMyPet implements IJumpable { - protected static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyMule.class, DataWatcherRegistry.i); - protected static final DataWatcherObject SADDLE_WATCHER = DataWatcher.a(EntityMyMule.class, DataWatcherRegistry.a); - protected static final DataWatcherObject> OWNER_WATCHER = DataWatcher.a(EntityMyMule.class, DataWatcherRegistry.o); - private static final DataWatcherObject CHEST_WATCHER = DataWatcher.a(EntityMyMule.class, DataWatcherRegistry.i); + protected static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyMule.class, EntityDataSerializers.BOOLEAN); + protected static final EntityDataAccessor SADDLE_WATCHER = SynchedEntityData.defineId(EntityMyMule.class, EntityDataSerializers.BYTE); + protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyMule.class, EntityDataSerializers.o); + private static final EntityDataAccessor CHEST_WATCHER = SynchedEntityData.defineId(EntityMyMule.class, EntityDataSerializers.BOOLEAN); int soundCounter = 0; int rearCounter = -1; - public EntityMyMule(World world, MyPet myPet) { + public EntityMyMule(Level world, MyPet myPet) { super(world, myPet); } @@ -75,11 +75,11 @@ public EntityMyMule(World world, MyPet myPet) { * 128 mouth open */ protected void applyVisual(int value, boolean flag) { - int i = this.getDataWatcher().get(SADDLE_WATCHER); + int i = this.getSynchedEntityData().get(SADDLE_WATCHER); if (flag) { - this.getDataWatcher().set(SADDLE_WATCHER, (byte) (i | value)); + this.getEntityData().set(SADDLE_WATCHER, (byte) (i | value)); } else { - this.getDataWatcher().set(SADDLE_WATCHER, (byte) (i & (~value))); + this.getEntityData().set(SADDLE_WATCHER, (byte) (i & (~value))); } } @@ -100,30 +100,30 @@ public boolean attack(Entity entity) { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (itemStack != null && canUseItem()) { if (itemStack.getItem() == Items.lL && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking() && canEquip()) { getMyPet().setSaddle(CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Item.getItemOf(Blocks.bX) && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && canEquip()) { getMyPet().setChest(CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { if (getMyPet().hasChest()) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getChest())); @@ -141,12 +141,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En makeSound("entity.sheep.shear", 1.0F, 1.0F); getMyPet().setChest(null); getMyPet().setSaddle(null); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -156,34 +156,34 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.Mule.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(SADDLE_WATCHER, (byte) 0); - getDataWatcher().register(OWNER_WATCHER, Optional.empty()); - getDataWatcher().register(CHEST_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(SADDLE_WATCHER, (byte) 0); + getEntityData().define(OWNER_WATCHER, Optional.empty()); + getEntityData().define(CHEST_WATCHER, false); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); - this.getDataWatcher().set(CHEST_WATCHER, getMyPet().hasChest()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(CHEST_WATCHER, getMyPet().hasChest()); applyVisual(4, getMyPet().hasSaddle()); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyOcelot.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyOcelot.java index b5388e61ce..350ba20ce8 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyOcelot.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyOcelot.java @@ -25,11 +25,11 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyOcelot; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.World; @@ -37,10 +37,10 @@ @EntitySize(width = 0.6F, height = 0.8F) public class EntityMyOcelot extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyOcelot.class, DataWatcherRegistry.i); - private static final DataWatcherObject TRUSTING_WATCHER = DataWatcher.a(EntityMyOcelot.class, DataWatcherRegistry.i); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyOcelot.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor TRUSTING_WATCHER = SynchedEntityData.defineId(EntityMyOcelot.class, EntityDataSerializers.BOOLEAN); - public EntityMyOcelot(World world, MyPet myPet) { + public EntityMyOcelot(Level world, MyPet myPet) { super(world, myPet); } @@ -60,38 +60,38 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman)) { if (itemStack != null && canUseItem() && getOwner().getPlayer().isSneaking()) { if (Configuration.MyPet.Ocelot.GROW_UP_ITEM.compare(itemStack) && canUseItem() && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(TRUSTING_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(TRUSTING_WATCHER, false); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPanda.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPanda.java index f45023e50b..cceef9bd77 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPanda.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPanda.java @@ -25,11 +25,11 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyPanda; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.World; @@ -37,15 +37,15 @@ @EntitySize(width = 1.825F, height = 1.25F) public class EntityMyPanda extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyPanda.class, DataWatcherRegistry.i); - private static final DataWatcherObject ASK_FOR_BAMBOO_TICKS_WATCHER = DataWatcher.a(EntityMyPanda.class, DataWatcherRegistry.b); - private static final DataWatcherObject SNEEZE_PROGRESS_WATCHER = DataWatcher.a(EntityMyPanda.class, DataWatcherRegistry.b); - private static final DataWatcherObject EATING_TICKS_WATCHER = DataWatcher.a(EntityMyPanda.class, DataWatcherRegistry.b); - private static final DataWatcherObject MAIN_GENE_WATCHER = DataWatcher.a(EntityMyPanda.class, DataWatcherRegistry.a); - private static final DataWatcherObject HIDDEN_GENE_WATCHER = DataWatcher.a(EntityMyPanda.class, DataWatcherRegistry.a); - private static final DataWatcherObject ACTIONS_WATCHER = DataWatcher.a(EntityMyPanda.class, DataWatcherRegistry.a); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyPanda.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor ASK_FOR_BAMBOO_TICKS_WATCHER = SynchedEntityData.defineId(EntityMyPanda.class, EntityDataSerializers.INT); + private static final EntityDataAccessor SNEEZE_PROGRESS_WATCHER = SynchedEntityData.defineId(EntityMyPanda.class, EntityDataSerializers.INT); + private static final EntityDataAccessor EATING_TICKS_WATCHER = SynchedEntityData.defineId(EntityMyPanda.class, EntityDataSerializers.INT); + private static final EntityDataAccessor MAIN_GENE_WATCHER = SynchedEntityData.defineId(EntityMyPanda.class, EntityDataSerializers.BYTE); + private static final EntityDataAccessor HIDDEN_GENE_WATCHER = SynchedEntityData.defineId(EntityMyPanda.class, EntityDataSerializers.BYTE); + private static final EntityDataAccessor ACTIONS_WATCHER = SynchedEntityData.defineId(EntityMyPanda.class, EntityDataSerializers.BYTE); - public EntityMyPanda(World world, MyPet myPet) { + public EntityMyPanda(Level world, MyPet myPet) { super(world, myPet); } @@ -65,45 +65,45 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman)) { if (itemStack != null && canUseItem() && getOwner().getPlayer().isSneaking()) { if (Configuration.MyPet.Ocelot.GROW_UP_ITEM.compare(itemStack) && canUseItem() && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(ASK_FOR_BAMBOO_TICKS_WATCHER, 0); - getDataWatcher().register(SNEEZE_PROGRESS_WATCHER, 0); - getDataWatcher().register(MAIN_GENE_WATCHER, (byte) 0); - getDataWatcher().register(HIDDEN_GENE_WATCHER, (byte) 0); - getDataWatcher().register(ACTIONS_WATCHER, (byte) 0); - getDataWatcher().register(EATING_TICKS_WATCHER, 0); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(ASK_FOR_BAMBOO_TICKS_WATCHER, 0); + getEntityData().define(SNEEZE_PROGRESS_WATCHER, 0); + getEntityData().define(MAIN_GENE_WATCHER, (byte) 0); + getEntityData().define(HIDDEN_GENE_WATCHER, (byte) 0); + getEntityData().define(ACTIONS_WATCHER, (byte) 0); + getEntityData().define(EATING_TICKS_WATCHER, 0); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); - this.getDataWatcher().set(MAIN_GENE_WATCHER, (byte) getMyPet().getMainGene().ordinal()); - this.getDataWatcher().set(HIDDEN_GENE_WATCHER, (byte) getMyPet().getHiddenGene().ordinal()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(MAIN_GENE_WATCHER, (byte) getMyPet().getMainGene().ordinal()); + this.getEntityData().set(HIDDEN_GENE_WATCHER, (byte) getMyPet().getHiddenGene().ordinal()); } /* diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyParrot.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyParrot.java index 9af98bcc4c..ffe99cbc69 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyParrot.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyParrot.java @@ -20,28 +20,28 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.util.Optional; +import java.util.UUID; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyParrot; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.level.World; -import java.util.Optional; -import java.util.UUID; - @EntitySize(width = 0.5F, height = 0.9f) public class EntityMyParrot extends EntityMyPet { + + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyParrot.class, EntityDataSerializers.BOOLEAN); + protected static final EntityDataAccessor SIT_WATCHER = SynchedEntityData.defineId(EntityMyParrot.class, EntityDataSerializers.INTYTE); + protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyParrot.class, EntityDataSerializers.OPTIONAL_UUID); + private static final EntityDataAccessor VARIANT_WATCHER = SynchedEntityData.defineId(EntityMyParrot.class, EntityDataSerializers.BOOLEANNT); - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyParrot.class, DataWatcherRegistry.i); - protected static final DataWatcherObject SIT_WATCHER = DataWatcher.a(EntityMyParrot.class, DataWatcherRegistry.a); - protected static final DataWatcherObject> OWNER_WATCHER = DataWatcher.a(EntityMyParrot.class, DataWatcherRegistry.o); - private static final DataWatcherObject VARIANT_WATCHER = DataWatcher.a(EntityMyParrot.class, DataWatcherRegistry.b); - - public EntityMyParrot(World world, MyPet myPet) { + public EntityMyParrot(Level world, MyPet myPet) { super(world, myPet); } @@ -72,17 +72,16 @@ protected String getLivingSound() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(SIT_WATCHER, (byte) 0); - getDataWatcher().register(OWNER_WATCHER, Optional.empty()); - getDataWatcher().register(VARIANT_WATCHER, 0); + protected void defineSynchedData() { + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(SIT_WATCHER, (byte) 0); + getEntityData().define(OWNER_WATCHER, Optional.empty()); + getEntityData().define(VARIANT_WATCHER, 0); } @Override public void updateVisuals() { - this.getDataWatcher().set(VARIANT_WATCHER, getMyPet().getVariant()); + this.getEntityData().set(VARIANT_WATCHER, getMyPet().getVariant()); } @Override @@ -90,8 +89,8 @@ public void onLivingUpdate() { super.onLivingUpdate(); if (Configuration.MyPet.Parrot.CAN_GLIDE) { - if (!this.z && this.getMot().getY() < 0.0D) { - this.setMot(getMot().d(1, 0.6D, 1)); + if (!this.onGround && this.getDeltaMovement().y() < 0.0D) { + this.setDeltaMovement(getDeltaMovement().multiply(1, 0.6D, 1)); } } } @@ -100,7 +99,7 @@ public void onLivingUpdate() { * -> disable falldamage */ @Override - public int d(float f, float f1) { + public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Parrot.CAN_GLIDE) { super.e(f, f1); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPhantom.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPhantom.java index 7381da27da..535770e005 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPhantom.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPhantom.java @@ -26,18 +26,18 @@ import de.Keyle.MyPet.api.entity.types.MyPhantom; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack.MeleeAttack; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.entity.EntityPose; import net.minecraft.world.level.World; @EntitySize(width = 0.51F, height = 0.51F) public class EntityMyPhantom extends EntityMyPet { - private static final DataWatcherObject SIZE_WATCHER = DataWatcher.a(EntityMyPhantom.class, DataWatcherRegistry.b); + private static final EntityDataAccessor SIZE_WATCHER = SynchedEntityData.defineId(EntityMyPhantom.class, EntityDataSerializers.INT); - public EntityMyPhantom(World world, MyPet myPet) { + public EntityMyPhantom(Level world, MyPet myPet) { super(world, myPet); } @@ -57,16 +57,16 @@ protected String getLivingSound() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); + protected void defineSynchedData() { + super.defineSynchedData(); - getDataWatcher().register(SIZE_WATCHER, 0); + getEntityData().define(SIZE_WATCHER, 0); } @Override public void updateVisuals() { int size = Math.max(1, getMyPet().getSize()); - getDataWatcher().set(SIZE_WATCHER, size); + getEntityData().set(SIZE_WATCHER, size); this.updateSize(); if (petPathfinderSelector != null && petPathfinderSelector.hasGoal("MeleeAttack")) { petPathfinderSelector.replaceGoal("MeleeAttack", new MeleeAttack(this, 0.1F, 3 + (getMyPet().getSize() * 0.2), 20)); @@ -95,8 +95,8 @@ public void onLivingUpdate() { super.onLivingUpdate(); if (Configuration.MyPet.Phantom.CAN_GLIDE) { - if (!this.z && this.getMot().getY() < 0.0D) { - this.setMot(getMot().d(1, 0.6D, 1)); + if (!this.onGround && this.getDeltaMovement().y() < 0.0D) { + this.setDeltaMovement(getDeltaMovement().multiply(1, 0.6D, 1)); } } } @@ -105,7 +105,7 @@ public void onLivingUpdate() { * -> disable falldamage */ @Override - public int d(float f, float f1) { + public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Phantom.CAN_GLIDE) { super.e(f, f1); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPig.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPig.java index f71641440d..d709f88a1a 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPig.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPig.java @@ -27,13 +27,13 @@ import de.Keyle.MyPet.api.entity.types.MyPig; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.server.level.EntityPlayer; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; @@ -50,10 +50,10 @@ @EntitySize(width = 0.7F, height = 0.9F) public class EntityMyPig extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyPig.class, DataWatcherRegistry.i); - private static final DataWatcherObject SADDLE_WATCHER = DataWatcher.a(EntityMyPig.class, DataWatcherRegistry.i); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyPig.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor SADDLE_WATCHER = SynchedEntityData.defineId(EntityMyPig.class, EntityDataSerializers.BOOLEAN); - public EntityMyPig(World world, MyPet myPet) { + public EntityMyPig(Level world, MyPet myPet) { super(world, myPet); } @@ -73,17 +73,17 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(final EntityHuman entityhuman, EnumHand enumhand, final ItemStack itemStack) { - if (enumhand == EnumHand.b) { + public InteractionResult handlePlayerInteraction(final EntityHuman entityhuman, InteractionHand enumhand, final ItemStack itemStack) { + if (enumhand == InteractionHand.b) { if (itemStack != null) { if (itemStack.getItem() == Items.rP) { ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutAttachEntity(this, null)); - entityhuman.a(EnumHand.b, ItemStack.b); + entityhuman.a(InteractionHand.b, ItemStack.EMPTY); new BukkitRunnable() { @Override public void run() { if (entityhuman instanceof EntityPlayer) { - entityhuman.a(EnumHand.b, itemStack); + entityhuman.a(InteractionHand.b, itemStack); Player p = (Player) entityhuman.getBukkitEntity(); if (!p.isOnline()) { p.saveData(); @@ -93,23 +93,23 @@ public void run() { }.runTaskLater(MyPetApi.getPlugin(), 5); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { if (itemStack.getItem() == Items.lL && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking()) { getMyPet().setSaddle(CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Items.pq && getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking()) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); entityitem.ap = 10; @@ -118,12 +118,12 @@ public void run() { makeSound("entity.sheep.shear", 1.0F, 1.0F); getMyPet().setSaddle(null); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -133,32 +133,32 @@ public void run() { } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.Pig.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(SADDLE_WATCHER, false); // saddle + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(SADDLE_WATCHER, false); // saddle } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); - this.getDataWatcher().set(SADDLE_WATCHER, getMyPet().hasSaddle()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(SADDLE_WATCHER, getMyPet().hasSaddle()); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglin.java index 3e3766c330..2f25c7a4b8 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglin.java @@ -31,13 +31,13 @@ import de.Keyle.MyPet.api.entity.types.MyPiglin; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -55,9 +55,9 @@ @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyPiglin extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyPiglin.class, DataWatcherRegistry.i); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyPiglin.class, EntityDataSerializers.BOOLEAN); - public EntityMyPiglin(World world, MyPet myPet) { + public EntityMyPiglin(Level world, MyPet myPet) { super(world, myPet); } @@ -77,9 +77,9 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack) == EnumInteractionResult.b) { - return EnumInteractionResult.b; + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack) == InteractionResult.CONSUME) { + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { @@ -97,12 +97,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -112,42 +112,42 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(EntityInsentient.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.Piglin.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); // is baby + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); // is baby } /** @@ -161,7 +161,7 @@ public float getSoundSpeed() { @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> { if (getMyPet().getStatus() == PetState.Here) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglinBrute.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglinBrute.java index 899581c72a..c9df5ce0e3 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglinBrute.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglinBrute.java @@ -32,14 +32,14 @@ import de.Keyle.MyPet.api.util.NMSUtil; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.server.level.WorldServer; import net.minecraft.sounds.SoundEffects; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -57,9 +57,9 @@ @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyPiglinBrute extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyPiglinBrute.class, DataWatcherRegistry.i); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyPiglinBrute.class, EntityDataSerializers.BOOLEAN); - public EntityMyPiglinBrute(World world, MyPet myPet) { + public EntityMyPiglinBrute(Level world, MyPet myPet) { super(world, myPet); } @@ -81,9 +81,9 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack) == EnumInteractionResult.b) { - return EnumInteractionResult.b; + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack) == InteractionResult.CONSUME) { + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { @@ -101,12 +101,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -116,42 +116,42 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(EntityInsentient.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.PiglinBrute.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); // is baby + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); // is baby } /** @@ -165,7 +165,7 @@ public float getSoundSpeed() { @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> { if (getMyPet().getStatus() == PetState.Here) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPillager.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPillager.java index 42284afba8..ad43e80177 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPillager.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPillager.java @@ -29,13 +29,13 @@ import de.Keyle.MyPet.api.entity.types.MyPillager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -54,10 +54,10 @@ @EntitySize(width = 0.6F, height = 1.95F) public class EntityMyPillager extends EntityMyPet { - protected static final DataWatcherObject RAID_WATCHER = DataWatcher.a(EntityMyPillager.class, DataWatcherRegistry.i); - private static final DataWatcherObject CROSSBOW_WATCHER = DataWatcher.a(EntityMyPillager.class, DataWatcherRegistry.i); + protected static final EntityDataAccessor RAID_WATCHER = SynchedEntityData.defineId(EntityMyPillager.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor CROSSBOW_WATCHER = SynchedEntityData.defineId(EntityMyPillager.class, EntityDataSerializers.BOOLEAN); - public EntityMyPillager(World world, MyPet myPet) { + public EntityMyPillager(Level world, MyPet myPet) { super(world, myPet); } @@ -92,9 +92,9 @@ protected String getLivingSound() { * false: no reaction on rightclick */ @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { @@ -112,12 +112,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -127,52 +127,52 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(EntityInsentient.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); if (slot == EquipmentSlot.MainHand) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } else if (itemStack.getItem() instanceof ItemBanner && getOwner().getPlayer().isSneaking() && canEquip()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(EquipmentSlot.Helmet)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(EquipmentSlot.Helmet, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(RAID_WATCHER, false); - getDataWatcher().register(CROSSBOW_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(RAID_WATCHER, false); + getEntityData().define(CROSSBOW_WATCHER, false); } @Override @@ -193,7 +193,7 @@ public MyPillager getMyPet() { public void setPetEquipment(ItemStack itemStack, EnumItemSlot slot) { ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(slot, itemStack)))); if (slot == EnumItemSlot.a) { - getDataWatcher().set(CROSSBOW_WATCHER, itemStack.getItem() == Items.sS); + getEntityData().set(CROSSBOW_WATCHER, itemStack.getItem() == Items.sS); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPolarBear.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPolarBear.java index bdb3ec10dc..369bd3648d 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPolarBear.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPolarBear.java @@ -25,11 +25,11 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyPolarBear; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; @@ -38,12 +38,12 @@ @EntitySize(width = 1.3F, height = 1.4F) public class EntityMyPolarBear extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyPolarBear.class, DataWatcherRegistry.i); - private static final DataWatcherObject REAR_WATCHER = DataWatcher.a(EntityMyPolarBear.class, DataWatcherRegistry.i); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyPolarBear.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor REAR_WATCHER = SynchedEntityData.defineId(EntityMyPolarBear.class, EntityDataSerializers.BOOLEAN); int rearCounter = -1; - public EntityMyPolarBear(World world, MyPet myPet) { + public EntityMyPolarBear(Level world, MyPet myPet) { super(world, myPet); } @@ -63,31 +63,31 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { if (Configuration.MyPet.Cow.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(REAR_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(REAR_WATCHER, false); } @@ -97,7 +97,7 @@ public boolean attack(Entity entity) { try { flag = super.attack(entity); if (flag) { - this.getDataWatcher().set(REAR_WATCHER, true); + this.getEntityData().set(REAR_WATCHER, true); rearCounter = 10; } } catch (Exception e) { @@ -110,14 +110,14 @@ public boolean attack(Entity entity) { public void onLivingUpdate() { super.onLivingUpdate(); if (rearCounter > -1 && rearCounter-- == 0) { - this.getDataWatcher().set(REAR_WATCHER, false); + this.getEntityData().set(REAR_WATCHER, false); rearCounter = -1; } } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java index 83a7ddaa26..edf0a60d9f 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java @@ -26,18 +26,18 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyPufferfish; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.level.World; @EntitySize(width = 0.5F, height = 0.5f) public class EntityMyPufferfish extends EntityMyPet { - private static final DataWatcherObject FROM_BUCKET_WATCHER = DataWatcher.a(EntityMyPufferfish.class, DataWatcherRegistry.i); - private static final DataWatcherObject PUFF_WATCHER = DataWatcher.a(EntityMyPufferfish.class, DataWatcherRegistry.b); + private static final EntityDataAccessor FROM_BUCKET_WATCHER = SynchedEntityData.defineId(EntityMyPufferfish.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor PUFF_WATCHER = SynchedEntityData.defineId(EntityMyPufferfish.class, EntityDataSerializers.INT); - public EntityMyPufferfish(World world, MyPet myPet) { + public EntityMyPufferfish(Level world, MyPet myPet) { super(world, myPet); } @@ -71,13 +71,13 @@ public MyPufferfish getMyPet() { @Override public void updateVisuals() { - getDataWatcher().set(PUFF_WATCHER, getMyPet().getPuffState().ordinal()); + getEntityData().set(PUFF_WATCHER, getMyPet().getPuffState().ordinal()); } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(FROM_BUCKET_WATCHER, false); - getDataWatcher().register(PUFF_WATCHER, 0); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(FROM_BUCKET_WATCHER, false); + getEntityData().define(PUFF_WATCHER, 0); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRabbit.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRabbit.java index b0b31a9a56..57e8460e53 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRabbit.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRabbit.java @@ -29,11 +29,11 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyRabbit; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.World; @@ -41,12 +41,12 @@ @EntitySize(width = 0.6F, height = 0.7F) public class EntityMyRabbit extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyRabbit.class, DataWatcherRegistry.i); - private static final DataWatcherObject VARIANT_WATCHER = DataWatcher.a(EntityMyRabbit.class, DataWatcherRegistry.b); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyRabbit.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor VARIANT_WATCHER = SynchedEntityData.defineId(EntityMyRabbit.class, EntityDataSerializers.INT); int jumpDelay; - public EntityMyRabbit(World world, MyPet myPet) { + public EntityMyRabbit(Level world, MyPet myPet) { super(world, myPet); this.jumpDelay = (this.Q.nextInt(20) + 10); } @@ -72,37 +72,37 @@ public void playPetStepSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { if (Configuration.MyPet.Rabbit.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } this.getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - public void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); // is baby - getDataWatcher().register(VARIANT_WATCHER, 0); // variant + public void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); // is baby + getEntityData().define(VARIANT_WATCHER, 0); // variant } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); - this.getDataWatcher().set(VARIANT_WATCHER, (int) getMyPet().getVariant().getId()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(VARIANT_WATCHER, (int) getMyPet().getVariant().getId()); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRavager.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRavager.java index 1f1541b8f7..5e8aa7063b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRavager.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRavager.java @@ -26,11 +26,11 @@ import de.Keyle.MyPet.api.entity.types.MyRavager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.skill.skills.RideImpl; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.World; @@ -38,9 +38,9 @@ @EntitySize(width = 1.95F, height = 2.2F) public class EntityMyRavager extends EntityMyPet { - protected static final DataWatcherObject RAID_WATCHER = DataWatcher.a(EntityMyRavager.class, DataWatcherRegistry.i); + protected static final EntityDataAccessor RAID_WATCHER = SynchedEntityData.defineId(EntityMyRavager.class, EntityDataSerializers.BOOLEAN); - public EntityMyRavager(World world, MyPet myPet) { + public EntityMyRavager(Level world, MyPet myPet) { super(world, myPet); } @@ -60,9 +60,9 @@ protected String getLivingSound() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(RAID_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(RAID_WATCHER, false); } @@ -72,11 +72,11 @@ public void playPetStepSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (Configuration.Skilltree.Skill.Ride.RIDE_ITEM.compare(itemStack)) { if (myPet.getSkills().isActive(RideImpl.class) && canMove()) { getOwner().sendMessage("Unfortunately, Ravagers can not be ridden (Minecraft limitation)", 5000); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } return super.handlePlayerInteraction(entityhuman, enumhand, itemStack); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySalmon.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySalmon.java index 607dae32cb..52765f799c 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySalmon.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySalmon.java @@ -25,17 +25,17 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.level.World; @EntitySize(width = 0.7F, height = 0.4f) public class EntityMySalmon extends EntityMyPet { - private static final DataWatcherObject FROM_BUCKET_WATCHER = DataWatcher.a(EntityMySalmon.class, DataWatcherRegistry.i); + private static final EntityDataAccessor FROM_BUCKET_WATCHER = SynchedEntityData.defineId(EntityMySalmon.class, EntityDataSerializers.BOOLEAN); - public EntityMySalmon(World world, MyPet myPet) { + public EntityMySalmon(Level world, MyPet myPet) { super(world, myPet); } @@ -63,8 +63,8 @@ public void onLivingUpdate() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(FROM_BUCKET_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(FROM_BUCKET_WATCHER, false); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySheep.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySheep.java index b54f735af8..810d0b3c72 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySheep.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySheep.java @@ -26,11 +26,11 @@ import de.Keyle.MyPet.api.entity.types.MySheep; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement.EatGrass; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.EnumColor; @@ -51,8 +51,8 @@ @EntitySize(width = 0.7F, height = 1.2349999f) public class EntityMySheep extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMySheep.class, DataWatcherRegistry.i); - private static final DataWatcherObject COLOR_WATCHER = DataWatcher.a(EntityMySheep.class, DataWatcherRegistry.a); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMySheep.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor COLOR_WATCHER = SynchedEntityData.defineId(EntityMySheep.class, EntityDataSerializers.BYTE); private static final Map colorMap = new HashMap<>(); @@ -75,7 +75,7 @@ public class EntityMySheep extends EntityMyPet { colorMap.put(EnumColor.p, Blocks.bt); } - public EntityMySheep(World world, MyPet myPet) { + public EntityMySheep(Level world, MyPet myPet) { super(world, myPet); } @@ -95,21 +95,21 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { if (itemStack.getItem() instanceof ItemDye && ((ItemDye) itemStack.getItem()).d().ordinal() != getMyPet().getColor().ordinal() && !getMyPet().isSheared()) { getMyPet().setColor(DyeColor.values()[((ItemDye) itemStack.getItem()).d().ordinal()]); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Items.pq && Configuration.MyPet.Sheep.CAN_BE_SHEARED && !getMyPet().isSheared()) { getMyPet().setSheared(true); int woolDropCount = 1 + this.Q.nextInt(3); @@ -121,12 +121,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En this.t.addEntity(entityitem); } makeSound("entity.sheep.shear", 1.0F, 1.0F); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -135,34 +135,34 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En }); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.Sheep.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(COLOR_WATCHER, (byte) 0); // color/sheared + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(COLOR_WATCHER, (byte) 0); // color/sheared } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); byte data = (byte) (getMyPet().isSheared() ? 16 : 0); - this.getDataWatcher().set(COLOR_WATCHER, (byte) (data & 0xF0 | getMyPet().getColor().ordinal() & 0xF)); + this.getEntityData().set(COLOR_WATCHER, (byte) (data & 0xF0 | getMyPet().getColor().ordinal() & 0xF)); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySilverfish.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySilverfish.java index ebc08a0b06..f6bf7cc55b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySilverfish.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySilverfish.java @@ -28,7 +28,7 @@ @EntitySize(width = 0.4F, height = 0.1F) public class EntityMySilverfish extends EntityMyPet { - public EntityMySilverfish(World world, MyPet myPet) { + public EntityMySilverfish(Level world, MyPet myPet) { super(world, myPet); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeleton.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeleton.java index c5bb869b2b..40c96ffd79 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeleton.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeleton.java @@ -31,9 +31,9 @@ import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -51,7 +51,7 @@ @EntitySize(width = 0.6F, height = 1.9F) public class EntityMySkeleton extends EntityMyPet { - public EntityMySkeleton(World world, MyPet myPet) { + public EntityMySkeleton(Level world, MyPet myPet) { super(world, myPet); } @@ -86,9 +86,9 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { @@ -106,12 +106,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -121,27 +121,27 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(EntityInsentient.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java index 912dabd421..f051542346 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java @@ -26,12 +26,12 @@ import de.Keyle.MyPet.api.entity.types.MySkeletonHorse; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.core.BlockPosition; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.sounds.SoundEffects; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.IJumpable; import net.minecraft.world.entity.item.EntityItem; @@ -53,14 +53,14 @@ @EntitySize(width = 1.4F, height = 1.6F) public class EntityMySkeletonHorse extends EntityMyPet implements IJumpable { - protected static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMySkeletonHorse.class, DataWatcherRegistry.i); - protected static final DataWatcherObject SADDLE_CHEST_WATCHER = DataWatcher.a(EntityMySkeletonHorse.class, DataWatcherRegistry.a); - protected static final DataWatcherObject> OWNER_WATCHER = DataWatcher.a(EntityMySkeletonHorse.class, DataWatcherRegistry.o); + protected static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMySkeletonHorse.class, EntityDataSerializers.BOOLEAN); + protected static final EntityDataAccessor SADDLE_CHEST_WATCHER = SynchedEntityData.defineId(EntityMySkeletonHorse.class, EntityDataSerializers.BYTE); + protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMySkeletonHorse.class, EntityDataSerializers.o); int soundCounter = 0; int rearCounter = -1; - public EntityMySkeletonHorse(World world, MyPet myPet) { + public EntityMySkeletonHorse(Level world, MyPet myPet) { super(world, myPet); } @@ -73,11 +73,11 @@ public EntityMySkeletonHorse(World world, MyPet myPet) { * 128 mouth open */ protected void applyVisual(int value, boolean flag) { - int i = getDataWatcher().get(SADDLE_CHEST_WATCHER); + int i = getSynchedEntityData().get(SADDLE_CHEST_WATCHER); if (flag) { - this.getDataWatcher().set(SADDLE_CHEST_WATCHER, (byte) (i | value)); + this.getEntityData().set(SADDLE_CHEST_WATCHER, (byte) (i | value)); } else { - this.getDataWatcher().set(SADDLE_CHEST_WATCHER, (byte) (i & (~value))); + this.getEntityData().set(SADDLE_CHEST_WATCHER, (byte) (i & (~value))); } } @@ -113,21 +113,21 @@ protected String getLivingSound() { @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (itemStack != null && canUseItem()) { if (itemStack.getItem() == Items.lL && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking() && canEquip()) { getMyPet().setSaddle(CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { if (getMyPet().hasSaddle()) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); @@ -138,12 +138,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En makeSound("entity.sheep.shear", 1.0F, 1.0F); getMyPet().setSaddle(null); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -153,32 +153,32 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.SkeletonHorse.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(SADDLE_CHEST_WATCHER, (byte) 0); - getDataWatcher().register(OWNER_WATCHER, Optional.empty()); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(SADDLE_CHEST_WATCHER, (byte) 0); + getEntityData().define(OWNER_WATCHER, Optional.empty()); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); applyVisual(4, getMyPet().hasSaddle()); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySlime.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySlime.java index fe5647e356..e244e3f9c6 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySlime.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySlime.java @@ -25,20 +25,20 @@ import de.Keyle.MyPet.api.entity.types.MySlime; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack.MeleeAttack; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.entity.EntityPose; import net.minecraft.world.level.World; @EntitySize(width = 0.51F, height = 0.51F) public class EntityMySlime extends EntityMyPet { - private static final DataWatcherObject SIZE_WATCHER = DataWatcher.a(EntityMySlime.class, DataWatcherRegistry.b); + private static final EntityDataAccessor SIZE_WATCHER = SynchedEntityData.defineId(EntityMySlime.class, EntityDataSerializers.INT); int jumpDelay; - public EntityMySlime(World world, MyPet myPet) { + public EntityMySlime(Level world, MyPet myPet) { super(world, myPet); this.jumpDelay = (this.Q.nextInt(20) + 10); } @@ -60,15 +60,15 @@ protected String getLivingSound() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(SIZE_WATCHER, 1); //size + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(SIZE_WATCHER, 1); //size } @Override public void updateVisuals() { int size = Math.max(1, getMyPet().getSize()); - getDataWatcher().set(SIZE_WATCHER, size); + getEntityData().set(SIZE_WATCHER, size); this.updateSize(); if (petPathfinderSelector != null && petPathfinderSelector.hasGoal("MeleeAttack")) { petPathfinderSelector.replaceGoal("MeleeAttack", new MeleeAttack(this, 0.1F, 3 + (getMyPet().getSize() * 0.51), 20)); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySnowman.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySnowman.java index 77d0ab00f8..43ce2bf9c4 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySnowman.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySnowman.java @@ -24,11 +24,11 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MySnowman; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -43,37 +43,37 @@ @EntitySize(width = 0.7F, height = 1.7F) public class EntityMySnowman extends EntityMyPet { - private static final DataWatcherObject SHEARED_WATCHER = DataWatcher.a(EntityMySnowman.class, DataWatcherRegistry.a); + private static final EntityDataAccessor SHEARED_WATCHER = SynchedEntityData.defineId(EntityMySnowman.class, EntityDataSerializers.BYTE); - public EntityMySnowman(World world, MyPet myPet) { + public EntityMySnowman(Level world, MyPet myPet) { super(world, myPet); } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { if (itemStack.getItem() == Item.getItemOf(Blocks.cS) && getMyPet().isSheared() && entityhuman.isSneaking()) { getMyPet().setSheared(false); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Items.pq && !getMyPet().isSheared() && entityhuman.isSneaking()) { getMyPet().setSheared(true); makeSound("entity.sheep.shear", 1.0F, 1.0F); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -82,22 +82,22 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En }); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override public void updateVisuals() { - getDataWatcher().set(SHEARED_WATCHER, (byte) (getMyPet().isSheared() ? 0 : 16)); + getEntityData().set(SHEARED_WATCHER, (byte) (getMyPet().isSheared() ? 0 : 16)); } @Override - protected void initDatawatcher() { - super.initDatawatcher(); + protected void defineSynchedData() { + super.defineSynchedData(); - getDataWatcher().register(SHEARED_WATCHER, (byte) 16); + getEntityData().define(SHEARED_WATCHER, (byte) 16); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySpider.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySpider.java index f5abb83f4e..834b50aeb3 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySpider.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySpider.java @@ -28,7 +28,7 @@ @EntitySize(width = 1.4F, height = 0.9F) public class EntityMySpider extends EntityMyPet { - public EntityMySpider(World world, MyPet myPet) { + public EntityMySpider(Level world, MyPet myPet) { super(world, myPet); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySquid.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySquid.java index 3bf0a83a71..7ff7fbb66c 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySquid.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySquid.java @@ -30,7 +30,7 @@ @EntitySize(width = 0.7F, height = 0.475f) public class EntityMySquid extends EntityMyPet { - public EntityMySquid(World world, MyPet myPet) { + public EntityMySquid(Level world, MyPet myPet) { super(world, myPet); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStray.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStray.java index 02705688cc..b6e5e27690 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStray.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStray.java @@ -31,9 +31,9 @@ import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -51,7 +51,7 @@ @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyStray extends EntityMyPet { - public EntityMyStray(World world, MyPet myPet) { + public EntityMyStray(Level world, MyPet myPet) { super(world, myPet); } @@ -71,9 +71,9 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { @@ -91,12 +91,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -106,28 +106,28 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(EntityInsentient.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStrider.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStrider.java index 7b0f55b198..d2593590ac 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStrider.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStrider.java @@ -25,11 +25,11 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyStrider; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; @@ -44,12 +44,12 @@ @EntitySize(width = 0.9F, height = 1.7F) public class EntityMyStrider extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyStrider.class, DataWatcherRegistry.i); - private static final DataWatcherObject BOOST_TICKS_WATCHER = DataWatcher.a(EntityMyStrider.class, DataWatcherRegistry.b); - private static final DataWatcherObject HAS_RIDER_WATCHER = DataWatcher.a(EntityMyStrider.class, DataWatcherRegistry.i); - private static final DataWatcherObject SADDLE_WATCHER = DataWatcher.a(EntityMyStrider.class, DataWatcherRegistry.i); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyStrider.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor BOOST_TICKS_WATCHER = SynchedEntityData.defineId(EntityMyStrider.class, EntityDataSerializers.INT); + private static final EntityDataAccessor HAS_RIDER_WATCHER = SynchedEntityData.defineId(EntityMyStrider.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor SADDLE_WATCHER = SynchedEntityData.defineId(EntityMyStrider.class, EntityDataSerializers.BOOLEAN); - public EntityMyStrider(World world, MyPet myPet) { + public EntityMyStrider(Level world, MyPet myPet) { super(world, myPet); } @@ -69,21 +69,21 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(final EntityHuman entityhuman, EnumHand enumhand, final ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(final EntityHuman entityhuman, InteractionHand enumhand, final ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { if (itemStack.getItem() == Items.lL && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking()) { getMyPet().setSaddle(CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Items.pq && getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking()) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); entityitem.ap = 10; @@ -92,12 +92,12 @@ public EnumInteractionResult handlePlayerInteraction(final EntityHuman entityhum makeSound("entity.sheep.shear", 1.0F, 1.0F); getMyPet().setSaddle(null); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -107,34 +107,34 @@ public EnumInteractionResult handlePlayerInteraction(final EntityHuman entityhum } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.Strider.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(BOOST_TICKS_WATCHER, 0); - getDataWatcher().register(HAS_RIDER_WATCHER, false); - getDataWatcher().register(SADDLE_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(BOOST_TICKS_WATCHER, 0); + getEntityData().define(HAS_RIDER_WATCHER, false); + getEntityData().define(SADDLE_WATCHER, false); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); - this.getDataWatcher().set(SADDLE_WATCHER, getMyPet().hasSaddle()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(SADDLE_WATCHER, getMyPet().hasSaddle()); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTraderLlama.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTraderLlama.java index dd561a64d9..333a913596 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTraderLlama.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTraderLlama.java @@ -25,12 +25,12 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyTraderLlama; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.tags.TagsItem; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; @@ -50,15 +50,15 @@ @EntitySize(width = 0.9F, height = 1.87F) public class EntityMyTraderLlama extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyTraderLlama.class, DataWatcherRegistry.i); - private static final DataWatcherObject SADDLE_CHEST_WATCHER = DataWatcher.a(EntityMyTraderLlama.class, DataWatcherRegistry.a); - private static final DataWatcherObject> OWNER_WATCHER = DataWatcher.a(EntityMyTraderLlama.class, DataWatcherRegistry.o); - private static final DataWatcherObject CHEST_WATCHER = DataWatcher.a(EntityMyTraderLlama.class, DataWatcherRegistry.i); - private static final DataWatcherObject STRENGTH_WATCHER = DataWatcher.a(EntityMyTraderLlama.class, DataWatcherRegistry.b); - private static final DataWatcherObject COLOR_WATCHER = DataWatcher.a(EntityMyTraderLlama.class, DataWatcherRegistry.b); - private static final DataWatcherObject VARIANT_WATCHER = DataWatcher.a(EntityMyTraderLlama.class, DataWatcherRegistry.b); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyTraderLlama.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor SADDLE_CHEST_WATCHER = SynchedEntityData.defineId(EntityMyTraderLlama.class, EntityDataSerializers.BYTE); + private static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyTraderLlama.class, EntityDataSerializers.o); + private static final EntityDataAccessor CHEST_WATCHER = SynchedEntityData.defineId(EntityMyTraderLlama.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor STRENGTH_WATCHER = SynchedEntityData.defineId(EntityMyTraderLlama.class, EntityDataSerializers.INT); + private static final EntityDataAccessor COLOR_WATCHER = SynchedEntityData.defineId(EntityMyTraderLlama.class, EntityDataSerializers.INT); + private static final EntityDataAccessor VARIANT_WATCHER = SynchedEntityData.defineId(EntityMyTraderLlama.class, EntityDataSerializers.INT); - public EntityMyTraderLlama(World world, MyPet myPet) { + public EntityMyTraderLlama(Level world, MyPet myPet) { super(world, myPet); } @@ -79,30 +79,30 @@ protected String getLivingSound() { @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (itemStack != null && canUseItem()) { if (TagsItem.g.isTagged(itemStack.getItem()) && !getMyPet().hasDecor() && getOwner().getPlayer().isSneaking() && canEquip()) { getMyPet().setDecor(CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Blocks.bX.getItem() && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && !getMyPet().isBaby() && canEquip()) { getMyPet().setChest(CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { if (getMyPet().hasChest()) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getChest())); @@ -120,12 +120,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En makeSound("entity.sheep.shear", 1.0F, 1.0F); getMyPet().setChest(null); getMyPet().setDecor(null); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -135,46 +135,46 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.Llama.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(SADDLE_CHEST_WATCHER, (byte) 0); // saddle & chest - getDataWatcher().register(OWNER_WATCHER, Optional.empty()); // owner - getDataWatcher().register(CHEST_WATCHER, true); - getDataWatcher().register(STRENGTH_WATCHER, 0); - getDataWatcher().register(COLOR_WATCHER, 0); - getDataWatcher().register(VARIANT_WATCHER, 0); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(SADDLE_CHEST_WATCHER, (byte) 0); // saddle & chest + getEntityData().define(OWNER_WATCHER, Optional.empty()); // owner + getEntityData().define(CHEST_WATCHER, true); + getEntityData().define(STRENGTH_WATCHER, 0); + getEntityData().define(COLOR_WATCHER, 0); + getEntityData().define(VARIANT_WATCHER, 0); } @Override public void updateVisuals() { - this.getDataWatcher().set(CHEST_WATCHER, getMyPet().hasChest()); - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(CHEST_WATCHER, getMyPet().hasChest()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); if (getMyPet().hasDecor()) { ItemStack is = CraftItemStack.asNMSCopy(getMyPet().getDecor()); Block block = Block.asBlock(is.getItem()); int color = block instanceof BlockCarpet ? ((BlockCarpet) block).c().getColorIndex() : 0; - this.getDataWatcher().set(COLOR_WATCHER, color); + this.getEntityData().set(COLOR_WATCHER, color); } else { - this.getDataWatcher().set(COLOR_WATCHER, -1); + this.getEntityData().set(COLOR_WATCHER, -1); } - this.getDataWatcher().set(VARIANT_WATCHER, getMyPet().getVariant()); + this.getEntityData().set(VARIANT_WATCHER, getMyPet().getVariant()); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTropicalFish.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTropicalFish.java index a13f1946ae..024cc72689 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTropicalFish.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTropicalFish.java @@ -26,18 +26,18 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyTropicalFish; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.level.World; @EntitySize(width = 0.5F, height = 0.4f) public class EntityMyTropicalFish extends EntityMyPet { - private static final DataWatcherObject FROM_BUCKET_WATCHER = DataWatcher.a(EntityMyTropicalFish.class, DataWatcherRegistry.i); - private static final DataWatcherObject VARIANT_WATCHER = DataWatcher.a(EntityMyTropicalFish.class, DataWatcherRegistry.b); + private static final EntityDataAccessor FROM_BUCKET_WATCHER = SynchedEntityData.defineId(EntityMyTropicalFish.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor VARIANT_WATCHER = SynchedEntityData.defineId(EntityMyTropicalFish.class, EntityDataSerializers.INT); - public EntityMyTropicalFish(World world, MyPet myPet) { + public EntityMyTropicalFish(Level world, MyPet myPet) { super(world, myPet); } @@ -71,13 +71,13 @@ public MyTropicalFish getMyPet() { @Override public void updateVisuals() { - getDataWatcher().set(VARIANT_WATCHER, getMyPet().getVariant()); + getEntityData().set(VARIANT_WATCHER, getMyPet().getVariant()); } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(FROM_BUCKET_WATCHER, false); - getDataWatcher().register(VARIANT_WATCHER, 0); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(FROM_BUCKET_WATCHER, false); + getEntityData().define(VARIANT_WATCHER, 0); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTurtle.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTurtle.java index ba2c130f02..b37aabb3a4 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTurtle.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTurtle.java @@ -26,11 +26,11 @@ import de.Keyle.MyPet.api.entity.types.MyTurtle; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.core.BlockPosition; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.World; @@ -38,15 +38,15 @@ @EntitySize(width = 1.2F, height = 0.4F) public class EntityMyTurtle extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyTurtle.class, DataWatcherRegistry.i); - private static final DataWatcherObject HOME_WATCHER = DataWatcher.a(EntityMyTurtle.class, DataWatcherRegistry.l); - private static final DataWatcherObject HAS_EGG_WATCHER = DataWatcher.a(EntityMyTurtle.class, DataWatcherRegistry.i); - private static final DataWatcherObject UNUSED_WATCHER_1 = DataWatcher.a(EntityMyTurtle.class, DataWatcherRegistry.i); - private static final DataWatcherObject TRAVEL_POS_WATCHER = DataWatcher.a(EntityMyTurtle.class, DataWatcherRegistry.l); - private static final DataWatcherObject UNUSED_WATCHER_2 = DataWatcher.a(EntityMyTurtle.class, DataWatcherRegistry.i); - private static final DataWatcherObject UNUSED_WATCHER_3 = DataWatcher.a(EntityMyTurtle.class, DataWatcherRegistry.i); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor HOME_WATCHER = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.l); + private static final EntityDataAccessor HAS_EGG_WATCHER = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor UNUSED_WATCHER_1 = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor TRAVEL_POS_WATCHER = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.l); + private static final EntityDataAccessor UNUSED_WATCHER_2 = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor UNUSED_WATCHER_3 = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.BOOLEAN); - public EntityMyTurtle(World world, MyPet myPet) { + public EntityMyTurtle(Level world, MyPet myPet) { super(world, myPet); } @@ -66,41 +66,41 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { if (Configuration.MyPet.Cow.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(HOME_WATCHER, BlockPosition.b); - getDataWatcher().register(HAS_EGG_WATCHER, false); - getDataWatcher().register(TRAVEL_POS_WATCHER, BlockPosition.b); - getDataWatcher().register(UNUSED_WATCHER_2, false); - getDataWatcher().register(UNUSED_WATCHER_3, false); - getDataWatcher().register(UNUSED_WATCHER_1, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(HOME_WATCHER, BlockPosition.b); + getEntityData().define(HAS_EGG_WATCHER, false); + getEntityData().define(TRAVEL_POS_WATCHER, BlockPosition.b); + getEntityData().define(UNUSED_WATCHER_2, false); + getEntityData().define(UNUSED_WATCHER_3, false); + getEntityData().define(UNUSED_WATCHER_1, false); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVex.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVex.java index 67ac76aca5..20d74c6d32 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVex.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVex.java @@ -32,13 +32,13 @@ import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.skill.skills.BehaviorImpl; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -56,11 +56,11 @@ @EntitySize(width = 0.4F, height = 0.8F) public class EntityMyVex extends EntityMyPet { - protected static final DataWatcherObject CHARGING_WATCHER = DataWatcher.a(EntityMyVex.class, DataWatcherRegistry.a); + protected static final EntityDataAccessor CHARGING_WATCHER = SynchedEntityData.defineId(EntityMyVex.class, EntityDataSerializers.BYTE); protected boolean isAggressive = false; - public EntityMyVex(World world, MyPet myPet) { + public EntityMyVex(Level world, MyPet myPet) { super(world, myPet); } @@ -95,9 +95,9 @@ protected String getLivingSound() { * false: no reaction on rightclick */ @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { @@ -115,12 +115,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -130,40 +130,40 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(EntityInsentient.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); if (slot == EquipmentSlot.MainHand) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(CHARGING_WATCHER, (byte) 0); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(CHARGING_WATCHER, (byte) 0); } @Override public void updateVisuals() { - getDataWatcher().set(CHARGING_WATCHER, (byte) (getMyPet().isGlowing() || isAggressive ? 1 : 0)); + getEntityData().set(CHARGING_WATCHER, (byte) (getMyPet().isGlowing() || isAggressive ? 1 : 0)); Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> { if (getMyPet().getStatus() == MyPet.PetState.Here) { @@ -196,8 +196,8 @@ public ItemStack getEquipment(EnumItemSlot vanillaSlot) { public void onLivingUpdate() { super.onLivingUpdate(); if (Configuration.MyPet.Vex.CAN_GLIDE) { - if (!this.z && this.getMot().getY() < 0.0D) { - this.setMot(getMot().d(1, 0.6D, 1)); + if (!this.onGround && this.getDeltaMovement().y() < 0.0D) { + this.setDeltaMovement(getDeltaMovement().multiply(1, 0.6D, 1)); } } } @@ -224,7 +224,7 @@ protected void doMyPetTick() { * -> disable falldamage */ @Override - public int d(float f, float f1) { + public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Vex.CAN_GLIDE) { super.e(f, f1); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVillager.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVillager.java index 2fce7c78d5..3f1fca9254 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVillager.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVillager.java @@ -27,12 +27,12 @@ import de.Keyle.MyPet.api.entity.types.MyVillager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.core.IRegistry; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.resources.MinecraftKey; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.npc.VillagerData; import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.entity.npc.VillagerType; @@ -43,11 +43,11 @@ @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyVillager extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyVillager.class, DataWatcherRegistry.i); - private static final DataWatcherObject UNUSED_WATCHER = DataWatcher.a(EntityMyVillager.class, DataWatcherRegistry.b); - private static final DataWatcherObject PROFESSION_WATCHER = DataWatcher.a(EntityMyVillager.class, DataWatcherRegistry.q); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyVillager.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor UNUSED_WATCHER = SynchedEntityData.defineId(EntityMyVillager.class, EntityDataSerializers.INT); + private static final EntityDataAccessor PROFESSION_WATCHER = SynchedEntityData.defineId(EntityMyVillager.class, EntityDataSerializers.q); - public EntityMyVillager(World world, MyPet myPet) { + public EntityMyVillager(Level world, MyPet myPet) { super(world, myPet); } @@ -67,43 +67,43 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { if (Configuration.MyPet.Villager.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); if (MyPetApi.getCompatUtil().isCompatible("1.14.1")) { - getDataWatcher().register(UNUSED_WATCHER, 0); + getEntityData().define(UNUSED_WATCHER, 0); } - getDataWatcher().register(PROFESSION_WATCHER, new VillagerData(VillagerType.c, VillagerProfession.a, 1)); + getEntityData().define(PROFESSION_WATCHER, new VillagerData(VillagerType.c, VillagerProfession.a, 1)); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); String professionKey = MyVillager.Profession.values()[getMyPet().getProfession()].getKey(); VillagerProfession profession = IRegistry.ap.get(new MinecraftKey(professionKey)); VillagerType type = IRegistry.ao.get(new MinecraftKey(getMyPet().getType().getKey())); - this.getDataWatcher().set(PROFESSION_WATCHER, new VillagerData(type, profession, getMyPet().getVillagerLevel())); + this.getEntityData().set(PROFESSION_WATCHER, new VillagerData(type, profession, getMyPet().getVillagerLevel())); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVindicator.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVindicator.java index 8fa75a4f12..c9e18ca129 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVindicator.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVindicator.java @@ -30,13 +30,13 @@ import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -52,9 +52,9 @@ @EntitySize(width = 0.6F, height = 1.95F) public class EntityMyVindicator extends EntityMyPet { - protected static final DataWatcherObject RAID_WATCHER = DataWatcher.a(EntityMyVindicator.class, DataWatcherRegistry.i); + protected static final EntityDataAccessor RAID_WATCHER = SynchedEntityData.defineId(EntityMyVindicator.class, EntityDataSerializers.BOOLEAN); - public EntityMyVindicator(World world, MyPet myPet) { + public EntityMyVindicator(Level world, MyPet myPet) { super(world, myPet); } @@ -89,9 +89,9 @@ protected String getLivingSound() { * false: no reaction on rightclick */ @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { @@ -109,12 +109,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -124,35 +124,35 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(EntityInsentient.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); if (slot == EquipmentSlot.MainHand) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(RAID_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(RAID_WATCHER, false); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWanderingTrader.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWanderingTrader.java index 221003f38e..8597be5178 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWanderingTrader.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWanderingTrader.java @@ -25,17 +25,17 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyWanderingTrader; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.level.World; @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyWanderingTrader extends EntityMyPet { - private static final DataWatcherObject UNUSED_WATCHER = DataWatcher.a(EntityMyWanderingTrader.class, DataWatcherRegistry.b); + private static final EntityDataAccessor UNUSED_WATCHER = SynchedEntityData.defineId(EntityMyWanderingTrader.class, EntityDataSerializers.INT); - public EntityMyWanderingTrader(World world, MyPet myPet) { + public EntityMyWanderingTrader(Level world, MyPet myPet) { super(world, myPet); } @@ -55,10 +55,10 @@ protected String getLivingSound() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); + protected void defineSynchedData() { + super.defineSynchedData(); if (MyPetApi.getCompatUtil().isCompatible("1.14.1")) { - getDataWatcher().register(UNUSED_WATCHER, 0); + getEntityData().define(UNUSED_WATCHER, 0); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitch.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitch.java index 04c10c44bc..568c71ae39 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitch.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitch.java @@ -28,7 +28,7 @@ @EntitySize(width = 0.6F, height = 1.62F) public class EntityMyWitch extends EntityMyPet { - public EntityMyWitch(World world, MyPet myPet) { + public EntityMyWitch(Level world, MyPet myPet) { super(world, myPet); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWither.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWither.java index c910f4df79..beb3be4997 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWither.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWither.java @@ -25,20 +25,20 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyWither; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.level.World; @EntitySize(width = 1.9F, height = 3.5F) public class EntityMyWither extends EntityMyPet { - private static final DataWatcherObject TARGET_WATCHER = DataWatcher.a(EntityMyWither.class, DataWatcherRegistry.b); - private static final DataWatcherObject UNUSED_WATCHER_1 = DataWatcher.a(EntityMyWither.class, DataWatcherRegistry.b); - private static final DataWatcherObject UNUSED_WATCHER_2 = DataWatcher.a(EntityMyWither.class, DataWatcherRegistry.b); - private static final DataWatcherObject INVULNERABILITY_WATCHER = DataWatcher.a(EntityMyWither.class, DataWatcherRegistry.b); + private static final EntityDataAccessor TARGET_WATCHER = SynchedEntityData.defineId(EntityMyWither.class, EntityDataSerializers.INT); + private static final EntityDataAccessor UNUSED_WATCHER_1 = SynchedEntityData.defineId(EntityMyWither.class, EntityDataSerializers.INT); + private static final EntityDataAccessor UNUSED_WATCHER_2 = SynchedEntityData.defineId(EntityMyWither.class, EntityDataSerializers.INT); + private static final EntityDataAccessor INVULNERABILITY_WATCHER = SynchedEntityData.defineId(EntityMyWither.class, EntityDataSerializers.INT); - public EntityMyWither(World world, MyPet myPet) { + public EntityMyWither(Level world, MyPet myPet) { super(world, myPet); } @@ -58,34 +58,34 @@ protected String getLivingSound() { } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(TARGET_WATCHER, 0); - getDataWatcher().register(UNUSED_WATCHER_1, 0); - getDataWatcher().register(UNUSED_WATCHER_2, 0); - getDataWatcher().register(INVULNERABILITY_WATCHER, 0); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(TARGET_WATCHER, 0); + getEntityData().define(UNUSED_WATCHER_1, 0); + getEntityData().define(UNUSED_WATCHER_2, 0); + getEntityData().define(INVULNERABILITY_WATCHER, 0); } @Override public void onLivingUpdate() { super.onLivingUpdate(); if (Configuration.MyPet.Wither.CAN_GLIDE) { - if (!this.z && this.getMot().getY() < 0.0D) { - this.setMot(getMot().d(1, 0.6D, 1)); + if (!this.onGround && this.getDeltaMovement().y() < 0.0D) { + this.setDeltaMovement(getDeltaMovement().multiply(1, 0.6D, 1)); } } } @Override public void updateVisuals() { - getDataWatcher().set(INVULNERABILITY_WATCHER, getMyPet().isBaby() ? 600 : 0); + getEntityData().set(INVULNERABILITY_WATCHER, getMyPet().isBaby() ? 600 : 0); } /** * -> disable falldamage */ @Override - public int d(float f, float f1) { + public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Wither.CAN_GLIDE) { super.e(f, f1); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitherSkeleton.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitherSkeleton.java index a3786fd002..80caa8defa 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitherSkeleton.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitherSkeleton.java @@ -31,9 +31,9 @@ import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -51,7 +51,7 @@ @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyWitherSkeleton extends EntityMyPet { - public EntityMyWitherSkeleton(World world, MyPet myPet) { + public EntityMyWitherSkeleton(Level world, MyPet myPet) { super(world, myPet); } @@ -71,9 +71,9 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { @@ -91,12 +91,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -106,28 +106,28 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(EntityInsentient.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWolf.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWolf.java index 0c6dac12e8..2f0a98cf57 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWolf.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWolf.java @@ -26,12 +26,12 @@ import de.Keyle.MyPet.api.entity.types.MyWolf; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.core.particles.Particles; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.util.MathHelper; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.ai.attributes.GenericAttributes; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemDye; @@ -46,27 +46,27 @@ @EntitySize(width = 0.6F, height = 0.64f) public class EntityMyWolf extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyWolf.class, DataWatcherRegistry.i); - protected static final DataWatcherObject SIT_WATCHER = DataWatcher.a(EntityMyWolf.class, DataWatcherRegistry.a); - protected static final DataWatcherObject> OWNER_WATCHER = DataWatcher.a(EntityMyWolf.class, DataWatcherRegistry.o); - private static final DataWatcherObject TAIL_WATCHER = DataWatcher.a(EntityMyWolf.class, DataWatcherRegistry.c); - private static final DataWatcherObject UNUSED_WATCHER = DataWatcher.a(EntityMyWolf.class, DataWatcherRegistry.i); - private static final DataWatcherObject COLLAR_COLOR_WATCHER = DataWatcher.a(EntityMyWolf.class, DataWatcherRegistry.b); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyWolf.class, EntityDataSerializers.BOOLEAN); + protected static final EntityDataAccessor SIT_WATCHER = SynchedEntityData.defineId(EntityMyWolf.class, EntityDataSerializers.BYTE); + protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyWolf.class, EntityDataSerializers.o); + private static final EntityDataAccessor TAIL_WATCHER = SynchedEntityData.defineId(EntityMyWolf.class, EntityDataSerializers.c); + private static final EntityDataAccessor UNUSED_WATCHER = SynchedEntityData.defineId(EntityMyWolf.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor COLLAR_COLOR_WATCHER = SynchedEntityData.defineId(EntityMyWolf.class, EntityDataSerializers.INT); protected boolean shaking; protected boolean isWet; protected float shakeCounter; - public EntityMyWolf(World world, MyPet myPet) { + public EntityMyWolf(Level world, MyPet myPet) { super(world, myPet); } public void applySitting(boolean sitting) { - int i = this.getDataWatcher().get(SIT_WATCHER); + int i = this.getSynchedEntityData().get(SIT_WATCHER); if (sitting) { - this.getDataWatcher().set(SIT_WATCHER, (byte) (i | 0x1)); + this.getEntityData().set(SIT_WATCHER, (byte) (i | 0x1)); } else { - this.getDataWatcher().set(SIT_WATCHER, (byte) (i & 0xFFFFFFFE)); + this.getEntityData().set(SIT_WATCHER, (byte) (i & 0xFFFFFFFE)); } } @@ -86,9 +86,9 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman)) { @@ -97,43 +97,43 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En if (itemStack.getItem() instanceof ItemDye && ((ItemDye) itemStack.getItem()).d().ordinal() != getMyPet().getCollarColor().ordinal()) { if (getOwner().getPlayer().isSneaking()) { getMyPet().setCollarColor(DyeColor.values()[((ItemDye) itemStack.getItem()).d().ordinal()]); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else { - this.getDataWatcher().set(COLLAR_COLOR_WATCHER, 0); + this.getEntityData().set(COLLAR_COLOR_WATCHER, 0); updateVisuals(); } } else if (Configuration.MyPet.Wolf.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(SIT_WATCHER, (byte) 0); - getDataWatcher().register(OWNER_WATCHER, Optional.empty()); - getDataWatcher().register(TAIL_WATCHER, 30F); - getDataWatcher().register(UNUSED_WATCHER, false); // not used - getDataWatcher().register(COLLAR_COLOR_WATCHER, 14); + protected void defineSynchedData() { + super.defineSynchedData(); + + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(SIT_WATCHER, (byte) 0); + getEntityData().define(OWNER_WATCHER, Optional.empty()); + getEntityData().define(TAIL_WATCHER, 30F); + getEntityData().define(UNUSED_WATCHER, false); // not used + getEntityData().define(COLLAR_COLOR_WATCHER, 14); } @Override @@ -143,23 +143,23 @@ protected void initAttributes() { @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); - byte b0 = this.getDataWatcher().get(SIT_WATCHER); + byte b0 = this.getSynchedEntityData().get(SIT_WATCHER); if (getMyPet().isTamed()) { - this.getDataWatcher().set(SIT_WATCHER, (byte) (b0 | 0x4)); + this.getEntityData().set(SIT_WATCHER, (byte) (b0 | 0x4)); } else { - this.getDataWatcher().set(SIT_WATCHER, (byte) (b0 & 0xFFFFFFFB)); + this.getEntityData().set(SIT_WATCHER, (byte) (b0 & 0xFFFFFFFB)); } - b0 = this.getDataWatcher().get(SIT_WATCHER); + b0 = this.getSynchedEntityData().get(SIT_WATCHER); if (getMyPet().isAngry()) { - this.getDataWatcher().set(SIT_WATCHER, (byte) (b0 | 0x2)); + this.getEntityData().set(SIT_WATCHER, (byte) (b0 | 0x2)); } else { - this.getDataWatcher().set(SIT_WATCHER, (byte) (b0 & 0xFFFFFFFD)); + this.getEntityData().set(SIT_WATCHER, (byte) (b0 & 0xFFFFFFFD)); } - this.getDataWatcher().set(COLLAR_COLOR_WATCHER, getMyPet().getCollarColor().ordinal()); + this.getEntityData().set(COLLAR_COLOR_WATCHER, getMyPet().getCollarColor().ordinal()); } @Override @@ -200,8 +200,8 @@ public void onLivingUpdate() { } float tailHeight = 30F * (getHealth() / getMaxHealth()); - if (this.getDataWatcher().get(TAIL_WATCHER) != tailHeight) { - this.getDataWatcher().set(TAIL_WATCHER, tailHeight); // update tail height + if (this.getSynchedEntityData().get(TAIL_WATCHER) != tailHeight) { + this.getEntityData().set(TAIL_WATCHER, tailHeight); // update tail height } } @@ -215,7 +215,7 @@ public void setHealth(float i) { super.setHealth(i); float tailHeight = 30F * (i / getMaxHealth()); - this.getDataWatcher().set(TAIL_WATCHER, tailHeight); + this.getEntityData().set(TAIL_WATCHER, tailHeight); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZoglin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZoglin.java index 1a9c8cdd5f..81d1f9edaf 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZoglin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZoglin.java @@ -25,11 +25,11 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyZoglin; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.World; @@ -37,9 +37,9 @@ @EntitySize(width = 1.3965F, height = 1.4F) public class EntityMyZoglin extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyZoglin.class, DataWatcherRegistry.i); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyZoglin.class, EntityDataSerializers.BOOLEAN); - public EntityMyZoglin(World world, MyPet myPet) { + public EntityMyZoglin(Level world, MyPet myPet) { super(world, myPet); } @@ -59,35 +59,35 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(final EntityHuman entityhuman, EnumHand enumhand, final ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(final EntityHuman entityhuman, InteractionHand enumhand, final ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { if (Configuration.MyPet.Zoglin.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombie.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombie.java index 008e56a800..5ca183e35d 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombie.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombie.java @@ -30,13 +30,13 @@ import de.Keyle.MyPet.api.entity.types.MyZombie; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -54,12 +54,12 @@ @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyZombie extends EntityMyPet { - private static final DataWatcherObject BABY_WATCHER = DataWatcher.a(EntityMyZombie.class, DataWatcherRegistry.i); - private static final DataWatcherObject TYPE_WATCHER = DataWatcher.a(EntityMyZombie.class, DataWatcherRegistry.b); - private static final DataWatcherObject DROWN_CONVERTING = DataWatcher.a(EntityMyZombie.class, DataWatcherRegistry.i); - private static final DataWatcherObject UNUSED_WATCHER_2 = DataWatcher.a(EntityMyZombie.class, DataWatcherRegistry.i); + private static final EntityDataAccessor BABY_WATCHER = SynchedEntityData.defineId(EntityMyZombie.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor TYPE_WATCHER = SynchedEntityData.defineId(EntityMyZombie.class, EntityDataSerializers.INT); + private static final EntityDataAccessor DROWN_CONVERTING = SynchedEntityData.defineId(EntityMyZombie.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor UNUSED_WATCHER_2 = SynchedEntityData.defineId(EntityMyZombie.class, EntityDataSerializers.BOOLEAN); - public EntityMyZombie(World world, MyPet myPet) { + public EntityMyZombie(Level world, MyPet myPet) { super(world, myPet); } @@ -94,9 +94,9 @@ protected String getLivingSound() { * false: no reaction on rightclick */ @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { @@ -114,12 +114,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -129,49 +129,49 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(EntityInsentient.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.Zombie.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(BABY_WATCHER, false); - getDataWatcher().register(TYPE_WATCHER, 0); - getDataWatcher().register(DROWN_CONVERTING, false); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(BABY_WATCHER, false); + getEntityData().define(TYPE_WATCHER, 0); + getEntityData().define(DROWN_CONVERTING, false); } @Override public void updateVisuals() { - getDataWatcher().set(BABY_WATCHER, getMyPet().isBaby()); + getEntityData().set(BABY_WATCHER, getMyPet().isBaby()); Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> { if (getMyPet().getStatus() == MyPet.PetState.Here) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieHorse.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieHorse.java index fd2b061b82..f985044e6a 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieHorse.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieHorse.java @@ -26,12 +26,12 @@ import de.Keyle.MyPet.api.entity.types.MyZombieHorse; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.core.BlockPosition; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.sounds.SoundEffects; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.IJumpable; import net.minecraft.world.entity.item.EntityItem; @@ -53,14 +53,14 @@ @EntitySize(width = 1.4F, height = 1.6F) public class EntityMyZombieHorse extends EntityMyPet implements IJumpable { - protected static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyZombieHorse.class, DataWatcherRegistry.i); - protected static final DataWatcherObject SADDLE_CHEST_WATCHER = DataWatcher.a(EntityMyZombieHorse.class, DataWatcherRegistry.a); - protected static final DataWatcherObject> OWNER_WATCHER = DataWatcher.a(EntityMyZombieHorse.class, DataWatcherRegistry.o); + protected static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyZombieHorse.class, EntityDataSerializers.BOOLEAN); + protected static final EntityDataAccessor SADDLE_CHEST_WATCHER = SynchedEntityData.defineId(EntityMyZombieHorse.class, EntityDataSerializers.BYTE); + protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyZombieHorse.class, EntityDataSerializers.o); int soundCounter = 0; int rearCounter = -1; - public EntityMyZombieHorse(World world, MyPet myPet) { + public EntityMyZombieHorse(Level world, MyPet myPet) { super(world, myPet); } @@ -73,11 +73,11 @@ public EntityMyZombieHorse(World world, MyPet myPet) { * 128 mouth open */ protected void applyVisual(int value, boolean flag) { - int i = this.getDataWatcher().get(SADDLE_CHEST_WATCHER); + int i = this.getSynchedEntityData().get(SADDLE_CHEST_WATCHER); if (flag) { - this.getDataWatcher().set(SADDLE_CHEST_WATCHER, (byte) (i | value)); + this.getEntityData().set(SADDLE_CHEST_WATCHER, (byte) (i | value)); } else { - this.getDataWatcher().set(SADDLE_CHEST_WATCHER, (byte) (i & (~value))); + this.getEntityData().set(SADDLE_CHEST_WATCHER, (byte) (i & (~value))); } } @@ -113,21 +113,21 @@ protected String getLivingSound() { @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (itemStack != null && canUseItem()) { if (itemStack.getItem() == Items.lL && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking() && canEquip()) { getMyPet().setSaddle(CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { if (getMyPet().hasSaddle()) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); @@ -138,12 +138,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En makeSound("entity.sheep.shear", 1.0F, 1.0F); getMyPet().setSaddle(null); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -153,32 +153,32 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.ZombieHorse.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); - getDataWatcher().register(SADDLE_CHEST_WATCHER, (byte) 0); - getDataWatcher().register(OWNER_WATCHER, Optional.empty()); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(SADDLE_CHEST_WATCHER, (byte) 0); + getEntityData().define(OWNER_WATCHER, Optional.empty()); } @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); applyVisual(4, getMyPet().hasSaddle()); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieVillager.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieVillager.java index 53b5154b2b..c9d063b225 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieVillager.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieVillager.java @@ -32,14 +32,14 @@ import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.core.IRegistry; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.resources.MinecraftKey; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.npc.VillagerData; @@ -60,13 +60,13 @@ @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyZombieVillager extends EntityMyPet { - private static final DataWatcherObject BABY_WATCHER = DataWatcher.a(EntityMyZombieVillager.class, DataWatcherRegistry.i); - private static final DataWatcherObject TYPE_WATCHER = DataWatcher.a(EntityMyZombieVillager.class, DataWatcherRegistry.b); - private static final DataWatcherObject DROWN_CONVERTING = DataWatcher.a(EntityMyZombieVillager.class, DataWatcherRegistry.i); - private static final DataWatcherObject SHIVER_WATCHER = DataWatcher.a(EntityMyZombieVillager.class, DataWatcherRegistry.i); - private static final DataWatcherObject PROFESSION_WATCHER = DataWatcher.a(EntityMyZombieVillager.class, DataWatcherRegistry.q); + private static final EntityDataAccessor BABY_WATCHER = SynchedEntityData.defineId(EntityMyZombieVillager.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor TYPE_WATCHER = SynchedEntityData.defineId(EntityMyZombieVillager.class, EntityDataSerializers.INT); + private static final EntityDataAccessor DROWN_CONVERTING = SynchedEntityData.defineId(EntityMyZombieVillager.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor SHIVER_WATCHER = SynchedEntityData.defineId(EntityMyZombieVillager.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor PROFESSION_WATCHER = SynchedEntityData.defineId(EntityMyZombieVillager.class, EntityDataSerializers.q); - public EntityMyZombieVillager(World world, MyPet myPet) { + public EntityMyZombieVillager(Level world, MyPet myPet) { super(world, myPet); } @@ -101,9 +101,9 @@ protected String getLivingSound() { * false: no reaction on rightclick */ @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { @@ -121,12 +121,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -136,56 +136,56 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(EntityInsentient.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.Zombie.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(BABY_WATCHER, false); - getDataWatcher().register(TYPE_WATCHER, 0); - getDataWatcher().register(DROWN_CONVERTING, false); - getDataWatcher().register(SHIVER_WATCHER, false); - - getDataWatcher().register(PROFESSION_WATCHER, new VillagerData(VillagerType.c, VillagerProfession.a, 1)); + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(BABY_WATCHER, false); + getEntityData().define(TYPE_WATCHER, 0); + getEntityData().define(DROWN_CONVERTING, false); + getEntityData().define(SHIVER_WATCHER, false); + + getEntityData().define(PROFESSION_WATCHER, new VillagerData(VillagerType.c, VillagerProfession.a, 1)); } @Override public void updateVisuals() { - getDataWatcher().set(BABY_WATCHER, getMyPet().isBaby()); + getEntityData().set(BABY_WATCHER, getMyPet().isBaby()); String professionKey = MyVillager.Profession.values()[getMyPet().getProfession()].getKey(); VillagerProfession profession = IRegistry.ap.get(new MinecraftKey(professionKey)); VillagerType type = IRegistry.ao.get(new MinecraftKey(getMyPet().getType().getKey())); - getDataWatcher().set(PROFESSION_WATCHER, new VillagerData(type, profession, getMyPet().getTradingLevel())); + getEntityData().set(PROFESSION_WATCHER, new VillagerData(type, profession, getMyPet().getTradingLevel())); Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> { if (getMyPet().getStatus() == MyPet.PetState.Here) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombifiedPiglin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombifiedPiglin.java index 6c6af926c2..ec9edeb925 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombifiedPiglin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombifiedPiglin.java @@ -31,13 +31,13 @@ import de.Keyle.MyPet.api.entity.types.MyZombifiedPiglin; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.EnumHand; -import net.minecraft.world.EnumInteractionResult; -import net.minecraft.world.entity.EntityInsentient; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.player.EntityHuman; @@ -55,9 +55,9 @@ @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyZombifiedPiglin extends EntityMyPet { - private static final DataWatcherObject AGE_WATCHER = DataWatcher.a(EntityMyZombifiedPiglin.class, DataWatcherRegistry.i); + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyZombifiedPiglin.class, EntityDataSerializers.BOOLEAN); - public EntityMyZombifiedPiglin(World world, MyPet myPet) { + public EntityMyZombifiedPiglin(Level world, MyPet myPet) { super(world, myPet); } @@ -77,9 +77,9 @@ protected String getLivingSound() { } @Override - public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack) == EnumInteractionResult.b) { - return EnumInteractionResult.b; + public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack) == InteractionResult.CONSUME) { + return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { @@ -97,12 +97,12 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } if (hadEquipment) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { try { - itemStack.damage(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastItemBreak(enumhand)); + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> entityhuman1.broadcastBreakEvent(enumhand)); } catch (Error e) { // TODO REMOVE - itemStack.damage(1, entityhuman, (entityhuman1) -> { + itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { @@ -112,42 +112,42 @@ public EnumInteractionResult handlePlayerInteraction(EntityHuman entityhuman, En } } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(EntityInsentient.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.b && !entityhuman.getAbilities().d) { + if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); entityitem.ap = 10; entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); this.t.addEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } else if (Configuration.MyPet.ZombifiedPiglin.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { - if (itemStack != ItemStack.b && !entityhuman.getAbilities().d) { - itemStack.subtract(1); + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().k, ItemStack.b); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } getMyPet().setBaby(false); - return EnumInteractionResult.b; + return InteractionResult.CONSUME; } } - return EnumInteractionResult.d; + return InteractionResult.PASS; } @Override - protected void initDatawatcher() { - super.initDatawatcher(); - getDataWatcher().register(AGE_WATCHER, false); // is baby + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); // is baby } /** @@ -161,7 +161,7 @@ public float getSoundSpeed() { @Override public void updateVisuals() { - this.getDataWatcher().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> { if (getMyPet().getStatus() == PetState.Here) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetArrow.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetArrow.java index 3013a9f895..cffe9a0f5a 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetArrow.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetArrow.java @@ -20,19 +20,20 @@ package de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit; +import org.bukkit.craftbukkit.v1_17_R1.CraftServer; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftArrow; + import de.Keyle.MyPet.api.entity.MyPetBukkitEntity; import de.Keyle.MyPet.api.entity.MyPetMinecraftEntity; import de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile; import de.Keyle.MyPet.api.entity.skill.ranged.EntityMyPetProjectile; import de.Keyle.MyPet.api.util.Compat; -import net.minecraft.world.entity.projectile.EntityArrow; -import org.bukkit.craftbukkit.v1_17_R1.CraftServer; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftArrow; +import net.minecraft.world.entity.projectile.Arrow; @Compat("v1_17_R1") public class CraftMyPetArrow extends CraftArrow implements CraftMyPetProjectile { - public CraftMyPetArrow(CraftServer server, EntityArrow entity) { + public CraftMyPetArrow(CraftServer server, Arrow entity) { super(server, entity); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetDragonFireball.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetDragonFireball.java index 5786ab4a3f..39a2a1f79f 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetDragonFireball.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetDragonFireball.java @@ -20,19 +20,20 @@ package de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit; +import org.bukkit.craftbukkit.v1_17_R1.CraftServer; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftDragonFireball; + import de.Keyle.MyPet.api.entity.MyPetBukkitEntity; import de.Keyle.MyPet.api.entity.MyPetMinecraftEntity; import de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile; import de.Keyle.MyPet.api.entity.skill.ranged.EntityMyPetProjectile; import de.Keyle.MyPet.api.util.Compat; -import net.minecraft.world.entity.projectile.EntityDragonFireball; -import org.bukkit.craftbukkit.v1_17_R1.CraftServer; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftDragonFireball; +import net.minecraft.world.entity.projectile.DragonFireball; @Compat("v1_17_R1") public class CraftMyPetDragonFireball extends CraftDragonFireball implements CraftMyPetProjectile { - public CraftMyPetDragonFireball(CraftServer server, EntityDragonFireball entity) { + public CraftMyPetDragonFireball(CraftServer server, DragonFireball entity) { super(server, entity); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetEgg.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetEgg.java index 28d0014275..057e324cdf 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetEgg.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetEgg.java @@ -20,19 +20,20 @@ package de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit; +import org.bukkit.craftbukkit.v1_17_R1.CraftServer; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEgg; + import de.Keyle.MyPet.api.entity.MyPetBukkitEntity; import de.Keyle.MyPet.api.entity.MyPetMinecraftEntity; import de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile; import de.Keyle.MyPet.api.entity.skill.ranged.EntityMyPetProjectile; import de.Keyle.MyPet.api.util.Compat; -import net.minecraft.world.entity.projectile.EntityEgg; -import org.bukkit.craftbukkit.v1_17_R1.CraftServer; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEgg; +import net.minecraft.world.entity.projectile.ThrownEgg; @Compat("v1_17_R1") public class CraftMyPetEgg extends CraftEgg implements CraftMyPetProjectile { - public CraftMyPetEgg(CraftServer server, EntityEgg entity) { + public CraftMyPetEgg(CraftServer server, ThrownEgg entity) { super(server, entity); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetEnderPearl.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetEnderPearl.java index 04c6ec0e5a..09cbda8c72 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetEnderPearl.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetEnderPearl.java @@ -20,19 +20,20 @@ package de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit; +import org.bukkit.craftbukkit.v1_17_R1.CraftServer; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEnderPearl; + import de.Keyle.MyPet.api.entity.MyPetBukkitEntity; import de.Keyle.MyPet.api.entity.MyPetMinecraftEntity; import de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile; import de.Keyle.MyPet.api.entity.skill.ranged.EntityMyPetProjectile; import de.Keyle.MyPet.api.util.Compat; -import net.minecraft.world.entity.projectile.EntityEnderPearl; -import org.bukkit.craftbukkit.v1_17_R1.CraftServer; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEnderPearl; +import net.minecraft.world.entity.projectile.ThrownEnderpearl; @Compat("v1_17_R1") public class CraftMyPetEnderPearl extends CraftEnderPearl implements CraftMyPetProjectile { - public CraftMyPetEnderPearl(CraftServer server, EntityEnderPearl entity) { + public CraftMyPetEnderPearl(CraftServer server, ThrownEnderpearl entity) { super(server, entity); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetLargeFireball.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetLargeFireball.java index af0231373d..9b38f05c0b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetLargeFireball.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetLargeFireball.java @@ -20,19 +20,20 @@ package de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit; +import org.bukkit.craftbukkit.v1_17_R1.CraftServer; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLargeFireball; + import de.Keyle.MyPet.api.entity.MyPetBukkitEntity; import de.Keyle.MyPet.api.entity.MyPetMinecraftEntity; import de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile; import de.Keyle.MyPet.api.entity.skill.ranged.EntityMyPetProjectile; import de.Keyle.MyPet.api.util.Compat; -import net.minecraft.world.entity.projectile.EntityLargeFireball; -import org.bukkit.craftbukkit.v1_17_R1.CraftServer; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLargeFireball; +import net.minecraft.world.entity.projectile.LargeFireball; @Compat("v1_17_R1") public class CraftMyPetLargeFireball extends CraftLargeFireball implements CraftMyPetProjectile { - public CraftMyPetLargeFireball(CraftServer server, EntityLargeFireball entity) { + public CraftMyPetLargeFireball(CraftServer server, LargeFireball entity) { super(server, entity); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetLlamaSpit.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetLlamaSpit.java index c592f9541a..128355804e 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetLlamaSpit.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetLlamaSpit.java @@ -20,19 +20,20 @@ package de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit; +import org.bukkit.craftbukkit.v1_17_R1.CraftServer; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLlamaSpit; + import de.Keyle.MyPet.api.entity.MyPetBukkitEntity; import de.Keyle.MyPet.api.entity.MyPetMinecraftEntity; import de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile; import de.Keyle.MyPet.api.entity.skill.ranged.EntityMyPetProjectile; import de.Keyle.MyPet.api.util.Compat; -import net.minecraft.world.entity.projectile.EntityLlamaSpit; -import org.bukkit.craftbukkit.v1_17_R1.CraftServer; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLlamaSpit; +import net.minecraft.world.entity.projectile.LlamaSpit; @Compat("v1_17_R1") public class CraftMyPetLlamaSpit extends CraftLlamaSpit implements CraftMyPetProjectile { - public CraftMyPetLlamaSpit(CraftServer server, EntityLlamaSpit entity) { + public CraftMyPetLlamaSpit(CraftServer server, LlamaSpit entity) { super(server, entity); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetSmallFireball.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetSmallFireball.java index 26dce4deed..954ac9b2b0 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetSmallFireball.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetSmallFireball.java @@ -20,19 +20,20 @@ package de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit; +import org.bukkit.craftbukkit.v1_17_R1.CraftServer; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftSmallFireball; + import de.Keyle.MyPet.api.entity.MyPetBukkitEntity; import de.Keyle.MyPet.api.entity.MyPetMinecraftEntity; import de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile; import de.Keyle.MyPet.api.entity.skill.ranged.EntityMyPetProjectile; import de.Keyle.MyPet.api.util.Compat; -import net.minecraft.world.entity.projectile.EntitySmallFireball; -import org.bukkit.craftbukkit.v1_17_R1.CraftServer; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftSmallFireball; +import net.minecraft.world.entity.projectile.SmallFireball; @Compat("v1_17_R1") public class CraftMyPetSmallFireball extends CraftSmallFireball implements CraftMyPetProjectile { - public CraftMyPetSmallFireball(CraftServer server, EntitySmallFireball entity) { + public CraftMyPetSmallFireball(CraftServer server, SmallFireball entity) { super(server, entity); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetSnowball.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetSnowball.java index ef57c3d707..69a922b209 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetSnowball.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetSnowball.java @@ -20,19 +20,20 @@ package de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit; +import org.bukkit.craftbukkit.v1_17_R1.CraftServer; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftSnowball; + import de.Keyle.MyPet.api.entity.MyPetBukkitEntity; import de.Keyle.MyPet.api.entity.MyPetMinecraftEntity; import de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile; import de.Keyle.MyPet.api.entity.skill.ranged.EntityMyPetProjectile; import de.Keyle.MyPet.api.util.Compat; -import net.minecraft.world.entity.projectile.EntitySnowball; -import org.bukkit.craftbukkit.v1_17_R1.CraftServer; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftSnowball; +import net.minecraft.world.entity.projectile.Snowball; @Compat("v1_17_R1") public class CraftMyPetSnowball extends CraftSnowball implements CraftMyPetProjectile { - public CraftMyPetSnowball(CraftServer server, EntitySnowball entity) { + public CraftMyPetSnowball(CraftServer server, Snowball entity) { super(server, entity); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetTrident.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetTrident.java index e59d4af9b4..6544d62fe4 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetTrident.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetTrident.java @@ -20,22 +20,23 @@ package de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit; -import de.Keyle.MyPet.api.entity.MyPetBukkitEntity; -import de.Keyle.MyPet.api.entity.MyPetMinecraftEntity; -import de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile; -import de.Keyle.MyPet.api.entity.skill.ranged.EntityMyPetProjectile; -import de.Keyle.MyPet.api.util.Compat; -import net.minecraft.world.entity.projectile.EntityThrownTrident; import org.bukkit.craftbukkit.v1_17_R1.CraftServer; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftTrident; import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import de.Keyle.MyPet.api.entity.MyPetBukkitEntity; +import de.Keyle.MyPet.api.entity.MyPetMinecraftEntity; +import de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile; +import de.Keyle.MyPet.api.entity.skill.ranged.EntityMyPetProjectile; +import de.Keyle.MyPet.api.util.Compat; +import net.minecraft.world.entity.projectile.ThrownTrident; + @Compat("v1_17_R1") public class CraftMyPetTrident extends CraftTrident implements CraftMyPetProjectile { - public CraftMyPetTrident(CraftServer server, EntityThrownTrident entity) { + public CraftMyPetTrident(CraftServer server, ThrownTrident entity) { super(server, entity); } @@ -67,11 +68,11 @@ public void setPersistent(boolean b) { @NotNull @Override public ItemStack getItem() { - return CraftItemStack.asBukkitCopy(getHandle().aq); + return CraftItemStack.asBukkitCopy(getHandle().tridentItem); } @Override public void setItem(@NotNull ItemStack itemStack) { - getHandle().aq = CraftItemStack.asNMSCopy(itemStack); + getHandle().tridentItem = CraftItemStack.asNMSCopy(itemStack); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetWitherSkull.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetWitherSkull.java index 2faea15dab..d72f65879b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetWitherSkull.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/bukkit/CraftMyPetWitherSkull.java @@ -20,19 +20,20 @@ package de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit; +import org.bukkit.craftbukkit.v1_17_R1.CraftServer; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftWitherSkull; + import de.Keyle.MyPet.api.entity.MyPetBukkitEntity; import de.Keyle.MyPet.api.entity.MyPetMinecraftEntity; import de.Keyle.MyPet.api.entity.skill.ranged.CraftMyPetProjectile; import de.Keyle.MyPet.api.entity.skill.ranged.EntityMyPetProjectile; import de.Keyle.MyPet.api.util.Compat; -import net.minecraft.world.entity.projectile.EntityWitherSkull; -import org.bukkit.craftbukkit.v1_17_R1.CraftServer; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftWitherSkull; +import net.minecraft.world.entity.projectile.WitherSkull; @Compat("v1_17_R1") public class CraftMyPetWitherSkull extends CraftWitherSkull implements CraftMyPetProjectile { - public CraftMyPetWitherSkull(CraftServer server, EntityWitherSkull entity) { + public CraftMyPetWitherSkull(CraftServer server, WitherSkull entity) { super(server, entity); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetArrow.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetArrow.java index 1a8e9c8301..3b1f816970 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetArrow.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetArrow.java @@ -24,25 +24,25 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetArrow; -import net.minecraft.nbt.NBTTagCompound; +import io.lumine.xikage.mythicmobs.utils.shadows.nbt.NBTTagCompound; +import net.minecraft.util.datafix.fixes.EntityTippedArrowFix; import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.projectile.EntityTippedArrow; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @Compat("v1_17_R1") public class MyPetArrow extends EntityTippedArrow implements EntityMyPetProjectile { protected CraftMyPetArrow bukkitEntity = null; - public MyPetArrow(World world, EntityMyPet entityMyPet) { + public MyPetArrow(Level world, EntityMyPet entityMyPet) { super(world, entityMyPet); } @Override public EntityMyPet getShooter() { - return (EntityMyPet) super.getShooter(); + return (EntityMyPet) super.getOwner(); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetDragonFireball.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetDragonFireball.java index a8b527642e..a2797bd888 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetDragonFireball.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetDragonFireball.java @@ -24,30 +24,30 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetDragonFireball; -import net.minecraft.nbt.NBTTagCompound; +import io.lumine.xikage.mythicmobs.utils.shadows.nbt.NBTTagCompound; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.projectile.EntityDragonFireball; -import net.minecraft.world.level.World; +import net.minecraft.world.entity.projectile.DragonFireball; +import net.minecraft.world.level.Level; import net.minecraft.world.phys.MovingObjectPosition; import net.minecraft.world.phys.MovingObjectPositionEntity; import net.royawesome.jlibnoise.MathHelper; @Compat("v1_17_R1") -public class MyPetDragonFireball extends EntityDragonFireball implements EntityMyPetProjectile { +public class MyPetDragonFireball extends DragonFireball implements EntityMyPetProjectile { protected float damage = 0; protected int deathCounter = 100; protected CraftMyPetDragonFireball bukkitEntity = null; - public MyPetDragonFireball(World world, EntityMyPet entityliving, double d0, double d1, double d2) { + public MyPetDragonFireball(Level world, EntityMyPet entityliving, double d0, double d1, double d2) { super(world, entityliving, d0, d1, d2); } @Override public EntityMyPet getShooter() { - return (EntityMyPet) super.getShooter(); + return (EntityMyPet) super.getOwner(); } public void setDamage(float damage) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEgg.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEgg.java index 4944fd0132..89f53cf651 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEgg.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEgg.java @@ -43,13 +43,13 @@ public class MyPetEgg extends EntityEgg implements EntityMyPetProjectile { protected float damage = 0; protected CraftMyPetEgg bukkitEntity = null; - public MyPetEgg(World world, EntityMyPet entityLiving) { + public MyPetEgg(Level world, EntityMyPet entityLiving) { super(world, entityLiving); } @Override public EntityMyPet getShooter() { - return (EntityMyPet) super.getShooter(); + return (EntityMyPet) super.getOwner(); } public void setDamage(float damage) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEnderPearl.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEnderPearl.java index d3a153096c..6d73f66bf8 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEnderPearl.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEnderPearl.java @@ -40,13 +40,13 @@ public class MyPetEnderPearl extends EntityEnderPearl implements EntityMyPetProj protected float damage = 0; protected CraftMyPetEnderPearl bukkitEntity = null; - public MyPetEnderPearl(World world, EntityMyPet entityLiving) { + public MyPetEnderPearl(Level world, EntityMyPet entityLiving) { super(world, entityLiving); } @Override public EntityMyPet getShooter() { - return (EntityMyPet) super.getShooter(); + return (EntityMyPet) super.getOwner(); } public void setDamage(float damage) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLargeFireball.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLargeFireball.java index dc95d2e10c..b41b2c24e1 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLargeFireball.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLargeFireball.java @@ -41,13 +41,13 @@ public class MyPetLargeFireball extends EntityLargeFireball implements EntityMyP protected int deathCounter = 100; protected CraftMyPetLargeFireball bukkitEntity = null; - public MyPetLargeFireball(World world, EntityMyPet entityliving, double d0, double d1, double d2) { + public MyPetLargeFireball(Level world, EntityMyPet entityliving, double d0, double d1, double d2) { super(world, entityliving, d0, d1, d2, 1); // TODO: 2021/06/28 temp value (i) - 2021/08/19 is this done? Where is i here? } @Override public EntityMyPet getShooter() { - return (EntityMyPet) super.getShooter(); + return (EntityMyPet) super.getOwner(); } public void setDamage(float damage) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLlamaSpit.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLlamaSpit.java index 80ae95fa88..9982096c7c 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLlamaSpit.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLlamaSpit.java @@ -45,7 +45,7 @@ public class MyPetLlamaSpit extends EntityLlamaSpit implements EntityMyPetProjec protected float damage = 0; protected CraftMyPetLlamaSpit bukkitEntity = null; - public MyPetLlamaSpit(World world, EntityMyPet entityMyPet) { + public MyPetLlamaSpit(Level world, EntityMyPet entityMyPet) { super(EntityTypes.W, world); this.setShooter(entityMyPet); this.setPosition(entityMyPet.locX() - (double) (entityMyPet.getWidth() + 1.0F) * 0.5D * (double) MathHelper.sin(entityMyPet.aE * 0.017453292F), @@ -55,7 +55,7 @@ public MyPetLlamaSpit(World world, EntityMyPet entityMyPet) { @Override public EntityMyPet getShooter() { - return (EntityMyPet) super.getShooter(); + return (EntityMyPet) super.getOwner(); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSmallFireball.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSmallFireball.java index 4b05902a83..f9fbeb60df 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSmallFireball.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSmallFireball.java @@ -41,13 +41,13 @@ public class MyPetSmallFireball extends EntitySmallFireball implements EntityMyP protected int deathCounter = 100; protected CraftMyPetSmallFireball bukkitEntity = null; - public MyPetSmallFireball(World world, EntityMyPet entityliving, double d0, double d1, double d2) { + public MyPetSmallFireball(Level world, EntityMyPet entityliving, double d0, double d1, double d2) { super(world, entityliving, d0, d1, d2); } @Override public EntityMyPet getShooter() { - return (EntityMyPet) super.getShooter(); + return (EntityMyPet) super.getOwner(); } public void setDamage(float damage) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSnowball.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSnowball.java index d82534ad22..cfe5617bf7 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSnowball.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSnowball.java @@ -40,13 +40,13 @@ public class MyPetSnowball extends EntitySnowball implements EntityMyPetProjecti protected float damage = 0; protected CraftMyPetSnowball bukkitEntity = null; - public MyPetSnowball(World world, EntityMyPet entityLiving) { + public MyPetSnowball(Level world, EntityMyPet entityLiving) { super(world, entityLiving); } @Override public EntityMyPet getShooter() { - return (EntityMyPet) super.getShooter(); + return (EntityMyPet) super.getOwner(); } public void setDamage(float damage) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetTrident.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetTrident.java index 919454e690..dc774fe7bc 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetTrident.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetTrident.java @@ -36,13 +36,13 @@ public class MyPetTrident extends EntityThrownTrident implements EntityMyPetProj protected CraftMyPetTrident bukkitEntity = null; - public MyPetTrident(World world, EntityMyPet entityMyPet) { + public MyPetTrident(Level world, EntityMyPet entityMyPet) { super(world, entityMyPet, new ItemStack(Items.sO)); } @Override public EntityMyPet getShooter() { - return (EntityMyPet) super.getShooter(); + return (EntityMyPet) super.getOwner(); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetWitherSkull.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetWitherSkull.java index e2f363834f..8a027290d4 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetWitherSkull.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetWitherSkull.java @@ -41,13 +41,13 @@ public class MyPetWitherSkull extends EntityWitherSkull implements EntityMyPetPr protected int deathCounter = 100; protected CraftMyPetWitherSkull bukkitEntity = null; - public MyPetWitherSkull(World world, EntityMyPet entityliving, double d0, double d1, double d2) { + public MyPetWitherSkull(Level world, EntityMyPet entityliving, double d0, double d1, double d2) { super(world, entityliving, d0, d1, d2); } @Override public EntityMyPet getShooter() { - return (EntityMyPet) super.getShooter(); + return (EntityMyPet) super.getOwner(); } public void setDamage(float damage) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/ConfigItem.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/ConfigItem.java index 688b9c2bb3..d3340c8fcb 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/ConfigItem.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/ConfigItem.java @@ -20,19 +20,20 @@ package de.Keyle.MyPet.compat.v1_17_R1.util; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; +import org.bukkit.inventory.ItemStack; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.api.util.inventory.material.MaterialHolder; import de.Keyle.MyPet.compat.v1_17_R1.util.inventory.ItemStackComparator; -import net.minecraft.core.IRegistry; -import net.minecraft.nbt.MojangsonParser; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.resources.MinecraftKey; +import net.minecraft.core.Registry; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.TagParser; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; -import org.bukkit.ChatColor; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; -import org.bukkit.inventory.ItemStack; @Compat("v1_17_R1") public class ConfigItem extends de.Keyle.MyPet.api.util.ConfigItem { @@ -58,12 +59,12 @@ public boolean compare(Object o) { @Override public void load(MaterialHolder material, String data) { - MinecraftKey key = new MinecraftKey(material.getId()); - Item item = IRegistry.Z.get(key); + ResourceLocation key = new ResourceLocation(material.getId()); + Item item = Registry.ITEM.get(key); //TODO AIR now? if (item == null) { - Block block = IRegistry.W.get(key); - item = block.getItem(); + Block block = Registry.BLOCK.get(key); + item = block.asItem(); } if (item == null) { return; @@ -72,14 +73,14 @@ public void load(MaterialHolder material, String data) { net.minecraft.world.item.ItemStack is = new net.minecraft.world.item.ItemStack(item, 1); if (data != null) { - NBTTagCompound tag = null; + CompoundTag tag = null; String nbtString = data.trim(); if (nbtString.startsWith("{") && nbtString.endsWith("}")) { try { - tag = MojangsonParser.parse(nbtString); + tag = TagParser.parseTag(nbtString); } catch (Exception e) { MyPetApi.getLogger().warning("Error" + ChatColor.RESET + " in config: " + ChatColor.UNDERLINE + e.getLocalizedMessage() + ChatColor.RESET + " caused by:"); - MyPetApi.getLogger().warning(item.getName() + " " + nbtString); + MyPetApi.getLogger().warning(item.getDescriptionId() + " " + nbtString); } if (tag != null) { is.setTag(tag); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/iconmenu/IconMenuInventory.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/iconmenu/IconMenuInventory.java index c62ed79e2c..d6041aa965 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/iconmenu/IconMenuInventory.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/iconmenu/IconMenuInventory.java @@ -20,6 +20,19 @@ package de.Keyle.MyPet.compat.v1_17_R1.util.iconmenu; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_17_R1.util.CraftChatMessage; +import org.bukkit.entity.HumanEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; + import de.Keyle.MyPet.api.gui.IconMenu; import de.Keyle.MyPet.api.gui.IconMenuItem; import de.Keyle.MyPet.api.util.Compat; @@ -30,23 +43,12 @@ import de.keyle.knbt.TagList; import de.keyle.knbt.TagShort; import de.keyle.knbt.TagString; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; -import net.minecraft.network.chat.IChatBaseComponent; +import io.lumine.xikage.mythicmobs.utils.shadows.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.StringTag; +import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; -import org.bukkit.craftbukkit.v1_17_R1.util.CraftChatMessage; -import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; @Compat("v1_17_R1") public class IconMenuInventory implements de.Keyle.MyPet.api.gui.IconMenuInventory { @@ -93,7 +95,7 @@ public void update(IconMenu menu) { ItemStack item = createItemStack(menuItem); minecraftInventory.setItem(slot, item); } else { - minecraftInventory.setItem(slot, ItemStack.b); + minecraftInventory.setItem(slot, ItemStack.EMPTY); } } } @@ -132,7 +134,7 @@ protected ItemStack createItemStack(IconMenuItem icon) { //TODO Check if this wo is = CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(Material.STONE)); } if (is.getTag() == null) { - is.setTag(new NBTTagCompound()); + is.setTag(new CompoundTag()); } if (icon.getBukkitMeta() != null) { @@ -151,51 +153,51 @@ protected ItemStack createItemStack(IconMenuItem icon) { //TODO Check if this wo TagList enchList = new TagList(); enchList.addTag(enchTag); - is.getTag().set("Enchantments", ItemStackNBTConverter.compoundToVanillaCompound(enchList)); + is.getTag().put("Enchantments", ItemStackNBTConverter.compoundToVanillaCompound(enchList)); } else { is.getTag().remove("Enchantments"); } // hide item attributes like attack damage - is.getTag().setInt("HideFlags", 63); + is.getTag().putInt("HideFlags", 63); // Prepare display tag - NBTTagCompound display; - if (is.getTag().hasKey("display")) { + CompoundTag display; + if (is.getTag().contains("display")) { display = is.getTag().getCompound("display"); } else { - display = new NBTTagCompound(); - is.getTag().set("display", display); + display = new CompoundTag(); + is.getTag().put("display", display); } // set Title if (!icon.getTitle().equals("")) { - display.setString("Name", "{\"text\":\"" + icon.getTitle() + "\"}"); + display.putString("Name", "{\"text\":\"" + icon.getTitle() + "\"}"); } if (icon.getLore().size() > 0) { // set Lore - NBTTagList loreTag = new NBTTagList(); - display.set("Lore", loreTag); + ListTag loreTag = new ListTag(); + display.put("Lore", loreTag); for (String loreLine : icon.getLore()) { - IChatBaseComponent cm = CraftChatMessage.fromStringOrNull(loreLine); - loreTag.add(NBTTagString.a(IChatBaseComponent.ChatSerializer.a(cm))); + Component cm = CraftChatMessage.fromStringOrNull(loreLine); + loreTag.add(StringTag.valueOf(Component.Serializer.toJson(cm))); } } if (icon.hasMeta()) { TagCompound tag = new TagCompound(); icon.getMeta().applyTo(tag); - NBTTagCompound vanillaTag = (NBTTagCompound) ItemStackNBTConverter.compoundToVanillaCompound(tag); - for (String key : vanillaTag.getKeys()) { - is.getTag().set(key, vanillaTag.get(key)); + CompoundTag vanillaTag = (CompoundTag) ItemStackNBTConverter.compoundToVanillaCompound(tag); + for (String key : vanillaTag.getAllKeys()) { + is.getTag().put(key, vanillaTag.get(key)); } } if (icon.getTags() != null) { - NBTTagCompound vanillaTag = (NBTTagCompound) ItemStackNBTConverter.compoundToVanillaCompound(icon.getTags()); - for (String key : vanillaTag.getKeys()) { - is.getTag().set(key, vanillaTag.get(key)); + CompoundTag vanillaTag = (CompoundTag) ItemStackNBTConverter.compoundToVanillaCompound(icon.getTags()); + for (String key : vanillaTag.getAllKeys()) { + is.getTag().put(key, vanillaTag.get(key)); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java index 6972c0af43..be02c4fde3 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java @@ -20,23 +20,10 @@ package de.Keyle.MyPet.compat.v1_17_R1.util.inventory; -import de.Keyle.MyPet.MyPetApi; -import de.Keyle.MyPet.api.Util; -import de.Keyle.MyPet.api.util.Compat; -import de.keyle.knbt.TagByte; -import de.keyle.knbt.TagCompound; -import de.keyle.knbt.TagList; -import net.minecraft.core.NonNullList; -import net.minecraft.network.chat.ChatComponentText; -import net.minecraft.network.protocol.game.PacketPlayOutOpenWindow; -import net.minecraft.server.level.EntityPlayer; -import net.minecraft.world.IInventory; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; -import net.minecraft.world.inventory.Container; -import net.minecraft.world.inventory.Containers; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.World; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -55,16 +42,28 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; +import de.Keyle.MyPet.MyPetApi; +import de.Keyle.MyPet.api.Util; +import de.Keyle.MyPet.api.util.Compat; +import de.keyle.knbt.TagByte; +import de.keyle.knbt.TagCompound; +import de.keyle.knbt.TagList; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.ChatComponentText; +import net.minecraft.network.protocol.game.PacketPlayOutOpenWindow; +import net.minecraft.server.level.EntityPlayer; +import net.minecraft.world.Container; +import net.minecraft.world.Containers; +import net.minecraft.world.entity.item.EntityItem; +import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; @Compat("v1_17_R1") -public class CustomInventory implements IInventory, Listener, de.Keyle.MyPet.api.util.inventory.CustomInventory { +public class CustomInventory implements Container, Listener, de.Keyle.MyPet.api.util.inventory.CustomInventory { private String inventoryName = ""; - private final NonNullList items = NonNullList.a(64, ItemStack.b); + private final NonNullList items = NonNullList.a(64, ItemStack.EMPTY); private int size = 0; private int stackSize = 64; private final List transaction = new ArrayList<>(); @@ -91,7 +90,7 @@ public void setSize(int size) { size *= 9; this.size = Util.clamp(size, 9, 54); for (int i = items.size(); i < this.size; i++) { - items.set(i, ItemStack.b); + items.set(i, ItemStack.EMPTY); } } @@ -113,7 +112,7 @@ public ItemStack getItem(int i) { if (i < size) { return items.get(i); } - return ItemStack.b; + return ItemStack.EMPTY; } @Override @@ -151,7 +150,7 @@ public int addItem(org.bukkit.inventory.ItemStack itemAdd) { } if (itemAdd.getAmount() > 0) { for (int i = 0; i < this.getSize(); i++) { - if (getItem(i) == ItemStack.b) { + if (getItem(i) == ItemStack.EMPTY) { if (itemAdd.getAmount() <= itemAdd.getMaxStackSize()) { setItem(i, CraftItemStack.asNMSCopy(itemAdd.clone())); itemAdd.setAmount(0); @@ -190,7 +189,7 @@ public String getName() { @Override public void dropContentAt(Location loc) { - World world = ((CraftWorld) loc.getWorld()).getHandle(); + Level world = ((CraftWorld) loc.getWorld()).getHandle(); for (int i = 0; i < this.getSize(); i++) { ItemStack is = this.splitWithoutUpdate(i); if (is != null && !is.isEmpty()) { @@ -204,21 +203,21 @@ public void dropContentAt(Location loc) { @Override public ItemStack splitStack(int slot, int subtract) { - if (slot < size && items.get(slot) != ItemStack.b) { + if (slot < size && items.get(slot) != ItemStack.EMPTY) { if (items.get(slot).getCount() <= subtract) { ItemStack itemStack = items.get(slot); - items.set(slot, ItemStack.b); + items.set(slot, ItemStack.EMPTY); return itemStack; } else { ItemStack splittedStack = items.get(slot).cloneAndSubtract(subtract); if (items.get(slot).getCount() == 0) { - items.set(slot, ItemStack.b); + items.set(slot, ItemStack.EMPTY); } return splittedStack; } } - return ItemStack.b; + return ItemStack.EMPTY; } @Override @@ -235,7 +234,7 @@ public TagCompound save(TagCompound compound) { List itemList = new ArrayList<>(); for (int i = 0; i < this.items.size(); i++) { ItemStack itemStack = this.items.get(i); - if (itemStack != ItemStack.b) { + if (itemStack != ItemStack.EMPTY) { TagCompound item = ItemStackNBTConverter.itemStackToCompound(itemStack); item.getCompoundData().put("Slot", new TagByte((byte) i)); itemList.add(item); @@ -272,11 +271,11 @@ public void onClose(CraftHumanEntity who) { this.transaction.remove(who); if (items.size() > this.size) { for (int counterOutside = items.size() - 1; counterOutside >= this.size; counterOutside--) { - if (items.get(counterOutside) != ItemStack.b) { + if (items.get(counterOutside) != ItemStack.EMPTY) { for (int counterInside = 0; counterInside < size; counterInside++) { - if (items.get(counterInside) == ItemStack.b) { + if (items.get(counterInside) == ItemStack.EMPTY) { items.set(counterInside, items.get(counterOutside)); - items.set(counterOutside, ItemStack.b); + items.set(counterOutside, ItemStack.EMPTY); } } } @@ -357,13 +356,13 @@ public Location getLocation() { @Override public ItemStack splitWithoutUpdate(int i) { - if (items.get(i) != ItemStack.b) { + if (items.get(i) != ItemStack.EMPTY) { ItemStack itemstack = items.get(i); - items.set(i, ItemStack.b); + items.set(i, ItemStack.EMPTY); return itemstack; } - return ItemStack.b; + return ItemStack.EMPTY; } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/ItemStackComparator.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/ItemStackComparator.java index f7c926c071..f3f0cc2c57 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/ItemStackComparator.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/ItemStackComparator.java @@ -20,11 +20,12 @@ package de.Keyle.MyPet.compat.v1_17_R1.util.inventory; -import de.Keyle.MyPet.api.util.Compat; -import net.minecraft.nbt.NBTTagCompound; import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; +import de.Keyle.MyPet.api.util.Compat; +import net.minecraft.nbt.CompoundTag; + @Compat("v1_17_R1") public class ItemStackComparator { @@ -47,8 +48,8 @@ public static boolean compareTagData(ItemStack i1, ItemStack i2) { return false; } if (i1.hasItemMeta() && i2.hasItemMeta()) { - NBTTagCompound tag1 = CraftItemStack.asNMSCopy(i1).getTag(); - NBTTagCompound tag2 = CraftItemStack.asNMSCopy(i2).getTag(); + CompoundTag tag1 = CraftItemStack.asNMSCopy(i1).getTag(); + CompoundTag tag2 = CraftItemStack.asNMSCopy(i2).getTag(); if (tag1 != null) { if (tag1.equals(tag2)) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/ItemStackNBTConverter.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/ItemStackNBTConverter.java index d1b6cdcada..36a497d3bd 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/ItemStackNBTConverter.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/ItemStackNBTConverter.java @@ -23,6 +23,7 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.api.util.ReflectionUtil; import de.keyle.knbt.*; +import de.keyle.knbt.TagType; import net.minecraft.nbt.*; import net.minecraft.world.item.ItemStack; import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; @@ -35,55 +36,55 @@ @Compat("v1_17_R1") public class ItemStackNBTConverter { - private static final Field TAG_LIST_LIST = ReflectionUtil.getField(NBTTagList.class, "list"); + private static final Field TAG_LIST_LIST = ReflectionUtil.getField(ListTag.class, "list"); public static TagCompound itemStackToCompound(org.bukkit.inventory.ItemStack itemStack) { return itemStackToCompound(CraftItemStack.asNMSCopy(itemStack)); } public static TagCompound itemStackToCompound(ItemStack itemStack) { - NBTTagCompound tagCompound = new NBTTagCompound(); + CompoundTag tagCompound = new CompoundTag(); itemStack.save(tagCompound); return (TagCompound) vanillaCompoundToCompound(tagCompound); } public static ItemStack compoundToItemStack(TagCompound compound) { - NBTTagCompound tagCompound = (NBTTagCompound) compoundToVanillaCompound(compound); - return ItemStack.a(tagCompound); + CompoundTag tagCompound = (CompoundTag) compoundToVanillaCompound(compound); + return ItemStack.of(tagCompound); } - public static NBTBase compoundToVanillaCompound(TagBase tag) { + public static Tag compoundToVanillaCompound(TagBase tag) { switch (TagType.getTypeById(tag.getTagTypeId())) { case Int: - return NBTTagInt.a(((TagInt) tag).getIntData()); + return IntTag.valueOf(((TagInt) tag).getIntData()); case Short: - return NBTTagShort.a(((TagShort) tag).getShortData()); + return ShortTag.valueOf(((TagShort) tag).getShortData()); case String: - return NBTTagString.a(((TagString) tag).getStringData()); + return StringTag.valueOf(((TagString) tag).getStringData()); case Byte: - return NBTTagByte.a(((TagByte) tag).getByteData()); + return ByteTag.valueOf(((TagByte) tag).getByteData()); case Byte_Array: - return new NBTTagByteArray(((TagByteArray) tag).getByteArrayData()); + return new ByteArrayTag(((TagByteArray) tag).getByteArrayData()); case Double: - return NBTTagDouble.a(((TagDouble) tag).getDoubleData()); + return DoubleTag.valueOf(((TagDouble) tag).getDoubleData()); case Float: - return NBTTagFloat.a(((TagFloat) tag).getFloatData()); + return FloatTag.valueOf(((TagFloat) tag).getFloatData()); case Int_Array: - return new NBTTagIntArray(((TagIntArray) tag).getIntArrayData()); + return new IntArrayTag(((TagIntArray) tag).getIntArrayData()); case Long: - return NBTTagLong.a(((TagLong) tag).getLongData()); + return LongTag.valueOf(((TagLong) tag).getLongData()); case List: TagList TagList = (TagList) tag; - NBTTagList tagList = new NBTTagList(); + ListTag tagList = new ListTag(); for (TagBase tagInList : TagList.getReadOnlyList()) { tagList.add(compoundToVanillaCompound(tagInList)); } return tagList; case Compound: TagCompound TagCompound = (TagCompound) tag; - NBTTagCompound tagCompound = new NBTTagCompound(); + CompoundTag tagCompound = new CompoundTag(); for (String name : TagCompound.getCompoundData().keySet()) { - tagCompound.set(name, compoundToVanillaCompound(TagCompound.getCompoundData().get(name))); + tagCompound.put(name, compoundToVanillaCompound(TagCompound.getCompoundData().get(name))); } return tagCompound; case End: @@ -92,31 +93,31 @@ public static NBTBase compoundToVanillaCompound(TagBase tag) { throw new IllegalArgumentException("Not a valid tag type"); } - public static TagBase vanillaCompoundToCompound(NBTBase vanillaTag) { - switch (vanillaTag.getTypeId()) { + public static TagBase vanillaCompoundToCompound(Tag vanillaTag) { + switch (vanillaTag.getId()) { case 1: - return new TagByte(((NBTTagByte) vanillaTag).asByte()); + return new TagByte(((ByteTag) vanillaTag).getAsByte()); case 2: - return new TagShort(((NBTTagShort) vanillaTag).asShort()); + return new TagShort(((ShortTag) vanillaTag).getAsShort()); case 3: - return new TagInt(((NBTTagInt) vanillaTag).asInt()); + return new TagInt(((IntTag) vanillaTag).getAsInt()); case 4: - return new TagLong(((NBTTagLong) vanillaTag).asLong()); + return new TagLong(((LongTag) vanillaTag).getAsLong()); case 5: - return new TagFloat(((NBTTagFloat) vanillaTag).asFloat()); + return new TagFloat(((FloatTag) vanillaTag).getAsFloat()); case 6: - return new TagDouble(((NBTTagDouble) vanillaTag).asDouble()); + return new TagDouble(((DoubleTag) vanillaTag).getAsDouble()); case 7: - return new TagByteArray(((NBTTagByteArray) vanillaTag).getBytes()); + return new TagByteArray(((ByteArrayTag) vanillaTag).getAsByteArray()); case 8: - return new TagString(vanillaTag.asString()); + return new TagString(vanillaTag.getAsString()); case 9: - NBTTagList tagList = (NBTTagList) vanillaTag; + ListTag tagList = (ListTag) vanillaTag; List compoundList = new ArrayList(); try { ArrayList list = (ArrayList) TAG_LIST_LIST.get(tagList); for (Object aList : list) { - compoundList.add(vanillaCompoundToCompound((NBTBase) aList)); + compoundList.add(vanillaCompoundToCompound((Tag) aList)); } } catch (IllegalAccessException e) { e.printStackTrace(); @@ -125,14 +126,14 @@ public static TagBase vanillaCompoundToCompound(NBTBase vanillaTag) { return new TagList(compoundList); case 10: TagCompound compound = new TagCompound(); - NBTTagCompound tagCompound = ((NBTTagCompound) vanillaTag); - Set keys = tagCompound.getKeys(); + CompoundTag tagCompound = ((CompoundTag) vanillaTag); + Set keys = tagCompound.getAllKeys(); for (String tagName : keys) { compound.getCompoundData().put(tagName, vanillaCompoundToCompound(tagCompound.get(tagName))); } return compound; case 11: - return new TagIntArray(((NBTTagIntArray) vanillaTag).getInts()); + return new TagIntArray(((TagIntArray) vanillaTag).getIntArrayData()); } return null; } From be31e6299c50c87430994c84c4e814b9a0873b9d Mon Sep 17 00:00:00 2001 From: Jakllp <57708725+Jakllp@users.noreply.github.com> Date: Mon, 23 Aug 2021 20:13:32 +0200 Subject: [PATCH 2/6] Conversion to Mojang-Mappings - Part 1/? Gotta pump up those numbers --- .../MyPet/compat/v1_17_R1/PlatformHelper.java | 18 +-- .../compat/v1_17_R1/entity/EntityMyPet.java | 4 +- .../entity/ai/attack/RangedAttack.java | 2 +- .../v1_17_R1/entity/ai/movement/EatGrass.java | 14 +-- .../v1_17_R1/entity/ai/movement/Float.java | 2 +- .../entity/ai/movement/FollowOwner.java | 2 +- .../entity/ai/movement/LookAtPlayer.java | 2 +- .../entity/ai/movement/RandomLookaround.java | 2 +- .../v1_17_R1/entity/types/EntityMyBat.java | 4 +- .../v1_17_R1/entity/types/EntityMyBee.java | 8 +- .../v1_17_R1/entity/types/EntityMyCat.java | 33 +++--- .../entity/types/EntityMyCaveSpider.java | 4 +- .../entity/types/EntityMyChicken.java | 18 +-- .../v1_17_R1/entity/types/EntityMyCod.java | 2 +- .../v1_17_R1/entity/types/EntityMyCow.java | 12 +- .../entity/types/EntityMyDolphin.java | 12 +- .../v1_17_R1/entity/types/EntityMyDonkey.java | 77 ++++++------- .../entity/types/EntityMyDrowned.java | 62 +++++------ .../entity/types/EntityMyEnderDragon.java | 22 ++-- .../entity/types/EntityMyEnderman.java | 20 ++-- .../v1_17_R1/entity/types/EntityMyFox.java | 83 +++++++------- .../v1_17_R1/entity/types/EntityMyGiant.java | 61 +++++----- .../entity/types/EntityMyGuardian.java | 2 +- .../v1_17_R1/entity/types/EntityMyHoglin.java | 6 +- .../v1_17_R1/entity/types/EntityMyHorse.java | 105 +++++++++--------- .../v1_17_R1/entity/types/EntityMyHusk.java | 49 ++++---- .../entity/types/EntityMyIllusioner.java | 47 ++++---- .../entity/types/EntityMyIronGolem.java | 39 ++++--- .../v1_17_R1/entity/types/EntityMyLlama.java | 53 +++++---- .../entity/types/EntityMyMagmaCube.java | 22 ++-- .../entity/types/EntityMyMooshroom.java | 27 ++--- .../v1_17_R1/entity/types/EntityMyMule.java | 81 +++++++------- .../v1_17_R1/entity/types/EntityMyOcelot.java | 10 +- .../v1_17_R1/entity/types/EntityMyPanda.java | 14 +-- .../entity/types/EntityMyPhantom.java | 14 +-- .../v1_17_R1/entity/types/EntityMyPig.java | 56 +++++----- .../v1_17_R1/entity/types/EntityMyPiglin.java | 61 +++++----- .../entity/types/EntityMyPiglinBrute.java | 69 ++++++------ .../entity/types/EntityMyPillager.java | 87 +++++++-------- .../entity/types/EntityMyPolarBear.java | 6 +- .../entity/types/EntityMyPufferfish.java | 2 +- .../v1_17_R1/entity/types/EntityMyRabbit.java | 26 ++--- .../entity/types/EntityMyRavager.java | 8 +- .../v1_17_R1/entity/types/EntityMySalmon.java | 6 +- .../v1_17_R1/entity/types/EntityMySheep.java | 77 ++++++------- .../entity/types/EntityMySkeleton.java | 61 +++++----- .../entity/types/EntityMySkeletonHorse.java | 67 ++++++----- .../v1_17_R1/entity/types/EntityMySlime.java | 24 ++-- .../entity/types/EntityMySnowman.java | 20 ++-- .../v1_17_R1/entity/types/EntityMySpider.java | 2 +- .../v1_17_R1/entity/types/EntityMySquid.java | 4 +- .../v1_17_R1/entity/types/EntityMyStray.java | 61 +++++----- .../entity/types/EntityMyStrider.java | 33 +++--- .../entity/types/EntityMyTraderLlama.java | 53 +++++---- .../entity/types/EntityMyTropicalFish.java | 6 +- .../v1_17_R1/entity/types/EntityMyTurtle.java | 20 ++-- .../v1_17_R1/entity/types/EntityMyVex.java | 63 ++++++----- .../entity/types/EntityMyVillager.java | 24 ++-- .../entity/types/EntityMyVindicator.java | 61 +++++----- .../entity/types/EntityMyWanderingTrader.java | 4 +- .../v1_17_R1/entity/types/EntityMyWitch.java | 2 +- .../v1_17_R1/entity/types/EntityMyWither.java | 4 +- .../entity/types/EntityMyWitherSkeleton.java | 61 +++++----- .../v1_17_R1/entity/types/EntityMyWolf.java | 61 +++++----- .../v1_17_R1/entity/types/EntityMyZoglin.java | 10 +- .../v1_17_R1/entity/types/EntityMyZombie.java | 63 ++++++----- .../entity/types/EntityMyZombieHorse.java | 71 ++++++------ .../entity/types/EntityMyZombieVillager.java | 75 ++++++------- .../entity/types/EntityMyZombifiedPiglin.java | 61 +++++----- .../skill/skills/ranged/nms/MyPetArrow.java | 10 +- .../ranged/nms/MyPetDragonFireball.java | 35 +++--- .../skill/skills/ranged/nms/MyPetEgg.java | 40 +++---- .../skills/ranged/nms/MyPetEnderPearl.java | 38 +++---- .../skills/ranged/nms/MyPetLargeFireball.java | 42 +++---- .../skills/ranged/nms/MyPetLlamaSpit.java | 48 ++++---- .../skills/ranged/nms/MyPetSmallFireball.java | 44 ++++---- .../skills/ranged/nms/MyPetSnowball.java | 38 +++---- .../skill/skills/ranged/nms/MyPetTrident.java | 22 ++-- .../skills/ranged/nms/MyPetWitherSkull.java | 42 +++---- .../util/inventory/CustomInventory.java | 58 +++++----- 80 files changed, 1316 insertions(+), 1343 deletions(-) diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/PlatformHelper.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/PlatformHelper.java index c6734cd26b..14ec352a9c 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/PlatformHelper.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/PlatformHelper.java @@ -54,7 +54,7 @@ import de.Keyle.MyPet.api.util.inventory.material.ItemDatabase; import de.Keyle.MyPet.compat.v1_17_R1.util.inventory.ItemStackNBTConverter; import de.keyle.knbt.TagCompound; -import net.minecraft.core.BlockPosition; +import net.minecraft.core.BlockPos; import net.minecraft.core.IRegistry; import net.minecraft.core.particles.Particle; import net.minecraft.core.particles.ParticleParam; @@ -78,7 +78,7 @@ import net.minecraft.world.entity.EntityLightning; import net.minecraft.world.entity.EntityLiving; import net.minecraft.world.entity.EntityTypes; -import net.minecraft.world.entity.item.EntityItem; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.npc.EntityVillager; import net.minecraft.world.entity.npc.EntityVillagerTrader; import net.minecraft.world.entity.player.EntityHuman; @@ -96,7 +96,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemSword; import net.minecraft.world.item.ItemTrident; -import net.minecraft.world.level.block.state.IBlockData; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.shapes.VoxelShape; @@ -217,8 +217,8 @@ public List getBlockBBsInBB(net.minecraft.world.level.Level world, AxisAlignedBB for (int z = minZ; z <= maxZ; z++) { if (((ChunkProviderServer) world.getChunkProvider()).isLoaded(x >> 4, z >> 4)) { for (int y = minY - 1; y <= maxY; y++) { - BlockPosition bp = new BlockPosition(x, y, z); - IBlockData blockData = world.getType(bp); + BlockPos bp = new BlockPos(x, y, z); + BlockState blockData = world.getType(bp); if (blockData != null && blockData.getMaterial().isSolid()) { vec3d = blockData.getCollisionShape(world, bp); isEmpty = vec3d.isEmpty(); @@ -322,7 +322,7 @@ public boolean comparePlayerWithEntity(MyPetPlayer player, Object obj) { public boolean isEquipment(org.bukkit.inventory.ItemStack itemStack) { { ItemStack itemstack = CraftItemStack.asNMSCopy(itemStack); - int slot = Mob.getEquipmentSlotForItem(itemstack).getSlotFlag(); + int slot = Mob.getEquipmentSlotForItem(itemstack).getFilterFlag(); if (slot == 0) { if (itemstack.getItem() instanceof ItemSword) { return true; @@ -363,8 +363,8 @@ public String getVanillaName(org.bukkit.inventory.ItemStack bukkitItemStack) { @Override public void doPickupAnimation(Entity entity, Entity target) { int count = 1; - if (target instanceof EntityItem) { - count = ((EntityItem) target).getItemStack().getCount(); + if (target instanceof ItemEntity) { + count = ((ItemEntity) target).getItemStack().getCount(); } for (Entity p : target.getNearbyEntities(10, 10, 10)) { if (p instanceof Player) { @@ -415,7 +415,7 @@ public void strikeLightning(Location loc, float distance) { .getServer() .getPlayerList() .sendPacketNearby(null, loc.getX(), loc.getY(), loc.getZ(), distance, world.getDimensionKey(), - new PacketPlayOutNamedSoundEffect(SoundEffects.jL, SoundCategory.d, loc.getX(), loc.getY(), loc.getZ(), distance, 1F)); + new PacketPlayOutNamedSoundEffect(SoundEvents.jL, SoundCategory.d, loc.getX(), loc.getY(), loc.getZ(), distance, 1F)); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPet.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPet.java index 2d8ce5bae4..5910db211e 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPet.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPet.java @@ -114,7 +114,7 @@ import net.minecraft.world.entity.EntityDimensions; import net.minecraft.world.entity.EntityLiving; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.IJumpable; +import net.minecraft.world.entity.PlayerRideableJumping; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MoverType; @@ -510,7 +510,7 @@ public void run() { } } }.runTaskLater(MyPetApi.getPlugin(), 5); - if (itemStack != null && itemStack.getItem() == Items.rP) { //TODO + if (itemStack != null && itemStack.getItem() == Items.LEAD) { //TODO ((ServerPlayer) entityhuman).connection.send(new ClientboundSetEntityLinkPacket(this, null)); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java index aa78dee8c6..5d6d00f6c4 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java @@ -172,7 +172,7 @@ public void tick() { this.entityMyPet.getPetNavigation().navigateTo(this.target.getBukkitEntity().getLocation()); } - this.entityMyPet.getLookControl().a(this.target, 30.0F, 30.0F); + this.entityMyPet.getLookControl().setLookAt(this.target, 30.0F, 30.0F); if (--this.shootTimer <= 0) { if (distanceToTarget < this.range && canSee) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java index 86e1da5734..b8758f5032 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java @@ -24,12 +24,12 @@ import de.Keyle.MyPet.api.entity.ai.AIGoal; import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.types.EntityMySheep; -import net.minecraft.core.BlockPosition; +import net.minecraft.core.BlockPos; import net.minecraft.util.MathHelper; import net.minecraft.world.level.World; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.IBlockData; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.predicate.BlockStatePredicate; import org.bukkit.GameRule; import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory; @@ -43,7 +43,7 @@ public class EatGrass implements AIGoal { private final Level world; int eatTicks = 0; - private static final Predicate GRASS = BlockStatePredicate.a(Blocks.aX); + private static final Predicate GRASS = BlockStatePredicate.a(Blocks.aX); public EatGrass(EntityMySheep entityMySheep) { this.entityMySheep = entityMySheep; @@ -65,7 +65,7 @@ public boolean shouldStart() { int blockLocY = MathHelper.floor(this.entityMySheep.locY()); int blockLocZ = MathHelper.floor(this.entityMySheep.locZ()); - BlockPosition blockposition = new BlockPosition(blockLocX, blockLocY, blockLocZ); + BlockPos blockposition = new BlockPos(blockLocX, blockLocY, blockLocZ); return GRASS.test(this.world.getType(blockposition)) || this.world.getType(blockposition.down()).getBlock() == Blocks.aX; } @@ -78,7 +78,7 @@ public boolean shouldFinish() { @Override public void start() { this.eatTicks = 30; - this.world.broadcastEntityEffect(this.entityMySheep, (byte) 10); + this.world.broadcastEntityEvent(this.entityMySheep, (byte) 10); this.entityMySheep.getPetNavigation().stop(); } @@ -94,7 +94,7 @@ public void tick() { int blockLocY = MathHelper.floor(this.entityMySheep.locY()); int blockLocZ = MathHelper.floor(this.entityMySheep.locZ()); - BlockPosition blockAt = new BlockPosition(blockLocX, blockLocY, blockLocZ); + BlockPos blockAt = new BlockPos(blockLocX, blockLocY, blockLocZ); if (GRASS.test(this.world.getType(blockAt))) { if (!CraftEventFactory.callEntityChangeBlockEvent( this.entityMySheep, @@ -106,7 +106,7 @@ public void tick() { } entityMySheep.getMyPet().setSheared(false); } else { - BlockPosition blockUnder = blockAt.down(); + BlockPos blockUnder = blockAt.down(); if (this.world.getType(blockUnder).getBlock() == Blocks.aX) { if (!CraftEventFactory.callEntityChangeBlockEvent( this.entityMySheep, diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Float.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Float.java index aeb67ef1de..e9bf36b301 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Float.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Float.java @@ -56,7 +56,7 @@ public void finish() { @Override public void tick() { - entityMyPet.setMot(entityMyPet.getMot().add(0, 0.05D, 0)); + entityMyPet.setDeltaMovement(entityMyPet.getDeltaMovement().add(0, 0.05D, 0)); if (inLava && lavaCounter-- <= 0) { if (entityMyPet.getPetNavigation().navigateTo(owner.getBukkitEntity())) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/FollowOwner.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/FollowOwner.java index 143a3d4e47..cf4c829707 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/FollowOwner.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/FollowOwner.java @@ -109,7 +109,7 @@ public void tick() { } //Look at Owner - this.petEntity.getControllerLook().a(owner, this.petEntity.eZ(), this.petEntity.eZ()); + this.petEntity.getLookControl().setLookAt(owner, this.petEntity.eZ(), this.petEntity.eZ()); //Teleportation if (this.petEntity.canMove()) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/LookAtPlayer.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/LookAtPlayer.java index 0a58f19e75..b004659ef8 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/LookAtPlayer.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/LookAtPlayer.java @@ -87,7 +87,7 @@ public void finish() { @Override public void tick() { - this.petEntity.getControllerLook().a(this.targetPlayer.locX(), this.targetPlayer.locY() + this.targetPlayer.getHeadHeight(), this.targetPlayer.locZ(), petEntity.eZ(), this.petEntity.eZ()); + this.petEntity.getLookControl().setLookAt(this.targetPlayer.locX(), this.targetPlayer.locY() + this.targetPlayer.getHeadHeight(), this.targetPlayer.locZ(), petEntity.eZ(), this.petEntity.eZ()); this.ticksUntilStopLooking -= 1; } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/RandomLookaround.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/RandomLookaround.java index f84a5a5668..48ec48f87a 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/RandomLookaround.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/RandomLookaround.java @@ -63,6 +63,6 @@ public void start() { @Override public void tick() { this.ticksUntilStopLookingAround--; - this.petEntity.getControllerLook().a(this.petEntity.locX() + this.directionX, this.petEntity.locY() + this.petEntity.getHeadHeight(), this.petEntity.locZ() + this.directionZ, this.petEntity.eZ(), this.petEntity.eZ()); + this.petEntity.getLookControl().setLookAt(this.petEntity.locX() + this.directionX, this.petEntity.locY() + this.petEntity.getHeadHeight(), this.petEntity.locZ() + this.directionZ, this.petEntity.eZ(), this.petEntity.eZ()); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java index bfb3304916..aad535f3aa 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java @@ -24,10 +24,10 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.world.level.World; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.level.Level; @EntitySize(width = 0.5F, height = 0.45f) public class EntityMyBat extends EntityMyPet { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBee.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBee.java index d02c8cd44b..84928552ac 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBee.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBee.java @@ -27,10 +27,10 @@ import de.Keyle.MyPet.api.skill.skills.Behavior; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.skill.skills.BehaviorImpl; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.world.level.World; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 0.6f) public class EntityMyBee extends EntityMyPet { @@ -95,9 +95,9 @@ public void updateVisuals() { */ private void setBeeStatus(int status, boolean flag) { if (flag) { - this.Y.set(BEE_STATUS_WATCHER, (byte) (this.Y.get(BEE_STATUS_WATCHER) | status)); + this.entityData.set(BEE_STATUS_WATCHER, (byte) (this.entityData.get(BEE_STATUS_WATCHER) | status)); } else { - this.Y.set(BEE_STATUS_WATCHER, (byte) (this.Y.get(BEE_STATUS_WATCHER) & ~status)); + this.entityData.set(BEE_STATUS_WATCHER, (byte) (this.entityData.get(BEE_STATUS_WATCHER) & ~status)); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCat.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCat.java index db57a002fb..61d2da6636 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCat.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCat.java @@ -20,31 +20,32 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.util.Optional; +import java.util.UUID; + +import org.bukkit.DyeColor; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyCat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.EntityHuman; -import net.minecraft.world.item.ItemDye; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.DyeItem; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.World; -import org.bukkit.DyeColor; - -import java.util.Optional; -import java.util.UUID; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 0.8F) public class EntityMyCat extends EntityMyPet { protected static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyCat.class, EntityDataSerializers.BOOLEAN); protected static final EntityDataAccessor SIT_WATCHER = SynchedEntityData.defineId(EntityMyCat.class, EntityDataSerializers.BYTE); - protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyCat.class, EntityDataSerializers.o); + protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyCat.class, EntityDataSerializers.OPTIONAL_UUID); protected static final EntityDataAccessor TYPE_WATCHER = SynchedEntityData.defineId(EntityMyCat.class, EntityDataSerializers.INT); protected static final EntityDataAccessor UNUSED_WATCHER_1 = SynchedEntityData.defineId(EntityMyCat.class, EntityDataSerializers.BOOLEAN); protected static final EntityDataAccessor UNUSED_WATCHER_2 = SynchedEntityData.defineId(EntityMyCat.class, EntityDataSerializers.BOOLEAN); @@ -75,27 +76,27 @@ protected String getHurtSound() { @Override protected String getLivingSound() { - return this.Q.nextInt(4) == 0 ? "entity.cat.purr" : "entity.cat.ambient"; + return this.random.nextInt(4) == 0 ? "entity.cat.purr" : "entity.cat.ambient"; } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman)) { if (itemStack != null && canUseItem() && getOwner().getPlayer().isSneaking()) { - if (itemStack.getItem() instanceof ItemDye) { - if (((ItemDye) itemStack.getItem()).d().getColorIndex() != getMyPet().getCollarColor().ordinal()) { - getMyPet().setCollarColor(DyeColor.values()[((ItemDye) itemStack.getItem()).d().getColorIndex()]); + if (itemStack.getItem() instanceof DyeItem) { + if (((DyeItem) itemStack.getItem()).d().getColorIndex() != getMyPet().getCollarColor().ordinal()) { + getMyPet().setCollarColor(DyeColor.values()[((DyeItem) itemStack.getItem()).d().getColorIndex()]); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); if (itemStack.getCount() <= 0) { entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); } } - return InteractionResult.a; + return InteractionResult.SUCCESS; } } else if (Configuration.MyPet.Ocelot.GROW_UP_ITEM.compare(itemStack) && canUseItem() && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCaveSpider.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCaveSpider.java index 9dc64158f1..2e3b26cba5 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCaveSpider.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCaveSpider.java @@ -23,10 +23,10 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.world.level.World; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.level.Level; @EntitySize(width = 0.7F, height = 0.45F) public class EntityMyCaveSpider extends EntityMyPet { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyChicken.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyChicken.java index 6ccee77991..2649c5da90 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyChicken.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyChicken.java @@ -25,15 +25,15 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyChicken; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 0.4F, height = 0.7F) public class EntityMyChicken extends EntityMyPet { @@ -44,7 +44,7 @@ public class EntityMyChicken extends EntityMyPet { public EntityMyChicken(Level world, MyPet myPet) { super(world, myPet); - nextEggTimer = (this.Q.nextInt(6000) + 6000); + nextEggTimer = (this.random.nextInt(6000) + 6000); } @Override @@ -63,8 +63,8 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } @@ -105,9 +105,9 @@ public void onLivingUpdate() { } if (Configuration.MyPet.Chicken.CAN_LAY_EGGS && canUseItem() && --nextEggTimer <= 0) { - this.makeSound("entity.chicken.egg", 1.0F, (this.Q.nextFloat() - this.Q.nextFloat()) * 0.2F + 1.0F); - a(Items.oo, 1); - nextEggTimer = this.Q.nextInt(6000) + 6000; + this.makeSound("entity.chicken.egg", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + a(Items.EGG, 1); + nextEggTimer = this.random.nextInt(6000) + 6000; } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java index dcfa4c512b..d99950a07f 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java @@ -57,7 +57,7 @@ protected String getLivingSound() { @Override public void onLivingUpdate() { super.onLivingUpdate(); - if (!isInWater() && this.Q.nextBoolean()) { + if (!isInWater() && this.random.nextBoolean()) { MyPetApi.getPlatformHelper().playParticleEffect(myPet.getLocation().get().add(0, 0.7, 0), ParticleCompat.WATER_SPLASH.get(), 0.2F, 0.2F, 0.2F, 0.5F, 10, 20); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCow.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCow.java index 43526b9174..cffff87587 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCow.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCow.java @@ -25,15 +25,15 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyCow; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 0.7F, height = 1.3F) public class EntityMyCow extends EntityMyPet { @@ -60,14 +60,14 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { if (itemStack.getItem() == Items.BUCKET && Configuration.MyPet.Cow.CAN_GIVE_MILK) { - ItemStack milkBucket = new ItemStack(Items.oc); + ItemStack milkBucket = new ItemStack(Items.MILK_BUCKET); entityhuman.getInventory().setItem(entityhuman.getInventory().selected, milkBucket); return InteractionResult.CONSUME; diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDolphin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDolphin.java index 9daf272b65..28290b2555 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDolphin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDolphin.java @@ -25,16 +25,16 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.core.BlockPosition; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.core.BlockPos; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.world.level.World; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.level.Level; @EntitySize(width = 0.9F, height = 0.6f) public class EntityMyDolphin extends EntityMyPet { - private static final EntityDataAccessor TREASURE_POS_WATCHER = SynchedEntityData.defineId(EntityMyDolphin.class, EntityDataSerializers.l); + private static final EntityDataAccessor TREASURE_POS_WATCHER = SynchedEntityData.defineId(EntityMyDolphin.class, EntityDataSerializers.BLOCK_POS); private static final EntityDataAccessor GOT_FISH_WATCHER = SynchedEntityData.defineId(EntityMyDolphin.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor MOISTNESS_WATCHER = SynchedEntityData.defineId(EntityMyDolphin.class, EntityDataSerializers.INT); @@ -60,7 +60,7 @@ protected String getLivingSound() { @Override public void onLivingUpdate() { super.onLivingUpdate(); - if (!isInWater() && this.Q.nextBoolean()) { + if (!isInWater() && this.random.nextBoolean()) { MyPetApi.getPlatformHelper().playParticleEffect(myPet.getLocation().get().add(0, 0.7, 0), ParticleCompat.WATER_SPLASH.get(), 0.2F, 0.2F, 0.2F, 0.5F, 10, 20); } } @@ -69,7 +69,7 @@ public void onLivingUpdate() { protected void defineSynchedData() { super.defineSynchedData(); - getEntityData().define(TREASURE_POS_WATCHER, BlockPosition.b); + getEntityData().define(TREASURE_POS_WATCHER, BlockPos.ZERO); getEntityData().define(GOT_FISH_WATCHER, false); getEntityData().define(MOISTNESS_WATCHER, 2400); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDonkey.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDonkey.java index b925e8cb76..429dd1e4cc 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDonkey.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDonkey.java @@ -20,43 +20,40 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Optional; +import java.util.UUID; + +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyDonkey; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.core.BlockPosition; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.sounds.SoundEffects; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.IJumpable; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.PlayerRideableJumping; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.SoundEffectType; -import net.minecraft.world.level.block.state.IBlockData; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Optional; -import java.util.UUID; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockState; @EntitySize(width = 1.4F, height = 1.6F) -public class EntityMyDonkey extends EntityMyPet implements IJumpable { +public class EntityMyDonkey extends EntityMyPet implements PlayerRideableJumping { protected static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyDonkey.class, EntityDataSerializers.BOOLEAN); protected static final EntityDataAccessor SADDLE_WATCHER = SynchedEntityData.defineId(EntityMyDonkey.class, EntityDataSerializers.BYTE); - protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyDonkey.class, EntityDataSerializers.o); + protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyDonkey.class, EntityDataSerializers.OPTIONAL_UUID); private static final EntityDataAccessor CHEST_WATCHER = SynchedEntityData.defineId(EntityMyDonkey.class, EntityDataSerializers.BOOLEAN); int soundCounter = 0; @@ -75,7 +72,7 @@ public EntityMyDonkey(Level world, MyPet myPet) { * 128 mouth open */ protected void applyVisual(int value, boolean flag) { - int i = this.getSynchedEntityData().get(SADDLE_WATCHER); + int i = this.getEntityData().get(SADDLE_WATCHER); if (flag) { this.getEntityData().set(SADDLE_WATCHER, (byte) (i | value)); } else { @@ -100,13 +97,13 @@ public boolean attack(Entity entity) { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (itemStack != null && canUseItem()) { - if (itemStack.getItem() == Items.lL && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SADDLE && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking() && canEquip()) { getMyPet().setSaddle(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -115,7 +112,7 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Item.getItemOf(Blocks.pq) && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && canEquip()) { + } else if (itemStack.getItem() == Item.byBlock(Blocks.pq) && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && canEquip()) { getMyPet().setChest(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -124,18 +121,18 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + } else if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { if (getMyPet().hasChest()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getChest())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getChest())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } if (getMyPet().hasSaddle()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } makeSound("entity.sheep.shear", 1.0F, 1.0F); @@ -223,25 +220,25 @@ public void onLivingUpdate() { @Override - public void playStepSound(BlockPosition blockposition, IBlockData blockdata) { + public void playStepSound(BlockPos blockposition, BlockState blockdata) { if (!blockdata.getMaterial().isLiquid()) { - IBlockData blockdataUp = this.t.getType(blockposition.up()); - SoundEffectType soundeffecttype = blockdata.getStepSound(); - if (blockdataUp.getBlock() == Blocks.cK) { - soundeffecttype = blockdata.getStepSound(); + BlockState blockdataUp = this.level.getBlockState(blockposition.up()); + SoundType soundeffecttype = blockdata.getSoundType(); + if (blockdataUp.getBlock() == Blocks.SNOW) { + soundeffecttype = blockdata.getSoundType(); } if (this.isVehicle()) { ++this.soundCounter; if (this.soundCounter > 5 && this.soundCounter % 3 == 0) { - this.playSound(SoundEffects.iB, soundeffecttype.getVolume() * 0.16F, soundeffecttype.getPitch()); + this.playSound(SoundEvents.HORSE_GALLOP, soundeffecttype.getVolume() * 0.16F, soundeffecttype.getPitch()); } else if (this.soundCounter <= 5) { - this.playSound(SoundEffects.iH, soundeffecttype.getVolume() * 0.16F, soundeffecttype.getPitch()); + this.playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.16F, soundeffecttype.getPitch()); } } else if (!blockdata.getMaterial().isLiquid()) { this.soundCounter += 1; - playSound(SoundEffects.iH, soundeffecttype.getVolume() * 0.16F, soundeffecttype.getPitch()); + playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.16F, soundeffecttype.getPitch()); } else { - playSound(SoundEffects.iG, soundeffecttype.getVolume() * 0.16F, soundeffecttype.getPitch()); + playSound(SoundEvents.HORSE_STEP, soundeffecttype.getVolume() * 0.16F, soundeffecttype.getPitch()); } } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDrowned.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDrowned.java index 2d5cba52ec..8b15203748 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDrowned.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDrowned.java @@ -20,7 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.Util; @@ -29,27 +36,20 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyDrowned; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.WorldServer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.95F) public class EntityMyDrowned extends EntityMyPet { @@ -95,21 +95,21 @@ protected String getLivingSound() { * false: no reaction on rightclick */ @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { - if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -132,13 +132,13 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -195,17 +195,17 @@ public MyDrowned getMyPet() { } public void setPetEquipment(EquipmentSlot slot, ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.values()[slot.get19Slot()], itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.values()[slot.get19Slot()], itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderDragon.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderDragon.java index bd3533df57..ad42a087cb 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderDragon.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderDragon.java @@ -88,7 +88,7 @@ public void onLivingUpdate() { } if (!registered && this.valid) { if (this.getWorld() instanceof WorldServer) { - WorldServer world = (WorldServer) this.getWorld(); + WorldServer world = (ServerLevel) this.getWorld(); Arrays.stream(this.children) .forEach(entityMyPetPart -> world.addEntity(entityMyPetPart)); // TODO: 2021/07/14 I don't know if this is the right replacement. } @@ -109,9 +109,9 @@ public int calculateFallDamage(float f, float f1) { /* fmm... @Override - public void die() { - super.die(); - Arrays.stream(this.children).forEach((en) -> (en.getBukkitEntity().getHandle()).die()); + public void discard() { + super.discard(); + Arrays.stream(this.children).forEach((en) -> (en.getBukkitEntity().getHandle()).discard()); } */ @@ -122,8 +122,8 @@ public void die(DamageSource damagesource) { } @Override - public void movementTick() { - super.movementTick(); + public void aiStep() { + super.aiStep(); // if (++this.d == this.c.length) { // this.d = 0; @@ -136,18 +136,18 @@ public void movementTick() { // float f11 = MathHelper.sin(f10); // float f12 = MathHelper.cos(f10); // this.children[2].tick(); - // this.children[2].setPositionRotation(this.locX() + (double) (f11 * 0.5F), this.locY(), this.locZ() - (double) (f12 * 0.5F), 0.0F, 0.0F); + // this.children[2].setPositionRotation(this.getX() + (double) (f11 * 0.5F), this.getY(), this.getZ() - (double) (f12 * 0.5F), 0.0F, 0.0F); // this.children[6].tick(); - // this.children[6].setPositionRotation(this.locX() + (double) (f12 * 4.5F), this.locY() + 2.0D, this.locZ() + (double) (f11 * 4.5F), 0.0F, 0.0F); + // this.children[6].setPositionRotation(this.getX() + (double) (f12 * 4.5F), this.getY() + 2.0D, this.getZ() + (double) (f11 * 4.5F), 0.0F, 0.0F); // this.children[7].tick(); - // this.children[7].setPositionRotation(this.locX() - (double) (f12 * 4.5F), this.locY() + 2.0D, this.locZ() - (double) (f11 * 4.5F), 0.0F, 0.0F); + // this.children[7].setPositionRotation(this.getX() - (double) (f12 * 4.5F), this.getY() + 2.0D, this.getZ() - (double) (f11 * 4.5F), 0.0F, 0.0F); // // float f13 = MathHelper.sin(this.yaw * 0.017453292F - this.be * 0.01F); // float f14 = MathHelper.cos(this.yaw * 0.017453292F - this.be * 0.01F); // this.children[0].tick(); // this.children[1].tick(); // double f3 = this.v(1.0F); - // this.children[0].setPositionRotation(this.locX() + (double) (f13 * 6.5F * f8), this.locY() + (double) f3 + (double) (f9 * 6.5F), this.locZ() - (double) (f14 * 6.5F * f8), 0.0F, 0.0F); - // this.children[1].setPositionRotation(this.locX() + (double) (f13 * 5.5F * f8), this.locY() + (double) f3 + (double) (f9 * 5.5F), this.locZ() - (double) (f14 * 5.5F * f8), 0.0F, 0.0F); + // this.children[0].setPositionRotation(this.getX() + (double) (f13 * 6.5F * f8), this.getY() + (double) f3 + (double) (f9 * 6.5F), this.getZ() - (double) (f14 * 6.5F * f8), 0.0F, 0.0F); + // this.children[1].setPositionRotation(this.getX() + (double) (f13 * 5.5F * f8), this.getY() + (double) f3 + (double) (f9 * 5.5F), this.getZ() - (double) (f14 * 5.5F * f8), 0.0F, 0.0F); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderman.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderman.java index bfaf4d59a9..2a64307f27 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderman.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderman.java @@ -32,13 +32,13 @@ import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.item.EntityItem; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.World; -import net.minecraft.world.level.block.state.IBlockData; +import net.minecraft.world.level.block.state.BlockState; import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_17_R1.util.CraftMagicNumbers; @@ -50,7 +50,7 @@ @EntitySize(width = 0.6F, height = 2.55F) public class EntityMyEnderman extends EntityMyPet { - private static final EntityDataAccessor> BLOCK_WATCHER = SynchedEntityData.defineId(EntityMyEnderman.class, EntityDataSerializers.h); + private static final EntityDataAccessor> BLOCK_WATCHER = SynchedEntityData.defineId(EntityMyEnderman.class, EntityDataSerializers.h); private static final EntityDataAccessor SCREAMING_WATCHER = SynchedEntityData.defineId(EntityMyEnderman.class, EntityDataSerializers.BOOLEAN); public EntityMyEnderman(Level world, MyPet myPet) { @@ -74,15 +74,15 @@ protected String getLivingSound() { @Override public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { - if (itemStack.getItem() == Items.pq && getMyPet().hasBlock() && getOwner().getPlayer().isSneaking()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getBlock())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); + if (itemStack.getItem() == Items.SHEARS && getMyPet().hasBlock() && getOwner().getPlayer().isSneaking()) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getBlock())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); makeSound("entity.sheep.shear", 1.0F, 1.0F); getMyPet().setBlock(null); @@ -125,9 +125,9 @@ protected void defineSynchedData() { @Override public void updateVisuals() { - Optional block; + Optional block; if (getMyPet().getBlock() != null) { - IBlockData data = CraftMagicNumbers.getBlock(getMyPet().getBlock().getData()); + BlockState data = CraftMagicNumbers.getBlock(getMyPet().getBlock().getData()); block = Optional.ofNullable(data); } else { block = Optional.empty(); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyFox.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyFox.java index f037069573..dec940c2c3 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyFox.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyFox.java @@ -20,7 +20,16 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; +import java.util.Optional; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.Util; @@ -29,28 +38,18 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyFox; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; -import java.util.Optional; -import java.util.UUID; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 0.8F) public class EntityMyFox extends EntityMyPet { @@ -58,12 +57,12 @@ public class EntityMyFox extends EntityMyPet { private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyFox.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor FOX_TYPE_WATCHER = SynchedEntityData.defineId(EntityMyFox.class, EntityDataSerializers.INT); private static final EntityDataAccessor ACTIONS_WATCHER = SynchedEntityData.defineId(EntityMyFox.class, EntityDataSerializers.BYTE); - private static final EntityDataAccessor> FRIEND_A_WATCHER = SynchedEntityData.defineId(EntityMyFox.class, EntityDataSerializers.o); - private static final EntityDataAccessor> FRIEND_B_WATCHER = SynchedEntityData.defineId(EntityMyFox.class, EntityDataSerializers.o); + private static final EntityDataAccessor> FRIEND_A_WATCHER = SynchedEntityData.defineId(EntityMyFox.class, EntityDataSerializers.OPTIONAL_UUID); + private static final EntityDataAccessor> FRIEND_B_WATCHER = SynchedEntityData.defineId(EntityMyFox.class, EntityDataSerializers.OPTIONAL_UUID); public EntityMyFox(Level world, MyPet myPet) { super(world, myPet); - this.getControllerLook().a(this, 60.0F, 30.0F); + this.getLookControl().setLookAt(this, 60.0F, 30.0F); } @Override @@ -82,20 +81,20 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman)) { - if (itemStack != null && itemStack.getItem() != Items.a && canUseItem() && getOwner().getPlayer().isSneaking()) { - if (itemStack.getItem() != Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack != null && itemStack.getItem() != Items.AIR && canUseItem() && getOwner().getPlayer().isSneaking()) { + if (itemStack.getItem() != Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(EquipmentSlot.MainHand)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(EquipmentSlot.MainHand, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -114,15 +113,15 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } getMyPet().setBaby(false); return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + } else if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -184,32 +183,32 @@ public void updateVisuals() { */ public void updateActionsWatcher(int i, boolean flag) { if (flag) { - this.Y.set(ACTIONS_WATCHER, (byte) (this.Y.get(ACTIONS_WATCHER) | i)); + this.entityData.set(ACTIONS_WATCHER, (byte) (this.entityData.get(ACTIONS_WATCHER) | i)); } else { - this.Y.set(ACTIONS_WATCHER, (byte) (this.Y.get(ACTIONS_WATCHER) & ~i)); + this.entityData.set(ACTIONS_WATCHER, (byte) (this.entityData.get(ACTIONS_WATCHER) & ~i)); } } @Override - public void movementTick() { - super.movementTick(); + public void aiStep() { + super.aiStep(); // foxes can't look up this.setXRot(0F); } public void setPetEquipment(ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.a, itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.MAINHAND, itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGiant.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGiant.java index b73574df59..14fec69198 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGiant.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGiant.java @@ -20,7 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Util; import de.Keyle.MyPet.api.entity.EntitySize; @@ -29,24 +36,16 @@ import de.Keyle.MyPet.api.entity.types.MyGiant; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack.MeleeAttack; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 6.0f, height = 10.440001F) public class EntityMyGiant extends EntityMyPet { @@ -84,21 +83,21 @@ public void setPathfinder() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { - if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -121,13 +120,13 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -154,18 +153,18 @@ public void updateVisuals() { } public void setPetEquipment(EquipmentSlot slot, ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.values()[slot.get19Slot()], itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.values()[slot.get19Slot()], itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGuardian.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGuardian.java index 7e12c6729f..40c12c74cc 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGuardian.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGuardian.java @@ -24,7 +24,7 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyGuardian; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 0.7F, height = 0.85F) public class EntityMyGuardian extends EntityMyPet { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java index 51194f8c1d..a9d3c57fff 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java @@ -25,14 +25,14 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyHoglin; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 1.3965F, height = 1.4F) public class EntityMyHoglin extends EntityMyPet { @@ -59,7 +59,7 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(final EntityHuman entityhuman, InteractionHand enumhand, final ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(final Player entityhuman, InteractionHand enumhand, final ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { return InteractionResult.CONSUME; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHorse.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHorse.java index 6d2faf9e1b..a2bae0888f 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHorse.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHorse.java @@ -20,7 +20,16 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; +import java.util.Optional; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.Util; @@ -29,42 +38,32 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyHorse; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.core.BlockPosition; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.core.BlockPos; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.server.level.WorldServer; -import net.minecraft.sounds.SoundEffects; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.IJumpable; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.PlayerRideableJumping; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.SoundEffectType; -import net.minecraft.world.level.block.state.IBlockData; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; -import java.util.Optional; -import java.util.UUID; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockState; @EntitySize(width = 1.3965F, height = 1.6F) -public class EntityMyHorse extends EntityMyPet implements IJumpable { +public class EntityMyHorse extends EntityMyPet implements PlayerRideableJumping { protected static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyHorse.class, EntityDataSerializers.BOOLEAN); protected static final EntityDataAccessor SADDLE_CHEST_WATCHER = SynchedEntityData.defineId(EntityMyHorse.class, EntityDataSerializers.BYTE); - protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyHorse.class, EntityDataSerializers.o); + protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyHorse.class, EntityDataSerializers.OPTIONAL_UUID); private static final EntityDataAccessor VARIANT_WATCHER = SynchedEntityData.defineId(EntityMyHorse.class, EntityDataSerializers.INT); int soundCounter = 0; @@ -82,7 +81,7 @@ public EntityMyHorse(Level world, MyPet myPet) { * 64 rear */ protected void applyVisual(int value, boolean flag) { - int i = this.getSynchedEntityData().get(SADDLE_CHEST_WATCHER); + int i = this.getEntityData().get(SADDLE_CHEST_WATCHER); if (flag) { this.getEntityData().set(SADDLE_CHEST_WATCHER, (byte) (i | value)); } else { @@ -122,14 +121,14 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (itemStack != null && canUseItem()) { org.bukkit.inventory.ItemStack is = CraftItemStack.asBukkitCopy(itemStack); - if (itemStack.getItem() == Items.lL && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SADDLE && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking() && canEquip()) { getMyPet().setSaddle(is); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -147,24 +146,24 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + } else if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { if (getMyPet().hasArmor()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getArmor())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getArmor())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } if (getMyPet().hasChest()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getChest())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getChest())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } if (getMyPet().hasSaddle()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } makeSound("entity.sheep.shear", 1.0F, 1.0F); @@ -255,42 +254,42 @@ public void onLivingUpdate() { } @Override - public void playStepSound(BlockPosition blockposition, IBlockData blockdata) { + public void playStepSound(BlockPos blockposition, BlockState blockdata) { if (!blockdata.getMaterial().isLiquid()) { - IBlockData blockdataUp = this.t.getType(blockposition.up()); - SoundEffectType soundeffecttype = blockdata.getStepSound(); - if (blockdataUp.getBlock() == Blocks.cK) { - soundeffecttype = blockdata.getStepSound(); + BlockState blockdataUp = this.level.getBlockState(blockposition.up()); + SoundType soundeffecttype = blockdata.getSoundType(); + if (blockdataUp.getBlock() == Blocks.SNOW) { + soundeffecttype = blockdata.getSoundType(); } if (this.isVehicle()) { ++this.soundCounter; if (this.soundCounter > 5 && this.soundCounter % 3 == 0) { - this.playSound(SoundEffects.iB, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + this.playSound(SoundEvents.HORSE_GALLOP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } else if (this.soundCounter <= 5) { - this.playSound(SoundEffects.iH, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + this.playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } } else if (!blockdata.getMaterial().isLiquid()) { this.soundCounter += 1; - playSound(SoundEffects.iH, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } else { - playSound(SoundEffects.iG, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + playSound(SoundEvents.HORSE_STEP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } } } public void setPetEquipment(EquipmentSlot slot, ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.values()[slot.get19Slot()], itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.values()[slot.get19Slot()], itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (slot == EquipmentSlot.Chestplate && getMyPet().getArmor() != null) { return CraftItemStack.asNMSCopy(getMyPet().getArmor()); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java index 6208ae7325..daacc726d6 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java @@ -20,7 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.Util; @@ -29,27 +36,19 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyHusk; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyHusk extends EntityMyPet { @@ -94,7 +93,7 @@ protected String getLivingSound() { */ @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { return InteractionResult.CONSUME; } @@ -105,10 +104,10 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -131,13 +130,13 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -193,17 +192,17 @@ public MyHusk getMyPet() { } public void setPetEquipment(EquipmentSlot slot, ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.values()[slot.get19Slot()], itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.values()[slot.get19Slot()], itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java index 1eb287b017..ad9164c0da 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java @@ -20,7 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Util; import de.Keyle.MyPet.api.entity.EntitySize; @@ -29,25 +36,19 @@ import de.Keyle.MyPet.api.entity.types.MyIllusioner; import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.95F) public class EntityMyIllusioner extends EntityMyPet { @@ -90,7 +91,7 @@ protected String getLivingSound() { * false: no reaction on rightclick */ @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { return InteractionResult.CONSUME; } @@ -101,10 +102,10 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -127,14 +128,14 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); if (slot == EquipmentSlot.MainHand) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -174,17 +175,17 @@ public MyIllusioner getMyPet() { } public void setPetEquipment(ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.a, itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.MAINHAND, itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIronGolem.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIronGolem.java index 0509a20b1f..d97636e4c8 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIronGolem.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIronGolem.java @@ -20,30 +20,29 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyIronGolem; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; @EntitySize(width = 1.4F, height = 2.7F) public class EntityMyIronGolem extends EntityMyPet { @@ -61,10 +60,10 @@ public EntityMyIronGolem(Level world, MyPet myPet) { public boolean attack(Entity entity) { boolean flag = false; try { - this.t.broadcastEntityEffect(this, (byte) 4); + this.level.broadcastEntityEvent(this, (byte) 4); flag = super.attack(entity); if (Configuration.MyPet.IronGolem.CAN_TOSS_UP && flag) { - entity.setMot(entity.getMot().add(0, 0.4000000059604645D, 0)); + entity.setDeltaMovement(entity.getDeltaMovement().add(0, 0.4000000059604645D, 0)); this.makeSound("entity.iron_golem.attack", 1.0F, 1.0F); } } catch (Exception e) { @@ -95,8 +94,8 @@ protected void defineSynchedData() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } @@ -122,11 +121,11 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Items.pq && getMyPet().hasFlower() && getOwner().getPlayer().isSneaking()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getFlower())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + } else if (itemStack.getItem() == Items.SHEARS && getMyPet().hasFlower() && getOwner().getPlayer().isSneaking()) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getFlower())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); makeSound("entity.sheep.shear", 1.0F, 1.0F); getMyPet().setFlower(null); @@ -171,7 +170,7 @@ public void playPetStepSound() { public void onLivingUpdate() { super.onLivingUpdate(); if (this.flower && this.flowerCounter-- <= 0) { - this.t.broadcastEntityEffect(this, (byte) 11); + this.level.broadcastEntityEvent(this, (byte) 11); flowerCounter = 300; } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyLlama.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyLlama.java index b324624e0b..3d513d29e3 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyLlama.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyLlama.java @@ -20,39 +20,38 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Optional; +import java.util.UUID; + +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyLlama; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.tags.TagsItem; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.BlockCarpet; +import net.minecraft.world.level.block.WoolCarpetBlock; import net.minecraft.world.level.block.Blocks; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Optional; -import java.util.UUID; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; @EntitySize(width = 0.9F, height = 1.87F) public class EntityMyLlama extends EntityMyPet { private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyLlama.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor SADDLE_CHEST_WATCHER = SynchedEntityData.defineId(EntityMyLlama.class, EntityDataSerializers.BYTE); - private static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyLlama.class, EntityDataSerializers.o); + private static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyLlama.class, EntityDataSerializers.OPTIONAL_UUID); private static final EntityDataAccessor CHEST_WATCHER = SynchedEntityData.defineId(EntityMyLlama.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor STRENGTH_WATCHER = SynchedEntityData.defineId(EntityMyLlama.class, EntityDataSerializers.INT); private static final EntityDataAccessor COLOR_WATCHER = SynchedEntityData.defineId(EntityMyLlama.class, EntityDataSerializers.INT); @@ -78,8 +77,8 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } @@ -93,7 +92,7 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Blocks.bX.getItem() && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && !getMyPet().isBaby() && canEquip()) { + } else if (itemStack.getItem() == Blocks.CHEST.getItem() && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && !getMyPet().isBaby() && canEquip()) { getMyPet().setChest(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -102,18 +101,18 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + } else if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { if (getMyPet().hasChest()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getChest())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getChest())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } if (getMyPet().hasDecor()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getDecor())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getDecor())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } makeSound("entity.sheep.shear", 1.0F, 1.0F); @@ -167,8 +166,8 @@ public void updateVisuals() { this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); if (getMyPet().hasDecor()) { ItemStack is = CraftItemStack.asNMSCopy(getMyPet().getDecor()); - Block block = Block.asBlock(is.getItem()); - int color = block instanceof BlockCarpet ? ((BlockCarpet) block).c().getColorIndex() : 0; + Block block = Block.byItem(is.getItem()); + int color = block instanceof WoolCarpetBlock ? ((WoolCarpetBlock) block).c().getColorIndex() : 0; this.getEntityData().set(COLOR_WATCHER, color); } else { this.getEntityData().set(COLOR_WATCHER, -1); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMagmaCube.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMagmaCube.java index 297b859af4..2dc9501f2b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMagmaCube.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMagmaCube.java @@ -25,11 +25,11 @@ import de.Keyle.MyPet.api.entity.types.MyMagmaCube; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack.MeleeAttack; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.world.entity.EntityPose; -import net.minecraft.world.level.World; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.entity.Pose; +import net.minecraft.world.level.Level; @EntitySize(width = 0.5100001F, height = 0.5100001F) public class EntityMyMagmaCube extends EntityMyPet { @@ -67,10 +67,10 @@ protected void defineSynchedData() { public void onLivingUpdate() { super.onLivingUpdate(); - if (this.z && jumpDelay-- <= 0) { - getControllerJump().jump(); - jumpDelay = (this.Q.nextInt(20) + 50); - this.makeSound("entity.magma_cube.jump", 1.0F, ((this.Q.nextFloat() - this.Q.nextFloat()) * 0.2F + 1.0F) / 0.8F); + if (this.onGround && jumpDelay-- <= 0) { + getJumpControl().jump(); + jumpDelay = (this.random.nextInt(20) + 50); + this.makeSound("entity.magma_cube.jump", 1.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); } } @@ -78,22 +78,22 @@ public void onLivingUpdate() { public void updateVisuals() { int size = Math.max(1, getMyPet().getSize()); getEntityData().set(SIZE_WATCHER, size); - this.updateSize(); + this.refreshDimensions(); if (petPathfinderSelector != null && petPathfinderSelector.hasGoal("MeleeAttack")) { petPathfinderSelector.replaceGoal("MeleeAttack", new MeleeAttack(this, 0.1F, 3 + (getMyPet().getSize() * 0.51), 20)); } } @Override - public net.minecraft.world.entity.EntitySize a(EntityPose entitypose) { + public net.minecraft.world.entity.EntityDimensions getDimensions(Pose entitypose) { EntitySize es = this.getClass().getAnnotation(EntitySize.class); if (es != null) { int size = Math.max(1, getMyPet().getSize()); float width = es.width(); float height = Float.isNaN(es.height()) ? width : es.height(); - return new net.minecraft.world.entity.EntitySize(width * size, height * size, false); + return new net.minecraft.world.entity.EntityDimensions(width * size, height * size, false); } - return super.a(entitypose); + return super.getDimensions(entitypose); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java index 60008b51b7..83fdc10942 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java @@ -20,28 +20,29 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import org.bukkit.Bukkit; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyMooshroom; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; +import net.minecraft.world.level.Level; @EntitySize(width = 0.7F, height = 1.3F) public class EntityMyMooshroom extends EntityMyPet { private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyMooshroom.class, EntityDataSerializers.BOOLEAN); - private static final EntityDataAccessor COLOR_WATCHER = SynchedEntityData.defineId(EntityMyMooshroom.class, EntityDataSerializers.d); + private static final EntityDataAccessor COLOR_WATCHER = SynchedEntityData.defineId(EntityMyMooshroom.class, EntityDataSerializers.STRING); public EntityMyMooshroom(Level world, MyPet myPet) { super(world, myPet); @@ -63,16 +64,16 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (itemStack != null) { - if (itemStack.getItem().equals(Items.nc)) { + if (itemStack.getItem().equals(Items.BOWL)) { if (!getOwner().equals(entityhuman) || !canUseItem() || !Configuration.MyPet.Mooshroom.CAN_GIVE_SOUP) { final int itemInHandIndex = entityhuman.getInventory().selected; - ItemStack is = new ItemStack(Items.nd); + ItemStack is = new ItemStack(Items.MUSHROOM_STEW); final ItemStack oldIs = entityhuman.getInventory().getItem(itemInHandIndex); entityhuman.getInventory().setItem(itemInHandIndex, is); Bukkit.getScheduler().scheduleSyncDelayedTask(MyPetApi.getPlugin(), () -> entityhuman.getInventory().setItem(itemInHandIndex, oldIs), 2L); @@ -80,10 +81,10 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } else { itemStack.shrink(1); if (itemStack.getCount() <= 0) { - entityhuman.getInventory().setItem(entityhuman.getInventory().selected, new ItemStack(Items.nd)); + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, new ItemStack(Items.MUSHROOM_STEW)); } else { - if (!entityhuman.getInventory().add(new ItemStack(Items.nd))) { - entityhuman.drop(new ItemStack(Items.pG), true); + if (!entityhuman.getInventory().add(new ItemStack(Items.MUSHROOM_STEW))) { + entityhuman.drop(new ItemStack(Items.GLASS_BOTTLE), true); } } return InteractionResult.CONSUME; @@ -115,7 +116,7 @@ protected void defineSynchedData() { @Override public void updateVisuals() { this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); - this.getEntityData().set(COLOR_WATCHER, getMyPet().getType().getType()); + this.getEntityData().set(COLOR_WATCHER, getMyPet().getType().getType()); //TODO } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMule.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMule.java index 2ccbd976e6..7a94a4b8dd 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMule.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMule.java @@ -20,43 +20,42 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Optional; +import java.util.UUID; + +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyMule; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.core.BlockPosition; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.core.BlockPos; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.sounds.SoundEffects; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.IJumpable; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.PlayerRideableJumping; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.SoundEffectType; -import net.minecraft.world.level.block.state.IBlockData; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Optional; -import java.util.UUID; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockState; @EntitySize(width = 1.4F, height = 1.6F) -public class EntityMyMule extends EntityMyPet implements IJumpable { +public class EntityMyMule extends EntityMyPet implements PlayerRideableJumping { protected static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyMule.class, EntityDataSerializers.BOOLEAN); protected static final EntityDataAccessor SADDLE_WATCHER = SynchedEntityData.defineId(EntityMyMule.class, EntityDataSerializers.BYTE); - protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyMule.class, EntityDataSerializers.o); + protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyMule.class, EntityDataSerializers.OPTIONAL_UUID); private static final EntityDataAccessor CHEST_WATCHER = SynchedEntityData.defineId(EntityMyMule.class, EntityDataSerializers.BOOLEAN); int soundCounter = 0; @@ -75,7 +74,7 @@ public EntityMyMule(Level world, MyPet myPet) { * 128 mouth open */ protected void applyVisual(int value, boolean flag) { - int i = this.getSynchedEntityData().get(SADDLE_WATCHER); + int i = this.getEntityData().get(SADDLE_WATCHER); if (flag) { this.getEntityData().set(SADDLE_WATCHER, (byte) (i | value)); } else { @@ -100,13 +99,13 @@ public boolean attack(Entity entity) { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (itemStack != null && canUseItem()) { - if (itemStack.getItem() == Items.lL && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SADDLE && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking() && canEquip()) { getMyPet().setSaddle(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -115,7 +114,7 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Item.getItemOf(Blocks.bX) && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && canEquip()) { + } else if (itemStack.getItem() == Item.byBlock(Blocks.CHEST) && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && canEquip()) { getMyPet().setChest(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -124,18 +123,18 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + } else if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { if (getMyPet().hasChest()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getChest())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getChest())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } if (getMyPet().hasSaddle()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } makeSound("entity.sheep.shear", 1.0F, 1.0F); @@ -222,25 +221,25 @@ public void onLivingUpdate() { } @Override - public void playStepSound(BlockPosition blockposition, IBlockData blockdata) { + public void playStepSound(BlockPos blockposition, BlockState blockdata) { if (!blockdata.getMaterial().isLiquid()) { - IBlockData blockdataUp = this.t.getType(blockposition.up()); - SoundEffectType soundeffecttype = blockdata.getStepSound(); - if (blockdataUp.getBlock() == Blocks.cK) { - soundeffecttype = blockdata.getStepSound(); + BlockState blockdataUp = this.level.getBlockState(blockposition.up()); + SoundType soundeffecttype = blockdata.getSoundType(); + if (blockdataUp.getBlock() == Blocks.SNOW) { + soundeffecttype = blockdata.getSoundType(); } if (this.isVehicle()) { ++this.soundCounter; if (this.soundCounter > 5 && this.soundCounter % 3 == 0) { - this.playSound(SoundEffects.hB, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + this.playSound(SoundEvents.hB, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } else if (this.soundCounter <= 5) { - this.playSound(SoundEffects.iH, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + this.playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } } else if (!blockdata.getMaterial().isLiquid()) { this.soundCounter += 1; - playSound(SoundEffects.iH, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } else { - playSound(SoundEffects.iG, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + playSound(SoundEvents.HORSE_STEP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyOcelot.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyOcelot.java index 350ba20ce8..0c597a121a 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyOcelot.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyOcelot.java @@ -25,14 +25,14 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyOcelot; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 0.8F) public class EntityMyOcelot extends EntityMyPet { @@ -60,8 +60,8 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPanda.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPanda.java index cceef9bd77..e015243f98 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPanda.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPanda.java @@ -25,14 +25,14 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyPanda; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 1.825F, height = 1.25F) public class EntityMyPanda extends EntityMyPet { @@ -65,8 +65,8 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } @@ -114,9 +114,9 @@ public void updateVisuals() { */ public void updateActionsWatcher(int i, boolean flag) { if (flag) { - this.Y.set(ACTIONS_WATCHER, (byte) (this.Y.get(ACTIONS_WATCHER) | i)); + this.entityData.set(ACTIONS_WATCHER, (byte) (this.entityData.get(ACTIONS_WATCHER) | i)); } else { - this.Y.set(ACTIONS_WATCHER, (byte) (this.Y.get(ACTIONS_WATCHER) & ~i)); + this.entityData.set(ACTIONS_WATCHER, (byte) (this.entityData.get(ACTIONS_WATCHER) & ~i)); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPhantom.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPhantom.java index 535770e005..494f1c4296 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPhantom.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPhantom.java @@ -26,11 +26,11 @@ import de.Keyle.MyPet.api.entity.types.MyPhantom; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack.MeleeAttack; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.world.entity.EntityPose; -import net.minecraft.world.level.World; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.entity.Pose; +import net.minecraft.world.level.Level; @EntitySize(width = 0.51F, height = 0.51F) public class EntityMyPhantom extends EntityMyPet { @@ -67,22 +67,22 @@ protected void defineSynchedData() { public void updateVisuals() { int size = Math.max(1, getMyPet().getSize()); getEntityData().set(SIZE_WATCHER, size); - this.updateSize(); + this.refreshDimensions(); if (petPathfinderSelector != null && petPathfinderSelector.hasGoal("MeleeAttack")) { petPathfinderSelector.replaceGoal("MeleeAttack", new MeleeAttack(this, 0.1F, 3 + (getMyPet().getSize() * 0.2), 20)); } } @Override - public net.minecraft.world.entity.EntitySize a(EntityPose entitypose) { + public net.minecraft.world.entity.EntityDimensions getDimensions(Pose entitypose) { EntitySize es = this.getClass().getAnnotation(EntitySize.class); if (es != null) { int size = Math.max(1, getMyPet().getSize()); float width = es.width(); float height = Float.isNaN(es.height()) ? width : es.height(); - return new net.minecraft.world.entity.EntitySize(width * size, height * size, false); + return new net.minecraft.world.entity.EntityDimensions(width * size, height * size, false); } - return super.a(entitypose); + return super.getDimensions(entitypose); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPig.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPig.java index d709f88a1a..ac7c94b13c 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPig.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPig.java @@ -20,32 +20,32 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; + +import java.lang.reflect.InvocationTargetException; + +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyPig; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.server.level.EntityPlayer; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; - -import java.lang.reflect.InvocationTargetException; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 0.7F, height = 0.9F) public class EntityMyPig extends EntityMyPet { @@ -73,17 +73,17 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(final EntityHuman entityhuman, InteractionHand enumhand, final ItemStack itemStack) { - if (enumhand == InteractionHand.b) { + public InteractionResult handlePlayerInteraction(final net.minecraft.world.entity.player.Player entityhuman, InteractionHand enumhand, final ItemStack itemStack) { + if (enumhand == InteractionHand.OFF_HAND) { if (itemStack != null) { - if (itemStack.getItem() == Items.rP) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutAttachEntity(this, null)); - entityhuman.a(InteractionHand.b, ItemStack.EMPTY); + if (itemStack.getItem() == Items.LEAD) { + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEntityLinkPacket(this, null)); + entityhuman.a(InteractionHand.OFF_HAND, ItemStack.EMPTY); new BukkitRunnable() { @Override public void run() { - if (entityhuman instanceof EntityPlayer) { - entityhuman.a(InteractionHand.b, itemStack); + if (entityhuman instanceof ServerPlayer) { + entityhuman.a(InteractionHand.OFF_HAND, itemStack);//TODO Player p = (Player) entityhuman.getBukkitEntity(); if (!p.isOnline()) { p.saveData(); @@ -96,12 +96,12 @@ public void run() { return InteractionResult.CONSUME; } - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { - if (itemStack.getItem() == Items.lL && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking()) { + if (itemStack.getItem() == Items.SADDLE && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking()) { getMyPet().setSaddle(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -110,11 +110,11 @@ public void run() { } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Items.pq && getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + } else if (itemStack.getItem() == Items.SHEARS && getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking()) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); makeSound("entity.sheep.shear", 1.0F, 1.0F); getMyPet().setSaddle(null); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglin.java index 2f25c7a4b8..20fbc8a18f 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglin.java @@ -20,7 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.Util; @@ -30,27 +37,19 @@ import de.Keyle.MyPet.api.entity.MyPet.PetState; import de.Keyle.MyPet.api.entity.types.MyPiglin; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyPiglin extends EntityMyPet { @@ -77,21 +76,21 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack) == InteractionResult.CONSUME) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { - if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -114,13 +113,13 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -178,17 +177,17 @@ public MyPiglin getMyPet() { } public void setPetEquipment(EquipmentSlot slot, ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.values()[slot.get19Slot()], itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.values()[slot.get19Slot()], itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglinBrute.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglinBrute.java index c9df5ce0e3..f778c390a1 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglinBrute.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglinBrute.java @@ -20,7 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.Util; @@ -31,28 +38,20 @@ import de.Keyle.MyPet.api.entity.types.MyPiglinBrute; import de.Keyle.MyPet.api.util.NMSUtil; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.server.level.WorldServer; -import net.minecraft.sounds.SoundEffects; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyPiglinBrute extends EntityMyPet { @@ -67,35 +66,35 @@ public EntityMyPiglinBrute(Level world, MyPet myPet) { protected String getDeathSound() { - return NMSUtil.getSoundEffectId(SoundEffects.nZ); + return NMSUtil.getSoundEffectId(SoundEvents.PIGLIN_BRUTE_DEATH); } @Override protected String getHurtSound() { - return NMSUtil.getSoundEffectId(SoundEffects.oa); + return NMSUtil.getSoundEffectId(SoundEvents.PIGLIN_BRUTE_HURT); } @Override protected String getLivingSound() { - return NMSUtil.getSoundEffectId(SoundEffects.nX); + return NMSUtil.getSoundEffectId(SoundEvents.PIGLIN_BRUTE_AMBIENT); } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack) == InteractionResult.CONSUME) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { - if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -118,13 +117,13 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -182,17 +181,17 @@ public MyPiglinBrute getMyPet() { } public void setPetEquipment(EquipmentSlot slot, ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.values()[slot.get19Slot()], itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.values()[slot.get19Slot()], itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPillager.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPillager.java index ad43e80177..29bc2701aa 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPillager.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPillager.java @@ -20,7 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Util; import de.Keyle.MyPet.api.entity.EntitySize; @@ -28,28 +35,20 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyPillager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; -import net.minecraft.world.item.ItemBanner; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BannerItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.95F) public class EntityMyPillager extends EntityMyPet { @@ -92,21 +91,21 @@ protected String getLivingSound() { * false: no reaction on rightclick */ @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { - if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -129,14 +128,14 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); if (slot == EquipmentSlot.MainHand) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -147,13 +146,13 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } - } else if (itemStack.getItem() instanceof ItemBanner && getOwner().getPlayer().isSneaking() && canEquip()) { + } else if (itemStack.getItem() instanceof BannerItem && getOwner().getPlayer().isSneaking() && canEquip()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(EquipmentSlot.Helmet)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(EquipmentSlot.Helmet, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -179,8 +178,8 @@ protected void defineSynchedData() { public void updateVisuals() { Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> { if (getMyPet().getStatus() == MyPet.PetState.Here) { - setPetEquipment(CraftItemStack.asNMSCopy(getMyPet().getEquipment(EquipmentSlot.MainHand)), EnumItemSlot.a); - setPetEquipment(CraftItemStack.asNMSCopy(getMyPet().getEquipment(EquipmentSlot.Helmet)), EnumItemSlot.f); + setPetEquipment(CraftItemStack.asNMSCopy(getMyPet().getEquipment(EquipmentSlot.MainHand)), net.minecraft.world.entity.EquipmentSlot.MAINHAND); + setPetEquipment(CraftItemStack.asNMSCopy(getMyPet().getEquipment(EquipmentSlot.Helmet)), net.minecraft.world.entity.EquipmentSlot.HEAD); } }, 5L); } @@ -190,21 +189,21 @@ public MyPillager getMyPet() { return (MyPillager) myPet; } - public void setPetEquipment(ItemStack itemStack, EnumItemSlot slot) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(slot, itemStack)))); - if (slot == EnumItemSlot.a) { - getEntityData().set(CROSSBOW_WATCHER, itemStack.getItem() == Items.sS); + public void setPetEquipment(ItemStack itemStack, net.minecraft.world.entity.EquipmentSlot slot) { + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(slot, itemStack)))); + if (slot == net.minecraft.world.entity.EquipmentSlot.MAINHAND) { + getEntityData().set(CROSSBOW_WATCHER, itemStack.getItem() == Items.CROSSBOW); } } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPolarBear.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPolarBear.java index 369bd3648d..3a3563a3e3 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPolarBear.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPolarBear.java @@ -25,15 +25,15 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyPolarBear; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 1.3F, height = 1.4F) public class EntityMyPolarBear extends EntityMyPet { @@ -64,7 +64,7 @@ protected String getLivingSound() { @Override public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java index edf0a60d9f..e33281ba65 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java @@ -59,7 +59,7 @@ protected String getLivingSound() { @Override public void onLivingUpdate() { super.onLivingUpdate(); - if (!isInWater() && this.Q.nextBoolean()) { + if (!isInWater() && this.random.nextBoolean()) { MyPetApi.getPlatformHelper().playParticleEffect(myPet.getLocation().get().add(0, 0.7, 0), ParticleCompat.WATER_SPLASH.get(), 0.2F, 0.2F, 0.2F, 0.5F, 10, 20); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRabbit.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRabbit.java index 57e8460e53..680a138021 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRabbit.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRabbit.java @@ -20,23 +20,19 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; -import java.lang.reflect.Method; - -import org.bukkit.Bukkit; - import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyRabbit; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 0.7F) public class EntityMyRabbit extends EntityMyPet { @@ -48,7 +44,7 @@ public class EntityMyRabbit extends EntityMyPet { public EntityMyRabbit(Level world, MyPet myPet) { super(world, myPet); - this.jumpDelay = (this.Q.nextInt(20) + 10); + this.jumpDelay = (this.random.nextInt(20) + 10); } @Override @@ -72,8 +68,8 @@ public void playPetStepSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } @@ -115,14 +111,14 @@ public void onLivingUpdate() { Bukkit.getConsoleSender().sendMessage("Normal: "+m.getName()+" "+m.getReturnType()); }*/ - //if (this.z && getNavigation().k() != null && jumpDelay-- <= 0) { //TODO Figure out k() and getPath() (Spigot and Paper) - if (this.z && jumpDelay-- <= 0) { - getControllerJump().jump(); - jumpDelay = (this.Q.nextInt(10) + 10); + //if (this.onGround && getNavigation().k() != null && jumpDelay-- <= 0) { //TODO Figure out k() and getPath() (Spigot and Paper) + if (this.onGround && jumpDelay-- <= 0) { + getJumpControl().jump(); + jumpDelay = (this.random.nextInt(10) + 10); if (getTarget() != null) { jumpDelay /= 3; } - this.t.broadcastEntityEffect(this, (byte) 1); + this.level.broadcastEntityEvent(this, (byte) 1); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRavager.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRavager.java index 5e8aa7063b..4c83d61df3 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRavager.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRavager.java @@ -26,14 +26,14 @@ import de.Keyle.MyPet.api.entity.types.MyRavager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.skill.skills.RideImpl; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 1.95F, height = 2.2F) public class EntityMyRavager extends EntityMyPet { @@ -72,7 +72,7 @@ public void playPetStepSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (Configuration.Skilltree.Skill.Ride.RIDE_ITEM.compare(itemStack)) { if (myPet.getSkills().isActive(RideImpl.class) && canMove()) { getOwner().sendMessage("Unfortunately, Ravagers can not be ridden (Minecraft limitation)", 5000); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySalmon.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySalmon.java index 52765f799c..a0c0ed4b56 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySalmon.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySalmon.java @@ -25,10 +25,10 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.world.level.World; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.level.Level; @EntitySize(width = 0.7F, height = 0.4f) public class EntityMySalmon extends EntityMyPet { @@ -57,7 +57,7 @@ protected String getLivingSound() { @Override public void onLivingUpdate() { super.onLivingUpdate(); - if (!isInWater() && this.Q.nextBoolean()) { + if (!isInWater() && this.random.nextBoolean()) { MyPetApi.getPlatformHelper().playParticleEffect(myPet.getLocation().get().add(0, 0.7, 0), ParticleCompat.WATER_SPLASH.get(), 0.2F, 0.2F, 0.2F, 0.5F, 10, 20); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySheep.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySheep.java index 810d0b3c72..3e5a4e0f62 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySheep.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySheep.java @@ -20,33 +20,30 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MySheep; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement.EatGrass; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; -import net.minecraft.world.item.EnumColor; -import net.minecraft.world.item.ItemDye; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.DyeItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; -import org.bukkit.DyeColor; - -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Map; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; @EntitySize(width = 0.7F, height = 1.2349999f) public class EntityMySheep extends EntityMyPet { @@ -54,25 +51,25 @@ public class EntityMySheep extends EntityMyPet { private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMySheep.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor COLOR_WATCHER = SynchedEntityData.defineId(EntityMySheep.class, EntityDataSerializers.BYTE); - private static final Map colorMap = new HashMap<>(); + private static final Map colorMap = new HashMap<>(); static { - colorMap.put(EnumColor.a, Blocks.be); - colorMap.put(EnumColor.b, Blocks.bf); - colorMap.put(EnumColor.c, Blocks.bg); - colorMap.put(EnumColor.d, Blocks.bh); - colorMap.put(EnumColor.e, Blocks.bi); - colorMap.put(EnumColor.f, Blocks.bj); - colorMap.put(EnumColor.g, Blocks.bk); - colorMap.put(EnumColor.h, Blocks.bl); - colorMap.put(EnumColor.i, Blocks.bm); - colorMap.put(EnumColor.j, Blocks.bn); - colorMap.put(EnumColor.k, Blocks.bo); - colorMap.put(EnumColor.l, Blocks.bp); - colorMap.put(EnumColor.m, Blocks.bq); - colorMap.put(EnumColor.n, Blocks.br); - colorMap.put(EnumColor.o, Blocks.bs); - colorMap.put(EnumColor.p, Blocks.bt); + colorMap.put(DyeColor.WHITE, Blocks.WHITE_WOOL); + colorMap.put(DyeColor.ORANGE, Blocks.ORANGE_WOOL); + colorMap.put(DyeColor.MAGENTA, Blocks.MAGENTA_WOOL); + colorMap.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_WOOL); + colorMap.put(DyeColor.YELLOW, Blocks.YELLOW_WOOL); + colorMap.put(DyeColor.LIME, Blocks.LIME_WOOL); + colorMap.put(DyeColor.PINK, Blocks.PINK_WOOL); + colorMap.put(DyeColor.GRAY, Blocks.GRAY_WOOL); + colorMap.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_WOOL); + colorMap.put(DyeColor.CYAN, Blocks.CYAN_WOOL); + colorMap.put(DyeColor.PURPLE, Blocks.PURPLE_WOOL); + colorMap.put(DyeColor.BLUE, Blocks.BLUE_WOOL); + colorMap.put(DyeColor.BROWN, Blocks.BROWN_WOOL); + colorMap.put(DyeColor.GREEN, Blocks.GREEN_WOOL); + colorMap.put(DyeColor.RED, Blocks.RED_WOOL); + colorMap.put(DyeColor.BLACK, Blocks.BLACK_WOOL); } public EntityMySheep(Level world, MyPet myPet) { @@ -95,14 +92,14 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { - if (itemStack.getItem() instanceof ItemDye && ((ItemDye) itemStack.getItem()).d().ordinal() != getMyPet().getColor().ordinal() && !getMyPet().isSheared()) { - getMyPet().setColor(DyeColor.values()[((ItemDye) itemStack.getItem()).d().ordinal()]); + if (itemStack.getItem() instanceof DyeItem && ((DyeItem) itemStack.getItem()).d().ordinal() != getMyPet().getColor().ordinal() && !getMyPet().isSheared()) { //TODO + getMyPet().setColor(org.bukkit.DyeColor.values()[((DyeItem) itemStack.getItem()).d().ordinal()]); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); if (itemStack.getCount() <= 0) { @@ -110,15 +107,15 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Items.pq && Configuration.MyPet.Sheep.CAN_BE_SHEARED && !getMyPet().isSheared()) { + } else if (itemStack.getItem() == Items.SHEARS && Configuration.MyPet.Sheep.CAN_BE_SHEARED && !getMyPet().isSheared()) { getMyPet().setSheared(true); - int woolDropCount = 1 + this.Q.nextInt(3); + int woolDropCount = 1 + this.random.nextInt(3); for (int j = 0; j < woolDropCount; ++j) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), new ItemStack(colorMap.get(EnumColor.values()[getMyPet().getColor().ordinal()]))); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), new ItemStack(colorMap.get(DyeColor.values()[getMyPet().getColor().ordinal()]))); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } makeSound("entity.sheep.shear", 1.0F, 1.0F); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeleton.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeleton.java index 40c96ffd79..43362f48ea 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeleton.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeleton.java @@ -20,7 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Util; import de.Keyle.MyPet.api.entity.EntitySize; @@ -29,24 +36,16 @@ import de.Keyle.MyPet.api.entity.MyPet.PetState; import de.Keyle.MyPet.api.entity.types.MySkeleton; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.9F) public class EntityMySkeleton extends EntityMyPet { @@ -86,21 +85,21 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { - if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -123,13 +122,13 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -172,17 +171,17 @@ public MySkeleton getMyPet() { } public void setPetEquipment(EquipmentSlot slot, ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.values()[slot.get19Slot()], itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.values()[slot.get19Slot()], itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java index f051542346..8bade03ecd 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java @@ -20,42 +20,41 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Optional; +import java.util.UUID; + +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MySkeletonHorse; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.core.BlockPosition; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.core.BlockPos; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.sounds.SoundEffects; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.IJumpable; -import net.minecraft.world.entity.item.EntityItem; +import net.minecraft.world.entity.PlayerRideableJumping; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.SoundEffectType; -import net.minecraft.world.level.block.state.IBlockData; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Optional; -import java.util.UUID; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockState; @EntitySize(width = 1.4F, height = 1.6F) -public class EntityMySkeletonHorse extends EntityMyPet implements IJumpable { +public class EntityMySkeletonHorse extends EntityMyPet implements PlayerRideableJumping { protected static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMySkeletonHorse.class, EntityDataSerializers.BOOLEAN); protected static final EntityDataAccessor SADDLE_CHEST_WATCHER = SynchedEntityData.defineId(EntityMySkeletonHorse.class, EntityDataSerializers.BYTE); - protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMySkeletonHorse.class, EntityDataSerializers.o); + protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMySkeletonHorse.class, EntityDataSerializers.OPTIONAL_UUID); int soundCounter = 0; int rearCounter = -1; @@ -73,7 +72,7 @@ public EntityMySkeletonHorse(Level world, MyPet myPet) { * 128 mouth open */ protected void applyVisual(int value, boolean flag) { - int i = getSynchedEntityData().get(SADDLE_CHEST_WATCHER); + int i = getEntityData().get(SADDLE_CHEST_WATCHER); if (flag) { this.getEntityData().set(SADDLE_CHEST_WATCHER, (byte) (i | value)); } else { @@ -114,12 +113,12 @@ protected String getLivingSound() { @Override public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (itemStack != null && canUseItem()) { - if (itemStack.getItem() == Items.lL && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SADDLE && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking() && canEquip()) { getMyPet().setSaddle(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -128,12 +127,12 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + } else if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { if (getMyPet().hasSaddle()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } makeSound("entity.sheep.shear", 1.0F, 1.0F); @@ -202,25 +201,25 @@ public void onLivingUpdate() { } @Override - public void playStepSound(BlockPosition blockposition, IBlockData blockdata) { + public void playStepSound(BlockPos blockposition, BlockState blockdata) { if (!blockdata.getMaterial().isLiquid()) { - IBlockData blockdataUp = this.t.getType(blockposition.up()); - SoundEffectType soundeffecttype = blockdata.getStepSound(); - if (blockdataUp.getBlock() == Blocks.cK) { - soundeffecttype = blockdata.getStepSound(); + BlockState blockdataUp = this.level.getBlockState(blockposition.up()); + SoundType soundeffecttype = blockdata.getSoundType(); + if (blockdataUp.getBlock() == Blocks.SNOW) { + soundeffecttype = blockdata.getSoundType(); } if (this.isVehicle()) { ++this.soundCounter; if (this.soundCounter > 5 && this.soundCounter % 3 == 0) { - this.playSound(SoundEffects.iB, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + this.playSound(SoundEvents.HORSE_GALLOP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } else if (this.soundCounter <= 5) { - this.playSound(SoundEffects.iH, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + this.playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } } else if (!blockdata.getMaterial().isLiquid()) { this.soundCounter += 1; - playSound(SoundEffects.iH, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } else { - playSound(SoundEffects.iG, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + playSound(SoundEvents.HORSE_STEP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySlime.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySlime.java index e244e3f9c6..76bd6f3f50 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySlime.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySlime.java @@ -25,11 +25,11 @@ import de.Keyle.MyPet.api.entity.types.MySlime; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack.MeleeAttack; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.world.entity.EntityPose; -import net.minecraft.world.level.World; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.entity.Pose; +import net.minecraft.world.level.Level; @EntitySize(width = 0.51F, height = 0.51F) public class EntityMySlime extends EntityMyPet { @@ -40,7 +40,7 @@ public class EntityMySlime extends EntityMyPet { public EntityMySlime(Level world, MyPet myPet) { super(world, myPet); - this.jumpDelay = (this.Q.nextInt(20) + 10); + this.jumpDelay = (this.random.nextInt(20) + 10); } @Override @@ -69,32 +69,32 @@ protected void defineSynchedData() { public void updateVisuals() { int size = Math.max(1, getMyPet().getSize()); getEntityData().set(SIZE_WATCHER, size); - this.updateSize(); + this.refreshDimensions(); if (petPathfinderSelector != null && petPathfinderSelector.hasGoal("MeleeAttack")) { petPathfinderSelector.replaceGoal("MeleeAttack", new MeleeAttack(this, 0.1F, 3 + (getMyPet().getSize() * 0.51), 20)); } } @Override - public net.minecraft.world.entity.EntitySize a(EntityPose entitypose) { + public net.minecraft.world.entity.EntityDimensions getDimensions(Pose entitypose) { EntitySize es = this.getClass().getAnnotation(EntitySize.class); if (es != null) { int size = Math.max(1, getMyPet().getSize()); float width = es.width(); float height = Float.isNaN(es.height()) ? width : es.height(); - return new net.minecraft.world.entity.EntitySize(width * size, height * size, false); + return new net.minecraft.world.entity.EntityDimensions(width * size, height * size, false); } - return super.a(entitypose); + return super.getDimensions(entitypose); } @Override public void onLivingUpdate() { super.onLivingUpdate(); - if (this.z && jumpDelay-- <= 0) { - getControllerJump().jump(); - jumpDelay = (this.Q.nextInt(20) + 50); - makeSound("entity.slime.jump", 1.0F, ((this.Q.nextFloat() - this.Q.nextFloat()) * 0.2F + 1.0F) / 0.8F); + if (this.onGround && jumpDelay-- <= 0) { + getJumpControl().jump(); + jumpDelay = (this.random.nextInt(20) + 50); + makeSound("entity.slime.jump", 1.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySnowman.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySnowman.java index 43ce2bf9c4..e0a3eac4fd 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySnowman.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySnowman.java @@ -20,26 +20,24 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; + import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MySnowman; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; -import java.lang.reflect.InvocationTargetException; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; - @EntitySize(width = 0.7F, height = 1.7F) public class EntityMySnowman extends EntityMyPet { @@ -50,13 +48,13 @@ public EntityMySnowman(Level world, MyPet myPet) { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { - if (itemStack.getItem() == Item.getItemOf(Blocks.cS) && getMyPet().isSheared() && entityhuman.isSneaking()) { + if (itemStack.getItem() == Item.byBlock(Blocks.PUMPKIN) && getMyPet().isSheared() && entityhuman.isShiftKeyDown()) { getMyPet().setSheared(false); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -65,7 +63,7 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Items.pq && !getMyPet().isSheared() && entityhuman.isSneaking()) { + } else if (itemStack.getItem() == Items.SHEARS && !getMyPet().isSheared() && entityhuman.isShiftKeyDown()) { getMyPet().setSheared(true); makeSound("entity.sheep.shear", 1.0F, 1.0F); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySpider.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySpider.java index 834b50aeb3..0ff459517c 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySpider.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySpider.java @@ -23,7 +23,7 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 1.4F, height = 0.9F) public class EntityMySpider extends EntityMyPet { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySquid.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySquid.java index 7ff7fbb66c..f2d260975d 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySquid.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySquid.java @@ -25,7 +25,7 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 0.7F, height = 0.475f) public class EntityMySquid extends EntityMyPet { @@ -52,7 +52,7 @@ protected String getLivingSound() { @Override public void onLivingUpdate() { super.onLivingUpdate(); - if (!isInWater() && this.Q.nextBoolean()) { + if (!isInWater() && this.random.nextBoolean()) { MyPetApi.getPlatformHelper().playParticleEffect(myPet.getLocation().get().add(0, 0.7, 0), ParticleCompat.WATER_SPLASH.get(), 0.2F, 0.2F, 0.2F, 0.5F, 10, 20); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStray.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStray.java index b6e5e27690..ff4601bd3c 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStray.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStray.java @@ -20,7 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Util; import de.Keyle.MyPet.api.entity.EntitySize; @@ -29,24 +36,16 @@ import de.Keyle.MyPet.api.entity.MyPet.PetState; import de.Keyle.MyPet.api.entity.types.MyStray; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyStray extends EntityMyPet { @@ -71,21 +70,21 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { - if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -108,13 +107,13 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -152,17 +151,17 @@ public MyStray getMyPet() { } public void setPetEquipment(EquipmentSlot slot, ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.values()[slot.get19Slot()], itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.values()[slot.get19Slot()], itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStrider.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStrider.java index d2593590ac..61a162fedb 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStrider.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStrider.java @@ -20,26 +20,25 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; + +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyStrider; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 0.9F, height = 1.7F) public class EntityMyStrider extends EntityMyPet { @@ -69,13 +68,13 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(final EntityHuman entityhuman, InteractionHand enumhand, final ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(final Player entityhuman, InteractionHand enumhand, final ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { - if (itemStack.getItem() == Items.lL && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking()) { + if (itemStack.getItem() == Items.SADDLE && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking()) { getMyPet().setSaddle(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -84,11 +83,11 @@ public InteractionResult handlePlayerInteraction(final EntityHuman entityhuman, } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Items.pq && getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + } else if (itemStack.getItem() == Items.SHEARS && getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking()) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); makeSound("entity.sheep.shear", 1.0F, 1.0F); getMyPet().setSaddle(null); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTraderLlama.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTraderLlama.java index 333a913596..c0710b1144 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTraderLlama.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTraderLlama.java @@ -20,39 +20,38 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Optional; +import java.util.UUID; + +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyTraderLlama; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.tags.TagsItem; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.BlockCarpet; import net.minecraft.world.level.block.Blocks; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Optional; -import java.util.UUID; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.block.WoolCarpetBlock; @EntitySize(width = 0.9F, height = 1.87F) public class EntityMyTraderLlama extends EntityMyPet { private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyTraderLlama.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor SADDLE_CHEST_WATCHER = SynchedEntityData.defineId(EntityMyTraderLlama.class, EntityDataSerializers.BYTE); - private static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyTraderLlama.class, EntityDataSerializers.o); + private static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyTraderLlama.class, EntityDataSerializers.OPTIONAL_UUID); private static final EntityDataAccessor CHEST_WATCHER = SynchedEntityData.defineId(EntityMyTraderLlama.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor STRENGTH_WATCHER = SynchedEntityData.defineId(EntityMyTraderLlama.class, EntityDataSerializers.INT); private static final EntityDataAccessor COLOR_WATCHER = SynchedEntityData.defineId(EntityMyTraderLlama.class, EntityDataSerializers.INT); @@ -79,8 +78,8 @@ protected String getLivingSound() { @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } @@ -94,7 +93,7 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Blocks.bX.getItem() && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && !getMyPet().isBaby() && canEquip()) { + } else if (itemStack.getItem() == Blocks.CHEST.getItem() && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && !getMyPet().isBaby() && canEquip()) { getMyPet().setChest(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -103,18 +102,18 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + } else if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { if (getMyPet().hasChest()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getChest())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getChest())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } if (getMyPet().hasDecor()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getDecor())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getDecor())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } makeSound("entity.sheep.shear", 1.0F, 1.0F); @@ -168,8 +167,8 @@ public void updateVisuals() { this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); if (getMyPet().hasDecor()) { ItemStack is = CraftItemStack.asNMSCopy(getMyPet().getDecor()); - Block block = Block.asBlock(is.getItem()); - int color = block instanceof BlockCarpet ? ((BlockCarpet) block).c().getColorIndex() : 0; + Block block = Block.byItem(is.getItem()); + int color = block instanceof WoolCarpetBlock ? ((WoolCarpetBlock) block).c().getColorIndex() : 0; this.getEntityData().set(COLOR_WATCHER, color); } else { this.getEntityData().set(COLOR_WATCHER, -1); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTropicalFish.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTropicalFish.java index 024cc72689..ae0ec9c03c 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTropicalFish.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTropicalFish.java @@ -26,10 +26,10 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyTropicalFish; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.world.level.World; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.level.Level; @EntitySize(width = 0.5F, height = 0.4f) public class EntityMyTropicalFish extends EntityMyPet { @@ -59,7 +59,7 @@ protected String getLivingSound() { @Override public void onLivingUpdate() { super.onLivingUpdate(); - if (!isInWater() && this.Q.nextBoolean()) { + if (!isInWater() && this.random.nextBoolean()) { MyPetApi.getPlatformHelper().playParticleEffect(myPet.getLocation().get().add(0, 0.7, 0), ParticleCompat.WATER_SPLASH.get(), 0.2F, 0.2F, 0.2F, 0.5F, 10, 20); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTurtle.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTurtle.java index b37aabb3a4..98b9a00499 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTurtle.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTurtle.java @@ -25,24 +25,24 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyTurtle; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.core.BlockPosition; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.core.BlockPos; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 1.2F, height = 0.4F) public class EntityMyTurtle extends EntityMyPet { private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.BOOLEAN); - private static final EntityDataAccessor HOME_WATCHER = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.l); + private static final EntityDataAccessor HOME_WATCHER = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.BLOCK_POS); private static final EntityDataAccessor HAS_EGG_WATCHER = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor UNUSED_WATCHER_1 = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.BOOLEAN); - private static final EntityDataAccessor TRAVEL_POS_WATCHER = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.l); + private static final EntityDataAccessor TRAVEL_POS_WATCHER = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.BLOCK_POS); private static final EntityDataAccessor UNUSED_WATCHER_2 = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor UNUSED_WATCHER_3 = SynchedEntityData.defineId(EntityMyTurtle.class, EntityDataSerializers.BOOLEAN); @@ -66,8 +66,8 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } @@ -90,9 +90,9 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera protected void defineSynchedData() { super.defineSynchedData(); getEntityData().define(AGE_WATCHER, false); - getEntityData().define(HOME_WATCHER, BlockPosition.b); + getEntityData().define(HOME_WATCHER, BlockPos.ZERO); getEntityData().define(HAS_EGG_WATCHER, false); - getEntityData().define(TRAVEL_POS_WATCHER, BlockPosition.b); + getEntityData().define(TRAVEL_POS_WATCHER, BlockPos.ZERO); getEntityData().define(UNUSED_WATCHER_2, false); getEntityData().define(UNUSED_WATCHER_3, false); getEntityData().define(UNUSED_WATCHER_1, false); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVex.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVex.java index 20d74c6d32..1788bcfc09 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVex.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVex.java @@ -20,7 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.Util; @@ -31,27 +38,19 @@ import de.Keyle.MyPet.api.skill.skills.Behavior; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.skill.skills.BehaviorImpl; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 0.4F, height = 0.8F) public class EntityMyVex extends EntityMyPet { @@ -95,21 +94,21 @@ protected String getLivingSound() { * false: no reaction on rightclick */ @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { - if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -132,14 +131,14 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); if (slot == EquipmentSlot.MainHand) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -178,18 +177,18 @@ public MyVex getMyPet() { } public void setPetEquipment(ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.a, itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.MAINHAND, itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVillager.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVillager.java index 3f1fca9254..b4adcc30a0 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVillager.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVillager.java @@ -20,32 +20,34 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import com.comphenix.protocol.wrappers.MinecraftKey; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyVillager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.core.IRegistry; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.core.Registry; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.resources.MinecraftKey; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.npc.VillagerData; import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.entity.npc.VillagerType; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyVillager extends EntityMyPet { private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyVillager.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor UNUSED_WATCHER = SynchedEntityData.defineId(EntityMyVillager.class, EntityDataSerializers.INT); - private static final EntityDataAccessor PROFESSION_WATCHER = SynchedEntityData.defineId(EntityMyVillager.class, EntityDataSerializers.q); + private static final EntityDataAccessor PROFESSION_WATCHER = SynchedEntityData.defineId(EntityMyVillager.class, EntityDataSerializers.VILLAGER_DATA); public EntityMyVillager(Level world, MyPet myPet) { super(world, myPet); @@ -67,8 +69,8 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } @@ -94,15 +96,15 @@ protected void defineSynchedData() { if (MyPetApi.getCompatUtil().isCompatible("1.14.1")) { getEntityData().define(UNUSED_WATCHER, 0); } - getEntityData().define(PROFESSION_WATCHER, new VillagerData(VillagerType.c, VillagerProfession.a, 1)); + getEntityData().define(PROFESSION_WATCHER, new VillagerData(VillagerType.PLAINS, VillagerProfession.NONE, 1)); } @Override public void updateVisuals() { this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); String professionKey = MyVillager.Profession.values()[getMyPet().getProfession()].getKey(); - VillagerProfession profession = IRegistry.ap.get(new MinecraftKey(professionKey)); - VillagerType type = IRegistry.ao.get(new MinecraftKey(getMyPet().getType().getKey())); + VillagerProfession profession = Registry.VILLAGER_PROFESSION.get(new ResourceLocation(professionKey)); + VillagerType type = Registry.VILLAGER_TYPE.get(new ResourceLocation(getMyPet().getType().getKey())); //TODO this.getEntityData().set(PROFESSION_WATCHER, new VillagerData(type, profession, getMyPet().getVillagerLevel())); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVindicator.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVindicator.java index c9e18ca129..e663fe8ee6 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVindicator.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVindicator.java @@ -20,7 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Util; import de.Keyle.MyPet.api.entity.EntitySize; @@ -29,25 +36,19 @@ import de.Keyle.MyPet.api.entity.types.MyVindicator; import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.95F) public class EntityMyVindicator extends EntityMyPet { @@ -89,21 +90,21 @@ protected String getLivingSound() { * false: no reaction on rightclick */ @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { - if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -126,14 +127,14 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); if (slot == EquipmentSlot.MainHand) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -170,17 +171,17 @@ public MyVindicator getMyPet() { } public void setPetEquipment(ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.a, itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.MAINHAND, itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWanderingTrader.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWanderingTrader.java index 8597be5178..0ef6bfacfd 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWanderingTrader.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWanderingTrader.java @@ -25,10 +25,10 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyWanderingTrader; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.world.level.World; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyWanderingTrader extends EntityMyPet { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitch.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitch.java index 568c71ae39..13e70778ea 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitch.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitch.java @@ -23,7 +23,7 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.62F) public class EntityMyWitch extends EntityMyPet { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWither.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWither.java index beb3be4997..ea7e493012 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWither.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWither.java @@ -25,10 +25,10 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyWither; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.world.level.World; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.level.Level; @EntitySize(width = 1.9F, height = 3.5F) public class EntityMyWither extends EntityMyPet { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitherSkeleton.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitherSkeleton.java index 80caa8defa..87440cca58 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitherSkeleton.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitherSkeleton.java @@ -20,7 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Util; import de.Keyle.MyPet.api.entity.EntitySize; @@ -29,24 +36,16 @@ import de.Keyle.MyPet.api.entity.MyPet.PetState; import de.Keyle.MyPet.api.entity.types.MyWitherSkeleton; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyWitherSkeleton extends EntityMyPet { @@ -71,21 +70,21 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { - if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -108,13 +107,13 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -152,17 +151,17 @@ public MyWitherSkeleton getMyPet() { } public void setPetEquipment(EquipmentSlot slot, ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.values()[slot.get19Slot()], itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.values()[slot.get19Slot()], itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWolf.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWolf.java index 2f0a98cf57..d706362ec9 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWolf.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWolf.java @@ -20,36 +20,37 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.util.Optional; +import java.util.UUID; + +import org.bukkit.DyeColor; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyWolf; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.core.particles.Particles; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.util.MathHelper; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.ai.attributes.GenericAttributes; -import net.minecraft.world.entity.player.EntityHuman; -import net.minecraft.world.item.ItemDye; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.DyeItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.DyeColor; - -import java.util.Optional; -import java.util.UUID; +import net.minecraft.world.level.Level; +import net.royawesome.jlibnoise.MathHelper; @EntitySize(width = 0.6F, height = 0.64f) public class EntityMyWolf extends EntityMyPet { private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyWolf.class, EntityDataSerializers.BOOLEAN); protected static final EntityDataAccessor SIT_WATCHER = SynchedEntityData.defineId(EntityMyWolf.class, EntityDataSerializers.BYTE); - protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyWolf.class, EntityDataSerializers.o); - private static final EntityDataAccessor TAIL_WATCHER = SynchedEntityData.defineId(EntityMyWolf.class, EntityDataSerializers.c); + protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyWolf.class, EntityDataSerializers.OPTIONAL_UUID); + private static final EntityDataAccessor TAIL_WATCHER = SynchedEntityData.defineId(EntityMyWolf.class, EntityDataSerializers.FLOAT); private static final EntityDataAccessor UNUSED_WATCHER = SynchedEntityData.defineId(EntityMyWolf.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor COLLAR_COLOR_WATCHER = SynchedEntityData.defineId(EntityMyWolf.class, EntityDataSerializers.INT); @@ -62,7 +63,7 @@ public EntityMyWolf(Level world, MyPet myPet) { } public void applySitting(boolean sitting) { - int i = this.getSynchedEntityData().get(SIT_WATCHER); + int i = this.getEntityData().get(SIT_WATCHER); if (sitting) { this.getEntityData().set(SIT_WATCHER, (byte) (i | 0x1)); } else { @@ -82,21 +83,21 @@ protected String getHurtSound() { @Override protected String getLivingSound() { - return this.Q.nextInt(5) == 0 ? (getHealth() * 100 / getMaxHealth() <= 25 ? "entity.wolf.whine" : "entity.wolf.pant") : "entity.wolf.ambient"; + return this.random.nextInt(5) == 0 ? (getHealth() * 100 / getMaxHealth() <= 25 ? "entity.wolf.whine" : "entity.wolf.pant") : "entity.wolf.ambient"; } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman)) { - if (itemStack != null && itemStack.getItem() != Items.a) { + if (itemStack != null && itemStack.getItem() != Items.AIR) { if (canUseItem()) { - if (itemStack.getItem() instanceof ItemDye && ((ItemDye) itemStack.getItem()).d().ordinal() != getMyPet().getCollarColor().ordinal()) { + if (itemStack.getItem() instanceof DyeItem && ((DyeItem) itemStack.getItem()).d().ordinal() != getMyPet().getCollarColor().ordinal()) { if (getOwner().getPlayer().isSneaking()) { - getMyPet().setCollarColor(DyeColor.values()[((ItemDye) itemStack.getItem()).d().ordinal()]); + getMyPet().setCollarColor(DyeColor.values()[((DyeItem) itemStack.getItem()).d().ordinal()]); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); if (itemStack.getCount() <= 0) { @@ -138,21 +139,21 @@ protected void defineSynchedData() { @Override protected void initAttributes() { - getAttributeInstance(GenericAttributes.a).setValue(20.0D); + getAttribute(Attributes.MAX_HEALTH).setBaseValue(20.0D); } @Override public void updateVisuals() { this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); - byte b0 = this.getSynchedEntityData().get(SIT_WATCHER); + byte b0 = this.getEntityData().get(SIT_WATCHER); if (getMyPet().isTamed()) { this.getEntityData().set(SIT_WATCHER, (byte) (b0 | 0x4)); } else { this.getEntityData().set(SIT_WATCHER, (byte) (b0 & 0xFFFFFFFB)); } - b0 = this.getSynchedEntityData().get(SIT_WATCHER); + b0 = this.getEntityData().get(SIT_WATCHER); if (getMyPet().isAngry()) { this.getEntityData().set(SIT_WATCHER, (byte) (b0 | 0x2)); } else { @@ -165,10 +166,10 @@ public void updateVisuals() { @Override public void onLivingUpdate() { super.onLivingUpdate(); - if (this.isWet && !this.shaking && this.z) { + if (this.isWet && !this.shaking && this.onGround) { this.shaking = true; this.shakeCounter = 0.0F; - this.t.broadcastEntityEffect(this, (byte) 8); + this.level.broadcastEntityEvent(this, (byte) 8); } if (isInWater()) // -> is in water @@ -178,7 +179,7 @@ public void onLivingUpdate() { this.shakeCounter = 0.0F; } else if ((this.isWet || this.shaking) && this.shaking) { if (this.shakeCounter == 0.0F) { - makeSound("entity.wolf.shake", 1.0F, (this.Q.nextFloat() - this.Q.nextFloat()) * 0.2F + 1.0F); + makeSound("entity.wolf.shake", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); } this.shakeCounter += 0.05F; @@ -191,16 +192,16 @@ public void onLivingUpdate() { if (this.shakeCounter > 0.4F) { int i = (int) (MathHelper.sin((this.shakeCounter - 0.4F) * 3.141593F) * 7.0F); for (; i >= 0; i--) { - float offsetX = (this.Q.nextFloat() * 2.0F - 1.0F) * this.getWidth() * 0.5F; - float offsetZ = (this.Q.nextFloat() * 2.0F - 1.0F) * this.getWidth() * 0.5F; + float offsetX = (this.random.nextFloat() * 2.0F - 1.0F) * this.getBbWidth() * 0.5F; + float offsetZ = (this.random.nextFloat() * 2.0F - 1.0F) * this.getBbWidth() * 0.5F; - this.t.addParticle(Particles.ac, this.locX() + offsetX, this.locY() + 0.8F, this.locZ() + offsetZ, this.getMot().getX(), this.getMot().getY(), this.getMot().getZ()); + this.level.addParticle(ParticleTypes.SPLASH, this.getX() + offsetX, this.getY() + 0.8F, this.getZ() + offsetZ, this.getDeltaMovement().x(), this.getDeltaMovement().y(), this.getDeltaMovement().z()); } } } float tailHeight = 30F * (getHealth() / getMaxHealth()); - if (this.getSynchedEntityData().get(TAIL_WATCHER) != tailHeight) { + if (this.getEntityData().get(TAIL_WATCHER) != tailHeight) { this.getEntityData().set(TAIL_WATCHER, tailHeight); // update tail height } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZoglin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZoglin.java index 81d1f9edaf..4cad6d7dd5 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZoglin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZoglin.java @@ -25,14 +25,14 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyZoglin; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 1.3965F, height = 1.4F) public class EntityMyZoglin extends EntityMyPet { @@ -59,8 +59,8 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(final EntityHuman entityhuman, InteractionHand enumhand, final ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(final Player entityhuman, InteractionHand enumhand, final ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombie.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombie.java index 5ca183e35d..53156a19f7 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombie.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombie.java @@ -20,7 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.Util; @@ -29,27 +36,19 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyZombie; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyZombie extends EntityMyPet { @@ -94,21 +93,21 @@ protected String getLivingSound() { * false: no reaction on rightclick */ @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { - if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -131,13 +130,13 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -193,17 +192,17 @@ public MyZombie getMyPet() { } public void setPetEquipment(EquipmentSlot slot, ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.values()[slot.get19Slot()], itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.values()[slot.get19Slot()], itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieHorse.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieHorse.java index f985044e6a..48d4937fbd 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieHorse.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieHorse.java @@ -20,42 +20,41 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Optional; +import java.util.UUID; + +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyZombieHorse; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.core.BlockPosition; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.core.BlockPos; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.sounds.SoundEffects; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.IJumpable; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.PlayerRideableJumping; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.SoundEffectType; -import net.minecraft.world.level.block.state.IBlockData; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Optional; -import java.util.UUID; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockState; @EntitySize(width = 1.4F, height = 1.6F) -public class EntityMyZombieHorse extends EntityMyPet implements IJumpable { +public class EntityMyZombieHorse extends EntityMyPet implements PlayerRideableJumping { protected static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyZombieHorse.class, EntityDataSerializers.BOOLEAN); protected static final EntityDataAccessor SADDLE_CHEST_WATCHER = SynchedEntityData.defineId(EntityMyZombieHorse.class, EntityDataSerializers.BYTE); - protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyZombieHorse.class, EntityDataSerializers.o); + protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyZombieHorse.class, EntityDataSerializers.OPTIONAL_UUID); int soundCounter = 0; int rearCounter = -1; @@ -73,7 +72,7 @@ public EntityMyZombieHorse(Level world, MyPet myPet) { * 128 mouth open */ protected void applyVisual(int value, boolean flag) { - int i = this.getSynchedEntityData().get(SADDLE_CHEST_WATCHER); + int i = this.getEntityData().get(SADDLE_CHEST_WATCHER); if (flag) { this.getEntityData().set(SADDLE_CHEST_WATCHER, (byte) (i | value)); } else { @@ -113,13 +112,13 @@ protected String getLivingSound() { @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (itemStack != null && canUseItem()) { - if (itemStack.getItem() == Items.lL && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SADDLE && !getMyPet().hasSaddle() && getOwner().getPlayer().isSneaking() && canEquip()) { getMyPet().setSaddle(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -128,12 +127,12 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + } else if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { if (getMyPet().hasSaddle()) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), CraftItemStack.asNMSCopy(getMyPet().getSaddle())); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } makeSound("entity.sheep.shear", 1.0F, 1.0F); @@ -202,25 +201,25 @@ public void onLivingUpdate() { } @Override - public void playStepSound(BlockPosition blockposition, IBlockData blockdata) { + public void playStepSound(BlockPos blockposition, BlockState blockdata) { if (!blockdata.getMaterial().isLiquid()) { - IBlockData blockdataUp = this.t.getType(blockposition.up()); - SoundEffectType soundeffecttype = blockdata.getStepSound(); - if (blockdataUp.getBlock() == Blocks.cK) { - soundeffecttype = blockdata.getStepSound(); + BlockState blockdataUp = this.level.getBlockState(blockposition.up()); + SoundType soundeffecttype = blockdata.getSoundType(); + if (blockdataUp.getBlock() == Blocks.SNOW) { + soundeffecttype = blockdata.getSoundType(); } if (this.isVehicle()) { ++this.soundCounter; if (this.soundCounter > 5 && this.soundCounter % 3 == 0) { - this.playSound(SoundEffects.iB, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + this.playSound(SoundEvents.HORSE_GALLOP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } else if (this.soundCounter <= 5) { - this.playSound(SoundEffects.iH, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + this.playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } } else if (!blockdata.getMaterial().isLiquid()) { this.soundCounter += 1; - playSound(SoundEffects.iH, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } else { - playSound(SoundEffects.iG, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + playSound(SoundEvents.HORSE_STEP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieVillager.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieVillager.java index c9d063b225..697f3e41b8 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieVillager.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieVillager.java @@ -20,7 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.Util; @@ -30,32 +37,24 @@ import de.Keyle.MyPet.api.entity.types.MyVillager; import de.Keyle.MyPet.api.entity.types.MyZombieVillager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.core.IRegistry; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.core.Registry; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.resources.MinecraftKey; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.npc.VillagerData; import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.entity.npc.VillagerType; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyZombieVillager extends EntityMyPet { @@ -64,7 +63,7 @@ public class EntityMyZombieVillager extends EntityMyPet { private static final EntityDataAccessor TYPE_WATCHER = SynchedEntityData.defineId(EntityMyZombieVillager.class, EntityDataSerializers.INT); private static final EntityDataAccessor DROWN_CONVERTING = SynchedEntityData.defineId(EntityMyZombieVillager.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor SHIVER_WATCHER = SynchedEntityData.defineId(EntityMyZombieVillager.class, EntityDataSerializers.BOOLEAN); - private static final EntityDataAccessor PROFESSION_WATCHER = SynchedEntityData.defineId(EntityMyZombieVillager.class, EntityDataSerializers.q); + private static final EntityDataAccessor PROFESSION_WATCHER = SynchedEntityData.defineId(EntityMyZombieVillager.class, EntityDataSerializers.VILLAGER_DATA); public EntityMyZombieVillager(Level world, MyPet myPet) { super(world, myPet); @@ -101,21 +100,21 @@ protected String getLivingSound() { * false: no reaction on rightclick */ @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { - if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -138,13 +137,13 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -176,15 +175,15 @@ protected void defineSynchedData() { getEntityData().define(DROWN_CONVERTING, false); getEntityData().define(SHIVER_WATCHER, false); - getEntityData().define(PROFESSION_WATCHER, new VillagerData(VillagerType.c, VillagerProfession.a, 1)); + getEntityData().define(PROFESSION_WATCHER, new VillagerData(VillagerType.PLAINS, VillagerProfession.NONE, 1)); } @Override public void updateVisuals() { getEntityData().set(BABY_WATCHER, getMyPet().isBaby()); String professionKey = MyVillager.Profession.values()[getMyPet().getProfession()].getKey(); - VillagerProfession profession = IRegistry.ap.get(new MinecraftKey(professionKey)); - VillagerType type = IRegistry.ao.get(new MinecraftKey(getMyPet().getType().getKey())); + VillagerProfession profession = Registry.VILLAGER_PROFESSION.get(new ResourceLocation(professionKey)); + VillagerType type = Registry.VILLAGER_TYPE.get(new ResourceLocation(getMyPet().getType().getKey())); //TODO getEntityData().set(PROFESSION_WATCHER, new VillagerData(type, profession, getMyPet().getTradingLevel())); Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> { @@ -207,17 +206,17 @@ public MyZombieVillager getMyPet() { } public void setPetEquipment(EquipmentSlot slot, ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.values()[slot.get19Slot()], itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.values()[slot.get19Slot()], itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombifiedPiglin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombifiedPiglin.java index ec9edeb925..003e8221e1 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombifiedPiglin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombifiedPiglin.java @@ -20,7 +20,14 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; + import com.mojang.datafixers.util.Pair; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.Util; @@ -30,27 +37,19 @@ import de.Keyle.MyPet.api.entity.MyPet.PetState; import de.Keyle.MyPet.api.entity.types.MyZombifiedPiglin; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; -import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.EnumItemSlot; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyZombifiedPiglin extends EntityMyPet { @@ -77,21 +76,21 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack) == InteractionResult.CONSUME) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { - if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); hadEquipment = true; } @@ -114,13 +113,13 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera } return InteractionResult.CONSUME; } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { - EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { - EntityItem entityitem = new EntityItem(this.t, this.locX(), this.locY() + 1, this.locZ(), itemInSlot); - entityitem.ap = 10; - entityitem.setMot(entityitem.getMot().add(0, this.Q.nextFloat() * 0.05F, 0)); - this.t.addEntity(entityitem); + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); + entityitem.pickupDelay = 10; + entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); + this.level.addFreshEntity(entityitem); } getMyPet().setEquipment(slot, CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { @@ -178,17 +177,17 @@ public MyZombifiedPiglin getMyPet() { } public void setPetEquipment(EquipmentSlot slot, ItemStack itemStack) { - ((WorldServer) this.t).getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutEntityEquipment(getId(), Arrays.asList(new Pair<>(EnumItemSlot.values()[slot.get19Slot()], itemStack)))); + ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEquipmentPacket(getId(), Arrays.asList(new Pair<>(net.minecraft.world.entity.EquipmentSlot.values()[slot.get19Slot()], itemStack)))); } @Override - public ItemStack getEquipment(EnumItemSlot vanillaSlot) { + public ItemStack getItemBySlot(net.minecraft.world.entity.EquipmentSlot vanillaSlot) { if (Util.findClassInStackTrace(Thread.currentThread().getStackTrace(), "net.minecraft.server.level.EntityTrackerEntry", 2)) { - EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getSlotFlag()); + EquipmentSlot slot = EquipmentSlot.getSlotById(vanillaSlot.getFilterFlag()); if (getMyPet().getEquipment(slot) != null) { return CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); } } - return super.getEquipment(vanillaSlot); + return super.getItemBySlot(vanillaSlot); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetArrow.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetArrow.java index 3b1f816970..00c54e15b2 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetArrow.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetArrow.java @@ -48,13 +48,13 @@ public EntityMyPet getShooter() { @Override public CraftMyPetArrow getBukkitEntity() { if (this.bukkitEntity == null) { - this.bukkitEntity = new CraftMyPetArrow(this.t.getCraftServer(), this); + this.bukkitEntity = new CraftMyPetArrow(this.level.getCraftServer(), this); } return this.bukkitEntity; } @Override - public void saveData(NBTTagCompound nbttagcompound) { + public void addAdditionalSaveData(CompoundTag nbttagcompound) { } @@ -64,7 +64,7 @@ protected ItemStack getItemStack() { } @Override - public void loadData(NBTTagCompound nbttagcompound) { + public void readAdditionalSaveData(CompoundTag nbttagcompound) { } @Override @@ -72,7 +72,7 @@ public void tick() { try { super.tick(); if (this.b) { - die(); + discard(); } } catch (Exception e) { e.printStackTrace(); @@ -80,7 +80,7 @@ public void tick() { } @Override - public boolean damageEntity(DamageSource damagesource, float f) { + public boolean hurt(DamageSource damagesource, float f) { return false; } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetDragonFireball.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetDragonFireball.java index a2797bd888..fa7a7f4a5c 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetDragonFireball.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetDragonFireball.java @@ -24,14 +24,13 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetDragonFireball; -import io.lumine.xikage.mythicmobs.utils.shadows.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityLiving; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.projectile.DragonFireball; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.MovingObjectPosition; -import net.minecraft.world.phys.MovingObjectPositionEntity; +import net.minecraft.world.phys.HitResult; import net.royawesome.jlibnoise.MathHelper; @Compat("v1_17_R1") @@ -56,11 +55,11 @@ public void setDamage(float damage) { @Override public void setDirection(double d0, double d1, double d2) { - d0 += this.Q.nextGaussian() * 0.2D; - d1 += this.Q.nextGaussian() * 0.2D; - d2 += this.Q.nextGaussian() * 0.2D; + d0 += this.random.nextGaussian() * 0.2D; + d1 += this.random.nextGaussian() * 0.2D; + d2 += this.random.nextGaussian() * 0.2D; double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); - this.b = (d0 / d3 * 0.1D); + this.b = (d0 / d3 * 0.1D); //TODO this.c = (d1 / d3 * 0.1D); this.d = (d2 / d3 * 0.1D); } @@ -68,29 +67,29 @@ public void setDirection(double d0, double d1, double d2) { @Override public CraftMyPetDragonFireball getBukkitEntity() { if (this.bukkitEntity == null) { - this.bukkitEntity = new CraftMyPetDragonFireball(this.t.getCraftServer(), this); + this.bukkitEntity = new CraftMyPetDragonFireball(this.level.getCraftServer(), this); } return this.bukkitEntity; } @Override - public void saveData(NBTTagCompound nbtTagCompound) { + public void addAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - public void loadData(NBTTagCompound nbtTagCompound) { + public void readAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - protected void a(MovingObjectPosition movingObjectPosition) { - if (movingObjectPosition.getType() == MovingObjectPosition.EnumMovingObjectType.c) { - Entity entity = ((MovingObjectPositionEntity) movingObjectPosition).getEntity(); - if (entity instanceof EntityLiving) { - entity.damageEntity(DamageSource.projectile(this, getShooter()), damage); + protected void onHit(HitResult movingObjectPosition) { + if (movingObjectPosition.getType() == HitResult.Type.ENTITY) { + Entity entity = ((HitResult) movingObjectPosition).getEntity(); //TODO + if (entity instanceof LivingEntity) { + entity.hurt(DamageSource.thrown(this, getShooter()), damage); } } - die(); + discard(); } @Override @@ -98,7 +97,7 @@ public void tick() { try { super.tick(); if (deathCounter-- <= 0) { - die(); + discard(); } } catch (Exception e) { e.printStackTrace(); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEgg.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEgg.java index 89f53cf651..52f09ed867 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEgg.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEgg.java @@ -24,21 +24,21 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetEgg; -import net.minecraft.core.particles.ParticleParamItem; -import net.minecraft.core.particles.Particles; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.core.particles.ItemParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.nbt.CompoundTag; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.projectile.EntityEgg; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.projectile.ThrownEgg; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; -import net.minecraft.world.phys.MovingObjectPosition; -import net.minecraft.world.phys.MovingObjectPositionEntity; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; @Compat("v1_17_R1") -public class MyPetEgg extends EntityEgg implements EntityMyPetProjectile { +public class MyPetEgg extends ThrownEgg implements EntityMyPetProjectile { protected float damage = 0; protected CraftMyPetEgg bukkitEntity = null; @@ -59,35 +59,35 @@ public void setDamage(float damage) { @Override public CraftMyPetEgg getBukkitEntity() { if (this.bukkitEntity == null) { - this.bukkitEntity = new CraftMyPetEgg(this.t.getCraftServer(), this); + this.bukkitEntity = new CraftMyPetEgg(this.level.getCraftServer(), this); } return this.bukkitEntity; } @Override - public void saveData(NBTTagCompound nbtTagCompound) { + public void addAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - public void loadData(NBTTagCompound nbtTagCompound) { + public void readAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - protected void a(MovingObjectPosition movingObjectPosition) { - if (movingObjectPosition.getType() == MovingObjectPosition.EnumMovingObjectType.c) { - Entity entity = ((MovingObjectPositionEntity) movingObjectPosition).getEntity(); - if (entity instanceof EntityLiving) { - entity.damageEntity(DamageSource.projectile(this, getShooter()), damage); + protected void onHit(HitResult movingObjectPosition) { + if (movingObjectPosition.getType() == HitResult.Type.ENTITY) { + Entity entity = ((EntityHitResult) movingObjectPosition).getEntity(); + if (entity instanceof LivingEntity) { + entity.hurt(DamageSource.thrown(this, getShooter()), damage); } } for (int i = 0; i < 8; ++i) { - this.t.addParticle(new ParticleParamItem(Particles.K, new ItemStack(Items.oo)), this.locX(), this.locY(), this.locZ(), ((double) this.Q.nextFloat() - 0.5D) * 0.08D, ((double) this.Q.nextFloat() - 0.5D) * 0.08D, ((double) this.Q.nextFloat() - 0.5D) * 0.08D); + this.level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, new ItemStack(Items.LEATHER_BOOTS)), this.getX(), this.getY(), this.getZ(), ((double) this.random.nextFloat() - 0.5D) * 0.08D, ((double) this.random.nextFloat() - 0.5D) * 0.08D, ((double) this.random.nextFloat() - 0.5D) * 0.08D); } - die(); + discard(); } @Override - public boolean damageEntity(DamageSource damagesource, float f) { + public boolean hurt(DamageSource damagesource, float f) { return false; } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEnderPearl.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEnderPearl.java index 6d73f66bf8..fd60c41509 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEnderPearl.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetEnderPearl.java @@ -24,18 +24,18 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetEnderPearl; -import net.minecraft.core.particles.Particles; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.nbt.CompoundTag; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.projectile.EntityEnderPearl; -import net.minecraft.world.level.World; -import net.minecraft.world.phys.MovingObjectPosition; -import net.minecraft.world.phys.MovingObjectPositionEntity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.projectile.ThrownEnderpearl; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; @Compat("v1_17_R1") -public class MyPetEnderPearl extends EntityEnderPearl implements EntityMyPetProjectile { +public class MyPetEnderPearl extends ThrownEnderpearl implements EntityMyPetProjectile { protected float damage = 0; protected CraftMyPetEnderPearl bukkitEntity = null; @@ -56,35 +56,35 @@ public void setDamage(float damage) { @Override public CraftMyPetEnderPearl getBukkitEntity() { if (this.bukkitEntity == null) { - this.bukkitEntity = new CraftMyPetEnderPearl(this.t.getCraftServer(), this); + this.bukkitEntity = new CraftMyPetEnderPearl(this.level.getCraftServer(), this); } return this.bukkitEntity; } @Override - public void saveData(NBTTagCompound nbtTagCompound) { + public void addAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - public void loadData(NBTTagCompound nbtTagCompound) { + public void readAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - protected void a(MovingObjectPosition movingObjectPosition) { - if (movingObjectPosition.getType() == MovingObjectPosition.EnumMovingObjectType.c) { - Entity entity = ((MovingObjectPositionEntity) movingObjectPosition).getEntity(); - if (entity instanceof EntityLiving) { - entity.damageEntity(DamageSource.projectile(this, getShooter()), damage); + protected void onHit(HitResult movingObjectPosition) { + if (movingObjectPosition.getType() == HitResult.Type.ENTITY) { + Entity entity = ((EntityHitResult) movingObjectPosition).getEntity(); + if (entity instanceof LivingEntity) { + entity.hurt(DamageSource.thrown(this, getShooter()), damage); } } for (int i = 0; i < 32; ++i) { - this.t.addParticle(Particles.T, this.locX(), this.locY() + this.Q.nextDouble() * 2.0D, this.locZ(), this.Q.nextGaussian(), 0.0D, this.Q.nextGaussian()); + this.level.addParticle(ParticleTypes.PORTAL, this.getX(), this.getY() + this.random.nextDouble() * 2.0D, this.getZ(), this.random.nextGaussian(), 0.0D, this.random.nextGaussian()); } - die(); + discard(); } @Override - public boolean damageEntity(DamageSource damagesource, float f) { + public boolean hurt(DamageSource damagesource, float f) { return false; } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLargeFireball.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLargeFireball.java index b41b2c24e1..19f1717dad 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLargeFireball.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLargeFireball.java @@ -24,18 +24,18 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetLargeFireball; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.projectile.EntityLargeFireball; -import net.minecraft.world.level.World; -import net.minecraft.world.phys.MovingObjectPosition; -import net.minecraft.world.phys.MovingObjectPositionEntity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.projectile.LargeFireball; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; import net.royawesome.jlibnoise.MathHelper; @Compat("v1_17_R1") -public class MyPetLargeFireball extends EntityLargeFireball implements EntityMyPetProjectile { +public class MyPetLargeFireball extends LargeFireball implements EntityMyPetProjectile { protected float damage = 0; protected int deathCounter = 100; @@ -56,9 +56,9 @@ public void setDamage(float damage) { @Override public void setDirection(double d0, double d1, double d2) { - d0 += this.Q.nextGaussian() * 0.2D; - d1 += this.Q.nextGaussian() * 0.2D; - d2 += this.Q.nextGaussian() * 0.2D; + d0 += this.random.nextGaussian() * 0.2D; + d1 += this.random.nextGaussian() * 0.2D; + d2 += this.random.nextGaussian() * 0.2D; double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); this.b = (d0 / d3 * 0.1D); this.c = (d1 / d3 * 0.1D); @@ -68,28 +68,28 @@ public void setDirection(double d0, double d1, double d2) { @Override public CraftMyPetLargeFireball getBukkitEntity() { if (this.bukkitEntity == null) { - this.bukkitEntity = new CraftMyPetLargeFireball(this.t.getCraftServer(), this); + this.bukkitEntity = new CraftMyPetLargeFireball(this.level.getCraftServer(), this); } return this.bukkitEntity; } @Override - public void saveData(NBTTagCompound nbtTagCompound) { + public void addAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - public void loadData(NBTTagCompound nbtTagCompound) { + public void readAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - protected void a(MovingObjectPosition movingObjectPosition) { - if (movingObjectPosition.getType() == MovingObjectPosition.EnumMovingObjectType.c) { - Entity entity = ((MovingObjectPositionEntity) movingObjectPosition).getEntity(); - if (entity instanceof EntityLiving) { - entity.damageEntity(DamageSource.fireball(this, getShooter()), damage); + protected void onHit(HitResult movingObjectPosition) { + if (movingObjectPosition.getType() == HitResult.Type.ENTITY) { + Entity entity = ((EntityHitResult) movingObjectPosition).getEntity(); + if (entity instanceof LivingEntity) { + entity.hurt(DamageSource.fireball(this, getShooter()), damage); } } - die(); + discard(); } @Override @@ -97,7 +97,7 @@ public void tick() { try { super.tick(); if (deathCounter-- <= 0) { - die(); + discard(); } } catch (Exception e) { e.printStackTrace(); @@ -105,7 +105,7 @@ public void tick() { } @Override - public boolean damageEntity(DamageSource damagesource, float f) { + public boolean hurt(DamageSource damagesource, float f) { return false; } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLlamaSpit.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLlamaSpit.java index 9982096c7c..1c125b76f0 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLlamaSpit.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLlamaSpit.java @@ -26,19 +26,19 @@ import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetLlamaSpit; import lombok.Getter; import lombok.Setter; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.MathHelper; +import net.minecraft.nbt.CompoundTag; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.EntityTypes; -import net.minecraft.world.entity.projectile.EntityLlamaSpit; -import net.minecraft.world.level.World; -import net.minecraft.world.phys.MovingObjectPosition; -import net.minecraft.world.phys.MovingObjectPositionEntity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.projectile.LlamaSpit; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; +import net.royawesome.jlibnoise.MathHelper; @Compat("v1_17_R1") -public class MyPetLlamaSpit extends EntityLlamaSpit implements EntityMyPetProjectile { +public class MyPetLlamaSpit extends LlamaSpit implements EntityMyPetProjectile { @Setter @Getter @@ -46,11 +46,11 @@ public class MyPetLlamaSpit extends EntityLlamaSpit implements EntityMyPetProjec protected CraftMyPetLlamaSpit bukkitEntity = null; public MyPetLlamaSpit(Level world, EntityMyPet entityMyPet) { - super(EntityTypes.W, world); - this.setShooter(entityMyPet); - this.setPosition(entityMyPet.locX() - (double) (entityMyPet.getWidth() + 1.0F) * 0.5D * (double) MathHelper.sin(entityMyPet.aE * 0.017453292F), - entityMyPet.locY() + (double) entityMyPet.getHeadHeight() - 0.10000000149011612D, - entityMyPet.locZ() + (double) (entityMyPet.getWidth() + 1.0F) * 0.5D * (double) MathHelper.cos(entityMyPet.aE * 0.017453292F)); + super(EntityType.LLAMA_SPIT, world); + this.setOwner(entityMyPet); + this.setPos(entityMyPet.getX() - (double) (entityMyPet.getBbWidth() + 1.0F) * 0.5D * (double) MathHelper.sin(entityMyPet.aE * 0.017453292F), //TODO + entityMyPet.getY() + (double) entityMyPet.getEyeHeight() - 0.10000000149011612D, + entityMyPet.getZ() + (double) (entityMyPet.getBbWidth() + 1.0F) * 0.5D * (double) MathHelper.cos(entityMyPet.aE * 0.017453292F)); } @Override @@ -61,32 +61,32 @@ public EntityMyPet getShooter() { @Override public CraftMyPetLlamaSpit getBukkitEntity() { if (this.bukkitEntity == null) { - this.bukkitEntity = new CraftMyPetLlamaSpit(this.t.getCraftServer(), this); + this.bukkitEntity = new CraftMyPetLlamaSpit(this.level.getCraftServer(), this); } return this.bukkitEntity; } @Override - public void saveData(NBTTagCompound nbtTagCompound) { + public void addAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - public void loadData(NBTTagCompound nbtTagCompound) { + public void readAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - public boolean damageEntity(DamageSource damagesource, float f) { + public boolean hurt(DamageSource damagesource, float f) { return false; } @Override - public void a(MovingObjectPosition movingObjectPosition) { - if (movingObjectPosition.getType() == MovingObjectPosition.EnumMovingObjectType.c) { - Entity entity = ((MovingObjectPositionEntity) movingObjectPosition).getEntity(); - if (entity instanceof EntityLiving) { - entity.damageEntity(DamageSource.a(this, getShooter()), damage); + public void onHit(HitResult movingObjectPosition) { + if (movingObjectPosition.getType() == HitResult.Type.ENTITY) { + Entity entity = ((EntityHitResult) movingObjectPosition).getEntity(); + if (entity instanceof LivingEntity) { + entity.hurt(DamageSource.a(this, getShooter()), damage); //TODO } } - this.die(); + this.discard(); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSmallFireball.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSmallFireball.java index f9fbeb60df..ea4d808a1a 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSmallFireball.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSmallFireball.java @@ -24,18 +24,18 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetSmallFireball; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.projectile.EntitySmallFireball; -import net.minecraft.world.level.World; -import net.minecraft.world.phys.MovingObjectPosition; -import net.minecraft.world.phys.MovingObjectPositionEntity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.projectile.SmallFireball; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; import net.royawesome.jlibnoise.MathHelper; @Compat("v1_17_R1") -public class MyPetSmallFireball extends EntitySmallFireball implements EntityMyPetProjectile { +public class MyPetSmallFireball extends SmallFireball implements EntityMyPetProjectile { protected float damage = 0; protected int deathCounter = 100; @@ -56,11 +56,11 @@ public void setDamage(float damage) { @Override public void setDirection(double d0, double d1, double d2) { - d0 += this.Q.nextGaussian() * 0.2D; - d1 += this.Q.nextGaussian() * 0.2D; - d2 += this.Q.nextGaussian() * 0.2D; + d0 += this.random.nextGaussian() * 0.2D; + d1 += this.random.nextGaussian() * 0.2D; + d2 += this.random.nextGaussian() * 0.2D; double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); - this.b = (d0 / d3 * 0.1D); + this.b = (d0 / d3 * 0.1D); //TODO this.c = (d1 / d3 * 0.1D); this.d = (d2 / d3 * 0.1D); } @@ -68,28 +68,28 @@ public void setDirection(double d0, double d1, double d2) { @Override public CraftMyPetSmallFireball getBukkitEntity() { if (this.bukkitEntity == null) { - this.bukkitEntity = new CraftMyPetSmallFireball(this.t.getCraftServer(), this); + this.bukkitEntity = new CraftMyPetSmallFireball(this.level.getCraftServer(), this); } return this.bukkitEntity; } @Override - public void saveData(NBTTagCompound nbtTagCompound) { + public void addAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - public void loadData(NBTTagCompound nbtTagCompound) { + public void readAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - protected void a(MovingObjectPosition movingObjectPosition) { - if (movingObjectPosition.getType() == MovingObjectPosition.EnumMovingObjectType.c) { - Entity entity = ((MovingObjectPositionEntity) movingObjectPosition).getEntity(); - if (entity instanceof EntityLiving) { - entity.damageEntity(DamageSource.fireball(this, getShooter()), damage); + protected void onHit(HitResult movingObjectPosition) { + if (movingObjectPosition.getType() == HitResult.Type.ENTITY) { + Entity entity = ((EntityHitResult) movingObjectPosition).getEntity(); + if (entity instanceof LivingEntity) { + entity.hurt(DamageSource.fireball(this, getShooter()), damage); } } - die(); + discard(); } @Override @@ -97,7 +97,7 @@ public void tick() { try { super.tick(); if (deathCounter-- <= 0) { - die(); + discard(); } } catch (Exception e) { e.printStackTrace(); @@ -105,7 +105,7 @@ public void tick() { } @Override - public boolean damageEntity(DamageSource damagesource, float f) { + public boolean hurt(DamageSource damagesource, float f) { return false; } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSnowball.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSnowball.java index cfe5617bf7..ef3544bfd9 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSnowball.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSnowball.java @@ -24,18 +24,18 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetSnowball; -import net.minecraft.core.particles.Particles; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.nbt.CompoundTag; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.projectile.EntitySnowball; -import net.minecraft.world.level.World; -import net.minecraft.world.phys.MovingObjectPosition; -import net.minecraft.world.phys.MovingObjectPositionEntity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.projectile.Snowball; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; @Compat("v1_17_R1") -public class MyPetSnowball extends EntitySnowball implements EntityMyPetProjectile { +public class MyPetSnowball extends Snowball implements EntityMyPetProjectile { protected float damage = 0; protected CraftMyPetSnowball bukkitEntity = null; @@ -56,35 +56,35 @@ public void setDamage(float damage) { @Override public CraftMyPetSnowball getBukkitEntity() { if (this.bukkitEntity == null) { - this.bukkitEntity = new CraftMyPetSnowball(this.t.getCraftServer(), this); + this.bukkitEntity = new CraftMyPetSnowball(this.level.getCraftServer(), this); } return this.bukkitEntity; } @Override - public void saveData(NBTTagCompound nbtTagCompound) { + public void addAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - public void loadData(NBTTagCompound nbtTagCompound) { + public void readAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - protected void a(MovingObjectPosition movingObjectPosition) { - if (movingObjectPosition.getType() == MovingObjectPosition.EnumMovingObjectType.c) { - Entity entity = ((MovingObjectPositionEntity) movingObjectPosition).getEntity(); - if (entity instanceof EntityLiving) { - entity.damageEntity(DamageSource.projectile(this, getShooter()), damage); + protected void onHit(HitResult movingObjectPosition) { + if (movingObjectPosition.getType() == HitResult.Type.ENTITY) { + Entity entity = ((EntityHitResult) movingObjectPosition).getEntity(); + if (entity instanceof LivingEntity) { + entity.hurt(DamageSource.thrown(this, getShooter()), damage); } } for (int i = 0; i < 8; i++) { - this.t.addParticle(Particles.N, this.locX(), this.locY(), this.locZ(), 0.0D, 0.0D, 0.0D); + this.level.addParticle(ParticleTypes.ITEM_SNOWBALL, this.getX(), this.getY(), this.getZ(), 0.0D, 0.0D, 0.0D); } - die(); + discard(); } @Override - public boolean damageEntity(DamageSource damagesource, float f) { + public boolean hurt(DamageSource damagesource, float f) { return false; } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetTrident.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetTrident.java index dc774fe7bc..3b8ba4f988 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetTrident.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetTrident.java @@ -24,20 +24,20 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetTrident; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.projectile.EntityThrownTrident; +import net.minecraft.world.entity.projectile.ThrownTrident; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @Compat("v1_17_R1") -public class MyPetTrident extends EntityThrownTrident implements EntityMyPetProjectile { +public class MyPetTrident extends ThrownTrident implements EntityMyPetProjectile { protected CraftMyPetTrident bukkitEntity = null; public MyPetTrident(Level world, EntityMyPet entityMyPet) { - super(world, entityMyPet, new ItemStack(Items.sO)); + super(world, entityMyPet, new ItemStack(Items.TRIDENT)); } @Override @@ -48,25 +48,25 @@ public EntityMyPet getShooter() { @Override public CraftMyPetTrident getBukkitEntity() { if (this.bukkitEntity == null) { - this.bukkitEntity = new CraftMyPetTrident(this.t.getCraftServer(), this); + this.bukkitEntity = new CraftMyPetTrident(this.level.getCraftServer(), this); } return this.bukkitEntity; } @Override - public void saveData(NBTTagCompound nbtTagCompound) { + public void addAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - public void loadData(NBTTagCompound nbtTagCompound) { + public void readAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override public void tick() { try { super.tick(); - if (this.b) { - die(); + if (this.b) { //TODO + discard(); } } catch (Exception e) { e.printStackTrace(); @@ -74,7 +74,7 @@ public void tick() { } @Override - public boolean damageEntity(DamageSource damagesource, float f) { + public boolean hurt(DamageSource damagesource, float f) { return false; } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetWitherSkull.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetWitherSkull.java index 8a027290d4..c8140c1e2f 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetWitherSkull.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetWitherSkull.java @@ -24,18 +24,18 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetWitherSkull; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.projectile.EntityWitherSkull; -import net.minecraft.world.level.World; -import net.minecraft.world.phys.MovingObjectPosition; -import net.minecraft.world.phys.MovingObjectPositionEntity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.projectile.WitherSkull; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; import net.royawesome.jlibnoise.MathHelper; @Compat("v1_17_R1") -public class MyPetWitherSkull extends EntityWitherSkull implements EntityMyPetProjectile { +public class MyPetWitherSkull extends WitherSkull implements EntityMyPetProjectile { protected float damage = 0; protected int deathCounter = 100; @@ -56,11 +56,11 @@ public void setDamage(float damage) { @Override public void setDirection(double d0, double d1, double d2) { - d0 += this.Q.nextGaussian() * 0.2D; - d1 += this.Q.nextGaussian() * 0.2D; - d2 += this.Q.nextGaussian() * 0.2D; + d0 += this.random.nextGaussian() * 0.2D; + d1 += this.random.nextGaussian() * 0.2D; + d2 += this.random.nextGaussian() * 0.2D; double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); - this.b = (d0 / d3 * 0.1D); + this.b = (d0 / d3 * 0.1D); //TODO this.c = (d1 / d3 * 0.1D); this.d = (d2 / d3 * 0.1D); } @@ -68,28 +68,28 @@ public void setDirection(double d0, double d1, double d2) { @Override public CraftMyPetWitherSkull getBukkitEntity() { if (this.bukkitEntity == null) { - this.bukkitEntity = new CraftMyPetWitherSkull(this.t.getCraftServer(), this); + this.bukkitEntity = new CraftMyPetWitherSkull(this.level.getCraftServer(), this); } return this.bukkitEntity; } @Override - public void saveData(NBTTagCompound nbtTagCompound) { + public void addAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - public void loadData(NBTTagCompound nbtTagCompound) { + public void readAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - protected void a(MovingObjectPosition movingObjectPosition) { - if (movingObjectPosition.getType() == MovingObjectPosition.EnumMovingObjectType.c) { - Entity entity = ((MovingObjectPositionEntity) movingObjectPosition).getEntity(); - if (entity instanceof EntityLiving) { - entity.damageEntity(DamageSource.projectile(this, getShooter()), damage); + protected void onHit(HitResult movingObjectPosition) { + if (movingObjectPosition.getType() == HitResult.Type.ENTITY) { + Entity entity = ((EntityHitResult) movingObjectPosition).getEntity(); + if (entity instanceof LivingEntity) { + entity.hurt(DamageSource.thrown(this, getShooter()), damage); } } - die(); + discard(); } @Override @@ -97,7 +97,7 @@ public void tick() { try { super.tick(); if (deathCounter-- <= 0) { - die(); + discard(); } } catch (Exception e) { e.printStackTrace(); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java index be02c4fde3..28d5c2d688 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java @@ -49,13 +49,13 @@ import de.keyle.knbt.TagCompound; import de.keyle.knbt.TagList; import net.minecraft.core.NonNullList; -import net.minecraft.network.chat.ChatComponentText; -import net.minecraft.network.protocol.game.PacketPlayOutOpenWindow; -import net.minecraft.server.level.EntityPlayer; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.Container; -import net.minecraft.world.Containers; -import net.minecraft.world.entity.item.EntityItem; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -63,7 +63,7 @@ public class CustomInventory implements Container, Listener, de.Keyle.MyPet.api.util.inventory.CustomInventory { private String inventoryName = ""; - private final NonNullList items = NonNullList.a(64, ItemStack.EMPTY); + private final NonNullList items = NonNullList.withSize(64, ItemStack.EMPTY); private int size = 0; private int stackSize = 64; private final List transaction = new ArrayList<>(); @@ -122,7 +122,7 @@ public void setItem(int i, ItemStack itemStack) { } else { items.add(i, itemStack); } - update(); + setChanged(); } @Override @@ -191,25 +191,25 @@ public String getName() { public void dropContentAt(Location loc) { Level world = ((CraftWorld) loc.getWorld()).getHandle(); for (int i = 0; i < this.getSize(); i++) { - ItemStack is = this.splitWithoutUpdate(i); + ItemStack is = this.removeItemNoUpdate(i); if (is != null && !is.isEmpty()) { - is = is.cloneItemStack(); - EntityItem itemEntity = new EntityItem(world, loc.getX(), loc.getY(), loc.getZ(), is); - itemEntity.ap = 20; - world.addEntity(itemEntity); + is = is.copy(); + ItemEntity itemEntity = new ItemEntity(world, loc.getX(), loc.getY(), loc.getZ(), is); + itemEntity.pickupDelay = 20; + world.addFreshEntity(itemEntity); } } } @Override - public ItemStack splitStack(int slot, int subtract) { + public ItemStack removeItem(int slot, int subtract) { if (slot < size && items.get(slot) != ItemStack.EMPTY) { if (items.get(slot).getCount() <= subtract) { ItemStack itemStack = items.get(slot); items.set(slot, ItemStack.EMPTY); return itemStack; } else { - ItemStack splittedStack = items.get(slot).cloneAndSubtract(subtract); + ItemStack splittedStack = items.get(slot).split(subtract); if (items.get(slot).getCount() == 0) { items.set(slot, ItemStack.EMPTY); @@ -257,7 +257,7 @@ public void load(TagCompound nbtTagCompound) { } @Override - public boolean a(EntityHuman entityHuman) { + public boolean stillValid(net.minecraft.world.entity.player.Player entityHuman) { return true; } @@ -301,30 +301,30 @@ public void close() { @Override public void open(Player player) { - EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); - Container container = new CraftContainer(getBukkitInventory(), entityPlayer, entityPlayer.nextContainerCounter()); + ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + AbstractContainerMenu container = new CraftContainer(getBukkitInventory(), entityPlayer, entityPlayer.nextContainerCounter()); container = CraftEventFactory.callInventoryOpenEvent(entityPlayer, container); if (container != null) { - Containers customSize = Containers.a; + MenuType customSize = MenuType.GENERIC_9x1; switch (this.getSize()) { case 18: - customSize = Containers.b; + customSize = MenuType.GENERIC_9x2; break; case 27: - customSize = Containers.c; + customSize = MenuType.GENERIC_9x3; break; case 36: - customSize = Containers.d; + customSize = MenuType.GENERIC_9x4; break; case 45: - customSize = Containers.e; + customSize = MenuType.GENERIC_9x5; break; case 54: - customSize = Containers.f; + customSize = MenuType.GENERIC_9x6; break; } - entityPlayer.b.sendPacket(new PacketPlayOutOpenWindow(container.j, customSize, new ChatComponentText(this.getName()))); - entityPlayer.bV = container; + entityPlayer.connection.send(new ClientboundOpenScreenPacket(container.containerId, customSize, new TextComponent(this.getName()))); + entityPlayer.containerMenu = container; entityPlayer.initMenu(container); } } @@ -355,7 +355,7 @@ public Location getLocation() { } @Override - public ItemStack splitWithoutUpdate(int i) { + public ItemStack removeItemNoUpdate(int i) { if (items.get(i) != ItemStack.EMPTY) { ItemStack itemstack = items.get(i); @@ -366,11 +366,11 @@ public ItemStack splitWithoutUpdate(int i) { } @Override - public void update() { + public void setChanged() { } @Override - public void clear() { + public void clearContent() { } public boolean isNotEmpty() { From 2089968a3777e1bc7d9d69b8f6a951ac4c611fb8 Mon Sep 17 00:00:00 2001 From: Jakllp <57708725+Jakllp@users.noreply.github.com> Date: Mon, 23 Aug 2021 20:16:35 +0200 Subject: [PATCH 3/6] Conversion to Mojang-Mappings - Part 3/? Forgot these --- .../compat/v1_17_R1/entity/types/EntityMyCod.java | 4 ++-- .../v1_17_R1/entity/types/EntityMyCreeper.java | 4 ++-- .../v1_17_R1/entity/types/EntityMyGhast.java | 2 +- .../v1_17_R1/entity/types/EntityMyHoglin.java | 4 ++-- .../compat/v1_17_R1/entity/types/EntityMyHusk.java | 14 +++++++------- .../v1_17_R1/entity/types/EntityMyIllusioner.java | 14 +++++++------- .../v1_17_R1/entity/types/EntityMyParrot.java | 2 +- .../v1_17_R1/entity/types/EntityMyPufferfish.java | 4 ++-- .../v1_17_R1/entity/types/EntityMySilverfish.java | 2 +- .../entity/types/EntityMySkeletonHorse.java | 4 ++-- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java index d99950a07f..9102e45be7 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java @@ -25,10 +25,10 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.world.level.World; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.level.Level; @EntitySize(width = 0.5F, height = 0.3f) public class EntityMyCod extends EntityMyPet { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCreeper.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCreeper.java index 183362151c..1183dc2277 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCreeper.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCreeper.java @@ -24,10 +24,10 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyCreeper; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.world.level.World; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.9F) public class EntityMyCreeper extends EntityMyPet { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGhast.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGhast.java index f7dc0cbc68..635dadf211 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGhast.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGhast.java @@ -25,7 +25,7 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack.MeleeAttack; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 4.F, height = 4.F) public class EntityMyGhast extends EntityMyPet { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java index a9d3c57fff..3c781b8ef2 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java @@ -30,7 +30,7 @@ import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -60,7 +60,7 @@ protected String getLivingSound() { @Override public InteractionResult handlePlayerInteraction(final Player entityhuman, InteractionHand enumhand, final ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java index daacc726d6..0c204fe9a7 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java @@ -45,7 +45,7 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; @@ -94,18 +94,18 @@ protected String getLivingSound() { @Override public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { - if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); - entityitem.ap = 10; + entityitem.pickupDelay = 10; entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); @@ -132,9 +132,9 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction } else if (MyPetApi.getPlatformHelper().isEquipment(CraftItemStack.asBukkitCopy(itemStack)) && getOwner().getPlayer().isSneaking() && canEquip()) { EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); - entityitem.ap = 10; + entityitem.pickupDelay = 10; entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); this.level.addFreshEntity(entityitem); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java index ad9164c0da..11be877e0e 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java @@ -45,7 +45,7 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; @@ -92,18 +92,18 @@ protected String getLivingSound() { */ @Override public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { - if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).a()) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } if (getOwner().equals(entityhuman) && itemStack != null) { - if (itemStack.getItem() == Items.pq && getOwner().getPlayer().isSneaking() && canEquip()) { + if (itemStack.getItem() == Items.SHEARS && getOwner().getPlayer().isSneaking() && canEquip()) { boolean hadEquipment = false; for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a) { + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR) { ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); - entityitem.ap = 10; + entityitem.pickupDelay = 10; entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); this.level.addFreshEntity(entityitem); getMyPet().setEquipment(slot, null); @@ -131,9 +131,9 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction EquipmentSlot slot = EquipmentSlot.getSlotById(Mob.getEquipmentSlotForItem(itemStack).getFilterFlag()); if (slot == EquipmentSlot.MainHand) { ItemStack itemInSlot = CraftItemStack.asNMSCopy(getMyPet().getEquipment(slot)); - if (itemInSlot != null && itemInSlot.getItem() != Items.a && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + if (itemInSlot != null && itemInSlot.getItem() != Items.AIR && itemInSlot != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY() + 1, this.getZ(), itemInSlot); - entityitem.ap = 10; + entityitem.pickupDelay = 10; entityitem.setDeltaMovement(entityitem.getDeltaMovement().add(0, this.random.nextFloat() * 0.05F, 0)); this.level.addFreshEntity(entityitem); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyParrot.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyParrot.java index ffe99cbc69..c0a1f58fd9 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyParrot.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyParrot.java @@ -31,7 +31,7 @@ import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 0.5F, height = 0.9f) public class EntityMyParrot extends EntityMyPet { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java index e33281ba65..82f8e53d5e 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java @@ -26,10 +26,10 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyPufferfish; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.world.level.World; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.level.Level; @EntitySize(width = 0.5F, height = 0.5f) public class EntityMyPufferfish extends EntityMyPet { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySilverfish.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySilverfish.java index f6bf7cc55b..9eae84cb9b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySilverfish.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySilverfish.java @@ -23,7 +23,7 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 0.4F, height = 0.1F) public class EntityMySilverfish extends EntityMyPet { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java index 8bade03ecd..ce538e2690 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java @@ -41,7 +41,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.PlayerRideableJumping; import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; @@ -112,7 +112,7 @@ protected String getLivingSound() { @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } From 55a07c52113cf050d3693186137f842759cb8c0d Mon Sep 17 00:00:00 2001 From: Jakllp <57708725+Jakllp@users.noreply.github.com> Date: Mon, 23 Aug 2021 20:42:13 +0200 Subject: [PATCH 4/6] Conversion to Mojang-Mappings - Part 4/? A small one? --- .../entity/ai/attack/MeleeAttack.java | 3 +- .../entity/ai/attack/RangedAttack.java | 7 ++- .../v1_17_R1/entity/ai/movement/EatGrass.java | 25 +++++---- .../v1_17_R1/entity/ai/movement/Float.java | 15 ++--- .../entity/ai/movement/FollowOwner.java | 55 +++++++++---------- .../entity/ai/movement/LookAtPlayer.java | 8 +-- .../entity/ai/movement/RandomLookaround.java | 4 +- .../v1_17_R1/entity/ai/movement/Sit.java | 2 +- .../v1_17_R1/entity/ai/movement/Sprint.java | 15 ++--- 9 files changed, 69 insertions(+), 65 deletions(-) diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/MeleeAttack.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/MeleeAttack.java index 4f4ac3d90a..63d7b717e0 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/MeleeAttack.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/MeleeAttack.java @@ -20,6 +20,7 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; import org.bukkit.entity.LivingEntity; import de.Keyle.MyPet.api.entity.EquipmentSlot; @@ -62,7 +63,7 @@ public boolean shouldStart() { if (!this.petEntity.hasTarget()) { return false; } - net.minecraft.world.entity.LivingEntity targetEntity = this.petEntity.getTarget(); + net.minecraft.world.entity.LivingEntity targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (targetEntity instanceof ArmorStand) { return false; diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java index 5d6d00f6c4..64637a3869 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java @@ -20,6 +20,8 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; + import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.ai.AIGoal; import de.Keyle.MyPet.api.skill.skills.Behavior; @@ -41,7 +43,6 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.TamableAnimal; import net.minecraft.world.entity.decoration.ArmorStand; -import net.minecraft.world.entity.projectile.Arrow; import net.minecraft.world.level.Level; import net.royawesome.jlibnoise.MathHelper; @@ -77,7 +78,7 @@ public boolean shouldStart() { return false; } - LivingEntity target = this.entityMyPet.getTarget(); + LivingEntity target = ((CraftLivingEntity) this.entityMyPet.getMyPetTarget()).getHandle(); if (target instanceof ArmorStand) { return false; @@ -96,7 +97,7 @@ public boolean shouldStart() { return false; } if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Raid) { - if (target instanceof TamableAnimal && ((TamableAnimal) target).isTamed()) { + if (target instanceof TamableAnimal && ((TamableAnimal) target).isTame()) { return false; } if (target instanceof EntityMyPet) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java index b8758f5032..c0d06f2ef0 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java @@ -20,21 +20,22 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement; +import java.util.function.Predicate; + +import org.bukkit.GameRule; +import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.ai.AIGoal; import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.types.EntityMySheep; import net.minecraft.core.BlockPos; -import net.minecraft.util.MathHelper; -import net.minecraft.world.level.World; +import net.minecraft.util.Mth; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.predicate.BlockStatePredicate; -import org.bukkit.GameRule; -import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory; - -import java.util.function.Predicate; @Compat("v1_17_R1") public class EatGrass implements AIGoal { @@ -61,9 +62,9 @@ public boolean shouldStart() { } else if (this.entityMySheep.getTarget() != null && !this.entityMySheep.getTarget().isDead()) { return false; } - int blockLocX = MathHelper.floor(this.entityMySheep.locX()); - int blockLocY = MathHelper.floor(this.entityMySheep.locY()); - int blockLocZ = MathHelper.floor(this.entityMySheep.locZ()); + int blockLocX = Mth.floor(this.entityMySheep.getX()); + int blockLocY = Mth.floor(this.entityMySheep.getY()); + int blockLocZ = Mth.floor(this.entityMySheep.getZ()); BlockPos blockposition = new BlockPos(blockLocX, blockLocY, blockLocZ); @@ -90,9 +91,9 @@ public void finish() { @Override public void tick() { if (--this.eatTicks == 0) { - int blockLocX = MathHelper.floor(this.entityMySheep.locX()); - int blockLocY = MathHelper.floor(this.entityMySheep.locY()); - int blockLocZ = MathHelper.floor(this.entityMySheep.locZ()); + int blockLocX = Mth.floor(this.entityMySheep.getX()); + int blockLocY = Mth.floor(this.entityMySheep.getY()); + int blockLocZ = Mth.floor(this.entityMySheep.getZ()); BlockPos blockAt = new BlockPos(blockLocX, blockLocY, blockLocZ); if (GRASS.test(this.world.getType(blockAt))) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Float.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Float.java index e9bf36b301..24e594b9f7 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Float.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Float.java @@ -20,19 +20,20 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; + import de.Keyle.MyPet.api.entity.ai.AIGoal; import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.server.level.EntityPlayer; -import net.minecraft.tags.TagsFluid; -import net.minecraft.world.entity.ai.navigation.Navigation; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; +import net.minecraft.tags.FluidTags; +import net.minecraft.world.entity.ai.navigation.PathNavigation; +import net.minecraft.world.entity.player.Player; @Compat("v1_17_R1") public class Float implements AIGoal { private final EntityMyPet entityMyPet; - private final EntityPlayer owner; + private final Player owner; private int lavaCounter = 10; private boolean inLava = false; @@ -41,7 +42,7 @@ public Float(EntityMyPet entityMyPet) { this.entityMyPet = entityMyPet; //entityMyPet.getNavigation().e(true); this.owner = ((CraftPlayer) entityMyPet.getOwner().getPlayer()).getHandle(); - ((Navigation) entityMyPet.getNavigation()).c(true); + ((PathNavigation) entityMyPet.getNavigation()).setCanFloat(true);; } @Override @@ -63,7 +64,7 @@ public void tick() { lavaCounter = 10; } } - if (!inLava && entityMyPet.a(TagsFluid.c)) { + if (!inLava && entityMyPet.isEyeInFluid(FluidTags.LAVA)) { inLava = true; } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/FollowOwner.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/FollowOwner.java index cf4c829707..d66c57581b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/FollowOwner.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/FollowOwner.java @@ -20,20 +20,19 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.entity.ai.AIGoal; import de.Keyle.MyPet.api.entity.ai.navigation.AbstractNavigation; import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.server.level.EntityPlayer; import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.ai.attributes.AttributeModifiable; -import net.minecraft.world.entity.ai.attributes.GenericAttributes; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.attributes.AttributeInstance; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.player.Player; @Compat("v1_17_R1") public class FollowOwner implements AIGoal { @@ -45,7 +44,7 @@ public class FollowOwner implements AIGoal { private final double startDistance; private final float teleportDistance; private Control controlPathfinderGoal; - private final EntityPlayer owner; + private final Player owner; private boolean waitForGround = false; public FollowOwner(EntityMyPet entityMyPet, double startDistance, float stopDistance, float teleportDistance) { @@ -66,11 +65,11 @@ public boolean shouldStart() { } if (!this.petEntity.canMove()) { return false; - } else if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + } else if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } else if (this.petEntity.getOwner() == null) { return false; - } else if (this.petEntity.f(owner) < this.startDistance) { + } else if (this.petEntity.distanceToSqr(owner) < this.startDistance) { return false; } else return controlPathfinderGoal == null || controlPathfinderGoal.moveTo == null; } @@ -81,11 +80,11 @@ public boolean shouldFinish() { return true; } else if (this.petEntity.getOwner() == null) { return true; - } else if (this.petEntity.f(owner) < this.stopDistance) { + } else if (this.petEntity.distanceToSqr(owner) < this.stopDistance) { return true; } else if (!this.petEntity.canMove()) { return true; - } else return this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead(); + } else return this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead(); } @Override @@ -109,19 +108,19 @@ public void tick() { } //Look at Owner - this.petEntity.getLookControl().setLookAt(owner, this.petEntity.eZ(), this.petEntity.eZ()); + this.petEntity.getLookControl().setLookAt(owner, this.petEntity.getMaxHeadXRot(), this.petEntity.getMaxHeadXRot()); //Teleportation if (this.petEntity.canMove()) { - if (!owner.getAbilities().b) { + if (!owner.getAbilities().flying) { if (!waitForGround) { - if (owner.J <= 4) { - if (this.petEntity.f(owner) >= this.teleportDistance) { + if (owner.flyDist <= 4) { + if (this.petEntity.distanceToSqr(owner) >= this.teleportDistance) { if (controlPathfinderGoal.moveTo == null) { if (!petEntity.hasTarget()) { if (MyPetApi.getPlatformHelper().canSpawn(ownerLocation, this.petEntity)) { - this.petEntity.J = 0; - this.petEntity.setPositionRotation(ownerLocation.getX(), ownerLocation.getY(), ownerLocation.getZ(), this.petEntity.getYRot(), this.petEntity.getXRot()); + this.petEntity.flyDist = 0; + this.petEntity.moveTo(ownerLocation.getX(), ownerLocation.getY(), ownerLocation.getZ(), this.petEntity.getYRot(), this.petEntity.getXRot()); this.setPathTimer = 0; return; } @@ -146,24 +145,24 @@ public void tick() { } private void applyWalkSpeed() { - float walkSpeed = owner.getAbilities().g; - if (owner.getAbilities().b) { + float walkSpeed = owner.getAbilities().walkingSpeed; + if (owner.getAbilities().flying) { // make the pet faster when the player is flying - walkSpeed += owner.getAbilities().f; + walkSpeed += owner.getAbilities().flyingSpeed; } else if (owner.isSprinting()) { // make the pet faster when the player is sprinting - if (owner.getAttributeMap().a(GenericAttributes.d) != null) { - walkSpeed += owner.getAttributeMap().a(GenericAttributes.d).getValue(); + if (owner.getAttributes().getInstance(Attributes.MOVEMENT_SPEED) != null) { + walkSpeed += owner.getAttributes().getInstance(Attributes.MOVEMENT_SPEED).getValue(); } - } else if (owner.isPassenger() && owner.getVehicle() instanceof EntityLiving) { + } else if (owner.isPassenger() && owner.getVehicle() instanceof LivingEntity) { // adjust the speed to the pet can catch up with the vehicle the player is in - AttributeModifiable vehicleSpeedAttribute = ((EntityLiving) owner.getVehicle()).getAttributeMap().a(GenericAttributes.d); + AttributeInstance vehicleSpeedAttribute = ((LivingEntity) owner.getVehicle()).getAttributes().getInstance(Attributes.MOVEMENT_SPEED); if (vehicleSpeedAttribute != null) { walkSpeed = (float) vehicleSpeedAttribute.getValue(); } - } else if (owner.hasEffect(MobEffects.a)) { + } else if (owner.hasEffect(MobEffects.MOVEMENT_SPEED)) { // make the pet faster when the player is has the SPEED effect - walkSpeed += owner.getEffect(MobEffects.a).getAmplifier() * 0.2 * walkSpeed; + walkSpeed += owner.getEffect(MobEffects.MOVEMENT_SPEED).getAmplifier() * 0.2 * walkSpeed; } // make the pet a little bit faster than the player so it can catch up walkSpeed += 0.07f; diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/LookAtPlayer.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/LookAtPlayer.java index b004659ef8..f3ecf724a5 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/LookAtPlayer.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/LookAtPlayer.java @@ -51,13 +51,13 @@ public boolean shouldStart() { if (this.petEntity.getRandom().nextFloat() >= this.lookAtPlayerChance) { return false; } - if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } if (this.petEntity.isVehicle()) { return false; } - this.targetPlayer = this.petEntity.t.findNearbyPlayer(this.petEntity, this.range); + this.targetPlayer = this.petEntity.level.getNearestPlayer(this.petEntity, this.range); return this.targetPlayer != null; } @@ -66,7 +66,7 @@ public boolean shouldFinish() { if (!this.targetPlayer.isAlive()) { return true; } - if (this.petEntity.f(this.targetPlayer) > this.range) { + if (this.petEntity.distanceToSqr(this.targetPlayer) > this.range) { return true; } if (this.petEntity.isVehicle()) { @@ -87,7 +87,7 @@ public void finish() { @Override public void tick() { - this.petEntity.getLookControl().setLookAt(this.targetPlayer.locX(), this.targetPlayer.locY() + this.targetPlayer.getHeadHeight(), this.targetPlayer.locZ(), petEntity.eZ(), this.petEntity.eZ()); + this.petEntity.getLookControl().setLookAt(this.targetPlayer.getX(), this.targetPlayer.getY() + this.targetPlayer.getEyeHeight(), this.targetPlayer.getZ(), petEntity.getMaxHeadXRot(), this.petEntity.getMaxHeadXRot()); this.ticksUntilStopLooking -= 1; } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/RandomLookaround.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/RandomLookaround.java index 48ec48f87a..bf00997416 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/RandomLookaround.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/RandomLookaround.java @@ -38,7 +38,7 @@ public RandomLookaround(EntityMyPet petEntity) { @Override public boolean shouldStart() { - if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } if (this.petEntity.isVehicle()) { @@ -63,6 +63,6 @@ public void start() { @Override public void tick() { this.ticksUntilStopLookingAround--; - this.petEntity.getLookControl().setLookAt(this.petEntity.locX() + this.directionX, this.petEntity.locY() + this.petEntity.getHeadHeight(), this.petEntity.locZ() + this.directionZ, this.petEntity.eZ(), this.petEntity.eZ()); + this.petEntity.getLookControl().setLookAt(this.petEntity.getX() + this.directionX, this.petEntity.getY() + this.petEntity.getEyeHeight(), this.petEntity.getZ() + this.directionZ, this.petEntity.getMaxHeadXRot(), this.petEntity.getMaxHeadXRot()); } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Sit.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Sit.java index b5e99e9e88..a4f2aaacbc 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Sit.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Sit.java @@ -65,7 +65,7 @@ public void start() { } else if (this.entityMyPet instanceof EntityMyPanda) { ((EntityMyPanda) this.entityMyPet).updateActionsWatcher(8, true); } - entityMyPet.setGoalTarget(null); + entityMyPet.setTarget(null); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Sprint.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Sprint.java index 6e91aaa337..7da7e256ea 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Sprint.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/Sprint.java @@ -20,6 +20,9 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; +import org.bukkit.scheduler.BukkitRunnable; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.ai.AIGoal; @@ -27,9 +30,7 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.skill.skills.SprintImpl; -import net.minecraft.world.entity.EntityLiving; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; -import org.bukkit.scheduler.BukkitRunnable; +import net.minecraft.world.entity.LivingEntity; @Compat("v1_17_R1") public class Sprint implements AIGoal { @@ -38,7 +39,7 @@ public class Sprint implements AIGoal { private final EntityMyPet petEntity; private final float walkSpeedModifier; private final AbstractNavigation nav; - private EntityLiving lastTarget = null; + private LivingEntity lastTarget = null; public Sprint(EntityMyPet entityMyPet, float walkSpeedModifier) { this.petEntity = entityMyPet; @@ -59,7 +60,7 @@ public boolean shouldStart() { return false; } - EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + LivingEntity targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (!targetEntity.isAlive()) { return false; @@ -67,7 +68,7 @@ public boolean shouldStart() { if (lastTarget == targetEntity) { return false; } - if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.f(targetEntity) >= 16) { + if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.distanceToSqr(targetEntity) >= 16) { return false; } this.lastTarget = targetEntity; @@ -78,7 +79,7 @@ public boolean shouldStart() { public boolean shouldFinish() { if (this.petEntity.getOwner() == null) { return true; - } else if (this.petEntity.f(this.lastTarget) < 16) { + } else if (this.petEntity.distanceToSqr(this.lastTarget) < 16) { return true; } else return !this.petEntity.canMove(); } From 1dd9bd1a2b1e3057fbcfb106a50ba60bfa0806b4 Mon Sep 17 00:00:00 2001 From: Jakllp <57708725+Jakllp@users.noreply.github.com> Date: Tue, 24 Aug 2021 22:48:10 +0200 Subject: [PATCH 5/6] Conversion to Mojang-Mappings - Part 5/5 Remap? Done. Bugs? Still there. So let's go fix them --- .../api/util/inventory/CustomInventory.java | 2 - .../MyPet/listeners/MyPetEntityListener.java | 2 +- .../compat/v1_12_R1/entity/CraftMyPet.java | 2 +- .../compat/v1_12_R1/entity/EntityMyPet.java | 10 +- .../entity/ai/attack/MeleeAttack.java | 4 +- .../entity/ai/attack/RangedAttack.java | 4 +- .../v1_12_R1/entity/ai/movement/EatGrass.java | 2 +- .../entity/ai/movement/FollowOwner.java | 4 +- .../entity/ai/movement/LookAtPlayer.java | 2 +- .../entity/ai/movement/RandomLookaround.java | 2 +- .../v1_12_R1/entity/ai/movement/Sprint.java | 2 +- .../ai/target/BehaviorAggressiveTarget.java | 6 +- .../entity/ai/target/BehaviorDuelTarget.java | 4 +- .../entity/ai/target/BehaviorFarmTarget.java | 4 +- .../entity/ai/target/ControlTarget.java | 4 +- .../entity/ai/target/HurtByTarget.java | 4 +- .../entity/ai/target/OwnerHurtByTarget.java | 4 +- .../v1_12_R1/entity/types/EntityMyRabbit.java | 2 +- .../compat/v1_16_R1/entity/CraftMyPet.java | 2 +- .../entity/ai/attack/MeleeAttack.java | 4 +- .../entity/ai/attack/RangedAttack.java | 4 +- .../v1_16_R1/entity/ai/movement/EatGrass.java | 2 +- .../entity/ai/movement/FollowOwner.java | 4 +- .../entity/ai/movement/LookAtPlayer.java | 2 +- .../entity/ai/movement/RandomLookaround.java | 2 +- .../v1_16_R1/entity/ai/movement/Sprint.java | 2 +- .../ai/target/BehaviorAggressiveTarget.java | 6 +- .../entity/ai/target/BehaviorDuelTarget.java | 4 +- .../entity/ai/target/BehaviorFarmTarget.java | 4 +- .../entity/ai/target/ControlTarget.java | 4 +- .../entity/ai/target/HurtByTarget.java | 4 +- .../entity/ai/target/OwnerHurtByTarget.java | 4 +- .../v1_16_R1/entity/types/EntityMyRabbit.java | 2 +- .../compat/v1_16_R3/entity/CraftMyPet.java | 2 +- .../compat/v1_16_R3/entity/EntityMyPet.java | 109 ++++++--- .../v1_16_R3/entity/EntityRegistry.java | 30 ++- .../entity/ai/attack/MeleeAttack.java | 4 +- .../entity/ai/attack/RangedAttack.java | 4 +- .../v1_16_R3/entity/ai/movement/EatGrass.java | 2 +- .../entity/ai/movement/FollowOwner.java | 4 +- .../entity/ai/movement/LookAtPlayer.java | 2 +- .../entity/ai/movement/RandomLookaround.java | 2 +- .../v1_16_R3/entity/ai/movement/Sprint.java | 2 +- .../ai/target/BehaviorAggressiveTarget.java | 6 +- .../entity/ai/target/BehaviorDuelTarget.java | 4 +- .../entity/ai/target/BehaviorFarmTarget.java | 4 +- .../entity/ai/target/ControlTarget.java | 13 +- .../entity/ai/target/HurtByTarget.java | 4 +- .../entity/ai/target/OwnerHurtByTarget.java | 4 +- .../v1_16_R3/entity/types/EntityMyRabbit.java | 2 +- .../skill/skills/ranged/nms/MyPetArrow.java | 7 +- modules/v1_17_R1/pom.xml | 8 +- .../MyPet/compat/v1_17_R1/PlatformHelper.java | 230 +++++++++--------- .../compat/v1_17_R1/entity/EntityMyPet.java | 78 +++--- .../v1_17_R1/entity/EntityMyPetPart.java | 7 +- .../v1_17_R1/entity/EntityRegistry.java | 3 +- .../entity/ai/attack/MeleeAttack.java | 2 +- .../entity/ai/attack/RangedAttack.java | 65 ++--- .../v1_17_R1/entity/ai/movement/EatGrass.java | 22 +- .../entity/ai/movement/FollowOwner.java | 4 +- .../ai/target/BehaviorAggressiveTarget.java | 42 ++-- .../entity/ai/target/BehaviorDuelTarget.java | 23 +- .../entity/ai/target/BehaviorFarmTarget.java | 30 +-- .../entity/ai/target/ControlTarget.java | 44 ++-- .../entity/ai/target/HurtByTarget.java | 44 ++-- .../entity/ai/target/OwnerHurtByTarget.java | 46 ++-- .../v1_17_R1/entity/types/EntityMyBat.java | 6 +- .../v1_17_R1/entity/types/EntityMyBee.java | 6 +- .../v1_17_R1/entity/types/EntityMyBlaze.java | 4 +- .../v1_17_R1/entity/types/EntityMyCat.java | 6 +- .../entity/types/EntityMyCaveSpider.java | 4 +- .../entity/types/EntityMyChicken.java | 8 +- .../v1_17_R1/entity/types/EntityMyCod.java | 4 +- .../v1_17_R1/entity/types/EntityMyCow.java | 4 +- .../entity/types/EntityMyCreeper.java | 4 +- .../entity/types/EntityMyDolphin.java | 4 +- .../v1_17_R1/entity/types/EntityMyDonkey.java | 21 +- .../entity/types/EntityMyDrowned.java | 8 +- .../entity/types/EntityMyElderGuardian.java | 4 +- .../entity/types/EntityMyEnderDragon.java | 20 +- .../entity/types/EntityMyEnderman.java | 28 +-- .../entity/types/EntityMyEndermite.java | 4 +- .../v1_17_R1/entity/types/EntityMyEvoker.java | 6 +- .../v1_17_R1/entity/types/EntityMyFox.java | 5 +- .../v1_17_R1/entity/types/EntityMyGhast.java | 4 +- .../v1_17_R1/entity/types/EntityMyGiant.java | 5 +- .../entity/types/EntityMyGuardian.java | 2 +- .../v1_17_R1/entity/types/EntityMyHoglin.java | 2 +- .../v1_17_R1/entity/types/EntityMyHorse.java | 15 +- .../v1_17_R1/entity/types/EntityMyHusk.java | 5 +- .../entity/types/EntityMyIllusioner.java | 2 +- .../entity/types/EntityMyIronGolem.java | 9 +- .../v1_17_R1/entity/types/EntityMyLlama.java | 15 +- .../entity/types/EntityMyMagmaCube.java | 2 +- .../entity/types/EntityMyMooshroom.java | 2 +- .../v1_17_R1/entity/types/EntityMyMule.java | 17 +- .../v1_17_R1/entity/types/EntityMyOcelot.java | 2 +- .../v1_17_R1/entity/types/EntityMyPanda.java | 2 +- .../v1_17_R1/entity/types/EntityMyParrot.java | 8 +- .../entity/types/EntityMyPhantom.java | 4 +- .../v1_17_R1/entity/types/EntityMyPig.java | 11 +- .../v1_17_R1/entity/types/EntityMyPiglin.java | 5 +- .../entity/types/EntityMyPiglinBrute.java | 7 +- .../entity/types/EntityMyPillager.java | 5 +- .../entity/types/EntityMyPolarBear.java | 6 +- .../entity/types/EntityMyPufferfish.java | 2 +- .../v1_17_R1/entity/types/EntityMyRabbit.java | 2 +- .../entity/types/EntityMyRavager.java | 2 +- .../v1_17_R1/entity/types/EntityMySalmon.java | 2 +- .../v1_17_R1/entity/types/EntityMySheep.java | 9 +- .../entity/types/EntityMySilverfish.java | 2 +- .../entity/types/EntityMySkeleton.java | 5 +- .../entity/types/EntityMySkeletonHorse.java | 15 +- .../v1_17_R1/entity/types/EntityMySlime.java | 2 +- .../entity/types/EntityMySnowman.java | 5 +- .../v1_17_R1/entity/types/EntityMySpider.java | 2 +- .../v1_17_R1/entity/types/EntityMySquid.java | 2 +- .../v1_17_R1/entity/types/EntityMyStray.java | 5 +- .../entity/types/EntityMyStrider.java | 5 +- .../entity/types/EntityMyTraderLlama.java | 13 +- .../entity/types/EntityMyTropicalFish.java | 2 +- .../v1_17_R1/entity/types/EntityMyTurtle.java | 2 +- .../v1_17_R1/entity/types/EntityMyVex.java | 7 +- .../entity/types/EntityMyVillager.java | 2 +- .../entity/types/EntityMyVindicator.java | 2 +- .../entity/types/EntityMyWanderingTrader.java | 2 +- .../v1_17_R1/entity/types/EntityMyWitch.java | 2 +- .../v1_17_R1/entity/types/EntityMyWither.java | 4 +- .../entity/types/EntityMyWitherSkeleton.java | 5 +- .../v1_17_R1/entity/types/EntityMyWolf.java | 10 +- .../v1_17_R1/entity/types/EntityMyZoglin.java | 2 +- .../v1_17_R1/entity/types/EntityMyZombie.java | 5 +- .../entity/types/EntityMyZombieHorse.java | 15 +- .../entity/types/EntityMyZombieVillager.java | 5 +- .../entity/types/EntityMyZombifiedPiglin.java | 5 +- .../services/EntityConverterService.java | 132 +++++++--- .../skill/skills/ranged/nms/MyPetArrow.java | 12 +- .../ranged/nms/MyPetDragonFireball.java | 13 +- .../skills/ranged/nms/MyPetLargeFireball.java | 12 +- .../skills/ranged/nms/MyPetLlamaSpit.java | 8 +- .../skills/ranged/nms/MyPetSmallFireball.java | 10 +- .../skill/skills/ranged/nms/MyPetTrident.java | 2 +- .../skills/ranged/nms/MyPetWitherSkull.java | 10 +- .../util/iconmenu/IconMenuInventory.java | 3 +- .../util/inventory/CustomInventory.java | 14 +- .../compat/v1_8_R3/entity/CraftMyPet.java | 2 +- .../compat/v1_8_R3/entity/EntityMyPet.java | 6 +- .../v1_8_R3/entity/ai/attack/MeleeAttack.java | 4 +- .../entity/ai/attack/RangedAttack.java | 4 +- .../v1_8_R3/entity/ai/movement/EatGrass.java | 2 +- .../entity/ai/movement/FollowOwner.java | 4 +- .../entity/ai/movement/LookAtPlayer.java | 2 +- .../entity/ai/movement/RandomLookaround.java | 2 +- .../v1_8_R3/entity/ai/movement/Sprint.java | 2 +- .../ai/target/BehaviorAggressiveTarget.java | 6 +- .../entity/ai/target/BehaviorDuelTarget.java | 4 +- .../entity/ai/target/BehaviorFarmTarget.java | 4 +- .../entity/ai/target/ControlTarget.java | 4 +- .../entity/ai/target/HurtByTarget.java | 4 +- .../entity/ai/target/OwnerHurtByTarget.java | 4 +- .../entity/types/EntityMyMagmaCube.java | 2 +- .../v1_8_R3/entity/types/EntityMyRabbit.java | 2 +- .../v1_8_R3/entity/types/EntityMySlime.java | 2 +- .../compat/v1_9_R2/entity/CraftMyPet.java | 2 +- .../compat/v1_9_R2/entity/EntityMyPet.java | 8 +- .../v1_9_R2/entity/ai/attack/MeleeAttack.java | 4 +- .../entity/ai/attack/RangedAttack.java | 4 +- .../v1_9_R2/entity/ai/movement/EatGrass.java | 2 +- .../entity/ai/movement/FollowOwner.java | 4 +- .../entity/ai/movement/LookAtPlayer.java | 2 +- .../entity/ai/movement/RandomLookaround.java | 2 +- .../v1_9_R2/entity/ai/movement/Sprint.java | 2 +- .../ai/target/BehaviorAggressiveTarget.java | 6 +- .../entity/ai/target/BehaviorDuelTarget.java | 4 +- .../entity/ai/target/BehaviorFarmTarget.java | 4 +- .../entity/ai/target/ControlTarget.java | 4 +- .../entity/ai/target/HurtByTarget.java | 4 +- .../entity/ai/target/OwnerHurtByTarget.java | 4 +- .../v1_9_R2/entity/types/EntityMyRabbit.java | 2 +- pom.xml | 2 +- 180 files changed, 944 insertions(+), 778 deletions(-) diff --git a/modules/API/src/main/java/de/Keyle/MyPet/api/util/inventory/CustomInventory.java b/modules/API/src/main/java/de/Keyle/MyPet/api/util/inventory/CustomInventory.java index ae4a5800ef..8367448e49 100644 --- a/modules/API/src/main/java/de/Keyle/MyPet/api/util/inventory/CustomInventory.java +++ b/modules/API/src/main/java/de/Keyle/MyPet/api/util/inventory/CustomInventory.java @@ -27,8 +27,6 @@ import org.bukkit.inventory.ItemStack; public interface CustomInventory { - int getSize(); - void setSize(int size); String getName(); diff --git a/modules/Plugin/src/main/java/de/Keyle/MyPet/listeners/MyPetEntityListener.java b/modules/Plugin/src/main/java/de/Keyle/MyPet/listeners/MyPetEntityListener.java index 8c56c83156..e836ab1876 100644 --- a/modules/Plugin/src/main/java/de/Keyle/MyPet/listeners/MyPetEntityListener.java +++ b/modules/Plugin/src/main/java/de/Keyle/MyPet/listeners/MyPetEntityListener.java @@ -507,7 +507,7 @@ public void onMyPet(final EntityDeathEvent event) { if (deadBehaviorSkill.getBehavior() == BehaviorMode.Duel && killerBehaviorSkill.getBehavior() == BehaviorMode.Duel) { MyPetMinecraftEntity myPetEntity = ((MyPetBukkitEntity) deadEntity).getHandle(); - if (e.getDamager().equals(myPetEntity.getTarget())) { + if (e.getDamager().equals(myPetEntity.getMyPetTarget())) { myPet.setRespawnTime(10); killerMyPet.setHealth(Double.MAX_VALUE); } diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/CraftMyPet.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/CraftMyPet.java index dd5679f3ee..b85b1c49c3 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/CraftMyPet.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/CraftMyPet.java @@ -123,7 +123,7 @@ public void forgetTarget() { } public void setTarget(LivingEntity target, TargetPriority priority) { - getHandle().setTarget(target, priority); + getHandle().setMyPetTarget(target, priority); } @Override diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/EntityMyPet.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/EntityMyPet.java index 6a497931d2..6def656fa4 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/EntityMyPet.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/EntityMyPet.java @@ -198,8 +198,9 @@ public boolean hasTarget() { public TargetPriority getTargetPriority() { return targetPriority; } - - public LivingEntity getTarget() { + + @Override + public LivingEntity getMyPetTarget() { if (target != null) { if (target.isAlive()) { return (LivingEntity) target.getBukkitEntity(); @@ -208,8 +209,9 @@ public LivingEntity getTarget() { } return null; } - - public void setTarget(LivingEntity entity, TargetPriority priority) { + + @Override + public void setMyPetTarget(LivingEntity entity, TargetPriority priority) { if (entity == null || entity.isDead() || entity instanceof ArmorStand || !(entity instanceof CraftLivingEntity)) { forgetTarget(); return; diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/attack/MeleeAttack.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/attack/MeleeAttack.java index a1ea362eeb..5fa9792086 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/attack/MeleeAttack.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/attack/MeleeAttack.java @@ -58,7 +58,7 @@ public boolean shouldStart() { if (!this.petEntity.hasTarget()) { return false; } - EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (targetEntity instanceof EntityArmorStand) { return false; @@ -92,7 +92,7 @@ public boolean shouldStart() { public boolean shouldFinish() { if (!this.petEntity.hasTarget() || !this.petEntity.canMove()) { return true; - } else if (this.targetEntity.getBukkitEntity() != this.petEntity.getTarget()) { + } else if (this.targetEntity.getBukkitEntity() != this.petEntity.getMyPetTarget()) { return true; } if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.e(targetEntity.locX, targetEntity.getBoundingBox().b, targetEntity.locZ) >= 20) { diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/attack/RangedAttack.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/attack/RangedAttack.java index c441b894e5..35b2eb4d03 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/attack/RangedAttack.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/attack/RangedAttack.java @@ -63,7 +63,7 @@ public boolean shouldStart() { return false; } - EntityLiving target = ((CraftLivingEntity) this.entityMyPet.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.entityMyPet.getMyPetTarget()).getHandle(); if (target instanceof EntityArmorStand) { return false; @@ -102,7 +102,7 @@ public boolean shouldFinish() { if (!entityMyPet.hasTarget() || myPet.getRangedDamage() <= 0 || !entityMyPet.canMove()) { return true; } - if (this.target.getBukkitEntity() != entityMyPet.getTarget()) { + if (this.target.getBukkitEntity() != entityMyPet.getMyPetTarget()) { return true; } double meleeDamage = myPet.getDamage(); diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/EatGrass.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/EatGrass.java index 89cbae525e..ef2a849399 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/EatGrass.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/EatGrass.java @@ -51,7 +51,7 @@ public boolean shouldStart() { return false; } else if (entityMySheep.getRandom().nextInt(1000) != 0) { return false; - } else if (this.entityMySheep.getTarget() != null && !this.entityMySheep.getTarget().isDead()) { + } else if (this.entityMySheep.getMyPetTarget() != null && !this.entityMySheep.getMyPetTarget().isDead()) { return false; } int blockLocX = MathHelper.floor(this.entityMySheep.locX); diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/FollowOwner.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/FollowOwner.java index d664e8ef6b..9c47474fae 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/FollowOwner.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/FollowOwner.java @@ -59,7 +59,7 @@ public boolean shouldStart() { } if (!this.petEntity.canMove()) { return false; - } else if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + } else if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } else if (this.petEntity.getOwner() == null) { return false; @@ -81,7 +81,7 @@ public boolean shouldFinish() { return true; } else if (!this.petEntity.canMove()) { return true; - } else if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + } else if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return true; } return false; diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/LookAtPlayer.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/LookAtPlayer.java index ea7e436310..87e01b4848 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/LookAtPlayer.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/LookAtPlayer.java @@ -50,7 +50,7 @@ public boolean shouldStart() { if (this.petEntity.getRandom().nextFloat() >= this.lookAtPlayerChance) { return false; } - if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } if (this.petEntity.isVehicle()) { diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/RandomLookaround.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/RandomLookaround.java index 7a6da393f6..1250160de9 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/RandomLookaround.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/RandomLookaround.java @@ -37,7 +37,7 @@ public RandomLookaround(EntityMyPet petEntity) { @Override public boolean shouldStart() { - if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } if (this.petEntity.isVehicle()) { diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/Sprint.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/Sprint.java index e00b695723..9d2ccf1658 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/Sprint.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/movement/Sprint.java @@ -58,7 +58,7 @@ public boolean shouldStart() { return false; } - EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (!targetEntity.isAlive()) { return false; diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/BehaviorAggressiveTarget.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/BehaviorAggressiveTarget.java index ba226bace6..017cde8a0b 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/BehaviorAggressiveTarget.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/BehaviorAggressiveTarget.java @@ -107,11 +107,11 @@ public boolean shouldStart() { public boolean shouldFinish() { if (!petEntity.canMove()) { return true; - } else if (petEntity.getTarget() == null) { + } else if (petEntity.getMyPetTarget() == null) { return true; } - EntityLiving target = ((CraftLivingEntity) petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) petEntity.getMyPetTarget()).getHandle(); if (!target.isAlive()) { return true; @@ -133,7 +133,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Aggressive); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Aggressive); } @Override diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/BehaviorDuelTarget.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/BehaviorDuelTarget.java index cef6a52c66..88e543c827 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/BehaviorDuelTarget.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/BehaviorDuelTarget.java @@ -99,7 +99,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); Behavior behaviorSkill = myPet.getSkills().get(Behavior.class); if (behaviorSkill.getBehavior() != BehaviorMode.Duel) { @@ -118,7 +118,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget(this.target.getBukkitEntity(), TargetPriority.Duel); + petEntity.setMyPetTarget(this.target.getBukkitEntity(), TargetPriority.Duel); setDuelOpponent(this.target); if (target.getTargetSelector().hasGoal("DuelTarget")) { BehaviorDuelTarget duelGoal = (BehaviorDuelTarget) target.getTargetSelector().getGoal("DuelTarget"); diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/BehaviorFarmTarget.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/BehaviorFarmTarget.java index 9263b0a06a..bab5b156b4 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/BehaviorFarmTarget.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/BehaviorFarmTarget.java @@ -87,7 +87,7 @@ public boolean shouldFinish() { if (!this.petEntity.hasTarget()) { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (!target.isAlive()) { return true; @@ -109,7 +109,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Farm); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Farm); } @Override diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/ControlTarget.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/ControlTarget.java index 021918a57c..2b220f00b7 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/ControlTarget.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/ControlTarget.java @@ -129,7 +129,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (target.world != petEntity.world) { return true; @@ -143,7 +143,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Control); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Control); } @Override diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/HurtByTarget.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/HurtByTarget.java index 359892ceba..60bee00a07 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/HurtByTarget.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/HurtByTarget.java @@ -98,7 +98,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (target.world != petEntity.world) { return true; @@ -112,7 +112,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.GetHurt); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.GetHurt); } @Override diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/OwnerHurtByTarget.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/OwnerHurtByTarget.java index c5e30a8c08..f404c62e0a 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/OwnerHurtByTarget.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/ai/target/OwnerHurtByTarget.java @@ -125,7 +125,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (target.world != petEntity.world) { return true; @@ -139,7 +139,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.lastDamager.getBukkitEntity(), TargetPriority.OwnerGetsHurt); + petEntity.setMyPetTarget((LivingEntity) this.lastDamager.getBukkitEntity(), TargetPriority.OwnerGetsHurt); } @Override diff --git a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/types/EntityMyRabbit.java b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/types/EntityMyRabbit.java index 21eb63e219..1f5f51c655 100644 --- a/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/types/EntityMyRabbit.java +++ b/modules/v1_12_R1/src/main/java/de/Keyle/MyPet/compat/v1_12_R1/entity/types/EntityMyRabbit.java @@ -98,7 +98,7 @@ public void onLivingUpdate() { if (this.onGround && getNavigation().l() != null && jumpDelay-- <= 0) { getControllerJump().a(); jumpDelay = (this.random.nextInt(10) + 10); - if (getTarget() != null) { + if (getMyPetTarget() != null) { jumpDelay /= 3; } this.world.broadcastEntityEffect(this, (byte) 1); diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/CraftMyPet.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/CraftMyPet.java index e35988e647..fdb186bd56 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/CraftMyPet.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/CraftMyPet.java @@ -165,7 +165,7 @@ public void forgetTarget() { @Override public void setTarget(LivingEntity target, TargetPriority priority) { - getHandle().setTarget(target, priority); + getHandle().setMyPetTarget(target, priority); } @Override diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/attack/MeleeAttack.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/attack/MeleeAttack.java index 490a580be2..bb7628cd9c 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/attack/MeleeAttack.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/attack/MeleeAttack.java @@ -59,7 +59,7 @@ public boolean shouldStart() { if (!this.petEntity.hasTarget()) { return false; } - EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (targetEntity instanceof EntityArmorStand) { return false; @@ -93,7 +93,7 @@ public boolean shouldStart() { public boolean shouldFinish() { if (!this.petEntity.hasTarget() || !this.petEntity.canMove()) { return true; - } else if (this.targetEntity.getBukkitEntity() != this.petEntity.getTarget()) { + } else if (this.targetEntity.getBukkitEntity() != this.petEntity.getMyPetTarget()) { return true; } if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.g(targetEntity.locX(), targetEntity.getBoundingBox().minY, targetEntity.locZ()) >= 20) { diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/attack/RangedAttack.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/attack/RangedAttack.java index cee906cbc4..52439b54f9 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/attack/RangedAttack.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/attack/RangedAttack.java @@ -63,7 +63,7 @@ public boolean shouldStart() { return false; } - EntityLiving target = ((CraftLivingEntity) this.entityMyPet.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.entityMyPet.getMyPetTarget()).getHandle(); if (target instanceof EntityArmorStand) { return false; @@ -102,7 +102,7 @@ public boolean shouldFinish() { if (!entityMyPet.hasTarget() || myPet.getRangedDamage() <= 0 || !entityMyPet.canMove()) { return true; } - if (this.target.getBukkitEntity() != entityMyPet.getTarget()) { + if (this.target.getBukkitEntity() != entityMyPet.getMyPetTarget()) { return true; } double meleeDamage = myPet.getDamage(); diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/EatGrass.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/EatGrass.java index a203ed0dc9..4a86b9f8c8 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/EatGrass.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/EatGrass.java @@ -52,7 +52,7 @@ public boolean shouldStart() { return false; } else if (entityMySheep.getRandom().nextInt(1000) != 0) { return false; - } else if (this.entityMySheep.getTarget() != null && !this.entityMySheep.getTarget().isDead()) { + } else if (this.entityMySheep.getMyPetTarget() != null && !this.entityMySheep.getMyPetTarget().isDead()) { return false; } int blockLocX = MathHelper.floor(this.entityMySheep.locX()); diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/FollowOwner.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/FollowOwner.java index 239efcdc35..6f8c610dc6 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/FollowOwner.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/FollowOwner.java @@ -60,7 +60,7 @@ public boolean shouldStart() { } if (!this.petEntity.canMove()) { return false; - } else if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + } else if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } else if (this.petEntity.getOwner() == null) { return false; @@ -82,7 +82,7 @@ public boolean shouldFinish() { return true; } else if (!this.petEntity.canMove()) { return true; - } else if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + } else if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return true; } return false; diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/LookAtPlayer.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/LookAtPlayer.java index 8fc353acb6..2c6d3e590d 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/LookAtPlayer.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/LookAtPlayer.java @@ -51,7 +51,7 @@ public boolean shouldStart() { if (this.petEntity.getRandom().nextFloat() >= this.lookAtPlayerChance) { return false; } - if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } if (this.petEntity.isVehicle()) { diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/RandomLookaround.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/RandomLookaround.java index ce42e7cb2f..3c5af13de4 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/RandomLookaround.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/RandomLookaround.java @@ -38,7 +38,7 @@ public RandomLookaround(EntityMyPet petEntity) { @Override public boolean shouldStart() { - if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } if (this.petEntity.isVehicle()) { diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/Sprint.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/Sprint.java index 4c1b7c9c1e..827aee058d 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/Sprint.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/movement/Sprint.java @@ -59,7 +59,7 @@ public boolean shouldStart() { return false; } - EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (!targetEntity.isAlive()) { return false; diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/BehaviorAggressiveTarget.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/BehaviorAggressiveTarget.java index 66c97faa60..b5e68f685b 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/BehaviorAggressiveTarget.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/BehaviorAggressiveTarget.java @@ -108,11 +108,11 @@ public boolean shouldStart() { public boolean shouldFinish() { if (!petEntity.canMove()) { return true; - } else if (petEntity.getTarget() == null) { + } else if (petEntity.getMyPetTarget() == null) { return true; } - EntityLiving target = ((CraftLivingEntity) petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) petEntity.getMyPetTarget()).getHandle(); if (!target.isAlive()) { return true; @@ -134,7 +134,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Aggressive); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Aggressive); } @Override diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/BehaviorDuelTarget.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/BehaviorDuelTarget.java index a354f21753..a6ca578774 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/BehaviorDuelTarget.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/BehaviorDuelTarget.java @@ -100,7 +100,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); Behavior behaviorSkill = myPet.getSkills().get(Behavior.class); if (behaviorSkill.getBehavior() != BehaviorMode.Duel) { @@ -119,7 +119,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget(this.target.getBukkitEntity(), TargetPriority.Duel); + petEntity.setMyPetTarget(this.target.getBukkitEntity(), TargetPriority.Duel); setDuelOpponent(this.target); if (target.getTargetSelector().hasGoal("DuelTarget")) { BehaviorDuelTarget duelGoal = (BehaviorDuelTarget) target.getTargetSelector().getGoal("DuelTarget"); diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/BehaviorFarmTarget.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/BehaviorFarmTarget.java index f994fc287b..af86e12062 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/BehaviorFarmTarget.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/BehaviorFarmTarget.java @@ -88,7 +88,7 @@ public boolean shouldFinish() { if (!this.petEntity.hasTarget()) { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (!target.isAlive()) { return true; @@ -110,7 +110,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Farm); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Farm); } @Override diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/ControlTarget.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/ControlTarget.java index 1d86df1031..0c37d005cc 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/ControlTarget.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/ControlTarget.java @@ -130,7 +130,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (target.world != petEntity.world) { return true; @@ -144,7 +144,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Control); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Control); } @Override diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/HurtByTarget.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/HurtByTarget.java index fa04c3049f..5192311147 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/HurtByTarget.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/HurtByTarget.java @@ -99,7 +99,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (target.world != petEntity.world) { return true; @@ -113,7 +113,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.GetHurt); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.GetHurt); } @Override diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/OwnerHurtByTarget.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/OwnerHurtByTarget.java index ba258dfc84..0fe84deafa 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/OwnerHurtByTarget.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/ai/target/OwnerHurtByTarget.java @@ -126,7 +126,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (target.world != petEntity.world) { return true; @@ -140,7 +140,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.lastDamager.getBukkitEntity(), TargetPriority.OwnerGetsHurt); + petEntity.setMyPetTarget((LivingEntity) this.lastDamager.getBukkitEntity(), TargetPriority.OwnerGetsHurt); } @Override diff --git a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/types/EntityMyRabbit.java b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/types/EntityMyRabbit.java index c6ae649def..4963d26ab3 100644 --- a/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/types/EntityMyRabbit.java +++ b/modules/v1_16_R1/src/main/java/de/Keyle/MyPet/compat/v1_16_R1/entity/types/EntityMyRabbit.java @@ -101,7 +101,7 @@ public void onLivingUpdate() { if (this.onGround && getNavigation().k() != null && jumpDelay-- <= 0) { getControllerJump().jump(); jumpDelay = (this.random.nextInt(10) + 10); - if (getTarget() != null) { + if (getMyPetTarget() != null) { jumpDelay /= 3; } this.world.broadcastEntityEffect(this, (byte) 1); diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/CraftMyPet.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/CraftMyPet.java index 8ff6b97072..b00b5ec047 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/CraftMyPet.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/CraftMyPet.java @@ -200,7 +200,7 @@ public void forgetTarget() { @Override public void setTarget(LivingEntity target, TargetPriority priority) { - getHandle().setTarget(target, priority); + getHandle().setMyPetTarget(target, priority); } @Override diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/EntityMyPet.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/EntityMyPet.java index a576994fea..c60e7f15a1 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/EntityMyPet.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/EntityMyPet.java @@ -20,13 +20,45 @@ package de.Keyle.MyPet.compat.v1_16_R3.entity; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_16_R3.attribute.CraftAttributeMap; +import org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_16_R3.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_16_R3.util.CraftChatMessage; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitRunnable; + import com.google.common.base.Preconditions; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.Util; import de.Keyle.MyPet.api.compat.ParticleCompat; import de.Keyle.MyPet.api.entity.EntitySize; -import de.Keyle.MyPet.api.entity.*; +import de.Keyle.MyPet.api.entity.JumpHelper; +import de.Keyle.MyPet.api.entity.MyPet; +import de.Keyle.MyPet.api.entity.MyPetBaby; +import de.Keyle.MyPet.api.entity.MyPetMinecraftEntity; +import de.Keyle.MyPet.api.entity.MyPetType; import de.Keyle.MyPet.api.entity.ai.AIGoalSelector; import de.Keyle.MyPet.api.entity.ai.navigation.AbstractNavigation; import de.Keyle.MyPet.api.entity.ai.target.TargetPriority; @@ -43,40 +75,57 @@ import de.Keyle.MyPet.compat.v1_16_R3.PlatformHelper; import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.attack.MeleeAttack; import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.attack.RangedAttack; +import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.movement.Control; import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.movement.Float; -import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.movement.*; +import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.movement.FollowOwner; +import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.movement.LookAtPlayer; +import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.movement.RandomLookaround; +import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.movement.Sit; +import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.movement.Sprint; import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.navigation.VanillaNavigation; -import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.target.*; +import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.target.BehaviorAggressiveTarget; +import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.target.BehaviorDuelTarget; +import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.target.BehaviorFarmTarget; +import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.target.ControlTarget; +import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.target.HurtByTarget; +import de.Keyle.MyPet.compat.v1_16_R3.entity.ai.target.OwnerHurtByTarget; import de.Keyle.MyPet.compat.v1_16_R3.entity.types.EntityMyHorse; import de.Keyle.MyPet.skill.skills.ControlImpl; import de.Keyle.MyPet.skill.skills.RideImpl; -import net.minecraft.server.v1_16_R3.*; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_16_R3.attribute.CraftAttributeMap; -import org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_16_R3.event.CraftEventFactory; -import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack; -import org.bukkit.craftbukkit.v1_16_R3.util.CraftChatMessage; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.scheduler.BukkitRunnable; - -import java.lang.reflect.Field; -import java.math.BigDecimal; -import java.util.List; +import net.minecraft.server.v1_16_R3.AttributeMapBase; +import net.minecraft.server.v1_16_R3.AttributeProvider; +import net.minecraft.server.v1_16_R3.AxisAlignedBB; +import net.minecraft.server.v1_16_R3.BlockPosition; +import net.minecraft.server.v1_16_R3.DamageSource; +import net.minecraft.server.v1_16_R3.DataWatcherObject; +import net.minecraft.server.v1_16_R3.Entity; +import net.minecraft.server.v1_16_R3.EntityHuman; +import net.minecraft.server.v1_16_R3.EntityInsentient; +import net.minecraft.server.v1_16_R3.EntityLiving; +import net.minecraft.server.v1_16_R3.EntityPlayer; +import net.minecraft.server.v1_16_R3.EntityPose; +import net.minecraft.server.v1_16_R3.EntityTypes; +import net.minecraft.server.v1_16_R3.EnumHand; +import net.minecraft.server.v1_16_R3.EnumInteractionResult; +import net.minecraft.server.v1_16_R3.EnumMoveType; +import net.minecraft.server.v1_16_R3.GenericAttributes; +import net.minecraft.server.v1_16_R3.IBlockData; +import net.minecraft.server.v1_16_R3.IChatBaseComponent; +import net.minecraft.server.v1_16_R3.IJumpable; +import net.minecraft.server.v1_16_R3.IRegistry; +import net.minecraft.server.v1_16_R3.ItemStack; +import net.minecraft.server.v1_16_R3.Items; +import net.minecraft.server.v1_16_R3.MathHelper; +import net.minecraft.server.v1_16_R3.MinecraftKey; +import net.minecraft.server.v1_16_R3.NBTTagCompound; +import net.minecraft.server.v1_16_R3.PacketPlayOutAttachEntity; +import net.minecraft.server.v1_16_R3.PacketPlayOutNamedSoundEffect; +import net.minecraft.server.v1_16_R3.PotionUtil; +import net.minecraft.server.v1_16_R3.SoundCategory; +import net.minecraft.server.v1_16_R3.SoundEffect; +import net.minecraft.server.v1_16_R3.TagsFluid; +import net.minecraft.server.v1_16_R3.Vec3D; +import net.minecraft.server.v1_16_R3.World; public abstract class EntityMyPet extends EntityInsentient implements MyPetMinecraftEntity { diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/EntityRegistry.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/EntityRegistry.java index 04892176fe..c652587cab 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/EntityRegistry.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/EntityRegistry.java @@ -20,8 +20,19 @@ package de.Keyle.MyPet.compat.v1_16_R3.entity; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_16_R3.CraftWorld; +import org.bukkit.event.entity.CreatureSpawnEvent; + import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Util; import de.Keyle.MyPet.api.entity.MyPet; @@ -30,16 +41,15 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.api.util.ReflectionUtil; import lombok.SneakyThrows; -import net.minecraft.server.v1_16_R3.*; -import org.bukkit.ChatColor; -import org.bukkit.craftbukkit.v1_16_R3.CraftWorld; -import org.bukkit.event.entity.CreatureSpawnEvent; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; +import net.minecraft.server.v1_16_R3.EntityLiving; +import net.minecraft.server.v1_16_R3.EntitySize; +import net.minecraft.server.v1_16_R3.EntityTypes; +import net.minecraft.server.v1_16_R3.EnumCreatureType; +import net.minecraft.server.v1_16_R3.IRegistry; +import net.minecraft.server.v1_16_R3.MinecraftKey; +import net.minecraft.server.v1_16_R3.RegistryBlocks; +import net.minecraft.server.v1_16_R3.RegistryMaterials; +import net.minecraft.server.v1_16_R3.World; @Compat("v1_16_R3") public class EntityRegistry extends de.Keyle.MyPet.api.entity.EntityRegistry { diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/attack/MeleeAttack.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/attack/MeleeAttack.java index 892bb96d0b..8d8950d61b 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/attack/MeleeAttack.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/attack/MeleeAttack.java @@ -59,7 +59,7 @@ public boolean shouldStart() { if (!this.petEntity.hasTarget()) { return false; } - EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (targetEntity instanceof EntityArmorStand) { return false; @@ -93,7 +93,7 @@ public boolean shouldStart() { public boolean shouldFinish() { if (!this.petEntity.hasTarget() || !this.petEntity.canMove()) { return true; - } else if (this.targetEntity.getBukkitEntity() != this.petEntity.getTarget()) { + } else if (this.targetEntity.getBukkitEntity() != this.petEntity.getMyPetTarget()) { return true; } if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.h(targetEntity.locX(), targetEntity.getBoundingBox().minY, targetEntity.locZ()) >= 20) { diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/attack/RangedAttack.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/attack/RangedAttack.java index 059553dfac..2366cca82f 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/attack/RangedAttack.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/attack/RangedAttack.java @@ -63,7 +63,7 @@ public boolean shouldStart() { return false; } - EntityLiving target = ((CraftLivingEntity) this.entityMyPet.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.entityMyPet.getMyPetTarget()).getHandle(); if (target instanceof EntityArmorStand) { return false; @@ -102,7 +102,7 @@ public boolean shouldFinish() { if (!entityMyPet.hasTarget() || myPet.getRangedDamage() <= 0 || !entityMyPet.canMove()) { return true; } - if (this.target.getBukkitEntity() != entityMyPet.getTarget()) { + if (this.target.getBukkitEntity() != entityMyPet.getMyPetTarget()) { return true; } double meleeDamage = myPet.getDamage(); diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/EatGrass.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/EatGrass.java index 6bc90d5069..0b03f7c049 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/EatGrass.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/EatGrass.java @@ -52,7 +52,7 @@ public boolean shouldStart() { return false; } else if (entityMySheep.getRandom().nextInt(1000) != 0) { return false; - } else if (this.entityMySheep.getTarget() != null && !this.entityMySheep.getTarget().isDead()) { + } else if (this.entityMySheep.getMyPetTarget() != null && !this.entityMySheep.getMyPetTarget().isDead()) { return false; } int blockLocX = MathHelper.floor(this.entityMySheep.locX()); diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/FollowOwner.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/FollowOwner.java index 5d823ab420..7089ec8fc4 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/FollowOwner.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/FollowOwner.java @@ -60,7 +60,7 @@ public boolean shouldStart() { } if (!this.petEntity.canMove()) { return false; - } else if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + } else if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } else if (this.petEntity.getOwner() == null) { return false; @@ -79,7 +79,7 @@ public boolean shouldFinish() { return true; } else if (!this.petEntity.canMove()) { return true; - } else return this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead(); + } else return this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead(); } @Override diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/LookAtPlayer.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/LookAtPlayer.java index a40055f550..f64f1db0ac 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/LookAtPlayer.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/LookAtPlayer.java @@ -51,7 +51,7 @@ public boolean shouldStart() { if (this.petEntity.getRandom().nextFloat() >= this.lookAtPlayerChance) { return false; } - if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } if (this.petEntity.isVehicle()) { diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/RandomLookaround.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/RandomLookaround.java index 62e4c205c7..bc0ebb5636 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/RandomLookaround.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/RandomLookaround.java @@ -38,7 +38,7 @@ public RandomLookaround(EntityMyPet petEntity) { @Override public boolean shouldStart() { - if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } if (this.petEntity.isVehicle()) { diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/Sprint.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/Sprint.java index b4df44a528..ca10482be8 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/Sprint.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/movement/Sprint.java @@ -59,7 +59,7 @@ public boolean shouldStart() { return false; } - EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (!targetEntity.isAlive()) { return false; diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/BehaviorAggressiveTarget.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/BehaviorAggressiveTarget.java index 071426fb68..67bb7da590 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/BehaviorAggressiveTarget.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/BehaviorAggressiveTarget.java @@ -108,11 +108,11 @@ public boolean shouldStart() { public boolean shouldFinish() { if (!petEntity.canMove()) { return true; - } else if (petEntity.getTarget() == null) { + } else if (petEntity.getMyPetTarget() == null) { return true; } - EntityLiving target = ((CraftLivingEntity) petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) petEntity.getMyPetTarget()).getHandle(); if (!target.isAlive()) { return true; @@ -131,7 +131,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Aggressive); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Aggressive); } @Override diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/BehaviorDuelTarget.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/BehaviorDuelTarget.java index 1af0d44d10..f478c0089c 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/BehaviorDuelTarget.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/BehaviorDuelTarget.java @@ -100,7 +100,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); Behavior behaviorSkill = myPet.getSkills().get(Behavior.class); if (behaviorSkill.getBehavior() != BehaviorMode.Duel) { @@ -116,7 +116,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget(this.target.getBukkitEntity(), TargetPriority.Duel); + petEntity.setMyPetTarget(this.target.getBukkitEntity(), TargetPriority.Duel); setDuelOpponent(this.target); if (target.getTargetSelector().hasGoal("DuelTarget")) { BehaviorDuelTarget duelGoal = (BehaviorDuelTarget) target.getTargetSelector().getGoal("DuelTarget"); diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/BehaviorFarmTarget.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/BehaviorFarmTarget.java index a05f0cc8c7..8230e4a1fa 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/BehaviorFarmTarget.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/BehaviorFarmTarget.java @@ -88,7 +88,7 @@ public boolean shouldFinish() { if (!this.petEntity.hasTarget()) { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (!target.isAlive()) { return true; @@ -107,7 +107,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Farm); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Farm); } @Override diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/ControlTarget.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/ControlTarget.java index 2e12e3e778..88c8c21825 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/ControlTarget.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/ControlTarget.java @@ -20,6 +20,11 @@ package de.Keyle.MyPet.compat.v1_16_R3.entity.ai.target; +import org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.ai.AIGoal; @@ -33,10 +38,6 @@ import net.minecraft.server.v1_16_R3.EntityLiving; import net.minecraft.server.v1_16_R3.EntityPlayer; import net.minecraft.server.v1_16_R3.EntityTameableAnimal; -import org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; @Compat("v1_16_R3") public class ControlTarget implements AIGoal { @@ -130,7 +131,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (target.world != petEntity.world) { return true; @@ -141,7 +142,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Control); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Control); } @Override diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/HurtByTarget.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/HurtByTarget.java index 5603928f06..b8cbc622cb 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/HurtByTarget.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/HurtByTarget.java @@ -99,7 +99,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (target.world != petEntity.world) { return true; @@ -110,7 +110,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.GetHurt); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.GetHurt); } @Override diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/OwnerHurtByTarget.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/OwnerHurtByTarget.java index a780570022..c2370912c8 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/OwnerHurtByTarget.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/ai/target/OwnerHurtByTarget.java @@ -124,7 +124,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (target.world != petEntity.world) { return true; @@ -135,7 +135,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.lastDamager.getBukkitEntity(), TargetPriority.OwnerGetsHurt); + petEntity.setMyPetTarget((LivingEntity) this.lastDamager.getBukkitEntity(), TargetPriority.OwnerGetsHurt); } @Override diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/types/EntityMyRabbit.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/types/EntityMyRabbit.java index f35a00a4ac..442c291a1a 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/types/EntityMyRabbit.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/entity/types/EntityMyRabbit.java @@ -101,7 +101,7 @@ public void onLivingUpdate() { if (this.onGround && getNavigation().k() != null && jumpDelay-- <= 0) { getControllerJump().jump(); jumpDelay = (this.random.nextInt(10) + 10); - if (getTarget() != null) { + if (getMyPetTarget() != null) { jumpDelay /= 3; } this.world.broadcastEntityEffect(this, (byte) 1); diff --git a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/skill/skills/ranged/nms/MyPetArrow.java b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/skill/skills/ranged/nms/MyPetArrow.java index 5db0054963..6985ecace0 100644 --- a/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/skill/skills/ranged/nms/MyPetArrow.java +++ b/modules/v1_16_R3/src/main/java/de/Keyle/MyPet/compat/v1_16_R3/skill/skills/ranged/nms/MyPetArrow.java @@ -24,7 +24,12 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_16_R3.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_16_R3.skill.skills.ranged.bukkit.CraftMyPetArrow; -import net.minecraft.server.v1_16_R3.*; +import net.minecraft.server.v1_16_R3.DamageSource; +import net.minecraft.server.v1_16_R3.EntityTippedArrow; +import net.minecraft.server.v1_16_R3.ItemStack; +import net.minecraft.server.v1_16_R3.Items; +import net.minecraft.server.v1_16_R3.NBTTagCompound; +import net.minecraft.server.v1_16_R3.World; @Compat("v1_16_R3") public class MyPetArrow extends EntityTippedArrow implements EntityMyPetProjectile { diff --git a/modules/v1_17_R1/pom.xml b/modules/v1_17_R1/pom.xml index 0c0eacdd5a..f7123d83f7 100644 --- a/modules/v1_17_R1/pom.xml +++ b/modules/v1_17_R1/pom.xml @@ -79,9 +79,9 @@ remap-obf - org.spigotmc:minecraft-server:1.17-R0.1-SNAPSHOT:txt:maps-mojang + org.spigotmc:minecraft-server:1.17.1-R0.1-SNAPSHOT:txt:maps-mojang true - org.spigotmc:spigot:1.17-R0.1-SNAPSHOT:jar:remapped-mojang + org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT:jar:remapped-mojang true remapped-obf @@ -94,8 +94,8 @@ remap-spigot ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:1.17-R0.1-SNAPSHOT:csrg:maps-spigot - org.spigotmc:spigot:1.17-R0.1-SNAPSHOT:jar:remapped-obf + org.spigotmc:minecraft-server:1.17.1-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT:jar:remapped-obf diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/PlatformHelper.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/PlatformHelper.java index 14ec352a9c..83828c58dc 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/PlatformHelper.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/PlatformHelper.java @@ -39,7 +39,6 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Villager; -import org.bukkit.entity.WanderingTrader; import org.bukkit.entity.Zombie; import com.mojang.brigadier.StringReader; @@ -55,56 +54,53 @@ import de.Keyle.MyPet.compat.v1_17_R1.util.inventory.ItemStackNBTConverter; import de.keyle.knbt.TagCompound; import net.minecraft.core.BlockPos; -import net.minecraft.core.IRegistry; -import net.minecraft.core.particles.Particle; -import net.minecraft.core.particles.ParticleParam; +import net.minecraft.core.Registry; +import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleType; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.chat.ChatMessage; -import net.minecraft.network.chat.ChatMessageType; -import net.minecraft.network.chat.IChatBaseComponent; -import net.minecraft.network.protocol.game.PacketPlayOutChat; -import net.minecraft.network.protocol.game.PacketPlayOutCollect; -import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect; -import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity; -import net.minecraft.network.protocol.game.PacketPlayOutWorldParticles; -import net.minecraft.resources.MinecraftKey; -import net.minecraft.server.level.ChunkProviderServer; -import net.minecraft.server.level.WorldServer; -import net.minecraft.sounds.SoundCategory; -import net.minecraft.sounds.SoundEffects; -import net.minecraft.util.MathHelper; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.ChatType; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; +import net.minecraft.network.protocol.game.ClientboundChatPacket; +import net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket; +import net.minecraft.network.protocol.game.ClientboundSoundPacket; +import net.minecraft.network.protocol.game.ClientboundTakeItemEntityPacket; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerChunkCache; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LightningBolt; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.EntityLightning; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.npc.EntityVillager; -import net.minecraft.world.entity.npc.EntityVillagerTrader; -import net.minecraft.world.entity.player.EntityHuman; -import net.minecraft.world.item.ItemAxe; -import net.minecraft.world.item.ItemBow; -import net.minecraft.world.item.ItemCarrotStick; -import net.minecraft.world.item.ItemCompass; -import net.minecraft.world.item.ItemCrossbow; -import net.minecraft.world.item.ItemFishingRod; -import net.minecraft.world.item.ItemHoe; -import net.minecraft.world.item.ItemPickaxe; -import net.minecraft.world.item.ItemShield; -import net.minecraft.world.item.ItemSign; -import net.minecraft.world.item.ItemSpade; +import net.minecraft.world.item.AxeItem; +import net.minecraft.world.item.BowItem; +import net.minecraft.world.item.CompassItem; +import net.minecraft.world.item.CrossbowItem; +import net.minecraft.world.item.FishingRodItem; +import net.minecraft.world.item.FoodOnAStickItem; +import net.minecraft.world.item.HoeItem; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.ItemSword; -import net.minecraft.world.item.ItemTrident; +import net.minecraft.world.item.PickaxeItem; +import net.minecraft.world.item.ShieldItem; +import net.minecraft.world.item.ShovelItem; +import net.minecraft.world.item.SignItem; +import net.minecraft.world.item.SwordItem; +import net.minecraft.world.item.TridentItem; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.AxisAlignedBB; +import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.shapes.VoxelShape; @Compat("v1_17_R1") public class PlatformHelper extends de.Keyle.MyPet.api.PlatformHelper { - private static final Method ENTITY_LIVING_cD = ReflectionUtil.getMethod(EntityLiving.class, "cT"); - private static final Method CHAT_MESSAGE_k = ReflectionUtil.getMethod(ChatMessage.class, "k"); + private static final Method ENTITY_LIVING_cD = ReflectionUtil.getMethod(net.minecraft.world.entity.LivingEntity.class, "cT"); + private static final Method CHAT_MESSAGE_k = ReflectionUtil.getMethod(TranslatableComponent.class, "k"); /** * @param location the {@link Location} around which players must be to see the effect @@ -118,33 +114,33 @@ public class PlatformHelper extends de.Keyle.MyPet.api.PlatformHelper { */ @Override public void playParticleEffect(Location location, String effectName, float offsetX, float offsetY, float offsetZ, float speed, int count, int radius, de.Keyle.MyPet.api.compat.Compat data) { - Particle effect = IRegistry.ab.get(new MinecraftKey(effectName)); + ParticleType effect = Registry.PARTICLE_TYPE.get(new ResourceLocation(effectName)); Validate.notNull(location, "Location cannot be null"); Validate.notNull(effect, "Effect cannot be null"); Validate.notNull(location.getWorld(), "World cannot be null"); - ParticleParam particle = null; + ParticleOptions particle = null; - if (effect.d() != null && data != null) { + if (effect.getDeserializer() != null && data != null) { try { - particle = effect.d().b(effect, new StringReader(" " + data.get().toString())); + particle = effect.getDeserializer().fromCommand(effect, new StringReader(" " + data.get().toString())); } catch (CommandSyntaxException e) { e.printStackTrace(); } - } else if (effect instanceof ParticleType) { - particle = (ParticleType) effect; + } else if (effect instanceof SimpleParticleType) { + particle = (SimpleParticleType) effect; } if (particle == null) { return; } - PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particle, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count); + ClientboundLevelParticlesPacket packet = new ClientboundLevelParticlesPacket(particle, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count); radius = radius * radius; for (Player player : location.getWorld().getPlayers()) { if ((int) MyPetApi.getPlatformHelper().distanceSquared(player.getLocation(), location) <= radius) { - ((CraftPlayer) player).getHandle().b.sendPacket(packet); + ((CraftPlayer) player).getHandle().connection.send(packet); } } @@ -162,69 +158,69 @@ public void playParticleEffect(Location location, String effectName, float offse */ @Override public void playParticleEffect(Player player, Location location, String effectName, float offsetX, float offsetY, float offsetZ, float speed, int count, int radius, de.Keyle.MyPet.api.compat.Compat data) { - Particle effect = IRegistry.ab.get(new MinecraftKey(effectName)); + ParticleType effect = Registry.PARTICLE_TYPE.get(new ResourceLocation(effectName)); Validate.notNull(location, "Location cannot be null"); Validate.notNull(effect, "Effect cannot be null"); Validate.notNull(location.getWorld(), "World cannot be null"); - ParticleParam particle = null; + ParticleOptions particle = null; - if (effect.d() != null && data != null) { + if (effect.getDeserializer() != null && data != null) { try { - particle = effect.d().b(effect, new StringReader(" " + data.get().toString())); + particle = effect.getDeserializer().fromCommand(effect, new StringReader(" " + data.get().toString())); } catch (CommandSyntaxException e) { e.printStackTrace(); } - } else if (effect instanceof ParticleType) { - particle = (ParticleType) effect; + } else if (effect instanceof SimpleParticleType) { + particle = (SimpleParticleType) effect; } if (particle == null) { return; } - PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particle, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count); + ClientboundLevelParticlesPacket packet = new ClientboundLevelParticlesPacket(particle, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count); if (MyPetApi.getPlatformHelper().distanceSquared(player.getLocation(), location) <= radius) { - ((CraftPlayer) player).getHandle().b.sendPacket(packet); + ((CraftPlayer) player).getHandle().connection.send(packet); } } @Override public boolean canSpawn(Location loc, MyPetMinecraftEntity entity) { - return canSpawn(loc, ((EntityLiving) entity).getBoundingBox()); + return canSpawn(loc, ((net.minecraft.world.entity.LivingEntity) entity).getBoundingBox()); } - public Boolean canSpawn(Location loc, AxisAlignedBB bb) { - net.minecraft.world.level.World mcWorld = ((CraftWorld) loc.getWorld()).getHandle(); - return getBlockBBsInBB(mcWorld, bb).isEmpty() && !mcWorld.containsLiquid(bb); + public Boolean canSpawn(Location loc, AABB bb) { + net.minecraft.world.level.Level mcWorld = ((CraftWorld) loc.getWorld()).getHandle(); + return getBlockBBsInBB(mcWorld, bb).isEmpty() && !mcWorld.containsAnyLiquid(bb); } - public List getBlockBBsInBB(net.minecraft.world.level.Level world, AxisAlignedBB axisalignedbb) { + public List getBlockBBsInBB(net.minecraft.world.level.Level world, AABB axisalignedbb) { UnsafeList unsafeList = new UnsafeList(); - int minX = MathHelper.floor(axisalignedbb.a); - int maxX = (int) Math.ceil(axisalignedbb.d); - int minY = MathHelper.floor(axisalignedbb.b); - int maxY = (int) Math.ceil(axisalignedbb.e); - int minZ = MathHelper.floor(axisalignedbb.c); - int maxZ = (int) Math.ceil(axisalignedbb.f); + int minX = Mth.floor(axisalignedbb.minX); + int maxX = (int) Math.ceil(axisalignedbb.maxX); + int minY = Mth.floor(axisalignedbb.minY); + int maxY = (int) Math.ceil(axisalignedbb.maxY); + int minZ = Mth.floor(axisalignedbb.minZ); + int maxZ = (int) Math.ceil(axisalignedbb.maxZ); VoxelShape vec3d; boolean isEmpty; for (int x = minX; x <= maxX; x++) { for (int z = minZ; z <= maxZ; z++) { - if (((ChunkProviderServer) world.getChunkProvider()).isLoaded(x >> 4, z >> 4)) { + if (((ServerChunkCache) world.getChunkSource()).hasChunk(x >> 4, z >> 4)) { for (int y = minY - 1; y <= maxY; y++) { BlockPos bp = new BlockPos(x, y, z); - BlockState blockData = world.getType(bp); + BlockState blockData = world.getBlockState(bp); if (blockData != null && blockData.getMaterial().isSolid()) { vec3d = blockData.getCollisionShape(world, bp); isEmpty = vec3d.isEmpty(); if (!isEmpty) { - for (AxisAlignedBB bb : vec3d.toList()) { - if (bb.a(bp).c(axisalignedbb)) { + for (AABB bb : vec3d.toAabbs()) { + if (bb.move(bp).intersects(axisalignedbb)) { unsafeList.add(bb); } } @@ -249,12 +245,12 @@ public String getPlayerLanguage(Player player) { @Override public TagCompound entityToTag(Entity bukkitEntity) { net.minecraft.world.entity.Entity entity = ((CraftEntity) bukkitEntity).getHandle(); - NBTTagCompound vanillaNBT = new NBTTagCompound(); + CompoundTag vanillaNBT = new CompoundTag(); - if (entity instanceof EntityLiving) { - ((EntityLiving) entity).saveData(vanillaNBT); + if (entity instanceof net.minecraft.world.entity.LivingEntity) { + ((net.minecraft.world.entity.LivingEntity) entity).addAdditionalSaveData(vanillaNBT); } else { - Method b = ReflectionUtil.getMethod(entity.getClass(), "b", NBTTagCompound.class); + Method b = ReflectionUtil.getMethod(entity.getClass(), "b", CompoundTag.class); try { b.invoke(entity, vanillaNBT); } catch (IllegalAccessException | InvocationTargetException e) { @@ -268,14 +264,14 @@ public TagCompound entityToTag(Entity bukkitEntity) { @Override public void applyTagToEntity(TagCompound tag, Entity bukkitEntity) { net.minecraft.world.entity.Entity entity = ((CraftEntity) bukkitEntity).getHandle(); - NBTTagCompound vanillaNBT = (NBTTagCompound) ItemStackNBTConverter.compoundToVanillaCompound(tag); + CompoundTag vanillaNBT = (CompoundTag) ItemStackNBTConverter.compoundToVanillaCompound(tag); if (vanillaNBT != null) { if (bukkitEntity instanceof Villager) { - EntityVillager villager = (EntityVillager) entity; - villager.a(vanillaNBT); - } else if (bukkitEntity instanceof WanderingTrader) { - EntityVillagerTrader villager = (EntityVillagerTrader) entity; - villager.saveData(vanillaNBT); + net.minecraft.world.entity.npc.Villager villager = (net.minecraft.world.entity.npc.Villager) entity; + villager.readAdditionalSaveData(vanillaNBT); + } else if (bukkitEntity instanceof net.minecraft.world.entity.npc.WanderingTrader) { + net.minecraft.world.entity.npc.WanderingTrader villager = (net.minecraft.world.entity.npc.WanderingTrader) entity; + villager.addAdditionalSaveData(vanillaNBT); } } } @@ -293,15 +289,15 @@ public org.bukkit.inventory.ItemStack compundToItemStack(TagCompound compound) { @Override public void sendMessageRaw(Player player, String message) { if (player instanceof CraftPlayer) { - ((CraftPlayer) player).getHandle().b.sendPacket(new PacketPlayOutChat(IChatBaseComponent.ChatSerializer.a(message), ChatMessageType.a, player.getUniqueId())); + ((CraftPlayer) player).getHandle().connection.send(new ClientboundChatPacket(Component.Serializer.fromJson(message), ChatType.CHAT, player.getUniqueId())); } } @Override public void sendMessageActionBar(Player player, String message) { if (player instanceof CraftPlayer) { - IChatBaseComponent cbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + Util.escapeJsonString(message) + "\"}"); - ((CraftPlayer) player).getHandle().b.sendPacket(new PacketPlayOutChat(cbc, ChatMessageType.c, player.getUniqueId())); + Component cbc = Component.Serializer.fromJson("{\"text\": \"" + Util.escapeJsonString(message) + "\"}"); + ((CraftPlayer) player).getHandle().connection.send(new ClientboundChatPacket(cbc, ChatType.GAME_INFO, player.getUniqueId())); } } @@ -311,9 +307,9 @@ public void addZombieTargetGoal(Zombie zombie) { @Override public boolean comparePlayerWithEntity(MyPetPlayer player, Object obj) { - if (obj instanceof EntityHuman && player != null && player.getPlayer() != null) { - EntityHuman entityHuman = (EntityHuman) obj; - return player.getPlayer().getUniqueId().equals(entityHuman.getUniqueID()); + if (obj instanceof net.minecraft.world.entity.player.Player && player != null && player.getPlayer() != null) { + net.minecraft.world.entity.player.Player entityHuman = (net.minecraft.world.entity.player.Player) obj; + return player.getPlayer().getUniqueId().equals(entityHuman.getUUID()); } return false; } @@ -324,31 +320,31 @@ public boolean isEquipment(org.bukkit.inventory.ItemStack itemStack) { ItemStack itemstack = CraftItemStack.asNMSCopy(itemStack); int slot = Mob.getEquipmentSlotForItem(itemstack).getFilterFlag(); if (slot == 0) { - if (itemstack.getItem() instanceof ItemSword) { + if (itemstack.getItem() instanceof SwordItem) { return true; - } else if (itemstack.getItem() instanceof ItemAxe) { + } else if (itemstack.getItem() instanceof AxeItem) { return true; - } else if (itemstack.getItem() instanceof ItemSpade) { + } else if (itemstack.getItem() instanceof ShovelItem) { return true; - } else if (itemstack.getItem() instanceof ItemHoe) { + } else if (itemstack.getItem() instanceof HoeItem) { return true; - } else if (itemstack.getItem() instanceof ItemPickaxe) { + } else if (itemstack.getItem() instanceof PickaxeItem) { return true; - } else if (itemstack.getItem() instanceof ItemBow) { + } else if (itemstack.getItem() instanceof BowItem) { return true; - } else if (itemstack.getItem() instanceof ItemShield) { + } else if (itemstack.getItem() instanceof ShieldItem) { return true; - } else if (itemstack.getItem() instanceof ItemTrident) { + } else if (itemstack.getItem() instanceof TridentItem) { return true; - } else if (itemstack.getItem() instanceof ItemFishingRod) { + } else if (itemstack.getItem() instanceof FishingRodItem) { return true; - } else if (itemstack.getItem() instanceof ItemCompass) { + } else if (itemstack.getItem() instanceof CompassItem) { return true; - } else if (itemstack.getItem() instanceof ItemCarrotStick) { + } else if (itemstack.getItem() instanceof FoodOnAStickItem) { return true; - } else if (itemstack.getItem() instanceof ItemSign) { + } else if (itemstack.getItem() instanceof SignItem) { return true; - } else return itemstack.getItem() instanceof ItemCrossbow; + } else return itemstack.getItem() instanceof CrossbowItem; } return true; } @@ -357,24 +353,24 @@ public boolean isEquipment(org.bukkit.inventory.ItemStack itemStack) { @Override public String getVanillaName(org.bukkit.inventory.ItemStack bukkitItemStack) { ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItemStack); - return itemStack.getItem().getName(); + return itemStack.getItem().getDescriptionId(); } @Override public void doPickupAnimation(Entity entity, Entity target) { int count = 1; if (target instanceof ItemEntity) { - count = ((ItemEntity) target).getItemStack().getCount(); + count = ((ItemEntity) target).getItem().getCount(); } for (Entity p : target.getNearbyEntities(10, 10, 10)) { if (p instanceof Player) { - ((CraftPlayer) p).getHandle().b.sendPacket(new PacketPlayOutCollect(target.getEntityId(), entity.getEntityId(), count)); + ((CraftPlayer) p).getHandle().connection.send(new ClientboundTakeItemEntityPacket(target.getEntityId(), entity.getEntityId(), count)); } } } @Override - public Entity getEntity(int id, Level world) { + public Entity getEntity(int id, World world) { net.minecraft.world.entity.Entity e = null; try { e = Bukkit.getScheduler().callSyncMethod(MyPetApi.getPlugin(), () -> @@ -396,35 +392,35 @@ public ItemStack asNmsItemStack(org.bukkit.inventory.ItemStack itemStack) { return CraftItemStack.asNMSCopy(itemStack); } - public net.minecraft.world.level.World getWorldNMS(Level world) { + public Level getWorldNMS(World world) { return ((CraftWorld) world).getHandle(); } @Override public void strikeLightning(Location loc, float distance) { - WorldServer world = ((CraftWorld) loc.getWorld()).getHandle(); - EntityLightning lightning = new EntityLightning(EntityTypes.U, world); - lightning.setEffect(true); - lightning.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), 0.0F, 0.0F); + ServerLevel world = ((CraftWorld) loc.getWorld()).getHandle(); + LightningBolt lightning = new LightningBolt(EntityType.LIGHTNING_BOLT, world); + lightning.setVisualOnly(true); + lightning.moveTo(loc.getX(), loc.getY(), loc.getZ(), 0.0F, 0.0F); world.getCraftServer() .getServer() .getPlayerList() - .sendPacketNearby(null, loc.getX(), loc.getY(), loc.getZ(), distance, world.getDimensionKey(), - new PacketPlayOutSpawnEntity(lightning)); + .broadcast(null, loc.getX(), loc.getY(), loc.getZ(), distance, world.dimension(), + new ClientboundAddEntityPacket(lightning)); world.getCraftServer() .getServer() .getPlayerList() - .sendPacketNearby(null, loc.getX(), loc.getY(), loc.getZ(), distance, world.getDimensionKey(), - new PacketPlayOutNamedSoundEffect(SoundEvents.jL, SoundCategory.d, loc.getX(), loc.getY(), loc.getZ(), distance, 1F)); + .broadcast(null, loc.getX(), loc.getY(), loc.getZ(), distance, world.dimension(), + new ClientboundSoundPacket(SoundEvents.LIGHTNING_BOLT_THUNDER, SoundSource.WEATHER, loc.getX(), loc.getY(), loc.getZ(), distance, 1F)); } @Override public String getLastDamageSource(LivingEntity e) { - EntityLiving el = ((CraftLivingEntity) e).getHandle(); - if (el.dW() == null) { + net.minecraft.world.entity.LivingEntity el = ((CraftLivingEntity) e).getHandle(); + if (el.getLastDamageSource() == null) { return null; } - return ((ChatMessage) el.dW().getLocalizedDeathMessage(el)).getKey(); + return ((TranslatableComponent) el.getLastDamageSource().getLocalizedDeathMessage(el)).getKey(); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPet.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPet.java index 5910db211e..b0be80a782 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPet.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPet.java @@ -23,6 +23,7 @@ import java.lang.reflect.Field; import java.math.BigDecimal; import java.util.List; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -91,7 +92,6 @@ import de.Keyle.MyPet.compat.v1_17_R1.entity.types.EntityMyHorse; import de.Keyle.MyPet.skill.skills.ControlImpl; import de.Keyle.MyPet.skill.skills.RideImpl; -import io.lumine.xikage.mythicmobs.utils.shadows.nbt.NBTTagCompound; import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; import net.minecraft.nbt.CompoundTag; @@ -100,21 +100,17 @@ import net.minecraft.network.protocol.game.ClientboundSoundPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.EntityPlayer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import net.minecraft.tags.FluidTags; -import net.minecraft.tags.TagsFluid; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityDimensions; -import net.minecraft.world.entity.EntityLiving; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.PlayerRideableJumping; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MoverType; @@ -123,16 +119,13 @@ 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.ai.attributes.GenericAttributes; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3; -import net.minecraft.world.phys.Vec3D; public abstract class EntityMyPet extends Mob implements MyPetMinecraftEntity { @@ -510,7 +503,7 @@ public void run() { } } }.runTaskLater(MyPetApi.getPlugin(), 5); - if (itemStack != null && itemStack.getItem() == Items.LEAD) { //TODO + if (itemStack != null && itemStack.getItem() == Items.LEAD) { ((ServerPlayer) entityhuman).connection.send(new ClientboundSetEntityLinkPacket(this, null)); } @@ -778,7 +771,7 @@ public float getSoundSpeed() { /** * Returns the sound that is played when the MyPet dies */ - protected abstract String getDeathSound(); //TODO + protected abstract String getMyPetDeathSound(); public void playPetStepSound() { } @@ -948,7 +941,7 @@ public EntityDimensions getDimensions(Pose entitypose) { * Allows handlePlayerInteraction() to * be fired when a lead is used */ - @Override //TODO + @Override public boolean canBeLeashed(net.minecraft.world.entity.player.Player entityhuman) { return false; } @@ -1005,9 +998,9 @@ protected SoundEvent getHurtSound(DamageSource damagesource) { * Returns the sound that is played when the MyPet dies */ @Override - protected SoundEvent getDeathSound() { //TODO + protected SoundEvent getDeathSound() { try { - return Registry.SOUND_EVENT.get(new ResourceLocation(getDeathSound())); + return Registry.SOUND_EVENT.get(new ResourceLocation(getMyPetDeathSound())); } catch (Exception e) { e.printStackTrace(); } @@ -1034,36 +1027,36 @@ public void aiStep() { //Speed-Probleme? if (this.isAlwaysTicking()) { this.lerpX = 0; - this.d(this.getX(), this.getY(), this.getZ()); + this.setPacketCoordinates(this.getX(), this.getY(), this.getZ()); } if (this.lerpX > 0) { double newX = this.getX() + (this.useItemRemaining - this.getX()) / this.lerpX; double newY = this.getY() + (this.fallFlyTicks - this.getY()) / this.lerpX; double newZ = this.getZ() + (this.autoSpinAttackTicks - this.getZ()) / this.lerpX; - double d3 = Mth.frac(this.az - (double) this.getYRot()); //TODO this area might be wrong in general (aR, aZ, aT) + double d3 = Mth.frac(this.animationSpeed - (double) this.getYRot()); //TODO animationSpeed might be wrong (was az which might have been wrong...) this.setYRot((float) ((double) this.getYRot() + d3 / this.lerpX)); this.setXRot((float) ((double) this.getXRot() + (this.animationPosition - (double) this.getXRot()) / this.lerpX)); --this.lerpX; this.setPos(newX, newY, newZ); this.setRot(this.getYRot(), this.getXRot()); } else { - this.setDeltaMovement(this.getDeltaMovement().a(0.98D)); + this.setDeltaMovement(this.getDeltaMovement().scale(0.98D)); } - Vec3D vec3d = this.getDeltaMovement(); - double motX = vec3d.getX(); - double motY = vec3d.getY(); - double motZ = vec3d.getZ(); + Vec3 vec3d = this.getDeltaMovement(); + double motX = vec3d.x(); + double motY = vec3d.y(); + double motZ = vec3d.z(); - if (Math.abs(vec3d.getX()) < 0.003D) { + if (Math.abs(vec3d.x()) < 0.003D) { motX = 0.0D; } - if (Math.abs(vec3d.getY()) < 0.003D) { + if (Math.abs(vec3d.y()) < 0.003D) { motY = 0.0D; } - if (Math.abs(vec3d.getZ()) < 0.003D) { + if (Math.abs(vec3d.z()) < 0.003D) { motZ = 0.0D; } @@ -1075,17 +1068,17 @@ public void aiStep() { //Speed-Probleme? double d7; if (this.isInLava()) { - d7 = this.b(FluidTags.LAVA);//TODO + d7 = this.getFluidHeight(FluidTags.LAVA); } else { - d7 = this.b(FluidTags.WATER); + d7 = this.getFluidHeight(FluidTags.WATER); } boolean flag = this.isInWater() && d7 > 0.0D; double d8 = this.getFluidJumpThreshold(); if (flag && (!this.onGround || d7 > d8)) { - this.c(FluidTags.WATER); - } else if (this.aX() && (!this.onGround || d7 > d8)) { - this.c(FluidTags.LAVA); + this.jumpInLiquid(FluidTags.WATER); + } else if (this.isInLava() && (!this.onGround || d7 > d8)) { + this.jumpInLiquid(FluidTags.LAVA); } else if ((this.onGround || flag && d7 <= d8) && this.jumpDelay == 0) { this.jumpFromGround(); this.jumpDelay = 10; @@ -1094,11 +1087,11 @@ public void aiStep() { //Speed-Probleme? this.jumpDelay = 0; } - this.aR *= 0.98F; - this.aT *= 0.98F; + this.animationSpeedOld *= 0.98F; + this.animationPosition *= 0.98F; // this.n(); //no Elytra flight - this.f(new Vec3(this.aR, this.aZ, this.aT)); + this.travel(new Vec3(this.animationSpeedOld, this.yHeadRot, this.animationPosition)); this.pushEntities(); } @@ -1233,9 +1226,10 @@ public int calculateFallDamage(float f, float f1) { /** * -> travel */ - public void f(Vec3 vec3d) { + @Override + public void travel(Vec3 vec3d) { if (!hasRider || !this.isVehicle()) { - g(vec3d); + super.travel(vec3d); return; } @@ -1263,7 +1257,6 @@ public void f(Vec3 vec3d) { setRot(this.getYRot(), this.getXRot()); this.oRun = (this.yBodyRot = this.getYRot()); - //TODO Got the right fields, now speed is something // get motion from passenger (player) double motionSideways = passenger.xxa; double motionForward = passenger.zza * 2; @@ -1364,9 +1357,9 @@ public void f(Vec3 vec3d) { } if (Configuration.HungerSystem.USE_HUNGER_SYSTEM && Configuration.Skilltree.Skill.Ride.HUNGER_PER_METER > 0) { - double dX = locX() - u; - double dY = Math.max(0, locY() - v); - double dZ = locZ() - w; + double dX = getX() - xo; + double dY = Math.max(0, getY() - yo); + double dZ = getZ() - zo; if (dX != 0 || dY != 0 || dZ != 0) { double distance = Math.sqrt(dX * dX + dY * dY + dZ * dZ); if (isFlying && rideSkill.getFlyLimit().getValue().doubleValue() > 0) { @@ -1374,8 +1367,8 @@ public void f(Vec3 vec3d) { } myPet.decreaseSaturation(Configuration.Skilltree.Skill.Ride.HUNGER_PER_METER * distance); double factor = Math.log10(myPet.getSaturation()) / 2; - getAttributeInstance(GenericAttributes.d).setValue((0.22222F * (1F + (rideSkill.getSpeedIncrease().getValue() / 100F))) * factor); - this.n((float) this.getAttributeInstance(GenericAttributes.d).getValue()); + getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue((0.22222F * (1F + (rideSkill.getSpeedIncrease().getValue() / 100F))) * factor); + this.setSpeed((float) this.getAttribute(Attributes.MOVEMENT_SPEED).getValue()); } } } @@ -1411,7 +1404,7 @@ protected SoundEvent getAmbientSound() { } @Override - protected void d(DamageSource damagesource) { //TODO Check LivingEntity! + protected void playHurtSound(DamageSource damagesource) { CraftEventFactory.callEntityDeathEvent(this); } @@ -1422,4 +1415,9 @@ public DamageSource getLastDamageSource() { } return super.getLastDamageSource(); } + + @Override + public UUID getUniqueID() { + return this.uuid; + } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPetPart.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPetPart.java index 0659968641..787eae3e1f 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPetPart.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityMyPetPart.java @@ -56,12 +56,11 @@ public boolean isPickable() { } @Override - public void load(CompoundTag nbtTagCompound) { + public void readAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override - public boolean save(CompoundTag nbtTagCompound) { - return true; + public void addAdditionalSaveData(CompoundTag nbtTagCompound) { } @Override @@ -70,7 +69,7 @@ public boolean hurt(DamageSource var1, float var2) { } @Override - public boolean q(Entity var1) { + public boolean is(Entity var1) { return this == var1 || this.owner == var1; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityRegistry.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityRegistry.java index 8b9be6b43a..757a685f76 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityRegistry.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/EntityRegistry.java @@ -42,6 +42,7 @@ import de.Keyle.MyPet.api.util.ReflectionUtil; import lombok.SneakyThrows; import net.minecraft.core.DefaultedRegistry; +import net.minecraft.core.MappedRegistry; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; @@ -150,7 +151,7 @@ protected void overwriteEntityID(EntityType types, int id, DefaultedRegistry clazz = map.getClass(); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/MeleeAttack.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/MeleeAttack.java index 63d7b717e0..8ad175aa20 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/MeleeAttack.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/MeleeAttack.java @@ -125,7 +125,7 @@ public boolean shouldFinish() { @Override public void start() { this.petEntity.getPetNavigation().getParameters().addSpeedModifier("MeleeAttack", walkSpeedModifier); - this.petEntity.getPetNavigation().navigateTo((LivingEntity) this.targetEntity.getBukkitEntity()); //TODO Location? + this.petEntity.getPetNavigation().navigateTo((LivingEntity) this.targetEntity.getBukkitEntity()); this.timeUntilNextNavigationUpdate = 0; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java index 64637a3869..54be8ccc5a 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/attack/RangedAttack.java @@ -40,11 +40,12 @@ import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetTrident; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.nms.MyPetWitherSkull; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.Mth; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.TamableAnimal; import net.minecraft.world.entity.decoration.ArmorStand; +import net.minecraft.world.entity.projectile.Arrow; import net.minecraft.world.level.Level; -import net.royawesome.jlibnoise.MathHelper; @Compat("v1_17_R1") public class RangedAttack implements AIGoal { @@ -84,7 +85,7 @@ public boolean shouldStart() { return false; } double meleeDamage = myPet.getDamage(); - if (meleeDamage > 0 && this.entityMyPet.h(target.getX(), target.getBoundingBox().minY, target.getZ()) < 4) { + if (meleeDamage > 0 && this.entityMyPet.distanceToSqr(target.getX(), target.getBoundingBox().minY, target.getZ()) < 4) { Ranged rangedSkill = myPet.getSkills().get(Ranged.class); if (meleeDamage > rangedSkill.getDamage().getValue().doubleValue()) { return false; @@ -121,7 +122,7 @@ public boolean shouldFinish() { return true; } double meleeDamage = myPet.getDamage(); - if (meleeDamage > 0 && this.entityMyPet.h(target.getX(), this.target.getBoundingBox().minY, target.getZ()) < 4) { + if (meleeDamage > 0 && this.entityMyPet.distanceToSqr(target.getX(), this.target.getBoundingBox().minY, target.getZ()) < 4) { Ranged rangedSkill = myPet.getSkills().get(Ranged.class); if (meleeDamage > rangedSkill.getDamage().getValue().doubleValue()) { return true; @@ -134,7 +135,7 @@ public boolean shouldFinish() { return true; } if (behaviorSkill.getBehavior() == Behavior.BehaviorMode.Raid) { - if (this.target instanceof TamableAnimal && ((TamableAnimal) this.target).isTamed()) { + if (this.target instanceof TamableAnimal && ((TamableAnimal) this.target).isTame()) { return true; } if (this.target instanceof EntityMyPet) { @@ -156,8 +157,8 @@ public void finish() { @Override public void tick() { - double distanceToTarget = this.entityMyPet.h(this.target.getX(), this.target.getBoundingBox().minY, this.target.getZ()); - boolean canSee = this.entityMyPet.getSensing().a(this.target); // a -> canSee + double distanceToTarget = this.entityMyPet.distanceToSqr(this.target.getX(), this.target.getBoundingBox().minY, this.target.getZ()); + boolean canSee = this.entityMyPet.getSensing().hasLineOfSight(this.target); if (canSee) { this.lastSeenTimer++; @@ -193,16 +194,16 @@ private Projectile getProjectile() { } public void shootProjectile(LivingEntity target, float damage, Projectile projectile) { - Level world = target.t; + Level world = target.level; double minY = this.target.getBoundingBox().minY; switch (projectile) { case Snowball: { MyPetSnowball snowball = new MyPetSnowball(world, entityMyPet); double distanceX = target.getX() - entityMyPet.getX(); - double distanceY = target.locY() + target.getHeadHeight() - 1.100000023841858D - snowball.locY(); + double distanceY = target.getY() + target.getEyeHeight() - 1.100000023841858D - snowball.getY(); double distanceZ = target.getZ() - entityMyPet.getZ(); - double distance20percent = MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2F; + double distance20percent = Mth.sqrt((float)(distanceX * distanceX + distanceZ * distanceZ)) * 0.2F; snowball.setDamage(damage); snowball.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1); entityMyPet.makeSound("entity.arrow.shoot", 0.5F, 0.4F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F)); @@ -212,9 +213,9 @@ public void shootProjectile(LivingEntity target, float damage, Projectile projec case Egg: { MyPetEgg egg = new MyPetEgg(world, entityMyPet); double distanceX = target.getX() - entityMyPet.getX(); - double distanceY = target.locY() + target.getHeadHeight() - 1.100000023841858D - egg.locY(); + double distanceY = target.getY() + target.getEyeHeight() - 1.100000023841858D - egg.getY(); double distanceZ = target.getZ() - entityMyPet.getZ(); - double distance20percent = MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2F; + double distance20percent = Mth.sqrt((float)(distanceX * distanceX + distanceZ * distanceZ)) * 0.2F; egg.setDamage(damage); egg.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1); entityMyPet.makeSound("entity.arrow.shoot", 0.5F, 0.4F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F)); @@ -223,10 +224,10 @@ public void shootProjectile(LivingEntity target, float damage, Projectile projec } case LargeFireball: { double distanceX = this.target.getX() - entityMyPet.getX(); - double distanceY = minY + (double) (this.target.getHeight() / 2.0F) - (0.5D + entityMyPet.locY() + (double) (entityMyPet.getHeight() / 2.0F)); + double distanceY = minY + (double) (this.target.getBbHeight() / 2.0F) - (0.5D + entityMyPet.getY() + (double) (entityMyPet.getBbHeight() / 2.0F)); double distanceZ = this.target.getZ() - entityMyPet.getZ(); MyPetLargeFireball largeFireball = new MyPetLargeFireball(world, entityMyPet, distanceX, distanceY, distanceZ); - largeFireball.setPositionRaw(largeFireball.getX(), (entityMyPet.locY() + entityMyPet.getHeight() / 2.0F + 0.5D), largeFireball.getZ()); + largeFireball.setPosRaw(largeFireball.getX(), (entityMyPet.getY() + entityMyPet.getBbHeight() / 2.0F + 0.5D), largeFireball.getZ()); largeFireball.setDamage(damage); world.addFreshEntity(largeFireball); entityMyPet.makeSound("entity.ghast.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F); @@ -234,10 +235,10 @@ public void shootProjectile(LivingEntity target, float damage, Projectile projec } case SmallFireball: { double distanceX = this.target.getX() - entityMyPet.getX(); - double distanceY = minY + (this.target.getHeight() / 2.0F) - (0.5D + entityMyPet.locY() + (entityMyPet.getHeight() / 2.0F)); + double distanceY = minY + (this.target.getBbHeight() / 2.0F) - (0.5D + entityMyPet.getY() + (entityMyPet.getBbHeight() / 2.0F)); double distanceZ = this.target.getZ() - entityMyPet.getZ(); MyPetSmallFireball smallFireball = new MyPetSmallFireball(world, entityMyPet, distanceX, distanceY, distanceZ); - smallFireball.setPositionRaw(smallFireball.getX(), (entityMyPet.locY() + entityMyPet.getHeight() / 2.0F + 0.5D), smallFireball.getZ()); + smallFireball.setPosRaw(smallFireball.getX(), (entityMyPet.getY() + entityMyPet.getBbHeight() / 2.0F + 0.5D), smallFireball.getZ()); smallFireball.setDamage(damage); world.addFreshEntity(smallFireball); entityMyPet.makeSound("entity.ghast.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F); @@ -245,10 +246,10 @@ public void shootProjectile(LivingEntity target, float damage, Projectile projec } case WitherSkull: { double distanceX = this.target.getX() - entityMyPet.getX(); - double distanceY = minY + (double) (this.target.getHeight() / 2.0F) - (0.5D + entityMyPet.locY() + (double) (entityMyPet.getHeight() / 2.0F)); + double distanceY = minY + (double) (this.target.getBbHeight() / 2.0F) - (0.5D + entityMyPet.getY() + (double) (entityMyPet.getBbHeight() / 2.0F)); double distanceZ = this.target.getZ() - entityMyPet.getZ(); MyPetWitherSkull witherSkull = new MyPetWitherSkull(world, entityMyPet, distanceX, distanceY, distanceZ); - witherSkull.setPositionRaw(witherSkull.getX(), (entityMyPet.locY() + entityMyPet.getHeight() / 2.0F + 0.5D), witherSkull.getZ()); + witherSkull.setPosRaw(witherSkull.getX(), (entityMyPet.getY() + entityMyPet.getBbHeight() / 2.0F + 0.5D), witherSkull.getZ()); witherSkull.setDamage(damage); world.addFreshEntity(witherSkull); entityMyPet.makeSound("entity.wither.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F); @@ -256,10 +257,10 @@ public void shootProjectile(LivingEntity target, float damage, Projectile projec } case DragonFireball: { double distanceX = this.target.getX() - entityMyPet.getX(); - double distanceY = minY + (double) (this.target.getHeight() / 2.0F) - (0.5D + entityMyPet.locY() + (double) (entityMyPet.getHeight() / 2.0F)); + double distanceY = minY + (double) (this.target.getBbHeight() / 2.0F) - (0.5D + entityMyPet.getY() + (double) (entityMyPet.getBbHeight() / 2.0F)); double distanceZ = this.target.getZ() - entityMyPet.getZ(); MyPetDragonFireball dragonFireball = new MyPetDragonFireball(world, entityMyPet, distanceX, distanceY, distanceZ); - dragonFireball.setPositionRaw(dragonFireball.getX(), (entityMyPet.locY() + entityMyPet.getHeight() / 2.0F + 0.5D), dragonFireball.getZ()); + dragonFireball.setPosRaw(dragonFireball.getX(), (entityMyPet.getY() + entityMyPet.getBbHeight() / 2.0F + 0.5D), dragonFireball.getZ()); dragonFireball.setDamage(damage); world.addFreshEntity(dragonFireball); entityMyPet.makeSound("entity.ender_dragon.shoot", 1.0F + entityMyPet.getRandom().nextFloat(), entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F); @@ -267,13 +268,13 @@ public void shootProjectile(LivingEntity target, float damage, Projectile projec } case Trident: { MyPetTrident trident = new MyPetTrident(world, entityMyPet); - trident.setDamage(damage); - trident.setCritical(false); + trident.setBaseDamage(damage); + trident.setCritArrow(false); entityMyPet.makeSound("item.trident.throw", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F)); double distanceX = target.getX() - entityMyPet.getX(); - double distanceY = target.locY() + target.getHeadHeight() - 1.100000023841858D - trident.locY(); + double distanceY = target.getY() + target.getEyeHeight() - 1.100000023841858D - trident.getY(); double distanceZ = target.getZ() - entityMyPet.getZ(); - double distance20percent = MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2F; + double distance20percent = Mth.sqrt((float)(distanceX * distanceX + distanceZ * distanceZ)) * 0.2F; trident.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1); world.addFreshEntity(trident); break; @@ -283,9 +284,9 @@ public void shootProjectile(LivingEntity target, float damage, Projectile projec enderPearl.setDamage(damage); entityMyPet.makeSound("entity.ender_pearl.throw", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F)); double distanceX = target.getX() - entityMyPet.getX(); - double distanceY = target.locY() + target.getHeadHeight() - 1.100000023841858D - enderPearl.locY(); + double distanceY = target.getY() + target.getEyeHeight() - 1.100000023841858D - enderPearl.getY(); double distanceZ = target.getZ() - entityMyPet.getZ(); - double distance20percent = MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2F; + double distance20percent = Mth.sqrt((float)(distanceX * distanceX + distanceZ * distanceZ)) * 0.2F; enderPearl.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1); world.addFreshEntity(enderPearl); break; @@ -295,23 +296,23 @@ public void shootProjectile(LivingEntity target, float damage, Projectile projec llamaSpit.setDamage(damage); entityMyPet.makeSound("entity.llama.spit", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F)); double distanceX = target.getX() - entityMyPet.getX(); - double distanceY = target.locY() + (target.getHeadHeight() / 3.0F) - llamaSpit.locY(); + double distanceY = target.getY() + (target.getEyeHeight() / 3.0F) - llamaSpit.getY(); double distanceZ = target.getZ() - entityMyPet.getZ(); - double distance20percent = MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2D; + double distance20percent = Mth.sqrt((float)(distanceX * distanceX + distanceZ * distanceZ)) * 0.2D; llamaSpit.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.5F, 10.0F); world.addFreshEntity(llamaSpit); break; } case Arrow: default: { - MyPetArrow arrow = new MyPetArrow(world, entityMyPet); - arrow.setDamage(damage); - arrow.setCritical(false); + Arrow arrow = new MyPetArrow(world, entityMyPet); + arrow.setBaseDamage(damage); + arrow.setCritArrow(false); entityMyPet.makeSound("entity.arrow.shoot", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F)); double distanceX = target.getX() - entityMyPet.getX(); - double distanceY = target.locY() + target.getHeadHeight() - 1.100000023841858D - arrow.locY(); + double distanceY = target.getY() + target.getEyeHeight() - 1.100000023841858D - arrow.getY(); double distanceZ = target.getZ() - entityMyPet.getZ(); - double distance20percent = MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2F; + double distance20percent = Mth.sqrt((float)(distanceX * distanceX + distanceZ * distanceZ)) * 0.2F; arrow.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1); world.addFreshEntity(arrow); break; diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java index c0d06f2ef0..6150d9a76e 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/EatGrass.java @@ -44,11 +44,11 @@ public class EatGrass implements AIGoal { private final Level world; int eatTicks = 0; - private static final Predicate GRASS = BlockStatePredicate.a(Blocks.aX); + private static final Predicate GRASS = BlockStatePredicate.forBlock(Blocks.GRASS); public EatGrass(EntityMySheep entityMySheep) { this.entityMySheep = entityMySheep; - this.world = entityMySheep.t; + this.world = entityMySheep.level; } @Override @@ -59,7 +59,7 @@ public boolean shouldStart() { return false; } else if (entityMySheep.getRandom().nextInt(1000) != 0) { return false; - } else if (this.entityMySheep.getTarget() != null && !this.entityMySheep.getTarget().isDead()) { + } else if (this.entityMySheep.getTarget() != null && !this.entityMySheep.getMyPetTarget().isDead()) { return false; } int blockLocX = Mth.floor(this.entityMySheep.getX()); @@ -68,7 +68,7 @@ public boolean shouldStart() { BlockPos blockposition = new BlockPos(blockLocX, blockLocY, blockLocZ); - return GRASS.test(this.world.getType(blockposition)) || this.world.getType(blockposition.down()).getBlock() == Blocks.aX; + return GRASS.test(this.world.getBlockState(blockposition)) || this.world.getBlockState(blockposition.down()).getBlock() == Blocks.GRASS; } @Override @@ -96,27 +96,27 @@ public void tick() { int blockLocZ = Mth.floor(this.entityMySheep.getZ()); BlockPos blockAt = new BlockPos(blockLocX, blockLocY, blockLocZ); - if (GRASS.test(this.world.getType(blockAt))) { + if (GRASS.test(this.world.getBlockState(blockAt))) { if (!CraftEventFactory.callEntityChangeBlockEvent( this.entityMySheep, blockAt, - Blocks.a.getBlockData(), + Blocks.AIR.defaultBlockState(), !this.world.getWorld().getGameRuleValue(GameRule.MOB_GRIEFING) ).isCancelled()) { - this.world.b(blockAt, false); + this.world.destroyBlock(blockAt, false); } entityMySheep.getMyPet().setSheared(false); } else { BlockPos blockUnder = blockAt.down(); - if (this.world.getType(blockUnder).getBlock() == Blocks.aX) { + if (this.world.getBlockState(blockUnder).getBlock() == Blocks.GRASS) { if (!CraftEventFactory.callEntityChangeBlockEvent( this.entityMySheep, blockAt, - Blocks.a.getBlockData(), + Blocks.AIR.defaultBlockState(), !this.world.getWorld().getGameRuleValue(GameRule.MOB_GRIEFING) ).isCancelled()) { - this.world.triggerEffect(2001, blockUnder, Block.getCombinedId(Blocks.i.getBlockData())); - this.world.setTypeAndData(blockUnder, Blocks.j.getBlockData(), 2); + this.world.levelEvent(2001, blockUnder, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState())); + this.world.setBlock(blockUnder, Blocks.DIRT.defaultBlockState(), 2); } entityMySheep.getMyPet().setSheared(false); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/FollowOwner.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/FollowOwner.java index d66c57581b..be80624023 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/FollowOwner.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/movement/FollowOwner.java @@ -108,7 +108,7 @@ public void tick() { } //Look at Owner - this.petEntity.getLookControl().setLookAt(owner, this.petEntity.getMaxHeadXRot(), this.petEntity.getMaxHeadXRot()); + this.petEntity.getLookControl().setLookAt(owner, this.petEntity.getMaxHeadXRot(), this.petEntity.getMaxHeadXRot()); //TODO MIGHT be wrong (also in different places) ->getMaxHeadXRot //Teleportation if (this.petEntity.canMove()) { @@ -138,7 +138,7 @@ public void tick() { if (--this.setPathTimer <= 0) { this.setPathTimer = 10; if (this.nav.navigateTo(owner.getBukkitEntity())) { //TODO 2021/08/19 Seemingly not doing that properly? - applyWalkSpeed(); //It get's called so it returned true + applyWalkSpeed(); //It get's called so it returned true} } } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/BehaviorAggressiveTarget.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/BehaviorAggressiveTarget.java index 9af83e7c4e..f04942666b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/BehaviorAggressiveTarget.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/BehaviorAggressiveTarget.java @@ -20,6 +20,11 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.ai.target; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.ai.AIGoal; @@ -28,22 +33,17 @@ import de.Keyle.MyPet.api.skill.skills.Behavior.BehaviorMode; import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.server.level.EntityPlayer; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.EntityTameableAnimal; -import net.minecraft.world.entity.decoration.EntityArmorStand; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.decoration.ArmorStand; @Compat("v1_17_R1") public class BehaviorAggressiveTarget implements AIGoal { private final MyPet myPet; private final EntityMyPet petEntity; - private final EntityPlayer petOwnerEntity; - private EntityLiving target; + private final ServerPlayer petOwnerEntity; + private net.minecraft.world.entity.LivingEntity target; private final float range; public BehaviorAggressiveTarget(EntityMyPet petEntity, float range) { @@ -69,9 +69,9 @@ public boolean shouldStart() { return false; } - for (EntityLiving entityLiving : this.petEntity.t.a(EntityLiving.class, this.petOwnerEntity.getBoundingBox().grow(range, range, range))) { - if (entityLiving != petEntity && !(entityLiving instanceof EntityArmorStand) && entityLiving.isAlive() && petEntity.f(entityLiving) <= 91) { - if (entityLiving instanceof EntityPlayer) { + for (net.minecraft.world.entity.LivingEntity entityLiving : this.petEntity.level.getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, this.petOwnerEntity.getBoundingBox().inflate(range, range, range))) { + if (entityLiving != petEntity && !(entityLiving instanceof ArmorStand) && entityLiving.isAlive() && petEntity.distanceToSqr(entityLiving) <= 91) { + if (entityLiving instanceof ServerPlayer) { Player targetPlayer = (Player) entityLiving.getBukkitEntity(); if (myPet.getOwner().equals(targetPlayer)) { continue; @@ -84,9 +84,9 @@ public boolean shouldStart() { if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) { continue; } - } else if (entityLiving instanceof EntityTameableAnimal) { - EntityTameableAnimal tameable = (EntityTameableAnimal) entityLiving; - if (tameable.isTamed() && tameable.getOwner() != null) { + } else if (entityLiving instanceof TamableAnimal) { + TamableAnimal tameable = (TamableAnimal) entityLiving; + if (tameable.isTame() && tameable.getOwner() != null) { Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity(); if (myPet.getOwner().equals(tameableOwner)) { continue; @@ -112,7 +112,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) petEntity.getTarget()).getHandle(); + net.minecraft.world.entity.LivingEntity target = ((CraftLivingEntity) petEntity.getMyPetTarget()).getHandle(); if (!target.isAlive()) { return true; @@ -122,16 +122,16 @@ public boolean shouldFinish() { return true; } else if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) { return true; - } else if (target.t != petEntity.t) { + } else if (target.level != petEntity.level) { return true; - } else if (petEntity.f(target) > 400) { + } else if (petEntity.distanceToSqr(target) > 400) { return true; - } else return petEntity.f(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600; + } else return petEntity.distanceToSqr(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600; } @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Aggressive); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Aggressive); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/BehaviorDuelTarget.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/BehaviorDuelTarget.java index 0e906829af..010b9e6935 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/BehaviorDuelTarget.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/BehaviorDuelTarget.java @@ -20,6 +20,9 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.ai.target; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; + import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.MyPetMinecraftEntity; import de.Keyle.MyPet.api.entity.ai.AIGoal; @@ -29,17 +32,15 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.skill.skills.BehaviorImpl; -import net.minecraft.server.level.EntityPlayer; -import net.minecraft.world.entity.EntityLiving; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.LivingEntity; @Compat("v1_17_R1") public class BehaviorDuelTarget implements AIGoal { private final MyPet myPet; private final EntityMyPet petEntity; - private final EntityPlayer petOwnerEntity; + private final ServerPlayer petOwnerEntity; private MyPetMinecraftEntity target; private MyPetMinecraftEntity duelOpponent = null; private final float range; @@ -71,7 +72,7 @@ public boolean shouldStart() { return true; } - for (EntityMyPet entityMyPet : this.petEntity.t.a(EntityMyPet.class, this.petOwnerEntity.getBoundingBox().grow(range, range, range))) { + for (EntityMyPet entityMyPet : this.petEntity.level.getEntitiesOfClass(EntityMyPet.class, this.petOwnerEntity.getBoundingBox().inflate(range, range, range))) { MyPet targetMyPet = entityMyPet.getMyPet(); if (entityMyPet != petEntity && entityMyPet.isAlive()) { @@ -100,23 +101,23 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + LivingEntity target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); Behavior behaviorSkill = myPet.getSkills().get(Behavior.class); if (behaviorSkill.getBehavior() != BehaviorMode.Duel) { return true; } else if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) { return true; - } else if (target.t != petEntity.t) { + } else if (target.level != petEntity.level) { return true; - } else if (petEntity.f(target) > 400) { + } else if (petEntity.distanceToSqr(target) > 400) { return true; - } else return petEntity.f(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600; + } else return petEntity.distanceToSqr(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600; } @Override public void start() { - petEntity.setTarget(this.target.getBukkitEntity(), TargetPriority.Duel); + petEntity.setMyPetTarget(this.target.getBukkitEntity(), TargetPriority.Duel); setDuelOpponent(this.target); if (target.getTargetSelector().hasGoal("DuelTarget")) { BehaviorDuelTarget duelGoal = (BehaviorDuelTarget) target.getTargetSelector().getGoal("DuelTarget"); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/BehaviorFarmTarget.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/BehaviorFarmTarget.java index 2bda790cfd..ef6dcca560 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/BehaviorFarmTarget.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/BehaviorFarmTarget.java @@ -20,6 +20,10 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.ai.target; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; +import org.bukkit.entity.LivingEntity; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.ai.AIGoal; @@ -28,20 +32,16 @@ import de.Keyle.MyPet.api.skill.skills.Behavior.BehaviorMode; import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.server.level.EntityPlayer; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.monster.EntityMonster; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; -import org.bukkit.entity.LivingEntity; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.monster.Monster; @Compat("v1_17_R1") public class BehaviorFarmTarget implements AIGoal { private final MyPet myPet; private final EntityMyPet petEntity; - private final EntityPlayer petOwnerEntity; - private EntityLiving target; + private final ServerPlayer petOwnerEntity; + private net.minecraft.world.entity.LivingEntity target; private final float range; public BehaviorFarmTarget(EntityMyPet petEntity, float range) { @@ -67,8 +67,8 @@ public boolean shouldStart() { return false; } - for (EntityMonster entityMonster : this.petEntity.t.a(EntityMonster.class, this.petOwnerEntity.getBoundingBox().grow(range, range, range))) { - if (!entityMonster.isAlive() || petEntity.f(entityMonster) > 91) { + for (Monster entityMonster : this.petEntity.level.getEntitiesOfClass(Monster.class, this.petOwnerEntity.getBoundingBox().inflate(range, range, range))) { + if (!entityMonster.isAlive() || petEntity.distanceToSqr(entityMonster) > 91) { continue; } if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), entityMonster.getBukkitEntity())) { @@ -88,7 +88,7 @@ public boolean shouldFinish() { if (!this.petEntity.hasTarget()) { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + net.minecraft.world.entity.LivingEntity target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (!target.isAlive()) { return true; @@ -98,16 +98,16 @@ public boolean shouldFinish() { return true; } else if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) { return true; - } else if (target.t != petEntity.t) { + } else if (target.level != petEntity.level) { return true; - } else if (petEntity.f(target) > 400) { + } else if (petEntity.distanceToSqr(target) > 400) { return true; - } else return petEntity.f(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600; + } else return petEntity.distanceToSqr(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600; } @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Farm); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Farm); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/ControlTarget.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/ControlTarget.java index 6320f5b4b0..7ba609e723 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/ControlTarget.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/ControlTarget.java @@ -20,6 +20,11 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.ai.target; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.ai.AIGoal; @@ -29,21 +34,16 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement.Control; -import net.minecraft.server.level.EntityPlayer; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.EntityTameableAnimal; -import net.minecraft.world.entity.decoration.EntityArmorStand; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.decoration.ArmorStand; @Compat("v1_17_R1") public class ControlTarget implements AIGoal { private final MyPet myPet; private final EntityMyPet petEntity; - private EntityLiving target; + private net.minecraft.world.entity.LivingEntity target; private final float range; private Control controlPathfinderGoal; @@ -73,18 +73,18 @@ public boolean shouldStart() { return false; } } - for (EntityLiving entityLiving : this.petEntity.t.a(EntityLiving.class, this.petEntity.getBoundingBox().grow(this.range, 4.0D, this.range))) { - if (entityLiving != petEntity && !(entityLiving instanceof EntityArmorStand)) { - if (entityLiving instanceof EntityPlayer) { + for (net.minecraft.world.entity.LivingEntity entityLiving : this.petEntity.level.getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, this.petEntity.getBoundingBox().inflate(this.range, 4.0D, this.range))) { + if (entityLiving != petEntity && !(entityLiving instanceof ArmorStand)) { + if (entityLiving instanceof ServerPlayer) { Player targetPlayer = (Player) entityLiving.getBukkitEntity(); if (myPet.getOwner().equals(targetPlayer)) { continue; } else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) { continue; } - } else if (entityLiving instanceof EntityTameableAnimal) { - EntityTameableAnimal tameable = (EntityTameableAnimal) entityLiving; - if (tameable.isTamed() && tameable.getOwner() != null) { + } else if (entityLiving instanceof TamableAnimal) { + TamableAnimal tameable = (TamableAnimal) entityLiving; + if (tameable.isTame() && tameable.getOwner() != null) { Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity(); if (myPet.getOwner().equals(tameableOwner)) { continue; @@ -103,11 +103,11 @@ public boolean shouldStart() { } if (behaviorSkill != null) { if (behaviorSkill.getBehavior() == BehaviorMode.Raid) { - if (entityLiving instanceof EntityTameableAnimal) { + if (entityLiving instanceof TamableAnimal) { continue; } else if (entityLiving instanceof EntityMyPet) { continue; - } else if (entityLiving instanceof EntityPlayer) { + } else if (entityLiving instanceof ServerPlayer) { continue; } } @@ -130,18 +130,18 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + net.minecraft.world.entity.LivingEntity target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); - if (target.t != petEntity.t) { + if (target.level != petEntity.level) { return true; - } else if (petEntity.f(target) > 400) { + } else if (petEntity.distanceToSqr(target) > 400) { return true; - } else return petEntity.f(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600; + } else return petEntity.distanceToSqr(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600; } @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Control); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Control); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/HurtByTarget.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/HurtByTarget.java index 36c89ca62c..e4c24f1d11 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/HurtByTarget.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/HurtByTarget.java @@ -20,27 +20,27 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.ai.target; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.ai.AIGoal; import de.Keyle.MyPet.api.entity.ai.target.TargetPriority; import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.server.level.EntityPlayer; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.EntityTameableAnimal; -import net.minecraft.world.entity.decoration.EntityArmorStand; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.decoration.ArmorStand; @Compat("v1_17_R1") public class HurtByTarget implements AIGoal { EntityMyPet petEntity; MyPet myPet; - EntityLiving target = null; + net.minecraft.world.entity.LivingEntity target = null; public HurtByTarget(EntityMyPet petEntity) { this.petEntity = petEntity; @@ -53,19 +53,19 @@ public boolean shouldStart() { if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) { return false; } - if (petEntity.getLastDamager() == null) { + if (petEntity.getLastHurtByMob() == null) { return false; } - if (target != petEntity.getLastDamager()) { - target = petEntity.getLastDamager(); + if (target != petEntity.getLastHurtByMob()) { + target = petEntity.getLastHurtByMob(); } if (target == petEntity) { return false; } - if (target instanceof EntityArmorStand) { + if (target instanceof ArmorStand) { return false; } - if (target instanceof EntityPlayer) { + if (target instanceof ServerPlayer) { Player targetPlayer = (Player) target.getBukkitEntity(); if (targetPlayer == myPet.getOwner().getPlayer()) { @@ -78,9 +78,9 @@ public boolean shouldStart() { if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) { return false; } - } else if (target instanceof EntityTameableAnimal) { - EntityTameableAnimal tameable = (EntityTameableAnimal) target; - if (tameable.isTamed() && tameable.getOwner() != null) { + } else if (target instanceof TamableAnimal) { + TamableAnimal tameable = (TamableAnimal) target; + if (tameable.isTame() && tameable.getOwner() != null) { Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity(); if (myPet.getOwner().equals(tameableOwner)) { return false; @@ -99,18 +99,18 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + net.minecraft.world.entity.LivingEntity target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); - if (target.t != petEntity.t) { + if (target.level != petEntity.level) { return true; - } else if (petEntity.f(target) > 400) { + } else if (petEntity.distanceToSqr(target) > 400) { return true; - } else return petEntity.f(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600; + } else return petEntity.distanceToSqr(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600; } @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.GetHurt); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.GetHurt); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/OwnerHurtByTarget.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/OwnerHurtByTarget.java index 022e5072ab..9e814f09af 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/OwnerHurtByTarget.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/ai/target/OwnerHurtByTarget.java @@ -20,6 +20,11 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.ai.target; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.ai.AIGoal; @@ -28,22 +33,17 @@ import de.Keyle.MyPet.api.skill.skills.Behavior.BehaviorMode; import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.server.level.EntityPlayer; -import net.minecraft.world.entity.EntityLiving; -import net.minecraft.world.entity.EntityTameableAnimal; -import net.minecraft.world.entity.decoration.EntityArmorStand; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.decoration.ArmorStand; @Compat("v1_17_R1") public class OwnerHurtByTarget implements AIGoal { private final EntityMyPet petEntity; - private EntityLiving lastDamager; + private net.minecraft.world.entity.LivingEntity lastDamager; private final MyPet myPet; - private final EntityPlayer owner; + private final ServerPlayer owner; public OwnerHurtByTarget(EntityMyPet entityMyPet) { this.petEntity = entityMyPet; @@ -59,18 +59,18 @@ public boolean shouldStart() { if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) { return false; } - this.lastDamager = owner.getLastDamager(); + this.lastDamager = owner.getLastHurtByMob(); if (this.lastDamager == null || !lastDamager.isAlive()) { return false; } - if (lastDamager instanceof EntityArmorStand) { + if (lastDamager instanceof ArmorStand) { return false; } if (lastDamager == petEntity) { return false; } - if (lastDamager instanceof EntityPlayer) { + if (lastDamager instanceof ServerPlayer) { if (owner == lastDamager) { return false; } @@ -85,9 +85,9 @@ public boolean shouldStart() { if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) { return false; } - } else if (lastDamager instanceof EntityTameableAnimal) { - EntityTameableAnimal tameable = (EntityTameableAnimal) lastDamager; - if (tameable.isTamed() && tameable.getOwner() != null) { + } else if (lastDamager instanceof TamableAnimal) { + TamableAnimal tameable = (TamableAnimal) lastDamager; + if (tameable.isTame() && tameable.getOwner() != null) { Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity(); if (myPet.getOwner().equals(tameableOwner)) { return false; @@ -103,13 +103,13 @@ public boolean shouldStart() { return false; } if (behaviorSkill.getBehavior() == BehaviorMode.Raid) { - if (lastDamager instanceof EntityTameableAnimal && ((EntityTameableAnimal) lastDamager).isTamed()) { + if (lastDamager instanceof TamableAnimal && ((TamableAnimal) lastDamager).isTame()) { return false; } if (lastDamager instanceof EntityMyPet) { return false; } - return !(lastDamager instanceof EntityPlayer); + return !(lastDamager instanceof ServerPlayer); } } return true; @@ -124,18 +124,18 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + net.minecraft.world.entity.LivingEntity target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); - if (target.t != petEntity.t) { + if (target.level != petEntity.level) { return true; - } else if (petEntity.f(target) > 400) { + } else if (petEntity.distanceToSqr(target) > 400) { return true; - } else return petEntity.f(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600; + } else return petEntity.distanceToSqr(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600; } @Override public void start() { - petEntity.setTarget((LivingEntity) this.lastDamager.getBukkitEntity(), TargetPriority.OwnerGetsHurt); + petEntity.setMyPetTarget((LivingEntity) this.lastDamager.getBukkitEntity(), TargetPriority.OwnerGetsHurt); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java index aad535f3aa..bc223eb48c 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java @@ -20,6 +20,8 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.util.UUID; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; @@ -43,7 +45,7 @@ public EntityMyBat(Level world, MyPet myPet) { * Returns the sound that is played when the MyPet dies */ @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.bat.death"; } @@ -88,7 +90,7 @@ public void onLivingUpdate() { @Override public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Bat.CAN_GLIDE) { - super.e(f, f1); + super.calculateFallDamage(f, f1); } return 0; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBee.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBee.java index 84928552ac..e2c712ba92 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBee.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBee.java @@ -20,6 +20,8 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.util.UUID; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; @@ -49,7 +51,7 @@ public EntityMyBee(Level world, MyPet myPet) { * Returns the sound that is played when the MyPet dies */ @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.bee.death"; } @@ -141,7 +143,7 @@ protected void doMyPetTick() { @Override public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Bee.CAN_GLIDE) { - super.e(f, f1); + super.calculateFallDamage(f, f1); } return 0; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBlaze.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBlaze.java index 548be315e0..09668e415a 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBlaze.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBlaze.java @@ -49,7 +49,7 @@ public EntityMyBlaze(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.blaze.death"; } @@ -139,7 +139,7 @@ public MyBlaze getMyPet() { @Override public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Blaze.CAN_GLIDE) { - super.e(f, f1); //TODO + super.calculateFallDamage(f, f1); } return 0; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCat.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCat.java index 61d2da6636..cb232cf2cd 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCat.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCat.java @@ -65,7 +65,7 @@ public void applySitting(boolean sitting) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.cat.death"; } @@ -88,8 +88,8 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction if (getOwner().equals(entityhuman)) { if (itemStack != null && canUseItem() && getOwner().getPlayer().isSneaking()) { if (itemStack.getItem() instanceof DyeItem) { - if (((DyeItem) itemStack.getItem()).d().getColorIndex() != getMyPet().getCollarColor().ordinal()) { - getMyPet().setCollarColor(DyeColor.values()[((DyeItem) itemStack.getItem()).d().getColorIndex()]); + if (((DyeItem) itemStack.getItem()).getDyeColor().getId() != getMyPet().getCollarColor().ordinal()) { + getMyPet().setCollarColor(DyeColor.values()[((DyeItem) itemStack.getItem()).getDyeColor().getId()]); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); if (itemStack.getCount() <= 0) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCaveSpider.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCaveSpider.java index 2e3b26cba5..6ecae56211 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCaveSpider.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCaveSpider.java @@ -20,6 +20,8 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.util.UUID; + import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; @@ -38,7 +40,7 @@ public EntityMyCaveSpider(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.spider.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyChicken.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyChicken.java index 2649c5da90..81b7ea8064 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyChicken.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyChicken.java @@ -20,6 +20,8 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.util.UUID; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; @@ -48,7 +50,7 @@ public EntityMyChicken(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.chicken.death"; } @@ -106,7 +108,7 @@ public void onLivingUpdate() { if (Configuration.MyPet.Chicken.CAN_LAY_EGGS && canUseItem() && --nextEggTimer <= 0) { this.makeSound("entity.chicken.egg", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); - a(Items.EGG, 1); + spawnAtLocation(Items.EGG, 1); nextEggTimer = this.random.nextInt(6000) + 6000; } } @@ -127,7 +129,7 @@ public MyChicken getMyPet() { @Override public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Chicken.CAN_GLIDE) { - super.e(f, f1); + super.calculateFallDamage(f, f1); } return 0; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java index 9102e45be7..fa8cc14df6 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCod.java @@ -20,6 +20,8 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.util.UUID; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.compat.ParticleCompat; import de.Keyle.MyPet.api.entity.EntitySize; @@ -40,7 +42,7 @@ public EntityMyCod(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.cod.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCow.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCow.java index cffff87587..fe7fc395ac 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCow.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCow.java @@ -20,6 +20,8 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.util.UUID; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; @@ -45,7 +47,7 @@ public EntityMyCow(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.cow.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCreeper.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCreeper.java index 1183dc2277..ec5a0b7d52 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCreeper.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyCreeper.java @@ -20,6 +20,8 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.util.UUID; + import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyCreeper; @@ -41,7 +43,7 @@ public EntityMyCreeper(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.creeper.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDolphin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDolphin.java index 28290b2555..0c7060ed05 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDolphin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDolphin.java @@ -20,6 +20,8 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.util.UUID; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.compat.ParticleCompat; import de.Keyle.MyPet.api.entity.EntitySize; @@ -43,7 +45,7 @@ public EntityMyDolphin(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.dolphin.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDonkey.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDonkey.java index 429dd1e4cc..d5a32380cf 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDonkey.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDonkey.java @@ -30,11 +30,13 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyDonkey; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; +import net.minecraft.core.BlockPos; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; -import net.minecraft.sounds.SoundEffects; +import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; @@ -44,6 +46,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; @@ -112,7 +115,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Item.byBlock(Blocks.pq) && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && canEquip()) { + } else if (itemStack.getItem() == Item.byBlock(Blocks.CHEST) && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && canEquip()) { getMyPet().setChest(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -145,7 +148,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } @@ -185,7 +188,7 @@ public void updateVisuals() { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.donkey.death"; } @@ -249,22 +252,22 @@ public MyDonkey getMyPet() { } @Override - public void a(int i) { - // I don't know. + public void onPlayerJump(int i) { + // I don't know. <- this was here before the remap } /* Jump power methods */ @Override - public boolean a() { + public boolean canJump() { return true; } @Override - public void b(int i) { + public void handleStartJump(int i) { this.jumpPower = i; } @Override - public void b() { + public void handleStopJump() { } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDrowned.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDrowned.java index 8b15203748..910cc032fc 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDrowned.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyDrowned.java @@ -35,15 +35,15 @@ import de.Keyle.MyPet.api.entity.EquipmentSlot; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyDrowned; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; -import net.minecraft.server.level.WorldServer; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; @@ -68,7 +68,7 @@ public EntityMyDrowned(Level world, MyPet myPet) { * Returns the sound that is played when the MyPet dies */ @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.drowned.death" + (isInWater() ? "_water" : ""); } @@ -122,7 +122,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyElderGuardian.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyElderGuardian.java index bc20e471f4..681199230e 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyElderGuardian.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyElderGuardian.java @@ -24,7 +24,7 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyElderGuardian; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 0.7F, height = 0.85F) public class EntityMyElderGuardian extends EntityMyPet { @@ -34,7 +34,7 @@ public EntityMyElderGuardian(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.elder_guardian.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderDragon.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderDragon.java index ad42a087cb..69eaf79ac1 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderDragon.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderDragon.java @@ -20,18 +20,18 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.util.Arrays; + import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPetPart; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack.MeleeAttack; -import net.minecraft.server.level.WorldServer; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.World; - -import java.util.Arrays; +import net.minecraft.world.level.Level; @EntitySize(width = 1.F, height = 1.F) public class EntityMyEnderDragon extends EntityMyPet { @@ -58,7 +58,7 @@ public EntityMyEnderDragon(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.ender_dragon.death"; } @@ -87,10 +87,10 @@ public void onLivingUpdate() { } } if (!registered && this.valid) { - if (this.getWorld() instanceof WorldServer) { - WorldServer world = (ServerLevel) this.getWorld(); + if (this.getCommandSenderWorld() instanceof ServerLevel) { + ServerLevel world = (ServerLevel) this.getCommandSenderWorld(); Arrays.stream(this.children) - .forEach(entityMyPetPart -> world.addEntity(entityMyPetPart)); // TODO: 2021/07/14 I don't know if this is the right replacement. + .forEach(entityMyPetPart -> world.addFreshEntity(entityMyPetPart)); // TODO: 2021/07/14 I don't know if this is the right replacement. } this.registered = true; } @@ -102,7 +102,7 @@ public void onLivingUpdate() { @Override public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.EnderDragon.CAN_GLIDE) { - super.e(f, f1); + super.calculateFallDamage(f, f1); } return 0; } @@ -118,7 +118,7 @@ public void discard() { @Override public void die(DamageSource damagesource) { super.die(damagesource); - Arrays.stream(this.children).forEach(Entity::die); + Arrays.stream(this.children).forEach(Entity::discard); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderman.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderman.java index 2a64307f27..823e23345d 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderman.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEnderman.java @@ -20,37 +20,37 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; +import java.lang.reflect.InvocationTargetException; +import java.util.Optional; + +import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_17_R1.util.CraftMagicNumbers; + import de.Keyle.MyPet.api.Util; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyEnderman; import de.Keyle.MyPet.api.skill.skills.Behavior; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.skill.skills.BehaviorImpl; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; -import org.bukkit.craftbukkit.v1_17_R1.util.CraftMagicNumbers; - -import java.lang.reflect.InvocationTargetException; -import java.util.Optional; - -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; @EntitySize(width = 0.6F, height = 2.55F) public class EntityMyEnderman extends EntityMyPet { - private static final EntityDataAccessor> BLOCK_WATCHER = SynchedEntityData.defineId(EntityMyEnderman.class, EntityDataSerializers.h); + private static final EntityDataAccessor> BLOCK_WATCHER = SynchedEntityData.defineId(EntityMyEnderman.class, EntityDataSerializers.BLOCK_STATE); private static final EntityDataAccessor SCREAMING_WATCHER = SynchedEntityData.defineId(EntityMyEnderman.class, EntityDataSerializers.BOOLEAN); public EntityMyEnderman(Level world, MyPet myPet) { @@ -58,7 +58,7 @@ public EntityMyEnderman(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.enderman.death"; } @@ -73,7 +73,7 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } @@ -93,7 +93,7 @@ public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, Intera // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEndermite.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEndermite.java index d7b01cba13..59981df8bd 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEndermite.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEndermite.java @@ -23,7 +23,7 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.world.level.World; +import net.minecraft.world.level.Level; @EntitySize(width = 0.4F, height = 0.1F) public class EntityMyEndermite extends EntityMyPet { @@ -33,7 +33,7 @@ public EntityMyEndermite(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.endermite.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEvoker.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEvoker.java index 46600ddc79..1278753a5c 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEvoker.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyEvoker.java @@ -24,10 +24,10 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyEvoker; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; -import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.world.level.World; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.level.Level; @EntitySize(width = 0.6F, height = 1.95F) public class EntityMyEvoker extends EntityMyPet { @@ -43,7 +43,7 @@ public EntityMyEvoker(Level world, MyPet myPet) { * Returns the sound that is played when the MyPet dies */ @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.evoker.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyFox.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyFox.java index dec940c2c3..3a50cf3158 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyFox.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyFox.java @@ -37,6 +37,7 @@ import de.Keyle.MyPet.api.entity.EquipmentSlot; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyFox; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; @@ -66,7 +67,7 @@ public EntityMyFox(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.fox.death"; } @@ -134,7 +135,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGhast.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGhast.java index 635dadf211..02f4837507 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGhast.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGhast.java @@ -35,7 +35,7 @@ public EntityMyGhast(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.ghast.death"; } @@ -71,7 +71,7 @@ public void onLivingUpdate() { @Override public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Ghast.CAN_GLIDE) { - super.e(f, f1); + super.calculateFallDamage(f, f1); } return 0; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGiant.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGiant.java index 14fec69198..efd1f86e7a 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGiant.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGiant.java @@ -34,6 +34,7 @@ import de.Keyle.MyPet.api.entity.EquipmentSlot; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyGiant; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack.MeleeAttack; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; @@ -55,7 +56,7 @@ public EntityMyGiant(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.zombie.death"; } @@ -110,7 +111,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGuardian.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGuardian.java index 40c12c74cc..cd848c7ab3 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGuardian.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGuardian.java @@ -34,7 +34,7 @@ public EntityMyGuardian(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.guardian.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java index 3c781b8ef2..682ff1c85a 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHoglin.java @@ -44,7 +44,7 @@ public EntityMyHoglin(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.hoglin.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHorse.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHorse.java index a2bae0888f..f76e590024 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHorse.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHorse.java @@ -37,6 +37,7 @@ import de.Keyle.MyPet.api.entity.EquipmentSlot; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyHorse; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.core.BlockPos; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; @@ -106,7 +107,7 @@ public boolean attack(Entity entity) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.horse.death"; } @@ -177,7 +178,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } @@ -299,22 +300,22 @@ public MyHorse getMyPet() { @Override - public void a(int i) { - // I don't know. + public void onPlayerJump(int i) { + // I don't know. <- this was here before the remap } /* Jump power methods */ @Override - public boolean a() { + public boolean canJump() { return true; } @Override - public void b(int i) { + public void handleStartJump(int i) { this.jumpPower = i; } @Override - public void b() { + public void handleStopJump() { } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java index 0c204fe9a7..6dfced09fa 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyHusk.java @@ -35,6 +35,7 @@ import de.Keyle.MyPet.api.entity.EquipmentSlot; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyHusk; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; @@ -65,7 +66,7 @@ public EntityMyHusk(Level world, MyPet myPet) { * Returns the sound that is played when the MyPet dies */ @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.husk.death"; } @@ -120,7 +121,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java index 11be877e0e..cfd0fa960f 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIllusioner.java @@ -64,7 +64,7 @@ public EntityMyIllusioner(Level world, MyPet myPet) { * Returns the sound that is played when the MyPet dies */ @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.illusioner.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIronGolem.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIronGolem.java index d97636e4c8..2cdb890d38 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIronGolem.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyIronGolem.java @@ -30,6 +30,7 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyIronGolem; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; @@ -73,7 +74,7 @@ public boolean attack(Entity entity) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.iron_golem.death"; } @@ -99,7 +100,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction return InteractionResult.CONSUME; } - if (itemStack.getItem() == Items.mq) { + if (itemStack.getItem() == Items.IRON_INGOT) { Bukkit.getScheduler().runTaskLater(MyPetApi.getPlugin(), () -> { if (getMyPet().getStatus() == MyPet.PetState.Here) { super.setHealth(this.getHealth() + 0.0001F); @@ -112,7 +113,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction }, 10L); } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { - if (itemStack.getItem() == Blocks.bw.getItem() && !getMyPet().hasFlower() && getOwner().getPlayer().isSneaking()) { + if (itemStack.getItem() == Blocks.POPPY.asItem() && !getMyPet().hasFlower() && getOwner().getPlayer().isSneaking()) { getMyPet().setFlower(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -136,7 +137,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyLlama.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyLlama.java index 3d513d29e3..9fa70d239b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyLlama.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyLlama.java @@ -30,11 +30,12 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyLlama; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; -import net.minecraft.tags.TagsItem; +import net.minecraft.tags.ItemTags; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.item.ItemEntity; @@ -43,8 +44,8 @@ import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.WoolCarpetBlock; import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.WoolCarpetBlock; @EntitySize(width = 0.9F, height = 1.87F) public class EntityMyLlama extends EntityMyPet { @@ -62,7 +63,7 @@ public EntityMyLlama(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.llama.death"; } @@ -83,7 +84,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction } if (itemStack != null && canUseItem()) { - if (TagsItem.g.isTagged(itemStack.getItem()) && !getMyPet().hasDecor() && getOwner().getPlayer().isSneaking() && canEquip()) { + if (ItemTags.CARPETS.contains(itemStack.getItem()) && !getMyPet().hasDecor() && getOwner().getPlayer().isSneaking() && canEquip()) { getMyPet().setDecor(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -92,7 +93,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Blocks.CHEST.getItem() && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && !getMyPet().isBaby() && canEquip()) { + } else if (itemStack.getItem() == Blocks.CHEST.asItem() && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && !getMyPet().isBaby() && canEquip()) { getMyPet().setChest(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -125,7 +126,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } @@ -167,7 +168,7 @@ public void updateVisuals() { if (getMyPet().hasDecor()) { ItemStack is = CraftItemStack.asNMSCopy(getMyPet().getDecor()); Block block = Block.byItem(is.getItem()); - int color = block instanceof WoolCarpetBlock ? ((WoolCarpetBlock) block).c().getColorIndex() : 0; + int color = block instanceof WoolCarpetBlock ? ((WoolCarpetBlock) block).getColor().getId() : 0; this.getEntityData().set(COLOR_WATCHER, color); } else { this.getEntityData().set(COLOR_WATCHER, -1); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMagmaCube.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMagmaCube.java index 2dc9501f2b..4c41e76282 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMagmaCube.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMagmaCube.java @@ -43,7 +43,7 @@ public EntityMyMagmaCube(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.magma_cube.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java index 83fdc10942..e801b42371 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java @@ -49,7 +49,7 @@ public EntityMyMooshroom(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.cow.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMule.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMule.java index 7a94a4b8dd..567207019c 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMule.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMule.java @@ -30,6 +30,7 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyMule; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.core.BlockPos; import net.minecraft.network.syncher.EntityDataAccessor; @@ -147,7 +148,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } @@ -187,7 +188,7 @@ public void updateVisuals() { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.mule.death"; } @@ -231,7 +232,7 @@ public void playStepSound(BlockPos blockposition, BlockState blockdata) { if (this.isVehicle()) { ++this.soundCounter; if (this.soundCounter > 5 && this.soundCounter % 3 == 0) { - this.playSound(SoundEvents.hB, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); + this.playSound(SoundEvents.HORSE_GALLOP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } else if (this.soundCounter <= 5) { this.playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch()); } @@ -250,22 +251,22 @@ public MyMule getMyPet() { } @Override - public void a(int i) { - // I don't know. + public void onPlayerJump(int i) { + // I don't know. <- this was here before the remap } /* Jump power methods */ @Override - public boolean a() { + public boolean canJump() { return true; } @Override - public void b(int i) { + public void handleStartJump(int i) { this.jumpPower = i; } @Override - public void b() { + public void handleStopJump() { } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyOcelot.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyOcelot.java index 0c597a121a..3601e65190 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyOcelot.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyOcelot.java @@ -45,7 +45,7 @@ public EntityMyOcelot(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.ocelot.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPanda.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPanda.java index e015243f98..44356049d1 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPanda.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPanda.java @@ -50,7 +50,7 @@ public EntityMyPanda(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.panda.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyParrot.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyParrot.java index c0a1f58fd9..b58ad6e15a 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyParrot.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyParrot.java @@ -37,9 +37,9 @@ public class EntityMyParrot extends EntityMyPet { private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyParrot.class, EntityDataSerializers.BOOLEAN); - protected static final EntityDataAccessor SIT_WATCHER = SynchedEntityData.defineId(EntityMyParrot.class, EntityDataSerializers.INTYTE); + protected static final EntityDataAccessor SIT_WATCHER = SynchedEntityData.defineId(EntityMyParrot.class, EntityDataSerializers.BYTE); protected static final EntityDataAccessor> OWNER_WATCHER = SynchedEntityData.defineId(EntityMyParrot.class, EntityDataSerializers.OPTIONAL_UUID); - private static final EntityDataAccessor VARIANT_WATCHER = SynchedEntityData.defineId(EntityMyParrot.class, EntityDataSerializers.BOOLEANNT); + private static final EntityDataAccessor VARIANT_WATCHER = SynchedEntityData.defineId(EntityMyParrot.class, EntityDataSerializers.INT); public EntityMyParrot(Level world, MyPet myPet) { super(world, myPet); @@ -54,7 +54,7 @@ public MyParrot getMyPet() { * Returns the sound that is played when the MyPet dies */ @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.parrot.death"; } @@ -101,7 +101,7 @@ public void onLivingUpdate() { @Override public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Parrot.CAN_GLIDE) { - super.e(f, f1); + super.calculateFallDamage(f, f1); } return 0; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPhantom.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPhantom.java index 494f1c4296..db24c5fa06 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPhantom.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPhantom.java @@ -42,7 +42,7 @@ public EntityMyPhantom(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.phantom.death"; } @@ -107,7 +107,7 @@ public void onLivingUpdate() { @Override public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Phantom.CAN_GLIDE) { - super.e(f, f1); + super.calculateFallDamage(f, f1); } return 0; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPig.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPig.java index ac7c94b13c..d739785b73 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPig.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPig.java @@ -20,8 +20,6 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; -import static de.Keyle.MyPet.compat.v1_17_R1.CompatManager.ENTITY_LIVING_broadcastItemBreak; - import java.lang.reflect.InvocationTargetException; import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; @@ -33,6 +31,7 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyPig; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket; import net.minecraft.network.syncher.EntityDataAccessor; @@ -58,7 +57,7 @@ public EntityMyPig(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.pig.death"; } @@ -78,12 +77,12 @@ public InteractionResult handlePlayerInteraction(final net.minecraft.world.entit if (itemStack != null) { if (itemStack.getItem() == Items.LEAD) { ((ServerLevel) this.level).getChunkProvider().broadcastAndSend(this, new ClientboundSetEntityLinkPacket(this, null)); - entityhuman.a(InteractionHand.OFF_HAND, ItemStack.EMPTY); + entityhuman.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY); new BukkitRunnable() { @Override public void run() { if (entityhuman instanceof ServerPlayer) { - entityhuman.a(InteractionHand.OFF_HAND, itemStack);//TODO + entityhuman.setItemInHand(InteractionHand.OFF_HAND, itemStack);//TODO Player p = (Player) entityhuman.getBukkitEntity(); if (!p.isOnline()) { p.saveData(); @@ -125,7 +124,7 @@ public void run() { // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglin.java index 20fbc8a18f..35d68f993b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglin.java @@ -36,6 +36,7 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.MyPet.PetState; import de.Keyle.MyPet.api.entity.types.MyPiglin; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; @@ -61,7 +62,7 @@ public EntityMyPiglin(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.piglin.death"; } @@ -103,7 +104,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglinBrute.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglinBrute.java index f778c390a1..6f9013a018 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglinBrute.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPiglinBrute.java @@ -37,6 +37,7 @@ import de.Keyle.MyPet.api.entity.MyPet.PetState; import de.Keyle.MyPet.api.entity.types.MyPiglinBrute; import de.Keyle.MyPet.api.util.NMSUtil; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; @@ -63,9 +64,7 @@ public EntityMyPiglinBrute(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { - - + protected String getMyPetDeathSound() { return NMSUtil.getSoundEffectId(SoundEvents.PIGLIN_BRUTE_DEATH); } @@ -107,7 +106,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPillager.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPillager.java index 29bc2701aa..fca932b50f 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPillager.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPillager.java @@ -34,6 +34,7 @@ import de.Keyle.MyPet.api.entity.EquipmentSlot; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyPillager; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; @@ -64,7 +65,7 @@ public EntityMyPillager(Level world, MyPet myPet) { * Returns the sound that is played when the MyPet dies */ @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.pillager.death"; } @@ -118,7 +119,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPolarBear.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPolarBear.java index 3a3563a3e3..8685957d82 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPolarBear.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPolarBear.java @@ -31,7 +31,7 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -48,7 +48,7 @@ public EntityMyPolarBear(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.polar_bear.death"; } @@ -63,7 +63,7 @@ protected String getLivingSound() { } @Override - public InteractionResult handlePlayerInteraction(EntityHuman entityhuman, InteractionHand enumhand, ItemStack itemStack) { + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { return InteractionResult.CONSUME; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java index 82f8e53d5e..76aacf873d 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyPufferfish.java @@ -42,7 +42,7 @@ public EntityMyPufferfish(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.puffer_fish.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRabbit.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRabbit.java index 680a138021..5ba0caa701 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRabbit.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRabbit.java @@ -48,7 +48,7 @@ public EntityMyRabbit(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.rabbit.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRavager.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRavager.java index 4c83d61df3..718aab35d1 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRavager.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyRavager.java @@ -45,7 +45,7 @@ public EntityMyRavager(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.ravager.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySalmon.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySalmon.java index a0c0ed4b56..e1e235b5d3 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySalmon.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySalmon.java @@ -40,7 +40,7 @@ public EntityMySalmon(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.salmon.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySheep.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySheep.java index 3e5a4e0f62..314675bddf 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySheep.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySheep.java @@ -28,6 +28,7 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MySheep; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement.EatGrass; import net.minecraft.network.syncher.EntityDataAccessor; @@ -77,7 +78,7 @@ public EntityMySheep(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.sheep.death"; } @@ -98,8 +99,8 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction } if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { - if (itemStack.getItem() instanceof DyeItem && ((DyeItem) itemStack.getItem()).d().ordinal() != getMyPet().getColor().ordinal() && !getMyPet().isSheared()) { //TODO - getMyPet().setColor(org.bukkit.DyeColor.values()[((DyeItem) itemStack.getItem()).d().ordinal()]); + if (itemStack.getItem() instanceof DyeItem && ((DyeItem) itemStack.getItem()).getDyeColor().ordinal() != getMyPet().getColor().ordinal() && !getMyPet().isSheared()) { + getMyPet().setColor(org.bukkit.DyeColor.values()[((DyeItem) itemStack.getItem()).getDyeColor().ordinal()]); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); if (itemStack.getCount() <= 0) { @@ -125,7 +126,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySilverfish.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySilverfish.java index 9eae84cb9b..90ce54725d 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySilverfish.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySilverfish.java @@ -33,7 +33,7 @@ public EntityMySilverfish(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.silverfish.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeleton.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeleton.java index 43362f48ea..f8b1a417ab 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeleton.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeleton.java @@ -35,6 +35,7 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.MyPet.PetState; import de.Keyle.MyPet.api.entity.types.MySkeleton; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.server.level.ServerLevel; @@ -55,7 +56,7 @@ public EntityMySkeleton(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { if (getMyPet().isStray()) { return "entity.stray.death"; } else if (getMyPet().isWither()) { @@ -112,7 +113,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java index ce538e2690..b120002147 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySkeletonHorse.java @@ -30,6 +30,7 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MySkeletonHorse; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.core.BlockPos; import net.minecraft.network.syncher.EntityDataAccessor; @@ -96,7 +97,7 @@ public boolean attack(Entity entity) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.skeleton_horse.death"; } @@ -144,7 +145,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } @@ -230,22 +231,22 @@ public MySkeletonHorse getMyPet() { } @Override - public void a(int i) { - // I don't know. + public void onPlayerJump(int i) { + // I don't know. <- this was here before the remap } /* Jump power methods */ @Override - public boolean a() { + public boolean canJump() { return true; } @Override - public void b(int i) { + public void handleStartJump(int i) { this.jumpPower = i; } @Override - public void b() { + public void handleStopJump() { } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySlime.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySlime.java index 76bd6f3f50..faee19996f 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySlime.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySlime.java @@ -44,7 +44,7 @@ public EntityMySlime(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.slime.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySnowman.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySnowman.java index e0a3eac4fd..fc50b7073f 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySnowman.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySnowman.java @@ -25,6 +25,7 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MySnowman; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; @@ -73,7 +74,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } @@ -99,7 +100,7 @@ protected void defineSynchedData() { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.snow_golem.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySpider.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySpider.java index 0ff459517c..0a5a1e6f3e 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySpider.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySpider.java @@ -33,7 +33,7 @@ public EntityMySpider(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.spider.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySquid.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySquid.java index f2d260975d..96dbe34927 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySquid.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMySquid.java @@ -35,7 +35,7 @@ public EntityMySquid(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.squid.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStray.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStray.java index ff4601bd3c..828db1bf70 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStray.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStray.java @@ -35,6 +35,7 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.MyPet.PetState; import de.Keyle.MyPet.api.entity.types.MyStray; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.server.level.ServerLevel; @@ -55,7 +56,7 @@ public EntityMyStray(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.stray.death"; } @@ -97,7 +98,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStrider.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStrider.java index 61a162fedb..61ee724c8d 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStrider.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyStrider.java @@ -28,6 +28,7 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyStrider; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; @@ -53,7 +54,7 @@ public EntityMyStrider(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.strider.death"; } @@ -98,7 +99,7 @@ public InteractionResult handlePlayerInteraction(final Player entityhuman, Inter // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTraderLlama.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTraderLlama.java index c0710b1144..1755bd2aea 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTraderLlama.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTraderLlama.java @@ -30,11 +30,12 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyTraderLlama; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; -import net.minecraft.tags.TagsItem; +import net.minecraft.tags.ItemTags; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.item.ItemEntity; @@ -62,7 +63,7 @@ public EntityMyTraderLlama(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.llama.death"; } @@ -84,7 +85,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction } if (itemStack != null && canUseItem()) { - if (TagsItem.g.isTagged(itemStack.getItem()) && !getMyPet().hasDecor() && getOwner().getPlayer().isSneaking() && canEquip()) { + if (ItemTags.CARPETS.contains(itemStack.getItem()) && !getMyPet().hasDecor() && getOwner().getPlayer().isSneaking() && canEquip()) { getMyPet().setDecor(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -93,7 +94,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction } } return InteractionResult.CONSUME; - } else if (itemStack.getItem() == Blocks.CHEST.getItem() && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && !getMyPet().isBaby() && canEquip()) { + } else if (itemStack.getItem() == Blocks.CHEST.asItem() && getOwner().getPlayer().isSneaking() && !getMyPet().hasChest() && !getMyPet().isBaby() && canEquip()) { getMyPet().setChest(CraftItemStack.asBukkitCopy(itemStack)); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); @@ -126,7 +127,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } @@ -168,7 +169,7 @@ public void updateVisuals() { if (getMyPet().hasDecor()) { ItemStack is = CraftItemStack.asNMSCopy(getMyPet().getDecor()); Block block = Block.byItem(is.getItem()); - int color = block instanceof WoolCarpetBlock ? ((WoolCarpetBlock) block).c().getColorIndex() : 0; + int color = block instanceof WoolCarpetBlock ? ((WoolCarpetBlock) block).getColor().getId() : 0; this.getEntityData().set(COLOR_WATCHER, color); } else { this.getEntityData().set(COLOR_WATCHER, -1); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTropicalFish.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTropicalFish.java index ae0ec9c03c..537729d497 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTropicalFish.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTropicalFish.java @@ -42,7 +42,7 @@ public EntityMyTropicalFish(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.tropical_fish.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTurtle.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTurtle.java index 98b9a00499..2a2ce3065d 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTurtle.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyTurtle.java @@ -51,7 +51,7 @@ public EntityMyTurtle(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.turtle.death" + (isBaby() ? "_baby" : ""); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVex.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVex.java index 1788bcfc09..06268c1ac6 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVex.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVex.java @@ -36,6 +36,7 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyVex; import de.Keyle.MyPet.api.skill.skills.Behavior; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.skill.skills.BehaviorImpl; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; @@ -67,7 +68,7 @@ public EntityMyVex(Level world, MyPet myPet) { * Returns the sound that is played when the MyPet dies */ @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.vex.death"; } @@ -121,7 +122,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } @@ -225,7 +226,7 @@ protected void doMyPetTick() { @Override public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Vex.CAN_GLIDE) { - super.e(f, f1); + super.calculateFallDamage(f, f1); } return 0; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVillager.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVillager.java index b4adcc30a0..7a0da6d3a6 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVillager.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVillager.java @@ -54,7 +54,7 @@ public EntityMyVillager(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.villager.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVindicator.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVindicator.java index e663fe8ee6..e8fbaa72ff 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVindicator.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyVindicator.java @@ -63,7 +63,7 @@ public EntityMyVindicator(Level world, MyPet myPet) { * Returns the sound that is played when the MyPet dies */ @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.vindicator.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWanderingTrader.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWanderingTrader.java index 0ef6bfacfd..75c6ba821b 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWanderingTrader.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWanderingTrader.java @@ -40,7 +40,7 @@ public EntityMyWanderingTrader(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.villager.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitch.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitch.java index 13e70778ea..d535368f3c 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitch.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitch.java @@ -33,7 +33,7 @@ public EntityMyWitch(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.witch.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWither.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWither.java index ea7e493012..d8c826cc81 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWither.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWither.java @@ -43,7 +43,7 @@ public EntityMyWither(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.wither.death"; } @@ -87,7 +87,7 @@ public void updateVisuals() { @Override public int calculateFallDamage(float f, float f1) { if (!Configuration.MyPet.Wither.CAN_GLIDE) { - super.e(f, f1); + super.calculateFallDamage(f, f1); } return 0; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitherSkeleton.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitherSkeleton.java index 87440cca58..a561a8b9c0 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitherSkeleton.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWitherSkeleton.java @@ -35,6 +35,7 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.MyPet.PetState; import de.Keyle.MyPet.api.entity.types.MyWitherSkeleton; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.server.level.ServerLevel; @@ -55,7 +56,7 @@ public EntityMyWitherSkeleton(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.wither_skeleton.death"; } @@ -97,7 +98,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWolf.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWolf.java index d706362ec9..bb55c535cf 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWolf.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyWolf.java @@ -34,6 +34,7 @@ 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.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.ai.attributes.Attributes; @@ -42,7 +43,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; -import net.royawesome.jlibnoise.MathHelper; @EntitySize(width = 0.6F, height = 0.64f) public class EntityMyWolf extends EntityMyPet { @@ -72,7 +72,7 @@ public void applySitting(boolean sitting) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.wolf.death"; } @@ -95,9 +95,9 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction if (getOwner().equals(entityhuman)) { if (itemStack != null && itemStack.getItem() != Items.AIR) { if (canUseItem()) { - if (itemStack.getItem() instanceof DyeItem && ((DyeItem) itemStack.getItem()).d().ordinal() != getMyPet().getCollarColor().ordinal()) { + if (itemStack.getItem() instanceof DyeItem && ((DyeItem) itemStack.getItem()).getDyeColor().ordinal() != getMyPet().getCollarColor().ordinal()) { if (getOwner().getPlayer().isSneaking()) { - getMyPet().setCollarColor(DyeColor.values()[((DyeItem) itemStack.getItem()).d().ordinal()]); + getMyPet().setCollarColor(DyeColor.values()[((DyeItem) itemStack.getItem()).getDyeColor().ordinal()]); if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { itemStack.shrink(1); if (itemStack.getCount() <= 0) { @@ -190,7 +190,7 @@ public void onLivingUpdate() { } if (this.shakeCounter > 0.4F) { - int i = (int) (MathHelper.sin((this.shakeCounter - 0.4F) * 3.141593F) * 7.0F); + int i = (int) (Mth.sin((this.shakeCounter - 0.4F) * 3.141593F) * 7.0F); for (; i >= 0; i--) { float offsetX = (this.random.nextFloat() * 2.0F - 1.0F) * this.getBbWidth() * 0.5F; float offsetZ = (this.random.nextFloat() * 2.0F - 1.0F) * this.getBbWidth() * 0.5F; diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZoglin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZoglin.java index 4cad6d7dd5..4d32fdf9c0 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZoglin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZoglin.java @@ -44,7 +44,7 @@ public EntityMyZoglin(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.zoglin.death"; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombie.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombie.java index 53156a19f7..a7a68a6b68 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombie.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombie.java @@ -35,6 +35,7 @@ import de.Keyle.MyPet.api.entity.EquipmentSlot; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyZombie; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; @@ -66,7 +67,7 @@ public EntityMyZombie(Level world, MyPet myPet) { * Returns the sound that is played when the MyPet dies */ @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.zombie.death"; } @@ -120,7 +121,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieHorse.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieHorse.java index 48d4937fbd..3bffc2f60d 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieHorse.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieHorse.java @@ -30,6 +30,7 @@ import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyZombieHorse; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.core.BlockPos; import net.minecraft.network.syncher.EntityDataAccessor; @@ -96,7 +97,7 @@ public boolean attack(Entity entity) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.zombie_horse.death"; } @@ -144,7 +145,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } @@ -230,22 +231,22 @@ public MyZombieHorse getMyPet() { } @Override - public void a(int i) { - // I don't know. + public void onPlayerJump(int i) { + // I don't know. <- this was here before the remap } /* Jump power methods */ @Override - public boolean a() { + public boolean canJump() { return true; } @Override - public void b(int i) { + public void handleStartJump(int i) { this.jumpPower = i; } @Override - public void b() { + public void handleStopJump() { } } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieVillager.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieVillager.java index 697f3e41b8..5f5fe8a1df 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieVillager.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombieVillager.java @@ -36,6 +36,7 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.types.MyVillager; import de.Keyle.MyPet.api.entity.types.MyZombieVillager; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.core.Registry; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; @@ -73,7 +74,7 @@ public EntityMyZombieVillager(Level world, MyPet myPet) { * Returns the sound that is played when the MyPet dies */ @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.zombie.death"; } @@ -127,7 +128,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombifiedPiglin.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombifiedPiglin.java index 003e8221e1..d6c1b5e06f 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombifiedPiglin.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyZombifiedPiglin.java @@ -36,6 +36,7 @@ import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.MyPet.PetState; import de.Keyle.MyPet.api.entity.types.MyZombifiedPiglin; +import de.Keyle.MyPet.compat.v1_17_R1.CompatManager; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.syncher.EntityDataAccessor; @@ -61,7 +62,7 @@ public EntityMyZombifiedPiglin(Level world, MyPet myPet) { } @Override - protected String getDeathSound() { + protected String getMyPetDeathSound() { return "entity.zombified_piglin.death"; } @@ -103,7 +104,7 @@ public InteractionResult handlePlayerInteraction(Player entityhuman, Interaction // TODO REMOVE itemStack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { try { - ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); + CompatManager.ENTITY_LIVING_broadcastItemBreak.invoke(entityhuman1, enumhand); } catch (IllegalAccessException | InvocationTargetException ex) { ex.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/services/EntityConverterService.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/services/EntityConverterService.java index a91b4a230f..a31d5260ee 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/services/EntityConverterService.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/services/EntityConverterService.java @@ -20,37 +20,99 @@ package de.Keyle.MyPet.compat.v1_17_R1.services; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Set; + +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftTropicalFish; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftVillager; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftVillagerZombie; +import org.bukkit.entity.AbstractHorse; +import org.bukkit.entity.Ageable; +import org.bukkit.entity.Bee; +import org.bukkit.entity.Cat; +import org.bukkit.entity.ChestedHorse; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.Enderman; +import org.bukkit.entity.Fox; +import org.bukkit.entity.Horse; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Llama; +import org.bukkit.entity.MagmaCube; +import org.bukkit.entity.MushroomCow; +import org.bukkit.entity.Panda; +import org.bukkit.entity.Parrot; +import org.bukkit.entity.Phantom; +import org.bukkit.entity.Pig; +import org.bukkit.entity.PufferFish; +import org.bukkit.entity.Rabbit; +import org.bukkit.entity.Sheep; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.SkeletonHorse; +import org.bukkit.entity.Slime; +import org.bukkit.entity.TropicalFish; +import org.bukkit.entity.Villager; +import org.bukkit.entity.WanderingTrader; +import org.bukkit.entity.Wolf; +import org.bukkit.entity.Zombie; +import org.bukkit.entity.ZombieHorse; +import org.bukkit.entity.ZombieVillager; +import org.bukkit.inventory.HorseInventory; +import org.bukkit.inventory.ItemStack; + import com.google.common.collect.Sets; import com.mojang.serialization.Dynamic; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.Util; import de.Keyle.MyPet.api.entity.EquipmentSlot; import de.Keyle.MyPet.api.entity.MyPet; import de.Keyle.MyPet.api.entity.MyPetBaby; -import de.Keyle.MyPet.api.entity.types.*; +import de.Keyle.MyPet.api.entity.types.MyBee; +import de.Keyle.MyPet.api.entity.types.MyCat; +import de.Keyle.MyPet.api.entity.types.MyCreeper; +import de.Keyle.MyPet.api.entity.types.MyEnderman; +import de.Keyle.MyPet.api.entity.types.MyHorse; +import de.Keyle.MyPet.api.entity.types.MyIronGolem; +import de.Keyle.MyPet.api.entity.types.MyLlama; +import de.Keyle.MyPet.api.entity.types.MyMagmaCube; +import de.Keyle.MyPet.api.entity.types.MyMooshroom; +import de.Keyle.MyPet.api.entity.types.MyPanda; +import de.Keyle.MyPet.api.entity.types.MyParrot; +import de.Keyle.MyPet.api.entity.types.MyPhantom; +import de.Keyle.MyPet.api.entity.types.MyPig; +import de.Keyle.MyPet.api.entity.types.MyPufferfish; +import de.Keyle.MyPet.api.entity.types.MyRabbit; +import de.Keyle.MyPet.api.entity.types.MySheep; +import de.Keyle.MyPet.api.entity.types.MySkeleton; +import de.Keyle.MyPet.api.entity.types.MySkeletonHorse; +import de.Keyle.MyPet.api.entity.types.MySlime; +import de.Keyle.MyPet.api.entity.types.MyTropicalFish; +import de.Keyle.MyPet.api.entity.types.MyVillager; +import de.Keyle.MyPet.api.entity.types.MyWanderingTrader; +import de.Keyle.MyPet.api.entity.types.MyWitherSkeleton; +import de.Keyle.MyPet.api.entity.types.MyZombieHorse; +import de.Keyle.MyPet.api.entity.types.MyZombieVillager; import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.api.util.ReflectionUtil; import de.Keyle.MyPet.compat.v1_17_R1.util.inventory.ItemStackNBTConverter; -import de.keyle.knbt.*; -import net.minecraft.core.IRegistry; -import net.minecraft.nbt.DynamicOpsNBT; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.resources.MinecraftKey; -import net.minecraft.world.entity.ai.gossip.Reputation; -import net.minecraft.world.entity.monster.EntityZombieVillager; -import net.minecraft.world.entity.npc.EntityVillager; -import net.minecraft.world.item.trading.MerchantRecipeList; -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftTropicalFish; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftVillager; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftVillagerZombie; -import org.bukkit.entity.*; -import org.bukkit.inventory.HorseInventory; -import org.bukkit.inventory.ItemStack; - -import java.util.*; +import de.keyle.knbt.TagByte; +import de.keyle.knbt.TagCompound; +import de.keyle.knbt.TagInt; +import de.keyle.knbt.TagList; +import de.keyle.knbt.TagLong; +import net.minecraft.core.Registry; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.NbtOps; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.ai.gossip.GossipContainer; +import net.minecraft.world.item.trading.MerchantOffers; @Compat("v1_17_R1") public class EntityConverterService extends de.Keyle.MyPet.api.util.service.types.EntityConverterService { @@ -188,21 +250,21 @@ public void convertEntity(MyPet myPet, LivingEntity normalEntity) { if (villagerPet.hasOriginalData()) { TagCompound villagerTag = villagerPet.getOriginalData(); - EntityVillager entityVillager = ((CraftVillager) villagerEntity).getHandle(); + net.minecraft.world.entity.npc.Villager entityVillager = ((CraftVillager) villagerEntity).getHandle(); try { if (villagerTag.containsKey("Offers")) { TagCompound offersTag = villagerTag.get("Offers"); - NBTTagCompound vanillaNBT = (NBTTagCompound) ItemStackNBTConverter.compoundToVanillaCompound(offersTag); - entityVillager.b(new MerchantRecipeList(vanillaNBT)); + CompoundTag vanillaNBT = (CompoundTag) ItemStackNBTConverter.compoundToVanillaCompound(offersTag); + entityVillager.setOffers(new MerchantOffers(vanillaNBT)); } if (villagerTag.containsKey("Inventory")) { TagList inventoryTag = villagerTag.get("Inventory"); - NBTTagList vanillaNBT = (NBTTagList) ItemStackNBTConverter.compoundToVanillaCompound(inventoryTag); + ListTag vanillaNBT = (ListTag) ItemStackNBTConverter.compoundToVanillaCompound(inventoryTag); for (int i = 0; i < vanillaNBT.size(); ++i) { - net.minecraft.world.item.ItemStack itemstack = net.minecraft.world.item.ItemStack.a(vanillaNBT.getCompound(i)); + net.minecraft.world.item.ItemStack itemstack = net.minecraft.world.item.ItemStack.of(vanillaNBT.getCompound(i)); if (!itemstack.isEmpty()) { - entityVillager.getInventory().a(itemstack); + entityVillager.getInventory().addItem(itemstack); } } } @@ -212,12 +274,12 @@ public void convertEntity(MyPet myPet, LivingEntity normalEntity) { } if (villagerTag.containsKey("Gossips")) { TagList inventoryTag = villagerTag.get("Gossips"); - NBTTagList vanillaNBT = (NBTTagList) ItemStackNBTConverter.compoundToVanillaCompound(inventoryTag); - ((Reputation) ReflectionUtil.getFieldValue(EntityVillager.class, entityVillager, "by")) - .a(new Dynamic<>(DynamicOpsNBT.a, vanillaNBT)); + ListTag vanillaNBT = (ListTag) ItemStackNBTConverter.compoundToVanillaCompound(inventoryTag); + ((GossipContainer) ReflectionUtil.getFieldValue(net.minecraft.world.entity.npc.Villager.class, entityVillager, "by")) + .update(new Dynamic<>(NbtOps.INSTANCE, vanillaNBT)); } if (villagerTag.containsKey("LastRestock")) { - long lastRestock = villagerTag.getAs("LastRestock", TagLong.class).getLongData(); + long lastRestock = villagerTag.getAs("LastRestock", TagLong.class).getLongData(); ReflectionUtil.setFieldValue("bC", entityVillager, lastRestock); } if (villagerTag.containsKey("LastGossipDecay")) { @@ -234,18 +296,18 @@ public void convertEntity(MyPet myPet, LivingEntity normalEntity) { } if (villagerTag.containsKey("Xp")) { int xp = villagerTag.getAs("Xp", TagInt.class).getIntData(); - entityVillager.setExperience(xp); + entityVillager.setVillagerXp(xp); } } } else if (myPet instanceof MySlime) { ((Slime) normalEntity).setSize(((MySlime) myPet).getSize()); } else if (myPet instanceof MyZombieVillager) { Villager.Profession profession = Villager.Profession.values()[((MyZombieVillager) myPet).getProfession()]; - EntityZombieVillager nmsEntity = ((CraftVillagerZombie) normalEntity).getHandle(); + net.minecraft.world.entity.monster.ZombieVillager nmsEntity = ((CraftVillagerZombie) normalEntity).getHandle(); nmsEntity.setVillagerData(nmsEntity.getVillagerData() - .withType(IRegistry.ao.get(new MinecraftKey(((MyZombieVillager) myPet).getType().name().toLowerCase(Locale.ROOT)))) - .withLevel(((MyZombieVillager) myPet).getTradingLevel()) - .withProfession(IRegistry.ap.get(new MinecraftKey(profession.name().toLowerCase(Locale.ROOT))))); + .setType(Registry.VILLAGER_TYPE.get(new ResourceLocation(((MyZombieVillager) myPet).getType().name().toLowerCase(Locale.ROOT)))) + .setLevel(((MyZombieVillager) myPet).getTradingLevel()) + .setProfession(Registry.VILLAGER_PROFESSION.get(new ResourceLocation(profession.name().toLowerCase(Locale.ROOT))))); } else if (myPet instanceof MyWitherSkeleton) { normalEntity.getEquipment().setItemInMainHand(new ItemStack(Material.STONE_SWORD)); } else if (myPet instanceof MySkeleton) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetArrow.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetArrow.java index 00c54e15b2..e112a24f1e 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetArrow.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetArrow.java @@ -24,15 +24,15 @@ import de.Keyle.MyPet.api.util.Compat; import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetArrow; -import io.lumine.xikage.mythicmobs.utils.shadows.nbt.NBTTagCompound; -import net.minecraft.util.datafix.fixes.EntityTippedArrowFix; +import net.minecraft.nbt.CompoundTag; import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.projectile.Arrow; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; @Compat("v1_17_R1") -public class MyPetArrow extends EntityTippedArrow implements EntityMyPetProjectile { +public class MyPetArrow extends Arrow implements EntityMyPetProjectile { protected CraftMyPetArrow bukkitEntity = null; @@ -59,8 +59,8 @@ public void addAdditionalSaveData(CompoundTag nbttagcompound) { } @Override - protected ItemStack getItemStack() { - return new ItemStack(Items.mh); + protected ItemStack getPickupItem() { + return new ItemStack(Items.ARROW); } @Override @@ -71,7 +71,7 @@ public void readAdditionalSaveData(CompoundTag nbttagcompound) { public void tick() { try { super.tick(); - if (this.b) { + if (this.inGround) { discard(); } } catch (Exception e) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetDragonFireball.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetDragonFireball.java index fa7a7f4a5c..0585581729 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetDragonFireball.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetDragonFireball.java @@ -25,13 +25,14 @@ import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetDragonFireball; import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.projectile.DragonFireball; import net.minecraft.world.level.Level; +import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; -import net.royawesome.jlibnoise.MathHelper; @Compat("v1_17_R1") public class MyPetDragonFireball extends DragonFireball implements EntityMyPetProjectile { @@ -58,10 +59,10 @@ public void setDirection(double d0, double d1, double d2) { d0 += this.random.nextGaussian() * 0.2D; d1 += this.random.nextGaussian() * 0.2D; d2 += this.random.nextGaussian() * 0.2D; - double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); - this.b = (d0 / d3 * 0.1D); //TODO - this.c = (d1 / d3 * 0.1D); - this.d = (d2 / d3 * 0.1D); + double d3 = Mth.sqrt((float) (d0 * d0 + d1 * d1 + d2 * d2)); + this.xPower = (d0 / d3 * 0.1D); + this.yPower = (d1 / d3 * 0.1D); + this.zPower = (d2 / d3 * 0.1D); } @Override @@ -83,7 +84,7 @@ public void readAdditionalSaveData(CompoundTag nbtTagCompound) { @Override protected void onHit(HitResult movingObjectPosition) { if (movingObjectPosition.getType() == HitResult.Type.ENTITY) { - Entity entity = ((HitResult) movingObjectPosition).getEntity(); //TODO + Entity entity = ((EntityHitResult) movingObjectPosition).getEntity(); if (entity instanceof LivingEntity) { entity.hurt(DamageSource.thrown(this, getShooter()), damage); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLargeFireball.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLargeFireball.java index 19f1717dad..dc70fa1316 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLargeFireball.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLargeFireball.java @@ -25,6 +25,7 @@ import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetLargeFireball; import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; @@ -32,7 +33,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; -import net.royawesome.jlibnoise.MathHelper; @Compat("v1_17_R1") public class MyPetLargeFireball extends LargeFireball implements EntityMyPetProjectile { @@ -42,7 +42,7 @@ public class MyPetLargeFireball extends LargeFireball implements EntityMyPetProj protected CraftMyPetLargeFireball bukkitEntity = null; public MyPetLargeFireball(Level world, EntityMyPet entityliving, double d0, double d1, double d2) { - super(world, entityliving, d0, d1, d2, 1); // TODO: 2021/06/28 temp value (i) - 2021/08/19 is this done? Where is i here? + super(world, entityliving, d0, d1, d2, 1); } @Override @@ -59,10 +59,10 @@ public void setDirection(double d0, double d1, double d2) { d0 += this.random.nextGaussian() * 0.2D; d1 += this.random.nextGaussian() * 0.2D; d2 += this.random.nextGaussian() * 0.2D; - double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); - this.b = (d0 / d3 * 0.1D); - this.c = (d1 / d3 * 0.1D); - this.d = (d2 / d3 * 0.1D); + double d3 = Mth.sqrt((float)(d0 * d0 + d1 * d1 + d2 * d2)); + this.xPower = (d0 / d3 * 0.1D); + this.yPower = (d1 / d3 * 0.1D); + this.zPower = (d2 / d3 * 0.1D); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLlamaSpit.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLlamaSpit.java index 1c125b76f0..850ff07e86 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLlamaSpit.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetLlamaSpit.java @@ -27,6 +27,7 @@ import lombok.Getter; import lombok.Setter; import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -35,7 +36,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; -import net.royawesome.jlibnoise.MathHelper; @Compat("v1_17_R1") public class MyPetLlamaSpit extends LlamaSpit implements EntityMyPetProjectile { @@ -48,9 +48,9 @@ public class MyPetLlamaSpit extends LlamaSpit implements EntityMyPetProjectile { public MyPetLlamaSpit(Level world, EntityMyPet entityMyPet) { super(EntityType.LLAMA_SPIT, world); this.setOwner(entityMyPet); - this.setPos(entityMyPet.getX() - (double) (entityMyPet.getBbWidth() + 1.0F) * 0.5D * (double) MathHelper.sin(entityMyPet.aE * 0.017453292F), //TODO + this.setPos(entityMyPet.getX() - (double) (entityMyPet.getBbWidth() + 1.0F) * 0.5D * (double) Mth.sin(entityMyPet.EXTRA_RENDER_CULLING_SIZE_WITH_BIG_HAT * 0.017453292F), entityMyPet.getY() + (double) entityMyPet.getEyeHeight() - 0.10000000149011612D, - entityMyPet.getZ() + (double) (entityMyPet.getBbWidth() + 1.0F) * 0.5D * (double) MathHelper.cos(entityMyPet.aE * 0.017453292F)); + entityMyPet.getZ() + (double) (entityMyPet.getBbWidth() + 1.0F) * 0.5D * (double) Mth.cos(entityMyPet.EXTRA_RENDER_CULLING_SIZE_WITH_BIG_HAT * 0.017453292F)); } @Override @@ -84,7 +84,7 @@ public void onHit(HitResult movingObjectPosition) { if (movingObjectPosition.getType() == HitResult.Type.ENTITY) { Entity entity = ((EntityHitResult) movingObjectPosition).getEntity(); if (entity instanceof LivingEntity) { - entity.hurt(DamageSource.a(this, getShooter()), damage); //TODO + entity.hurt(DamageSource.indirectMobAttack(this, getShooter()), damage); } } this.discard(); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSmallFireball.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSmallFireball.java index ea4d808a1a..d646f3c597 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSmallFireball.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetSmallFireball.java @@ -25,6 +25,7 @@ import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetSmallFireball; import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; @@ -32,7 +33,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; -import net.royawesome.jlibnoise.MathHelper; @Compat("v1_17_R1") public class MyPetSmallFireball extends SmallFireball implements EntityMyPetProjectile { @@ -59,10 +59,10 @@ public void setDirection(double d0, double d1, double d2) { d0 += this.random.nextGaussian() * 0.2D; d1 += this.random.nextGaussian() * 0.2D; d2 += this.random.nextGaussian() * 0.2D; - double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); - this.b = (d0 / d3 * 0.1D); //TODO - this.c = (d1 / d3 * 0.1D); - this.d = (d2 / d3 * 0.1D); + double d3 = Mth.sqrt((float)(d0 * d0 + d1 * d1 + d2 * d2)); + this.xPower = (d0 / d3 * 0.1D); //TODO + this.yPower = (d1 / d3 * 0.1D); + this.zPower = (d2 / d3 * 0.1D); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetTrident.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetTrident.java index 3b8ba4f988..5632e6e2e0 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetTrident.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetTrident.java @@ -65,7 +65,7 @@ public void readAdditionalSaveData(CompoundTag nbtTagCompound) { public void tick() { try { super.tick(); - if (this.b) { //TODO + if (this.inGround) { //TODO discard(); } } catch (Exception e) { diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetWitherSkull.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetWitherSkull.java index c8140c1e2f..ac28683337 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetWitherSkull.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/skill/skills/ranged/nms/MyPetWitherSkull.java @@ -25,6 +25,7 @@ import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; import de.Keyle.MyPet.compat.v1_17_R1.skill.skills.ranged.bukkit.CraftMyPetWitherSkull; import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; @@ -32,7 +33,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; -import net.royawesome.jlibnoise.MathHelper; @Compat("v1_17_R1") public class MyPetWitherSkull extends WitherSkull implements EntityMyPetProjectile { @@ -59,10 +59,10 @@ public void setDirection(double d0, double d1, double d2) { d0 += this.random.nextGaussian() * 0.2D; d1 += this.random.nextGaussian() * 0.2D; d2 += this.random.nextGaussian() * 0.2D; - double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); - this.b = (d0 / d3 * 0.1D); //TODO - this.c = (d1 / d3 * 0.1D); - this.d = (d2 / d3 * 0.1D); + double d3 = Mth.sqrt((float)(d0 * d0 + d1 * d1 + d2 * d2)); + this.xPower = (d0 / d3 * 0.1D); //TODO + this.yPower = (d1 / d3 * 0.1D); + this.zPower = (d2 / d3 * 0.1D); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/iconmenu/IconMenuInventory.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/iconmenu/IconMenuInventory.java index d6041aa965..2dac34ce06 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/iconmenu/IconMenuInventory.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/iconmenu/IconMenuInventory.java @@ -43,7 +43,6 @@ import de.keyle.knbt.TagList; import de.keyle.knbt.TagShort; import de.keyle.knbt.TagString; -import io.lumine.xikage.mythicmobs.utils.shadows.nbt.NBTTagCompound; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.StringTag; @@ -58,7 +57,7 @@ public class IconMenuInventory implements de.Keyle.MyPet.api.gui.IconMenuInvento static { try { Class craftMetaItemClass = Class.forName("org.bukkit.craftbukkit.v1_17_R1.inventory.CraftMetaItem"); - applyToItemMethod = ReflectionUtil.getMethod(craftMetaItemClass, "applyToItem", NBTTagCompound.class); + applyToItemMethod = ReflectionUtil.getMethod(craftMetaItemClass, "applyToItem", CompoundTag.class); } catch (ClassNotFoundException e) { e.printStackTrace(); } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java index 28d5c2d688..0728acefe5 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java @@ -78,9 +78,9 @@ public CustomInventory(int size, String name) { setSize(size); setName(name); } - + @Override - public int getSize() { + public int getContainerSize() { return this.size; } @@ -132,7 +132,7 @@ public int addItem(org.bukkit.inventory.ItemStack itemAdd) { } itemAdd = itemAdd.clone(); - for (int i = 0; i < this.getSize(); i++) { + for (int i = 0; i < this.getContainerSize(); i++) { CraftItemStack craftItem = CraftItemStack.asCraftMirror(getItem(i)); if (ItemStackComparator.compareItem(itemAdd, craftItem)) { @@ -149,7 +149,7 @@ public int addItem(org.bukkit.inventory.ItemStack itemAdd) { } } if (itemAdd.getAmount() > 0) { - for (int i = 0; i < this.getSize(); i++) { + for (int i = 0; i < this.getContainerSize(); i++) { if (getItem(i) == ItemStack.EMPTY) { if (itemAdd.getAmount() <= itemAdd.getMaxStackSize()) { setItem(i, CraftItemStack.asNMSCopy(itemAdd.clone())); @@ -190,7 +190,7 @@ public String getName() { @Override public void dropContentAt(Location loc) { Level world = ((CraftWorld) loc.getWorld()).getHandle(); - for (int i = 0; i < this.getSize(); i++) { + for (int i = 0; i < this.getContainerSize(); i++) { ItemStack is = this.removeItemNoUpdate(i); if (is != null && !is.isEmpty()) { is = is.copy(); @@ -223,7 +223,7 @@ public ItemStack removeItem(int slot, int subtract) { @Override public List getContents() { List itemStack = new LinkedList<>(); - for (int i = 0; i < getSize(); i++) { + for (int i = 0; i < getContainerSize(); i++) { itemStack.add(i, items.get(i)); } return itemStack; @@ -306,7 +306,7 @@ public void open(Player player) { container = CraftEventFactory.callInventoryOpenEvent(entityPlayer, container); if (container != null) { MenuType customSize = MenuType.GENERIC_9x1; - switch (this.getSize()) { + switch (this.getContainerSize()) { case 18: customSize = MenuType.GENERIC_9x2; break; diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/CraftMyPet.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/CraftMyPet.java index 0a91722049..b8a82f8816 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/CraftMyPet.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/CraftMyPet.java @@ -153,7 +153,7 @@ public void forgetTarget() { } public void setTarget(LivingEntity target, TargetPriority priority) { - getHandle().setTarget(target, priority); + getHandle().setMyPetTarget(target, priority); } @Override diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/EntityMyPet.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/EntityMyPet.java index a193f3537d..315e880da9 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/EntityMyPet.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/EntityMyPet.java @@ -190,7 +190,8 @@ public TargetPriority getTargetPriority() { return targetPriority; } - public LivingEntity getTarget() { + @Override + public LivingEntity getMyPetTarget() { if (target != null) { if (target.isAlive()) { return (LivingEntity) target.getBukkitEntity(); @@ -200,7 +201,8 @@ public LivingEntity getTarget() { return null; } - public void setTarget(LivingEntity entity, TargetPriority priority) { + @Override + public void setMyPetTarget(LivingEntity entity, TargetPriority priority) { if (entity == null || entity.isDead() || entity instanceof ArmorStand || !(entity instanceof CraftLivingEntity)) { forgetTarget(); return; diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/attack/MeleeAttack.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/attack/MeleeAttack.java index 90e70f3114..a7a406927e 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/attack/MeleeAttack.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/attack/MeleeAttack.java @@ -61,7 +61,7 @@ public boolean shouldStart() { if (!this.petEntity.hasTarget()) { return false; } - EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (targetEntity instanceof EntityArmorStand) { return false; @@ -95,7 +95,7 @@ public boolean shouldStart() { public boolean shouldFinish() { if (!this.petEntity.hasTarget() || !this.petEntity.canMove()) { return true; - } else if (this.targetEntity.getBukkitEntity() != this.petEntity.getTarget()) { + } else if (this.targetEntity.getBukkitEntity() != this.petEntity.getMyPetTarget()) { return true; } if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.f(targetEntity.locX, targetEntity.getBoundingBox().b, targetEntity.locZ) >= 20) { diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/attack/RangedAttack.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/attack/RangedAttack.java index cccf19da5f..8e08b2f4c0 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/attack/RangedAttack.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/attack/RangedAttack.java @@ -63,7 +63,7 @@ public boolean shouldStart() { return false; } - EntityLiving target = ((CraftLivingEntity) this.entityMyPet.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.entityMyPet.getMyPetTarget()).getHandle(); if (target instanceof EntityArmorStand) { return false; @@ -102,7 +102,7 @@ public boolean shouldFinish() { if (!entityMyPet.hasTarget() || myPet.getRangedDamage() <= 0 || !entityMyPet.canMove()) { return true; } - if (this.target.getBukkitEntity() != this.entityMyPet.getTarget()) { + if (this.target.getBukkitEntity() != this.entityMyPet.getMyPetTarget()) { return true; } double meleeDamage = myPet.getDamage(); diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/EatGrass.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/EatGrass.java index e2ad1ca57d..940e3c6f4a 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/EatGrass.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/EatGrass.java @@ -53,7 +53,7 @@ public boolean shouldStart() { return false; } else if (entityMySheep.getRandom().nextInt(1000) != 0) { return false; - } else if (this.entityMySheep.getTarget() != null && !this.entityMySheep.getTarget().isDead()) { + } else if (this.entityMySheep.getMyPetTarget() != null && !this.entityMySheep.getMyPetTarget().isDead()) { return false; } int blockLocX = MathHelper.floor(this.entityMySheep.locX); diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/FollowOwner.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/FollowOwner.java index b8111f9be7..029a08ab71 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/FollowOwner.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/FollowOwner.java @@ -59,7 +59,7 @@ public boolean shouldStart() { } if (!this.petEntity.canMove()) { return false; - } else if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + } else if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } else if (this.petEntity.getOwner() == null) { return false; @@ -81,7 +81,7 @@ public boolean shouldFinish() { return true; } else if (!this.petEntity.canMove()) { return true; - } else if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + } else if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return true; } return false; diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/LookAtPlayer.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/LookAtPlayer.java index a016712f69..d8c01c94d5 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/LookAtPlayer.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/LookAtPlayer.java @@ -50,7 +50,7 @@ public boolean shouldStart() { if (this.petEntity.getRandom().nextFloat() >= this.lookAtPlayerChance) { return false; } - if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } if (this.petEntity.passenger != null) { diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/RandomLookaround.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/RandomLookaround.java index 343472761d..881eb352c5 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/RandomLookaround.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/RandomLookaround.java @@ -37,7 +37,7 @@ public RandomLookaround(EntityMyPet petEntity) { @Override public boolean shouldStart() { - if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } if (this.petEntity.passenger != null) { diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/Sprint.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/Sprint.java index 532009e94e..f3ef7ba4fd 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/Sprint.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/movement/Sprint.java @@ -58,7 +58,7 @@ public boolean shouldStart() { return false; } - EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (!targetEntity.isAlive()) { return false; diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/BehaviorAggressiveTarget.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/BehaviorAggressiveTarget.java index e863693eef..3b0ee20d1f 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/BehaviorAggressiveTarget.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/BehaviorAggressiveTarget.java @@ -107,11 +107,11 @@ public boolean shouldStart() { public boolean shouldFinish() { if (!petEntity.canMove()) { return true; - } else if (petEntity.getTarget() == null) { + } else if (petEntity.getMyPetTarget() == null) { return true; } - EntityLiving target = ((CraftLivingEntity) petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) petEntity.getMyPetTarget()).getHandle(); if (!target.isAlive()) { return true; @@ -133,7 +133,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Aggressive); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Aggressive); } @Override diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/BehaviorDuelTarget.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/BehaviorDuelTarget.java index 77aff794c2..c73b3cc2b6 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/BehaviorDuelTarget.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/BehaviorDuelTarget.java @@ -99,7 +99,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); Behavior behaviorSkill = myPet.getSkills().get(Behavior.class); if (behaviorSkill.getBehavior() != BehaviorMode.Duel) { @@ -118,7 +118,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget(this.target.getBukkitEntity(), TargetPriority.Duel); + petEntity.setMyPetTarget(this.target.getBukkitEntity(), TargetPriority.Duel); setDuelOpponent(this.target); if (target.getTargetSelector().hasGoal("DuelTarget")) { BehaviorDuelTarget duelGoal = (BehaviorDuelTarget) target.getTargetSelector().getGoal("DuelTarget"); diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/BehaviorFarmTarget.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/BehaviorFarmTarget.java index 64e7276c81..ea6769d56d 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/BehaviorFarmTarget.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/BehaviorFarmTarget.java @@ -87,7 +87,7 @@ public boolean shouldFinish() { if (!this.petEntity.hasTarget()) { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (!target.isAlive()) { return true; @@ -109,7 +109,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Farm); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Farm); } @Override diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/ControlTarget.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/ControlTarget.java index f10ebc7c93..dc8779518d 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/ControlTarget.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/ControlTarget.java @@ -129,7 +129,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (target.world != petEntity.world) { return true; @@ -143,7 +143,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Control); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Control); } @Override diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/HurtByTarget.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/HurtByTarget.java index 9795381a12..9cff3b369b 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/HurtByTarget.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/HurtByTarget.java @@ -98,7 +98,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (target.world != petEntity.world) { return true; @@ -112,7 +112,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.GetHurt); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.GetHurt); } @Override diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/OwnerHurtByTarget.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/OwnerHurtByTarget.java index dbbc0f2063..6ee2d2108f 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/OwnerHurtByTarget.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/ai/target/OwnerHurtByTarget.java @@ -125,7 +125,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (target.world != petEntity.world) { return true; @@ -139,7 +139,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.lastDamager.getBukkitEntity(), TargetPriority.OwnerGetsHurt); + petEntity.setMyPetTarget((LivingEntity) this.lastDamager.getBukkitEntity(), TargetPriority.OwnerGetsHurt); } @Override diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/types/EntityMyMagmaCube.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/types/EntityMyMagmaCube.java index e15f400446..226b5ab0b4 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/types/EntityMyMagmaCube.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/types/EntityMyMagmaCube.java @@ -60,7 +60,7 @@ public void onLivingUpdate() { if (this.onGround && jumpDelay-- <= 0) { getControllerJump().a(); jumpDelay = (this.random.nextInt(20) + 10); - if (getTarget() != null) { + if (getMyPetTarget() != null) { jumpDelay /= 3; } makeSound(getDeathSound(), 1.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/types/EntityMyRabbit.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/types/EntityMyRabbit.java index ba222dcd31..a2458453d6 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/types/EntityMyRabbit.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/types/EntityMyRabbit.java @@ -101,7 +101,7 @@ public void onLivingUpdate() { if (this.onGround && getNavigation().j() != null && jumpDelay-- <= 0) { getControllerJump().a(); jumpDelay = (this.random.nextInt(10) + 10); - if (getTarget() != null) { + if (getMyPetTarget() != null) { jumpDelay /= 3; } this.world.broadcastEntityEffect(this, (byte) 1); diff --git a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/types/EntityMySlime.java b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/types/EntityMySlime.java index 69118bc5dc..05f4f877de 100644 --- a/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/types/EntityMySlime.java +++ b/modules/v1_8_R3/src/main/java/de/Keyle/MyPet/compat/v1_8_R3/entity/types/EntityMySlime.java @@ -75,7 +75,7 @@ public void onLivingUpdate() { if (this.onGround && jumpDelay-- <= 0) { getControllerJump().a(); jumpDelay = (this.random.nextInt(20) + 10); - if (getTarget() != null) { + if (getMyPetTarget() != null) { jumpDelay /= 3; } makeSound(getDeathSound(), 1.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/CraftMyPet.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/CraftMyPet.java index e148e4da75..c0a468c739 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/CraftMyPet.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/CraftMyPet.java @@ -130,7 +130,7 @@ public void forgetTarget() { } public void setTarget(LivingEntity target, TargetPriority priority) { - getHandle().setTarget(target, priority); + getHandle().setMyPetTarget(target, priority); } @Override diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/EntityMyPet.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/EntityMyPet.java index d321b28f15..d173740dee 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/EntityMyPet.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/EntityMyPet.java @@ -197,8 +197,9 @@ public boolean hasTarget() { public TargetPriority getTargetPriority() { return targetPriority; } - - public LivingEntity getTarget() { + + @Override + public LivingEntity getMyPetTarget() { if (target != null) { if (target.isAlive()) { return (LivingEntity) target.getBukkitEntity(); @@ -208,7 +209,8 @@ public LivingEntity getTarget() { return null; } - public void setTarget(LivingEntity entity, TargetPriority priority) { + @Override + public void setMyPetTarget(LivingEntity entity, TargetPriority priority) { if (entity == null || entity.isDead() || entity instanceof ArmorStand || !(entity instanceof CraftLivingEntity)) { forgetTarget(); return; diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/attack/MeleeAttack.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/attack/MeleeAttack.java index 576157ffa4..2692607091 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/attack/MeleeAttack.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/attack/MeleeAttack.java @@ -58,7 +58,7 @@ public boolean shouldStart() { if (!this.petEntity.hasTarget()) { return false; } - EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (targetEntity instanceof EntityArmorStand) { return false; @@ -92,7 +92,7 @@ public boolean shouldStart() { public boolean shouldFinish() { if (!this.petEntity.hasTarget() || !this.petEntity.canMove()) { return true; - } else if (this.targetEntity.getBukkitEntity() != this.petEntity.getTarget()) { + } else if (this.targetEntity.getBukkitEntity() != this.petEntity.getMyPetTarget()) { return true; } if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.f(targetEntity.locX, targetEntity.getBoundingBox().b, targetEntity.locZ) >= 20) { diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/attack/RangedAttack.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/attack/RangedAttack.java index 362c4e0100..915f67d842 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/attack/RangedAttack.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/attack/RangedAttack.java @@ -63,7 +63,7 @@ public boolean shouldStart() { return false; } - EntityLiving target = ((CraftLivingEntity) this.entityMyPet.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.entityMyPet.getMyPetTarget()).getHandle(); if (target instanceof EntityArmorStand) { return false; @@ -102,7 +102,7 @@ public boolean shouldFinish() { if (!entityMyPet.hasTarget() || myPet.getRangedDamage() <= 0 || !entityMyPet.canMove()) { return true; } - if (this.target.getBukkitEntity() != entityMyPet.getTarget()) { + if (this.target.getBukkitEntity() != entityMyPet.getMyPetTarget()) { return true; } double meleeDamage = myPet.getDamage(); diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/EatGrass.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/EatGrass.java index 6c806f01fb..da522dc461 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/EatGrass.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/EatGrass.java @@ -53,7 +53,7 @@ public boolean shouldStart() { return false; } else if (entityMySheep.getRandom().nextInt(1000) != 0) { return false; - } else if (this.entityMySheep.getTarget() != null && !this.entityMySheep.getTarget().isDead()) { + } else if (this.entityMySheep.getMyPetTarget() != null && !this.entityMySheep.getMyPetTarget().isDead()) { return false; } int blockLocX = MathHelper.floor(this.entityMySheep.locX); diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/FollowOwner.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/FollowOwner.java index fa50ceb8ab..040ea70603 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/FollowOwner.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/FollowOwner.java @@ -59,7 +59,7 @@ public boolean shouldStart() { } if (!this.petEntity.canMove()) { return false; - } else if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + } else if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } else if (this.petEntity.getOwner() == null) { return false; @@ -81,7 +81,7 @@ public boolean shouldFinish() { return true; } else if (!this.petEntity.canMove()) { return true; - } else if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + } else if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return true; } return false; diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/LookAtPlayer.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/LookAtPlayer.java index 7b4a1842c0..3cd0ee1beb 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/LookAtPlayer.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/LookAtPlayer.java @@ -50,7 +50,7 @@ public boolean shouldStart() { if (this.petEntity.getRandom().nextFloat() >= this.lookAtPlayerChance) { return false; } - if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } if (this.petEntity.isVehicle()) { diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/RandomLookaround.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/RandomLookaround.java index 46b0cb6203..ab2f337fb3 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/RandomLookaround.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/RandomLookaround.java @@ -37,7 +37,7 @@ public RandomLookaround(EntityMyPet petEntity) { @Override public boolean shouldStart() { - if (this.petEntity.getTarget() != null && !this.petEntity.getTarget().isDead()) { + if (this.petEntity.getMyPetTarget() != null && !this.petEntity.getMyPetTarget().isDead()) { return false; } if (this.petEntity.isVehicle()) { diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/Sprint.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/Sprint.java index 7e7bdf2740..bb8d7c75b2 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/Sprint.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/movement/Sprint.java @@ -58,7 +58,7 @@ public boolean shouldStart() { return false; } - EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (!targetEntity.isAlive()) { return false; diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/BehaviorAggressiveTarget.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/BehaviorAggressiveTarget.java index 9131b5ac51..0a958a1f55 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/BehaviorAggressiveTarget.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/BehaviorAggressiveTarget.java @@ -107,11 +107,11 @@ public boolean shouldStart() { public boolean shouldFinish() { if (!petEntity.canMove()) { return true; - } else if (petEntity.getTarget() == null) { + } else if (petEntity.getMyPetTarget() == null) { return true; } - EntityLiving target = ((CraftLivingEntity) petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) petEntity.getMyPetTarget()).getHandle(); if (!target.isAlive()) { return true; @@ -133,7 +133,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Aggressive); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Aggressive); } @Override diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/BehaviorDuelTarget.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/BehaviorDuelTarget.java index c12a4682e6..03b48acd73 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/BehaviorDuelTarget.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/BehaviorDuelTarget.java @@ -99,7 +99,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); Behavior behaviorSkill = myPet.getSkills().get(Behavior.class); if (behaviorSkill.getBehavior() != BehaviorMode.Duel) { @@ -118,7 +118,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget(this.target.getBukkitEntity(), TargetPriority.Duel); + petEntity.setMyPetTarget(this.target.getBukkitEntity(), TargetPriority.Duel); setDuelOpponent(this.target); if (target.getTargetSelector().hasGoal("DuelTarget")) { BehaviorDuelTarget duelGoal = (BehaviorDuelTarget) target.getTargetSelector().getGoal("DuelTarget"); diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/BehaviorFarmTarget.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/BehaviorFarmTarget.java index a4322dbeb5..6ca279b0ef 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/BehaviorFarmTarget.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/BehaviorFarmTarget.java @@ -87,7 +87,7 @@ public boolean shouldFinish() { if (!this.petEntity.hasTarget()) { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (!target.isAlive()) { return true; @@ -109,7 +109,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Farm); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Farm); } @Override diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/ControlTarget.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/ControlTarget.java index 9d24199a3b..ab2199dfc5 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/ControlTarget.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/ControlTarget.java @@ -129,7 +129,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (target.world != petEntity.world) { return true; @@ -143,7 +143,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Control); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.Control); } @Override diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/HurtByTarget.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/HurtByTarget.java index 2a18ecf4e7..061a2c4464 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/HurtByTarget.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/HurtByTarget.java @@ -98,7 +98,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (target.world != petEntity.world) { return true; @@ -112,7 +112,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.GetHurt); + petEntity.setMyPetTarget((LivingEntity) this.target.getBukkitEntity(), TargetPriority.GetHurt); } @Override diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/OwnerHurtByTarget.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/OwnerHurtByTarget.java index 4137d009fd..66095dba65 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/OwnerHurtByTarget.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/ai/target/OwnerHurtByTarget.java @@ -125,7 +125,7 @@ public boolean shouldFinish() { return true; } - EntityLiving target = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle(); + EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle(); if (target.world != petEntity.world) { return true; @@ -139,7 +139,7 @@ public boolean shouldFinish() { @Override public void start() { - petEntity.setTarget((LivingEntity) this.lastDamager.getBukkitEntity(), TargetPriority.OwnerGetsHurt); + petEntity.setMyPetTarget((LivingEntity) this.lastDamager.getBukkitEntity(), TargetPriority.OwnerGetsHurt); } @Override diff --git a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/types/EntityMyRabbit.java b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/types/EntityMyRabbit.java index 9ad243cb25..142f51186c 100644 --- a/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/types/EntityMyRabbit.java +++ b/modules/v1_9_R2/src/main/java/de/Keyle/MyPet/compat/v1_9_R2/entity/types/EntityMyRabbit.java @@ -97,7 +97,7 @@ public void onLivingUpdate() { if (this.onGround && getNavigation().k() != null && jumpDelay-- <= 0) { getControllerJump().a(); jumpDelay = (this.random.nextInt(10) + 10); - if (getTarget() != null) { + if (getMyPetTarget() != null) { jumpDelay /= 3; } this.world.broadcastEntityEffect(this, (byte) 1); diff --git a/pom.xml b/pom.xml index fb4115e83d..c91653f549 100644 --- a/pom.xml +++ b/pom.xml @@ -31,11 +31,11 @@ modules/API modules/Skills - modules/v1_16_R3 modules/v1_8_R3 modules/v1_9_R2 modules/v1_12_R1 modules/v1_16_R1 + modules/v1_16_R3 modules/v1_17_R1 modules/GUI modules/Plugin From 5fd1478e9a73fe280e8387c59eb3e6a46074852e Mon Sep 17 00:00:00 2001 From: Jakllp <57708725+Jakllp@users.noreply.github.com> Date: Tue, 24 Aug 2021 23:05:50 +0200 Subject: [PATCH 6/6] Axolotl+Goats - Bump to dev5 New: - Added Goats - Added Axolotls Bump to dev5 --- .../de/Keyle/MyPet/api/Configuration.java | 6 + .../de/Keyle/MyPet/api/entity/MyPetType.java | 6 + .../MyPet/api/entity/types/MyAxolotl.java | 32 ++++++ .../Keyle/MyPet/api/entity/types/MyGoat.java | 31 +++++ modules/MyPet/pom.xml | 2 +- .../commands/admin/CommandOptionCreate.java | 9 ++ .../de/Keyle/MyPet/entity/MyPetClass.java | 2 + .../Keyle/MyPet/entity/types/MyAxolotl.java | 91 +++++++++++++++ .../de/Keyle/MyPet/entity/types/MyGoat.java | 71 ++++++++++++ .../entity/types/EntityMyAxolotl.java | 79 +++++++++++++ .../v1_17_R1/entity/types/EntityMyBat.java | 2 - .../v1_17_R1/entity/types/EntityMyGoat.java | 107 ++++++++++++++++++ .../entity/types/EntityMyMooshroom.java | 2 +- .../v1_17_R1/services/EggIconService.java | 6 + 14 files changed, 442 insertions(+), 4 deletions(-) create mode 100644 modules/API/src/main/java/de/Keyle/MyPet/api/entity/types/MyAxolotl.java create mode 100644 modules/API/src/main/java/de/Keyle/MyPet/api/entity/types/MyGoat.java create mode 100644 modules/Plugin/src/main/java/de/Keyle/MyPet/entity/types/MyAxolotl.java create mode 100644 modules/Plugin/src/main/java/de/Keyle/MyPet/entity/types/MyGoat.java create mode 100644 modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyAxolotl.java create mode 100644 modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGoat.java diff --git a/modules/API/src/main/java/de/Keyle/MyPet/api/Configuration.java b/modules/API/src/main/java/de/Keyle/MyPet/api/Configuration.java index 5e136bbed3..c018126f5a 100644 --- a/modules/API/src/main/java/de/Keyle/MyPet/api/Configuration.java +++ b/modules/API/src/main/java/de/Keyle/MyPet/api/Configuration.java @@ -238,6 +238,12 @@ public static class Ghast { public static boolean CAN_GLIDE = true; } + public static class Goat { + public static boolean CAN_GIVE_MILK = true; + public static ConfigItem GROW_UP_ITEM; + + } + public static class Hoglin { public static ConfigItem GROW_UP_ITEM; diff --git a/modules/API/src/main/java/de/Keyle/MyPet/api/entity/MyPetType.java b/modules/API/src/main/java/de/Keyle/MyPet/api/entity/MyPetType.java index 111ca4679a..8109b124f9 100644 --- a/modules/API/src/main/java/de/Keyle/MyPet/api/entity/MyPetType.java +++ b/modules/API/src/main/java/de/Keyle/MyPet/api/entity/MyPetType.java @@ -29,6 +29,9 @@ import java.util.List; public enum MyPetType { + Axolotl("AXOLOTL", "1.17.1", MyAxolotl.class, new Compat<>() + .v("1.17.1", "axolotl") + .search()), Bat("BAT", "1.7.10", MyBat.class, new Compat<>() .v("1.7.10", 65) .v("1.13", "bat") @@ -99,6 +102,9 @@ public enum MyPetType { .v("1.7.10", 56) .v("1.13", "ghast") .search()), + Goat("GOAT", "1.17.1", MyGoat.class, new Compat<>() + .v("1.17.1", "goat") + .search()), Giant("GIANT", "1.7.10", MyGiant.class, new Compat<>() .v("1.7.10", 53) .v("1.13", "giant") diff --git a/modules/API/src/main/java/de/Keyle/MyPet/api/entity/types/MyAxolotl.java b/modules/API/src/main/java/de/Keyle/MyPet/api/entity/types/MyAxolotl.java new file mode 100644 index 0000000000..e33323a98b --- /dev/null +++ b/modules/API/src/main/java/de/Keyle/MyPet/api/entity/types/MyAxolotl.java @@ -0,0 +1,32 @@ +/* + * This file is part of MyPet + * + * Copyright © 2011-2019 Keyle + * MyPet is licensed under the GNU Lesser General Public License. + * + * MyPet is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MyPet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.Keyle.MyPet.api.entity.types; + +import de.Keyle.MyPet.api.entity.DefaultInfo; +import de.Keyle.MyPet.api.entity.MyPet; +import de.Keyle.MyPet.api.entity.MyPetBaby; +@DefaultInfo(food = {"bucket"}) +public interface MyAxolotl extends MyPet, MyPetBaby { + + int getVariant(); + + void setVariant(int variant); +} \ No newline at end of file diff --git a/modules/API/src/main/java/de/Keyle/MyPet/api/entity/types/MyGoat.java b/modules/API/src/main/java/de/Keyle/MyPet/api/entity/types/MyGoat.java new file mode 100644 index 0000000000..e269fa7be2 --- /dev/null +++ b/modules/API/src/main/java/de/Keyle/MyPet/api/entity/types/MyGoat.java @@ -0,0 +1,31 @@ +/* + * This file is part of MyPet + * + * Copyright © 2011-2019 Keyle + * MyPet is licensed under the GNU Lesser General Public License. + * + * MyPet is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MyPet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.Keyle.MyPet.api.entity.types; + +import de.Keyle.MyPet.api.entity.DefaultInfo; +import de.Keyle.MyPet.api.entity.MyPet; +import de.Keyle.MyPet.api.entity.MyPetBaby; + + +@DefaultInfo(food = {"wheat"}) +public interface MyGoat extends MyPet, MyPetBaby { + +} \ No newline at end of file diff --git a/modules/MyPet/pom.xml b/modules/MyPet/pom.xml index aea224a91f..74cba96a27 100644 --- a/modules/MyPet/pom.xml +++ b/modules/MyPet/pom.xml @@ -24,7 +24,7 @@ de.keyle mypet - 3.12-dev4 + 3.12-dev5 jar MyPet https://www.spigotmc.org/resources/mypet.12725/ diff --git a/modules/Plugin/src/main/java/de/Keyle/MyPet/commands/admin/CommandOptionCreate.java b/modules/Plugin/src/main/java/de/Keyle/MyPet/commands/admin/CommandOptionCreate.java index 9bb6b2275b..617e822e75 100644 --- a/modules/Plugin/src/main/java/de/Keyle/MyPet/commands/admin/CommandOptionCreate.java +++ b/modules/Plugin/src/main/java/de/Keyle/MyPet/commands/admin/CommandOptionCreate.java @@ -61,6 +61,11 @@ public class CommandOptionCreate implements CommandOptionTabCompleter { commonTypeOptionList.add("skilltree:"); commonTypeOptionList.add("name:"); + petTypeOptionMap.put("axolotl", new CommandOptionCreator() + .add("baby") + .add("type:") + .get()); + petTypeOptionMap.put("bee", new CommandOptionCreator() .add("baby") .add("angry") @@ -110,6 +115,10 @@ public class CommandOptionCreate implements CommandOptionTabCompleter { .add("type:white") .get()); + petTypeOptionMap.put("goat", new CommandOptionCreator() + .add("baby") + .get()); + petTypeOptionMap.put("guardian", new CommandOptionCreator() .add("1.7.10", "1.11", "elder") .get()); diff --git a/modules/Plugin/src/main/java/de/Keyle/MyPet/entity/MyPetClass.java b/modules/Plugin/src/main/java/de/Keyle/MyPet/entity/MyPetClass.java index 051bc7fc0d..97451a582b 100644 --- a/modules/Plugin/src/main/java/de/Keyle/MyPet/entity/MyPetClass.java +++ b/modules/Plugin/src/main/java/de/Keyle/MyPet/entity/MyPetClass.java @@ -28,6 +28,7 @@ import java.lang.reflect.Constructor; public enum MyPetClass { + Axolotl(MyAxolotl.class), Bat(MyBat.class), Bee(MyBee.class), Blaze(MyBlaze.class), @@ -47,6 +48,7 @@ public enum MyPetClass { Evoker(MyEvoker.class), Fox(MyFox.class), Ghast(MyGhast.class), + Goat(MyGoat.class), Giant(MyGiant.class), Guardian(MyGuardian.class), Hoglin(MyHoglin.class), diff --git a/modules/Plugin/src/main/java/de/Keyle/MyPet/entity/types/MyAxolotl.java b/modules/Plugin/src/main/java/de/Keyle/MyPet/entity/types/MyAxolotl.java new file mode 100644 index 0000000000..27590a602d --- /dev/null +++ b/modules/Plugin/src/main/java/de/Keyle/MyPet/entity/types/MyAxolotl.java @@ -0,0 +1,91 @@ + /* + * This file is part of MyPet + * + * Copyright © 2011-2019 Keyle + * MyPet is licensed under the GNU Lesser General Public License. + * + * MyPet is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MyPet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + package de.Keyle.MyPet.entity.types; + + import de.Keyle.MyPet.api.entity.MyPetType; + import de.Keyle.MyPet.api.player.MyPetPlayer; + import de.Keyle.MyPet.entity.MyPet; + import de.keyle.knbt.TagByte; + import de.keyle.knbt.TagCompound; + import de.keyle.knbt.TagInt; + import org.bukkit.ChatColor; + +public class MyAxolotl extends MyPet implements de.Keyle.MyPet.api.entity.types.MyAxolotl { + + protected boolean isBaby = false; + protected int axolotlType = 1; + + public MyAxolotl(MyPetPlayer petOwner) { + super(petOwner); + } + @Override + public TagCompound writeExtendedInfo() { + TagCompound info = super.writeExtendedInfo(); + info.getCompoundData().put("Baby", new TagByte(isBaby())); + info.getCompoundData().put("Variant", new TagInt(getVariant())); + return info; + } + + @Override + public void readExtendedInfo(TagCompound info) { + if (info.containsKey("Variant")) { + setVariant(info.getAs("Variant", TagInt.class).getIntData()); + } + if (info.containsKey("Baby")) { + setBaby(info.getAs("Baby", TagByte.class).getBooleanData()); + } + + } + + @Override + public MyPetType getPetType() { + return MyPetType.Axolotl; + } + + @Override + public int getVariant() { + return axolotlType; + } + + @Override + public void setVariant(int variant) { + this.axolotlType = Math.min(4, Math.max(0, variant)); + if (status == PetState.Here) { + getEntity().ifPresent(entity -> entity.getHandle().updateVisuals()); + } + } + + public boolean isBaby() { + return isBaby; + } + + public void setBaby(boolean flag) { + this.isBaby = flag; + if (status == PetState.Here) { + getEntity().ifPresent(entity -> entity.getHandle().updateVisuals()); + } + } + + @Override + public String toString() { + return "MyAxolotl{owner=" + getOwner().getName() + ", name=" + ChatColor.stripColor(petName) + ", exp=" + experience.getExp() + "/" + experience.getRequiredExp() + ", lv=" + experience.getLevel() + ", status=" + status.name() + ", skilltree=" + (skilltree != null ? skilltree.getName() : "-") + ", worldgroup=" + worldGroup + ", baby=" + isBaby() + "}"; + } +} \ No newline at end of file diff --git a/modules/Plugin/src/main/java/de/Keyle/MyPet/entity/types/MyGoat.java b/modules/Plugin/src/main/java/de/Keyle/MyPet/entity/types/MyGoat.java new file mode 100644 index 0000000000..6d966329a7 --- /dev/null +++ b/modules/Plugin/src/main/java/de/Keyle/MyPet/entity/types/MyGoat.java @@ -0,0 +1,71 @@ +/* + * This file is part of MyPet + * + * Copyright © 2011-2019 Keyle + * MyPet is licensed under the GNU Lesser General Public License. + * + * MyPet is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MyPet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.Keyle.MyPet.entity.types; + +import de.Keyle.MyPet.api.entity.MyPetType; +import de.Keyle.MyPet.api.player.MyPetPlayer; +import de.Keyle.MyPet.entity.MyPet; +import de.keyle.knbt.TagByte; +import de.keyle.knbt.TagCompound; +import org.bukkit.ChatColor; + +public class MyGoat extends MyPet implements de.Keyle.MyPet.api.entity.types.MyGoat { + protected boolean isBaby = false; + + public MyGoat(MyPetPlayer petOwner) { + super(petOwner); + } + + @Override + public TagCompound writeExtendedInfo() { + TagCompound info = super.writeExtendedInfo(); + info.getCompoundData().put("Baby", new TagByte(isBaby())); + return info; + } + + @Override + public void readExtendedInfo(TagCompound info) { + if (info.containsKey("Baby")) { + setBaby(info.getAs("Baby", TagByte.class).getBooleanData()); + } + } + + @Override + public MyPetType getPetType() { + return MyPetType.Goat; + } + + public boolean isBaby() { + return isBaby; + } + + public void setBaby(boolean flag) { + this.isBaby = flag; + if (status == PetState.Here) { + getEntity().ifPresent(entity -> entity.getHandle().updateVisuals()); + } + } + + @Override + public String toString() { + return "MyGoat{owner=" + getOwner().getName() + ", name=" + ChatColor.stripColor(petName) + ", exp=" + experience.getExp() + "/" + experience.getRequiredExp() + ", lv=" + experience.getLevel() + ", status=" + status.name() + ", skilltree=" + (skilltree != null ? skilltree.getName() : "-") + ", worldgroup=" + worldGroup + ", baby=" + isBaby() + "}"; + } +} \ No newline at end of file diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyAxolotl.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyAxolotl.java new file mode 100644 index 0000000000..1d709e0505 --- /dev/null +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyAxolotl.java @@ -0,0 +1,79 @@ +/* + * This file is part of MyPet + * + * Copyright © 2011-2020 Keyle + * MyPet is licensed under the GNU Lesser General Public License. + * + * MyPet is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MyPet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.Keyle.MyPet.compat.v1_17_R1.entity.types; + +import de.Keyle.MyPet.api.entity.EntitySize; +import de.Keyle.MyPet.api.entity.MyPet; +import de.Keyle.MyPet.api.entity.types.MyAxolotl; +import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.level.Level; + +@EntitySize(width = 0.7F, height = 1.3F) +public class EntityMyAxolotl extends EntityMyPet { + + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyAxolotl.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor VARIANT_WATCHER = SynchedEntityData.defineId(EntityMyAxolotl.class, EntityDataSerializers.INT); + + public EntityMyAxolotl(Level world, MyPet myPet) { + super(world, myPet); + } + + @Override + protected String getMyPetDeathSound() { + return "entity.axolotl.death"; + } + + @Override + protected String getHurtSound() { + return "entity.axolotl.hurt"; + } + + @Override + protected String getLivingSound() { + return "entity.axolotl.idle_air"; + } + + @Override + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + getEntityData().define(VARIANT_WATCHER, 0); + } + + @Override + public void updateVisuals() { + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); + this.getEntityData().set(VARIANT_WATCHER, getMyPet().getVariant()); + } + + @Override + public void playPetStepSound() { + makeSound("entity.axolotl.step", 0.15F, 1.0F); + } + + @Override + public MyAxolotl getMyPet() { + return (MyAxolotl) myPet; + } +} diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java index bc223eb48c..994f537ab2 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyBat.java @@ -20,8 +20,6 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity.types; -import java.util.UUID; - import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.entity.EntitySize; import de.Keyle.MyPet.api.entity.MyPet; diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGoat.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGoat.java new file mode 100644 index 0000000000..d4391df9e4 --- /dev/null +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyGoat.java @@ -0,0 +1,107 @@ +/* + * This file is part of MyPet + * + * Copyright © 2011-2020 Keyle + * MyPet is licensed under the GNU Lesser General Public License. + * + * MyPet is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MyPet is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.Keyle.MyPet.compat.v1_17_R1.entity.types; + +import de.Keyle.MyPet.api.Configuration; +import de.Keyle.MyPet.api.entity.EntitySize; +import de.Keyle.MyPet.api.entity.MyPet; +import de.Keyle.MyPet.api.entity.types.MyGoat; +import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.Level; + +@EntitySize(width = 0.7F, height = 1.3F) +public class EntityMyGoat extends EntityMyPet { + + private static final EntityDataAccessor AGE_WATCHER = SynchedEntityData.defineId(EntityMyGoat.class, EntityDataSerializers.BOOLEAN); + + public EntityMyGoat(Level world, MyPet myPet) { + super(world, myPet); + } + + @Override + protected String getMyPetDeathSound() { + return "entity.goat.death"; + } + + @Override + protected String getHurtSound() { + return "entity.goat.hurt"; + } + + @Override + protected String getLivingSound() { + return "entity.goat.ambient"; + } + + @Override + public InteractionResult handlePlayerInteraction(Player entityhuman, InteractionHand enumhand, ItemStack itemStack) { + if (super.handlePlayerInteraction(entityhuman, enumhand, itemStack).consumesAction()) { + return InteractionResult.CONSUME; + } + + if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) { + if (itemStack.getItem() == Items.BUCKET && Configuration.MyPet.Goat.CAN_GIVE_MILK) { + ItemStack milkBucket = new ItemStack(Items.MILK_BUCKET); + + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, milkBucket); + return InteractionResult.CONSUME; + } else if (Configuration.MyPet.Goat.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) { + if (itemStack != ItemStack.EMPTY && !entityhuman.getAbilities().instabuild) { + itemStack.shrink(1); + if (itemStack.getCount() <= 0) { + entityhuman.getInventory().setItem(entityhuman.getInventory().selected, ItemStack.EMPTY); + } + } + getMyPet().setBaby(false); + return InteractionResult.CONSUME; + } + } + return InteractionResult.PASS; + } + @Override + protected void defineSynchedData() { + super.defineSynchedData(); + getEntityData().define(AGE_WATCHER, false); + } + + @Override + public void updateVisuals() { + this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); + } + + @Override + public void playPetStepSound() { + makeSound("entity.goat.step", 0.15F, 1.0F); + } + + @Override + public MyGoat getMyPet() { + return (MyGoat) myPet; + } +} diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java index e801b42371..523ce6cd07 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyMooshroom.java @@ -116,7 +116,7 @@ protected void defineSynchedData() { @Override public void updateVisuals() { this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); - this.getEntityData().set(COLOR_WATCHER, getMyPet().getType().getType()); //TODO + this.getEntityData().set(COLOR_WATCHER, getMyPet().getType().getType()); } @Override diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/services/EggIconService.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/services/EggIconService.java index 33c12008c5..bd262faa31 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/services/EggIconService.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/services/EggIconService.java @@ -31,6 +31,9 @@ public class EggIconService extends de.Keyle.MyPet.api.util.service.types.EggIco @Override public void updateIcon(MyPetType type, IconMenuItem icon) { switch (type) { + case Axolotl: + icon.setMaterial(Material.AXOLOTL_SPAWN_EGG); + break; case Bat: icon.setMaterial(Material.BAT_SPAWN_EGG); break; @@ -82,6 +85,9 @@ public void updateIcon(MyPetType type, IconMenuItem icon) { case Giant: icon.setMaterial(Material.ZOMBIE_SPAWN_EGG); break; + case Goat: + icon.setMaterial(Material.GOAT_SPAWN_EGG); + break; case Guardian: icon.setMaterial(Material.GUARDIAN_SPAWN_EGG); break;