aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorBlueWeabo <76872108+BlueWeabo@users.noreply.github.com>2023-01-09 09:43:25 +0200
committerGitHub <noreply@github.com>2023-01-09 08:43:25 +0100
commit4886338870379112a913bceabbec4384e984ffce (patch)
tree0e57de0dff6b29f14330842526c2057a7d47f39c /src/main
parent8b26e7f41011b9f489480a95793084b027c28fc2 (diff)
downloadGT5-Unofficial-4886338870379112a913bceabbec4384e984ffce.tar.gz
GT5-Unofficial-4886338870379112a913bceabbec4384e984ffce.tar.bz2
GT5-Unofficial-4886338870379112a913bceabbec4384e984ffce.zip
Add GUIs to Super Busses (#490)
* bus guis * convert to row * remove useless part of description * remove useless overrides and make slot count match other busses * spotlessApply (#491) Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> Co-authored-by: GitHub GTNH Actions <> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java112
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java102
2 files changed, 32 insertions, 182 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java
index b8cdd775d5..8854818cac 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java
@@ -1,24 +1,15 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
-import com.gtnewhorizons.modularui.api.UIInfos;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import gregtech.api.enums.GT_Values;
+import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder;
+import com.gtnewhorizons.modularui.api.screen.UIBuildContext;
+import com.gtnewhorizons.modularui.common.widget.Scrollable;
+import com.gtnewhorizons.modularui.common.widget.SlotWidget;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus;
-import gregtech.api.net.GT_Packet_SetConfigurationCircuit;
-import gregtech.api.util.GT_Utility;
import gregtech.api.util.extensions.ArrayExt;
-import gregtech.common.gui.modularui.uifactory.SelectItemUIFactory;
import gtPlusPlus.core.lib.CORE;
-import gtPlusPlus.core.util.minecraft.ItemUtils;
-import gtPlusPlus.core.util.minecraft.PlayerUtils;
-import java.util.List;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.StatCollector;
public class GT_MetaTileEntity_SuperBus_Input extends GT_MetaTileEntity_Hatch_InputBus {
public GT_MetaTileEntity_SuperBus_Input(int aID, String aName, String aNameRegional, int aTier) {
@@ -46,96 +37,25 @@ public class GT_MetaTileEntity_SuperBus_Input extends GT_MetaTileEntity_Hatch_In
@Override
public String[] getDescription() {
- return new String[] {
- "Item Input for Multiblocks",
- "This bus has no GUI, but can have items extracted",
- "" + (getSlots(this.mTier) + 1) + " Slots",
- "To set circuit slot, left click with empty hand",
- CORE.GT_Tooltip
- };
+ return new String[] {"Item Input for Multiblocks", "" + getSlots(this.mTier) + " Slots", CORE.GT_Tooltip};
}
@Override
- public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
- if (aBaseMetaTileEntity.isClientSide() && aPlayer.getCurrentEquippedItem() == null) {
- openCircuitSelector(aPlayer);
- }
- }
-
- @SideOnly(Side.CLIENT)
- private void openCircuitSelector(EntityPlayer player) {
- List<ItemStack> circuits = getConfigurationCircuits();
- UIInfos.openClientUI(player, buildContext -> new SelectItemUIFactory(
- StatCollector.translateToLocal("GT5U.machines.select_circuit"),
- getStackForm(0),
- this::onCircuitSelected,
- circuits,
- GT_Utility.findMatchingStackInList(circuits, getStackInSlot(getCircuitSlot())))
- .createWindow(buildContext));
- }
-
- @SideOnly(Side.CLIENT)
- private void onCircuitSelected(ItemStack selected) {
- GT_Values.NW.sendToServer(new GT_Packet_SetConfigurationCircuit(getBaseMetaTileEntity(), selected));
- // we will not do any validation on client side
- // it doesn't get to actually decide what inventory contains anyway
- setInventorySlotContents(getCircuitSlot(), selected);
+ public int getCircuitSlot() {
+ return getSlots(mTier);
}
@Override
- public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
- if (aBaseMetaTileEntity.isClientSide()) {
- return true;
- } else {
- // Logger.INFO("Trying to display Super Input Bus contents.");
- displayBusContents(aPlayer);
- return true;
- }
- }
-
- public void displayBusContents(EntityPlayer aPlayer) {
- String STRIP = "Item Array: ";
- String aNameString = ItemUtils.getArrayStackNames(mInventory);
- aNameString = aNameString.replace(STRIP, "");
-
- String[] aNames;
- if (aNameString.length() < 1) {
- aNames = null;
- } else {
- aNames = aNameString.split(",");
- }
-
- if (aNames == null || aNames.length == 0) {
- PlayerUtils.messagePlayer(aPlayer, "This Super Bus (I) is Empty. Total Slots: " + mInventory.length);
- return;
- }
-
- PlayerUtils.messagePlayer(aPlayer, "This Super Bus (I) contains: [" + mInventory.length + "]");
-
- if (aNames.length <= 12) {
- for (String s : aNames) {
- if (s.startsWith(" ")) {
- s = s.substring(1);
- }
- // Logger.INFO("Trying to display Super Input Bus contents. "+s);
- PlayerUtils.messagePlayer(aPlayer, s);
- }
- } else {
-
- StringBuilder superString = new StringBuilder();
-
- for (String s : aNames) {
- if (s.startsWith(" ")) {
- s = s.substring(1);
- }
- superString.append(s).append(", ");
+ public void addUIWidgets(Builder builder, UIBuildContext buildContext) {
+ final Scrollable scrollable = new Scrollable().setVerticalScroll();
+ for (int row = 0; row * 4 < inventoryHandler.getSlots() - 1; row++) {
+ int columnsToMake = Math.min(inventoryHandler.getSlots() - row * 4, 4);
+ for (int column = 0; column < columnsToMake; column++) {
+ scrollable.widget(new SlotWidget(inventoryHandler, row * 4 + column)
+ .setPos(column * 18, row * 18)
+ .setSize(18, 18));
}
- PlayerUtils.messagePlayer(aPlayer, superString.toString());
}
- }
-
- @Override
- public int getCircuitSlot() {
- return getSlots(mTier);
+ builder.widget(scrollable.setSize(18 * 4 + 4, 18 * 4).setPos(52, 7));
}
}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java
index 544c4b9308..26fbf7cdd8 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java
@@ -1,5 +1,9 @@
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
+import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder;
+import com.gtnewhorizons.modularui.api.screen.UIBuildContext;
+import com.gtnewhorizons.modularui.common.widget.Scrollable;
+import com.gtnewhorizons.modularui.common.widget.SlotWidget;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
@@ -7,12 +11,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Outpu
import gregtech.api.util.GT_Utility;
import gregtech.api.util.extensions.ArrayExt;
import gtPlusPlus.core.lib.CORE;
-import gtPlusPlus.core.util.minecraft.ItemUtils;
-import gtPlusPlus.core.util.minecraft.PlayerUtils;
-import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
public class GT_MetaTileEntity_SuperBus_Output extends GT_MetaTileEntity_Hatch_OutputBus {
@@ -80,92 +79,23 @@ public class GT_MetaTileEntity_SuperBus_Output extends GT_MetaTileEntity_Hatch_O
}
@Override
- public void saveNBTData(NBTTagCompound aNBT) {
- super.saveNBTData(aNBT);
- }
-
- @Override
- public void loadNBTData(NBTTagCompound aNBT) {
- super.loadNBTData(aNBT);
- }
-
- @Override
public String[] getDescription() {
- String[] aDesc = new String[] {
- "Item Output for Multiblocks", "This bus has no GUI", "" + getSlots(this.mTier) + " Slots", CORE.GT_Tooltip
- };
+ String[] aDesc =
+ new String[] {"Item Output for Multiblocks", "" + getSlots(this.mTier) + " Slots", CORE.GT_Tooltip};
return aDesc;
}
- public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
- if (aBaseMetaTileEntity.isClientSide()) {
- return true;
- } else {
- displayBusContents(aPlayer);
- return true;
- }
- }
-
- public void displayBusContents(EntityPlayer aPlayer) {
- String STRIP = "Item Array: ";
- String aNameString = ItemUtils.getArrayStackNames(getRealInventory());
- aNameString = aNameString.replace(STRIP, "");
-
- String[] aNames;
- if (aNameString.length() < 1) {
- aNames = null;
- } else {
- aNames = aNameString.split(",");
- }
-
- if (aNames == null || aNames.length <= 0) {
- PlayerUtils.messagePlayer(aPlayer, "This Super Bus (O) is Empty. Total Slots: " + getSlots(this.mTier));
- return;
- }
-
- PlayerUtils.messagePlayer(aPlayer, "This Super Bus (O) contains:");
- for (String s : aNames) {
- if (s.startsWith(" ")) {
- s = s.substring(1);
+ @Override
+ public void addUIWidgets(Builder builder, UIBuildContext buildContext) {
+ final Scrollable scrollable = new Scrollable().setVerticalScroll();
+ for (int row = 0; row * 4 < inventoryHandler.getSlots() - 1; row++) {
+ int columnsToMake = Math.min(inventoryHandler.getSlots() - row * 4, 4);
+ for (int column = 0; column < columnsToMake; column++) {
+ scrollable.widget(new SlotWidget(inventoryHandler, row * 4 + column)
+ .setPos(column * 18, row * 18)
+ .setSize(18, 18));
}
- // Logger.INFO("Trying to display Super Output Bus contents. "+s);
- PlayerUtils.messagePlayer(aPlayer, s);
}
- }
-
- @Override
- public int getMaxItemCount() {
- // TODO Auto-generated method stub
- return super.getMaxItemCount();
- }
-
- @Override
- public int getSizeInventory() {
- // TODO Auto-generated method stub
- return super.getSizeInventory();
- }
-
- @Override
- public ItemStack getStackInSlot(int aIndex) {
- // TODO Auto-generated method stub
- return super.getStackInSlot(aIndex);
- }
-
- @Override
- public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) {
- // TODO Auto-generated method stub
- return super.canInsertItem(aIndex, aStack, aSide);
- }
-
- @Override
- public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) {
- // TODO Auto-generated method stub
- return super.canExtractItem(aIndex, aStack, aSide);
- }
-
- @Override
- public ItemStack[] getRealInventory() {
- // TODO Auto-generated method stub
- return super.getRealInventory();
+ builder.widget(scrollable.setSize(18 * 4 + 4, 18 * 4).setPos(52, 7));
}
}