From 0240818f1d312235a3412a638558323590ebd7f6 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Fri, 20 Dec 2013 22:23:47 +0800 Subject: [PATCH] Removed non-multipart wire. Now FMP dependent --- src/resonantinduction/ClientProxy.java | 3 - src/resonantinduction/ResonantInduction.java | 12 - src/resonantinduction/render/RenderWire.java | 136 --------- src/resonantinduction/wire/BlockWire.java | 135 --------- src/resonantinduction/wire/PartConductor.java | 2 + .../wire/PartUniversalConductor.java | 264 ------------------ src/resonantinduction/wire/PartWire.java | 23 +- .../wire/TileEntityWire.java | 212 -------------- 8 files changed, 3 insertions(+), 784 deletions(-) delete mode 100644 src/resonantinduction/render/RenderWire.java delete mode 100644 src/resonantinduction/wire/BlockWire.java delete mode 100644 src/resonantinduction/wire/PartUniversalConductor.java delete mode 100644 src/resonantinduction/wire/TileEntityWire.java diff --git a/src/resonantinduction/ClientProxy.java b/src/resonantinduction/ClientProxy.java index dfa4a8bb..1fb1407d 100644 --- a/src/resonantinduction/ClientProxy.java +++ b/src/resonantinduction/ClientProxy.java @@ -16,9 +16,7 @@ import resonantinduction.render.RenderBattery; import resonantinduction.render.RenderEMContractor; import resonantinduction.render.RenderMultimeter; import resonantinduction.render.RenderTesla; -import resonantinduction.render.RenderWire; import resonantinduction.tesla.TileEntityTesla; -import resonantinduction.wire.TileEntityWire; import universalelectricity.api.vector.Vector3; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; @@ -44,7 +42,6 @@ public class ClientProxy extends CommonProxy ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMultimeter.class, new RenderMultimeter()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEMContractor.class, new RenderEMContractor()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBattery.class, new RenderBattery()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWire.class, new RenderWire()); } @Override diff --git a/src/resonantinduction/ResonantInduction.java b/src/resonantinduction/ResonantInduction.java index 42d2af1f..6431cf36 100644 --- a/src/resonantinduction/ResonantInduction.java +++ b/src/resonantinduction/ResonantInduction.java @@ -37,11 +37,8 @@ import resonantinduction.multimeter.MultimeterEventHandler; import resonantinduction.multimeter.TileEntityMultimeter; import resonantinduction.tesla.BlockTesla; import resonantinduction.tesla.TileEntityTesla; -import resonantinduction.wire.BlockWire; import resonantinduction.wire.EnumWireMaterial; import resonantinduction.wire.ItemBlockWire; -import resonantinduction.wire.TileEntityWire; -import universalelectricity.api.Compatibility; import universalelectricity.api.vector.Vector3; import universalelectricity.core.item.IItemElectric; import basiccomponents.api.BasicRegistry; @@ -212,11 +209,6 @@ public class ResonantInduction blockEMContractor = new BlockEMContractor(getNextBlockID()); blockBattery = new BlockBattery(getNextBlockID()); - if (itemPartWire == null) - { - blockWire = new BlockWire(getNextBlockID()); - } - if (REPLACE_FURNACE) { blockAdvancedFurnaceIdle = BlockAdvancedFurnace.createNew(false); @@ -249,10 +241,6 @@ public class ResonantInduction GameRegistry.registerTileEntity(TileEntityEMContractor.class, blockEMContractor.getUnlocalizedName()); GameRegistry.registerTileEntity(TileEntityBattery.class, blockBattery.getUnlocalizedName()); - if (blockWire != null) - { - GameRegistry.registerTileEntity(TileEntityWire.class, blockWire.getUnlocalizedName()); - } ResonantInduction.proxy.registerRenderers(); diff --git a/src/resonantinduction/render/RenderWire.java b/src/resonantinduction/render/RenderWire.java deleted file mode 100644 index 867eec7c..00000000 --- a/src/resonantinduction/render/RenderWire.java +++ /dev/null @@ -1,136 +0,0 @@ -package resonantinduction.render; - -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; - -import resonantinduction.ResonantInduction; -import resonantinduction.model.ModelInsulation; -import resonantinduction.model.ModelWire; -import resonantinduction.wire.EnumWireMaterial; -import resonantinduction.wire.TileEntityWire; -import universalelectricity.api.vector.Vector3; -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -/** - * TODO: Use ISBRH. - * - * @author Calclavia - * - */ -@SideOnly(Side.CLIENT) -public class RenderWire extends TileEntitySpecialRenderer -{ - private static final ResourceLocation WIRE_TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "wire.png"); - private static final ResourceLocation INSULATION_TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "insulation.png"); - public static final ModelWire WIRE_MODEL = new ModelWire(); - public static final ModelInsulation INSULATION_MODEL = new ModelInsulation(); - - public void renderModelAt(TileEntityWire tileEntity, double x, double y, double z, float f) - { - if (tileEntity != null) - { - 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(); - // Texture file - FMLClientHandler.instance().getClient().renderEngine.bindTexture(WIRE_TEXTURE); - GL11.glColor4d(material.color.x, material.color.y, material.color.z, 1); - - tileEntity.adjacentConnections = null; - TileEntity[] adjacentConnections = tileEntity.getAdjacentConnections(); - - if (adjacentConnections != null) - { - if (adjacentConnections[0] != null) - { - WIRE_MODEL.renderBottom(); - } - - if (adjacentConnections[1] != null) - { - WIRE_MODEL.renderTop(); - } - - if (adjacentConnections[2] != null) - { - WIRE_MODEL.renderBack(); - } - - if (adjacentConnections[3] != null) - { - WIRE_MODEL.renderFront(); - } - - if (adjacentConnections[4] != null) - { - WIRE_MODEL.renderLeft(); - } - - if (adjacentConnections[5] != null) - { - WIRE_MODEL.renderRight(); - } - } - - WIRE_MODEL.renderMiddle(); - - if (tileEntity.isInsulated) - { - // Texture file - FMLClientHandler.instance().getClient().renderEngine.bindTexture(INSULATION_TEXTURE); - Vector3 insulationColor = ResonantInduction.DYE_COLORS[tileEntity.dyeID]; - GL11.glColor4d(insulationColor.x, insulationColor.y, insulationColor.z, 1); - - if (adjacentConnections != null) - { - if (adjacentConnections[0] != null) - { - INSULATION_MODEL.renderBottom(0.0625f); - } - - if (adjacentConnections[1] != null) - { - INSULATION_MODEL.renderTop(0.0625f); - } - - if (adjacentConnections[2] != null) - { - INSULATION_MODEL.renderBack(0.0625f); - } - - if (adjacentConnections[3] != null) - { - INSULATION_MODEL.renderFront(0.0625f); - } - - if (adjacentConnections[4] != null) - { - INSULATION_MODEL.renderLeft(0.0625f); - } - - if (adjacentConnections[5] != null) - { - INSULATION_MODEL.renderRight(0.0625f); - } - } - - INSULATION_MODEL.renderMiddle(0.0625f); - } - - GL11.glPopMatrix(); - } - } - - @Override - public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) - { - this.renderModelAt((TileEntityWire) tileEntity, var2, var4, var6, var8); - } -} \ No newline at end of file diff --git a/src/resonantinduction/wire/BlockWire.java b/src/resonantinduction/wire/BlockWire.java deleted file mode 100644 index fefb9fc0..00000000 --- a/src/resonantinduction/wire/BlockWire.java +++ /dev/null @@ -1,135 +0,0 @@ -package resonantinduction.wire; - -import java.util.List; - -import calclavia.lib.prefab.block.BlockConductor; -import net.minecraft.block.Block; -import net.minecraft.block.BlockColored; -import net.minecraft.block.material.Material; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import resonantinduction.ResonantInduction; -import resonantinduction.TabRI; - -/** - * A copper wire block that can change its collision bounds based on the connection. - * - * @author Calclavia, Aidancbrady - */ -public class BlockWire extends BlockConductor -{ - public BlockWire(int id) - { - super(ResonantInduction.CONFIGURATION.getBlock("wire", id).getInt(id), Material.cloth); - this.setUnlocalizedName(ResonantInduction.PREFIX + "wire"); - this.setStepSound(soundClothFootstep); - this.setResistance(0.2F); - this.setHardness(0.1f); - this.setBlockBounds(0.3f, 0.3f, 0.3f, 0.7f, 0.7f, 0.7f); - this.setCreativeTab(CreativeTabs.tabRedstone); - Block.setBurnProperties(this.blockID, 30, 60); - this.setTextureName(ResonantInduction.PREFIX + "wire"); - this.setCreativeTab(TabRI.INSTANCE); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) - { - TileEntity t = world.getBlockTileEntity(x, y, z); - TileEntityWire tileEntity = (TileEntityWire) t; - - if (entityPlayer.getCurrentEquippedItem() != null) - { - if (entityPlayer.getCurrentEquippedItem().itemID == Item.dyePowder.itemID) - { - tileEntity.setDye(entityPlayer.getCurrentEquippedItem().getItemDamage()); - return true; - } - else if (entityPlayer.getCurrentEquippedItem().itemID == Block.cloth.blockID && !tileEntity.isInsulated) - { - tileEntity.setInsulated(); - tileEntity.setDye(BlockColored.getDyeFromBlock(entityPlayer.getCurrentEquippedItem().getItemDamage())); - entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1); - return true; - } - } - - return false; - } - - /** - * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the - * shared face of two adjacent blocks and also whether the player can attach torches, redstone - * wire, etc to this block. - */ - @Override - public boolean isOpaqueCube() - { - return false; - } - - /** - * If this block doesn't render as an ordinary block it will return False (examples: signs, - * buttons, stairs, etc) - */ - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - /** - * The type of render function that is called for this block - */ - @Override - public int getRenderType() - { - return -1; - } - - @Override - public TileEntity createNewTileEntity(World var1) - { - return new TileEntityWire(); - } - - @Override - public int damageDropped(int par1) - { - return par1; - } - - @Override - public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) - { - for (int i = 0; i < EnumWireMaterial.values().length; i++) - { - par3List.add(new ItemStack(par1, 1, i)); - } - } - - @Override - public void breakBlock(World world, int x, int y, int z, int par5, int par6) - { - TileEntity t = world.getBlockTileEntity(x, y, z); - - /** - * Drop wool insulation if the wire is insulated. - */ - if (t instanceof TileEntityWire) - { - TileEntityWire tileEntity = (TileEntityWire) t; - - if (tileEntity.isInsulated) - { - this.dropBlockAsItem_do(world, x, y, z, new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(tileEntity.dyeID))); - } - } - - super.breakBlock(world, x, y, z, par5, par6); - } -} \ No newline at end of file diff --git a/src/resonantinduction/wire/PartConductor.java b/src/resonantinduction/wire/PartConductor.java index b62f0940..a7ca424a 100644 --- a/src/resonantinduction/wire/PartConductor.java +++ b/src/resonantinduction/wire/PartConductor.java @@ -4,6 +4,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; import universalelectricity.api.IConnector; import universalelectricity.api.INetworkProvider; +import universalelectricity.api.UniversalClass; import universalelectricity.api.energy.IConductor; import universalelectricity.api.energy.IEnergyInterface; import universalelectricity.api.vector.Vector3; @@ -12,6 +13,7 @@ import universalelectricity.core.grid.EnergyNetworkLoader; import universalelectricity.core.grid.IEnergyNetwork; import codechicken.multipart.TileMultipart; +@UniversalClass public abstract class PartConductor extends PartAdvanced implements IConductor { private IEnergyNetwork network; diff --git a/src/resonantinduction/wire/PartUniversalConductor.java b/src/resonantinduction/wire/PartUniversalConductor.java deleted file mode 100644 index 1bf6295d..00000000 --- a/src/resonantinduction/wire/PartUniversalConductor.java +++ /dev/null @@ -1,264 +0,0 @@ -package resonantinduction.wire; - -import ic2.api.energy.event.EnergyTileLoadEvent; -import ic2.api.energy.event.EnergyTileUnloadEvent; -import ic2.api.energy.tile.IEnergySink; -import ic2.api.energy.tile.IEnergyTile; - -import java.util.HashSet; -import java.util.Set; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.common.MinecraftForge; -import universalelectricity.api.Compatibility; -import universalelectricity.api.vector.Vector3; -import universalelectricity.api.vector.VectorHelper; -import universalelectricity.core.electricity.ElectricityPack; -import buildcraft.api.power.IPowerReceptor; -import buildcraft.api.power.PowerHandler; -import buildcraft.api.power.PowerHandler.PowerReceiver; -import buildcraft.api.power.PowerHandler.Type; -import cofh.api.energy.IEnergyHandler; - -public abstract class PartUniversalConductor extends PartConductor implements IEnergySink, IPowerReceptor, IEnergyHandler -{ - protected boolean isAddedToEnergyNet; - public PowerHandler powerHandler; - public float buildcraftBuffer = Compatibility.BC3_RATIO * 50; - - public PartUniversalConductor() - { - powerHandler = new PowerHandler(this, Type.PIPE); - powerHandler.configure(0, buildcraftBuffer, buildcraftBuffer, buildcraftBuffer * 2); - powerHandler.configurePowerPerdition(0, 0); - } - - @Override - public boolean isValidAcceptor(TileEntity tile) - { - if(tile instanceof IEnergyTile) - { - return true; - } - else if(tile instanceof IPowerReceptor) - { - return true; - } - else if(tile instanceof IEnergyHandler) - { - return true; - } - - return super.isValidAcceptor(tile); - } - - @Override - public boolean isConnectionPrevented(TileEntity tile, ForgeDirection side) - { - if(tile instanceof IEnergyHandler) - { - return !((IEnergyHandler)tile).canInterface(side); - } - - return super.isConnectionPrevented(tile, side); - } - - @Override - public void onWorldJoin() - { - super.onWorldJoin(); - - if(!world().isRemote) - { - if(!isAddedToEnergyNet) - { - initIC(); - } - } - } - - @Override - public void onAdded() - { - super.onAdded(); - - if(!world().isRemote) - { - if(!isAddedToEnergyNet) - { - initIC(); - } - } - } - - @Override - public void onChunkLoad() - { - super.onChunkLoad(); - - if(!world().isRemote) - { - if(!isAddedToEnergyNet) - { - initIC(); - } - } - } - - @Override - public void onWorldSeparate() - { - unloadTileIC2(); - super.onWorldSeparate(); - } - - @Override - public void onChunkUnload() - { - unloadTileIC2(); - super.onChunkUnload(); - } - - @Override - public void onRemoved() {} - - @Override - public void preRemove() - { - unloadTileIC2(); - super.preRemove(); - } - - protected void initIC() - { - if(Compatibility.isIndustrialCraft2Loaded()) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent((IEnergyTile) tile())); - } - - isAddedToEnergyNet = true; - } - - private void unloadTileIC2() - { - if(isAddedToEnergyNet && world() != null) - { - if(Compatibility.isIndustrialCraft2Loaded()) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile) tile())); - } - - isAddedToEnergyNet = false; - } - } - - @Override - public double demandedEnergyUnits() - { - if(getNetwork() == null) - { - return 0.0; - } - - return getNetwork().getRequest(tile()).getWatts() * Compatibility.TO_IC2_RATIO; - } - - @Override - public double injectEnergyUnits(ForgeDirection directionFrom, double amount) - { - TileEntity tile = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), directionFrom); - ElectricityPack pack = ElectricityPack.getFromWatts((float) (amount * Compatibility.IC2_RATIO), 120); - return getNetwork().produce(pack, tile(), tile) * Compatibility.TO_IC2_RATIO; - } - - @Override - public int getMaxSafeInput() - { - return Integer.MAX_VALUE; - } - - @Override - public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) - { - return true; - } - - /** - * BuildCraft functions - */ - @Override - public PowerReceiver getPowerReceiver(ForgeDirection side) - { - return powerHandler.getPowerReceiver(); - } - - @Override - public void doWork(PowerHandler workProvider) - { - Set ignoreTiles = new HashSet(); - ignoreTiles.add(tile()); - - for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity tile = new Vector3(tile()).modifyPositionFromSide(direction).getTileEntity(world()); - ignoreTiles.add(tile); - } - - ElectricityPack pack = ElectricityPack.getFromWatts(workProvider.useEnergy(0, getNetwork().getRequest(tile()).getWatts() * Compatibility.TO_BC_RATIO, true) * Compatibility.BC3_RATIO, 120); - getNetwork().produce(pack, ignoreTiles.toArray(new TileEntity[0])); - } - - @Override - public World getWorld() - { - return world(); - } - - /** - * Thermal Expansion Functions - */ - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) - { - ElectricityPack pack = ElectricityPack.getFromWatts(maxReceive * Compatibility.TE_RATIO, 1); - float request = getMaxEnergyStored(from); - - if(!simulate) - { - if(request > 0) - { - return (int) (maxReceive - (getNetwork().produce(pack, new Vector3(tile()).modifyPositionFromSide(from).getTileEntity(world())) * Compatibility.TO_TE_RATIO)); - } - - return 0; - } - - return (int)Math.min(maxReceive, request * Compatibility.TO_TE_RATIO); - } - - @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) - { - return 0; - } - - @Override - public boolean canInterface(ForgeDirection from) - { - return true; - } - - @Override - public int getEnergyStored(ForgeDirection from) - { - return 0; - } - - @Override - public int getMaxEnergyStored(ForgeDirection from) - { - return (int)Math.round(getNetwork().getRequest(new Vector3(tile()).modifyPositionFromSide(from).getTileEntity(world())).getWatts() * Compatibility.TO_TE_RATIO); - } -} diff --git a/src/resonantinduction/wire/PartWire.java b/src/resonantinduction/wire/PartWire.java index 825965dc..59ee3a18 100644 --- a/src/resonantinduction/wire/PartWire.java +++ b/src/resonantinduction/wire/PartWire.java @@ -43,7 +43,7 @@ import codechicken.multipart.TSlottedPart; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class PartWire extends PartUniversalConductor implements TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects, IInsulatedMaterial, IBlockableConnection +public class PartWire extends PartConductor implements TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects, IInsulatedMaterial, IBlockableConnection { public static final int DEFAULT_COLOR = 16; public int dyeID = DEFAULT_COLOR; @@ -149,18 +149,6 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN return super.getPossibleAcceptorConnections(); } - @Override - public float getResistance() - { - return getMaterial().resistance; - } - - @Override - public float getCurrentCapacity() - { - return getMaterial().maxAmps; - } - @Override public EnumWireMaterial getMaterial() { @@ -185,15 +173,6 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN material = EnumWireMaterial.values()[id]; } - @Override - public void doWork(PowerHandler workProvider) - { - buildcraftBuffer = Compatibility.BC3_RATIO * 25 * Math.min(getMaterial().maxAmps, 100); - powerHandler.configure(0, buildcraftBuffer, buildcraftBuffer, buildcraftBuffer * 2); - - super.doWork(workProvider); - } - @Override public String getType() { diff --git a/src/resonantinduction/wire/TileEntityWire.java b/src/resonantinduction/wire/TileEntityWire.java deleted file mode 100644 index b9243f2b..00000000 --- a/src/resonantinduction/wire/TileEntityWire.java +++ /dev/null @@ -1,212 +0,0 @@ -package resonantinduction.wire; - -import java.util.ArrayList; - -import resonantinduction.ResonantInduction; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.packet.Packet; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; -import universalelectricity.api.Compatibility; -import universalelectricity.api.vector.Vector3; -import universalelectricity.api.vector.VectorHelper; -import universalelectricity.compatibility.TileEntityUniversalConductor; -import universalelectricity.core.block.INetworkProvider; -import buildcraft.api.power.PowerHandler; -import calclavia.lib.network.IPacketReceiver; -import calclavia.lib.network.IPacketSender; -import calclavia.lib.network.PacketHandler; - -import com.google.common.io.ByteArrayDataInput; - -public class TileEntityWire extends TileEntityUniversalConductor implements IPacketSender, IPacketReceiver, IInsulatedMaterial -{ - public static final int DEFAULT_COLOR = 16; - public int dyeID = DEFAULT_COLOR; - public boolean isInsulated = false; - - @Override - public boolean canConnect(ForgeDirection direction) - { - if (this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)) - { - return false; - } - - Vector3 connectPos = new Vector3(this).modifyPositionFromSide(direction); - TileEntity connectTile = connectPos.getTileEntity(this.worldObj); - if (connectTile instanceof IWireMaterial) - { - IWireMaterial wireTile = (IWireMaterial) connectTile; - - if (wireTile.getMaterial() != this.getMaterial()) - { - return false; - } - } - - if (this.isInsulated() && connectTile instanceof IInsulation) - { - IInsulation insulatedTile = (IInsulation) connectTile; - - if ((insulatedTile.isInsulated() && insulatedTile.getInsulationColor() != this.getInsulationColor() && this.getInsulationColor() != DEFAULT_COLOR && insulatedTile.getInsulationColor() != DEFAULT_COLOR)) - { - return false; - } - } - - return true; - } - - @Override - public void refresh() - { - if (!this.worldObj.isRemote) - { - this.adjacentConnections = null; - - for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - if (this.canConnect(side.getOpposite())) - { - TileEntity tileEntity = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), side); - - if (tileEntity != null) - { - if (/* tileEntity.getClass().isInstance(this) && */tileEntity instanceof INetworkProvider) - { - this.getNetwork().merge(((INetworkProvider) tileEntity).getNetwork()); - } - } - } - } - - this.getNetwork().refresh(); - } - } - - @Override - public float getResistance() - { - return getMaterial().resistance; - } - - @Override - public float getCurrentCapacity() - { - return getMaterial().maxAmps; - } - - @Override - public EnumWireMaterial getMaterial() - { - return EnumWireMaterial.values()[this.getTypeID()]; - } - - public int getTypeID() - { - return this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord); - } - - /** - * @param dyeID - */ - public void setDye(int dyeID) - { - this.dyeID = dyeID; - this.refresh(); - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - } - - public void setInsulated() - { - this.isInsulated = true; - this.refresh(); - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - } - - @Override - public ArrayList getPacketData(int type) - { - ArrayList data = new ArrayList(); - return data; - } - - @Override - public Packet getDescriptionPacket() - { - return ResonantInduction.PACKET_TILE.getPacket(this, this.getPacketData(1)); - } - - @Override - public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player) - { - try - { - this.isInsulated = data.readBoolean(); - this.dyeID = data.readInt(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - /** - * Reads a tile entity from NBT. - */ - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - this.dyeID = nbt.getInteger("dyeID"); - this.isInsulated = nbt.getBoolean("isInsulated"); - } - - /** - * Writes a tile entity to NBT. - */ - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - nbt.setInteger("dyeID", this.dyeID); - nbt.setBoolean("isInsulated", this.isInsulated); - } - - @Override - public void doWork(PowerHandler workProvider) - { - this.buildcraftBuffer = Compatibility.BC3_RATIO * 25 * this.getMaterial().maxAmps; - this.powerHandler.configure(0, this.buildcraftBuffer, this.buildcraftBuffer, this.buildcraftBuffer * 2); - super.doWork(workProvider); - } - - @Override - public boolean isInsulated() - { - return isInsulated; - } - - @Override - public void setInsulated(boolean insulated) - { - if (insulated && !isInsulated()) - setInsulated(); - - } - - @Override - public int getInsulationColor() - { - return dyeID; - } - - @Override - public void setInsulationColor(int dyeID) - { - setDye(dyeID); - } - -}