Simplified block icon assignment

This commit is contained in:
Taylor Shuler 2014-08-03 22:09:39 +01:00
parent 2a127a0871
commit 2b93d37be3
26 changed files with 18 additions and 47 deletions

View File

@ -33,6 +33,9 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class BlockIronChest extends BlockContainer { public class BlockIronChest extends BlockContainer {
@SideOnly(Side.CLIENT)
public static IIcon icon[] = new IIcon[IronChestType.values().length];
public BlockIronChest() public BlockIronChest()
{ {
super(Material.iron); super(Material.iron);
@ -68,14 +71,22 @@ public class BlockIronChest extends BlockContainer {
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int i, int j) public void registerBlockIcons(IIconRegister r)
{ {
if (j < IronChestType.values().length) for (IronChestType type : IronChestType.values())
{ {
IronChestType type = IronChestType.values()[j]; if (type.isValidForCreativeMode())
return type.getIcon(i); {
} icon[type.ordinal()] = r.registerIcon("ironchest:" + type.name().toLowerCase());
return null; }
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
return icon[meta];
} }
@Override @Override
@ -238,16 +249,6 @@ public class BlockIronChest extends BlockContainer {
return 0; return 0;
} }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister)
{
for (IronChestType typ: IronChestType.values())
{
typ.makeIcons(par1IconRegister);
}
}
@Override @Override
public ForgeDirection[] getValidRotations(World worldObj, int x, int y, int z) public ForgeDirection[] getValidRotations(World worldObj, int x, int y, int z)
{ {

View File

@ -4,17 +4,13 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagByte; import net.minecraft.nbt.NBTTagByte;
import net.minecraft.util.IIcon;
import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapedOreRecipe;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public enum IronChestType { public enum IronChestType {
IRON(54, 9, true, "Iron Chest", "ironchest.png", 0, Arrays.asList("ingotIron", "ingotRefinedIron"), TileEntityIronChest.class, "mmmmPmmmm", "mGmG3GmGm"), IRON(54, 9, true, "Iron Chest", "ironchest.png", 0, Arrays.asList("ingotIron", "ingotRefinedIron"), TileEntityIronChest.class, "mmmmPmmmm", "mGmG3GmGm"),
@ -204,32 +200,6 @@ public enum IronChestType {
return this == OBSIDIAN; return this == OBSIDIAN;
} }
@SideOnly(Side.CLIENT)
private IIcon[] icons;
@SideOnly(Side.CLIENT)
public void makeIcons(IIconRegister par1IconRegister)
{
if (isValidForCreativeMode())
{
icons = new IIcon[3];
int i = 0;
for (String s : sideNames)
{
icons[i++] = par1IconRegister.registerIcon(String.format("ironchest:%s_%s",name().toLowerCase(),s));
}
}
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side)
{
return icons[sideMapping[side]];
}
private static String[] sideNames = { "top", "front", "side" };
private static int[] sideMapping = { 0, 0, 2, 1, 2, 2, 2 };
public boolean acceptsStack(ItemStack itemstack) public boolean acceptsStack(ItemStack itemstack)
{ {
return itemFilter == null || itemstack == null || itemstack.getItem() == itemFilter; return itemFilter == null || itemstack == null || itemstack.getItem() == itemFilter;

View File

Before

Width:  |  Height:  |  Size: 546 B

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 661 B

View File

Before

Width:  |  Height:  |  Size: 382 B

After

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

View File

Before

Width:  |  Height:  |  Size: 572 B

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 719 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 572 B

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 784 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 726 B

View File

Before

Width:  |  Height:  |  Size: 572 B

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 787 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 726 B

View File

Before

Width:  |  Height:  |  Size: 604 B

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 593 B

View File

Before

Width:  |  Height:  |  Size: 527 B

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 608 B