From bb4f8d1fc67183c34d6bf8933abb7d2f52ed4b5e Mon Sep 17 00:00:00 2001 From: speed <43330808+speedxx@users.noreply.github.com> Date: Mon, 3 Aug 2020 13:50:44 -0400 Subject: [PATCH 1/2] replace private constructors & new attribute names --- .../command/Command_modifyitem.java | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java index 75d81ba9..9002dccd 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_modifyitem.java @@ -5,11 +5,14 @@ import java.util.List; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; import net.minecraft.server.v1_16_R1.NBTTagCompound; +import net.minecraft.server.v1_16_R1.NBTTagInt; import net.minecraft.server.v1_16_R1.NBTTagList; +import net.minecraft.server.v1_16_R1.NBTTagString; import org.apache.commons.lang.StringUtils; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; +import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -141,13 +144,13 @@ public class Command_modifyitem extends FreedomCommand item.setItemMeta(potionMeta); break; } - // TODO: Fix code here bc 1.15 made some things private for some reason - /*case "attribute": + + case "attribute": if (args.length < 3) { return false; } - net.minecraft.server.v1_15_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item); + net.minecraft.server.v1_16_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item); NBTTagCompound compound = (nmsStack.hasTag()) ? nmsStack.getTag() : new NBTTagCompound(); NBTTagList modifiers = getAttributeList(nmsStack); NBTTagCompound cmpnd = new NBTTagCompound(); @@ -157,8 +160,8 @@ public class Command_modifyitem extends FreedomCommand msg("Invalid attribute. Please run /attributelist for a list of valid attributes."); return true; } - cmpnd.set("AttributeName", new NBTTagString(attribute.getAttribute())); - cmpnd.set("Name", new NBTTagString(attribute.getAttribute())); + cmpnd.set("AttributeName", NBTTagString.a(attribute.getAttribute())); + cmpnd.set("Name", NBTTagString.a(attribute.getAttribute())); int amount; try { @@ -169,16 +172,16 @@ public class Command_modifyitem extends FreedomCommand msg("The amount specified is not a valid integer."); return true; } - cmpnd.set("Amount", new NBTTagInt(amount)); - cmpnd.set("Operation", new NBTTagInt(0)); - cmpnd.set("UUIDLeast", new NBTTagInt(894654)); - cmpnd.set("UUIDMost", new NBTTagInt(2872)); - cmpnd.set("Slot", new NBTTagString("mainhand")); + cmpnd.set("Amount", NBTTagInt.a(amount)); + cmpnd.set("Operation", NBTTagInt.a(0)); + cmpnd.set("UUIDLeast", NBTTagInt.a(894654)); + cmpnd.set("UUIDMost", NBTTagInt.a(2872)); + cmpnd.set("Slot", NBTTagString.a("mainhand")); modifiers.add(cmpnd); compound.set("AttributeModifiers", modifiers); nmsStack.setTag(compound); item = CraftItemStack.asBukkitCopy(nmsStack); - break;*/ + break; default: return false; } @@ -200,21 +203,20 @@ public class Command_modifyitem extends FreedomCommand return stack.getTag().getList("AttributeModifiers", 10); } - private enum Attribute { - GENERIC_MAX_HEALTH("GENERIC_MAX_HEALTH", "generic.maxHealth"), - GENERIC_FOLLOW_RANGE("GENERIC_FOLLOW_RANGE", "generic.followRange"), - GENERIC_KNOCKBACK_RESISTANCE("GENERIC_KNOCKBACK_RESISTANCE", "generic.knockbackResistance"), - GENERIC_MOVEMENT_SPEED("GENERIC_MOVEMENT_SPEED", "generic.movementSpeed"), - GENERIC_FLYING_SPEED("GENERIC_FLYING_SPEED", "generic.flyingSpeed"), - GENERIC_ATTACK_DAMAGE("GENERIC_ATTACK_DAMAGE", "generic.attackDamage"), - GENERIC_ATTACK_SPEED("GENERIC_ATTACK_SPEED", "generic.attackSpeed"), + GENERIC_MAX_HEALTH("GENERIC_MAX_HEALTH", "generic.max_health"), + GENERIC_FOLLOW_RANGE("GENERIC_FOLLOW_RANGE", "generic.follow_range"), + GENERIC_KNOCKBACK_RESISTANCE("GENERIC_KNOCKBACK_RESISTANCE", "generic.knockback_resistance"), + GENERIC_MOVEMENT_SPEED("GENERIC_MOVEMENT_SPEED", "generic.movement_speed"), + GENERIC_FLYING_SPEED("GENERIC_FLYING_SPEED", "generic.flying_speed"), + GENERIC_ATTACK_DAMAGE("GENERIC_ATTACK_DAMAGE", "generic.attack_damage"), + GENERIC_ATTACK_SPEED("GENERIC_ATTACK_SPEED", "generic.attack_speed"), GENERIC_ARMOR("GENERIC_ARMOR", "generic.armor"), - GENERIC_ARMOR_TOUGHNESS("GENERIC_ARMOR_TOUGHNESS", "generic.armorToughmess"), + GENERIC_ARMOR_TOUGHNESS("GENERIC_ARMOR_TOUGHNESS", "generic.armor_toughmess"), GENERIC_LUCK("GENERIC_LUCK", "generic.luck"), - HORSE_JUMP_STRENGTH("GENERIC_MAX_HEALTH", "horse.JumpStrength"), - ZOMBIE_SPAWN_REINFORCEMENTS("ZOMBIE_SPAWN_REINFORCEMENTS", "zombie.SpawnReinforcements"); + HORSE_JUMP_STRENGTH("GENERIC_MAX_HEALTH", "horse.jump_strength"), + ZOMBIE_SPAWN_REINFORCEMENTS("ZOMBIE_SPAWN_REINFORCEMENTS", "zombie.spawn_reinforcements"); private final String name; private final String attribute; From 3f942613d7fb6ffa11e619558d69a3e9f0da6efe Mon Sep 17 00:00:00 2001 From: speed <43330808+speedxx@users.noreply.github.com> Date: Mon, 3 Aug 2020 13:52:49 -0400 Subject: [PATCH 2/2] add missing mobs here too why not --- .../java/me/totalfreedom/totalfreedommod/util/Groups.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/Groups.java b/src/main/java/me/totalfreedom/totalfreedommod/util/Groups.java index bef6a17c..5428f1b8 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/util/Groups.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/util/Groups.java @@ -69,6 +69,8 @@ public class Groups EntityType.HOGLIN, EntityType.HORSE, EntityType.HUSK, + EntityType.ILLUSIONER, + EntityType.IRON_GOLEM, EntityType.LLAMA, EntityType.MAGMA_CUBE, EntityType.MUSHROOM_COW, @@ -78,6 +80,7 @@ public class Groups EntityType.PARROT, EntityType.PHANTOM, EntityType.PIG, + EntityType.PIGLIN, EntityType.PILLAGER, EntityType.POLAR_BEAR, EntityType.PUFFERFISH, @@ -90,6 +93,7 @@ public class Groups EntityType.SKELETON, EntityType.SKELETON_HORSE, EntityType.SLIME, + EntityType.SNOWMAN, EntityType.SPIDER, EntityType.SQUID, EntityType.STRAY,