Fixed unamed MultiPart wires

This commit is contained in:
Calclavia 2013-10-02 20:38:46 +08:00
parent 3b35287c2c
commit e44027bcf5
8 changed files with 80 additions and 69 deletions

View file

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

Before

Width:  |  Height:  |  Size: 224 B

After

Width:  |  Height:  |  Size: 224 B

View file

@ -24,10 +24,12 @@ import cpw.mods.fml.relauncher.SideOnly;
public class ItemPartWire extends JItemMultiPart public class ItemPartWire extends JItemMultiPart
{ {
private Icon[] icons = new Icon[EnumWireMaterial.values().length];
public ItemPartWire(int id) public ItemPartWire(int id)
{ {
super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_ITEM, "wireMultipart", id).getInt(id)); super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_ITEM, "wireMultipart", id).getInt(id));
this.setUnlocalizedName(ResonantInduction.PREFIX + "multiwire"); this.setUnlocalizedName(ResonantInduction.PREFIX + "wire");
this.setCreativeTab(TabRI.INSTANCE); this.setCreativeTab(TabRI.INSTANCE);
this.setHasSubtypes(true); this.setHasSubtypes(true);
this.setMaxDamage(0); this.setMaxDamage(0);
@ -39,7 +41,11 @@ public class ItemPartWire extends JItemMultiPart
return new PartWire(this.getDamage(arg0)); return new PartWire(this.getDamage(arg0));
} }
private Icon[] icons = new Icon[EnumWireMaterial.values().length]; @Override
public String getUnlocalizedName()
{
return super.getUnlocalizedName().replace("item", "tile");
}
@Override @Override
public int getMetadata(int damage) public int getMetadata(int damage)
@ -66,7 +72,7 @@ public class ItemPartWire extends JItemMultiPart
{ {
for (int i = 0; i < EnumWireMaterial.values().length; i++) for (int i = 0; i < EnumWireMaterial.values().length; i++)
{ {
this.icons[i] = iconRegister.registerIcon(this.getUnlocalizedName(new ItemStack(this.itemID, 1, i)).replaceAll("item.", "").replaceAll("multi","")); this.icons[i] = iconRegister.registerIcon(this.getUnlocalizedName(new ItemStack(this.itemID, 1, i)).replaceAll("tile.", ""));
} }
RenderPartWire.registerIcons(iconRegister); RenderPartWire.registerIcons(iconRegister);
@ -80,8 +86,10 @@ public class ItemPartWire extends JItemMultiPart
} }
@Override @Override
public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo) { public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo)
for (EnumWireMaterial mat : EnumWireMaterial.values()) { {
for (EnumWireMaterial mat : EnumWireMaterial.values())
{
listToAddTo.add(new ItemStack(itemID, 1, mat.ordinal())); listToAddTo.add(new ItemStack(itemID, 1, mat.ordinal()));
} }
} }

View file

@ -68,7 +68,8 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
/** Client Side Connection Check */ /** Client Side Connection Check */
private ForgeDirection testingSide; private ForgeDirection testingSide;
static { static
{
sides[0] = new IndexedCuboid6(0, new Cuboid6(0.36, 0.000, 0.36, 0.64, 0.36, 0.64)); sides[0] = new IndexedCuboid6(0, new Cuboid6(0.36, 0.000, 0.36, 0.64, 0.36, 0.64));
sides[1] = new IndexedCuboid6(1, new Cuboid6(0.36, 0.64, 0.36, 0.64, 1.000, 0.64)); sides[1] = new IndexedCuboid6(1, new Cuboid6(0.36, 0.64, 0.36, 0.64, 1.000, 0.64));
sides[2] = new IndexedCuboid6(2, new Cuboid6(0.36, 0.36, 0.000, 0.64, 0.64, 0.36)); sides[2] = new IndexedCuboid6(2, new Cuboid6(0.36, 0.36, 0.000, 0.64, 0.64, 0.36));
@ -130,7 +131,7 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
return true; return true;
} }
return (this.isBlockedOnSide(side) || tile instanceof IBlockableConnection && ((IBlockableConnection)tile).isBlockedOnSide(side.getOpposite())); return (this.isBlockedOnSide(side) || tile instanceof IBlockableConnection && ((IBlockableConnection) tile).isBlockedOnSide(side.getOpposite()));
} }
public byte getPossibleWireConnections() public byte getPossibleWireConnections()
@ -210,12 +211,13 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
{ {
Set<IndexedCuboid6> subParts = new HashSet<IndexedCuboid6>(); Set<IndexedCuboid6> subParts = new HashSet<IndexedCuboid6>();
IndexedCuboid6[] currentSides = this.isInsulated() ? insulatedSides : sides; IndexedCuboid6[] currentSides = this.isInsulated() ? insulatedSides : sides;
if(tile() != null) if (tile() != null)
{ {
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{ {
int ord = side.ordinal(); int ord = side.ordinal();
if(connectionMapContainsSide(getAllCurrentConnections(), side) || side == this.testingSide) subParts.add(currentSides[ord]); if (connectionMapContainsSide(getAllCurrentConnections(), side) || side == this.testingSide)
subParts.add(currentSides[ord]);
} }
} }
subParts.add(currentSides[6]); subParts.add(currentSides[6]);
@ -235,7 +237,7 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
{ {
List<ItemStack> drops = new ArrayList<ItemStack>(); List<ItemStack> drops = new ArrayList<ItemStack>();
drops.add(pickItem(null)); drops.add(pickItem(null));
if(isInsulated) if (isInsulated)
drops.add(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(dyeID))); drops.add(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(dyeID)));
return drops; return drops;
} }
@ -277,7 +279,8 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
this.isInsulated = packet.readBoolean(); this.isInsulated = packet.readBoolean();
this.currentWireConnections = packet.readByte(); this.currentWireConnections = packet.readByte();
this.currentAcceptorConnections = packet.readByte(); this.currentAcceptorConnections = packet.readByte();
if (tile() != null) tile().markRender(); if (tile() != null)
tile().markRender();
} }
@Override @Override
@ -342,7 +345,8 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
return true; return true;
} }
} }
if (!world().isRemote)player.addChatMessage(getNetwork().toString()); if (!world().isRemote)
player.addChatMessage(getNetwork().toString());
return false; return false;
} }
@ -391,7 +395,7 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
this.dyeID = DEFAULT_COLOR; this.dyeID = DEFAULT_COLOR;
this.refresh(); this.refresh();
this.world().markBlockForUpdate(this.x(), this.y(), this.z()); this.world().markBlockForUpdate(this.x(), this.y(), this.z());
((TileMultipart)this.tile()).notifyPartChange(this); ((TileMultipart) this.tile()).notifyPartChange(this);
} }
public void setInsulated(int dyeColour) public void setInsulated(int dyeColour)
@ -400,7 +404,7 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
this.dyeID = dyeColour; this.dyeID = dyeColour;
this.refresh(); this.refresh();
this.world().markBlockForUpdate(this.x(), this.y(), this.z()); this.world().markBlockForUpdate(this.x(), this.y(), this.z());
((TileMultipart)this.tile()).notifyPartChange(this); ((TileMultipart) this.tile()).notifyPartChange(this);
} }
public void setInsulated() public void setInsulated()
@ -454,5 +458,4 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
refresh(); refresh();
} }
} }