From d544f75a0c20d4dc92a9e00bd682957d4bae7a39 Mon Sep 17 00:00:00 2001 From: Integer Limit <103940576+IntegerLimit@users.noreply.github.com> Date: Wed, 11 Dec 2024 10:29:02 +1100 Subject: [PATCH] Impl DME JEI Exclusion Zones from DME #39 --- gradle.properties | 2 +- .../AccessibleGuiMachine.java | 8 +++ .../deepmobevolution/DMEJEIExclusion.java | 50 +++++++++++++++++++ .../deepmobevolution/JEIExcluded.java | 9 ++++ .../nomilabs/integration/jei/JEIPlugin.java | 12 ++++- .../deepmoblearning/GuiMachineMixin.java | 39 +++++++++++++++ .../GuiSimulationChamberMixin.java | 46 +++++++++++++++++ .../mixins.nomilabs.deepmoblearning.json | 5 +- 8 files changed, 168 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/nomiceu/nomilabs/integration/deepmobevolution/AccessibleGuiMachine.java create mode 100644 src/main/java/com/nomiceu/nomilabs/integration/deepmobevolution/DMEJEIExclusion.java create mode 100644 src/main/java/com/nomiceu/nomilabs/integration/deepmobevolution/JEIExcluded.java create mode 100644 src/main/java/com/nomiceu/nomilabs/mixin/deepmoblearning/GuiMachineMixin.java create mode 100644 src/main/java/com/nomiceu/nomilabs/mixin/deepmoblearning/GuiSimulationChamberMixin.java diff --git a/gradle.properties b/gradle.properties index a8730524..805368ff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -247,7 +247,7 @@ enable_nae2 = false enable_better_p2p = false # Whether to enable DME in runtime. Enables the DME Sim Chamber. -enable_dme = false +enable_dme = true # Whether to enable Extended Crafting in runtime. Enables Extended Crafting Blocks in DME Sim Chamber and Naq Reactors. # If this is set to false, those blocks will be set to air. diff --git a/src/main/java/com/nomiceu/nomilabs/integration/deepmobevolution/AccessibleGuiMachine.java b/src/main/java/com/nomiceu/nomilabs/integration/deepmobevolution/AccessibleGuiMachine.java new file mode 100644 index 00000000..06272899 --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/integration/deepmobevolution/AccessibleGuiMachine.java @@ -0,0 +1,8 @@ +package com.nomiceu.nomilabs.integration.deepmobevolution; + +import java.awt.*; + +public interface AccessibleGuiMachine { + + Rectangle getRedstoneButtonRect(); +} diff --git a/src/main/java/com/nomiceu/nomilabs/integration/deepmobevolution/DMEJEIExclusion.java b/src/main/java/com/nomiceu/nomilabs/integration/deepmobevolution/DMEJEIExclusion.java new file mode 100644 index 00000000..7bbd47b2 --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/integration/deepmobevolution/DMEJEIExclusion.java @@ -0,0 +1,50 @@ +package com.nomiceu.nomilabs.integration.deepmobevolution; + +import static mustapelto.deepmoblearning.DMLConstants.Gui.TrialKeystone.*; + +import java.awt.*; +import java.util.List; + +import org.jetbrains.annotations.NotNull; + +import com.google.common.collect.ImmutableList; + +import mezz.jei.api.gui.IAdvancedGuiHandler; +import mustapelto.deepmoblearning.client.gui.GuiMachine; +import mustapelto.deepmoblearning.client.gui.GuiTrialKeystone; + +public class DMEJEIExclusion { + + public static class MachineGuiExclusion implements IAdvancedGuiHandler { + + @Override + @NotNull + public Class getGuiContainerClass() { + return GuiMachine.class; + } + + @Override + public List getGuiExtraAreas(@NotNull GuiMachine gui) { + return ((JEIExcluded) gui).getGuiExclusionAreas(); + } + } + + public static class TrialGuiExclusion implements IAdvancedGuiHandler { + + @Override + @NotNull + public Class getGuiContainerClass() { + return GuiTrialKeystone.class; + } + + @Override + public List getGuiExtraAreas(GuiTrialKeystone gui) { + return ImmutableList.of( + new Rectangle( + gui.guiLeft + TRIAL_KEY_SLOT.LEFT, + gui.guiTop + TRIAL_KEY_SLOT.TOP, + TRIAL_KEY_SLOT.WIDTH, + TRIAL_KEY_SLOT.HEIGHT)); + } + } +} diff --git a/src/main/java/com/nomiceu/nomilabs/integration/deepmobevolution/JEIExcluded.java b/src/main/java/com/nomiceu/nomilabs/integration/deepmobevolution/JEIExcluded.java new file mode 100644 index 00000000..64602a43 --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/integration/deepmobevolution/JEIExcluded.java @@ -0,0 +1,9 @@ +package com.nomiceu.nomilabs.integration.deepmobevolution; + +import java.awt.*; +import java.util.List; + +public interface JEIExcluded { + + List getGuiExclusionAreas(); +} diff --git a/src/main/java/com/nomiceu/nomilabs/integration/jei/JEIPlugin.java b/src/main/java/com/nomiceu/nomilabs/integration/jei/JEIPlugin.java index 06890fba..493e54c8 100644 --- a/src/main/java/com/nomiceu/nomilabs/integration/jei/JEIPlugin.java +++ b/src/main/java/com/nomiceu/nomilabs/integration/jei/JEIPlugin.java @@ -11,6 +11,7 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.registry.ForgeRegistries; import org.apache.commons.lang3.tuple.Pair; @@ -22,7 +23,9 @@ import com.google.common.collect.HashBasedTable; import com.google.common.collect.ImmutableList; import com.google.common.collect.Table; +import com.nomiceu.nomilabs.LabsValues; import com.nomiceu.nomilabs.groovy.PartialRecipe; +import com.nomiceu.nomilabs.integration.deepmobevolution.DMEJEIExclusion; import com.nomiceu.nomilabs.item.registry.LabsItems; import com.nomiceu.nomilabs.util.ItemTagMeta; @@ -59,7 +62,14 @@ public class JEIPlugin implements IModPlugin { private static IIngredientRegistry itemRegistry; @Override - public void register(IModRegistry registry) { + public void register(@NotNull IModRegistry registry) { + /* DME Custom JEI Exclusion Handler (Impl DME#39) */ + if (Loader.isModLoaded(LabsValues.DME_MODID)) { + registry.addAdvancedGuiHandlers( + new DMEJEIExclusion.MachineGuiExclusion(), + new DMEJEIExclusion.TrialGuiExclusion()); + } + var jeiHelpers = registry.getJeiHelpers(); itemRegistry = registry.getIngredientRegistry(); diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/deepmoblearning/GuiMachineMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/deepmoblearning/GuiMachineMixin.java new file mode 100644 index 00000000..49f3ba46 --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/mixin/deepmoblearning/GuiMachineMixin.java @@ -0,0 +1,39 @@ +package com.nomiceu.nomilabs.mixin.deepmoblearning; + +import java.awt.*; +import java.util.List; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +import com.google.common.collect.ImmutableList; +import com.nomiceu.nomilabs.integration.deepmobevolution.AccessibleGuiMachine; +import com.nomiceu.nomilabs.integration.deepmobevolution.JEIExcluded; + +import mustapelto.deepmoblearning.client.gui.GuiMachine; +import mustapelto.deepmoblearning.client.gui.buttons.ButtonRedstoneMode; + +/** + * Adds JEI Exclusion Areas to Gui Machine. + */ +@Mixin(value = GuiMachine.class, remap = false) +public class GuiMachineMixin implements JEIExcluded, AccessibleGuiMachine { + + @Shadow + private ButtonRedstoneMode redstoneModeButton; + + @Override + public List getGuiExclusionAreas() { + return ImmutableList.of( + getRedstoneButtonRect()); + } + + @Override + public Rectangle getRedstoneButtonRect() { + return new Rectangle( + redstoneModeButton.x, + redstoneModeButton.y, + redstoneModeButton.width, + redstoneModeButton.height); + } +} diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/deepmoblearning/GuiSimulationChamberMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/deepmoblearning/GuiSimulationChamberMixin.java new file mode 100644 index 00000000..ff2f049d --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/mixin/deepmoblearning/GuiSimulationChamberMixin.java @@ -0,0 +1,46 @@ +package com.nomiceu.nomilabs.mixin.deepmoblearning; + +import static mustapelto.deepmoblearning.DMLConstants.Gui.SimulationChamber.DATA_MODEL_SLOT; + +import java.awt.*; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +import org.spongepowered.asm.mixin.Mixin; + +import com.google.common.collect.ImmutableList; +import com.nomiceu.nomilabs.integration.deepmobevolution.AccessibleGuiMachine; +import com.nomiceu.nomilabs.integration.deepmobevolution.JEIExcluded; + +import mustapelto.deepmoblearning.client.gui.GuiMachine; +import mustapelto.deepmoblearning.client.gui.GuiSimulationChamber; +import mustapelto.deepmoblearning.common.tiles.TileEntityMachine; +import mustapelto.deepmoblearning.common.util.Point; + +/** + * Adds JEI Exclusion Areas to Gui Simulation Chamber. + */ +@Mixin(value = GuiSimulationChamber.class, remap = false) +public abstract class GuiSimulationChamberMixin extends GuiMachine implements JEIExcluded { + + /** + * Default Ignored Constructor + */ + private GuiSimulationChamberMixin(TileEntityMachine tileEntity, EntityPlayer player, World world, int width, + int height, Point redstoneModeButtonLocation) { + super(tileEntity, player, world, width, height, redstoneModeButtonLocation); + } + + @Override + public List getGuiExclusionAreas() { + return ImmutableList.of( + ((AccessibleGuiMachine) this).getRedstoneButtonRect(), + new Rectangle( + guiLeft + DATA_MODEL_SLOT.LEFT, + guiTop + DATA_MODEL_SLOT.TOP, + DATA_MODEL_SLOT.WIDTH, + DATA_MODEL_SLOT.HEIGHT)); + } +} diff --git a/src/main/resources/mixins.nomilabs.deepmoblearning.json b/src/main/resources/mixins.nomilabs.deepmoblearning.json index c2da9af1..f5b772b2 100644 --- a/src/main/resources/mixins.nomilabs.deepmoblearning.json +++ b/src/main/resources/mixins.nomilabs.deepmoblearning.json @@ -7,6 +7,9 @@ "mixins": [ "DataModelHelperAccessor" ], - "client": [], + "client": [ + "GuiMachineMixin", + "GuiSimulationChamberMixin" + ], "server": [] }