Java Code Examples for net.minecraft.block.Block#getIcon()

The following examples show how to use net.minecraft.block.Block#getIcon() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenderAutoChisel.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
	Tessellator tes = Tessellator.instance;
	IIcon icon = renderer.hasOverrideBlockTexture() ? renderer.overrideBlockTexture : block.getIcon(0, 0);
	tes.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
	tes.setColorOpaque_F(1, 1, 1);
	tes.addTranslation(x, y, z + 1);
	for (GroupObject go : model.groupObjects) {
		for (Face f : go.faces) {
			Vertex n = f.faceNormal;
			tes.setNormal(n.x, n.y, n.z);
			for (int i = 0; i < f.vertices.length; i++) {
				Vertex vert = f.vertices[i];
				TextureCoordinate t = f.textureCoordinates[i];
				if (!renderer.hasOverrideBlockTexture()) {
					tes.addVertexWithUV(vert.x, vert.y, vert.z, icon.getInterpolatedU(t.u * 16), icon.getInterpolatedV(t.v * 16));
				} else {
					tes.addVertexWithUV(vert.x, vert.y, vert.z, icon.getInterpolatedU((t.u * 64) % 16), icon.getInterpolatedV((t.v * 64) % 16));
				}
			}
		}
	}
	tes.addTranslation(-x, -y, -z - 1);
	return true;
}
 
Example 2
Source File: BlockThinLog.java    From GardenCollection with MIT License 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon (int side, int meta) {
    int ometa = 0;
    if (orientation == 1)
        ometa |= 8;
    else if (orientation == 2)
        ometa |= 4;
    else if (orientation == 3)
        ometa |= 12;

    int protoMeta = TileEntityWoodProxy.getMetaFromComposedMetadata(meta);
    Block protoBlock = TileEntityWoodProxy.getBlockFromComposedMetadata(meta);
    if (protoBlock == null)
        protoBlock = getIconSource(meta);

    return protoBlock.getIcon(side, protoMeta | ometa);
}
 
Example 3
Source File: BlockThinLog.java    From GardenCollection with MIT License 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon (IBlockAccess blockAccess, int x, int y, int z, int side) {
    TileEntityWoodProxy te = getTileEntity(blockAccess, x, y, z);
    if (te == null || te.getProtoBlock() == null)
        return super.getIcon(blockAccess, x, y, z, side);

    int ometa = 0;
    if (orientation == 1)
        ometa |= 8;
    else if (orientation == 2)
        ometa |= 4;
    else if (orientation == 3)
        ometa |= 12;

    int protoMeta = te.getProtoMeta();
    Block protoBlock = te.getProtoBlock();
    if (protoBlock == null)
        protoBlock = Blocks.log;

    return protoBlock.getIcon(side, protoMeta | ometa);
}
 
Example 4
Source File: BlockGardenProxy.java    From GardenCollection with MIT License 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon (IBlockAccess blockAccess, int x, int y, int z, int side) {
    int slot = GardenCore.proxy.getClientBindingStack(this).getSlot();
    TileEntityGarden te = getGardenEntity(blockAccess, x, y, z);
    if (te == null || slot == -1)
        return super.getIcon(blockAccess, x, y, z, side);

    Block block = getPlantBlockRestricted(te, slot);
    if (block == null)
        return super.getIcon(blockAccess, x, y, z, side);

    try {
        return block.getIcon(blockAccess, x, y, z, side);
    }
    catch (Exception e) {
        return super.getIcon(blockAccess, x, y, z, side);
    }
}
 
Example 5
Source File: RenderLaserSource.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
	int l = 1;
	if(world != null)
		l = world.getBlockMetadata(x, y, z);
	IIcon laser = block.getIcon(0,0);
	Tessellator tessellator = Tessellator.instance;
	tessellator.setBrightness(15728880);
	tessellator.setColorOpaque_F(1, 1, 1);
       float f = 1F - 1F/128F;
       renderer.renderMaxX = 1;
       renderer.renderMinX = 0;
       renderer.renderMaxY = 1;
       renderer.renderMinY = 0;
       renderer.renderMaxZ = 1;
       renderer.renderMinZ = 0;
	switch(l&3) {
		case 0:
			renderer.renderFaceZPos(Blocks.ice, x, y, z-f, laser);
			break;
		case 1:
			renderer.renderFaceXNeg(Blocks.ice, x+f, y, z, laser);
			break;
		case 2:
			renderer.renderFaceZNeg(Blocks.ice, x, y, z+f, laser);
			break;
		case 3:
			renderer.renderFaceXPos(Blocks.ice, x-f, y, z, laser);
			break;
	}
	if(world != null)
		renderer.renderBlockAllFaces(BlockLaserBeam.instance, x, y, z);
	return true;
}
 
