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 extends EntityLiving> types) {
+ public static void setupAttributes(EntityMyPet pet, EntityType extends LivingEntity> 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 extends EntityLiving> types = (EntityTypes extends EntityLiving>) 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 extends LivingEntity> types = (EntityType extends LivingEntity>) 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 extends EntityLiving> customType, EntityTypes extends EntityLiving> rootType) {
- MyAttributeDefaults.registerCustomEntityTypes(customType, rootType);
+ public static void registerDefaultAttributes(EntityType extends LivingEntity> customType, EntityType extends LivingEntity> rootType) {
+ MyAttributeDefaults.registerCustomEntityType(customType, rootType);
}
- protected void registerEntity(MyPetType type, RegistryBlocks> entityRegistry) {
+ protected void registerEntity(MyPetType type, DefaultedRegistry> entityRegistry) {
Class extends EntityMyPet> 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 extends EntityMyPet> clazz) {
public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bukkitWorld) {
EntityMyPet petEntity = null;
Class extends MyPetMinecraftEntity> 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 extends EntityLiving> customType, EntityTypes extends EntityLiving> 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