Reworked vanilla electric furnace
This commit is contained in:
parent
aa8a2b9726
commit
bbe89086a1
7 changed files with 70 additions and 68 deletions
|
@ -13,9 +13,10 @@ public class MultipartRI implements IPartFactory
|
||||||
public MultipartRI()
|
public MultipartRI()
|
||||||
{
|
{
|
||||||
MultiPartRegistry.registerParts(this, new String[] { "resonant_induction_flat_wire" });
|
MultiPartRegistry.registerParts(this, new String[] { "resonant_induction_flat_wire" });
|
||||||
MultipartGenerator.registerTrait("ic2.api.energy.tile.IEnergySink", "resonantinduction.wire.part.TraitEnergySink");
|
|
||||||
MultipartGenerator.registerTrait("universalelectricity.api.energy.IConductor", "resonantinduction.wire.part.TraitConductor");
|
MultipartGenerator.registerTrait("universalelectricity.api.energy.IConductor", "resonantinduction.wire.part.TraitConductor");
|
||||||
|
// MultipartGenerator.registerTrait("resonantinduction.wire.part.ITest",
|
||||||
|
// "resonantinduction.wire.part.TraitTest");
|
||||||
|
MultipartGenerator.registerTrait("ic2.api.energy.tile.IEnergySink", "resonantinduction.wire.part.TraitEnergySink");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class ResonantInduction
|
||||||
* Settings
|
* Settings
|
||||||
*/
|
*/
|
||||||
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), NAME + ".cfg"));
|
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), NAME + ".cfg"));
|
||||||
public static int FURNACE_WATTAGE = 50000;
|
public static int FURNACE_WATTAGE = 25000;
|
||||||
public static boolean SOUND_FXS = true;
|
public static boolean SOUND_FXS = true;
|
||||||
public static boolean LO_FI_INSULATION = false;
|
public static boolean LO_FI_INSULATION = false;
|
||||||
public static boolean SHINY_SILVER = true;
|
public static boolean SHINY_SILVER = true;
|
||||||
|
|
|
@ -7,9 +7,6 @@ import net.minecraft.tileentity.TileEntityFurnace;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import resonantinduction.ResonantInduction;
|
import resonantinduction.ResonantInduction;
|
||||||
import universalelectricity.api.CompatibilityModule;
|
import universalelectricity.api.CompatibilityModule;
|
||||||
import universalelectricity.api.UniversalClass;
|
|
||||||
import universalelectricity.api.electricity.IVoltage;
|
|
||||||
import universalelectricity.api.energy.IConductor;
|
|
||||||
import universalelectricity.api.energy.IEnergyInterface;
|
import universalelectricity.api.energy.IEnergyInterface;
|
||||||
import universalelectricity.api.vector.Vector3;
|
import universalelectricity.api.vector.Vector3;
|
||||||
import calclavia.lib.tile.EnergyStorage;
|
import calclavia.lib.tile.EnergyStorage;
|
||||||
|
@ -20,7 +17,7 @@ import calclavia.lib.tile.EnergyStorage;
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IEnergyInterface, IVoltage
|
public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IEnergyInterface
|
||||||
{
|
{
|
||||||
private static final float WATTAGE = 5;
|
private static final float WATTAGE = 5;
|
||||||
|
|
||||||
|
@ -29,50 +26,10 @@ public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IEne
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
{
|
{
|
||||||
boolean canSmelt = canSmelt() && this.getStackInSlot(1) == null && this.furnaceBurnTime == 0;
|
/**
|
||||||
boolean canBurn = this.getStackInSlot(0) == null && TileEntityFurnace.getItemBurnTime(this.getStackInSlot(1)) > 0;
|
* If we have fuel and can smelt properly, do the vanilla process.
|
||||||
|
*/
|
||||||
if (canSmelt)
|
if (this.canSmelt() && TileEntityFurnace.getItemBurnTime(this.getStackInSlot(1)) > 0)
|
||||||
{
|
|
||||||
if (this.energy.checkExtract(ResonantInduction.FURNACE_WATTAGE / 20))
|
|
||||||
{
|
|
||||||
this.furnaceCookTime++;
|
|
||||||
|
|
||||||
if (this.furnaceCookTime == 200)
|
|
||||||
{
|
|
||||||
this.furnaceCookTime = 0;
|
|
||||||
this.smeltItem();
|
|
||||||
this.onInventoryChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.energy.extractEnergy(ResonantInduction.FURNACE_WATTAGE / 20, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!this.energy.isFull())
|
|
||||||
{
|
|
||||||
boolean doBlockStateUpdate = this.furnaceBurnTime > 0;
|
|
||||||
|
|
||||||
if (this.furnaceBurnTime == 0)
|
|
||||||
{
|
|
||||||
int burnTime = TileEntityFurnace.getItemBurnTime(this.getStackInSlot(1));
|
|
||||||
this.decrStackSize(1, 1);
|
|
||||||
this.furnaceBurnTime = burnTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.furnaceBurnTime > 0)
|
|
||||||
{
|
|
||||||
this.energy.receiveEnergy(ResonantInduction.FURNACE_WATTAGE / 20, true);
|
|
||||||
|
|
||||||
this.produce();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doBlockStateUpdate != this.furnaceBurnTime > 0)
|
|
||||||
{
|
|
||||||
// TODO: Send descript packet.
|
|
||||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
boolean flag = this.furnaceBurnTime > 0;
|
boolean flag = this.furnaceBurnTime > 0;
|
||||||
boolean flag1 = false;
|
boolean flag1 = false;
|
||||||
|
@ -132,6 +89,47 @@ public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IEne
|
||||||
this.onInventoryChanged();
|
this.onInventoryChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (this.getStackInSlot(1) == null && canSmelt() && this.furnaceBurnTime == 0)
|
||||||
|
{
|
||||||
|
if (this.energy.checkExtract(ResonantInduction.FURNACE_WATTAGE / 20))
|
||||||
|
{
|
||||||
|
this.furnaceCookTime++;
|
||||||
|
|
||||||
|
if (this.furnaceCookTime == 200)
|
||||||
|
{
|
||||||
|
this.furnaceCookTime = 0;
|
||||||
|
this.smeltItem();
|
||||||
|
this.onInventoryChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.energy.extractEnergy(ResonantInduction.FURNACE_WATTAGE / 20, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this.getStackInSlot(0) == null)
|
||||||
|
{
|
||||||
|
boolean doBlockStateUpdate = this.furnaceBurnTime > 0;
|
||||||
|
|
||||||
|
if (!this.energy.isFull() && this.furnaceBurnTime == 0)
|
||||||
|
{
|
||||||
|
int burnTime = TileEntityFurnace.getItemBurnTime(this.getStackInSlot(1));
|
||||||
|
this.decrStackSize(1, 1);
|
||||||
|
this.furnaceBurnTime = burnTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.furnaceBurnTime > 0)
|
||||||
|
{
|
||||||
|
this.energy.receiveEnergy(ResonantInduction.FURNACE_WATTAGE / 20, true);
|
||||||
|
this.furnaceBurnTime--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doBlockStateUpdate != this.furnaceBurnTime > 0)
|
||||||
|
{
|
||||||
|
// TODO: Send descript packet.
|
||||||
|
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.produce();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void produce()
|
private void produce()
|
||||||
|
@ -141,7 +139,12 @@ public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IEne
|
||||||
if (this.energy.getEnergy() > 0)
|
if (this.energy.getEnergy() > 0)
|
||||||
{
|
{
|
||||||
TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(direction).getTileEntity(this.worldObj);
|
TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(direction).getTileEntity(this.worldObj);
|
||||||
this.energy.extractEnergy(CompatibilityModule.receiveEnergy(tileEntity, direction.getOpposite(), this.energy.extractEnergy(this.energy.getEnergy(), false), true), true);
|
|
||||||
|
if (tileEntity != null)
|
||||||
|
{
|
||||||
|
long used = CompatibilityModule.receiveEnergy(tileEntity, direction.getOpposite(), this.energy.extractEnergy(this.energy.getEnergy(), false), true);
|
||||||
|
this.energy.extractEnergy(used, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,11 +191,4 @@ public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IEne
|
||||||
{
|
{
|
||||||
return this.energy.extractEnergy(request, doProvide);
|
return this.energy.extractEnergy(request, doProvide);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getVoltage(ForgeDirection direction)
|
|
||||||
{
|
|
||||||
return 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ import java.util.HashMap;
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.event.ForgeSubscribe;
|
import net.minecraftforge.event.ForgeSubscribe;
|
||||||
import universalelectricity.api.electricity.ElectricalEvent.EnergyUpdateEvent;
|
|
||||||
import universalelectricity.api.energy.IEnergyNetwork;
|
import universalelectricity.api.energy.IEnergyNetwork;
|
||||||
|
import universalelectricity.api.net.NetworkEvent.EnergyUpdateEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
|
|
|
@ -23,7 +23,6 @@ import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import resonantinduction.ResonantInduction;
|
import resonantinduction.ResonantInduction;
|
||||||
import resonantinduction.api.ITesla;
|
import resonantinduction.api.ITesla;
|
||||||
import universalelectricity.api.electricity.ElectricityPack;
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
import universalelectricity.api.vector.Vector3;
|
||||||
import calclavia.lib.network.IPacketReceiver;
|
import calclavia.lib.network.IPacketReceiver;
|
||||||
import calclavia.lib.network.IPacketSender;
|
import calclavia.lib.network.IPacketSender;
|
||||||
|
|
|
@ -24,7 +24,7 @@ public abstract class PartConductor extends PartAdvanced implements IAdvancedCon
|
||||||
@Override
|
@Override
|
||||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
||||||
{
|
{
|
||||||
return this.getNetwork().produce(receive);
|
return this.getNetwork().produce(this, receive, doReceive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -88,15 +88,21 @@ public class TraitConductor extends TileMultipart implements IConductor
|
||||||
@Override
|
@Override
|
||||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
||||||
{
|
{
|
||||||
TMultiPart part = this.partMap(from.ordinal());
|
System.out.println("RECEIVING"+receive);
|
||||||
|
|
||||||
if (this.interfaces.contains(part) && part instanceof IConductor)
|
/*TMultiPart part = partMap(from.ordinal());
|
||||||
|
|
||||||
|
if (part != null)
|
||||||
{
|
{
|
||||||
//((IConductor) part).onReceiveEnergy(from, receive, doReceive);
|
for (IConductor conductor : this.interfaces)
|
||||||
|
{
|
||||||
System.out.println("RECEIVING");
|
if (conductor == part)
|
||||||
|
{
|
||||||
|
conductor.onReceiveEnergy(from, receive, doReceive);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue