Removed ticking wires
This commit is contained in:
parent
56a3f7a74a
commit
671373f13a
4 changed files with 1 additions and 219 deletions
|
@ -3,7 +3,6 @@ package resonantinduction;
|
|||
import ic2.api.item.Items;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -15,7 +14,6 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
|
@ -40,9 +38,7 @@ import resonantinduction.tesla.TileEntityTesla;
|
|||
import resonantinduction.wire.BlockWire;
|
||||
import resonantinduction.wire.EnumWireMaterial;
|
||||
import resonantinduction.wire.ItemBlockWire;
|
||||
import resonantinduction.wire.TileEntityTickWire;
|
||||
import resonantinduction.wire.TileEntityWire;
|
||||
import scala.collection.generic.BitOperations.Int;
|
||||
import universalelectricity.compatibility.Compatibility;
|
||||
import universalelectricity.core.item.IItemElectric;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
@ -63,7 +59,6 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
|||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
|
@ -248,7 +243,6 @@ public class ResonantInduction
|
|||
if (blockWire != null)
|
||||
{
|
||||
GameRegistry.registerTileEntity(TileEntityWire.class, blockWire.getUnlocalizedName());
|
||||
GameRegistry.registerTileEntity(TileEntityTickWire.class, blockWire.getUnlocalizedName() + "2");
|
||||
}
|
||||
|
||||
ResonantInduction.proxy.registerRenderers();
|
||||
|
|
|
@ -60,37 +60,6 @@ public class BlockWire extends BlockConductor
|
|||
}
|
||||
}
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (entityPlayer.isSneaking())
|
||||
{
|
||||
/**
|
||||
* Change the TileEntity type.
|
||||
*/
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
tileEntity.writeToNBT(nbt);
|
||||
|
||||
if (tileEntity instanceof TileEntityTickWire)
|
||||
{
|
||||
nbt.setString("id", this.getUnlocalizedName());
|
||||
entityPlayer.addChatMessage("Wire will now stop ticking and withdrawing energy.");
|
||||
}
|
||||
else
|
||||
{
|
||||
nbt.setString("id", this.getUnlocalizedName() + "2");
|
||||
entityPlayer.addChatMessage("Wire will now tick and withdraw energy.");
|
||||
}
|
||||
|
||||
world.setBlockTileEntity(x, y, z, TileEntity.createAndLoadEntity(nbt));
|
||||
((IConductor) world.getBlockTileEntity(x, y, z)).refresh();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
entityPlayer.addChatMessage(tileEntity.getNetwork().toString());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,152 +0,0 @@
|
|||
package resonantinduction.wire;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.block.BlockFurnace;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.ResonantInduction;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
/**
|
||||
* A version of the wire that has furnace interaction.
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
public class TileEntityTickWire extends TileEntityWire
|
||||
{
|
||||
private final HashMap<ForgeDirection, TileEntityFurnace> furnaces = new HashMap<ForgeDirection, TileEntityFurnace>();
|
||||
private float energyBuffer;
|
||||
private static final float FURNACE_VOLTAGE = 120;
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
if (this.getNetwork().getRequest().getWatts() > 0)
|
||||
{
|
||||
Iterator<Entry<ForgeDirection, TileEntityFurnace>> it = this.furnaces.entrySet().iterator();
|
||||
|
||||
while (it.hasNext())
|
||||
{
|
||||
Entry<ForgeDirection, TileEntityFurnace> entry = it.next();
|
||||
ForgeDirection direction = entry.getKey();
|
||||
TileEntityFurnace tileEntity = entry.getValue();
|
||||
|
||||
if (!tileEntity.isInvalid() && tileEntity.getStackInSlot(0) == null)
|
||||
{
|
||||
/**
|
||||
* Steal power from furnace.
|
||||
*/
|
||||
boolean doBlockStateUpdate = tileEntity.furnaceBurnTime > 0;
|
||||
|
||||
if (tileEntity.furnaceBurnTime == 0)
|
||||
{
|
||||
int burnTime = TileEntityFurnace.getItemBurnTime(tileEntity.getStackInSlot(1));
|
||||
tileEntity.decrStackSize(1, 1);
|
||||
tileEntity.furnaceBurnTime = burnTime;
|
||||
}
|
||||
|
||||
if (tileEntity.furnaceBurnTime > 0)
|
||||
{
|
||||
this.getNetwork().produce(ElectricityPack.getFromWatts(ResonantInduction.FURNACE_WATTAGE / 20, FURNACE_VOLTAGE));
|
||||
}
|
||||
|
||||
if (doBlockStateUpdate != tileEntity.furnaceBurnTime > 0)
|
||||
{
|
||||
BlockFurnace.updateFurnaceBlockState(tileEntity.furnaceBurnTime > 0, tileEntity.worldObj, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
public float receiveElectricity(ForgeDirection from, ElectricityPack receive, boolean doReceive)
|
||||
{
|
||||
this.energyBuffer += receive.getWatts();
|
||||
|
||||
/**
|
||||
* Inject power to furnace.
|
||||
*/
|
||||
for (int i = 0; i < this.furnaces.size(); i++)
|
||||
{
|
||||
ForgeDirection direction = ForgeDirection.getOrientation(i);
|
||||
TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(direction).getTileEntity(this.worldObj);
|
||||
|
||||
if (tileEntity instanceof TileEntityFurnace)
|
||||
{
|
||||
TileEntityFurnace furnaceTile = (TileEntityFurnace) tileEntity;
|
||||
|
||||
boolean doBlockStateUpdate = furnaceTile.furnaceBurnTime > 0;
|
||||
|
||||
furnaceTile.furnaceBurnTime += 2;
|
||||
|
||||
if (doBlockStateUpdate != furnaceTile.furnaceBurnTime > 0)
|
||||
{
|
||||
BlockFurnace.updateFurnaceBlockState(furnaceTile.furnaceBurnTime > 0, furnaceTile.worldObj, furnaceTile.xCoord, furnaceTile.yCoord, furnaceTile.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return receive.getWatts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh()
|
||||
{
|
||||
super.refresh();
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
this.furnaces.clear();
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection direction = ForgeDirection.getOrientation(i);
|
||||
TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(direction).getTileEntity(this.worldObj);
|
||||
|
||||
if (tileEntity instanceof TileEntityFurnace)
|
||||
{
|
||||
this.furnaces.put(direction, (TileEntityFurnace) tileEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// @Override
|
||||
public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide)
|
||||
{
|
||||
return new ElectricityPack();
|
||||
}
|
||||
|
||||
// @Override
|
||||
public float getRequest(ForgeDirection direction)
|
||||
{
|
||||
return this.furnaces.size() > 0 ? ResonantInduction.FURNACE_WATTAGE / 20 : 0;
|
||||
}
|
||||
|
||||
// @Override
|
||||
public float getProvide(ForgeDirection direction)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// @Override
|
||||
public float getVoltage()
|
||||
{
|
||||
return FURNACE_VOLTAGE;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,6 @@ import java.util.ArrayList;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.PacketHandler;
|
||||
import resonantinduction.base.IPacketReceiver;
|
||||
|
@ -24,9 +23,6 @@ public class TileEntityWire extends TileEntityUniversalConductor implements IPac
|
|||
public int dyeID = DEFAULT_COLOR;
|
||||
public boolean isInsulated = false;
|
||||
|
||||
/** Client Side Connection Check */
|
||||
public boolean isTick = false;
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
|
@ -130,7 +126,7 @@ public class TileEntityWire extends TileEntityUniversalConductor implements IPac
|
|||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return PacketHandler.getTileEntityPacket(this, this.isInsulated, this.dyeID, this instanceof TileEntityTickWire);
|
||||
return PacketHandler.getTileEntityPacket(this, this.isInsulated, this.dyeID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -140,7 +136,6 @@ public class TileEntityWire extends TileEntityUniversalConductor implements IPac
|
|||
{
|
||||
this.isInsulated = input.readBoolean();
|
||||
this.dyeID = input.readInt();
|
||||
this.isTick = input.readBoolean();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -159,30 +154,6 @@ public class TileEntityWire extends TileEntityUniversalConductor implements IPac
|
|||
this.isInsulated = nbt.getBoolean("isInsulated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Furnace connection for tick wires
|
||||
*/
|
||||
@Override
|
||||
public TileEntity[] getAdjacentConnections()
|
||||
{
|
||||
super.getAdjacentConnections();
|
||||
|
||||
if (this.isTick)
|
||||
{
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation(i);
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), side);
|
||||
|
||||
if (tileEntity instanceof TileEntityFurnace)
|
||||
{
|
||||
this.adjacentConnections[i] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.adjacentConnections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue