aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authormiozune <miozune@gmail.com>2022-11-16 19:23:57 +0900
committermiozune <miozune@gmail.com>2022-11-16 19:23:57 +0900
commit05b8c2b2312834b1b0b302adfdc04bbd1b7115d1 (patch)
tree8671ee5fae2ed94108087b5c9c8eb34171b350e8 /src/main/java/com
parent417f7c1b3181a82be6913bfdb158445247caaa32 (diff)
downloadGT5-Unofficial-05b8c2b2312834b1b0b302adfdc04bbd1b7115d1.tar.gz
GT5-Unofficial-05b8c2b2312834b1b0b302adfdc04bbd1b7115d1.tar.bz2
GT5-Unofficial-05b8c2b2312834b1b0b302adfdc04bbd1b7115d1.zip
Capacitor Hatch
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java55
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Capacitor.java100
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Capacitor.java35
3 files changed, 34 insertions, 156 deletions
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java
index 1be2282efc..041e60eefe 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java
@@ -7,14 +7,18 @@ import static net.minecraft.util.StatCollector.translateToLocal;
import com.github.technus.tectech.Reference;
import com.github.technus.tectech.TecTech;
-import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_Container_Capacitor;
-import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_Capacitor;
import com.github.technus.tectech.util.CommonValues;
import com.github.technus.tectech.util.TT_Utility;
+import com.gtnewhorizons.modularui.api.screen.ModularWindow;
+import com.gtnewhorizons.modularui.api.screen.UIBuildContext;
+import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot;
+import com.gtnewhorizons.modularui.common.widget.SlotGroup;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.enums.Textures;
+import gregtech.api.gui.modularui.GT_UIInfos;
import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.modularui.IAddUIWidgets;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
@@ -23,14 +27,13 @@ import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
/**
* Created by Tec on 03.04.2017.
*/
-public class GT_MetaTileEntity_Hatch_Capacitor extends GT_MetaTileEntity_Hatch {
+public class GT_MetaTileEntity_Hatch_Capacitor extends GT_MetaTileEntity_Hatch implements IAddUIWidgets {
private static Textures.BlockIcons.CustomIcon TM_H;
private static Textures.BlockIcons.CustomIcon TM_H_ACTIVE;
private static Map<String, GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent> componentBinds = new HashMap<>();
@@ -103,24 +106,8 @@ public class GT_MetaTileEntity_Hatch_Capacitor extends GT_MetaTileEntity_Hatch {
}
@Override
- public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
- return new GT_Container_Capacitor(aPlayerInventory, aBaseMetaTileEntity);
- }
-
- @Override
- public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
- return new GT_GUIContainer_Capacitor(
- aPlayerInventory,
- aBaseMetaTileEntity,
- translateToLocal("gt.blockmachines.hatch.capacitor.tier.03.name")); // Capacitor Hatch
- }
-
- @Override
public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
- if (aBaseMetaTileEntity.isClientSide()) {
- return true;
- }
- aBaseMetaTileEntity.openGUI(aPlayer);
+ GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer);
return true;
}
@@ -175,6 +162,32 @@ public class GT_MetaTileEntity_Hatch_Capacitor extends GT_MetaTileEntity_Hatch {
return new long[] {tier, tCurrent, tEnergyMax};
}
+ @Override
+ public boolean useModularUI() {
+ return true;
+ }
+
+ @Override
+ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) {
+ builder.widget(SlotGroup.ofItemHandler(inventoryHandler, 4)
+ .startFromSlot(0)
+ .endAtSlot(15)
+ .slotCreator(index -> new BaseSlot(inventoryHandler, index) {
+ @Override
+ public int getSlotStackLimit() {
+ return 1;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return !getBaseMetaTileEntity().isActive();
+ }
+ })
+ .background(getGUITextureSet().getItemSlot())
+ .build()
+ .setPos(52, 7));
+ }
+
public static void run() {
new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent(
Reference.MODID + ":item.tm.teslaCoilCapacitor.0", 0, 1, V[1] * 512); // LV Capacitor
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Capacitor.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Capacitor.java
deleted file mode 100644
index 378736d334..0000000000
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Capacitor.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package com.github.technus.tectech.thing.metaTileEntity.hatch.gui;
-
-import gregtech.api.gui.GT_ContainerMetaTile_Machine;
-import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.InventoryPlayer;
-import net.minecraft.inventory.Slot;
-import net.minecraft.item.ItemStack;
-
-public class GT_Container_Capacitor extends GT_ContainerMetaTile_Machine {
- public GT_Container_Capacitor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) {
- super(aInventoryPlayer, aTileEntity);
- }
-
- @Override
- public void addSlots(InventoryPlayer aInventoryPlayer) {
- this.addSlotToContainer(new Slot(this.mTileEntity, 0, 53, 8));
- this.addSlotToContainer(new Slot(this.mTileEntity, 1, 71, 8));
- this.addSlotToContainer(new Slot(this.mTileEntity, 2, 89, 8));
- this.addSlotToContainer(new Slot(this.mTileEntity, 3, 107, 8));
- this.addSlotToContainer(new Slot(this.mTileEntity, 4, 53, 26));
- this.addSlotToContainer(new Slot(this.mTileEntity, 5, 71, 26));
- this.addSlotToContainer(new Slot(this.mTileEntity, 6, 89, 26));
- this.addSlotToContainer(new Slot(this.mTileEntity, 7, 107, 26));
- this.addSlotToContainer(new Slot(this.mTileEntity, 8, 53, 44));
- this.addSlotToContainer(new Slot(this.mTileEntity, 9, 71, 44));
- this.addSlotToContainer(new Slot(this.mTileEntity, 10, 89, 44));
- this.addSlotToContainer(new Slot(this.mTileEntity, 11, 107, 44));
- this.addSlotToContainer(new Slot(this.mTileEntity, 12, 53, 62));
- this.addSlotToContainer(new Slot(this.mTileEntity, 13, 71, 62));
- this.addSlotToContainer(new Slot(this.mTileEntity, 14, 89, 62));
- this.addSlotToContainer(new Slot(this.mTileEntity, 15, 107, 62));
- }
-
- @Override
- public int getSlotCount() {
- return 16;
- }
-
- @Override
- public int getShiftClickSlotCount() {
- return getSlotCount();
- }
-
- @Override
- public void detectAndSendChanges() {
- super.detectAndSendChanges();
- if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) {
- return;
- }
- }
-
- @Override
- public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) {
- if (mActive != 0) {
- return null;
- }
- return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
- }
-
- @Override
- public ItemStack transferStackInSlot(EntityPlayer aPlayer, int aSlotIndex) {
- if (mActive != 0) {
- return null;
- }
- return super.transferStackInSlot(aPlayer, aSlotIndex);
- }
-
- @Override
- public boolean canDragIntoSlot(Slot par1Slot) {
- if (mActive != 0) {
- return false;
- }
- return super.canDragIntoSlot(par1Slot);
- }
-
- @Override
- public void putStacksInSlots(ItemStack[] par1ArrayOfItemStack) {
- if (mActive != 0) {
- return;
- }
- super.putStacksInSlots(par1ArrayOfItemStack);
- }
-
- @Override
- protected boolean mergeItemStack(ItemStack aStack, int aStartIndex, int aSlotCount, boolean par4) {
- if (mActive != 0) {
- return false;
- }
- return super.mergeItemStack(aStack, aStartIndex, aSlotCount, par4);
- }
-
- @Override
- public void putStackInSlot(int par1, ItemStack par2ItemStack) {
- if (mActive != 0) {
- return;
- }
- super.putStackInSlot(par1, par2ItemStack);
- }
-}
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Capacitor.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Capacitor.java
deleted file mode 100644
index e97430d9bb..0000000000
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Capacitor.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.github.technus.tectech.thing.metaTileEntity.hatch.gui;
-
-import gregtech.api.gui.GT_GUIContainerMetaTile_Machine;
-import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import net.minecraft.entity.player.InventoryPlayer;
-
-public class GT_GUIContainer_Capacitor extends GT_GUIContainerMetaTile_Machine {
- private final String mName;
-
- public GT_GUIContainer_Capacitor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) {
- super(new GT_Container_Capacitor(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/4by4.png");
- mName = aName;
- }
-
- public GT_GUIContainer_Capacitor(
- InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) {
- super(
- new GT_Container_Capacitor(aInventoryPlayer, aTileEntity),
- "gregtech:textures/gui/" + aBackground + "4by4.png");
- this.mName = aName;
- }
-
- @Override
- protected void drawGuiContainerForegroundLayer(int par1, int par2) {
- fontRendererObj.drawString(mName, 8, 4, 4210752);
- }
-
- @Override
- protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
- super.drawGuiContainerBackgroundLayer(par1, par2, par3);
- int x = (this.width - this.xSize) / 2;
- int y = (this.height - this.ySize) / 2;
- this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
- }
-}