Added wire material colors

This commit is contained in:
Calclavia 2013-08-23 20:49:01 +08:00
parent a8317525bc
commit e3551fcefd
14 changed files with 67 additions and 55 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 B

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 798 B

View file

@ -27,11 +27,12 @@ import resonantinduction.multimeter.TileEntityMultimeter;
import resonantinduction.tesla.BlockTesla;
import resonantinduction.tesla.TileEntityTesla;
import resonantinduction.wire.BlockWire;
import resonantinduction.wire.EnumWire;
import resonantinduction.wire.EnumWireMaterial;
import resonantinduction.wire.ItemBlockWire;
import resonantinduction.wire.TileEntityTickWire;
import resonantinduction.wire.TileEntityWire;
import universalelectricity.core.item.IItemElectric;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.TranslationHelper;
import basiccomponents.api.BasicRegistry;
import calclavia.lib.UniversalRecipes;
@ -135,6 +136,7 @@ public class ResonantInduction
public static Block blockEMContractor;
public static Block blockBattery;
public static Block blockWire;
public static final Vector3[] DYE_COLORS = new Vector3[] { new Vector3(), new Vector3(1, 0, 0), new Vector3(0, 0.608, 0.232), new Vector3(0.9, 0.8, 0.8), new Vector3(0, 0, 1), new Vector3(0.5, 0, 05), new Vector3(0, 0.3, 1), new Vector3(0.8, 0.8, 0.8), new Vector3(0.3, 0.3, 0.3), new Vector3(1, 0.768, 0.812), new Vector3(0.616, 1, 0), new Vector3(1, 1, 0), new Vector3(0.46f, 0.932, 1), new Vector3(0.5, 0.2, 0.5), new Vector3(0.7, 0.5, 0.1), new Vector3(1, 1, 1) };
@EventHandler
public void preInit(FMLPreInitializationEvent evt)
@ -222,7 +224,7 @@ public class ResonantInduction
ItemStack emptyCapacitor = new ItemStack(itemCapacitor);
((IItemElectric) itemCapacitor).setElectricity(emptyCapacitor, 0);
final ItemStack defaultWire = new ItemStack(blockWire, 1, EnumWire.IRON.ordinal());
final ItemStack defaultWire = new ItemStack(blockWire, 1, EnumWireMaterial.IRON.ordinal());
/** Capacitor **/
GameRegistry.addRecipe(new ShapedOreRecipe(emptyCapacitor, "RRR", "RIR", "RRR", 'R', Item.redstone, 'I', UniversalRecipes.PRIMARY_METAL));
@ -246,12 +248,12 @@ public class ResonantInduction
GameRegistry.addRecipe(new ShapedOreRecipe(blockEMContractor, " I ", "GCG", "WWW", 'W', UniversalRecipes.PRIMARY_METAL, 'C', emptyCapacitor, 'G', UniversalRecipes.SECONDARY_METAL, 'I', UniversalRecipes.PRIMARY_METAL));
/** Wires **/
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWire.COPPER.ordinal()), "MMM", 'M', "ingotCopper"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWire.TIN.ordinal()), "MMM", 'M', "ingotTin"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWire.IRON.ordinal()), "MMM", 'M', Item.ingotIron));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWire.ALUMINUM.ordinal()), "MMM", 'M', "ingotAluminum"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWire.SILVER.ordinal()), "MMM", 'M', "ingotSilver"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWire.SUPERCONDUCTOR.ordinal()), "MMM", 'M', "ingotSuperconductor"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.COPPER.ordinal()), "MMM", 'M', "ingotCopper"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.TIN.ordinal()), "MMM", 'M', "ingotTin"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.IRON.ordinal()), "MMM", 'M', Item.ingotIron));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.ALUMINUM.ordinal()), "MMM", 'M', "ingotAluminum"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.SILVER.ordinal()), "MMM", 'M', "ingotSilver"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.SUPERCONDUCTOR.ordinal()), "MMM", 'M', "ingotSuperconductor"));
}
}

View file