Example 6
Source File: RenderCoverPlate.java    From Artifacts with MIT License 5 votes vote down vote up
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
	int l = world.getBlockMetadata(x, y, z);
	switch(l) {
        case 2:
        	z++;
        	break;
        case 3:
        	z--;
        	break;
        case 4:
        	x++;
        	break;
        case 5:
        	x--;
        	break;
    }
	Block blockToCopy = world.getBlock(x, y, z);
	if(blockToCopy == null) {
		blockToCopy = Blocks.planks;
	}
	int meta = world.getBlockMetadata(x, y, z);
	IIcon camo = blockToCopy.getIcon(l, meta);
    y--;
	renderer.renderBlockUsingTexture(blockToCopy, x, y, z, camo);
	renderer.renderBlockUsingTexture(Blocks.ice, x, y, z, block.getIcon(0, 0));
	//renderer.renderStandardBlock(Block.ice, x, y, z);
	return true;
}
 
Example 7
Source File: ModelCertusTank.java    From ExtraCells1 with MIT License 5 votes vote down vote up
public void renderInnerBlock(Block block, int x, int y, int z, RenderBlocks renderer, IBlockAccess world)
{
	Tessellator tessellator = Tessellator.instance;
	boolean tankUp = world.getBlockTileEntity(x, y + 1, z) instanceof TileEntityCertusTank;
	boolean tankDown = world.getBlockTileEntity(x, y - 1, z) instanceof TileEntityCertusTank;
	int meta = 0;
	if (tankUp && tankDown)
		meta = 3;
	else if (tankUp)
		meta = 2;
	else if (tankDown)
		meta = 1;
	if (!tankDown)
	{
		tessellator.setNormal(0.0F, -1F, 0.0F);
		renderer.renderFaceYNeg(block, x, y + 0.001D, z, block.getIcon(0, 0));
	}
	if (!(tankUp))
	{
		tessellator.setNormal(0.0F, 1.0F, 0.0F);
		renderer.renderFaceYPos(block, x, y - 0.001D, z, block.getIcon(1, 0));
	}
	Icon sideIcon = block.getIcon(3, meta);
	tessellator.setNormal(0.0F, 0.0F, -1F);
	renderer.renderFaceZNeg(block, x, y, z + 0.001D, sideIcon);
	tessellator.setNormal(0.0F, 0.0F, 1.0F);
	renderer.renderFaceZPos(block, x, y, z - 0.001D, sideIcon);
	tessellator.setNormal(-1F, 0.0F, 0.0F);
	renderer.renderFaceXNeg(block, x + 0.001D, y, z, sideIcon);
	tessellator.setNormal(1.0F, 0.0F, 0.0F);
	renderer.renderFaceXPos(block, x - 0.001D, y, z, sideIcon);

}
 
