Search in sources :

Example 41 with ItemBlock

use of net.minecraft.item.ItemBlock in project PneumaticCraft by MineMaarten.

the class ReplacementBlock method getMeta.

/**
	 * Called to get the metadata of the replacement block in the world.
	 * @param world The world object
	 * @param x The X coord
	 * @param y The Y coord
	 * @param z The Z coord
	 * @param stack The ItemStack being used to replace the block (may be null)
	 * @return The metadata of the block
	 */
protected int getMeta(World world, int x, int y, int z, ItemStack stack) {
    int m = 0;
    if (_hasMeta > 0) {
        if (_hasMeta > 1)
            return _meta;
        m = stack.getItemDamage();
        Item item = stack.getItem();
        if (item instanceof ItemBlock)
            m = ((ItemBlock) item).getMetadata(m);
    }
    return m;
}
Also used : Item(net.minecraft.item.Item) ItemBlock(net.minecraft.item.ItemBlock)

Example 42 with ItemBlock

use of net.minecraft.item.ItemBlock in project PneumaticCraft by MineMaarten.

the class RenderChargingStationPad method renderWorldBlock.

@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
    TileEntity te = world.getTileEntity(x, y, z);
    if (te instanceof TileEntityChargingStation) {
        TileEntityChargingStation station = (TileEntityChargingStation) te;
        if (station.getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE) > 0) {
            ItemStack camo = station.getCamoStack();
            Block camoBlock = ((ItemBlock) camo.getItem()).field_150939_a;
            renderer.renderAllFaces = true;
            renderer.setOverrideBlockTexture(camoBlock.getIcon(0, camo.getItemDamage()));
            renderer.setRenderBounds(0, 15 / 16D, 0, 1, 1, 1);
            renderer.renderStandardBlock(block, x, y, z);
            renderer.setOverrideBlockTexture(null);
            renderer.renderAllFaces = false;
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityChargingStation(pneumaticCraft.common.tileentity.TileEntityChargingStation) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 43 with ItemBlock

use of net.minecraft.item.ItemBlock in project PneumaticCraft by MineMaarten.

the class ModelAssemblyPlatform method renderModel.

public void renderModel(float size, float progress, EntityItem carriedItem) {
    float clawTrans;
    float scaleFactor = 0.7F;
    IAssemblyRenderOverriding renderOverride = null;
    if (carriedItem != null) {
        renderOverride = AssemblyRenderOverriding.renderOverrides.get(carriedItem.getEntityItem());
        if (renderOverride != null) {
            clawTrans = renderOverride.getPlatformClawShift(carriedItem.getEntityItem());
        } else {
            if (carriedItem.getEntityItem().getItem() instanceof ItemBlock) {
                clawTrans = 1.5F / 16F - progress * 0.1F / 16F;
            } else {
                clawTrans = 1.5F / 16F - progress * 1.4F / 16F;
                scaleFactor = 0.4F;
            }
        }
    } else {
        clawTrans = 1.5F / 16F - progress * 1.5F / 16F;
    }
    Base.render(size);
    Platform.render(size);
    Leg1.render(size);
    Leg2.render(size);
    Leg3.render(size);
    Leg4.render(size);
    GL11.glPushMatrix();
    GL11.glTranslated(0, 0, clawTrans);
    Claw1.render(size);
    GL11.glTranslated(0, 0, -2 * clawTrans);
    Claw2.render(size);
    GL11.glPopMatrix();
    if (carriedItem != null) {
        if (renderOverride == null || renderOverride.applyRenderChangePlatform(carriedItem.getEntityItem())) {
            GL11.glRotated(180, 1, 0, 0);
            GL11.glTranslated(0, carriedItem.getEntityItem().getItem() instanceof ItemBlock ? -16.5 / 16F : -17.5 / 16F, 0);
            // GL11.glRotated(-90, 0, 1, 0);
            GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
            customRenderItem.doRender(carriedItem, 0, 0, 0, 0, 0);
        }
    }
}
Also used : IAssemblyRenderOverriding(pneumaticCraft.api.client.assemblymachine.AssemblyRenderOverriding.IAssemblyRenderOverriding) ItemBlock(net.minecraft.item.ItemBlock)

Example 44 with ItemBlock

use of net.minecraft.item.ItemBlock in project PneumaticCraft by MineMaarten.

the class ModelPneumaticDoorBase method renderDynamic.

@Override
public void renderDynamic(float size, TileEntity tile, float partialTicks) {
    if (tile instanceof TileEntityPneumaticDoorBase) {
        TileEntityPneumaticDoorBase door = (TileEntityPneumaticDoorBase) tile;
        ItemStack camoStack = door.getStackInSlot(TileEntityPneumaticDoorBase.CAMO_SLOT);
        boolean renderBase = true;
        if (camoStack != null && camoStack.getItem() instanceof ItemBlock) {
            Block block = Block.getBlockFromItem(camoStack.getItem());
            renderBase = !PneumaticCraftUtils.isRenderIDCamo(block.getRenderType());
        }
        PneumaticCraftUtils.rotateMatrixByMetadata(door.orientation.ordinal());
        renderModel(size, door.oldProgress + (door.progress - door.oldProgress) * partialTicks, renderBase, ((TileEntityPneumaticDoorBase) tile).rightGoing);
    } else {
        renderModel(size, 1, true, false);
    }
}
Also used : TileEntityPneumaticDoorBase(pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 45 with ItemBlock

use of net.minecraft.item.ItemBlock in project PneumaticCraft by MineMaarten.

the class DroneAIPlace method doBlockInteraction.

@Override
protected boolean doBlockInteraction(ChunkPosition pos, double distToBlock) {
    if (drone.getPathNavigator().hasNoPath()) {
        ForgeDirection side = ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides());
        for (int i = 0; i < drone.getInventory().getSizeInventory(); i++) {
            ItemStack droneStack = drone.getInventory().getStackInSlot(i);
            if (droneStack != null && droneStack.getItem() instanceof ItemBlock && ((ItemBlock) droneStack.getItem()).field_150939_a.canPlaceBlockOnSide(drone.getWorld(), pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ, ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides()).ordinal())) {
                if (widget.isItemValidForFilters(droneStack)) {
                    if (drone instanceof EntityDrone) {
                        EntityDrone entity = (EntityDrone) drone;
                        //Teleport the drone to make sure it isn't in the way of placing a block.
                        entity.setPosition(entity.posX, entity.posY + 200, entity.posZ);
                    }
                    if (drone.getWorld().canPlaceEntityOnSide(((ItemBlock) droneStack.getItem()).field_150939_a, pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ, false, 0, null, droneStack)) {
                        Block block = Block.getBlockFromItem(droneStack.getItem());
                        int meta = droneStack.getItem().getMetadata(droneStack.getItemDamage());
                        int newMeta = block.onBlockPlaced(drone.getWorld(), pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ, side.ordinal(), side.offsetX, side.offsetY, side.offsetZ, meta);
                        setFakePlayerAccordingToDir();
                        if (placeBlockAt(droneStack, drone.getFakePlayer(), drone.getWorld(), pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ, side.ordinal(), 0, 0, 0, newMeta)) {
                            drone.addAir(null, -PneumaticValues.DRONE_USAGE_PLACE);
                            drone.getWorld().playSoundEffect(pos.chunkPosX + 0.5F, pos.chunkPosY + 0.5F, pos.chunkPosZ + 0.5F, block.stepSound.func_150496_b(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
                            if (--droneStack.stackSize <= 0) {
                                drone.getInventory().setInventorySlotContents(i, null);
                            }
                        }
                        if (drone instanceof EntityDrone) {
                            EntityDrone entity = (EntityDrone) drone;
                            entity.setPosition(entity.posX, entity.posY - 200, entity.posZ);
                        }
                        return false;
                    }
                    if (drone instanceof EntityDrone) {
                        EntityDrone entity = (EntityDrone) drone;
                        entity.setPosition(entity.posX, entity.posY - 200, entity.posZ);
                    }
                }
            }
        }
        return false;
    } else {
        return true;
    }
}
Also used : ISidedWidget(pneumaticCraft.common.progwidgets.ISidedWidget) EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Aggregations

ItemBlock (net.minecraft.item.ItemBlock)78 Block (net.minecraft.block.Block)41 ItemStack (net.minecraft.item.ItemStack)37 Item (net.minecraft.item.Item)20 IBlockState (net.minecraft.block.state.IBlockState)11 EntityItem (net.minecraft.entity.item.EntityItem)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 TileEntity (net.minecraft.tileentity.TileEntity)4 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)3 IProperty (net.minecraft.block.properties.IProperty)3 RenderItem (net.minecraft.client.renderer.entity.RenderItem)3 EnumFacing (net.minecraft.util.EnumFacing)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 BlockPos (net.minecraft.util.math.BlockPos)3 AMVector3 (am2.api.math.AMVector3)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Tessellator (net.minecraft.client.renderer.Tessellator)2 ChatComponentText (net.minecraft.util.ChatComponentText)2