Lots of work on resistive heaters, still mostly unfinished

This commit is contained in:
aidancbrady 2016-02-26 19:51:37 -05:00
parent a31bc02e83
commit 9d55f6cc8a
19 changed files with 391 additions and 115 deletions

View file

@ -61,6 +61,7 @@ public class MekanismConfig
public static double evaporationTempMultiplier = 0.1;
public static double evaporationSolarMultiplier = 0.2;
public static double evaporationMaxTemp = 3000;
public static double energyPerHeat = 1000;
}
public static class client

View file

@ -29,6 +29,7 @@ import mekanism.client.gui.GuiEnergyCube;
import mekanism.client.gui.GuiEnrichmentChamber;
import mekanism.client.gui.GuiEntangledBlock;
import mekanism.client.gui.GuiFactory;
import mekanism.client.gui.GuiFluidTank;
import mekanism.client.gui.GuiFluidicPlenisher;
import mekanism.client.gui.GuiGasTank;
import mekanism.client.gui.GuiInductionMatrix;
@ -41,9 +42,9 @@ import mekanism.client.gui.GuiOsmiumCompressor;
import mekanism.client.gui.GuiPRC;
import mekanism.client.gui.GuiPasswordEnter;
import mekanism.client.gui.GuiPasswordModify;
import mekanism.client.gui.GuiFluidTank;
import mekanism.client.gui.GuiPrecisionSawmill;
import mekanism.client.gui.GuiPurificationChamber;
import mekanism.client.gui.GuiResistiveHeater;
import mekanism.client.gui.GuiRobitCrafting;
import mekanism.client.gui.GuiRobitInventory;
import mekanism.client.gui.GuiRobitMain;
@ -53,9 +54,9 @@ import mekanism.client.gui.GuiRotaryCondensentrator;
import mekanism.client.gui.GuiSeismicReader;
import mekanism.client.gui.GuiSeismicVibrator;
import mekanism.client.gui.GuiSideConfiguration;
import mekanism.client.gui.GuiThermalEvaporationController;
import mekanism.client.gui.GuiSolarNeutronActivator;
import mekanism.client.gui.GuiTeleporter;
import mekanism.client.gui.GuiThermalEvaporationController;
import mekanism.client.gui.GuiTransporterConfig;
import mekanism.client.gui.GuiUpgradeManagement;
import mekanism.client.render.MekanismRenderer;
@ -85,6 +86,7 @@ import mekanism.client.render.tileentity.RenderElectricChest;
import mekanism.client.render.tileentity.RenderElectricPump;
import mekanism.client.render.tileentity.RenderElectrolyticSeparator;
import mekanism.client.render.tileentity.RenderEnergyCube;
import mekanism.client.render.tileentity.RenderFluidTank;
import mekanism.client.render.tileentity.RenderFluidicPlenisher;
import mekanism.client.render.tileentity.RenderGasTank;
import mekanism.client.render.tileentity.RenderLaser;
@ -93,13 +95,12 @@ import mekanism.client.render.tileentity.RenderLaserTractorBeam;
import mekanism.client.render.tileentity.RenderLogisticalSorter;
import mekanism.client.render.tileentity.RenderMetallurgicInfuser;
import mekanism.client.render.tileentity.RenderObsidianTNT;
import mekanism.client.render.tileentity.RenderFluidTank;
import mekanism.client.render.tileentity.RenderPressurizedReactionChamber;
import mekanism.client.render.tileentity.RenderRotaryCondensentrator;
import mekanism.client.render.tileentity.RenderThermalEvaporationController;
import mekanism.client.render.tileentity.RenderSeismicVibrator;
import mekanism.client.render.tileentity.RenderSolarNeutronActivator;
import mekanism.client.render.tileentity.RenderTeleporter;
import mekanism.client.render.tileentity.RenderThermalEvaporationController;
import mekanism.common.CommonProxy;
import mekanism.common.Mekanism;
import mekanism.common.MekanismBlocks;
@ -144,6 +145,7 @@ import mekanism.common.tile.TileEntityEnergyCube;
import mekanism.common.tile.TileEntityEnrichmentChamber;
import mekanism.common.tile.TileEntityEntangledBlock;
import mekanism.common.tile.TileEntityFactory;
import mekanism.common.tile.TileEntityFluidTank;
import mekanism.common.tile.TileEntityFluidicPlenisher;
import mekanism.common.tile.TileEntityGasTank;
import mekanism.common.tile.TileEntityInductionCasing;
@ -160,15 +162,15 @@ import mekanism.common.tile.TileEntityObsidianTNT;
import mekanism.common.tile.TileEntityOredictionificator;
import mekanism.common.tile.TileEntityOsmiumCompressor;
import mekanism.common.tile.TileEntityPRC;
import mekanism.common.tile.TileEntityFluidTank;
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.TileEntityThermalEvaporationController;
import mekanism.common.tile.TileEntitySolarNeutronActivator;
import mekanism.common.tile.TileEntityStructuralGlass;
import mekanism.common.tile.TileEntityTeleporter;
import mekanism.common.tile.TileEntityThermalEvaporationController;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
@ -333,6 +335,7 @@ public class ClientProxy extends CommonProxy
GameRegistry.registerTileEntity(TileEntityInductionProvider.class, "InductionProvider");
GameRegistry.registerTileEntity(TileEntityOredictionificator.class, "Oredictionificator");
GameRegistry.registerTileEntity(TileEntityStructuralGlass.class, "StructuralGlass");
GameRegistry.registerTileEntity(TileEntityResistiveHeater.class, "ResistiveHeater");
}
@Override
@ -513,6 +516,8 @@ public class ClientProxy extends CommonProxy
return new GuiTransporterConfig(player, (ISideConfiguration)tileEntity);
case 52:
return new GuiOredictionificator(player.inventory, (TileEntityOredictionificator)tileEntity);
case 53:
return new GuiResistiveHeater(player.inventory, (TileEntityResistiveHeater)tileEntity);
}
return null;