@ -150,7 +150,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
{
if (renderBeam)
{
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this).translate(0.5), new Vector3(this).translate(new Vector3(this.getDirection())).translate(0.5), TileEntityTesla.dyeColors[dyeID], false);
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this).translate(0.5), new Vector3(this).translate(new Vector3(this.getDirection())).translate(0.5), ResonantInduction.DYE_COLORS[dyeID], false);
}
/**
@ -173,7 +173,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
if (renderBeam)
{
ResonantInduction.proxy.renderElectricShock(this.worldObj, prevResult.clone().translate(0.5), result.clone().translate(0.5), TileEntityTesla.dyeColors[dyeID], false);
ResonantInduction.proxy.renderElectricShock(this.worldObj, prevResult.clone().translate(0.5), result.clone().translate(0.5), ResonantInduction.DYE_COLORS[dyeID], false);
}
AxisAlignedBB bounds = AxisAlignedBB.getAABBPool().getAABB(result.x, result.y, result.z, result.x + 1, result.y + 1, result.z + 1);
@ -203,7 +203,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
{
if (renderBeam && this.linked != null && this.linked.pathfinder != null)
{
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this).translate(0.5), new Vector3(this).translate(new Vector3(this.getDirection())).translate(0.5), TileEntityTesla.dyeColors[dyeID], false);
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this).translate(0.5), new Vector3(this).translate(new Vector3(this.getDirection())).translate(0.5), ResonantInduction.DYE_COLORS[dyeID], false);
}
this.pathfinder = null;
@ -222,7 +222,7 @@ public class TileEntityEMContractor extends TileEntityAdvanced implements IPacke
{
if (renderBeam)
{
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this).translate(0.5), new Vector3(entityItem), TileEntityTesla.dyeColors[dyeID], false);
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this).translate(0.5), new Vector3(entityItem), ResonantInduction.DYE_COLORS[dyeID], false);
}
this.moveEntity(entityItem, this.getDirection(), new Vector3(this));

View file

@ -7,7 +7,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ModelCopperWire extends ModelBase
public class ModelWire extends ModelBase
{
// fields
ModelRenderer Middle;
@ -18,7 +18,7 @@ public class ModelCopperWire extends ModelBase
ModelRenderer Top;
ModelRenderer Bottom;
public ModelCopperWire()
public ModelWire()
{
textureWidth = 64;
textureHeight = 32;

View file

@ -7,7 +7,8 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import resonantinduction.ResonantInduction;
import resonantinduction.model.ModelCopperWire;
import resonantinduction.model.ModelWire;
import resonantinduction.wire.EnumWireMaterial;
import resonantinduction.wire.TileEntityWire;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
@ -22,17 +23,20 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderWire extends TileEntitySpecialRenderer
{
private static final ResourceLocation COPPER_TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "wire.png");
public static final ModelCopperWire WIRE_MODEL = new ModelCopperWire();
private static final ResourceLocation WIRE_TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "wire.png");
public static final ModelWire WIRE_MODEL = new ModelWire();
public void renderModelAt(TileEntityWire tileEntity, double x, double y, double z, float f)
{
// Texture file
FMLClientHandler.instance().getClient().renderEngine.func_110577_a(COPPER_TEXTURE);
FMLClientHandler.instance().getClient().renderEngine.func_110577_a(WIRE_TEXTURE);
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
GL11.glScalef(1, -1, -1);
EnumWireMaterial material = tileEntity.getMaterial();
GL11.glColor4d(material.color.x, material.color.y, material.color.z, 1);
tileEntity.adjacentConnections = null;
TileEntity[] adjacentConnections = tileEntity.getAdjacentConnections();

View file

@ -44,8 +44,6 @@ import cpw.mods.fml.common.network.PacketDispatcher;
*/
public class TileEntityTesla extends TileEntityUniversalElectrical implements ITesla, IPacketReceiver
{
public static final Vector3[] dyeColors = new Vector3[] { new Vector3(), new Vector3(1, 0, 0), new Vector3(0, 0.608, 0.232), new Vector3(0.9, 0.8, 0.8), new Vector3(0, 0, 1), new Vector3(0.5, 0, 05), new Vector3(0, 0.3, 1), new Vector3(0.8, 0.8, 0.8), new Vector3(0.3, 0.3, 0.3), new Vector3(1, 0.768, 0.812), new Vector3(0.616, 1, 0), new Vector3(1, 1, 0), new Vector3(0.46f, 0.932, 1), new Vector3(0.5, 0.2, 0.5), new Vector3(0.7, 0.5, 0.1), new Vector3(1, 1, 1) };
public final static int DEFAULT_COLOR = 12;
public final float TRANSFER_CAP = 10;
private int dyeID = DEFAULT_COLOR;
@ -210,7 +208,7 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
}
double distance = topTeslaVector.distance(targetVector);
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).translate(new Vector3(0.5)), targetVector.translate(new Vector3(0.5)), (float) dyeColors[this.dyeID].x, (float) dyeColors[this.dyeID].y, (float) dyeColors[this.dyeID].z);
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).translate(new Vector3(0.5)), targetVector.translate(new Vector3(0.5)), (float) ResonantInduction.DYE_COLORS[this.dyeID].x, (float) ResonantInduction.DYE_COLORS[this.dyeID].y, (float) ResonantInduction.DYE_COLORS[this.dyeID].z);
this.transfer(tesla, Math.min(transferEnergy, TRANSFER_CAP));