Example 8
Source File: ModelCertusTank.java    From ExtraCells1 with MIT License 5 votes vote down vote up
public void renderOuterBlock(Block block, int x, int y, int z, RenderBlocks renderer, IBlockAccess world)
{

	Tessellator tessellator = Tessellator.instance;
	boolean tankUp = world.getBlockTileEntity(x, y + 1, z) instanceof TileEntityCertusTank;
	boolean tankDown = world.getBlockTileEntity(x, y - 1, z) instanceof TileEntityCertusTank;
	int meta = 0;
	if (tankUp && tankDown)
		meta = 3;
	else if (tankUp)
		meta = 2;
	else if (tankDown)
		meta = 1;
	if (!tankDown)
	{
		tessellator.setNormal(0.0F, -1F, 0.0F);
		renderer.renderFaceYNeg(block, x, y, z, block.getIcon(0, 0));
	}
	if (!(tankUp))
	{
		tessellator.setNormal(0.0F, 1.0F, 0.0F);
		renderer.renderFaceYPos(block, x, y, z, block.getIcon(1, 0));
	}

	Icon sideIcon = block.getIcon(3, meta);
	tessellator.setNormal(0.0F, 0.0F, -1F);
	renderer.renderFaceZNeg(block, x, y, z, sideIcon);
	tessellator.setNormal(0.0F, 0.0F, 1.0F);
	renderer.renderFaceZPos(block, x, y, z, sideIcon);
	tessellator.setNormal(-1F, 0.0F, 0.0F);
	renderer.renderFaceXNeg(block, x, y, z, sideIcon);
	tessellator.setNormal(1.0F, 0.0F, 0.0F);
	renderer.renderFaceXPos(block, x, y, z, sideIcon);

}
 
Example 9
Source File: BlockPneumaticDoorBase.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
    TileEntityPneumaticDoorBase te = (TileEntityPneumaticDoorBase)world.getTileEntity(x, y, z);
    ItemStack camoStack = te.getStackInSlot(TileEntityPneumaticDoorBase.CAMO_SLOT);
    if(camoStack != null && camoStack.getItem() instanceof ItemBlock) {
        Block block = ((ItemBlock)camoStack.getItem()).field_150939_a;
        if(PneumaticCraftUtils.isRenderIDCamo(block.getRenderType())) {
            return block.getIcon(side, camoStack.getItemDamage());
        }
    }
    return this.getIcon(side, world.getBlockMetadata(x, y, z));
}
 
Example 10
Source File: BlockNoCTMRenderer.java    From Chisel with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{
    int meta = world.getBlockMetadata(x, y, z);

    if(meta != 0) renderer.overrideBlockTexture = block.getIcon(0, meta);
    renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    renderer.renderStandardBlock(block, x, y, z);
    renderer.overrideBlockTexture = null;

    return false;
}
 
Example 11
Source File: BlockLatticeWood.java    From GardenCollection with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon (IBlockAccess blockAccess, int x, int y, int z, int side) {
    TileEntityBlockMateralProxy te = getTileEntity(blockAccess, x, y, z);
    if (te == null || te.getProtoBlock() == null)
        return super.getIcon(blockAccess, x, y, z, side);

    Block protoBlock = te.getProtoBlock();
    if (protoBlock == null)
        protoBlock = Blocks.planks;

    return protoBlock.getIcon(side, te.getProtoMeta());
}
 
Example 12
Source File: BlockLatticeWood.java    From GardenCollection with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon (int side, int meta) {
    Block protoBlock = TileEntityLatticeWood.instance.getBlockFromComposedMetadata(meta);
    if (protoBlock != null)
        return protoBlock.getIcon(side, TileEntityLatticeWood.instance.getMetaFromComposedMetadata(meta));

    return Blocks.planks.getIcon(side, meta);
}
 
Example 13
Source File: BlockLatticeMetal.java    From GardenCollection with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon (IBlockAccess blockAccess, int x, int y, int z, int side) {
    TileEntityBlockMateralProxy te = getTileEntity(blockAccess, x, y, z);
    if (te == null || te.getProtoBlock() == null)
        return super.getIcon(blockAccess, x, y, z, side);

    Block protoBlock = te.getProtoBlock();
    if (protoBlock == null)
        protoBlock = this;

    return protoBlock.getIcon(side, te.getProtoMeta());
}
 
Example 14
Source File: BlockLatticeMetal.java    From GardenCollection with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon (int side, int meta) {
    Block protoBlock = TileEntityLatticeMetal.instance.getBlockFromComposedMetadata(meta);
    if (protoBlock != null && protoBlock != this)
        return protoBlock.getIcon(side, TileEntityLatticeMetal.instance.getMetaFromComposedMetadata(meta));

    return icons[meta % icons.length];
}
 
