mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-03-11 12:15:35 +00:00
wood burner GUI
This commit is contained in:
parent
505bdbf863
commit
a44f31279b
@ -0,0 +1,103 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.inventory.SlotTakeOnly;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineWoodBurner;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
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.minecraft.tileentity.TileEntityFurnace;
|
||||
|
||||
public class ContainerMachineWoodBurner extends Container {
|
||||
|
||||
protected TileEntityMachineWoodBurner burner;
|
||||
|
||||
public ContainerMachineWoodBurner(InventoryPlayer invPlayer, TileEntityMachineWoodBurner burner) {
|
||||
this.burner = burner;
|
||||
this.burner.openInventory();
|
||||
|
||||
//Fuel
|
||||
this.addSlotToContainer(new Slot(burner, 0, 26, 18));
|
||||
//Ashes
|
||||
this.addSlotToContainer(new SlotTakeOnly(burner, 1, 26, 54));
|
||||
//Fluid ID
|
||||
this.addSlotToContainer(new Slot(burner, 2, 98, 54));
|
||||
//Fluid Container
|
||||
this.addSlotToContainer(new Slot(burner, 3, 98, 18));
|
||||
this.addSlotToContainer(new SlotTakeOnly(burner, 4, 98, 36));
|
||||
//Battery
|
||||
this.addSlotToContainer(new Slot(burner, 5, 143, 54));
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 9; j++) {
|
||||
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 104 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 162));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||
ItemStack stack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(index);
|
||||
|
||||
if(slot != null && slot.getHasStack()) {
|
||||
ItemStack originalStack = slot.getStack();
|
||||
stack = originalStack.copy();
|
||||
|
||||
if(index <= 5) {
|
||||
if(!this.mergeItemStack(originalStack, 6, this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onSlotChange(originalStack, stack);
|
||||
|
||||
} else {
|
||||
|
||||
if(stack.getItem() instanceof IBatteryItem) {
|
||||
if(!this.mergeItemStack(originalStack, 5, 6, false)) {
|
||||
return null;
|
||||
}
|
||||
} else if(stack.getItem() instanceof IItemFluidIdentifier) {
|
||||
if(!this.mergeItemStack(originalStack, 2, 3, false)) {
|
||||
return null;
|
||||
}
|
||||
} else if(TileEntityFurnace.isItemFuel(stack)) {
|
||||
if(!this.mergeItemStack(originalStack, 2, 3, false)) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if(!this.mergeItemStack(originalStack, 3, 4, false)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(originalStack.stackSize == 0) {
|
||||
slot.putStack((ItemStack) null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return burner.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
this.burner.closeInventory();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerMachineWoodBurner;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.packet.NBTControlPacket;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineWoodBurner;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIMachineWoodBurner extends GuiInfoContainer {
|
||||
|
||||
private TileEntityMachineWoodBurner burner;
|
||||
private final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/generators/gui_wood_burner_alt.png");
|
||||
|
||||
public GUIMachineWoodBurner(InventoryPlayer invPlayer, TileEntityMachineWoodBurner tedf) {
|
||||
super(new ContainerMachineWoodBurner(invPlayer, tedf));
|
||||
burner = tedf;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 186;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float f) {
|
||||
super.drawScreen(mouseX, mouseY, f);
|
||||
this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 143, guiTop + 18, 16, 34, burner.power, burner.maxPower);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int i) {
|
||||
super.mouseClicked(x, y, i);
|
||||
|
||||
if(guiLeft + 53 <= x && guiLeft + 53 + 16 > x && guiTop + 17 < y && guiTop + 17 + 15 >= y) {
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setBoolean("toggle", false);
|
||||
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, burner.xCoord, burner.yCoord, burner.zCoord));
|
||||
}
|
||||
|
||||
if(guiLeft + 46 <= x && guiLeft + 46 + 30 > x && guiTop + 37 < y && guiTop + 37 + 14 >= y) {
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setBoolean("switch", false);
|
||||
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, burner.xCoord, burner.yCoord, burner.zCoord));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.burner.hasCustomInventoryName() ? this.burner.getInventoryName() : I18n.format(this.burner.getInventoryName());
|
||||
|
||||
this.fontRendererObj.drawString(name, 70 - this.fontRendererObj.getStringWidth(name) / 2, 6, 0xffffff);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float interp, int x, int y) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
if(burner.liquidBurn) {
|
||||
drawTexturedModalRect(guiLeft + 16, guiTop + 17, 176, 52, 60, 54);
|
||||
drawTexturedModalRect(guiLeft + 79, guiTop + 17, 176, 106, 36, 54);
|
||||
}
|
||||
|
||||
if(burner.isOn) {
|
||||
drawTexturedModalRect(guiLeft + 53, guiTop + 17, 196, 0, 16, 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -30,9 +30,9 @@ public class ArcWelderRecipes extends SerializableRecipe {
|
||||
@Override
|
||||
public void registerDefaults() {
|
||||
|
||||
recipes.add(new ArcWelderRecipe(new ItemStack(ModItems.motor), 100, 200L,
|
||||
recipes.add(new ArcWelderRecipe(new ItemStack(ModItems.motor, 2), 100, 200L,
|
||||
new OreDictStack(IRON.plate(), 2), new ComparableStack(ModItems.coil_copper), new ComparableStack(ModItems.coil_copper_torus)));
|
||||
recipes.add(new ArcWelderRecipe(new ItemStack(ModItems.motor), 100, 400L,
|
||||
recipes.add(new ArcWelderRecipe(new ItemStack(ModItems.motor, 2), 100, 400L,
|
||||
new OreDictStack(STEEL.plate(), 1), new ComparableStack(ModItems.coil_copper), new ComparableStack(ModItems.coil_copper_torus)));
|
||||
|
||||
recipes.add(new ArcWelderRecipe(new ItemStack(ModItems.circuit_copper), 100, 1_000L, new FluidStack(Fluids.GAS, 250),
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.inventory.container.ContainerMachineWoodBurner;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.fluid.trait.FT_Flammable;
|
||||
import com.hbm.inventory.gui.GUIMachineWoodBurner;
|
||||
import com.hbm.module.ModuleBurnTime;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachinePolluting;
|
||||
@ -16,7 +19,7 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityMachineWoodBurner extends TileEntityMachinePolluting implements IFluidStandardTransceiver, IGUIProvider {
|
||||
public class TileEntityMachineWoodBurner extends TileEntityMachinePolluting implements IFluidStandardTransceiver, IControlReceiver, IGUIProvider {
|
||||
|
||||
public long power;
|
||||
public static final long maxPower = 100_000;
|
||||
@ -80,19 +83,50 @@ public class TileEntityMachineWoodBurner extends TileEntityMachinePolluting impl
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setLong("power", power);
|
||||
data.setInteger("burnTime", burnTime);
|
||||
data.setInteger("maxBurnTime", maxBurnTime);
|
||||
data.setBoolean("isOn", isOn);
|
||||
data.setBoolean("liquidBurn", liquidBurn);
|
||||
this.networkPack(data, 25);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
this.power = nbt.getLong("power");
|
||||
this.burnTime = nbt.getInteger("burnTime");
|
||||
this.maxBurnTime = nbt.getInteger("maxBurnTime");
|
||||
this.isOn = nbt.getBoolean("isOn");
|
||||
this.liquidBurn = nbt.getBoolean("liquidBurn");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveControl(NBTTagCompound data) {
|
||||
if(data.hasKey("toggle")) {
|
||||
this.isOn = !this.isOn;
|
||||
this.markChanged();
|
||||
}
|
||||
if(data.hasKey("switch")) {
|
||||
this.liquidBurn = !this.liquidBurn;
|
||||
this.markChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(EntityPlayer player) {
|
||||
return this.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return null;
|
||||
return new ContainerMachineWoodBurner(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return null;
|
||||
return new GUIMachineWoodBurner(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 6.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
Loading…
x
Reference in New Issue
Block a user