Tweaked material specialty

This commit is contained in:
Calclavia 2013-12-23 12:38:55 +08:00
parent 6056a2215a
commit 1743f428c4
5 changed files with 43 additions and 34 deletions

View file

@ -16,10 +16,18 @@ import codechicken.lib.colour.ColourRGBA;
public enum EnumWireMaterial public enum EnumWireMaterial
{ {
COPPER("Copper", 12.5F, 3, 20, 184, 115, 51), TIN("Tin", 13, 2, 5, 132, 132, 130), /** Copper: General. */
IRON("Iron", 0.1F, 20, 40, 97, 102, 105), ALUMINUM("Aluminum", 0.025F, 6, 150, 215, 205, 181), COPPER("Copper", 1.68f, 5, 10, 184, 115, 51),
SILVER("Silver", 5F, 1, 20, 192, 192, 192), /** Tin: Low shock, cheap */
SUPERCONDUCTOR("Superconductor", 0, 1, 100, 255, 255, 1); TIN("Tin", 11f, 1, 5, 132, 132, 130),
/** Iron: High Capacity */
IRON("Iron", 10f, 3, 80, 97, 102, 105),
/** Aluminum: High Shock */
ALUMINUM("Aluminum", 2.82f, 10, 70, 215, 205, 181),
/** Aluminum: Low Resistance */
SILVER("Silver", 1.59f, 5, 20, 192, 192, 192),
/** Superconductor: Over-powered */
SUPERCONDUCTOR("Superconductor", 0, 10, 200, 255, 255, 1);
public final float resistance; public final float resistance;
public final int damage; public final int damage;
@ -28,13 +36,14 @@ public enum EnumWireMaterial
private ItemStack wire; private ItemStack wire;
private final String name; private final String name;
private EnumWireMaterial(String s, float resist, int electrocution, long max, int r, int g, int b) private EnumWireMaterial(String name, float resistance, int electrocutionDamage, long maxAmps, int r, int g, int b)
{ {
name = s; this.name = name;
resistance = resist; /** Multiply the realistic resistance by a factor for game balance. */
damage = electrocution; this.resistance = resistance * 2;
maxAmps = max; this.damage = electrocutionDamage;
color = new ColourRGBA(r, g, b, 255); this.maxAmps = maxAmps;
this.color = new ColourRGBA(r, g, b, 255);
} }
public String getName() public String getName()

View file

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import calclavia.lib.prefab.CustomDamageSource;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockColored; import net.minecraft.block.BlockColored;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -14,9 +13,11 @@ import net.minecraft.item.ItemShears;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import resonantinduction.ResonantInduction;
import resonantinduction.wire.EnumWireMaterial; import resonantinduction.wire.EnumWireMaterial;
import universalelectricity.api.CompatibilityModule; import universalelectricity.api.CompatibilityModule;
import universalelectricity.api.UniversalElectricity;
import universalelectricity.api.energy.IConductor;
import calclavia.lib.prefab.CustomDamageSource;
import codechicken.lib.data.MCDataInput; import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput; import codechicken.lib.data.MCDataOutput;
@ -53,7 +54,7 @@ public abstract class PartAdvancedWire extends PartConductor
return true; return true;
} }
} }
else else if (!(obj instanceof IConductor))
{ {
return CompatibilityModule.isHandler(obj); return CompatibilityModule.isHandler(obj);
} }
@ -71,18 +72,15 @@ public abstract class PartAdvancedWire extends PartConductor
} }
@Override @Override
public long getEnergyLoss() public float getResistance()
{ {
/** return this.getMaterial().resistance;
* TODO: FIX THIS!
*/
return (int) (this.getMaterial().resistance * 10);
} }
@Override @Override
public long getEnergyCapacitance() public long getTransferCapacity()
{ {
return this.getMaterial().maxAmps * 1000; return this.getMaterial().maxAmps * UniversalElectricity.DEFAULT_VOLTAGE;
} }
/** /**

View file

@ -22,7 +22,7 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
*/ */
@Override @Override
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive) public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
{System.out.println("RECEIVE"); {
return this.getNetwork().produce(new Vector3(tile()).modifyPositionFromSide(from).getTileEntity(world()), from.getOpposite(), receive, doReceive); return this.getNetwork().produce(new Vector3(tile()).modifyPositionFromSide(from).getTileEntity(world()), from.getOpposite(), receive, doReceive);
} }

View file

@ -300,17 +300,12 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
*/ */
for (byte r = 0; r < 4; r++) for (byte r = 0; r < 4; r++)
{ {
boolean didConnect = false;
int absDir = Rotation.rotateSide(this.side, r);
if (maskOpen(r)) if (maskOpen(r))
{ {
int absDir = Rotation.rotateSide(this.side, r);
// Check direct connection. // Check direct connection.
if (this.setExternalConnection(absDir)) this.setExternalConnection(absDir);
{
didConnect |= true;
}
// Check Corner Connection // Check Corner Connection
BlockCoord cornerPos = new BlockCoord(tile()); BlockCoord cornerPos = new BlockCoord(tile());
@ -330,7 +325,6 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
// We found a wire, merge networks! // We found a wire, merge networks!
this.connections[absDir] = tp; this.connections[absDir] = tp;
this.getNetwork().merge(((PartFlatWire) tp).getNetwork()); this.getNetwork().merge(((PartFlatWire) tp).getNetwork());
didConnect |= true;
} }
} }
} }
@ -370,6 +364,10 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
if (this.maskOpen(absSide)) if (this.maskOpen(absSide))
{ {
BlockCoord pos = new BlockCoord(tile()).offset(absSide); BlockCoord pos = new BlockCoord(tile()).offset(absSide);
/**
* Look for an external wire connection.
*/
TileMultipart t = Utility.getMultipartTile(world(), pos); TileMultipart t = Utility.getMultipartTile(world(), pos);
if (t != null) if (t != null)
@ -385,10 +383,14 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
} }
} }
/**
* Look for an external energy handler.
*/
TileEntity tileEntity = world().getBlockTileEntity(pos.x, pos.y, pos.z); TileEntity tileEntity = world().getBlockTileEntity(pos.x, pos.y, pos.z);
if (this.canConnectTo(tileEntity)) if (this.canConnectTo(tileEntity))
{ {
System.out.println("FOUND TE");
this.connections[absSide] = tileEntity; this.connections[absSide] = tileEntity;
return true; return true;
} }

View file

@ -130,7 +130,7 @@ public class TraitConductor extends TileMultipart implements IConductor
} }
@Override @Override
public long getEnergyLoss() public float getResistance()
{ {
long energyLoss = 0; long energyLoss = 0;
@ -138,7 +138,7 @@ public class TraitConductor extends TileMultipart implements IConductor
{ {
for (IConductor conductor : this.interfaces) for (IConductor conductor : this.interfaces)
{ {
energyLoss += conductor.getEnergyLoss(); energyLoss += conductor.getResistance();
} }
energyLoss /= this.interfaces.size(); energyLoss /= this.interfaces.size();
@ -148,7 +148,7 @@ public class TraitConductor extends TileMultipart implements IConductor
} }
@Override @Override
public long getEnergyCapacitance() public long getTransferCapacity()
{ {
long capacitance = 0; long capacitance = 0;
@ -156,7 +156,7 @@ public class TraitConductor extends TileMultipart implements IConductor
{ {
for (IConductor conductor : this.interfaces) for (IConductor conductor : this.interfaces)
{ {
capacitance += conductor.getEnergyCapacitance(); capacitance += conductor.getTransferCapacity();
} }
capacitance /= this.interfaces.size(); capacitance /= this.interfaces.size();