More work on TWire to unify framed and flat wire code
This commit is contained in:
parent
35afb54126
commit
07e50eb5dd
7 changed files with 46 additions and 72 deletions
|
@ -12,7 +12,7 @@ import resonantinduction.core.util.ResonantUtil
|
||||||
* Trait applied to objects that can associates with a color.
|
* Trait applied to objects that can associates with a color.
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*/
|
*/
|
||||||
trait TColorable[M] extends TMultiPart with TPart
|
trait TColorable extends TMultiPart with TPart
|
||||||
{
|
{
|
||||||
val defaultColor = 15
|
val defaultColor = 15
|
||||||
var colorID = defaultColor
|
var colorID = defaultColor
|
||||||
|
@ -74,7 +74,7 @@ trait TColorable[M] extends TMultiPart with TPart
|
||||||
{
|
{
|
||||||
if (packetID == 2)
|
if (packetID == 2)
|
||||||
{
|
{
|
||||||
colorID = packet.readInt
|
colorID = packet.readInt()
|
||||||
tile.markRender()
|
tile.markRender()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,5 +90,4 @@ trait TColorable[M] extends TMultiPart with TPart
|
||||||
super.load(nbt)
|
super.load(nbt)
|
||||||
this.colorID = nbt.getInteger("dyeID")
|
this.colorID = nbt.getInteger("dyeID")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -12,6 +12,7 @@ import scala.collection.convert.wrapAll._
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Trait applied to objects that can be insulated/enhanced by a certain item.
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*/
|
*/
|
||||||
trait TInsulatable extends TMultiPart with TPart
|
trait TInsulatable extends TMultiPart with TPart
|
||||||
|
|
|
@ -24,7 +24,7 @@ trait TMaterial[M] extends TMultiPart
|
||||||
|
|
||||||
override def writeDesc(packet: MCDataOutput)
|
override def writeDesc(packet: MCDataOutput)
|
||||||
{
|
{
|
||||||
packet.writeByte(getMaterialID.asInstanceOf[Byte])
|
packet.writeByte(getMaterialID.toByte)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def save(nbt: NBTTagCompound)
|
override def save(nbt: NBTTagCompound)
|
||||||
|
|
|
@ -57,7 +57,7 @@ class ItemWire extends TItemMultiPart
|
||||||
|
|
||||||
override def getUnlocalizedName(itemStack: ItemStack): String =
|
override def getUnlocalizedName(itemStack: ItemStack): String =
|
||||||
{
|
{
|
||||||
return super.getUnlocalizedName(itemStack) + "." + WireMaterial.values()(itemStack.getItemDamage).getName.toLowerCase
|
return super.getUnlocalizedName(itemStack) + "." + WireMaterial.values()(itemStack.getItemDamage).name.toLowerCase
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings(Array("unchecked")) override def addInformation(itemStack: ItemStack, player: EntityPlayer, list: List[_], par4: Boolean)
|
@SuppressWarnings(Array("unchecked")) override def addInformation(itemStack: ItemStack, player: EntityPlayer, list: List[_], par4: Boolean)
|
||||||
|
@ -69,7 +69,7 @@ class ItemWire extends TItemMultiPart
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.wire.resistance").replace("%v", "" + EnumColor.ORANGE + new UnitDisplay(UnitDisplay.Unit.RESISTANCE, WireMaterial.values()(itemStack.getItemDamage).resistance)))
|
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.wire.resistance").replace("%v", "" + EnumColor.ORANGE + new UnitDisplay(UnitDisplay.Unit.RESISTANCE, WireMaterial.values()(itemStack.getItemDamage).resistance)))
|
||||||
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.wire.current").replace("%v", "" + EnumColor.ORANGE + new UnitDisplay(UnitDisplay.Unit.AMPERE, WireMaterial.values()(itemStack.getItemDamage).maxAmps)))
|
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.wire.current").replace("%v", "" + EnumColor.ORANGE + new UnitDisplay(UnitDisplay.Unit.AMPERE, WireMaterial.values()(itemStack.getItemDamage).maxCurrent)))
|
||||||
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.wire.damage").replace("%v", "" + EnumColor.ORANGE + WireMaterial.values()(itemStack.getItemDamage).damage))
|
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.wire.damage").replace("%v", "" + EnumColor.ORANGE + WireMaterial.values()(itemStack.getItemDamage).damage))
|
||||||
list.addAll(LanguageUtility.splitStringPerWord(LanguageUtility.getLocal("tooltip.wire.helpText"), 5))
|
list.addAll(LanguageUtility.splitStringPerWord(LanguageUtility.getLocal("tooltip.wire.helpText"), 5))
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ class ItemWire extends TItemMultiPart
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT) override def getColorFromItemStack(itemStack: ItemStack, par2: Int): Int =
|
@SideOnly(Side.CLIENT) override def getColorFromItemStack(itemStack: ItemStack, par2: Int): Int =
|
||||||
{
|
{
|
||||||
return new Color(WireMaterial.values()(itemStack.getItemDamage).color.rgb).darker.getRGB
|
return new Color(WireMaterial.values()(itemStack.getItemDamage).color).darker.getRGB
|
||||||
}
|
}
|
||||||
|
|
||||||
override def getSubItems(itemID: Item, tab: CreativeTabs, listToAddTo: List[_])
|
override def getSubItems(itemID: Item, tab: CreativeTabs, listToAddTo: List[_])
|
||||||
|
|
|
@ -80,7 +80,7 @@ public abstract class PartAdvancedWire extends PartConductor
|
||||||
//@Override
|
//@Override
|
||||||
public long getCurrentCapacity()
|
public long getCurrentCapacity()
|
||||||
{
|
{
|
||||||
return this.getMaterial().maxAmps;
|
return this.getMaterial().maxCurrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Material Methods */
|
/** Material Methods */
|
||||||
|
|
|
@ -4,82 +4,53 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
import codechicken.lib.colour.ColourRGBA;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enumerator for different wire materials. The metadata of the wire determines the type of the
|
* An enumerator for different wire materials. The metadata of the wire determines the type of the
|
||||||
* wire.
|
* wire.
|
||||||
*
|
*
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public enum WireMaterial
|
public enum WireMaterial
|
||||||
{
|
{
|
||||||
/** Copper: General. */
|
/**
|
||||||
COPPER("Copper", 1.68f, 5, 200, 184, 115, 51),
|
* Copper: General.
|
||||||
/** Tin: Low shock, cheap */
|
*/
|
||||||
TIN("Tin", 3.1f, 1, 100, 132, 132, 130),
|
COPPER("Copper", 1.68f, 5, 200, 0xB87333),
|
||||||
/** Iron: High Capacity */
|
/**
|
||||||
IRON("Iron", 3f, 3, 800, 97, 102, 105),
|
* Tin: Low shock, cheap
|
||||||
/** Aluminum: High Shock */
|
*/
|
||||||
ALUMINUM("Aluminum", 2.6f, 10, 600, 215, 205, 181),
|
TIN("Tin", 3.1f, 1, 100, 0x848482),
|
||||||
/** Aluminum: Low Resistance */
|
/**
|
||||||
SILVER("Silver", 1.59f, 5, 700, 192, 192, 192),
|
* Iron: High Capacity
|
||||||
/** Superconductor: Over-powered */
|
*/
|
||||||
SUPERCONDUCTOR("Superconductor", 0, 10, 1000000, 255, 255, 1);
|
IRON("Iron", 3f, 3, 800, 0x616669),
|
||||||
|
/**
|
||||||
|
* Aluminum: High Shock
|
||||||
|
*/
|
||||||
|
ALUMINUM("Aluminum", 2.6f, 10, 600, 0xD7CDB5),
|
||||||
|
/**
|
||||||
|
* Aluminum: Low Resistance
|
||||||
|
*/
|
||||||
|
SILVER("Silver", 1.59f, 5, 700, 0xC0C0C0),
|
||||||
|
/**
|
||||||
|
* Superconductor: Over-powered
|
||||||
|
*/
|
||||||
|
SUPERCONDUCTOR("Superconductor", 0, 10, 1000000, 0xFFFF01);
|
||||||
|
|
||||||
|
public final String name;
|
||||||
public final float resistance;
|
public final float resistance;
|
||||||
public final int damage;
|
public final int damage;
|
||||||
public final long maxAmps;
|
public final long maxCurrent;
|
||||||
public final ColourRGBA color;
|
public final int color;
|
||||||
private ItemStack wire;
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
private WireMaterial(String name, float resistance, int electrocutionDamage, long maxAmps, int r, int g, int b)
|
private WireMaterial(String name, float resistance, int damage, long maxCurrent, int color)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
/** Multiply the realistic resistance by a factor for game balance. */
|
this.resistance = resistance;
|
||||||
this.resistance = resistance / 100;
|
this.damage = damage;
|
||||||
this.damage = electrocutionDamage;
|
this.maxCurrent = maxCurrent;
|
||||||
this.maxAmps = maxAmps;
|
this.color = color;
|
||||||
this.color = new ColourRGBA(r, g, b, 255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getWire()
|
|
||||||
{
|
|
||||||
return getWire(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getWire(int amount)
|
|
||||||
{
|
|
||||||
ItemStack returnStack = wire.copy();
|
|
||||||
returnStack.stackSize = amount;
|
|
||||||
|
|
||||||
return returnStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWire(ItemStack item)
|
|
||||||
{
|
|
||||||
if (wire == null)
|
|
||||||
{
|
|
||||||
wire = item;
|
|
||||||
OreDictionary.registerOre(getName().toLowerCase() + "Wire", wire);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWire(Item item)
|
|
||||||
{
|
|
||||||
setWire(new ItemStack(item, 1, ordinal()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWire(Block block)
|
|
||||||
{
|
|
||||||
setWire(new ItemStack(block, 1, ordinal()));
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,15 +1,18 @@
|
||||||
package resonantinduction.electrical.wire.base
|
package resonantinduction.electrical.wire.base
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack
|
import net.minecraft.item.{Item, ItemStack}
|
||||||
import resonantinduction.core.prefab.part.TColorable
|
import resonantinduction.core.prefab.part.{TMaterial, TInsulatable, TColorable}
|
||||||
import resonantinduction.electrical.ElectricalContent
|
import resonantinduction.electrical.ElectricalContent
|
||||||
import resonantinduction.electrical.wire.WireMaterial
|
import resonantinduction.electrical.wire.WireMaterial
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Trait implemented by wires
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*/
|
*/
|
||||||
trait TWire extends TColorable[WireMaterial]
|
trait TWire extends TColorable with TMaterial[WireMaterial] with TInsulatable
|
||||||
{
|
{
|
||||||
|
override protected val insulationItem: Item = ElectricalContent.itemInsulation
|
||||||
|
|
||||||
def preparePlacement(side: Int, meta: Int)
|
def preparePlacement(side: Int, meta: Int)
|
||||||
|
|
||||||
override def setMaterial(i: Int)
|
override def setMaterial(i: Int)
|
||||||
|
|
Loading…
Reference in a new issue