More descriptive way of getting armor slots

This commit is contained in:
Bartek Bok 2017-12-23 14:11:26 +01:00
parent dc0fd04672
commit a84b51f562
No known key found for this signature in database
GPG Key ID: D4AB7344B821F0B5
2 changed files with 4 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -82,7 +83,7 @@ public class SoundEventsManager {
public static boolean isEntityWearingGlasses(Entity e) { public static boolean isEntityWearingGlasses(Entity e) {
if (e instanceof EntityPlayer) { if (e instanceof EntityPlayer) {
ItemStack helmet = ((EntityPlayer)e).inventory.armorInventory[3]; ItemStack helmet = ((EntityPlayer)e).getItemStackFromSlot(EntityEquipmentSlot.HEAD);
return helmet != null return helmet != null
&& helmet.getItem() instanceof ItemSonicGlasses; && helmet.getItem() instanceof ItemSonicGlasses;
} }

View File

@ -3,6 +3,7 @@ package openblocks.common.tileentity;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -144,7 +145,7 @@ public class TileEntityImaginary extends OpenTileEntity implements ICustomPickIt
if (what == Property.VISIBLE && player.isSpectator()) return true; if (what == Property.VISIBLE && player.isSpectator()) return true;
if (what == Property.SOLID && isPencil()) return true; if (what == Property.SOLID && isPencil()) return true;
ItemStack helmet = player.inventory.armorInventory[3]; final ItemStack helmet = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (helmet == null) return isInverted(); if (helmet == null) return isInverted();