diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index 08fea90fe..e2e3aceda 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -30,6 +30,7 @@ import mekanism.client.gui.GuiOsmiumCompressor; import mekanism.client.gui.GuiPRC; import mekanism.client.gui.GuiPasswordEnter; import mekanism.client.gui.GuiPasswordModify; +import mekanism.client.gui.GuiPortableTank; import mekanism.client.gui.GuiPortableTeleporter; import mekanism.client.gui.GuiPrecisionSawmill; import mekanism.client.gui.GuiPurificationChamber; @@ -445,6 +446,8 @@ public class ClientProxy extends CommonProxy return new GuiSeismicVibrator(player.inventory, (TileEntitySeismicVibrator)tileEntity); case 40: return new GuiPRC(player.inventory, (TileEntityPRC)tileEntity); + case 41: + return new GuiPortableTank(player.inventory, (TileEntityPortableTank)tileEntity); } return null; diff --git a/src/main/java/mekanism/client/gui/GuiPortableTank.java b/src/main/java/mekanism/client/gui/GuiPortableTank.java new file mode 100644 index 000000000..3bc12108c --- /dev/null +++ b/src/main/java/mekanism/client/gui/GuiPortableTank.java @@ -0,0 +1,60 @@ +package mekanism.client.gui; + +import mekanism.client.gui.GuiFluidGauge.IFluidInfoHandler; +import mekanism.client.gui.GuiSlot.SlotOverlay; +import mekanism.client.gui.GuiSlot.SlotType; +import mekanism.common.inventory.container.ContainerPortableTank; +import mekanism.common.tile.TileEntityPortableTank; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraftforge.fluids.FluidTank; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class GuiPortableTank extends GuiMekanism +{ + public TileEntityPortableTank tileEntity; + + public GuiPortableTank(InventoryPlayer inventory, TileEntityPortableTank tentity) + { + super(new ContainerPortableTank(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiPortableTank.png"))); + guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() + { + @Override + public FluidTank getTank() + { + return tileEntity.fluidTank; + } + }, GuiFluidGauge.Type.WIDE, this, MekanismUtils.getResource(ResourceType.GUI, "GuiPortableTank.png"), 55, 18)); + guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiPortableTank.png"), 16, 34).with(SlotOverlay.INPUT)); + guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiPortableTank.png"), 142, 34).with(SlotOverlay.OUTPUT)); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + fontRendererObj.drawString(tileEntity.getInventoryName(), 43, 6, 0x404040); + fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiPortableTank.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); + } +} diff --git a/src/main/java/mekanism/client/gui/GuiSlot.java b/src/main/java/mekanism/client/gui/GuiSlot.java index 6f2d22200..2e22eadbe 100644 --- a/src/main/java/mekanism/client/gui/GuiSlot.java +++ b/src/main/java/mekanism/client/gui/GuiSlot.java @@ -103,7 +103,9 @@ public class GuiSlot extends GuiElement { MINUS(18, 18, 0, 18), PLUS(18, 18, 18, 18), - POWER(18, 18, 36, 18); + POWER(18, 18, 36, 18), + INPUT(18, 18, 54, 18), + OUTPUT(18, 18, 72, 18); public int width; public int height; diff --git a/src/main/java/mekanism/client/model/ModelPortableTank.java b/src/main/java/mekanism/client/model/ModelPortableTank.java index 3e9faf40b..9e4ca8367 100644 --- a/src/main/java/mekanism/client/model/ModelPortableTank.java +++ b/src/main/java/mekanism/client/model/ModelPortableTank.java @@ -2,7 +2,10 @@ package mekanism.client.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class ModelPortableTank extends ModelBase { ModelRenderer Base; diff --git a/src/main/java/mekanism/client/model/ModelPressurizedReactionChamber.java b/src/main/java/mekanism/client/model/ModelPressurizedReactionChamber.java index 7e9c8ad59..5a8226c28 100644 --- a/src/main/java/mekanism/client/model/ModelPressurizedReactionChamber.java +++ b/src/main/java/mekanism/client/model/ModelPressurizedReactionChamber.java @@ -2,7 +2,10 @@ package mekanism.client.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +@SideOnly(Side.CLIENT) public class ModelPressurizedReactionChamber extends ModelBase { ModelRenderer Base; diff --git a/src/main/java/mekanism/common/CommonProxy.java b/src/main/java/mekanism/common/CommonProxy.java index 8e0a1d56c..86ca36dac 100644 --- a/src/main/java/mekanism/common/CommonProxy.java +++ b/src/main/java/mekanism/common/CommonProxy.java @@ -25,6 +25,7 @@ import mekanism.common.inventory.container.ContainerGasTank; import mekanism.common.inventory.container.ContainerMetallurgicInfuser; import mekanism.common.inventory.container.ContainerNull; import mekanism.common.inventory.container.ContainerPRC; +import mekanism.common.inventory.container.ContainerPortableTank; import mekanism.common.inventory.container.ContainerRobitCrafting; import mekanism.common.inventory.container.ContainerRobitInventory; import mekanism.common.inventory.container.ContainerRobitMain; @@ -412,6 +413,8 @@ public class CommonProxy return new ContainerSeismicVibrator(player.inventory, (TileEntitySeismicVibrator)tileEntity); case 40: return new ContainerPRC(player.inventory, (TileEntityPRC)tileEntity); + case 41: + return new ContainerPortableTank(player.inventory, (TileEntityPortableTank)tileEntity); } return null; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerPortableTank.java b/src/main/java/mekanism/common/inventory/container/ContainerPortableTank.java new file mode 100644 index 000000000..98d8c4888 --- /dev/null +++ b/src/main/java/mekanism/common/inventory/container/ContainerPortableTank.java @@ -0,0 +1,123 @@ +package mekanism.common.inventory.container; + +import mekanism.common.inventory.slot.SlotOutput; +import mekanism.common.tile.TileEntityPortableTank; +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; +import net.minecraftforge.fluids.FluidContainerRegistry; + +public class ContainerPortableTank extends Container +{ + private TileEntityPortableTank tileEntity; + + public ContainerPortableTank(InventoryPlayer inventory, TileEntityPortableTank tentity) + { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 146, 20)); + addSlotToContainer(new SlotOutput(tentity, 1, 146, 51)); + int slotX; + + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 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(FluidContainerRegistry.isEmptyContainer(slotStack) || FluidContainerRegistry.isFilledContainer(slotStack)) + { + if(slotID != 0 && slotID != 1) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 2 && slotID <= 8) + { + if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 28) + { + if(!mergeItemStack(slotStack, 2, 28, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 2, 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; + } +} diff --git a/src/main/java/mekanism/common/item/ItemBlockMachine.java b/src/main/java/mekanism/common/item/ItemBlockMachine.java index ee6049595..0e943c8f3 100644 --- a/src/main/java/mekanism/common/item/ItemBlockMachine.java +++ b/src/main/java/mekanism/common/item/ItemBlockMachine.java @@ -95,6 +95,9 @@ import cpw.mods.fml.relauncher.SideOnly; * 1:6: Chemical Dissolution Chamber * 1:7: Chemical Washer * 1:8: Chemical Crystallizer + * 1:9: Seismic Vibrator + * 1:10: Pressurized Reaction Chamber + * 1:11: Portable Tank * @author AidanBrady * */ @@ -151,6 +154,11 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec list.add(EnumColor.INDIGO + MekanismUtils.localize("tooltip.auth") + ": " + EnumColor.GREY + LangUtils.transYesNo(getAuthenticated(itemstack))); list.add(EnumColor.INDIGO + MekanismUtils.localize("tooltip.locked") + ": " + EnumColor.GREY + LangUtils.transYesNo(getLocked(itemstack))); } + + if(type == MachineType.PORTABLE_TANK) + { + list.add(EnumColor.INDIGO + MekanismUtils.localize("tooltip.portableTank.bucketMode") + ": " + EnumColor.GREY + LangUtils.transYesNo(getBucketMode(itemstack))); + } if(type.isElectric) { @@ -180,6 +188,19 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec list.addAll(MekanismUtils.splitLines(type.getDescription())); } } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + { + MachineType type = MachineType.get(stack); + + if(type == MachineType.PORTABLE_TANK && getBucketMode(stack)) + { + return false; + } + + return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ); + } @Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) @@ -448,7 +469,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } else if(type == MachineType.PORTABLE_TANK) { - if(world.isRemote) + if(world != null && !world.isRemote) { float targetScale = (float)(getFluidStack(itemstack) != null ? getFluidStack(itemstack).amount : 0)/TileEntityPortableTank.MAX_FLUID; diff --git a/src/main/java/mekanism/common/tile/TileEntityGasTank.java b/src/main/java/mekanism/common/tile/TileEntityGasTank.java index 5e63643ca..ac90ace80 100644 --- a/src/main/java/mekanism/common/tile/TileEntityGasTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityGasTank.java @@ -108,7 +108,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH return itemstack.getItem() instanceof IGasItem && (gasTank.getGas() == null || ((IGasItem)itemstack.getItem()).canProvideGas(itemstack, gasTank.getGas().getGas())); } - return true; + return false; } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityPortableTank.java b/src/main/java/mekanism/common/tile/TileEntityPortableTank.java index b975733c6..ff947ab93 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPortableTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityPortableTank.java @@ -6,10 +6,12 @@ import java.util.ArrayList; import mekanism.api.Coord4D; import mekanism.api.IConfigurable; +import mekanism.api.gas.IGasItem; import mekanism.common.IActiveState; import mekanism.common.ISustainedTank; import mekanism.common.Mekanism; import mekanism.common.network.PacketTileEntity.TileEntityMessage; +import mekanism.common.util.InventoryUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.PipeUtils; import net.minecraft.entity.player.EntityPlayer; @@ -205,6 +207,48 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements } } } + + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) + { + if(slotID == 1) + { + return (itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) == null); + } + else if(slotID == 0) + { + return (itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null && + ((IGasItem)itemstack.getItem()).getGas(itemstack).amount == ((IGasItem)itemstack.getItem()).getMaxGas(itemstack)); + } + + return false; + } + + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) + { + if(slotID == 0) + { + return FluidContainerRegistry.isContainer(itemstack); + } + + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) + { + if(side == 0) + { + return new int[] {1}; + } + else if(side == 1) + { + return new int[] {0}; + } + + return InventoryUtils.EMPTY; + } @Override public void writeToNBT(NBTTagCompound nbtTags) diff --git a/src/main/resources/assets/mekanism/gui/elements/GuiRecipeType.png b/src/main/resources/assets/mekanism/gui/elements/GuiRecipeType.png index eeaf1d895..704d60972 100644 Binary files a/src/main/resources/assets/mekanism/gui/elements/GuiRecipeType.png and b/src/main/resources/assets/mekanism/gui/elements/GuiRecipeType.png differ diff --git a/src/main/resources/assets/mekanism/gui/elements/GuiSlot.png b/src/main/resources/assets/mekanism/gui/elements/GuiSlot.png index 183afdfe8..dc64827db 100644 Binary files a/src/main/resources/assets/mekanism/gui/elements/GuiSlot.png and b/src/main/resources/assets/mekanism/gui/elements/GuiSlot.png differ diff --git a/src/main/resources/assets/mekanism/lang/en_US.lang b/src/main/resources/assets/mekanism/lang/en_US.lang index bc3142690..11ea8c315 100644 --- a/src/main/resources/assets/mekanism/lang/en_US.lang +++ b/src/main/resources/assets/mekanism/lang/en_US.lang @@ -471,6 +471,8 @@ tooltip.keysFound=Key(s) found tooltip.noKey=No key tooltip.hp=HP +tooltip.portableTank.bucketMode=Bucket Mode + tooltip.disassembler.normal=normal tooltip.disassembler.slow=slow tooltip.disassembler.fast=fast @@ -516,6 +518,8 @@ tooltip.ChemicalDissolutionChamber=An ultimate machine used to !nchemically diss tooltip.ChemicalWasher=An ultimate machine that cleans unprocessed !nslurry and prepares it for crystallization. tooltip.ChemicalCrystallizer=An ultimate machine used to crystallize !npurified ore slurry into ore crystals. tooltip.SeismicVibrator=A machine that uses seismic vibrations to !nprovide information on differing layers !nof the world. +tooltip.PressurizedReactionChamber=An advanced machine that processes a solid, liquid and gaseous mixture and creates both a gaseous and solid product. +tooltip.PortableTank=A handy, portable tank that lets you carry 14 !nbuckets of fluid wherever you !nplease. Also doubles as a bucket! tooltip.HeatGenerator=A generator that uses the heat of lava or !nother burnable resources to produce energy. tooltip.SolarGenerator=A generator that uses the power of the !nsun to produce energy.