diff --git a/modules/API/src/main/java/de/Keyle/MyPet/api/entity/MyPetType.java b/modules/API/src/main/java/de/Keyle/MyPet/api/entity/MyPetType.java index 111ca4679a..9a7a29ce15 100644 --- a/modules/API/src/main/java/de/Keyle/MyPet/api/entity/MyPetType.java +++ b/modules/API/src/main/java/de/Keyle/MyPet/api/entity/MyPetType.java @@ -57,6 +57,7 @@ public enum MyPetType { Cow("COW", "1.7.10", MyCow.class, new Compat<>() .v("1.7.10", 92) .v("1.13", "cow") + .v("1.17", "n") //This creates a... pig .search()), Creeper("CREEPER", "1.7.10", MyCreeper.class, new Compat<>() .v("1.7.10", 50) diff --git a/modules/API/src/main/java/de/Keyle/MyPet/api/util/service/types/RepositoryMyPetConverterService.java b/modules/API/src/main/java/de/Keyle/MyPet/api/util/service/types/RepositoryMyPetConverterService.java index c9c3bfd4e0..95ae2da172 100644 --- a/modules/API/src/main/java/de/Keyle/MyPet/api/util/service/types/RepositoryMyPetConverterService.java +++ b/modules/API/src/main/java/de/Keyle/MyPet/api/util/service/types/RepositoryMyPetConverterService.java @@ -52,7 +52,8 @@ public enum Version { v1_15_R1, v1_16_R1, v1_16_R2, - v1_16_R3 + v1_16_R3, + v1_17_R1 } Version toVersion; 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 25ae1931e5..a654ae10c4 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 @@ -20,13 +20,45 @@ package de.Keyle.MyPet.compat.v1_17_R1.entity; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_17_R1.attribute.CraftAttributeMap; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory; +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; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitRunnable; + import com.google.common.base.Preconditions; + import de.Keyle.MyPet.MyPetApi; import de.Keyle.MyPet.api.Configuration; import de.Keyle.MyPet.api.Util; import de.Keyle.MyPet.api.compat.ParticleCompat; import de.Keyle.MyPet.api.entity.EntitySize; -import de.Keyle.MyPet.api.entity.*; +import de.Keyle.MyPet.api.entity.JumpHelper; +import de.Keyle.MyPet.api.entity.MyPet; +import de.Keyle.MyPet.api.entity.MyPetBaby; +import de.Keyle.MyPet.api.entity.MyPetMinecraftEntity; +import de.Keyle.MyPet.api.entity.MyPetType; import de.Keyle.MyPet.api.entity.ai.AIGoalSelector; import de.Keyle.MyPet.api.entity.ai.navigation.AbstractNavigation; import de.Keyle.MyPet.api.entity.ai.target.TargetPriority; @@ -43,10 +75,20 @@ import de.Keyle.MyPet.compat.v1_17_R1.PlatformHelper; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack.MeleeAttack; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.attack.RangedAttack; +import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement.Control; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement.Float; -import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement.*; +import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement.FollowOwner; +import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement.LookAtPlayer; +import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement.RandomLookaround; +import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement.Sit; +import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.movement.Sprint; import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.navigation.VanillaNavigation; -import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.target.*; +import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.target.BehaviorAggressiveTarget; +import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.target.BehaviorDuelTarget; +import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.target.BehaviorFarmTarget; +import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.target.ControlTarget; +import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.target.HurtByTarget; +import de.Keyle.MyPet.compat.v1_17_R1.entity.ai.target.OwnerHurtByTarget; 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; @@ -56,8 +98,6 @@ import net.minecraft.network.chat.IChatBaseComponent; import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity; import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect; -import net.minecraft.network.protocol.game.PacketPlayOutSetSlot; -import net.minecraft.network.protocol.game.PacketPlayOutWindowItems; import net.minecraft.network.syncher.DataWatcher; import net.minecraft.network.syncher.DataWatcherObject; import net.minecraft.network.syncher.DataWatcherRegistry; @@ -70,12 +110,17 @@ import net.minecraft.world.EnumHand; import net.minecraft.world.EnumInteractionResult; import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.*; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityInsentient; +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.IJumpable; import net.minecraft.world.entity.ai.attributes.AttributeMapBase; import net.minecraft.world.entity.ai.attributes.AttributeProvider; import net.minecraft.world.entity.ai.attributes.GenericAttributes; import net.minecraft.world.entity.player.EntityHuman; -import net.minecraft.world.inventory.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.alchemy.PotionUtil; @@ -83,34 +128,6 @@ import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.Vec3D; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_17_R1.attribute.CraftAttributeMap; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory; -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; -import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.scheduler.BukkitRunnable; - -import java.lang.reflect.Field; -import java.math.BigDecimal; -import java.util.EnumSet; -import java.util.List; public abstract class EntityMyPet extends EntityInsentient implements MyPetMinecraftEntity { @@ -1022,7 +1039,7 @@ public void movementTick() { 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(this.az - (double) this.getYRot()); + 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; 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 4a14040d9c..53df749289 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 @@ -89,7 +89,7 @@ public MyPetMinecraftEntity createMinecraftEntity(MyPet pet, org.bukkit.World bu try { Constructor ctor = entityClass.getConstructor(World.class, MyPet.class); - Object obj = ctor.newInstance(world, pet); + Object obj = ctor.newInstance(world, pet); //TODO 2021/08/18 This fails - pet not having the right class? if (obj instanceof EntityMyPet) { petEntity = (EntityMyPet) obj; } diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/iconmenu/IconMenuInventory.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/iconmenu/IconMenuInventory.java index b036440a7e..42363aec60 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/iconmenu/IconMenuInventory.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/iconmenu/IconMenuInventory.java @@ -55,7 +55,7 @@ public class IconMenuInventory implements de.Keyle.MyPet.api.gui.IconMenuInvento static { try { - Class craftMetaItemClass = Class.forName("org.bukkit.craftbukkit.v1_16_R3.inventory.CraftMetaItem"); + Class craftMetaItemClass = Class.forName("org.bukkit.craftbukkit.v1_17_R1.inventory.CraftMetaItem"); applyToItemMethhod = ReflectionUtil.getMethod(craftMetaItemClass, "applyToItem", NBTTagCompound.class); } catch (ClassNotFoundException e) { e.printStackTrace(); diff --git a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java index 377f2eea43..fe4c9a19ce 100644 --- a/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java +++ b/modules/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/util/inventory/CustomInventory.java @@ -306,7 +306,7 @@ public void open(Player player) { Container container = new CraftContainer(getBukkitInventory(), entityPlayer, entityPlayer.nextContainerCounter()); container = CraftEventFactory.callInventoryOpenEvent(entityPlayer, container); if (container != null) { - Containers customSize = Containers.a; + Containers customSize = Containers.a; switch (this.getSize()) { case 18: customSize = Containers.b; @@ -326,7 +326,7 @@ public void open(Player player) { } entityPlayer.b.sendPacket(new PacketPlayOutOpenWindow(container.j, customSize, new ChatComponentText(this.getName()))); entityPlayer.bV = container; - entityPlayer.bV.addSlotListener((ICrafting) entityPlayer); // TODO: 2021/06/28 Cast Error? + entityPlayer.bV.b(entityPlayer); //This seems to work even though the method-definition doesn't really match the old one } }