use of net.minecraft.item.Item in project BetterStorage by copygirl.
the class SlotArmorBackpack method isItemValid.
@Override
public boolean isItemValid(ItemStack stack) {
if (stack == null)
return false;
EntityPlayer player = ((InventoryPlayer) inventory).player;
Item item = stack.getItem();
if ((item instanceof ItemBackpack) && !ItemBackpack.canEquipBackpack(player))
return false;
return item.isValidArmor(stack, armorType, player);
}
use of net.minecraft.item.Item in project BetterStorage by copygirl.
the class RecipeInputBase method craft.
@Override
public void craft(ItemStack input, ContainerInfo containerInfo) {
if (input == null)
return;
Item item = input.getItem();
ItemStack containerItem = item.getContainerItem(input.copy());
boolean doesLeaveCrafting = item.doesContainerItemLeaveCraftingGrid(input);
containerInfo.set(containerItem, doesLeaveCrafting);
input.stackSize -= getAmount();
}
use of net.minecraft.item.Item in project BetterStorage by copygirl.
the class RenderUtils method renderItemIn3d.
public static void renderItemIn3d(ItemStack stack) {
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
// Not sure why but this can be null when the world loads.
if (textureManager == null)
return;
Item item = stack.getItem();
GL11.glPushMatrix();
Tessellator tessellator = Tessellator.instance;
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glTranslatef(-0.5F, -0.5F, 1 / 32.0F);
int passes = item.getRenderPasses(stack.getItemDamage());
for (int pass = 0; pass < passes; pass++) {
textureManager.bindTexture(((stack.getItemSpriteNumber() == 0) ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture));
IIcon icon = item.getIcon(stack, pass);
float minU = icon.getMinU();
float maxU = icon.getMaxU();
float minV = icon.getMinV();
float maxV = icon.getMaxV();
RenderUtils.setColorFromInt(item.getColorFromItemStack(stack, pass));
ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), 0.0625F);
}
if (stack.hasEffect(0)) {
GL11.glDepthFunc(GL11.GL_EQUAL);
GL11.glDisable(GL11.GL_LIGHTING);
textureManager.bindTexture(glint);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
float f7 = 0.76F;
GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
float f8 = 0.125F;
GL11.glScalef(f8, f8, f8);
float f9 = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F;
GL11.glTranslatef(f9, 0.0F, 0.0F);
GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glScalef(f8, f8, f8);
f9 = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F;
GL11.glTranslatef(-f9, 0.0F, 0.0F);
GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthFunc(GL11.GL_LEQUAL);
}
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
use of net.minecraft.item.Item in project BetterStorage by copygirl.
the class CratePileData method fromCompound.
public static CratePileData fromCompound(CratePileCollection collection, int crateId, NBTTagCompound compound) {
int numCrates = compound.getShort("numCrates");
CratePileData pileData = new CratePileData(collection, crateId, numCrates);
NBTTagList stacks = compound.getTagList("stacks", NBT.TAG_COMPOUND);
for (int j = 0; j < stacks.tagCount(); j++) {
NBTTagCompound stackCompound = stacks.getCompoundTagAt(j);
Item item = Item.getItemById(stackCompound.getShort("id"));
int count = stackCompound.getInteger("Count");
int damage = stackCompound.getShort("Damage");
ItemStack stack = new ItemStack(item, count, damage);
if (stackCompound.hasKey("tag"))
stack.stackTagCompound = stackCompound.getCompoundTag("tag");
if (stack.getItem() != null)
pileData.getContents().set(new ItemIdentifier(stack), stack.stackSize);
}
if (compound.hasKey("map"))
pileData.map = CratePileMap.fromCompound(compound.getCompoundTag("map"));
return pileData;
}
use of net.minecraft.item.Item in project BluePower by Qmunity.
the class BlockEngine method onBlockActivated.
@SuppressWarnings("cast")
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
if (player.inventory.getCurrentItem() != null) {
Item item = player.inventory.getCurrentItem().getItem();
if (item == BPItems.screwdriver) {
if (!world.isRemote) {
int direction = 0;
int facing = 0;
if (player.rotationPitch > 45) {
facing = 5;
} else if (player.rotationPitch < -45) {
facing = 4;
} else {
facing = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
}
TileEngine engine = (TileEngine) world.getTileEntity(x, y, z);
if (facing == 0) {
if (player.isSneaking())
direction = ForgeDirection.NORTH.ordinal();
direction = ForgeDirection.SOUTH.ordinal();
} else if (facing == 1) {
if (player.isSneaking())
direction = ForgeDirection.EAST.ordinal();
direction = ForgeDirection.WEST.ordinal();
} else if (facing == 2) {
if (player.isSneaking())
direction = ForgeDirection.SOUTH.ordinal();
direction = ForgeDirection.NORTH.ordinal();
} else if (facing == 3) {
if (player.isSneaking())
direction = ForgeDirection.WEST.ordinal();
direction = ForgeDirection.EAST.ordinal();
} else if (facing == 4) {
if (player.isSneaking())
direction = ForgeDirection.DOWN.ordinal();
direction = ForgeDirection.UP.ordinal();
} else if (facing == 5) {
if (player.isSneaking())
direction = ForgeDirection.UP.ordinal();
direction = ForgeDirection.DOWN.ordinal();
}
engine.setOrientation(direction);
world.markBlockForUpdate(x, y, z);
}
}
}
return false;
}
Aggregations