mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Better machine hierarchy to avoid repetition
This commit is contained in:
1 parent
b3621cd511
commit
2c161ed4ce
28 files changed
+279
-1184
No files matched your search
@@ -71,7 +71,7 @@ public class GuiChemicalCrystallizer extends GuiMekanism
|
||||
@Override
|
||||
public List<String> getInfo()
|
||||
{
|
||||
String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyUsage);
|
||||
String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick);
|
||||
return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy()));
|
||||
}
|
||||
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png")));
|
||||
|
||||
@@ -46,7 +46,7 @@ public class GuiChemicalDissolutionChamber extends GuiMekanism
|
||||
@Override
|
||||
public List<String> getInfo()
|
||||
{
|
||||
String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyUsage);
|
||||
String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick);
|
||||
return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy()));
|
||||
}
|
||||
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png")));
|
||||
|
||||
@@ -46,7 +46,7 @@ public class GuiChemicalOxidizer extends GuiMekanism
|
||||
@Override
|
||||
public List<String> getInfo()
|
||||
{
|
||||
String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyUsage);
|
||||
String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick);
|
||||
return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy()));
|
||||
}
|
||||
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png")));
|
||||
|
||||
@@ -23,10 +23,8 @@ import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.AdvancedMachineInput;
|
||||
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import mekanism.common.tile.component.TileComponentAdvancedUpgrade;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -68,7 +66,7 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
||||
*/
|
||||
public TileEntityAdvancedElectricMachine(String soundPath, String name, double perTick, int secondaryPerTick, int ticksRequired, double maxEnergy)
|
||||
{
|
||||
super(soundPath, name, MekanismUtils.getResource(ResourceType.GUI, "GuiAdvancedMachine.png"), perTick, ticksRequired, maxEnergy);
|
||||
super(soundPath, name, ticksRequired, maxEnergy, perTick, 4, MekanismUtils.getResource(ResourceType.GUI, "GuiAdvancedMachine.png"));
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
@@ -87,9 +85,11 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
||||
|
||||
BASE_SECONDARY_ENERGY_PER_TICK = secondaryPerTick;
|
||||
secondaryEnergyPerTick = secondaryPerTick;
|
||||
|
||||
upgradeComponent = upgradeableSecondaryEfficiency() ? new TileComponentAdvancedUpgrade(this, 4) : new TileComponentUpgrade(this, 4);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
|
||||
if(upgradeableSecondaryEfficiency())
|
||||
{
|
||||
upgradeComponent.setSupported(Upgrade.GAS);
|
||||
}
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2));
|
||||
|
||||
@@ -32,9 +32,6 @@ public class TileEntityAdvancedFactory extends TileEntityFactory
|
||||
configComponent.setCanEject(TransmissionType.GAS, false);
|
||||
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2));
|
||||
|
||||
@@ -5,28 +5,18 @@ import io.netty.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.IConfigCardAccess;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IElectricMachine;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.integration.IComputerIntegration;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.inputs.MachineInput;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.outputs.MachineOutput;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -34,14 +24,8 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>, OUTPUT extends MachineOutput<OUTPUT>, RECIPE extends MachineRecipe<INPUT, OUTPUT, RECIPE>> extends TileEntityNoisyElectricBlock implements IElectricMachine<INPUT, OUTPUT, RECIPE>, IComputerIntegration, ISideConfiguration, IUpgradeTile, IRedstoneControl, IConfigCardAccess, ISecurityTile
|
||||
public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>, OUTPUT extends MachineOutput<OUTPUT>, RECIPE extends MachineRecipe<INPUT, OUTPUT, RECIPE>> extends TileEntityMachine implements IElectricMachine<INPUT, OUTPUT, RECIPE>, IComputerIntegration, ISideConfiguration, IConfigCardAccess
|
||||
{
|
||||
/** How much energy this machine uses per tick, un-upgraded. */
|
||||
public double BASE_ENERGY_PER_TICK;
|
||||
|
||||
/** How much energy this machine uses per tick including upgrades */
|
||||
public double energyPerTick;
|
||||
|
||||
/** How many ticks this machine has operated for. */
|
||||
public int operatingTicks = 0;
|
||||
|
||||
@@ -50,31 +34,13 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
|
||||
|
||||
/** Ticks required including upgrades */
|
||||
public int ticksRequired;
|
||||
|
||||
/** How many ticks must pass until this block's active state can sync with the client. */
|
||||
public int updateDelay;
|
||||
|
||||
/** Whether or not this block is in it's active state. */
|
||||
public boolean isActive;
|
||||
|
||||
/** The client's current active state. */
|
||||
public boolean clientActive;
|
||||
|
||||
/** The GUI texture path for this machine. */
|
||||
|
||||
public ResourceLocation guiLocation;
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
/** This machine's previous amount of energy. */
|
||||
public double prevEnergy;
|
||||
|
||||
public RECIPE cachedRecipe = null;
|
||||
|
||||
public TileComponentUpgrade upgradeComponent;
|
||||
public TileComponentEjector ejectorComponent;
|
||||
public TileComponentConfig configComponent;
|
||||
public TileComponentSecurity securityComponent;
|
||||
|
||||
/**
|
||||
* The foundation of all machines - a simple tile entity with a facing, active state, initialized state, sound effect, and animated texture.
|
||||
@@ -85,48 +51,13 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
|
||||
* @param baseTicksRequired - how many ticks it takes to run a cycle
|
||||
* @param maxEnergy - how much energy this machine can store
|
||||
*/
|
||||
public TileEntityBasicMachine(String soundPath, String name, ResourceLocation location, double perTick, int baseTicksRequired, double maxEnergy)
|
||||
public TileEntityBasicMachine(String soundPath, String name, int baseTicksRequired, double maxEnergy, double baseEnergyUsage, int upgradeSlot, ResourceLocation location)
|
||||
{
|
||||
super("machine." + soundPath, name, maxEnergy);
|
||||
super("machine." + soundPath, name, maxEnergy, baseEnergyUsage, upgradeSlot);
|
||||
|
||||
BASE_ENERGY_PER_TICK = perTick;
|
||||
energyPerTick = perTick;
|
||||
BASE_TICKS_REQUIRED = baseTicksRequired;
|
||||
ticksRequired = baseTicksRequired;
|
||||
guiLocation = location;
|
||||
isActive = false;
|
||||
|
||||
securityComponent = new TileComponentSecurity(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
if(world.isRemote && updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
if(updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList<Object>())), new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,8 +72,6 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
operatingTicks = nbtTags.getInteger("operatingTicks");
|
||||
clientActive = isActive = nbtTags.getBoolean("isActive");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,8 +80,6 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setInteger("operatingTicks", operatingTicks);
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
|
||||
return nbtTags;
|
||||
}
|
||||
@@ -165,16 +92,7 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
operatingTicks = dataStream.readInt();
|
||||
clientActive = dataStream.readBoolean();
|
||||
ticksRequired = dataStream.readInt();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
updateDelay = general.UPDATE_DELAY;
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,9 +102,7 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(operatingTicks);
|
||||
data.add(isActive);
|
||||
data.add(ticksRequired);
|
||||
data.add(controlType.ordinal());
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -198,27 +114,7 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
|
||||
{
|
||||
return ((double)operatingTicks) / ((double)ticksRequired);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive()
|
||||
{
|
||||
return isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
isActive = active;
|
||||
|
||||
if(clientActive != active && updateDelay == 0)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList<Object>())), new Range4D(Coord4D.get(this)));
|
||||
|
||||
updateDelay = 10;
|
||||
clientActive = active;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void recalculateUpgradables(Upgrade upgrade)
|
||||
{
|
||||
@@ -228,12 +124,7 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
|
||||
{
|
||||
case SPEED:
|
||||
ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED);
|
||||
energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK);
|
||||
break;
|
||||
case ENERGY:
|
||||
energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK);
|
||||
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);
|
||||
setEnergy(Math.min(getMaxEnergy(), getEnergy()));
|
||||
energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -263,56 +154,13 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
|
||||
{
|
||||
return facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lightUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
return controlType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlType(RedstoneControl type)
|
||||
{
|
||||
controlType = type;
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPulse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentUpgrade getComponent()
|
||||
{
|
||||
return upgradeComponent;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileComponentEjector getEjector()
|
||||
{
|
||||
return ejectorComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentSecurity getSecurity()
|
||||
{
|
||||
return securityComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing side)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,6 @@ import mekanism.common.recipe.machines.ChanceMachineRecipe;
|
||||
import mekanism.common.recipe.outputs.ChanceOutput;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -24,9 +23,9 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe<RECIPE>> extends TileEntityBasicMachine<ItemStackInput, ChanceOutput, RECIPE>
|
||||
{
|
||||
public TileEntityChanceMachine(String soundPath, String name, ResourceLocation location, double perTick, int ticksRequired, double maxEnergy)
|
||||
public TileEntityChanceMachine(String soundPath, String name, int ticksRequired, double maxEnergy, double baseEnergyUsage, ResourceLocation location)
|
||||
{
|
||||
super(soundPath, name, location, perTick, ticksRequired, maxEnergy);
|
||||
super(soundPath, name, ticksRequired, maxEnergy, baseEnergyUsage, 3, location);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
@@ -39,9 +38,6 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(3));
|
||||
|
||||
@@ -38,7 +38,7 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
|
||||
public class TileEntityChargepad extends TileEntityNoisyElectricBlock
|
||||
public class TileEntityChargepad extends TileEntityNoisyBlock
|
||||
{
|
||||
public boolean isActive;
|
||||
public boolean clientActive;
|
||||
|
||||
@@ -4,10 +4,8 @@ import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.IConfigCardAccess;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
@@ -16,27 +14,20 @@ import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.base.ITankManager;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.block.states.BlockStateMachine;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.config.MekanismConfig.usage;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.GasInput;
|
||||
import mekanism.common.recipe.machines.CrystallizerRecipe;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.GasUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
@@ -49,43 +40,26 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, ISideConfiguration, IUpgradeTile, ISustainedData, ITankManager, IConfigCardAccess, ISecurityTile
|
||||
public class TileEntityChemicalCrystallizer extends TileEntityMachine implements IGasHandler, ITubeConnection, ISideConfiguration, ISustainedData, ITankManager, IConfigCardAccess
|
||||
{
|
||||
public static final int MAX_GAS = 10000;
|
||||
|
||||
public GasTank inputTank = new GasTank(MAX_GAS);
|
||||
|
||||
public int updateDelay;
|
||||
|
||||
public int operatingTicks;
|
||||
|
||||
public int BASE_TICKS_REQUIRED = 200;
|
||||
|
||||
public int ticksRequired = 200;
|
||||
|
||||
public boolean isActive;
|
||||
|
||||
public boolean clientActive;
|
||||
|
||||
public double prevEnergy;
|
||||
|
||||
public final double BASE_ENERGY_USAGE = usage.chemicalCrystallizerUsage;
|
||||
|
||||
public double energyUsage = usage.chemicalCrystallizerUsage;
|
||||
|
||||
public CrystallizerRecipe cachedRecipe;
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileComponentUpgrade upgradeComponent;
|
||||
public TileComponentEjector ejectorComponent;
|
||||
public TileComponentConfig configComponent;
|
||||
public TileComponentSecurity securityComponent;
|
||||
|
||||
public TileEntityChemicalCrystallizer()
|
||||
{
|
||||
super("machine.crystallizer", "ChemicalCrystallizer", BlockStateMachine.MachineType.CHEMICAL_CRYSTALLIZER.baseEnergy);
|
||||
super("machine.crystallizer", "ChemicalCrystallizer", BlockStateMachine.MachineType.CHEMICAL_CRYSTALLIZER.baseEnergy, usage.chemicalCrystallizerUsage, 3);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.GAS);
|
||||
|
||||
@@ -103,9 +77,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2));
|
||||
@@ -118,29 +89,8 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
if(world.isRemote && updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
if(updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList<Object>())), new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
}
|
||||
|
||||
ChargeUtils.discharge(2, this);
|
||||
|
||||
if(!inventory.get(0).isEmpty() && (inputTank.getGas() == null || inputTank.getStored() < inputTank.getMaxGas()))
|
||||
@@ -150,11 +100,11 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
|
||||
CrystallizerRecipe recipe = getRecipe();
|
||||
|
||||
if(canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyUsage)
|
||||
if(canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick)
|
||||
{
|
||||
setActive(true);
|
||||
|
||||
setEnergy(getEnergy() - energyUsage);
|
||||
setEnergy(getEnergy() - energyPerTick);
|
||||
|
||||
if((operatingTicks+1) < ticksRequired)
|
||||
{
|
||||
@@ -218,9 +168,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
isActive = dataStream.readBoolean();
|
||||
operatingTicks = dataStream.readInt();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
@@ -229,13 +177,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
else {
|
||||
inputTank.setGas(null);
|
||||
}
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
updateDelay = general.UPDATE_DELAY;
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,9 +185,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(isActive);
|
||||
data.add(operatingTicks);
|
||||
data.add(controlType.ordinal());
|
||||
|
||||
if(inputTank.getGas() != null)
|
||||
{
|
||||
@@ -266,10 +205,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
isActive = nbtTags.getBoolean("isActive");
|
||||
operatingTicks = nbtTags.getInteger("operatingTicks");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
|
||||
inputTank.read(nbtTags.getCompoundTag("rightTank"));
|
||||
}
|
||||
|
||||
@@ -278,9 +214,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("operatingTicks", operatingTicks);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
|
||||
nbtTags.setTag("rightTank", inputTank.write(new NBTTagCompound()));
|
||||
|
||||
@@ -300,38 +234,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
return ((double)operatingTicks) / (double)ticksRequired;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
isActive = active;
|
||||
|
||||
if(clientActive != active && updateDelay == 0)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList<Object>())), new Range4D(Coord4D.get(this)));
|
||||
|
||||
updateDelay = 10;
|
||||
clientActive = active;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive()
|
||||
{
|
||||
return isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lightUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTubeConnect(EnumFacing side)
|
||||
{
|
||||
@@ -345,25 +247,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
RecipeHandler.Recipe.CHEMICAL_CRYSTALLIZER.containsRecipe(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
return controlType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlType(RedstoneControl type)
|
||||
{
|
||||
controlType = type;
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPulse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveGas(EnumFacing side, GasStack stack, boolean doTransfer)
|
||||
{
|
||||
@@ -465,12 +348,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
return ejectorComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentUpgrade getComponent()
|
||||
{
|
||||
return upgradeComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSustainedData(ItemStack itemStack)
|
||||
{
|
||||
@@ -495,12 +372,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
{
|
||||
case SPEED:
|
||||
ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED);
|
||||
energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE);
|
||||
break;
|
||||
case ENERGY:
|
||||
energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE);
|
||||
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);
|
||||
setEnergy(Math.min(getMaxEnergy(), getEnergy()));
|
||||
energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -512,10 +384,4 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
{
|
||||
return new Object[] {inputTank};
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentSecurity getSecurity()
|
||||
{
|
||||
return securityComponent;
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,6 @@ import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
@@ -13,24 +11,16 @@ import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismFluids;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.base.ITankManager;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.block.states.BlockStateMachine;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.config.MekanismConfig.usage;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.machines.DissolutionRecipe;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentAdvancedUpgrade;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.GasUtils;
|
||||
@@ -46,7 +36,7 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectricBlock implements ITubeConnection, IRedstoneControl, IGasHandler, IUpgradeTile, ISustainedData, ITankManager, ISecurityTile
|
||||
public class TileEntityChemicalDissolutionChamber extends TileEntityMachine implements ITubeConnection, IGasHandler, ISustainedData, ITankManager
|
||||
{
|
||||
public GasTank injectTank = new GasTank(MAX_GAS);
|
||||
public GasTank outputTank = new GasTank(MAX_GAS);
|
||||
@@ -59,16 +49,8 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
|
||||
public int injectUsageThisTick;
|
||||
|
||||
public int updateDelay;
|
||||
|
||||
public int gasOutput = 256;
|
||||
|
||||
public boolean isActive;
|
||||
|
||||
public boolean clientActive;
|
||||
|
||||
public double prevEnergy;
|
||||
|
||||
public int operatingTicks = 0;
|
||||
|
||||
public int BASE_TICKS_REQUIRED = 100;
|
||||
@@ -77,49 +59,20 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
|
||||
public final double BASE_ENERGY_USAGE = usage.chemicalDissolutionChamberUsage;
|
||||
|
||||
public double energyUsage = usage.chemicalDissolutionChamberUsage;
|
||||
|
||||
public DissolutionRecipe cachedRecipe;
|
||||
|
||||
public TileComponentUpgrade upgradeComponent = new TileComponentAdvancedUpgrade(this, 4);
|
||||
public TileComponentSecurity securityComponent = new TileComponentSecurity(this);
|
||||
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileEntityChemicalDissolutionChamber()
|
||||
{
|
||||
super("machine.dissolution", "ChemicalDissolutionChamber", BlockStateMachine.MachineType.CHEMICAL_DISSOLUTION_CHAMBER.baseEnergy);
|
||||
super("machine.dissolution", "ChemicalDissolutionChamber", BlockStateMachine.MachineType.CHEMICAL_DISSOLUTION_CHAMBER.baseEnergy, usage.chemicalDissolutionChamberUsage, 4);
|
||||
|
||||
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
if(world.isRemote && updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
if(updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList<Object>())), new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
}
|
||||
|
||||
ChargeUtils.discharge(3, this);
|
||||
|
||||
if(!inventory.get(0).isEmpty() && injectTank.getNeeded() > 0)
|
||||
@@ -138,10 +91,10 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
|
||||
injectUsageThisTick = Math.max(1, StatUtils.inversePoisson(injectUsage));
|
||||
|
||||
if(canOperate(recipe) && getEnergy() >= energyUsage && injectTank.getStored() >= injectUsageThisTick && MekanismUtils.canFunction(this))
|
||||
if(canOperate(recipe) && getEnergy() >= energyPerTick && injectTank.getStored() >= injectUsageThisTick && MekanismUtils.canFunction(this))
|
||||
{
|
||||
setActive(true);
|
||||
setEnergy(getEnergy() - energyUsage);
|
||||
setEnergy(getEnergy() - energyPerTick);
|
||||
minorOperate();
|
||||
|
||||
if((operatingTicks+1) < ticksRequired)
|
||||
@@ -267,8 +220,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
isActive = dataStream.readBoolean();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
operatingTicks = dataStream.readInt();
|
||||
|
||||
if(dataStream.readBoolean())
|
||||
@@ -286,13 +237,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
else {
|
||||
outputTank.setGas(null);
|
||||
}
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
updateDelay = general.UPDATE_DELAY;
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,8 +245,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(isActive);
|
||||
data.add(controlType.ordinal());
|
||||
data.add(operatingTicks);
|
||||
|
||||
if(injectTank.getGas() != null)
|
||||
@@ -333,8 +275,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
isActive = nbtTags.getBoolean("isActive");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
operatingTicks = nbtTags.getInteger("operatingTicks");
|
||||
injectTank.read(nbtTags.getCompoundTag("injectTank"));
|
||||
outputTank.read(nbtTags.getCompoundTag("gasTank"));
|
||||
@@ -345,8 +285,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
nbtTags.setInteger("operatingTicks", operatingTicks);
|
||||
nbtTags.setTag("injectTank", injectTank.write(new NBTTagCompound()));
|
||||
nbtTags.setTag("gasTank", outputTank.write(new NBTTagCompound()));
|
||||
@@ -359,38 +297,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
{
|
||||
return i != 0 && i != 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
isActive = active;
|
||||
|
||||
if(clientActive != active && updateDelay == 0)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
|
||||
updateDelay = 10;
|
||||
clientActive = active;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive()
|
||||
{
|
||||
return isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lightUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTubeConnect(EnumFacing side)
|
||||
@@ -398,25 +304,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
return side == MekanismUtils.getLeft(facing) || side == MekanismUtils.getRight(facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
return controlType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlType(RedstoneControl type)
|
||||
{
|
||||
controlType = type;
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPulse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveGas(EnumFacing side, GasStack stack, boolean doTransfer)
|
||||
{
|
||||
@@ -503,14 +390,9 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
break;
|
||||
case SPEED:
|
||||
ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED);
|
||||
energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE);
|
||||
energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE);
|
||||
injectUsage = MekanismUtils.getSecondaryEnergyPerTickMean(this, BASE_INJECT_USAGE);
|
||||
break;
|
||||
case ENERGY:
|
||||
energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE);
|
||||
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);
|
||||
setEnergy(Math.min(getMaxEnergy(), getEnergy()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -521,10 +403,4 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
{
|
||||
return new Object[] {injectTank, outputTank};
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentSecurity getSecurity()
|
||||
{
|
||||
return securityComponent;
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,6 @@ import io.netty.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
@@ -14,7 +12,6 @@ import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.Upgrade.IUpgradeInfoHandler;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
@@ -23,15 +20,11 @@ import mekanism.common.base.ITankManager;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.block.states.BlockStateMachine;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.config.MekanismConfig.usage;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.ChemicalPairInput;
|
||||
import mekanism.common.recipe.machines.ChemicalInfuserRecipe;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.GasUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
@@ -41,12 +34,12 @@ import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.EnumFacing.Axis;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, ISustainedData, IUpgradeTile, IUpgradeInfoHandler, ITankManager, ISecurityTile
|
||||
public class TileEntityChemicalInfuser extends TileEntityMachine implements IGasHandler, ITubeConnection, IRedstoneControl, ISustainedData, IUpgradeTile, IUpgradeInfoHandler, ITankManager, ISecurityTile
|
||||
{
|
||||
public GasTank leftTank = new GasTank(MAX_GAS);
|
||||
public GasTank rightTank = new GasTank(MAX_GAS);
|
||||
@@ -54,36 +47,17 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
||||
|
||||
public static final int MAX_GAS = 10000;
|
||||
|
||||
public int updateDelay;
|
||||
|
||||
public int gasOutput = 256;
|
||||
|
||||
public boolean isActive;
|
||||
|
||||
public boolean clientActive;
|
||||
|
||||
public double prevEnergy;
|
||||
|
||||
public final double BASE_ENERGY_USAGE = usage.chemicalInfuserUsage;
|
||||
|
||||
public double energyPerTick = BASE_ENERGY_USAGE;
|
||||
|
||||
public ChemicalInfuserRecipe cachedRecipe;
|
||||
|
||||
public double clientEnergyUsed;
|
||||
|
||||
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 4);
|
||||
public TileComponentSecurity securityComponent = new TileComponentSecurity(this);
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileEntityChemicalInfuser()
|
||||
{
|
||||
super("machine.cheminfuser", "ChemicalInfuser", BlockStateMachine.MachineType.CHEMICAL_INFUSER.baseEnergy);
|
||||
super("machine.cheminfuser", "ChemicalInfuser", BlockStateMachine.MachineType.CHEMICAL_INFUSER.baseEnergy, usage.chemicalInfuserUsage, 4);
|
||||
|
||||
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,29 +65,8 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
if(world.isRemote && updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
if(updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
}
|
||||
|
||||
ChargeUtils.discharge(3, this);
|
||||
|
||||
if(!inventory.get(0).isEmpty() && (leftTank.getGas() == null || leftTank.getStored() < leftTank.getMaxGas()))
|
||||
@@ -207,7 +160,6 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
||||
int operations = getUpgradedUsage(recipe);
|
||||
|
||||
recipe.operate(leftTank, rightTank, centerTank, operations);
|
||||
|
||||
markDirty();
|
||||
|
||||
return operations;
|
||||
@@ -220,8 +172,6 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
isActive = dataStream.readBoolean();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
clientEnergyUsed = dataStream.readDouble();
|
||||
|
||||
if(dataStream.readBoolean())
|
||||
@@ -247,13 +197,6 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
||||
else {
|
||||
centerTank.setGas(null);
|
||||
}
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
updateDelay = general.UPDATE_DELAY;
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,8 +205,6 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(isActive);
|
||||
data.add(controlType.ordinal());
|
||||
data.add(clientEnergyUsed);
|
||||
|
||||
if(leftTank.getGas() != null)
|
||||
@@ -304,9 +245,6 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
isActive = nbtTags.getBoolean("isActive");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
|
||||
leftTank.read(nbtTags.getCompoundTag("leftTank"));
|
||||
rightTank.read(nbtTags.getCompoundTag("rightTank"));
|
||||
centerTank.read(nbtTags.getCompoundTag("centerTank"));
|
||||
@@ -317,9 +255,6 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
|
||||
nbtTags.setTag("leftTank", leftTank.write(new NBTTagCompound()));
|
||||
nbtTags.setTag("rightTank", rightTank.write(new NBTTagCompound()));
|
||||
nbtTags.setTag("centerTank", centerTank.write(new NBTTagCompound()));
|
||||
@@ -351,38 +286,6 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
isActive = active;
|
||||
|
||||
if(clientActive != active && updateDelay == 0)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList<Object>())), new Range4D(Coord4D.get(this)));
|
||||
|
||||
updateDelay = 10;
|
||||
clientActive = active;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive()
|
||||
{
|
||||
return isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lightUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTubeConnect(EnumFacing side)
|
||||
{
|
||||
@@ -395,25 +298,6 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
||||
return (getTank(side) != null && getTank(side) != centerTank) && getTank(side).canReceive(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
return controlType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlType(RedstoneControl type)
|
||||
{
|
||||
controlType = type;
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPulse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveGas(EnumFacing side, GasStack stack, boolean doTransfer)
|
||||
{
|
||||
@@ -535,28 +419,6 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
||||
centerTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "centerTank")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentUpgrade getComponent()
|
||||
{
|
||||
return upgradeComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculateUpgradables(Upgrade upgrade)
|
||||
{
|
||||
super.recalculateUpgradables(upgrade);
|
||||
|
||||
switch(upgrade)
|
||||
{
|
||||
case ENERGY:
|
||||
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);
|
||||
energyPerTick = MekanismUtils.getBaseEnergyPerTick(this, BASE_ENERGY_USAGE);
|
||||
setEnergy(Math.min(getMaxEnergy(), getEnergy()));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInfo(Upgrade upgrade)
|
||||
{
|
||||
@@ -568,10 +430,4 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
||||
{
|
||||
return new Object[] {leftTank, rightTank, centerTank};
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentSecurity getSecurity()
|
||||
{
|
||||
return securityComponent;
|
||||
}
|
||||
}
|
||||
@@ -4,30 +4,20 @@ import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.base.ITankManager;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.block.states.BlockStateMachine;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.config.MekanismConfig.usage;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.machines.OxidationRecipe;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.GasUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
@@ -37,50 +27,32 @@ import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.EnumFacing.Axis;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock implements ITubeConnection, IRedstoneControl, IUpgradeTile, ISustainedData, ITankManager, ISecurityTile
|
||||
public class TileEntityChemicalOxidizer extends TileEntityMachine implements ITubeConnection, ISustainedData, ITankManager
|
||||
{
|
||||
public GasTank gasTank = new GasTank(MAX_GAS);
|
||||
|
||||
public static final int MAX_GAS = 10000;
|
||||
|
||||
public int updateDelay;
|
||||
|
||||
public int gasOutput = 256;
|
||||
|
||||
public boolean isActive;
|
||||
|
||||
public boolean clientActive;
|
||||
|
||||
public double prevEnergy;
|
||||
|
||||
public int operatingTicks = 0;
|
||||
|
||||
public int BASE_TICKS_REQUIRED = 100;
|
||||
|
||||
public int ticksRequired = BASE_TICKS_REQUIRED;
|
||||
|
||||
public final double BASE_ENERGY_USAGE = usage.rotaryCondensentratorUsage;
|
||||
|
||||
public double energyUsage = BASE_ENERGY_USAGE;
|
||||
|
||||
public OxidationRecipe cachedRecipe;
|
||||
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
public TileComponentSecurity securityComponent = new TileComponentSecurity(this);
|
||||
|
||||
public TileEntityChemicalOxidizer()
|
||||
{
|
||||
super("machine.oxidizer", "ChemicalOxidizer", BlockStateMachine.MachineType.CHEMICAL_OXIDIZER.baseEnergy);
|
||||
super("machine.oxidizer", "ChemicalOxidizer", BlockStateMachine.MachineType.CHEMICAL_OXIDIZER.baseEnergy, usage.rotaryCondensentratorUsage, 3);
|
||||
|
||||
inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,29 +60,8 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
if(world.isRemote && updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
if(updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
}
|
||||
|
||||
ChargeUtils.discharge(1, this);
|
||||
|
||||
if(!inventory.get(2).isEmpty() && gasTank.getGas() != null)
|
||||
@@ -120,10 +71,10 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
|
||||
|
||||
OxidationRecipe recipe = getRecipe();
|
||||
|
||||
if(canOperate(recipe) && getEnergy() >= energyUsage && MekanismUtils.canFunction(this))
|
||||
if(canOperate(recipe) && getEnergy() >= energyPerTick && MekanismUtils.canFunction(this))
|
||||
{
|
||||
setActive(true);
|
||||
setEnergy(getEnergy() - energyUsage);
|
||||
setEnergy(getEnergy() - energyPerTick);
|
||||
|
||||
if(operatingTicks < ticksRequired)
|
||||
{
|
||||
@@ -239,8 +190,6 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
isActive = dataStream.readBoolean();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
operatingTicks = dataStream.readInt();
|
||||
|
||||
if(dataStream.readBoolean())
|
||||
@@ -250,13 +199,6 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
|
||||
else {
|
||||
gasTank.setGas(null);
|
||||
}
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
updateDelay = general.UPDATE_DELAY;
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,8 +207,6 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(isActive);
|
||||
data.add(controlType.ordinal());
|
||||
data.add(operatingTicks);
|
||||
|
||||
if(gasTank.getGas() != null)
|
||||
@@ -287,8 +227,6 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
isActive = nbtTags.getBoolean("isActive");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
operatingTicks = nbtTags.getInteger("operatingTicks");
|
||||
gasTank.read(nbtTags.getCompoundTag("gasTank"));
|
||||
}
|
||||
@@ -298,8 +236,6 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
nbtTags.setInteger("operatingTicks", operatingTicks);
|
||||
nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound()));
|
||||
|
||||
@@ -311,38 +247,6 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
|
||||
{
|
||||
return i != 0 && i != 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
isActive = active;
|
||||
|
||||
if(clientActive != active && updateDelay == 0)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
|
||||
updateDelay = 10;
|
||||
clientActive = active;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive()
|
||||
{
|
||||
return isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lightUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTubeConnect(EnumFacing side)
|
||||
@@ -367,31 +271,6 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
|
||||
return super.getCapability(capability, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
return controlType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlType(RedstoneControl type)
|
||||
{
|
||||
controlType = type;
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPulse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentUpgrade getComponent()
|
||||
{
|
||||
return upgradeComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSustainedData(ItemStack itemStack)
|
||||
{
|
||||
@@ -416,10 +295,8 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
|
||||
{
|
||||
case SPEED:
|
||||
ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED);
|
||||
case ENERGY:
|
||||
energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE);
|
||||
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);
|
||||
setEnergy(Math.min(getMaxEnergy(), getEnergy()));
|
||||
energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -430,10 +307,4 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
|
||||
{
|
||||
return new Object[] {gasTank};
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentSecurity getSecurity()
|
||||
{
|
||||
return securityComponent;
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,6 @@ import io.netty.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
@@ -14,27 +12,20 @@ import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.Upgrade.IUpgradeInfoHandler;
|
||||
import mekanism.common.base.FluidHandlerWrapper;
|
||||
import mekanism.common.base.IFluidHandlerWrapper;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.base.ITankManager;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.block.states.BlockStateMachine;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.config.MekanismConfig.usage;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.GasInput;
|
||||
import mekanism.common.recipe.machines.WasherRecipe;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.FluidContainerUtils;
|
||||
import mekanism.common.util.FluidContainerUtils.FluidChecker;
|
||||
@@ -47,8 +38,8 @@ import mekanism.common.util.PipeUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.EnumFacing.Axis;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
@@ -59,7 +50,7 @@ import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, IFluidHandlerWrapper, IUpgradeTile, ISustainedData, IUpgradeInfoHandler, ITankManager, ISecurityTile
|
||||
public class TileEntityChemicalWasher extends TileEntityMachine implements IGasHandler, ITubeConnection, IFluidHandlerWrapper, ISustainedData, IUpgradeInfoHandler, ITankManager
|
||||
{
|
||||
public FluidTank fluidTank = new FluidTank(MAX_FLUID);
|
||||
public GasTank inputTank = new GasTank(MAX_GAS);
|
||||
@@ -70,36 +61,17 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
||||
|
||||
public static int WATER_USAGE = 5;
|
||||
|
||||
public int updateDelay;
|
||||
|
||||
public int gasOutput = 256;
|
||||
|
||||
public boolean isActive;
|
||||
|
||||
public boolean clientActive;
|
||||
|
||||
public double prevEnergy;
|
||||
|
||||
public final double BASE_ENERGY_USAGE = usage.chemicalWasherUsage;
|
||||
|
||||
public double energyPerTick = BASE_ENERGY_USAGE;
|
||||
|
||||
public WasherRecipe cachedRecipe;
|
||||
|
||||
public double clientEnergyUsed;
|
||||
|
||||
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 4);
|
||||
public TileComponentSecurity securityComponent = new TileComponentSecurity(this);
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileEntityChemicalWasher()
|
||||
{
|
||||
super("machine.washer", "ChemicalWasher", BlockStateMachine.MachineType.CHEMICAL_WASHER.baseEnergy);
|
||||
super("machine.washer", "ChemicalWasher", BlockStateMachine.MachineType.CHEMICAL_WASHER.baseEnergy, usage.chemicalWasherUsage, 4);
|
||||
|
||||
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,29 +79,8 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
if(world.isRemote && updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
if(updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
}
|
||||
|
||||
ChargeUtils.discharge(3, this);
|
||||
manageBuckets();
|
||||
|
||||
@@ -222,8 +173,6 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
isActive = dataStream.readBoolean();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
clientEnergyUsed = dataStream.readDouble();
|
||||
|
||||
if(dataStream.readBoolean())
|
||||
@@ -264,8 +213,6 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(isActive);
|
||||
data.add(controlType.ordinal());
|
||||
data.add(clientEnergyUsed);
|
||||
|
||||
if(fluidTank.getFluid() != null)
|
||||
@@ -306,9 +253,6 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
isActive = nbtTags.getBoolean("isActive");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
|
||||
fluidTank.readFromNBT(nbtTags.getCompoundTag("leftTank"));
|
||||
inputTank.read(nbtTags.getCompoundTag("rightTank"));
|
||||
outputTank.read(nbtTags.getCompoundTag("centerTank"));
|
||||
@@ -319,9 +263,6 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
|
||||
nbtTags.setTag("leftTank", fluidTank.writeToNBT(new NBTTagCompound()));
|
||||
nbtTags.setTag("rightTank", inputTank.write(new NBTTagCompound()));
|
||||
nbtTags.setTag("centerTank", outputTank.write(new NBTTagCompound()));
|
||||
@@ -349,38 +290,6 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
isActive = active;
|
||||
|
||||
if(clientActive != active && updateDelay == 0)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
|
||||
updateDelay = 10;
|
||||
clientActive = active;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive()
|
||||
{
|
||||
return isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lightUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTubeConnect(EnumFacing side)
|
||||
{
|
||||
@@ -398,24 +307,6 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
return controlType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlType(RedstoneControl type)
|
||||
{
|
||||
controlType = type;
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPulse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveGas(EnumFacing side, GasStack stack, boolean doTransfer)
|
||||
@@ -589,28 +480,6 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
||||
inputTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "inputTank")));
|
||||
outputTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "outputTank")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentUpgrade getComponent()
|
||||
{
|
||||
return upgradeComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculateUpgradables(Upgrade upgrade)
|
||||
{
|
||||
super.recalculateUpgradables(upgrade);
|
||||
|
||||
switch(upgrade)
|
||||
{
|
||||
case ENERGY:
|
||||
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);
|
||||
energyPerTick = MekanismUtils.getBaseEnergyPerTick(this, BASE_ENERGY_USAGE);
|
||||
setEnergy(Math.min(getMaxEnergy(), getEnergy()));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInfo(Upgrade upgrade)
|
||||
@@ -623,10 +492,4 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
||||
{
|
||||
return new Object[] {fluidTank, inputTank, outputTank};
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentSecurity getSecurity()
|
||||
{
|
||||
return securityComponent;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public class TileEntityCrusher extends TileEntityElectricMachine<CrusherRecipe>
|
||||
{
|
||||
public TileEntityCrusher()
|
||||
{
|
||||
super("crusher", "Crusher", usage.crusherUsage, 200, BlockStateMachine.MachineType.CRUSHER.baseEnergy);
|
||||
super("crusher", "Crusher", 200, BlockStateMachine.MachineType.CRUSHER.baseEnergy, usage.crusherUsage);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,6 @@ import mekanism.common.recipe.machines.BasicMachineRecipe;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -36,9 +35,9 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
|
||||
* @param ticksRequired - ticks required to operate -- or smelt an item.
|
||||
* @param maxEnergy - maximum energy this machine can hold.
|
||||
*/
|
||||
public TileEntityElectricMachine(String soundPath, String name, double perTick, int ticksRequired, double maxEnergy)
|
||||
public TileEntityElectricMachine(String soundPath, String name, int ticksRequired, double perTick, double maxEnergy)
|
||||
{
|
||||
super(soundPath, name, MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png"), perTick, ticksRequired, maxEnergy);
|
||||
super(soundPath, name, ticksRequired, maxEnergy, perTick, 3, MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png"));
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
@@ -51,9 +50,6 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2));
|
||||
|
||||
@@ -32,9 +32,6 @@ public class TileEntityEliteFactory extends TileEntityFactory
|
||||
configComponent.setCanEject(TransmissionType.GAS, false);
|
||||
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2));
|
||||
|
||||
@@ -12,7 +12,7 @@ public class TileEntityEnergizedSmelter extends TileEntityElectricMachine<Smelti
|
||||
{
|
||||
public TileEntityEnergizedSmelter()
|
||||
{
|
||||
super("smelter", "EnergizedSmelter", usage.energizedSmelterUsage, 200, BlockStateMachine.MachineType.ENERGIZED_SMELTER.baseEnergy);
|
||||
super("smelter", "EnergizedSmelter", 200, BlockStateMachine.MachineType.ENERGIZED_SMELTER.baseEnergy, usage.energizedSmelterUsage);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,7 +13,7 @@ public class TileEntityEnrichmentChamber extends TileEntityElectricMachine<Enric
|
||||
{
|
||||
public TileEntityEnrichmentChamber()
|
||||
{
|
||||
super("enrichment", "EnrichmentChamber", usage.enrichmentChamberUsage, 200, BlockStateMachine.MachineType.ENRICHMENT_CHAMBER.baseEnergy);
|
||||
super("enrichment", "EnrichmentChamber", 200, BlockStateMachine.MachineType.ENRICHMENT_CHAMBER.baseEnergy, usage.enrichmentChamberUsage);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,10 +30,8 @@ import mekanism.common.Tier.BaseTier;
|
||||
import mekanism.common.Tier.FactoryTier;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.base.ITierUpgradeable;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.base.SoundWrapper;
|
||||
import mekanism.common.block.states.BlockStateMachine;
|
||||
import mekanism.common.block.states.BlockStateMachine.MachineType;
|
||||
@@ -47,7 +45,6 @@ import mekanism.common.recipe.inputs.InfusionInput;
|
||||
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
|
||||
import mekanism.common.recipe.machines.BasicMachineRecipe;
|
||||
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
@@ -71,7 +68,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityFactory extends TileEntityNoisyElectricBlock implements IComputerIntegration, ISideConfiguration, IUpgradeTile, IRedstoneControl, IGasHandler, ITubeConnection, ISpecialConfigData, ISecurityTile, ITierUpgradeable
|
||||
public class TileEntityFactory extends TileEntityMachine implements IComputerIntegration, ISideConfiguration, IGasHandler, ITubeConnection, ISpecialConfigData, ITierUpgradeable
|
||||
{
|
||||
/** This Factory's tier. */
|
||||
public FactoryTier tier;
|
||||
@@ -89,12 +86,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
/** How many ticks it takes, with upgrades, to run an operation */
|
||||
public int ticksRequired = 200;
|
||||
|
||||
/** How much energy each operation consumes per tick, without upgrades. */
|
||||
public double BASE_ENERGY_PER_TICK = usage.factoryUsage;
|
||||
|
||||
/** How much energy each operation consumes per tick. */
|
||||
public double energyPerTick = usage.factoryUsage;
|
||||
|
||||
/** How much secondary energy each operation consumes per tick */
|
||||
public double secondaryEnergyPerTick = 0;
|
||||
|
||||
@@ -106,24 +97,12 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
/** How many recipe ticks have progressed. */
|
||||
public int recipeTicks;
|
||||
|
||||
/** The client's current active state. */
|
||||
public boolean clientActive;
|
||||
|
||||
/** This machine's active state. */
|
||||
public boolean isActive;
|
||||
|
||||
/** How many ticks must pass until this block's active state can sync with the client. */
|
||||
public int updateDelay;
|
||||
|
||||
/** This machine's recipe type. */
|
||||
public RecipeType recipeType = RecipeType.SMELTING;
|
||||
|
||||
/** The amount of infuse this machine has stored. */
|
||||
public InfuseStorage infuseStored = new InfuseStorage();
|
||||
|
||||
/** This machine's previous amount of energy. */
|
||||
public double prevEnergy;
|
||||
|
||||
public GasTank gasTank;
|
||||
|
||||
public boolean sorting;
|
||||
@@ -138,10 +117,8 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileComponentUpgrade upgradeComponent;
|
||||
public TileComponentEjector ejectorComponent;
|
||||
public TileComponentConfig configComponent;
|
||||
public TileComponentSecurity securityComponent = new TileComponentSecurity(this);
|
||||
|
||||
public TileEntityFactory()
|
||||
{
|
||||
@@ -163,9 +140,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
configComponent.setCanEject(TransmissionType.GAS, false);
|
||||
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2));
|
||||
@@ -173,7 +147,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
|
||||
public TileEntityFactory(FactoryTier type, MachineType machine)
|
||||
{
|
||||
super("null", machine.blockName, machine.baseEnergy);
|
||||
super("null", machine.blockName, machine.baseEnergy, usage.factoryUsage, 0);
|
||||
|
||||
tier = type;
|
||||
inventory = NonNullList.withSize(5+type.processes*2, ItemStack.EMPTY);
|
||||
@@ -270,17 +244,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
if(world.isRemote && updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
if(ticker == 1)
|
||||
@@ -288,16 +251,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
world.notifyNeighborsOfStateChange(getPos(), getBlockType(), true);
|
||||
}
|
||||
|
||||
if(updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
}
|
||||
|
||||
ChargeUtils.discharge(1, this);
|
||||
|
||||
handleSecondaryFuel();
|
||||
@@ -753,12 +706,10 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
clientActive = dataStream.readBoolean();
|
||||
RecipeType oldRecipe = recipeType;
|
||||
recipeType = RecipeType.values()[dataStream.readInt()];
|
||||
upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades());
|
||||
recipeTicks = dataStream.readInt();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
sorting = dataStream.readBoolean();
|
||||
upgraded = dataStream.readBoolean();
|
||||
lastUsage = dataStream.readDouble();
|
||||
@@ -787,13 +738,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
else {
|
||||
gasTank.setGas(null);
|
||||
}
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
updateDelay = general.UPDATE_DELAY;
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
|
||||
if(upgraded)
|
||||
{
|
||||
@@ -809,7 +753,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
clientActive = isActive = nbtTags.getBoolean("isActive");
|
||||
RecipeType oldRecipe = recipeType;
|
||||
recipeType = RecipeType.values()[nbtTags.getInteger("recipeType")];
|
||||
upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades());
|
||||
@@ -820,7 +763,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
}
|
||||
|
||||
recipeTicks = nbtTags.getInteger("recipeTicks");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
sorting = nbtTags.getBoolean("sorting");
|
||||
infuseStored.amount = nbtTags.getInteger("infuseStored");
|
||||
infuseStored.type = InfuseRegistry.get(nbtTags.getString("type"));
|
||||
@@ -838,10 +780,8 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("recipeType", recipeType.ordinal());
|
||||
nbtTags.setInteger("recipeTicks", recipeTicks);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
nbtTags.setBoolean("sorting", sorting);
|
||||
nbtTags.setInteger("infuseStored", infuseStored.amount);
|
||||
|
||||
@@ -868,10 +808,8 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(isActive);
|
||||
data.add(recipeType.ordinal());
|
||||
data.add(recipeTicks);
|
||||
data.add(controlType.ordinal());
|
||||
data.add(sorting);
|
||||
data.add(upgraded);
|
||||
data.add(lastUsage);
|
||||
@@ -983,26 +921,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
isActive = active;
|
||||
|
||||
if(clientActive != active && updateDelay == 0)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList<Object>())), new Range4D(Coord4D.get(this)));
|
||||
|
||||
updateDelay = 10;
|
||||
clientActive = active;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive()
|
||||
{
|
||||
return isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
@@ -1046,43 +964,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lightUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
return controlType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlType(RedstoneControl type)
|
||||
{
|
||||
controlType = type;
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPulse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentUpgrade getComponent()
|
||||
{
|
||||
return upgradeComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentEjector getEjector()
|
||||
{
|
||||
@@ -1166,14 +1047,9 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
break;
|
||||
case SPEED:
|
||||
ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED);
|
||||
energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK);
|
||||
energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE);
|
||||
secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType);
|
||||
break;
|
||||
case ENERGY:
|
||||
energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK);
|
||||
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);
|
||||
setEnergy(Math.min(getMaxEnergy(), getEnergy()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1198,10 +1074,4 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
{
|
||||
return tier.getBaseTier().getLocalizedName() + " " + recipeType.getLocalizedName() + " " + super.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentSecurity getSecurity()
|
||||
{
|
||||
return securityComponent;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityLaser extends TileEntityNoisyElectricBlock implements IActiveState
|
||||
public class TileEntityLaser extends TileEntityNoisyBlock implements IActiveState
|
||||
{
|
||||
public Coord4D digging;
|
||||
public double diggingProgress;
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public abstract class TileEntityMachine extends TileEntityNoisyBlock implements IUpgradeTile, IRedstoneControl, ISecurityTile
|
||||
{
|
||||
public int updateDelay;
|
||||
|
||||
public boolean isActive;
|
||||
|
||||
public boolean clientActive;
|
||||
|
||||
public double prevEnergy;
|
||||
|
||||
public final double BASE_ENERGY_USAGE;
|
||||
|
||||
public double energyPerTick;
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileComponentUpgrade upgradeComponent;
|
||||
public TileComponentSecurity securityComponent = new TileComponentSecurity(this);
|
||||
|
||||
public TileEntityMachine(String sound, String name, double maxEnergy, double baseEnergyUsage, int upgradeSlot)
|
||||
{
|
||||
super(sound, name, maxEnergy);
|
||||
|
||||
BASE_ENERGY_USAGE = baseEnergyUsage;
|
||||
energyPerTick = baseEnergyUsage;
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, upgradeSlot);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
if(world.isRemote && updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
if(updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
isActive = active;
|
||||
|
||||
if(clientActive != active && updateDelay == 0)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
|
||||
updateDelay = 10;
|
||||
clientActive = active;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive()
|
||||
{
|
||||
return isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lightUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteBuf dataStream)
|
||||
{
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
isActive = dataStream.readBoolean();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
updateDelay = general.UPDATE_DELAY;
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Object> getNetworkedData(ArrayList<Object> data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(isActive);
|
||||
data.add(controlType.ordinal());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
isActive = nbtTags.getBoolean("isActive");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
|
||||
return nbtTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
return controlType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlType(RedstoneControl type)
|
||||
{
|
||||
controlType = type;
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPulse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentSecurity getSecurity()
|
||||
{
|
||||
return securityComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentUpgrade getComponent()
|
||||
{
|
||||
return upgradeComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculateUpgradables(Upgrade upgrade)
|
||||
{
|
||||
super.recalculateUpgradables(upgrade);
|
||||
|
||||
switch(upgrade)
|
||||
{
|
||||
case ENERGY:
|
||||
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);
|
||||
energyPerTick = MekanismUtils.getBaseEnergyPerTick(this, BASE_ENERGY_USAGE);
|
||||
setEnergy(Math.min(getMaxEnergy(), getEnergy()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,15 +4,12 @@ import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.IConfigCardAccess;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.infuse.InfuseObject;
|
||||
import mekanism.api.infuse.InfuseRegistry;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.InfuseStorage;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.PacketHandler;
|
||||
@@ -20,25 +17,19 @@ import mekanism.common.SideData;
|
||||
import mekanism.common.Tier.BaseTier;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.base.ITierUpgradeable;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.block.states.BlockStateMachine;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.config.MekanismConfig.usage;
|
||||
import mekanism.common.integration.IComputerIntegration;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.recipe.inputs.InfusionInput;
|
||||
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -49,16 +40,11 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock implements IComputerIntegration, ISideConfiguration, IUpgradeTile, IRedstoneControl, IConfigCardAccess, ISecurityTile, ITierUpgradeable
|
||||
public class TileEntityMetallurgicInfuser extends TileEntityMachine implements IComputerIntegration, ISideConfiguration, IConfigCardAccess, ITierUpgradeable
|
||||
{
|
||||
/** The maxiumum amount of infuse this machine can store. */
|
||||
public int MAX_INFUSE = 1000;
|
||||
|
||||
/** How much energy this machine consumes per-tick. */
|
||||
public double BASE_ENERGY_PER_TICK = usage.metallurgicInfuserUsage;
|
||||
|
||||
public double energyPerTick = BASE_ENERGY_PER_TICK;
|
||||
|
||||
/** How many ticks it takes to run an operation. */
|
||||
public int BASE_TICKS_REQUIRED = 200;
|
||||
|
||||
@@ -70,29 +56,12 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
/** How many ticks this machine has been operating for. */
|
||||
public int operatingTicks;
|
||||
|
||||
/** Whether or not this machine is in it's active state. */
|
||||
public boolean isActive;
|
||||
|
||||
/** The client's current active state. */
|
||||
public boolean clientActive;
|
||||
|
||||
/** How many ticks must pass until this block's active state can sync with the client. */
|
||||
public int updateDelay;
|
||||
|
||||
/** This machine's previous amount of energy. */
|
||||
public double prevEnergy;
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileComponentUpgrade upgradeComponent;
|
||||
public TileComponentEjector ejectorComponent;
|
||||
public TileComponentConfig configComponent;
|
||||
public TileComponentSecurity securityComponent;
|
||||
|
||||
public TileEntityMetallurgicInfuser()
|
||||
{
|
||||
super("machine.metalinfuser", "MetallurgicInfuser", BlockStateMachine.MachineType.METALLURGIC_INFUSER.baseEnergy);
|
||||
super("machine.metalinfuser", "MetallurgicInfuser", BlockStateMachine.MachineType.METALLURGIC_INFUSER.baseEnergy, usage.metallurgicInfuserUsage, 0);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
|
||||
|
||||
@@ -106,9 +75,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
|
||||
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2));
|
||||
|
||||
@@ -119,30 +85,9 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
if(world.isRemote && updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
if(updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList<Object>())), new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
}
|
||||
|
||||
ChargeUtils.discharge(4, this);
|
||||
|
||||
if(!inventory.get(1).isEmpty())
|
||||
@@ -362,10 +307,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
clientActive = isActive = nbtTags.getBoolean("isActive");
|
||||
operatingTicks = nbtTags.getInteger("operatingTicks");
|
||||
infuseStored.amount = nbtTags.getInteger("infuseStored");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
infuseStored.type = InfuseRegistry.get(nbtTags.getString("type"));
|
||||
}
|
||||
|
||||
@@ -374,10 +317,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("operatingTicks", operatingTicks);
|
||||
nbtTags.setInteger("infuseStored", infuseStored.amount);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
|
||||
if(infuseStored.type != null)
|
||||
{
|
||||
@@ -405,18 +346,9 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
clientActive = dataStream.readBoolean();
|
||||
operatingTicks = dataStream.readInt();
|
||||
infuseStored.amount = dataStream.readInt();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
infuseStored.type = InfuseRegistry.get(PacketHandler.readString(dataStream));
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
updateDelay = general.UPDATE_DELAY;
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,10 +357,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(isActive);
|
||||
data.add(operatingTicks);
|
||||
data.add(infuseStored.amount);
|
||||
data.add(controlType.ordinal());
|
||||
|
||||
if(infuseStored.type != null)
|
||||
{
|
||||
@@ -487,26 +417,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
return side != 0 && side != 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
isActive = active;
|
||||
|
||||
if(clientActive != active && updateDelay == 0)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList<Object>())), new Range4D(Coord4D.get(this)));
|
||||
|
||||
updateDelay = 10;
|
||||
clientActive = active;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive()
|
||||
{
|
||||
return isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentConfig getConfig()
|
||||
{
|
||||
@@ -519,54 +429,11 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
return facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lightUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
return controlType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlType(RedstoneControl type)
|
||||
{
|
||||
controlType = type;
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPulse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentUpgrade getComponent()
|
||||
{
|
||||
return upgradeComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentEjector getEjector()
|
||||
{
|
||||
return ejectorComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentSecurity getSecurity()
|
||||
{
|
||||
return securityComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculateUpgradables(Upgrade upgrade)
|
||||
@@ -577,10 +444,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
{
|
||||
case SPEED:
|
||||
ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED);
|
||||
case ENERGY:
|
||||
energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK);
|
||||
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);
|
||||
setEnergy(Math.min(getMaxEnergy(), getEnergy()));
|
||||
energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class TileEntityNoisyElectricBlock extends TileEntityElectricBlock implements IHasSound, ISoundSource, IActiveState
|
||||
public abstract class TileEntityNoisyBlock extends TileEntityElectricBlock implements IHasSound, ISoundSource, IActiveState
|
||||
{
|
||||
/** The ResourceLocation of the machine's sound */
|
||||
public ResourceLocation soundURL;
|
||||
@@ -33,7 +33,7 @@ public abstract class TileEntityNoisyElectricBlock extends TileEntityElectricBlo
|
||||
* @param name - full name of this block
|
||||
* @param maxEnergy - how much energy this block can store
|
||||
*/
|
||||
public TileEntityNoisyElectricBlock(String sound, String name, double maxEnergy)
|
||||
public TileEntityNoisyBlock(String sound, String name, double maxEnergy)
|
||||
{
|
||||
super(name, maxEnergy);
|
||||
|
||||
@@ -30,7 +30,6 @@ import mekanism.common.recipe.machines.PressurizedRecipe;
|
||||
import mekanism.common.recipe.outputs.PressurizedOutput;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
@@ -59,7 +58,7 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
|
||||
|
||||
public TileEntityPRC()
|
||||
{
|
||||
super("prc", BlockStateMachine.MachineType.PRESSURIZED_REACTION_CHAMBER.blockName, new ResourceLocation("mekanism", "gui/GuiPRC.png"), usage.pressurizedReactionBaseUsage, 100, BlockStateMachine.MachineType.PRESSURIZED_REACTION_CHAMBER.baseEnergy);
|
||||
super("prc", BlockStateMachine.MachineType.PRESSURIZED_REACTION_CHAMBER.blockName, 100, BlockStateMachine.MachineType.PRESSURIZED_REACTION_CHAMBER.baseEnergy, usage.pressurizedReactionBaseUsage, 3, new ResourceLocation("mekanism", "gui/GuiPRC.png"));
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.FLUID, TransmissionType.GAS);
|
||||
|
||||
@@ -82,9 +81,6 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
upgradeComponent.setSupported(Upgrade.MUFFLING);
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(3));
|
||||
@@ -102,7 +98,7 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
|
||||
|
||||
ChargeUtils.discharge(1, this);
|
||||
|
||||
if(canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy))
|
||||
if(canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE + recipe.extraEnergy))
|
||||
{
|
||||
boolean update = BASE_TICKS_REQUIRED != recipe.ticks;
|
||||
|
||||
@@ -118,14 +114,14 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
|
||||
if((operatingTicks+1) < ticksRequired)
|
||||
{
|
||||
operatingTicks++;
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy);
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE + recipe.extraEnergy);
|
||||
}
|
||||
else if((operatingTicks+1) >= ticksRequired && getEnergy() >= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy))
|
||||
else if((operatingTicks+1) >= ticksRequired && getEnergy() >= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE + recipe.extraEnergy))
|
||||
{
|
||||
operate(recipe);
|
||||
|
||||
operatingTicks = 0;
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy);
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE + recipe.extraEnergy);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -16,7 +16,7 @@ public class TileEntityPrecisionSawmill extends TileEntityChanceMachine<SawmillR
|
||||
{
|
||||
public TileEntityPrecisionSawmill()
|
||||
{
|
||||
super("sawmill", "PrecisionSawmill", MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png"), usage.precisionSawmillUsage, 200, BlockStateMachine.MachineType.PRECISION_SAWMILL.baseEnergy);
|
||||
super("sawmill", "PrecisionSawmill", 200, BlockStateMachine.MachineType.PRECISION_SAWMILL.baseEnergy, usage.precisionSawmillUsage, MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,7 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock implements IHeatTransfer, IComputerIntegration, IRedstoneControl, ISecurityTile
|
||||
public class TileEntityResistiveHeater extends TileEntityNoisyBlock implements IHeatTransfer, IComputerIntegration, IRedstoneControl, ISecurityTile
|
||||
{
|
||||
public double energyUsage = 100;
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package mekanism.common.tile.component;
|
||||
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.tile.TileEntityContainerBlock;
|
||||
|
||||
public class TileComponentAdvancedUpgrade extends TileComponentUpgrade
|
||||
{
|
||||
public TileComponentAdvancedUpgrade(TileEntityContainerBlock tile, int slot)
|
||||
{
|
||||
super(tile, slot);
|
||||
|
||||
setSupported(Upgrade.GAS);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.integration.IComputerIntegration;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.TileEntityNoisyElectricBlock;
|
||||
import mekanism.common.tile.TileEntityNoisyBlock;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.util.CableUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -29,7 +29,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class TileEntityGenerator extends TileEntityNoisyElectricBlock implements IComputerIntegration, IActiveState, IHasSound, ISoundSource, IRedstoneControl, ISecurityTile
|
||||
public abstract class TileEntityGenerator extends TileEntityNoisyBlock implements IComputerIntegration, IActiveState, IHasSound, ISoundSource, IRedstoneControl, ISecurityTile
|
||||
{
|
||||
/** Output per tick this generator can transfer. */
|
||||
public double output;
|
||||
|
||||
Reference in new issue
Block a user