View file

@ -72,7 +72,7 @@ public class BlockWire extends BlockConductor
@Override
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int i = 0; i < EnumWire.values().length - 1; i++)
for (int i = 0; i < EnumWireMaterial.values().length; i++)
{
par3List.add(new ItemStack(par1, 1, i));
}

View file

@ -1,26 +0,0 @@
package resonantinduction.wire;
/**
* An enumerator for different wire materials. The metadata of the wire determines the type of the
* wire.
*
* @author Calclavia
*
*/
public enum EnumWire
{
COPPER(12.5f, 3, 2), TIN(10, 2, 0.5f), IRON(0.1f, 2, 4), ALUMINUM(0.025f, 6, 0.15f),
SILVER(0.005f, 1, 2), SUPERCONDUCTOR(0, 8, Float.MAX_VALUE);
public final float resistance;
public final float damage;
public final float maxAmps;
EnumWire(float resistance, float electrocutionDamage, float maxAmps)
{
this.resistance = resistance;
this.damage = electrocutionDamage;
this.maxAmps = maxAmps;
}
}

View file

@ -0,0 +1,34 @@
package resonantinduction.wire;
import universalelectricity.core.vector.Vector3;
/**
* An enumerator for different wire materials. The metadata of the wire determines the type of the
* wire.
*
* @author Calclavia
*
*/
public enum EnumWireMaterial
{
COPPER(12.5f, 3, 2, new Vector3(132, 73, 33)),
TIN(10, 2, 0.5f, new Vector3(215, 205, 181)),
IRON(0.1f, 2, 4, new Vector3(97, 102, 105)),
ALUMINUM(0.025f, 6, 0.15f, new Vector3(97, 102, 105)),
SILVER(0.005f, 1, 2, new Vector3(176, 175, 171)),
SUPERCONDUCTOR(0, 8, Float.MAX_VALUE, new Vector3(242, 210, 63));
public final float resistance;
public final float damage;
public final float maxAmps;
public final Vector3 color;
EnumWireMaterial(float resistance, float electrocutionDamage, float maxAmps, Vector3 color)
{
this.resistance = resistance;
this.damage = electrocutionDamage;
this.maxAmps = maxAmps;
this.color = color.normalize();
}
}

View file

@ -14,7 +14,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockWire extends ItemBlock
{
private Icon[] icons = new Icon[EnumWire.values().length];
private Icon[] icons = new Icon[EnumWireMaterial.values().length];
public ItemBlockWire(int id)
{
@ -32,21 +32,21 @@ public class ItemBlockWire extends ItemBlock
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
return this.getUnlocalizedName() + "." + EnumWire.values()[itemStack.getItemDamage()].name().toLowerCase();
return this.getUnlocalizedName() + "." + EnumWireMaterial.values()[itemStack.getItemDamage()].name().toLowerCase();
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List par3List, boolean par4)
{
par3List.add("Resistance: " + ElectricityDisplay.getDisplay(EnumWire.values()[itemstack.getItemDamage()].resistance, ElectricUnit.RESISTANCE));
par3List.add("Max Amperage: " + ElectricityDisplay.getDisplay(EnumWire.values()[itemstack.getItemDamage()].maxAmps, ElectricUnit.AMPERE));
par3List.add("Resistance: " + ElectricityDisplay.getDisplay(EnumWireMaterial.values()[itemstack.getItemDamage()].resistance, ElectricUnit.RESISTANCE));
par3List.add("Max Amperage: " + ElectricityDisplay.getDisplay(EnumWireMaterial.values()[itemstack.getItemDamage()].maxAmps, ElectricUnit.AMPERE));
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
for (int i = 0; i < EnumWire.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("tile.", ""));
}

View file

@ -74,9 +74,9 @@ public class TileEntityWire extends TileEntityUniversalConductor
return getMaterial().maxAmps;
}
public EnumWire getMaterial()
public EnumWireMaterial getMaterial()
{
return EnumWire.values()[this.getTypeID()];
return EnumWireMaterial.values()[this.getTypeID()];
}
public int getTypeID()