watz GUI stuff

This commit is contained in:
Bob 2023-03-22 21:02:27 +01:00
parent a6913160e0
commit 1901eb317a
6 changed files with 129 additions and 3 deletions

View File

@ -847,7 +847,6 @@ public class ModBlocks {
public static Block plasma_heater;
public static Block watz;
public static final int guiID_watz = 98;
public static Block watz_element;
public static Block watz_control;

View File

@ -4,6 +4,7 @@ import com.hbm.blocks.BlockDummyable;
import com.hbm.tileentity.machine.TileEntityWatz;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@ -21,6 +22,11 @@ public class Watz extends BlockDummyable {
return null;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
return super.standardOpenBehavior(world, x, y, z, player, 0);
}
@Override
public int[] getDimensions() {

View File

@ -0,0 +1,74 @@
package com.hbm.inventory.container;
import com.hbm.tileentity.machine.TileEntityWatz;
import com.hbm.util.InventoryUtil;
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 ContainerWatz extends Container {
protected TileEntityWatz watz;
public ContainerWatz(InventoryPlayer invPlayer, TileEntityWatz tedf) {
watz = tedf;
int index = 0;
for(int j = 0; j < 6; j++) {
for(int i = 0; i < 6; i++) {
if(i + j > 1 && i + j < 9 && 5 - i + j > 1 && i + 5 - j > 1) {
this.addSlotToContainer(new Slot(watz, index, 17 + i * 18, 8 + j * 18));
index++;
}
}
}
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, 147 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 205));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) {
ItemStack var3 = null;
Slot var4 = (Slot) this.inventorySlots.get(par2);
if(var4 != null && var4.getHasStack()) {
ItemStack var5 = var4.getStack();
var3 = var5.copy();
if(par2 <= watz.getSizeInventory() - 1) {
if(!InventoryUtil.mergeItemStack(this.inventorySlots, var5, watz.getSizeInventory(), this.inventorySlots.size(), true)) {
return null;
}
} else if(!InventoryUtil.mergeItemStack(this.inventorySlots, var5, 0, watz.getSizeInventory(), false)) {
return null;
}
if(var5.stackSize == 0) {
var4.putStack((ItemStack) null);
} else {
var4.onSlotChanged();
}
var4.onPickupFromSlot(p_82846_1_, var5);
}
return var3;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return watz.isUseableByPlayer(player);
}
}

View File

@ -0,0 +1,45 @@
package com.hbm.inventory.gui;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerWatz;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.TileEntityWatz;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
public class GUIWatz extends GuiInfoContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/reactors/gui_watz.png");
private TileEntityWatz watz;
public GUIWatz(InventoryPlayer invPlayer, TileEntityWatz watz) {
super(new ContainerWatz(invPlayer, watz));
this.watz = watz;
this.xSize = 176;
this.ySize = 229;
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 93, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float interp, int x, int y) {
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
float col = (float) (Math.sin(System.currentTimeMillis() / 500D) * 0.5 + 0.5);
GL11.glColor4f(1.0F, col, col, 1.0F);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 131, 122);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
drawTexturedModalRect(guiLeft + 131, guiTop, 131, 0, 36, 122);
drawTexturedModalRect(guiLeft, guiTop + 130, 0, 130, xSize, 99);
drawTexturedModalRect(guiLeft + 126, guiTop + 31, 176, 31, 9, 60);
drawTexturedModalRect(guiLeft + 105, guiTop + 96, 185, 26, 30, 26);
drawTexturedModalRect(guiLeft + 9, guiTop + 96, 184, 0, 26, 26);
}
}

View File

@ -1,7 +1,9 @@
package com.hbm.tileentity.machine;
import com.hbm.inventory.container.ContainerWatz;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.gui.GUIWatz;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityMachineBase;
@ -73,12 +75,12 @@ public class TileEntityWatz extends TileEntityMachineBase implements IGUIProvide
@Override
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
return new ContainerWatz(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 GUIWatz(player.inventory, this);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB