Skip to content

Commit

Permalink
Impl DME JEI Exclusion Zones from DME #39
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Dec 10, 2024
1 parent 7a01e0d commit d544f75
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.nomiceu.nomilabs.integration.deepmobevolution;

import java.awt.*;

public interface AccessibleGuiMachine {

Rectangle getRedstoneButtonRect();
}
Original file line number Diff line number Diff line change
@@ -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<GuiMachine> {

@Override
@NotNull
public Class<GuiMachine> getGuiContainerClass() {
return GuiMachine.class;
}

@Override
public List<Rectangle> getGuiExtraAreas(@NotNull GuiMachine gui) {
return ((JEIExcluded) gui).getGuiExclusionAreas();
}
}

public static class TrialGuiExclusion implements IAdvancedGuiHandler<GuiTrialKeystone> {

@Override
@NotNull
public Class<GuiTrialKeystone> getGuiContainerClass() {
return GuiTrialKeystone.class;
}

@Override
public List<Rectangle> 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));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.nomiceu.nomilabs.integration.deepmobevolution;

import java.awt.*;
import java.util.List;

public interface JEIExcluded {

List<Rectangle> getGuiExclusionAreas();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
@@ -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<Rectangle> getGuiExclusionAreas() {
return ImmutableList.of(
getRedstoneButtonRect());
}

@Override
public Rectangle getRedstoneButtonRect() {
return new Rectangle(
redstoneModeButton.x,
redstoneModeButton.y,
redstoneModeButton.width,
redstoneModeButton.height);
}
}
Original file line number Diff line number Diff line change
@@ -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<Rectangle> 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));
}
}
5 changes: 4 additions & 1 deletion src/main/resources/mixins.nomilabs.deepmoblearning.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"mixins": [
"DataModelHelperAccessor"
],
"client": [],
"client": [
"GuiMachineMixin",
"GuiSimulationChamberMixin"
],
"server": []
}

0 comments on commit d544f75

Please sign in to comment.