View file

@ -66,7 +66,7 @@ public class GuiElectricPump extends GuiMekanism
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040);
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize / 2) - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), 6, 0x404040);
fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040);
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00);

View file

@ -6,7 +6,7 @@ import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiFluidGauge.IFluidInfoHandler;
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
import mekanism.client.gui.element.GuiSlot.SlotType;
import mekanism.common.inventory.container.ContainerPortableTank;
import mekanism.common.inventory.container.ContainerFluidTank;
import mekanism.common.tile.TileEntityFluidTank;
import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils;
@ -25,7 +25,7 @@ public class GuiFluidTank extends GuiMekanism
public GuiFluidTank(InventoryPlayer inventory, TileEntityFluidTank tentity)
{
super(tentity, new ContainerPortableTank(inventory, tentity));
super(tentity, new ContainerFluidTank(inventory, tentity));
tileEntity = tentity;
guiElements.add(new GuiContainerEditMode(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")));
guiElements.add(new GuiFluidGauge(new IFluidInfoHandler()

View file

@ -66,7 +66,7 @@ public class GuiFluidicPlenisher extends GuiMekanism
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040);
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize / 2) - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), 6, 0x404040);
fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040);
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00);
fontRendererObj.drawString(LangUtils.localize("gui.finished") + ": " + LangUtils.transYesNo(tileEntity.finishedCalc), 51, 35, 0x00CD00);

View file

@ -0,0 +1,96 @@
package mekanism.client.gui;
import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
import mekanism.client.gui.element.GuiSlot.SlotType;
import mekanism.common.inventory.container.ContainerResistiveHeater;
import mekanism.common.tile.TileEntityResistiveHeater;
import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiResistiveHeater extends GuiMekanism
{
public TileEntityResistiveHeater tileEntity;
private GuiTextField energyUsageField;
public GuiResistiveHeater(InventoryPlayer inventory, TileEntityResistiveHeater tentity)
{
super(tentity, new ContainerResistiveHeater(inventory, tentity));
tileEntity = tentity;
guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 27, 34).with(SlotOverlay.POWER));
}
@Override
public void initGui()
{
super.initGui();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
String prevEnergyUsage = energyUsageField != null ? energyUsageField.getText() : "";
energyUsageField = new GuiTextField(fontRendererObj, guiWidth + 50, guiHeight + 104, 86, 11);
energyUsageField.setMaxStringLength(7);
energyUsageField.setEnableBackgroundDrawing(false);
energyUsageField.setText(prevEnergyUsage);
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize / 2) - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), 6, 0x404040);
fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040);
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
}
private void setEnergyUsage()
{
}
@Override
public void keyTyped(char c, int i)
{
if(!energyUsageField.isFocused() || i == Keyboard.KEY_ESCAPE)
{
super.keyTyped(c, i);
}
if(energyUsageField.isFocused() && i == Keyboard.KEY_RETURN)
{
setEnergyUsage();
return;
}
if(Character.isDigit(c) || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT)
{
energyUsageField.textboxKeyTyped(c, i);
}
}
}

View file

@ -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;

View file

@ -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[] {

View file

@ -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;
}

View file

@ -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);
}
}
}

View file

@ -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));

View file

@ -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;
}
}

View file

@ -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
*
*/

View file

@ -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;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -149,6 +149,7 @@ tile.MachineBlock2.LaserTractorBeam.name=Laser Tractor Beam
//Machine Block 3 (third ID iteration)
tile.MachineBlock3.SolarNeutronActivator.name=Solar Neutron Activator
tile.MachineBlock3.Oredictionificator.name=Oredictionificator
tile.MachineBlock3.ResistiveHeater.name=Resistive Heater
//Plastic
tile.PlasticBlock.name=Plastic Block
@ -783,6 +784,7 @@ tooltip.LaserTractorBeam=A block used to merge and redirect laser beams. Collect
tooltip.SolarNeutronActivator=A machine that directs the neutron radiation of the sun into its internal reservoir, allowing for the slow creation of various isotopes.
tooltip.Oredictionificator=A machine used to unify and translate between various items and blocks using the Ore Dictionary.
tooltip.Factory=A machine that serves as an upgrade to regular machinery, allowing for multiple processing operations to occur at once.
tooltip.ResistiveHeater=A condensed, coiled resistor capable of converting electrical energy directly into heat energy.
tooltip.HeatGenerator=A generator that uses the heat of lava or other burnable resources to produce energy.
tooltip.SolarGenerator=A generator that uses the power of the sun to produce energy.

View file

@ -37,6 +37,7 @@
"tile.machine.smelter": {"category": "block", "sounds": [{"name": "Smelter", "stream": false}]},
"tile.machine.laser": {"category": "block", "sounds": [{"name": "Laser", "stream": false}]},
"tile.machine.fusionreactor": {"category": "block", "sounds": [{"name": "FusionReactor", "stream": false}]},
"tile.machine.resistiveheater": {"category": "block", "sounds": [{"name": "ResistiveHeater", "stream": false}]},
"tile.christmas.1": {"category": "block", "sounds": [{"name": "holiday/Nutcracker1", "stream": false}]},
"tile.christmas.2": {"category": "block", "sounds": [{"name": "holiday/Nutcracker2", "stream": false}]},