Example 15
Source File: BlockThinLogFence.java    From GardenCollection with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon (IBlockAccess blockAccess, int x, int y, int z, int side) {
    TileEntityWoodProxy te = getTileEntity(blockAccess, x, y, z);
    if (te == null || te.getProtoBlock() == null)
        return super.getIcon(blockAccess, x, y, z, side);

    int protoMeta = te.getProtoMeta();
    Block protoBlock = te.getProtoBlock();
    if (protoBlock == null)
        protoBlock = Blocks.log;

    return protoBlock.getIcon(side, protoMeta);
}
 
Example 16
Source File: BlockThinLogFence.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public IIcon getIcon (int side, int meta) {
    int protoMeta = TileEntityWoodProxy.getMetaFromComposedMetadata(meta);
    Block protoBlock = TileEntityWoodProxy.getBlockFromComposedMetadata(meta);
    if (protoBlock == null)
        protoBlock = getIconSource(meta);

    return protoBlock.getIcon(side, protoMeta);
}
 
Example 17
Source File: BlockColourGen.java    From mapwriter with MIT License 4 votes vote down vote up
public static void genBlockColours(BlockColours bc) {
	
	MwUtil.log("generating block map colours from textures");

	// copy terrain texture to MwRender pixel bytebuffer
	
	// bind the terrain texture
	//Minecraft.getMinecraft().func_110434_K().func_110577_a(TextureMap.field_110575_b);
	// get the bound texture id
	//int terrainTextureId = Render.getBoundTextureId();
	
	int terrainTextureId = Minecraft.getMinecraft().renderEngine.getTexture(TextureMap.locationBlocksTexture).getGlTextureId();
	
	// create texture object from the currently bound GL texture
	if (terrainTextureId == 0) {
		MwUtil.log("error: could get terrain texture ID");
		return;
	}
	Texture terrainTexture = new Texture(terrainTextureId);
	
	double u1Last = 0;
	double u2Last = 0;
	double v1Last = 0;
	double v2Last = 0;
	int blockColourLast = 0;
	int e_count = 0;
	int b_count = 0;
	int s_count = 0;

	for (int blockID = 0; blockID < 4096; blockID++) { //TODO: replace hardcoded 4096 with actual registry size
		for (int dv = 0; dv < 16; dv++) {
			
			int blockAndMeta = ((blockID & 0xfff) << 4) | (dv & 0xf);
			Block block = (Block) Block.blockRegistry.getObjectById(blockID);
			int blockColour = 0;
			
			if (block != null) {
				
				IIcon icon = null;
				try {
					icon = block.getIcon(1, dv);
				} catch (Exception e) {
					//MwUtil.log("genFromTextures: exception caught when requesting block texture for %03x:%x", blockID, dv);
					//e.printStackTrace();
					e_count++;
				}
				
				if (icon != null) {
					double u1 = icon.getMinU();
					double u2 = icon.getMaxU();
					double v1 = icon.getMinV();
					double v2 = icon.getMaxV();
					
					if ((u1 == u1Last) && (u2 == u2Last) && (v1 == v1Last) && (v2 == v2Last)) {
						blockColour = blockColourLast;
						s_count++;
					} else {
						blockColour = getIconMapColour(icon, terrainTexture);
						u1Last = u1;
						u2Last = u2;
						v1Last = v1;
						v2Last = v2;
						blockColourLast = blockColour;
						b_count++;
					}
					//if (dv == 0)
					//	MwUtil.log("block %03x:%x colour = %08x", blockID, dv, blockColour);
				}
				
				// doesn't work as some leaves blocks aren't rendered using the biome
				// foliage colour
				//try {
				//	if (block.isLeaves(null, 0, 0, 0)) {
				//		bc.setBlockType(blockAndMeta, BlockType.LEAVES);
				//	}
				//} catch (NullPointerException e) {
				//}
				
				blockColour = adjustBlockColourFromType(bc, blockAndMeta, blockColour);
			}
			bc.setColour(blockAndMeta, blockColour);
		}
	}
	
	MwUtil.log("processed %d block textures, %d skipped, %d exceptions", b_count, s_count, e_count);
	
	genBiomeColours(bc);
}
 
Example 18
Source File: Botania.java    From GardenCollection with MIT License 4 votes vote down vote up
@Override
public IIcon getIcon (Block block, IBlockAccess blockAccess, int meta) {
    return block.getIcon(0, meta);
}
 
