Precision Sawmill and overall Chance Machine framework GUI & Container
This commit is contained in:
parent
19b36e901b
commit
5dfee9ec7a
|
@ -26,6 +26,7 @@ import mekanism.client.gui.GuiOsmiumCompressor;
|
|||
import mekanism.client.gui.GuiPasswordEnter;
|
||||
import mekanism.client.gui.GuiPasswordModify;
|
||||
import mekanism.client.gui.GuiPortableTeleporter;
|
||||
import mekanism.client.gui.GuiPrecisionSawmill;
|
||||
import mekanism.client.gui.GuiPurificationChamber;
|
||||
import mekanism.client.gui.GuiRobitCrafting;
|
||||
import mekanism.client.gui.GuiRobitInventory;
|
||||
|
@ -419,7 +420,8 @@ public class ClientProxy extends CommonProxy
|
|||
return new GuiElectrolyticSeparator(player.inventory, (TileEntityElectrolyticSeparator)tileEntity);
|
||||
case 33:
|
||||
return new GuiSalinationController(player.inventory, (TileEntitySalinationController)tileEntity);
|
||||
|
||||
case 34:
|
||||
return new GuiPrecisionSawmill(player.inventory, (TileEntityPrecisionSawmill)tileEntity);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -1,6 +1,68 @@
|
|||
package mekanism.client.gui;
|
||||
|
||||
public class GuiChanceMachine
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.ListUtils;
|
||||
import mekanism.client.gui.GuiEnergyInfo.IInfoHandler;
|
||||
import mekanism.common.inventory.container.ContainerChanceMachine;
|
||||
import mekanism.common.tile.TileEntityChanceMachine;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiChanceMachine extends GuiMekanism
|
||||
{
|
||||
|
||||
public TileEntityChanceMachine tileEntity;
|
||||
|
||||
public GuiChanceMachine(InventoryPlayer inventory, TileEntityChanceMachine tentity)
|
||||
{
|
||||
super(tentity, new ContainerChanceMachine(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
|
||||
guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation));
|
||||
guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.guiLocation));
|
||||
guiElements.add(new GuiConfigurationTab(this, tileEntity, tileEntity.guiLocation));
|
||||
guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15));
|
||||
guiElements.add(new GuiEnergyInfo(new IInfoHandler() {
|
||||
@Override
|
||||
public List<String> getInfo()
|
||||
{
|
||||
String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity.getSpeedMultiplier(), tileEntity.getEnergyMultiplier(), tileEntity.ENERGY_PER_TICK));
|
||||
return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy()));
|
||||
}
|
||||
}, this, tileEntity, tileEntity.guiLocation));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
||||
fontRenderer.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(tileEntity.guiLocation);
|
||||
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);
|
||||
|
||||
int xAxis = mouseX - guiWidth;
|
||||
int yAxis = mouseY - guiHeight;
|
||||
|
||||
int displayInt;
|
||||
|
||||
displayInt = tileEntity.getScaledProgress(24);
|
||||
drawTexturedModalRect(guiWidth + 79, guiHeight + 39, 176, 0, displayInt + 1, 7);
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
package mekanism.client.gui;
|
||||
|
||||
public class GuiPrecisionSawmill
|
||||
import mekanism.common.tile.TileEntityChanceMachine;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
public class GuiPrecisionSawmill extends GuiChanceMachine
|
||||
{
|
||||
|
||||
public GuiPrecisionSawmill(InventoryPlayer inventory, TileEntityChanceMachine tentity)
|
||||
{
|
||||
super(inventory, tentity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.io.File;
|
|||
|
||||
import mekanism.common.entity.EntityRobit;
|
||||
import mekanism.common.inventory.container.ContainerAdvancedElectricMachine;
|
||||
import mekanism.common.inventory.container.ContainerChanceMachine;
|
||||
import mekanism.common.inventory.container.ContainerChemicalInfuser;
|
||||
import mekanism.common.inventory.container.ContainerChemicalOxidizer;
|
||||
import mekanism.common.inventory.container.ContainerDictionary;
|
||||
|
@ -29,6 +30,7 @@ import mekanism.common.inventory.container.ContainerTeleporter;
|
|||
import mekanism.common.tile.TileEntityAdvancedElectricMachine;
|
||||
import mekanism.common.tile.TileEntityAdvancedFactory;
|
||||
import mekanism.common.tile.TileEntityBin;
|
||||
import mekanism.common.tile.TileEntityChanceMachine;
|
||||
import mekanism.common.tile.TileEntityChargepad;
|
||||
import mekanism.common.tile.TileEntityChemicalInfuser;
|
||||
import mekanism.common.tile.TileEntityChemicalInjectionChamber;
|
||||
|
@ -359,6 +361,8 @@ public class CommonProxy
|
|||
return new ContainerElectrolyticSeparator(player.inventory, (TileEntityElectrolyticSeparator)tileEntity);
|
||||
case 33:
|
||||
return new ContainerSalinationController(player.inventory, (TileEntitySalinationController)tileEntity);
|
||||
case 34:
|
||||
return new ContainerChanceMachine(player.inventory, (TileEntityChanceMachine)tileEntity);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -1116,7 +1116,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
|
|||
CHEMICAL_INFUSER(Mekanism.machineBlock2ID, 2, "ChemicalInfuser", 30, 20000, TileEntityChemicalInfuser.class, true, false),
|
||||
CHEMICAL_INJECTION_CHAMBER(Mekanism.machineBlock2ID, 3, "ChemicalInjectionChamber", 31, Mekanism.chemicalInjectionChamberUsage*400, TileEntityChemicalInjectionChamber.class, false, true),
|
||||
ELECTROLYTIC_SEPARATOR(Mekanism.machineBlock2ID, 4, "ElectrolyticSeparator", 32, 20000, TileEntityElectrolyticSeparator.class, true, false),
|
||||
PRECISION_SAWMILL(Mekanism.machineBlock2ID, 5, "PrecisionSawmill", 33, Mekanism.precisionSawmillUsage*400, TileEntityPrecisionSawmill.class, false, true);
|
||||
PRECISION_SAWMILL(Mekanism.machineBlock2ID, 5, "PrecisionSawmill", 34, Mekanism.precisionSawmillUsage*400, TileEntityPrecisionSawmill.class, false, true);
|
||||
|
||||
public int typeId;
|
||||
public int meta;
|
||||
|
|
|
@ -1,6 +1,170 @@
|
|||
package mekanism.common.inventory.container;
|
||||
|
||||
public class ContainerChanceMachine
|
||||
import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge;
|
||||
import mekanism.common.inventory.slot.SlotMachineUpgrade;
|
||||
import mekanism.common.inventory.slot.SlotOutput;
|
||||
import mekanism.common.item.ItemMachineUpgrade;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.tile.TileEntityChanceMachine;
|
||||
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 ContainerChanceMachine extends Container
|
||||
{
|
||||
|
||||
private TileEntityChanceMachine tileEntity;
|
||||
|
||||
public ContainerChanceMachine(InventoryPlayer inventory, TileEntityChanceMachine tentity)
|
||||
{
|
||||
tileEntity = tentity;
|
||||
addSlotToContainer(new Slot(tentity, 0, 56, 17));
|
||||
addSlotToContainer(new SlotDischarge(tentity, 1, 56, 53));
|
||||
addSlotToContainer(new SlotOutput(tentity, 2, 116, 35));
|
||||
addSlotToContainer(new SlotMachineUpgrade(tentity, 3, 180, 11));
|
||||
addSlotToContainer(new SlotOutput(tentity, 4, 132, 35));
|
||||
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.openChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
super.onContainerClosed(entityplayer);
|
||||
|
||||
tileEntity.close(entityplayer);
|
||||
tileEntity.closeChest();
|
||||
}
|
||||
|
||||
@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(slotID == 2 || slotID == 4)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(ChargeUtils.canBeDischarged(slotStack))
|
||||
{
|
||||
if(slotID != 1)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 1, 2, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID == 1)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(RecipeHandler.getChanceOutput(slotStack, false, tileEntity.getRecipes()) != null)
|
||||
{
|
||||
if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3 && slotID != 4)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(slotStack.getItem() instanceof ItemMachineUpgrade)
|
||||
{
|
||||
if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 3, 4, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(slotID >= 5 && slotID <= 31)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 32, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID > 31)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 5, 31, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 5, 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ public class ContainerElectricMachine extends Container
|
|||
{
|
||||
if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3)
|
||||
{
|
||||
if (!mergeItemStack(slotStack, 0, 1, false))
|
||||
if(!mergeItemStack(slotStack, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Loading…
Reference in a new issue