More portable tank work, mainly on GUIs
This commit is contained in:
parent
adc8a9bc23
commit
a3784d1fe7
13 changed files with 269 additions and 3 deletions
|
@ -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;
|
||||
|
|
60
src/main/java/mekanism/client/gui/GuiPortableTank.java
Normal file
60
src/main/java/mekanism/client/gui/GuiPortableTank.java
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 873 B After Width: | Height: | Size: 2.8 KiB |
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue