mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 06:14:41 +00:00
Lots of work on resistive heaters, still mostly unfinished
This commit is contained in:
1 parent
a31bc02e83
commit
9d55f6cc8a
19 files changed
+391
-115
No files matched your search
@@ -32,6 +32,7 @@ import mekanism.common.inventory.container.ContainerElectrolyticSeparator;
|
||||
import mekanism.common.inventory.container.ContainerEnergyCube;
|
||||
import mekanism.common.inventory.container.ContainerFactory;
|
||||
import mekanism.common.inventory.container.ContainerFilter;
|
||||
import mekanism.common.inventory.container.ContainerFluidTank;
|
||||
import mekanism.common.inventory.container.ContainerFluidicPlenisher;
|
||||
import mekanism.common.inventory.container.ContainerGasTank;
|
||||
import mekanism.common.inventory.container.ContainerInductionMatrix;
|
||||
@@ -41,7 +42,7 @@ import mekanism.common.inventory.container.ContainerMetallurgicInfuser;
|
||||
import mekanism.common.inventory.container.ContainerNull;
|
||||
import mekanism.common.inventory.container.ContainerOredictionificator;
|
||||
import mekanism.common.inventory.container.ContainerPRC;
|
||||
import mekanism.common.inventory.container.ContainerPortableTank;
|
||||
import mekanism.common.inventory.container.ContainerResistiveHeater;
|
||||
import mekanism.common.inventory.container.ContainerRobitCrafting;
|
||||
import mekanism.common.inventory.container.ContainerRobitInventory;
|
||||
import mekanism.common.inventory.container.ContainerRobitMain;
|
||||
@@ -101,6 +102,7 @@ import mekanism.common.tile.TileEntityOsmiumCompressor;
|
||||
import mekanism.common.tile.TileEntityPRC;
|
||||
import mekanism.common.tile.TileEntityPrecisionSawmill;
|
||||
import mekanism.common.tile.TileEntityPurificationChamber;
|
||||
import mekanism.common.tile.TileEntityResistiveHeater;
|
||||
import mekanism.common.tile.TileEntityRotaryCondensentrator;
|
||||
import mekanism.common.tile.TileEntitySeismicVibrator;
|
||||
import mekanism.common.tile.TileEntitySolarNeutronActivator;
|
||||
@@ -193,6 +195,7 @@ public class CommonProxy implements IGuiProvider
|
||||
GameRegistry.registerTileEntity(TileEntityInductionProvider.class, "InductionProvider");
|
||||
GameRegistry.registerTileEntity(TileEntityOredictionificator.class, "Oredictionificator");
|
||||
GameRegistry.registerTileEntity(TileEntityStructuralGlass.class, "StructuralGlass");
|
||||
GameRegistry.registerTileEntity(TileEntityResistiveHeater.class, "ResistiveHeater");
|
||||
}
|
||||
|
||||
public void handleTeleporterUpdate(PortableTeleporterMessage message) {}
|
||||
@@ -508,7 +511,7 @@ public class CommonProxy implements IGuiProvider
|
||||
case 40:
|
||||
return new ContainerPRC(player.inventory, (TileEntityPRC)tileEntity);
|
||||
case 41:
|
||||
return new ContainerPortableTank(player.inventory, (TileEntityFluidTank)tileEntity);
|
||||
return new ContainerFluidTank(player.inventory, (TileEntityFluidTank)tileEntity);
|
||||
case 42:
|
||||
return new ContainerFluidicPlenisher(player.inventory, (TileEntityFluidicPlenisher)tileEntity);
|
||||
case 43:
|
||||
@@ -531,6 +534,8 @@ public class CommonProxy implements IGuiProvider
|
||||
return new ContainerNull(player, (TileEntityContainerBlock)tileEntity);
|
||||
case 52:
|
||||
return new ContainerOredictionificator(player.inventory, (TileEntityOredictionificator)tileEntity);
|
||||
case 53:
|
||||
return new ContainerResistiveHeater(player.inventory, (TileEntityResistiveHeater)tileEntity);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -43,7 +43,6 @@ import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.base.IModule;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.chunkloading.ChunkManager;
|
||||
import mekanism.common.content.boiler.BoilerManager;
|
||||
import mekanism.common.content.boiler.SynchronizedBoilerData;
|
||||
import mekanism.common.content.matrix.SynchronizedMatrixData;
|
||||
import mekanism.common.content.tank.SynchronizedTankData;
|
||||
@@ -174,7 +173,7 @@ public class Mekanism
|
||||
/** MultiblockManagers for various structrures */
|
||||
public static MultiblockManager<SynchronizedTankData> tankManager = new MultiblockManager<SynchronizedTankData>("dynamicTank");
|
||||
public static MultiblockManager<SynchronizedMatrixData> matrixManager = new MultiblockManager<SynchronizedMatrixData>("inductionMatrix");
|
||||
public static MultiblockManager<SynchronizedBoilerData> boilerManager = new BoilerManager("thermoelectricBoiler");
|
||||
public static MultiblockManager<SynchronizedBoilerData> boilerManager = new MultiblockManager<SynchronizedBoilerData>("thermoelectricBoiler");
|
||||
|
||||
/** FrequencyManagers for various networks */
|
||||
public static FrequencyManager publicTeleporters = new FrequencyManager(Frequency.class);
|
||||
@@ -511,6 +510,9 @@ public class Mekanism
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock2, 1, 5), new Object[] {
|
||||
"ACA", "CIC", "ACA", Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8), Character.valueOf('C'), "ingotCopper", Character.valueOf('A'), "alloyBasic"
|
||||
}));
|
||||
MachineType.RESISTIVE_HEATER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock3, 1, 4), new Object[] {
|
||||
"CRC", "RHR", "CEC", Character.valueOf('C'), "ingotTin", Character.valueOf('R'), "dustRedstone", Character.valueOf('H'), new ItemStack(MekanismBlocks.BasicBlock2, 1, 5), Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem()
|
||||
}));;
|
||||
|
||||
//Energy Cube recipes
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), new Object[] {
|
||||
|
||||
@@ -153,6 +153,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
* 2:1: Solar Neutron Activator
|
||||
* 2:2: Ambient Accumulator
|
||||
* 2:3: Oredictionificator
|
||||
* 2:4: Resistive Heater
|
||||
*
|
||||
* @author AidanBrady
|
||||
*
|
||||
@@ -1315,6 +1316,8 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo
|
||||
return 0;
|
||||
case AMBIENT_ACCUMULATOR:
|
||||
return 0;
|
||||
case RESISTIVE_HEATER:
|
||||
return 100;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
package mekanism.common.content.boiler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.multiblock.MultiblockCache;
|
||||
import mekanism.common.multiblock.MultiblockManager;
|
||||
import mekanism.common.tile.TileEntityMultiblock;
|
||||
import mekanism.common.tile.TileEntityBoilerCasing;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Created by ben on 09/01/15.
|
||||
*/
|
||||
public class BoilerManager extends MultiblockManager<SynchronizedBoilerData>
|
||||
{
|
||||
public BoilerManager(String s)
|
||||
{
|
||||
super(s);
|
||||
}
|
||||
|
||||
public void tickSelf(World world)
|
||||
{
|
||||
ArrayList<String> idsToKill = new ArrayList<String>();
|
||||
HashMap<String, HashSet<Coord4D>> tilesToKill = new HashMap<String, HashSet<Coord4D>>();
|
||||
|
||||
for(Map.Entry<String, MultiblockCache<SynchronizedBoilerData>> entry : inventories.entrySet())
|
||||
{
|
||||
String inventoryID = entry.getKey();
|
||||
|
||||
HashSet<TileEntityBoilerCasing> boilers = new HashSet<TileEntityBoilerCasing>();
|
||||
|
||||
for(Coord4D obj : entry.getValue().locations)
|
||||
{
|
||||
if(obj.dimensionId == world.provider.dimensionId && obj.exists(world))
|
||||
{
|
||||
TileEntity tileEntity = obj.getTileEntity(world);
|
||||
|
||||
if(!(tileEntity instanceof TileEntityMultiblock) || ((TileEntityMultiblock)tileEntity).getManager() != this || (getStructureId(((TileEntityMultiblock<?>)tileEntity)) != null && getStructureId(((TileEntityMultiblock)tileEntity)) != inventoryID))
|
||||
{
|
||||
if(!tilesToKill.containsKey(inventoryID))
|
||||
{
|
||||
tilesToKill.put(inventoryID, new HashSet<Coord4D>());
|
||||
}
|
||||
|
||||
tilesToKill.get(inventoryID).add(obj);
|
||||
}
|
||||
else if(tileEntity instanceof TileEntityBoilerCasing)
|
||||
{
|
||||
((TileEntityBoilerCasing)tileEntity).simulateHeat();
|
||||
boilers.add((TileEntityBoilerCasing) tileEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!boilers.isEmpty())
|
||||
{
|
||||
SynchronizedBoilerData data = boilers.iterator().next().getSynchronizedData();
|
||||
|
||||
if(data != null)
|
||||
{
|
||||
boilers.iterator().next().getSynchronizedData().applyTemperatureChange();
|
||||
}
|
||||
|
||||
for (TileEntityBoilerCasing boiler : boilers)
|
||||
{
|
||||
boiler.applyTemperatureChange();
|
||||
}
|
||||
}
|
||||
|
||||
if(entry.getValue().locations.isEmpty())
|
||||
{
|
||||
idsToKill.add(inventoryID);
|
||||
}
|
||||
}
|
||||
|
||||
for(Map.Entry<String, HashSet<Coord4D>> entry : tilesToKill.entrySet())
|
||||
{
|
||||
for(Coord4D obj : entry.getValue())
|
||||
{
|
||||
inventories.get(entry.getKey()).locations.remove(obj);
|
||||
}
|
||||
}
|
||||
|
||||
for(String inventoryID : idsToKill)
|
||||
{
|
||||
inventories.remove(inventoryID);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -10,11 +10,11 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
|
||||
public class ContainerPortableTank extends Container
|
||||
public class ContainerFluidTank extends Container
|
||||
{
|
||||
private TileEntityFluidTank tileEntity;
|
||||
|
||||
public ContainerPortableTank(InventoryPlayer inventory, TileEntityFluidTank tentity)
|
||||
public ContainerFluidTank(InventoryPlayer inventory, TileEntityFluidTank tentity)
|
||||
{
|
||||
tileEntity = tentity;
|
||||
addSlotToContainer(new Slot(tentity, 0, 146, 19));
|
||||
@@ -0,0 +1,124 @@
|
||||
package mekanism.common.inventory.container;
|
||||
|
||||
import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge;
|
||||
import mekanism.common.tile.TileEntityResistiveHeater;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerResistiveHeater extends Container
|
||||
{
|
||||
private TileEntityResistiveHeater tileEntity;
|
||||
|
||||
public ContainerResistiveHeater(InventoryPlayer inventory, TileEntityResistiveHeater tentity)
|
||||
{
|
||||
tileEntity = tentity;
|
||||
addSlotToContainer(new SlotDischarge(tentity, 0, 28, 35));
|
||||
|
||||
int slotY;
|
||||
|
||||
for(slotY = 0; slotY < 3; slotY++)
|
||||
{
|
||||
for(int slotX = 0; slotX < 9; slotX++)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(slotY = 0; slotY < 9; slotY++)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142));
|
||||
}
|
||||
|
||||
tileEntity.open(inventory.player);
|
||||
tileEntity.openInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
super.onContainerClosed(entityplayer);
|
||||
|
||||
tileEntity.close(entityplayer);
|
||||
tileEntity.closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer)
|
||||
{
|
||||
return tileEntity.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
|
||||
{
|
||||
ItemStack stack = null;
|
||||
Slot currentSlot = (Slot)inventorySlots.get(slotID);
|
||||
|
||||
if(currentSlot != null && currentSlot.getHasStack())
|
||||
{
|
||||
ItemStack slotStack = currentSlot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
if(ChargeUtils.canBeDischarged(slotStack))
|
||||
{
|
||||
if(slotID != 0)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID == 0)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(slotID >= 1 && slotID <= 27)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID > 27)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 1, 27, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == 0)
|
||||
{
|
||||
currentSlot.putStack((ItemStack)null);
|
||||
}
|
||||
else {
|
||||
currentSlot.onSlotChanged();
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == stack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
currentSlot.onPickupFromSlot(player, slotStack);
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -108,6 +108,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
* 2:1: Solar Neutron Activator
|
||||
* 2:2: Ambient Accumulator
|
||||
* 2:3: Oredictionificator
|
||||
* 2:4: Resistive Heater
|
||||
* @author AidanBrady
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -1,26 +1,82 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.IHeatTransfer;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.HeatUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityResistiveHeater extends TileEntityElectricBlock implements IHeatTransfer
|
||||
public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock implements IHeatTransfer
|
||||
{
|
||||
public double energyUsage = 100;
|
||||
|
||||
public double temperature;
|
||||
public double heatToAbsorb = 0;
|
||||
|
||||
/** 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;
|
||||
|
||||
public TileEntityResistiveHeater()
|
||||
{
|
||||
super("ResistiveHeater", MachineType.RESISTIVE_HEATER.baseEnergy);
|
||||
super("machine.resistiveheater", "ResistiveHeater", MachineType.RESISTIVE_HEATER.baseEnergy);
|
||||
inventory = new ItemStack[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
simulateHeat();
|
||||
applyTemperatureChange();
|
||||
super.onUpdate();
|
||||
|
||||
if(worldObj.isRemote && updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.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(0, this);
|
||||
|
||||
double toUse = Math.min(getEnergy(), energyUsage);
|
||||
heatToAbsorb += toUse/general.energyPerHeat;
|
||||
setEnergy(getEnergy() - toUse);
|
||||
|
||||
simulateHeat();
|
||||
applyTemperatureChange();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -28,7 +84,9 @@ public class TileEntityResistiveHeater extends TileEntityElectricBlock implement
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
energyUsage = nbtTags.getDouble("energyUsage");
|
||||
temperature = nbtTags.getDouble("temperature");
|
||||
clientActive = isActive = nbtTags.getBoolean("isActive");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -36,7 +94,47 @@ public class TileEntityResistiveHeater extends TileEntityElectricBlock implement
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setDouble("energyUsage", energyUsage);
|
||||
nbtTags.setDouble("temperature", temperature);
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteBuf dataStream)
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
energyUsage = dataStream.readDouble();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
energyUsage = dataStream.readDouble();
|
||||
temperature = dataStream.readDouble();
|
||||
clientActive = dataStream.readBoolean();
|
||||
maxEnergy = dataStream.readDouble();
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
updateDelay = general.UPDATE_DELAY;
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(energyUsage);
|
||||
data.add(temperature);
|
||||
data.add(isActive);
|
||||
data.add(maxEnergy);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,7 +179,7 @@ public class TileEntityResistiveHeater extends TileEntityElectricBlock implement
|
||||
@Override
|
||||
public boolean canConnectHeat(ForgeDirection side)
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,4 +187,36 @@ public class TileEntityResistiveHeater extends TileEntityElectricBlock implement
|
||||
{
|
||||
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 true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lightUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user