The standalone wires render! :D
This commit is contained in:
parent
cb9d7a60cb
commit
0122b481a8
5 changed files with 132 additions and 105 deletions
|
@ -4,6 +4,7 @@ import resonantinduction.multimeter.PartMultimeter;
|
|||
import resonantinduction.transformer.PartTransformer;
|
||||
import resonantinduction.wire.flat.PartFlatSwitchWire;
|
||||
import resonantinduction.wire.flat.PartFlatWire;
|
||||
import resonantinduction.wire.framed.PartWire;
|
||||
import codechicken.multipart.MultiPartRegistry;
|
||||
import codechicken.multipart.MultiPartRegistry.IPartFactory;
|
||||
import codechicken.multipart.MultipartGenerator;
|
||||
|
@ -12,10 +13,18 @@ import codechicken.multipart.TMultiPart;
|
|||
public class MultipartRI implements IPartFactory
|
||||
{
|
||||
public static MultipartRI INSTANCE;
|
||||
|
||||
public static final String[] PART_TYPES = {
|
||||
"resonant_induction_wire",
|
||||
"resonant_induction_flat_wire",
|
||||
"resonant_induction_flat_switch_wire",
|
||||
"resonant_induction_multimeter",
|
||||
"resonant_induction_transformer"
|
||||
};
|
||||
|
||||
public MultipartRI()
|
||||
{
|
||||
MultiPartRegistry.registerParts(this, new String[] { "resonant_induction_flat_wire", "resonant_induction_flat_switch_wire", "resonant_induction_multimeter", "resonant_induction_transformer" });
|
||||
MultiPartRegistry.registerParts(this, PART_TYPES);
|
||||
MultipartGenerator.registerTrait("universalelectricity.api.energy.IConductor", "resonantinduction.wire.trait.TraitConductor");
|
||||
MultipartGenerator.registerTrait("cofh.api.energy.IEnergyHandler", "resonantinduction.wire.trait.TraitEnergyHandler");
|
||||
MultipartGenerator.registerTrait("ic2.api.energy.tile.IEnergySink", "resonantinduction.wire.trait.TraitEnergySink");
|
||||
|
@ -24,23 +33,24 @@ public class MultipartRI implements IPartFactory
|
|||
@Override
|
||||
public TMultiPart createPart(String name, boolean client)
|
||||
{
|
||||
if (name.equals("resonant_induction_flat_wire"))
|
||||
{
|
||||
return new PartFlatWire();
|
||||
}
|
||||
else if(name.equals("resonant_induction_flat_switch_wire"))
|
||||
{
|
||||
return new PartFlatSwitchWire();
|
||||
}
|
||||
else if (name.equals("resonant_induction_multimeter"))
|
||||
{
|
||||
return new PartMultimeter();
|
||||
}
|
||||
else if (name.equals("resonant_induction_transformer"))
|
||||
{
|
||||
return new PartTransformer();
|
||||
}
|
||||
|
||||
switch(name)
|
||||
{
|
||||
case "resonant_induction_wire":
|
||||
return new PartWire();
|
||||
|
||||
case "resonant_induction_flat_wire":
|
||||
return new PartFlatWire();
|
||||
|
||||
case "resonant_induction_flat_switch_wire":
|
||||
return new PartFlatSwitchWire();
|
||||
|
||||
case "resonant_induction_multimeter":
|
||||
return new PartMultimeter();
|
||||
|
||||
case "resonant_induction_transformer":
|
||||
return new PartTransformer();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,15 @@ import resonantinduction.TabRI;
|
|||
import resonantinduction.Utility;
|
||||
import resonantinduction.wire.flat.PartFlatWire;
|
||||
import resonantinduction.wire.flat.RenderFlatWire;
|
||||
import resonantinduction.wire.framed.PartWire;
|
||||
import resonantinduction.wire.framed.RenderPartWire;
|
||||
import universalelectricity.api.energy.UnitDisplay;
|
||||
import universalelectricity.api.energy.UnitDisplay.Unit;
|
||||
import calclavia.lib.Calclavia;
|
||||
import calclavia.lib.render.EnumColor;
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import codechicken.multipart.ControlKeyModifer;
|
||||
import codechicken.multipart.JItemMultiPart;
|
||||
import codechicken.multipart.MultiPartRegistry;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
|
@ -32,96 +35,112 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
|
||||
public class ItemWire extends JItemMultiPart
|
||||
{
|
||||
private Icon[] icons = new Icon[EnumWireMaterial.values().length];
|
||||
private Icon[] icons = new Icon[EnumWireMaterial.values().length];
|
||||
|
||||
public ItemWire(int id)
|
||||
{
|
||||
super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_ITEM, "wire", id).getInt(id));
|
||||
this.setUnlocalizedName(ResonantInduction.PREFIX + "wire");
|
||||
this.setCreativeTab(TabRI.INSTANCE);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
public ItemWire(int id)
|
||||
{
|
||||
super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_ITEM, "wire", id).getInt(id));
|
||||
this.setUnlocalizedName(ResonantInduction.PREFIX + "wire");
|
||||
this.setCreativeTab(TabRI.INSTANCE);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TMultiPart newPart(ItemStack itemStack, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 hit)
|
||||
{
|
||||
BlockCoord onPos = pos.copy().offset(side ^ 1);
|
||||
@Override
|
||||
public TMultiPart newPart(ItemStack itemStack, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 hit)
|
||||
{
|
||||
BlockCoord onPos = pos.copy().offset(side ^ 1);
|
||||
|
||||
if (!Utility.canPlaceWireOnSide(world, onPos.x, onPos.y, onPos.z, ForgeDirection.getOrientation(side), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (ControlKeyModifer.isControlDown(player))
|
||||
{
|
||||
PartWire wire = (PartWire) MultiPartRegistry.createPart("resonant_induction_wire", false);
|
||||
|
||||
PartFlatWire wire = (PartFlatWire) MultiPartRegistry.createPart("resonant_induction_flat_wire", false);
|
||||
if (wire != null)
|
||||
{
|
||||
wire.preparePlacement(itemStack.getItemDamage());
|
||||
}
|
||||
|
||||
if (wire != null)
|
||||
{
|
||||
wire.preparePlacement(side, itemStack.getItemDamage());
|
||||
}
|
||||
return wire;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Utility.canPlaceWireOnSide(world, onPos.x, onPos.y, onPos.z, ForgeDirection.getOrientation(side), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return wire;
|
||||
}
|
||||
PartFlatWire wire = (PartFlatWire) MultiPartRegistry.createPart("resonant_induction_flat_wire", false);
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage)
|
||||
{
|
||||
return damage;
|
||||
}
|
||||
if (wire != null)
|
||||
{
|
||||
wire.preparePlacement(side, itemStack.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
return super.getUnlocalizedName(itemStack) + "." + EnumWireMaterial.values()[itemStack.getItemDamage()].getName().toLowerCase();
|
||||
}
|
||||
return wire;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
list.add("Hold " + EnumColor.AQUA + "shift" + EnumColor.GREY + " for more information");
|
||||
}
|
||||
else
|
||||
{
|
||||
list.add(EnumColor.AQUA + "Resistance: " + EnumColor.ORANGE + UnitDisplay.getDisplay(EnumWireMaterial.values()[itemstack.getItemDamage()].resistance, Unit.RESISTANCE));
|
||||
list.add(EnumColor.AQUA + "Current Capacity: " + EnumColor.ORANGE + UnitDisplay.getDisplay(EnumWireMaterial.values()[itemstack.getItemDamage()].maxAmps, Unit.AMPERE));
|
||||
list.add(EnumColor.AQUA + "Shock Damage: " + EnumColor.ORANGE + EnumWireMaterial.values()[itemstack.getItemDamage()].damage);
|
||||
list.addAll(Calclavia.splitStringPerWord("The energy transfer rate can be increased and the energy loss may be reduced by using a higher the voltage.", 5));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int getMetadata(int damage)
|
||||
{
|
||||
return damage;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSpriteNumber()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
return super.getUnlocalizedName(itemStack) + "." + EnumWireMaterial.values()[itemStack.getItemDamage()].getName().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister register)
|
||||
{
|
||||
for (EnumWireMaterial material : EnumWireMaterial.values())
|
||||
{
|
||||
icons[material.ordinal()] = register.registerIcon(ResonantInduction.PREFIX + "wire." + EnumWireMaterial.values()[material.ordinal()].getName().toLowerCase());
|
||||
}
|
||||
@Override
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
list.add("Hold " + EnumColor.AQUA + "shift" + EnumColor.GREY + " for more information");
|
||||
}
|
||||
else
|
||||
{
|
||||
list.add(EnumColor.AQUA + "Resistance: " + EnumColor.ORANGE + UnitDisplay.getDisplay(EnumWireMaterial.values()[itemstack.getItemDamage()].resistance, Unit.RESISTANCE));
|
||||
list.add(EnumColor.AQUA + "Current Capacity: " + EnumColor.ORANGE + UnitDisplay.getDisplay(EnumWireMaterial.values()[itemstack.getItemDamage()].maxAmps, Unit.AMPERE));
|
||||
list.add(EnumColor.AQUA + "Shock Damage: " + EnumColor.ORANGE + EnumWireMaterial.values()[itemstack.getItemDamage()].damage);
|
||||
list.addAll(Calclavia.splitStringPerWord("The energy transfer rate can be increased and the energy loss may be reduced by using a higher the voltage.", 5));
|
||||
}
|
||||
}
|
||||
|
||||
RenderFlatWire.flatWireTexture = register.registerIcon(ResonantInduction.PREFIX + "models/flatWire");
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSpriteNumber()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIconFromDamage(int meta)
|
||||
{
|
||||
return icons[meta];
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister register)
|
||||
{
|
||||
for (EnumWireMaterial material : EnumWireMaterial.values())
|
||||
{
|
||||
icons[material.ordinal()] = register.registerIcon(ResonantInduction.PREFIX + "wire." + EnumWireMaterial.values()[material.ordinal()].getName().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo)
|
||||
{
|
||||
for (EnumWireMaterial mat : EnumWireMaterial.values())
|
||||
{
|
||||
listToAddTo.add(new ItemStack(itemID, 1, mat.ordinal()));
|
||||
}
|
||||
}
|
||||
RenderFlatWire.flatWireTexture = register.registerIcon(ResonantInduction.PREFIX + "models/flatWire");
|
||||
RenderPartWire.wireIcon = register.registerIcon(ResonantInduction.PREFIX + "models/wire");
|
||||
RenderPartWire.insulationIcon = register.registerIcon(ResonantInduction.PREFIX + "models/insulation" + (ResonantInduction.LO_FI_INSULATION ? "tiny" : ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIconFromDamage(int meta)
|
||||
{
|
||||
return icons[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo)
|
||||
{
|
||||
for (EnumWireMaterial mat : EnumWireMaterial.values())
|
||||
{
|
||||
listToAddTo.add(new ItemStack(itemID, 1, mat.ordinal()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,6 +115,11 @@ public class PartWire extends PartAdvancedWire implements TSlottedPart, JNormalO
|
|||
subParts.add(currentSides[6]);
|
||||
return subParts;
|
||||
}
|
||||
|
||||
public void preparePlacement(int meta)
|
||||
{
|
||||
this.setMaterial(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Cuboid6> getCollisionBoxes()
|
||||
|
@ -272,13 +277,8 @@ public class PartWire extends PartAdvancedWire implements TSlottedPart, JNormalO
|
|||
*/
|
||||
public boolean isConnectionPrevented(TileEntity tile, ForgeDirection side)
|
||||
{
|
||||
return (tile instanceof IConductor ? this.canConnectTo((IConductor) tile) : false) || (isBlockedOnSide(side));// ||
|
||||
// tile
|
||||
// instanceof
|
||||
// IBlockableConnection
|
||||
// &&
|
||||
// ((IBlockableConnection)
|
||||
// tile).isBlockedOnSide(side.getOpposite()))*/;
|
||||
return (tile instanceof IConductor ? this.canConnectTo((IConductor) tile) : false) || (isBlockedOnSide(side));
|
||||
// || tile instanceof IBlockableConnection && ((IBlockableConnection) tile).isBlockedOnSide(side.getOpposite()))*/;
|
||||
}
|
||||
|
||||
public byte getPossibleWireConnections()
|
||||
|
|
|
@ -133,9 +133,7 @@ public class RenderPartWire
|
|||
|
||||
public static void registerIcons(IconRegister iconReg)
|
||||
{
|
||||
wireIcon = iconReg.registerIcon(ResonantInduction.PREFIX + "models/wire");
|
||||
lainWireIcon = iconReg.registerIcon(ResonantInduction.PREFIX + "models/lainWire");
|
||||
insulationIcon = iconReg.registerIcon(ResonantInduction.PREFIX + "models/insulation" + (ResonantInduction.LO_FI_INSULATION ? "tiny" : ""));
|
||||
breakIcon = iconReg.registerIcon(ResonantInduction.PREFIX + "wire");
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3 KiB |
Loading…
Add table
Reference in a new issue