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);
@ -38,8 +40,12 @@ 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,9 +72,9 @@ 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);
} }
@ -79,18 +85,20 @@ public class ItemPartWire extends JItemMultiPart
return this.icons[meta]; return this.icons[meta];
} }
@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()) { {
listToAddTo.add(new ItemStack(itemID, 1, mat.ordinal())); for (EnumWireMaterial mat : EnumWireMaterial.values())
} {
} listToAddTo.add(new ItemStack(itemID, 1, mat.ordinal()));
}
@Override }
@SideOnly(Side.CLIENT)
public int getSpriteNumber() @Override
{ @SideOnly(Side.CLIENT)
return 0; public int getSpriteNumber()
} {
return 0;
}
} }

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));
@ -84,23 +85,23 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
insulatedSides[5] = new IndexedCuboid6(5, new Cuboid6(0.7, 0.3, 0.3, 1.0, 0.7, 0.7)); insulatedSides[5] = new IndexedCuboid6(5, new Cuboid6(0.7, 0.3, 0.3, 1.0, 0.7, 0.7));
insulatedSides[6] = new IndexedCuboid6(6, new Cuboid6(0.3, 0.3, 0.3, 0.7, 0.7, 0.7)); insulatedSides[6] = new IndexedCuboid6(6, new Cuboid6(0.3, 0.3, 0.3, 0.7, 0.7, 0.7));
} }
public PartWire(int typeID) public PartWire(int typeID)
{ {
this(EnumWireMaterial.values()[typeID]); this(EnumWireMaterial.values()[typeID]);
} }
public PartWire(EnumWireMaterial type) public PartWire(EnumWireMaterial type)
{ {
super(); super();
this.material = type; this.material = type;
} }
public PartWire() public PartWire()
{ {
super(); super();
} }
@Override @Override
public boolean canConnect(ForgeDirection direction) public boolean canConnect(ForgeDirection direction)
{ {
@ -111,13 +112,13 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
return super.canConnect(direction); return super.canConnect(direction);
} }
public boolean connectionPrevented(TileEntity tile, ForgeDirection side) public boolean connectionPrevented(TileEntity tile, ForgeDirection side)
{ {
if (tile instanceof IWireMaterial) if (tile instanceof IWireMaterial)
{ {
IWireMaterial wireTile = (IWireMaterial) tile; IWireMaterial wireTile = (IWireMaterial) tile;
if (wireTile.getMaterial() != this.getMaterial()) if (wireTile.getMaterial() != this.getMaterial())
return true; return true;
} }
@ -129,10 +130,10 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
if ((insulatedTile.isInsulated() && insulatedTile.getInsulationColor() != this.getInsulationColor() && this.getInsulationColor() != DEFAULT_COLOR && insulatedTile.getInsulationColor() != DEFAULT_COLOR)) if ((insulatedTile.isInsulated() && insulatedTile.getInsulationColor() != this.getInsulationColor() && this.getInsulationColor() != DEFAULT_COLOR && insulatedTile.getInsulationColor() != DEFAULT_COLOR))
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()
{ {
if (this.world().isBlockIndirectlyGettingPowered(this.x(), this.y(), this.z())) if (this.world().isBlockIndirectlyGettingPowered(this.x(), this.y(), this.z()))
@ -167,7 +168,7 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
{ {
return material; return material;
} }
public int getTypeID() public int getTypeID()
{ {
return material.ordinal(); return material.ordinal();
@ -179,7 +180,7 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
this.refresh(); this.refresh();
this.world().markBlockForUpdate(this.x(), this.y(), this.z()); this.world().markBlockForUpdate(this.x(), this.y(), this.z());
} }
public void setMaterialFromID(int id) public void setMaterialFromID(int id)
{ {
this.material = EnumWireMaterial.values()[id]; this.material = EnumWireMaterial.values()[id];
@ -192,13 +193,13 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
this.powerHandler.configure(0, this.buildcraftBuffer, this.buildcraftBuffer, this.buildcraftBuffer * 2); this.powerHandler.configure(0, this.buildcraftBuffer, this.buildcraftBuffer, this.buildcraftBuffer * 2);
super.doWork(workProvider); super.doWork(workProvider);
} }
@Override @Override
public String getType() public String getType()
{ {
return "resonant_induction_wire"; return "resonant_induction_wire";
} }
@Override @Override
public boolean occlusionTest(TMultiPart other) public boolean occlusionTest(TMultiPart other)
{ {
@ -210,18 +211,19 @@ 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]);
return subParts; return subParts;
} }
@Override @Override
public Iterable<Cuboid6> getCollisionBoxes() public Iterable<Cuboid6> getCollisionBoxes()
{ {
@ -235,17 +237,17 @@ 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;
} }
@Override @Override
public float getStrength(MovingObjectPosition hit, EntityPlayer player) public float getStrength(MovingObjectPosition hit, EntityPlayer player)
{ {
return 10F; return 10F;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void renderStatic(codechicken.lib.vec.Vector3 pos, LazyLightMatrix olm, int pass) public void renderStatic(codechicken.lib.vec.Vector3 pos, LazyLightMatrix olm, int pass)
@ -253,33 +255,34 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
if (pass == 0) if (pass == 0)
renderer.renderStatic(this); renderer.renderStatic(this);
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void renderDynamic(codechicken.lib.vec.Vector3 pos, float frame, int pass) public void renderDynamic(codechicken.lib.vec.Vector3 pos, float frame, int pass)
{ {
if (ResonantInduction.SHINY_SILVER && this.getMaterial() == EnumWireMaterial.SILVER) if (ResonantInduction.SHINY_SILVER && this.getMaterial() == EnumWireMaterial.SILVER)
renderer.renderShine(this, pos.x, pos.y, pos.z, frame); renderer.renderShine(this, pos.x, pos.y, pos.z, frame);
} }
@Override @Override
public void drawBreaking(RenderBlocks renderBlocks) public void drawBreaking(RenderBlocks renderBlocks)
{ {
CCRenderState.reset(); CCRenderState.reset();
RenderUtils.renderBlock(sides[6], 0, new Translation(x(), y(), z()), new IconTransformation(renderBlocks.overrideBlockTexture), null); RenderUtils.renderBlock(sides[6], 0, new Translation(x(), y(), z()), new IconTransformation(renderBlocks.overrideBlockTexture), null);
} }
@Override @Override
public void readDesc(MCDataInput packet) public void readDesc(MCDataInput packet)
{ {
this.setMaterialFromID(packet.readInt()); this.setMaterialFromID(packet.readInt());
this.dyeID = packet.readInt(); this.dyeID = packet.readInt();
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
public void writeDesc(MCDataOutput packet) public void writeDesc(MCDataOutput packet)
{ {
@ -289,7 +292,7 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
packet.writeByte(this.currentWireConnections); packet.writeByte(this.currentWireConnections);
packet.writeByte(this.currentAcceptorConnections); packet.writeByte(this.currentAcceptorConnections);
} }
@Override @Override
public void save(NBTTagCompound nbt) public void save(NBTTagCompound nbt)
{ {
@ -298,7 +301,7 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
nbt.setInteger("dyeID", this.dyeID); nbt.setInteger("dyeID", this.dyeID);
nbt.setBoolean("isInsulated", this.isInsulated); nbt.setBoolean("isInsulated", this.isInsulated);
} }
@Override @Override
public void load(NBTTagCompound nbt) public void load(NBTTagCompound nbt)
{ {
@ -307,13 +310,13 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
this.dyeID = nbt.getInteger("dyeID"); this.dyeID = nbt.getInteger("dyeID");
this.isInsulated = nbt.getBoolean("isInsulated"); this.isInsulated = nbt.getBoolean("isInsulated");
} }
@Override @Override
public ItemStack pickItem(MovingObjectPosition hit) public ItemStack pickItem(MovingObjectPosition hit)
{ {
return new ItemStack(ResonantInduction.itemPartWire, 1, this.getTypeID()); return new ItemStack(ResonantInduction.itemPartWire, 1, this.getTypeID());
} }
@Override @Override
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item) public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
{ {
@ -342,16 +345,17 @@ 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;
} }
@Override @Override
public Iterable<Cuboid6> getOcclusionBoxes() public Iterable<Cuboid6> getOcclusionBoxes()
{ {
return getCollisionBoxes(); return getCollisionBoxes();
} }
@Override @Override
public int getSlotMask() public int getSlotMask()
{ {
@ -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()
@ -425,18 +429,18 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
{ {
return RenderPartWire.breakIcon; return RenderPartWire.breakIcon;
} }
@Override @Override
public void addHitEffects(MovingObjectPosition hit, EffectRenderer effectRenderer) public void addHitEffects(MovingObjectPosition hit, EffectRenderer effectRenderer)
{ {
IconHitEffects.addHitEffects(this, hit, effectRenderer); IconHitEffects.addHitEffects(this, hit, effectRenderer);
} }
@Override @Override
public void addDestroyEffects(EffectRenderer effectRenderer) public void addDestroyEffects(EffectRenderer effectRenderer)
{ {
IconHitEffects.addDestroyEffects(this, effectRenderer, false); IconHitEffects.addDestroyEffects(this, effectRenderer, false);
} }
@Override @Override
public boolean isBlockedOnSide(ForgeDirection side) public boolean isBlockedOnSide(ForgeDirection side)
@ -447,12 +451,11 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
this.testingSide = null; this.testingSide = null;
return !expandable; return !expandable;
} }
@Override @Override
public void onPartChanged(TMultiPart part) public void onPartChanged(TMultiPart part)
{ {
refresh(); refresh();
} }
} }