下面列出了怎么用net.minecraft.util.IIcon的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon)
{
setupSides(icon, 0, 3, 7, 4, 13, 0, 3, 7, 4);
vert(0);
vert(3);
vert(13);
vert(13);
vert(3);
vert(7);
vert(13);
vert(13);
vert(7);
vert(4);
vert(13);
vert(13);
vert(4);
vert(0);
vert(13);
vert(13);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister par1IconRegister){
texture = new IIcon[UPGRADES_AMOUNT];
texture[0] = par1IconRegister.registerIcon(Textures.ITEM_UPGRADE_VOLUME);
texture[1] = par1IconRegister.registerIcon(Textures.ITEM_UPGRADE_DISPENSER);
texture[2] = par1IconRegister.registerIcon(Textures.ITEM_UPGRADE_ITEM_LIFE);
texture[3] = par1IconRegister.registerIcon(Textures.ITEM_UPGRADE_ENTITY_TRACKER);
texture[4] = par1IconRegister.registerIcon(Textures.ITEM_UPGRADE_BLOCK_TRACKER);
texture[5] = par1IconRegister.registerIcon(Textures.ITEM_UPGRADE_SPEED);
texture[6] = par1IconRegister.registerIcon(Textures.ITEM_UPGRADE_SEARCH);
texture[7] = par1IconRegister.registerIcon(Textures.ITEM_UPGRADE_COORDINATE_TRACKER);
texture[8] = par1IconRegister.registerIcon(Textures.ITEM_UPGRADE_RANGE);
texture[9] = par1IconRegister.registerIcon(Textures.ITEM_UPGRADE_SECURITY);
texture[10] = par1IconRegister.registerIcon(Textures.ITEM_UPGRADE_THAUMCRAFT);
}
@Override
public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon)
{
if(rendererOld != null && rendererOld.hasOverrideBlockTexture())
{
IIcon i = rendererOld.overrideBlockTexture;
tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMinU(), i.getMaxV());
tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMinV());
tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMaxU(), i.getMinV());
tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
} else
{
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 0);
setupSides(0, 3, 7, 4, 18, 21, 20, 19, 13);
side(13, 21, 7, 20, tex[3], true);
side(19, 13, 20, 4, tex[2], true);
side(0, 18, 13, 19, tex[0], true);
side(18, 3, 21, 13, tex[1], true);
}
}
void side(int a, int b, int c, int d, int iconIndex, boolean flip)
{
IIcon icon = iconIndex >= 16 ? submapSmall.icons[iconIndex - 16] : submap.icons[iconIndex];
double u0 = icon.getMaxU();
double u1 = icon.getMinU();
double v0 = icon.getMaxV();
double v1 = icon.getMinV();
U[a] = flip ? u1 : u1;
U[b] = flip ? u0 : u1;
U[c] = flip ? u0 : u0;
U[d] = flip ? u1 : u0;
V[a] = flip ? v1 : v1;
V[b] = flip ? v1 : v0;
V[c] = flip ? v0 : v0;
V[d] = flip ? v0 : v1;
vert(a);
vert(b);
vert(c);
vert(d);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister register) {
icons = new IIcon[4];
icons[ICON_SIDE] = register.registerIcon(GardenCore.MOD_ID + ":compost_bin_side");
icons[ICON_TOP] = register.registerIcon(GardenCore.MOD_ID + ":compost_bin_top");
icons[ICON_BOTTOM] = register.registerIcon(GardenCore.MOD_ID + ":compost_bin_bottom");
icons[ICON_INNER] = register.registerIcon(GardenCore.MOD_ID + ":compost_bin_inner");
}
private IIcon getCasingEdgeIcon(TileEntityReactorPart part, MultiblockReactor reactor, int side) {
if(reactor == null || !reactor.isAssembled()) { return _icons[METADATA_CASING][DEFAULT]; }
CoordTriplet minCoord = reactor.getMinimumCoord();
CoordTriplet maxCoord = reactor.getMaximumCoord();
boolean xExtreme, yExtreme, zExtreme;
xExtreme = yExtreme = zExtreme = false;
if(part.xCoord == minCoord.x || part.xCoord == maxCoord.x) { xExtreme = true; }
if(part.yCoord == minCoord.y || part.yCoord == maxCoord.y) { yExtreme = true; }
if(part.zCoord == minCoord.z || part.zCoord == maxCoord.z) { zExtreme = true; }
int idx = DEFAULT;
if(!xExtreme) {
if(side < 4) { idx = EASTWEST; }
}
else if(!yExtreme) {
if(side > 1) {
idx = VERTICAL;
}
}
else { // !zExtreme
if(side < 2) {
idx = NORTHSOUTH;
}
else if(side > 3) {
idx = EASTWEST;
}
}
return _icons[METADATA_CASING][idx];
}
/**
* Gets the block's texture. Args: side, meta
*/
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
if(meta == 1)
return bottom;
else
return top;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister) {
this.texture = new IIcon[this.textureNames.length];
for (int i = 0; i < this.textureNames.length; i++) {
this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]);
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
if (meta < 0 || meta >= icons.length)
meta = 0;
return icons[meta];
}
private IIcon safeGetIcon(IIcon[] list, int idx, int x, int y, int z) {
if(idx < 0 || idx >= list.length) {
BRLog.warning("Invalid metadata (%d) for block at %d, %d, %d!", idx, x, y, z);
return blockIcon;
}
else {
return list[idx];
}
}
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister ir) {
icons = new IIcon[2];
icons[0] = ir.registerIcon("forbidden:emptycrystal");
icons[1] = ir.registerIcon("forbidden:mobcrystal");
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
TileEntityElevatorCaller te = (TileEntityElevatorCaller)world.getTileEntity(x, y, z);
if(te.camoBlock != null && PneumaticCraftUtils.isRenderIDCamo(te.camoBlock.getRenderType())) {
return te.camoBlock.getIcon(side, te.camoStack.getItemDamage());
}
return this.getIcon(side, world.getBlockMetadata(x, y, z));
}
private IIcon getTurbineCasing(int meta, int iconIndex, boolean active) {
switch (meta) {
case 0:
return active ? Textures.BlockIcons.TURBINE_ACTIVE[iconIndex].getIcon() : Textures.BlockIcons.TURBINE[iconIndex].getIcon();
default:
return active ? Textures.BlockIcons.TURBINE_ACTIVE[iconIndex].getIcon() : Textures.BlockIcons.TURBINE[iconIndex].getIcon();
}
}
@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());
}
public static void drawBlock(Block block, IIcon icon, RenderBlocks renderer)
{
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1.0F, 0.0F);
renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, icon);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, icon);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1.0F);
renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, icon);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, icon);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, icon);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, icon);
tessellator.draw();
}
@SideOnly(Side.CLIENT)
public IIcon getFlowerIcon (IBlockAccess world, int x, int y, int z, int meta, int side) {
boolean clear1 = world.getBlock(x, y + 1, z) != this;
boolean clear2 = world.getBlock(x, y, z - 1) != this;
boolean clear3 = world.getBlock(x, y, z + 1) != this;
boolean clear4 = world.getBlock(x - 1, y, z) != this;
boolean clear5 = world.getBlock(x + 1, y, z) != this;
if (side == 1 && clear1)
return flowersTop[meta & 3];
else if ((side == 2 && clear2) || (side == 3 && clear3) || (side == 4 && clear4) || (side == 5 && clear5))
return clear1 ? flowersTopSide[meta & 3] : flowersSide[meta & 3];
return null;
}
@Override
@SideOnly(Side.CLIENT)
/**
* Returns the icon index on items.png that is used as background image of the slot.
*/
public IIcon getBackgroundIconIndex(){
return ItemArmor.func_94602_b(armorType);
}
@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);
}
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;
}
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
{
int meta = world.getBlockMetadata(x, y, z);
int logDirection = meta & 12;
if((logDirection == 0 && (side == 1 || side == 0)) || (logDirection == 4 && (side == 5 || side == 4)) || (logDirection == 8 && (side == 2 || side == 3)))
return ends;
else {
Random r = new Random((long)(side + y + x * z));
return r.nextInt(100) < 75 ? sides : r.nextBoolean() ? gross : gross2;
}
}
private void renderInteriorFace (int face, IBlockAccess blockAccess, Block block, double x, double y, double z) {
IIcon icon = interiorIcon[face];
float r = interiorColor[face][0];
float g = interiorColor[face][1];
float b = interiorColor[face][2];
renderFace(face, blockAccess, block, x, y, z, icon, r, g, b);
}
@Override
public IIcon getIcon(){
if(icon == null) {
ItemStack stack = new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.HELIUM_PLANT_DAMAGE);
icon = stack.getIconIndex();
}
return icon;
}
@Override
public IIcon getIcon( int side, int damage )
{
if( s_forceGrass )
{
return Blocks.grass.getIcon( side, damage );
}
else
{
return s_swirlIcon;
}
}
@Override
public IIcon getIconIndex(ItemStack stack) {
if (stack.getItemDamage() == 0)
return normal;
if (stack.getItemDamage() == 1)
return rotate;
if (stack.getItemDamage() == 2)
return debug;
if (stack.getItemDamage() == 3)
return config;
return super.getIconIndex(stack);
}
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int metadata = world.getBlockMetadata(x, y, z);
if (metadata < 0 || metadata > 15)
metadata = 0;
IVariationInfo info = infoMap[metadata];
if (info == null)
return getMissingIcon();
return info.getIcon(world, x, y, z, side);
}
@Override
public void registerIcons( IIconRegister iconRegister )
{
s_icons = new IIcon[ SubTypes.Count ];
s_icons[ SubTypes.Quantum ] = iconRegister.registerIcon( "qcraft:goggles" );
s_icons[ SubTypes.AntiObservation ] = iconRegister.registerIcon( "qcraft:ao_goggles" );
}
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister ir) {
icons = new IIcon[7];
for (int x = 0; x < 7; x++) {
icons[x] = ir.registerIcon("forbidden:" + vices[x] + "shard");
}
}
public TextureSubmap(IIcon i, int w, int h)
{
icon = i;
width = w;
height = h;
icons = new IIcon[width * height];
MinecraftForge.EVENT_BUS.register(this);
}
@Override
public IIcon getIcon(int side, int meta) {
return submapSmall.getBaseIcon();
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return base.getIcon(side, 0);
}