diff options
author | nea <romangraef@gmail.com> | 2022-02-15 20:56:09 +0100 |
---|---|---|
committer | nea <romangraef@gmail.com> | 2022-04-14 04:10:06 +0200 |
commit | a2854c8f47c8d727a8e90141557d0006a2c2d8a9 (patch) | |
tree | 747792b8b6cacdc464e8b76ba94b5eef084f3136 | |
parent | 83195cbb9d2618e0f913f4d77f76bb5800f8950d (diff) | |
download | NotEnoughUpdates-a2854c8f47c8d727a8e90141557d0006a2c2d8a9.tar.gz NotEnoughUpdates-a2854c8f47c8d727a8e90141557d0006a2c2d8a9.tar.bz2 NotEnoughUpdates-a2854c8f47c8d727a8e90141557d0006a2c2d8a9.zip |
Fix cookie fuckup
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java index ed1a932b..e68aa948 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java @@ -4,21 +4,41 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NEUManager; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; public class EquipmentModifier extends EntityViewerModifier { @Override public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { NEUManager manager = NotEnoughUpdates.INSTANCE.manager; if (info.has("hand")) - base.setCurrentItemOrArmor(0, manager.createItem(info.get("hand").getAsString())); + setCurrentItemOrArmor(base, 0, manager.createItem(info.get("hand").getAsString())); if (info.has("helmet")) - base.setCurrentItemOrArmor(4, manager.createItem(info.get("helmet").getAsString())); + setCurrentItemOrArmor(base, 4, manager.createItem(info.get("helmet").getAsString())); if (info.has("chestplate")) - base.setCurrentItemOrArmor(3, manager.createItem(info.get("chestplate").getAsString())); + setCurrentItemOrArmor(base, 3, manager.createItem(info.get("chestplate").getAsString())); if (info.has("leggings")) - base.setCurrentItemOrArmor(2, manager.createItem(info.get("leggings").getAsString())); + setCurrentItemOrArmor(base, 2, manager.createItem(info.get("leggings").getAsString())); if (info.has("feet")) - base.setCurrentItemOrArmor(1, manager.createItem(info.get("feet").getAsString())); + setCurrentItemOrArmor(base, 1, manager.createItem(info.get("feet").getAsString())); return base; } + + public void setCurrentItemOrArmor(EntityLivingBase entity, int slot, ItemStack itemStack) { + if (entity instanceof EntityPlayer) { + setPlayerCurrentItemOrArmor((EntityPlayer) entity, slot, itemStack); + } else { + entity.setCurrentItemOrArmor(slot, itemStack); + } + } + + // Biscuit person needs to learn how to code and not fuck up valid vanilla behaviour + public static void setPlayerCurrentItemOrArmor(EntityPlayer player, int slot, ItemStack itemStack) { + if (slot == 0) { + player.inventory.mainInventory[player.inventory.currentItem] = itemStack; + } else { + player.inventory.armorInventory[slot - 1] = itemStack; + } + } + } |