Example 19
Source File: BlockArtifactsPressurePlate.java    From Artifacts with MIT License 4 votes vote down vote up
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
{
	if(this.camouflaged) {

		if(side != 1) {
			return this == camoStone ? Blocks.stone.getBlockTextureFromSide(0) : this == camoObsidian ? Blocks.obsidian.getBlockTextureFromSide(0) : Blocks.planks.getBlockTextureFromSide(0);
		}

		IIcon icon = this.blockIcon;
		Block block = world.getBlock(x, y-1, z);
		int meta = world.getBlockMetadata(x, y-1, z);

		if(block != null) {
			if(block == BlockTrap.instance) {
				int[] blockToCopyLocation = BlockTrap.getNeighbourBlockPosition(world, x, y-1, z, block, meta);
				Block blockToCopy = Blocks.stonebrick;
				int metaToCopy = 0;
				if(! (blockToCopyLocation[0] == x && blockToCopyLocation[1] == y && blockToCopyLocation[2] == z )) {
					blockToCopy = world.getBlock(blockToCopyLocation[0], blockToCopyLocation[1], blockToCopyLocation[2]);
					metaToCopy = world.getBlockMetadata(blockToCopyLocation[0], blockToCopyLocation[1], blockToCopyLocation[2]);
				}
				return blockToCopy.getIcon(side, metaToCopy);
			}
			else if(block != this && block.isOpaqueCube()) {
				icon = block.getIcon(side, meta);
				if(icon != null) {
					return icon;
				}
			}
			else if(block == BlockIllusionary.instance) {
				return block.getIcon(world, x, y-1, z, side);
				
			}
		}
	}

	//If it fails, return default icon.
			return super.getIcon(world, x, y, z, side);

}
 
Example 20
Source File: BlockWallPlate.java    From Artifacts with MIT License 4 votes vote down vote up
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
{
	if(this.camouflage) {
		
		IIcon icon = this.blockIcon;
		Block block = Blocks.air;
		int bMeta = 0;
		int bx = x;
		int bz = z;
		int meta = world.getBlockMetadata(x, y, z) & 0x07;

		if (meta == 2 && side == 2)
		{
			block = world.getBlock(x, y, z+1);
			bMeta = world.getBlockMetadata(x, y, z+1);
			bz = z+1;
		}
		else if (meta == 3 && side == 3)
		{
			block = world.getBlock(x, y, z-1);
			bMeta = world.getBlockMetadata(x, y, z-1);
			bz = z-1;
		}
		else if (meta == 4 && side == 4)
		{
			block = world.getBlock(x+1, y, z);
			bMeta = world.getBlockMetadata(x+1, y, z);
			bx = x+1;
		}
		else if (meta == 5 && side == 5)
		{
			block = world.getBlock(x-1, y, z);
			bMeta = world.getBlockMetadata(x-1, y, z);
			bx = x-1;
		}
		else {
			block = this == camoStone ? Blocks.stone : this == camoObsidian ? Blocks.obsidian : Blocks.planks;
			bMeta = 0;
		}
		
		if(block != null) {
			if(block == BlockTrap.instance) {
				int[] blockToCopyLocation = BlockTrap.getNeighbourBlockPosition(world, bx, y, bz, block, bMeta);
				Block blockToCopy = Blocks.stonebrick;
				int metaToCopy = 0;
				if(! (blockToCopyLocation[0] == x && blockToCopyLocation[1] == y && blockToCopyLocation[2] == z )) {
					blockToCopy = world.getBlock(blockToCopyLocation[0], blockToCopyLocation[1], blockToCopyLocation[2]);
					metaToCopy = world.getBlockMetadata(blockToCopyLocation[0], blockToCopyLocation[1], blockToCopyLocation[2]);
				}
				return blockToCopy.getIcon(side, metaToCopy);
			}
			else if(block != this && block.isOpaqueCube()) {
				icon = block.getIcon(side, bMeta);
				if(icon != null) {
					return icon;
				}
			}
			else if(block == BlockIllusionary.instance) {
				return block.getIcon(world, bx, y, bz, side);
			}
		}
	}
	
	//If it fails, return default icon.
	return super.getIcon(world, x, y, z, side);

}