Skip to content

Commit

Permalink
Port to MUI 2.4 (#2281)
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss authored Dec 17, 2023
1 parent d17b339 commit 510be94
Show file tree
Hide file tree
Showing 19 changed files with 373 additions and 196 deletions.
6 changes: 2 additions & 4 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,14 @@ dependencies {
// the CCL deobf jar uses very old MCP mappings, making it error at runtime in runClient/runServer
// therefore we manually deobf the regular jar
implementation rfg.deobf("curse.maven:codechicken-lib-1-8-242818:2779848") // CCL 3.2.3.358
implementation "curse.maven:modularui-624243:4856895-deobf-4856896-sources-4856897" // MUI 2.3.1
implementation("com.cleanroommc:modularui:2.4.1") { transitive = false }

// Soft Dependencies
// Can change any of these from compileOnlyApi -> implementation to test them in-game.

implementation "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.684"
implementation rfg.deobf("curse.maven:ctm-267602:2915363") // CTM 1.0.2.31
implementation ("com.cleanroommc:groovyscript:0.7.1") {
transitive = false
}
implementation("com.cleanroommc:groovyscript:0.7.1") { transitive = false }
implementation rfg.deobf("curse.maven:ae2-extended-life-570458:4402048") // AE2UEL 0.55.6

compileOnlyApi rfg.deobf("curse.maven:opencomputers-223008:4526246") // OpenComputers 1.8.0+9833087
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/gregtech/api/cover/CoverWithUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
import gregtech.api.gui.IUIHolder;
import gregtech.api.gui.ModularUI;
import gregtech.api.mui.GTGuiTheme;
import gregtech.api.mui.GTGuis;
import gregtech.api.mui.GregTechGuiScreen;
import gregtech.api.mui.factory.CoverGuiFactory;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import com.cleanroommc.modularui.api.IGuiHolder;
import com.cleanroommc.modularui.manager.GuiCreationContext;
import com.cleanroommc.modularui.factory.SidedPosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.screen.ModularScreen;
import com.cleanroommc.modularui.value.sync.GuiSyncManager;
import org.jetbrains.annotations.ApiStatus;

public interface CoverWithUI extends Cover, IUIHolder, IGuiHolder {
public interface CoverWithUI extends Cover, IUIHolder, IGuiHolder<SidedPosGuiData> {

@ApiStatus.Experimental
default boolean usesMui2() {
Expand All @@ -27,8 +27,7 @@ default boolean usesMui2() {

default void openUI(EntityPlayerMP player) {
if (usesMui2()) {
GTGuis.getCoverUiInfo(getAttachedSide())
.open(player, getCoverableView().getWorld(), getCoverableView().getPos());
CoverGuiFactory.open(player, this);
} else {
CoverUIFactory.INSTANCE.openUI(this, player);
}
Expand All @@ -42,7 +41,7 @@ default ModularUI createUI(EntityPlayer player) {
@ApiStatus.NonExtendable
@SideOnly(Side.CLIENT)
@Override
default ModularScreen createScreen(GuiCreationContext creationContext, ModularPanel mainPanel) {
default ModularScreen createScreen(SidedPosGuiData guiData, ModularPanel mainPanel) {
return new GregTechGuiScreen(mainPanel, getUITheme());
}

Expand All @@ -51,8 +50,7 @@ default GTGuiTheme getUITheme() {
}

@Override
default ModularPanel buildUI(GuiCreationContext guiCreationContext, GuiSyncManager guiSyncManager,
boolean isClient) {
default ModularPanel buildUI(SidedPosGuiData guiData, GuiSyncManager guiSyncManager) {
return null;
}

Expand Down
9 changes: 4 additions & 5 deletions src/main/java/gregtech/api/items/gui/ItemUIFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import net.minecraftforge.fml.relauncher.SideOnly;

import com.cleanroommc.modularui.api.IGuiHolder;
import com.cleanroommc.modularui.manager.GuiCreationContext;
import com.cleanroommc.modularui.factory.HandGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.screen.ModularScreen;
import com.cleanroommc.modularui.value.sync.GuiSyncManager;
import org.jetbrains.annotations.ApiStatus;

public interface ItemUIFactory extends IItemComponent, IGuiHolder {
public interface ItemUIFactory extends IItemComponent, IGuiHolder<HandGuiData> {

/**
* Creates new UI basing on given holder. Holder contains information
Expand All @@ -30,7 +30,7 @@ default ModularUI createUI(PlayerInventoryHolder holder, EntityPlayer entityPlay
@ApiStatus.NonExtendable
@SideOnly(Side.CLIENT)
@Override
default ModularScreen createScreen(GuiCreationContext creationContext, ModularPanel mainPanel) {
default ModularScreen createScreen(HandGuiData creationContext, ModularPanel mainPanel) {
return new GregTechGuiScreen(mainPanel, getUITheme());
}

Expand All @@ -39,8 +39,7 @@ default GTGuiTheme getUITheme() {
}

@Override
default ModularPanel buildUI(GuiCreationContext guiCreationContext, GuiSyncManager guiSyncManager,
boolean isClient) {
default ModularPanel buildUI(HandGuiData guiData, GuiSyncManager guiSyncManager) {
return null;
}
}
13 changes: 6 additions & 7 deletions src/main/java/gregtech/api/metatileentity/MetaTileEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
import gregtech.api.metatileentity.interfaces.ISyncedTileEntity;
import gregtech.api.mui.GTGuiTheme;
import gregtech.api.mui.GTGuis;
import gregtech.api.mui.GregTechGuiScreen;
import gregtech.api.mui.factory.MetaTileEntityGuiFactory;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.util.GTLog;
import gregtech.api.util.GTTransferUtils;
Expand Down Expand Up @@ -70,7 +70,7 @@
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Matrix4;
import com.cleanroommc.modularui.api.IGuiHolder;
import com.cleanroommc.modularui.manager.GuiCreationContext;
import com.cleanroommc.modularui.factory.PosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.screen.ModularScreen;
import com.cleanroommc.modularui.value.sync.GuiSyncManager;
Expand All @@ -90,7 +90,7 @@

import static gregtech.api.capability.GregtechDataCodes.*;

public abstract class MetaTileEntity implements ISyncedTileEntity, CoverHolder, IVoidable, IGuiHolder {
public abstract class MetaTileEntity implements ISyncedTileEntity, CoverHolder, IVoidable, IGuiHolder<PosGuiData> {

public static final IndexedCuboid6 FULL_CUBE_COLLISION = new IndexedCuboid6(null, Cuboid6.full);

Expand Down Expand Up @@ -437,7 +437,7 @@ public boolean usesMui2() {

@SideOnly(Side.CLIENT)
@Override
public final ModularScreen createScreen(GuiCreationContext creationContext, ModularPanel mainPanel) {
public final ModularScreen createScreen(PosGuiData posGuiData, ModularPanel mainPanel) {
return new GregTechGuiScreen(mainPanel, getUITheme());
}

Expand All @@ -446,8 +446,7 @@ public GTGuiTheme getUITheme() {
}

@Override
public ModularPanel buildUI(GuiCreationContext guiCreationContext, GuiSyncManager guiSyncManager,
boolean isClient) {
public ModularPanel buildUI(PosGuiData guiData, GuiSyncManager guiSyncManager) {
return null;
}

Expand All @@ -469,7 +468,7 @@ public boolean onRightClick(EntityPlayer playerIn, EnumHand hand, EnumFacing fac
if (!playerIn.isSneaking() && openGUIOnRightClick()) {
if (getWorld() != null && !getWorld().isRemote) {
if (usesMui2()) {
GTGuis.MTE.open(playerIn, getWorld(), getPos());
MetaTileEntityGuiFactory.open(playerIn, this);
} else {
MetaTileEntityUIFactory.INSTANCE.openUI(getHolder(), (EntityPlayerMP) playerIn);
}
Expand Down
30 changes: 20 additions & 10 deletions src/main/java/gregtech/api/mui/GTGuiTextures.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ public static class IDs {
.location(GTValues.MODID, "textures/gui/base/background.png")
.imageSize(176, 166)
.adaptable(3)
.registerAsBackground(IDs.STANDARD_BACKGROUND, true)
.name(IDs.STANDARD_BACKGROUND)
.canApplyTheme()
.build();

public static final UITexture BACKGROUND_POPUP = UITexture.builder()
.location(GTValues.MODID, "textures/gui/base/background_popup.png")
.imageSize(195, 136)
.adaptable(4)
.canApplyTheme()
.build();

// todo BORDERED/BOXED backgrounds will not be ported, if possible
Expand All @@ -61,22 +69,22 @@ public static class IDs {
.location(GTValues.MODID, "textures/gui/base/background_bronze.png")
.imageSize(176, 166)
.adaptable(3)
.registerAsBackground(IDs.BRONZE_BACKGROUND)
.name(IDs.BRONZE_BACKGROUND)
.build();

public static final UITexture BACKGROUND_STEEL = UITexture.builder()
.location(GTValues.MODID, "textures/gui/base/background_steel.png")
.imageSize(176, 166)
.adaptable(3)
.registerAsBackground(IDs.STEEL_BACKGROUND)
.name(IDs.STEEL_BACKGROUND)
.build();

// todo move to textures/gui/base
public static final UITexture BACKGROUND_PRIMITIVE = UITexture.builder()
.location(GTValues.MODID, "textures/gui/primitive/primitive_background.png")
.imageSize(176, 166)
.adaptable(3)
.registerAsBackground(IDs.PRIMITIVE_BACKGROUND)
.name(IDs.PRIMITIVE_BACKGROUND)
.build();

// todo clipboard backgrounds, may deserve some redoing
Expand Down Expand Up @@ -108,36 +116,38 @@ public static class IDs {
.location(GTValues.MODID, "textures/gui/base/slot.png")
.imageSize(18, 18)
.adaptable(1)
.registerAsBackground(IDs.STANDARD_SLOT, true)
.name(IDs.STANDARD_SLOT)
.canApplyTheme()
.build();

public static final UITexture SLOT_BRONZE = new UITexture.Builder()
.location(GTValues.MODID, "textures/gui/base/slot_bronze.png")
.imageSize(18, 18)
.adaptable(1)
.registerAsBackground(IDs.BRONZE_SLOT)
.name(IDs.BRONZE_SLOT)
.build();

public static final UITexture SLOT_STEEL = new UITexture.Builder()
.location(GTValues.MODID, "textures/gui/base/slot_steel.png")
.imageSize(18, 18)
.adaptable(1)
.registerAsBackground(IDs.STEEL_SLOT)
.name(IDs.STEEL_SLOT)
.build();

// todo move to textures/gui/base
public static final UITexture SLOT_PRIMITIVE = new UITexture.Builder()
.location(GTValues.MODID, "textures/gui/primitive/primitive_slot.png")
.imageSize(18, 18)
.adaptable(1)
.registerAsBackground(IDs.PRIMITIVE_SLOT)
.name(IDs.PRIMITIVE_SLOT)
.build();

public static final UITexture FLUID_SLOT = new UITexture.Builder()
.location(GTValues.MODID, "textures/gui/base/fluid_slot.png")
.imageSize(18, 18)
.adaptable(1)
.registerAsBackground(IDs.STANDARD_FLUID_SLOT, true)
.name(IDs.STANDARD_FLUID_SLOT)
.canApplyTheme()
.build();

// todo bronze/steel/primitive fluid slots?
Expand Down Expand Up @@ -253,7 +263,7 @@ public static class IDs {
.location(GTValues.MODID, "textures/gui/widget/button.png")
.imageSize(18, 18)
.adaptable(1)
.registerAsIcon(IDs.STANDARD_BUTTON)
.name(IDs.STANDARD_BUTTON)
.canApplyTheme()
.build();

Expand Down
Loading

0 comments on commit 510be94

Please sign in to comment.