Skip to content

Commit

Permalink
IconMenuInventory brought to 1.17 - Inventory-Size-Fix - Added 1.17 t…
Browse files Browse the repository at this point in the history
…o ConverterService
  • Loading branch information
Jakllp committed Aug 18, 2021
1 parent 58a1799 commit e5ba2b7
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -70,47 +110,24 @@
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;
import net.minecraft.world.level.World;
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 {

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
}
}

Expand Down

0 comments on commit e5ba2b7

Please sign in to comment.