From af0d372e2a987032d4de3d3105acf8e919279d69 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 21 Dec 2024 07:52:29 +0200 Subject: [PATCH 01/24] i didn't remember the axis methods when i wrote it ok it was after a couple hours of fighting with the vertex methods --- .../renderer/machine/gcym/LargeChemicalBathRenderer.java | 2 +- .../primitive/PrimitiveBlastFurnaceMachine.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/gcym/LargeChemicalBathRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/gcym/LargeChemicalBathRenderer.java index 73568a351a..144f96b113 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/gcym/LargeChemicalBathRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/gcym/LargeChemicalBathRenderer.java @@ -82,7 +82,7 @@ public void render(BlockEntity blockEntity, float partialTicks, PoseStack stack, var up = RelativeDirection.UP.getRelativeFacing(lcb.getFrontFacing(), lcb.getUpwardsFacing(), lcb.isFlipped()); - if (up != Direction.UP && up != Direction.DOWN) up = up.getOpposite(); + if (up.getAxis() != Direction.Axis.Y) up = up.getOpposite(); fluidBlockRenderer.drawPlane(up, lcb.getFluidBlockOffsets(), pose, consumer, cachedFluid, RenderUtil.FluidTextureType.STILL, combinedOverlay, lcb.getPos()); diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java index 641212f88e..6b3e27a3c2 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java @@ -90,10 +90,10 @@ public void clientTick() { float zPos = facing.getStepZ() * 0.76F + pos.getZ() + 0.5F; var up = RelativeDirection.UP.getRelativeFacing(getFrontFacing(), getUpwardsFacing(), isFlipped()); - var sign = up == Direction.UP || up == Direction.EAST || up == Direction.SOUTH ? 1 : -1; - var shouldX = up == Direction.EAST || up == Direction.WEST; - var shouldY = up == Direction.UP || up == Direction.DOWN; - var shouldZ = up == Direction.NORTH || up == Direction.SOUTH; + var sign = up.getAxisDirection().getStep(); + var shouldX = up.getAxis() == Direction.Axis.X; + var shouldY = up.getAxis() == Direction.Axis.Y; + var shouldZ = up.getAxis() == Direction.Axis.Z; var speed = ((shouldY ? facing.getStepY() : shouldX ? facing.getStepX() : facing.getStepZ()) * 0.1F + 0.2F + 0.1F * GTValues.RNG.nextFloat()) * sign; if (getOffsetTimer() % 20 == 0) { From 149ee42ffbb81598779a769ee7cf854e56e934af Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 21 Dec 2024 07:53:05 +0200 Subject: [PATCH 02/24] get offset timer should now work on both client and server again --- .../gtceu/api/machine/IMachineBlockEntity.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java b/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java index 9028fa281c..4257ee835e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java @@ -53,7 +53,13 @@ default void scheduleRenderUpdate() { } default long getOffsetTimer() { - return level() == null ? getOffset() : (level().getServer().getTickCount() + getOffset()); + if (level() == null) { + return getOffset(); + } else if (level().isClientSide() || level().getServer() == null) { + return level().getGameTime() + getOffset(); + } else { + return level().getServer().getTickCount() + getOffset(); + } } default MachineDefinition getDefinition() { From 715240fc59eacfddadf99fdd2b6877617bccb908 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 21 Dec 2024 08:19:09 +0200 Subject: [PATCH 03/24] added the getTime thing back for client --- .../com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java b/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java index 4257ee835e..62a9300882 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java @@ -58,7 +58,7 @@ default long getOffsetTimer() { } else if (level().isClientSide() || level().getServer() == null) { return level().getGameTime() + getOffset(); } else { - return level().getServer().getTickCount() + getOffset(); + return level().getServer().getTickCount() + getOffset(); } } From 3ff50e288b2420068568deaa886d634eb07c5c4d Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 21 Dec 2024 08:19:23 +0200 Subject: [PATCH 04/24] moved mod load checks to forge native method --- src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java | 5 +++++ .../gtceu/common/item/ColorSprayBehaviour.java | 5 ++--- .../gtceu/integration/map/GroupingMapRenderer.java | 9 ++++----- .../gtceu/integration/map/WaypointManager.java | 7 +++---- .../gtceu/integration/map/xaeros/XaerosMapPlugin.java | 5 ++--- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java b/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java index 1214cdbf1e..99c80eb9e1 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java +++ b/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java @@ -17,6 +17,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import net.minecraftforge.eventbus.api.GenericEvent; +import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.event.IModBusEvent; import lombok.Getter; @@ -56,6 +57,10 @@ public static void initializeHighTier() { else GTCEu.LOGGER.info("High-Tier is Disabled."); } + public static boolean isModLoaded(java.lang.String modId) { + return ModList.get().isLoaded(modId); + } + public static class RegisterEvent extends GenericEvent implements IModBusEvent { private final GTRegistry registry; diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java b/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java index 4b226860e0..6b06bb9a6e 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.common.item; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.blockentity.IPaintable; import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; @@ -14,8 +15,6 @@ import com.gregtechceu.gtceu.utils.BreadthFirstBlockSearch; import com.gregtechceu.gtceu.utils.GradientUtil; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.registries.BuiltInRegistries; @@ -92,7 +91,7 @@ private static ResourceLocation getId(String modid, DyeColor color, String postf for (DyeColor color : DyeColor.values()) { // if there are > 16 colors (vanilla end) & tinted is loaded, use tinted blocks - if (color.ordinal() > 15 && Platform.isModLoaded(GTValues.MODID_TINTED)) { + if (color.ordinal() > 15 && GTCEuAPI.isModLoaded(GTValues.MODID_TINTED)) { glassBuilder.put(color, BuiltInRegistries.BLOCK.get(getId(GTValues.MODID_TINTED, color, "stained_glass"))); glassPaneBuilder.put(color, diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/GroupingMapRenderer.java b/src/main/java/com/gregtechceu/gtceu/integration/map/GroupingMapRenderer.java index fee59b0cff..5bf4a1ec01 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/GroupingMapRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/GroupingMapRenderer.java @@ -1,13 +1,12 @@ package com.gregtechceu.gtceu.integration.map; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.worldgen.ores.GeneratedVeinMetadata; import com.gregtechceu.gtceu.api.gui.misc.ProspectorMode; import com.gregtechceu.gtceu.integration.map.journeymap.JourneymapRenderer; import com.gregtechceu.gtceu.integration.map.xaeros.XaerosRenderer; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; @@ -27,13 +26,13 @@ public class GroupingMapRenderer extends GenericMapRenderer { static { Map renderers = new HashMap<>(); - if (Platform.isModLoaded(GTValues.MODID_JOURNEYMAP)) { + if (GTCEuAPI.isModLoaded(GTValues.MODID_JOURNEYMAP)) { renderers.put(GTValues.MODID_JOURNEYMAP, new JourneymapRenderer()); } - if (Platform.isModLoaded(GTValues.MODID_XAEROS_MINIMAP)) { + if (GTCEuAPI.isModLoaded(GTValues.MODID_XAEROS_MINIMAP)) { renderers.put(GTValues.MODID_XAEROS_MINIMAP, new XaerosRenderer()); } - if (Platform.isModLoaded(GTValues.MODID_FTB_CHUNKS)) { + if (GTCEuAPI.isModLoaded(GTValues.MODID_FTB_CHUNKS)) { // TODO FTB chunks support } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java b/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java index 20bbc5a6ae..de881e108b 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java @@ -1,11 +1,10 @@ package com.gregtechceu.gtceu.integration.map; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.integration.map.journeymap.JourneymapWaypointHandler; import com.gregtechceu.gtceu.integration.map.xaeros.XaeroWaypointHandler; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.Level; @@ -27,11 +26,11 @@ public class WaypointManager { private static boolean active = false; public static void init() { - if (Platform.isModLoaded(GTValues.MODID_XAEROS_MINIMAP)) { + if (GTCEuAPI.isModLoaded(GTValues.MODID_XAEROS_MINIMAP)) { WaypointManager.registerWaypointHandler(new XaeroWaypointHandler()); active = true; } - if (Platform.isModLoaded(GTValues.MODID_JOURNEYMAP)) { + if (GTCEuAPI.isModLoaded(GTValues.MODID_JOURNEYMAP)) { WaypointManager.registerWaypointHandler(new JourneymapWaypointHandler()); active = true; } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/xaeros/XaerosMapPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/map/xaeros/XaerosMapPlugin.java index ce0973e2ca..a43a0cee4f 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/xaeros/XaerosMapPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/xaeros/XaerosMapPlugin.java @@ -1,9 +1,8 @@ package com.gregtechceu.gtceu.integration.map.xaeros; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; -import com.lowdragmc.lowdraglib.Platform; - import it.unimi.dsi.fastutil.objects.Object2BooleanMap; import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap; import xaero.common.minimap.highlight.DimensionHighlighterHandler; @@ -32,7 +31,7 @@ public static void toggleOption(String name, boolean active) { dimHighlightHandler.requestRefresh(); } - if (Platform.isModLoaded(GTValues.MODID_XAEROS_WORLDMAP)) { + if (GTCEuAPI.isModLoaded(GTValues.MODID_XAEROS_WORLDMAP)) { WorldMapSession session = WorldMapSession.getCurrentSession(); MapWorld world = session.getMapProcessor().getMapWorld(); for (MapDimension mapDim : world.getDimensionsList()) { From 8d6ebbc9fd058afb3288033db3b9890db7f3608d Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 21 Dec 2024 09:17:02 +0200 Subject: [PATCH 05/24] doing the actual thing with the stuff --- .../primitive/PrimitiveBlastFurnaceMachine.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java index 6b3e27a3c2..434521924d 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java @@ -45,7 +45,6 @@ public class PrimitiveBlastFurnaceMachine extends PrimitiveWorkableMachine imple public PrimitiveBlastFurnaceMachine(IMachineBlockEntity holder, Object... args) { super(holder, args); - this.onServerTick = subscribeServerTick(this::hurtEntities); } @Override @@ -60,16 +59,12 @@ protected NotifiableItemStackHandler createExportItemHandler(Object... args) { IO.NONE); } - @Override - public void onLoad() { - super.onLoad(); - this.onServerTick = subscribeServerTick(onServerTick, this::hurtEntities); - } - @Override public void onUnload() { super.onUnload(); - this.onServerTick.unsubscribe(); + if (onServerTick != null) { + this.onServerTick.unsubscribe(); + } } @Override @@ -96,7 +91,7 @@ public void clientTick() { var shouldZ = up.getAxis() == Direction.Axis.Z; var speed = ((shouldY ? facing.getStepY() : shouldX ? facing.getStepX() : facing.getStepZ()) * 0.1F + 0.2F + 0.1F * GTValues.RNG.nextFloat()) * sign; - if (getOffsetTimer() % 20 == 0) { + if (GTValues.CLIENT_TIME % 20 == 0) { getLevel().addParticle(ParticleTypes.LAVA, xPos, yPos, zPos, shouldX ? speed * 2 : 0, shouldY ? speed * 2 : 0, From c66e3e0a70ca5154f9998b2eafd0f8370274e49b Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 21 Dec 2024 09:23:06 +0200 Subject: [PATCH 06/24] CLIENT_TIME --- .../gtceu/api/machine/IMachineBlockEntity.java | 8 +++++--- .../primitive/PrimitiveBlastFurnaceMachine.java | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java b/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java index 62a9300882..9ebcd293fd 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.api.machine; +import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.block.IMachineBlock; import com.gregtechceu.gtceu.api.item.tool.IToolGridHighlight; import com.gregtechceu.gtceu.common.machine.owner.IMachineOwner; @@ -55,11 +56,12 @@ default void scheduleRenderUpdate() { default long getOffsetTimer() { if (level() == null) { return getOffset(); - } else if (level().isClientSide() || level().getServer() == null) { - return level().getGameTime() + getOffset(); - } else { + } else if (level().isClientSide()) { + return GTValues.CLIENT_TIME + getOffset(); + } else if (level().getServer() == null) { return level().getServer().getTickCount() + getOffset(); } + return getOffset(); } default MachineDefinition getDefinition() { diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java index 434521924d..ada5cfaef3 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java @@ -91,7 +91,7 @@ public void clientTick() { var shouldZ = up.getAxis() == Direction.Axis.Z; var speed = ((shouldY ? facing.getStepY() : shouldX ? facing.getStepX() : facing.getStepZ()) * 0.1F + 0.2F + 0.1F * GTValues.RNG.nextFloat()) * sign; - if (GTValues.CLIENT_TIME % 20 == 0) { + if ((GTValues.CLIENT_TIME + getHolder().getOffset()) % 20 == 0) { getLevel().addParticle(ParticleTypes.LAVA, xPos, yPos, zPos, shouldX ? speed * 2 : 0, shouldY ? speed * 2 : 0, From 8e9bc480d47c457f2dae472661673535c8204478 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 21 Dec 2024 09:49:37 +0200 Subject: [PATCH 07/24] moved unsubscribe to onInvalid and removed check from subscriber runnable --- .../primitive/PrimitiveBlastFurnaceMachine.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java index ada5cfaef3..928a94de89 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java @@ -67,6 +67,14 @@ public void onUnload() { } } + @Override + public void onStructureInvalid() { + super.onStructureInvalid(); + if (onServerTick != null) { + this.onServerTick.unsubscribe(); + } + } + @Override public void onStructureFormed() { super.onStructureFormed(); @@ -165,7 +173,6 @@ public void animateTick(RandomSource random) { } private void hurtEntities() { - if (!isFormed) return; BlockPos middlePos = self().getPos().offset(getFrontFacing().getOpposite().getNormal()); getLevel().getEntities(null, new AABB(middlePos)).forEach(e -> e.hurt(e.damageSources().lava(), 3.0f)); From 433ba8fcbb6450fd52723862e81a9a26beabf686 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 21 Dec 2024 09:56:42 +0200 Subject: [PATCH 08/24] getOffsetTimer in pbf --- .../multiblock/primitive/PrimitiveBlastFurnaceMachine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java index 928a94de89..6cb34a3350 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveBlastFurnaceMachine.java @@ -99,7 +99,7 @@ public void clientTick() { var shouldZ = up.getAxis() == Direction.Axis.Z; var speed = ((shouldY ? facing.getStepY() : shouldX ? facing.getStepX() : facing.getStepZ()) * 0.1F + 0.2F + 0.1F * GTValues.RNG.nextFloat()) * sign; - if ((GTValues.CLIENT_TIME + getHolder().getOffset()) % 20 == 0) { + if (getOffsetTimer() % 20 == 0) { getLevel().addParticle(ParticleTypes.LAVA, xPos, yPos, zPos, shouldX ? speed * 2 : 0, shouldY ? speed * 2 : 0, From 0dc659d02eafeff245c5df4ba07e98f339dcf34e Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 21 Dec 2024 11:01:22 +0200 Subject: [PATCH 09/24] Here is my wisdom: If your ball is too big for your mouth it's not yours. --- .../Development/General-Topics/Global-Data.md | 2 +- .../java/com/gregtechceu/gtceu/GTCEu.java | 39 ---------- .../com/gregtechceu/gtceu/api/GTCEuAPI.java | 71 +++++++++++++++++++ .../com/gregtechceu/gtceu/api/GTValues.java | 2 + .../blockentity/MetaMachineBlockEntity.java | 9 ++- .../gtceu/api/capability/ICoverable.java | 5 +- .../gtceu/api/cover/filter/FilterHandler.java | 4 +- .../material/info/MaterialIconSet.java | 4 +- .../material/info/MaterialIconType.java | 3 +- .../material/properties/HazardProperty.java | 6 +- .../gtceu/api/data/tag/TagPrefix.java | 7 +- .../api/data/worldgen/WorldGenLayers.java | 4 +- .../api/gui/editor/EditableMachineUI.java | 4 +- .../api/gui/factory/GTUIEditorFactory.java | 3 +- .../api/gui/fancy/FancyMachineUIWidget.java | 4 +- .../gtceu/api/gui/misc/IGhostFluidTarget.java | 9 +-- .../gtceu/api/gui/misc/IGhostItemTarget.java | 7 +- .../api/gui/widget/EnumSelectorWidget.java | 4 +- .../api/gui/widget/NumberInputWidget.java | 4 +- .../api/gui/widget/PatternPreviewWidget.java | 11 +-- .../api/gui/widget/PhantomFluidWidget.java | 13 ++-- .../api/gui/widget/PhantomSlotWidget.java | 11 +-- .../gtceu/api/gui/widget/SlotWidget.java | 38 +++++----- .../gtceu/api/gui/widget/TankWidget.java | 40 +++++------ .../api/item/component/ElectricStats.java | 4 +- .../gtceu/api/machine/MetaMachine.java | 4 +- .../gtceu/api/machine/feature/IUIMachine.java | 4 +- .../trait/NotifiableItemStackHandler.java | 8 ++- .../pattern/predicates/SimplePredicate.java | 4 +- .../gtceu/api/pipenet/IPipeNode.java | 5 +- .../gtceu/api/pipenet/PipeNetWalker.java | 4 +- .../gtceu/api/recipe/GTRecipeSerializer.java | 7 +- .../gtceu/api/recipe/ui/GTRecipeTypeUI.java | 12 ++-- .../registry/registrate/MachineBuilder.java | 9 ++- .../api/transfer/fluid/FluidHandlerList.java | 6 +- .../client/model/WorkableOverlayModel.java | 4 +- .../renderer/block/PipeBlockRenderer.java | 6 +- .../block/TextureOverrideRenderer.java | 8 +-- .../renderer/cover/ConveyorCoverRenderer.java | 4 +- .../cover/FluidRegulatorCoverRenderer.java | 4 +- .../renderer/cover/PumpCoverRenderer.java | 4 +- .../renderer/cover/RobotArmCoverRenderer.java | 4 +- .../renderer/cover/SimpleCoverRenderer.java | 4 +- .../machine/FusionReactorRenderer.java | 4 +- .../gregtechceu/gtceu/common/CommonProxy.java | 7 +- .../detector/AdvancedEnergyDetectorCover.java | 4 +- .../gtceu/common/data/GTDimensionMarkers.java | 3 +- .../gtceu/common/data/GTElements.java | 3 +- .../gtceu/common/data/GTItems.java | 9 ++- .../gtceu/common/data/GTMachines.java | 20 +++--- .../gtceu/common/data/GTRecipeCategories.java | 2 +- .../gtceu/common/data/GTRecipeTypes.java | 2 +- .../common/data/machines/GCYMMachines.java | 6 +- .../common/data/machines/GTMultiMachines.java | 11 ++- .../common/item/ColorSprayBehaviour.java | 3 +- .../gtceu/common/item/ItemMagnetBehavior.java | 4 +- .../common/machine/electric/HullMachine.java | 14 ++-- .../multiblock/part/DiodePartMachine.java | 4 +- .../common/machine/owner/IMachineOwner.java | 5 +- .../pipelike/cable/EnergyNetWalker.java | 5 +- .../gtceu/data/loader/BedrockFluidLoader.java | 3 +- .../gtceu/data/loader/BedrockOreLoader.java | 3 +- .../gtceu/data/loader/GTOreLoader.java | 3 +- .../gtceu/data/recipe/CraftingComponent.java | 3 +- .../recipe/builder/BlastingRecipeBuilder.java | 4 +- .../recipe/builder/CampfireRecipeBuilder.java | 4 +- .../builder/ShapelessRecipeBuilder.java | 4 +- .../recipe/builder/SmeltingRecipeBuilder.java | 4 +- .../recipe/builder/SmokingRecipeBuilder.java | 4 +- .../data/recipe/misc/MachineRecipeLoader.java | 4 +- .../MetaTileEntityMachineRecipeLoader.java | 3 +- .../gtceu/integration/emi/GTEMIPlugin.java | 7 +- .../gtceu/integration/jade/GTJadePlugin.java | 6 +- .../gtceu/integration/jei/GTJEIPlugin.java | 10 +-- .../xei/widgets/GTRecipeWidget.java | 4 +- .../com/gregtechceu/gtceu/utils/GTUtil.java | 11 ++- 76 files changed, 314 insertions(+), 278 deletions(-) diff --git a/docs/content/Development/General-Topics/Global-Data.md b/docs/content/Development/General-Topics/Global-Data.md index 8442155303..82a00718c1 100644 --- a/docs/content/Development/General-Topics/Global-Data.md +++ b/docs/content/Development/General-Topics/Global-Data.md @@ -18,7 +18,7 @@ When doing so, you need to ensure that remote and serverside instances don't get To make working with this requirement easier, You can use `SideLocal` to store your global data. It is similar to Java's `ThreadLocal`, but operates on the game's sides instead. -If you are currently on the remote side (`LDLib.isRemote()` / on the client's `main` thread), it will return the +If you are currently on the remote side (`GTCEuAPI.isClientSide()` / on the client's `main` thread), it will return the remote side's instance of your data. Otherwise, you will get the server side's instance. ??? example "Example Usage" diff --git a/src/main/java/com/gregtechceu/gtceu/GTCEu.java b/src/main/java/com/gregtechceu/gtceu/GTCEu.java index edfe13fea9..0a022c9b98 100644 --- a/src/main/java/com/gregtechceu/gtceu/GTCEu.java +++ b/src/main/java/com/gregtechceu/gtceu/GTCEu.java @@ -1,12 +1,10 @@ package com.gregtechceu.gtceu; import com.gregtechceu.gtceu.api.GTCEuAPI; -import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.client.ClientProxy; import com.gregtechceu.gtceu.common.CommonProxy; import com.gregtechceu.gtceu.utils.FormattingUtil; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.Platform; import net.minecraft.resources.ResourceLocation; @@ -53,43 +51,6 @@ public static ResourceLocation appendId(String id) { return new ResourceLocation(strings[0], strings[1]); } - public static boolean isKubeJSLoaded() { - return LDLib.isModLoaded(GTValues.MODID_KUBEJS); - } - - public static boolean isIrisOculusLoaded() { - return LDLib.isModLoaded(GTValues.MODID_IRIS) || LDLib.isModLoaded(GTValues.MODID_OCULUS); - } - - public static boolean isSodiumRubidiumEmbeddiumLoaded() { - return LDLib.isModLoaded(GTValues.MODID_SODIUM) || LDLib.isModLoaded(GTValues.MODID_RUBIDIUM) || - LDLib.isModLoaded(GTValues.MODID_EMBEDDIUM); - } - - public static boolean isAE2Loaded() { - return LDLib.isModLoaded(GTValues.MODID_APPENG); - } - - public static boolean isCuriosLoaded() { - return LDLib.isModLoaded(GTValues.MODID_CURIOS); - } - - public static boolean isShimmerLoaded() { - return LDLib.isModLoaded(GTValues.MODID_SHIMMER); - } - - public static boolean isJAVDLoaded() { - return LDLib.isModLoaded(GTValues.MODID_JAVD); - } - - public static boolean isFTBTeamsLoaded() { - return LDLib.isModLoaded(GTValues.MODID_FTB_TEAMS); - } - - public static boolean isArgonautsLoaded() { - return LDLib.isModLoaded(GTValues.MODID_ARGONAUTS); - } - @Deprecated(forRemoval = true, since = "1.0.21") public static boolean isHighTier() { return GTCEuAPI.isHighTier(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java b/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java index 99c80eb9e1..4128134a3e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java +++ b/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java @@ -12,13 +12,16 @@ import com.gregtechceu.gtceu.common.block.CoilBlock; import com.gregtechceu.gtceu.config.ConfigHolder; +import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.Platform; +import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import net.minecraftforge.eventbus.api.GenericEvent; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.event.IModBusEvent; +import net.minecraftforge.fml.loading.FMLEnvironment; import lombok.Getter; import org.jetbrains.annotations.ApiStatus; @@ -61,6 +64,74 @@ public static boolean isModLoaded(java.lang.String modId) { return ModList.get().isLoaded(modId); } + /** + * @return if the current thread is the client thread + */ + public static boolean isClientThread() { + return isClientSide() && Minecraft.getInstance().isSameThread(); + } + + /** + * @return if the FML environment is a client + */ + public static boolean isClientSide() { + return FMLEnvironment.dist.isClient(); + } + + public static class Mods { + + public static boolean isJeiLoaded() { + return !(isEmiLoaded() || isReiLoaded()) && isModLoaded(GTValues.MODID_JEI); + } + + public static boolean isReiLoaded() { + // todo: convert to base check after ui rework + return LDLib.isReiLoaded(); + } + + public static boolean isEmiLoaded() { + // todo: convert to base check after ui rework + return LDLib.isEmiLoaded(); + } + + public static boolean isKubeJSLoaded() { + return isModLoaded(GTValues.MODID_KUBEJS); + } + + public static boolean isIrisOculusLoaded() { + return isModLoaded(GTValues.MODID_IRIS) || isModLoaded(GTValues.MODID_OCULUS); + } + + public static boolean isSodiumRubidiumEmbeddiumLoaded() { + return isModLoaded(GTValues.MODID_SODIUM) || isModLoaded(GTValues.MODID_RUBIDIUM) || + isModLoaded(GTValues.MODID_EMBEDDIUM); + } + + public static boolean isAE2Loaded() { + return isModLoaded(GTValues.MODID_APPENG); + } + + public static boolean isCuriosLoaded() { + return isModLoaded(GTValues.MODID_CURIOS); + } + + public static boolean isShimmerLoaded() { + return isModLoaded(GTValues.MODID_SHIMMER); + } + + public static boolean isJAVDLoaded() { + return isModLoaded(GTValues.MODID_JAVD); + } + + public static boolean isFTBTeamsLoaded() { + return isModLoaded(GTValues.MODID_FTB_TEAMS); + } + + public static boolean isArgonautsLoaded() { + return isModLoaded(GTValues.MODID_ARGONAUTS); + } + } + public static class RegisterEvent extends GenericEvent implements IModBusEvent { private final GTRegistry registry; diff --git a/src/main/java/com/gregtechceu/gtceu/api/GTValues.java b/src/main/java/com/gregtechceu/gtceu/api/GTValues.java index b5af91ff72..94e91980f8 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/GTValues.java +++ b/src/main/java/com/gregtechceu/gtceu/api/GTValues.java @@ -112,6 +112,8 @@ public static int[] tiersBetween(int minInclusive, int maxInclusive) { public static final String MODID_TOP = "theoneprobe", MODID_JEI = "jei", + MODID_REI = "roughlyenoughitems", + MODID_EMI = "emi", MODID_APPENG = "ae2", MODID_KUBEJS = "kubejs", MODID_IRIS = "iris", diff --git a/src/main/java/com/gregtechceu/gtceu/api/blockentity/MetaMachineBlockEntity.java b/src/main/java/com/gregtechceu/gtceu/api/blockentity/MetaMachineBlockEntity.java index 8fc62de826..160a5683dd 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/blockentity/MetaMachineBlockEntity.java +++ b/src/main/java/com/gregtechceu/gtceu/api/blockentity/MetaMachineBlockEntity.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.blockentity; -import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.*; import com.gregtechceu.gtceu.api.capability.forge.GTCapability; @@ -49,7 +49,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; /** * @author KilaBash @@ -269,7 +272,7 @@ public static LazyOptional getCapability(MetaMachine machine, @NotNull Ca return GTCapability.CAPABILITY_DATA_ACCESS.orEmpty(cap, LazyOptional.of(() -> list.get(0))); } } - if (GTCEu.isAE2Loaded()) { + if (GTCEuAPI.Mods.isAE2Loaded()) { if (cap == Capabilities.IN_WORLD_GRID_NODE_HOST) { if (machine instanceof IInWorldGridNodeHost nodeHost) { return Capabilities.IN_WORLD_GRID_NODE_HOST.orEmpty(cap, LazyOptional.of(() -> nodeHost)); diff --git a/src/main/java/com/gregtechceu/gtceu/api/capability/ICoverable.java b/src/main/java/com/gregtechceu/gtceu/api/capability/ICoverable.java index da5b1a6976..16560da266 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/capability/ICoverable.java +++ b/src/main/java/com/gregtechceu/gtceu/api/capability/ICoverable.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.api.capability; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.block.IAppearance; import com.gregtechceu.gtceu.api.blockentity.ITickSubscription; import com.gregtechceu.gtceu.api.cover.CoverBehavior; @@ -7,8 +8,6 @@ import com.gregtechceu.gtceu.api.transfer.fluid.IFluidHandlerModifiable; import com.gregtechceu.gtceu.utils.GTUtil; -import com.lowdragmc.lowdraglib.LDLib; - import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerPlayer; @@ -169,7 +168,7 @@ default boolean hasCover(Direction facing) { } default boolean isRemote() { - return getLevel() == null ? LDLib.isRemote() : getLevel().isClientSide; + return getLevel() == null ? GTCEuAPI.isClientThread() : getLevel().isClientSide; } default VoxelShape[] addCoverCollisionBoundingBox() { diff --git a/src/main/java/com/gregtechceu/gtceu/api/cover/filter/FilterHandler.java b/src/main/java/com/gregtechceu/gtceu/api/cover/filter/FilterHandler.java index c02ba23d84..30f734d9cf 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/cover/filter/FilterHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/api/cover/filter/FilterHandler.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.api.cover.filter; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.cover.CoverBehavior; import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.api.gui.widget.SlotWidget; @@ -7,7 +8,6 @@ import com.gregtechceu.gtceu.api.machine.MetaMachine; import com.gregtechceu.gtceu.api.transfer.item.CustomItemStackHandler; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup; import com.lowdragmc.lowdraglib.gui.widget.Widget; import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; @@ -128,7 +128,7 @@ private CustomItemStackHandler getFilterSlot() { private void updateFilter() { var filterContainer = getFilterSlot(); - if (LDLib.isRemote()) { + if (GTCEuAPI.isClientThread()) { if (!filterContainer.getStackInSlot(0).isEmpty() && !this.filterItem.isEmpty()) { return; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java index edf2447771..ef13662299 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.data.chemical.material.info; -import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import com.google.common.base.Preconditions; @@ -98,7 +98,7 @@ public String toString() { } public static void init() { - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistryInfo.MATERIAL_ICON_SET.registryKey); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java index 19d4f58e4e..f018403900 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.api.data.chemical.material.info; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import com.lowdragmc.lowdraglib.Platform; @@ -127,7 +128,7 @@ public MaterialIconType(String name) { } public static void init() { - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistryInfo.MATERIAL_ICON_TYPE.registryKey); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/HazardProperty.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/HazardProperty.java index f63a34822f..69bacfa33f 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/HazardProperty.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/HazardProperty.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.data.chemical.material.properties; -import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.stack.UnificationEntry; @@ -120,7 +120,7 @@ public boolean isProtected(LivingEntity livingEntity) { correctArmorItems.add(equipmentType); } } - if (!GTCEu.isCuriosLoaded() || this.curioSlots.isEmpty()) { + if (!GTCEuAPI.Mods.isCuriosLoaded() || this.curioSlots.isEmpty()) { return correctArmorItems.containsAll(equipmentTypes); } Set correctCurios = new HashSet<>(); @@ -153,7 +153,7 @@ public void damageEquipment(Player player, int amount) { armor.hurtAndBreak(amount, player, p -> p.broadcastBreakEvent(type.getSlot())); } } - if (GTCEu.isCuriosLoaded()) { + if (GTCEuAPI.Mods.isCuriosLoaded()) { ICuriosItemHandler curiosInventory = CuriosApi.getCuriosInventory(player) .resolve() .orElse(null); diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java b/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java index 9a2174fa51..c95fc6c810 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java @@ -13,7 +13,10 @@ import com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey; import com.gregtechceu.gtceu.api.data.chemical.material.stack.MaterialStack; import com.gregtechceu.gtceu.api.item.tool.GTToolType; -import com.gregtechceu.gtceu.common.data.*; +import com.gregtechceu.gtceu.common.data.GTBlocks; +import com.gregtechceu.gtceu.common.data.GTMaterialBlocks; +import com.gregtechceu.gtceu.common.data.GTMaterialItems; +import com.gregtechceu.gtceu.common.data.GTMaterials; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import com.gregtechceu.gtceu.integration.xei.widgets.GTOreByProduct; @@ -72,7 +75,7 @@ public class TagPrefix { public static void init() { AddonFinder.getAddons().forEach(IGTAddon::registerTagPrefixes); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistryInfo.TAG_PREFIX.registryKey); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java index 4aefcf064e..a8878e9ef3 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.data.worldgen; -import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.addon.AddonFinder; import com.gregtechceu.gtceu.api.addon.IGTAddon; import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; @@ -59,7 +59,7 @@ public enum WorldGenLayers implements IWorldGenLayer, StringRepresentable { public static void registerAll() { AddonFinder.getAddons().forEach(IGTAddon::registerWorldgenLayers); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistryInfo.WORLD_GEN_LAYER.registryKey); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/editor/EditableMachineUI.java b/src/main/java/com/gregtechceu/gtceu/api/gui/editor/EditableMachineUI.java index 98d767a451..9a087e4774 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/editor/EditableMachineUI.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/editor/EditableMachineUI.java @@ -1,8 +1,8 @@ package com.gregtechceu.gtceu.api.gui.editor; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.machine.MetaMachine; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.gui.editor.configurator.IConfigurableWidget; import com.lowdragmc.lowdraglib.gui.editor.data.Resources; @@ -76,7 +76,7 @@ public WidgetGroup createCustomUI() { public CompoundTag getCustomUI() { if (this.customUICache == null) { ResourceManager resourceManager = null; - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { resourceManager = Minecraft.getInstance().getResourceManager(); } else if (Platform.getMinecraftServer() != null) { resourceManager = Platform.getMinecraftServer().getResourceManager(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/factory/GTUIEditorFactory.java b/src/main/java/com/gregtechceu/gtceu/api/gui/factory/GTUIEditorFactory.java index 9c531f2edb..b4514fb674 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/factory/GTUIEditorFactory.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/factory/GTUIEditorFactory.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.api.gui.factory; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.gui.editor.GTUIEditor; import com.lowdragmc.lowdraglib.LDLib; @@ -43,7 +44,7 @@ public boolean isInvalid() { @Override public boolean isRemote() { - return LDLib.isRemote(); + return GTCEuAPI.isClientThread(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/FancyMachineUIWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/FancyMachineUIWidget.java index fcd8798aad..52a4955d42 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/FancyMachineUIWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/FancyMachineUIWidget.java @@ -1,9 +1,9 @@ package com.gregtechceu.gtceu.api.gui.fancy; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.config.ConfigHolder; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; import com.lowdragmc.lowdraglib.gui.util.ClickData; import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; @@ -200,7 +200,7 @@ protected void setupFancyUI(IFancyUIProvider fancyUI, boolean showInventory) { Math.max(86, page.getSize().height + border * 2)); setSize(new Size(size.width, size.height + (!showInventory || playerInventory == null ? 0 : playerInventory.getSize().height))); - if (LDLib.isRemote() && getGui() != null) { + if (GTCEuAPI.isClientSide() && getGui() != null) { getGui().setSize(getSize().width, getSize().height); } this.sideTabsWidget.setSize(new Size(24, size.height)); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java index b208a0f118..df00a8d959 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.api.gui.misc; -import com.lowdragmc.lowdraglib.LDLib; +import com.gregtechceu.gtceu.api.GTCEuAPI; + import com.lowdragmc.lowdraglib.gui.ingredient.IGhostIngredientTarget; import com.lowdragmc.lowdraglib.gui.ingredient.Target; @@ -61,17 +62,17 @@ public void accept(@NotNull Object ingredient) { } default Object convertIngredient(Object ingredient) { - if (LDLib.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { + if (GTCEuAPI.Mods.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), (int) fluidStack.getAmount(), fluidStack.getTag()); } - if (LDLib.isEmiLoaded() && ingredient instanceof EmiStack fluidEmiStack) { + if (GTCEuAPI.Mods.isEmiLoaded() && ingredient instanceof EmiStack fluidEmiStack) { Fluid fluid = fluidEmiStack.getKeyOfType(Fluid.class); ingredient = fluid == null ? FluidStack.EMPTY : new FluidStack(fluid, (int) fluidEmiStack.getAmount(), fluidEmiStack.getNbt()); } - if (LDLib.isJeiLoaded() && ingredient instanceof net.minecraftforge.fluids.FluidStack fluidStack) { + if (GTCEuAPI.Mods.isJeiLoaded() && ingredient instanceof net.minecraftforge.fluids.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), fluidStack.getAmount(), fluidStack.getTag()); } return ingredient; diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java index 28593addd8..39c0fc4dde 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.api.gui.misc; -import com.lowdragmc.lowdraglib.LDLib; +import com.gregtechceu.gtceu.api.GTCEuAPI; + import com.lowdragmc.lowdraglib.gui.ingredient.IGhostIngredientTarget; import com.lowdragmc.lowdraglib.gui.ingredient.Target; @@ -52,7 +53,7 @@ public void accept(@NotNull Object ingredient) { } default Object convertIngredient(Object ingredient) { - if (LDLib.isEmiLoaded() && ingredient instanceof EmiStack itemEmiStack) { + if (GTCEuAPI.Mods.isEmiLoaded() && ingredient instanceof EmiStack itemEmiStack) { Item item = itemEmiStack.getKeyOfType(Item.class); ItemStack itemStack = item == null ? ItemStack.EMPTY : new ItemStack(item, (int) itemEmiStack.getAmount()); if (!itemStack.isEmpty()) { @@ -61,7 +62,7 @@ default Object convertIngredient(Object ingredient) { ingredient = itemStack; } - if (LDLib.isJeiLoaded() && ingredient instanceof ITypedIngredient itemJeiStack) { + if (GTCEuAPI.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient itemJeiStack) { return itemJeiStack.getItemStack().orElse(ItemStack.EMPTY); } return ingredient; diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/EnumSelectorWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/EnumSelectorWidget.java index 6e68b2d5bc..0bcd01335a 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/EnumSelectorWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/EnumSelectorWidget.java @@ -1,9 +1,9 @@ package com.gregtechceu.gtceu.api.gui.widget; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.data.lang.LangHandler; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup; import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; import com.lowdragmc.lowdraglib.gui.widget.CycleButtonWidget; @@ -125,7 +125,7 @@ public void setSelected(@NotNull T value) { } private void updateTooltip() { - if (!LDLib.isRemote()) + if (!GTCEuAPI.isClientThread()) return; T selectedValue = getCurrentValue(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/NumberInputWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/NumberInputWidget.java index 59400619f4..0f722aeb1b 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/NumberInputWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/NumberInputWidget.java @@ -1,9 +1,9 @@ package com.gregtechceu.gtceu.api.gui.widget; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.utils.GTUtil; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup; import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; import com.lowdragmc.lowdraglib.gui.texture.TextTexture; @@ -133,7 +133,7 @@ private void buildUI() { private IGuiTexture getButtonTexture(String prefix, int buttonWidth) { var texture = new TextTexture(prefix + "1"); - if (!LDLib.isRemote()) { + if (!GTCEuAPI.isClientThread()) { return texture; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java index ce329dab36..f91812ed41 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.api.gui.widget; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.block.MetaMachineBlock; import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; @@ -13,9 +14,10 @@ import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.integration.xei.handlers.item.CycleItemStackHandler; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.gui.editor.ColorPattern; -import com.lowdragmc.lowdraglib.gui.texture.*; +import com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture; +import com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup; +import com.lowdragmc.lowdraglib.gui.texture.TextTexture; import com.lowdragmc.lowdraglib.gui.widget.*; import com.lowdragmc.lowdraglib.jei.IngredientIO; import com.lowdragmc.lowdraglib.utils.BlockInfo; @@ -44,7 +46,6 @@ import org.jetbrains.annotations.NotNull; import java.util.*; -import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -254,10 +255,10 @@ public static BlockPos locateNextRegion(int range) { public void updateScreen() { super.updateScreen(); // I can only think of this way - if (!isLoaded && LDLib.isEmiLoaded() && Minecraft.getInstance().screen instanceof RecipeScreen) { + if (!isLoaded && GTCEuAPI.Mods.isEmiLoaded() && Minecraft.getInstance().screen instanceof RecipeScreen) { setPage(0); isLoaded = true; - } else if (!isLoaded && LDLib.isReiLoaded() && + } else if (!isLoaded && GTCEuAPI.Mods.isReiLoaded() && Minecraft.getInstance().screen instanceof AbstractDisplayViewingScreen) { setPage(0); isLoaded = true; diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java index b6ee5f605c..f9928636c7 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.api.gui.widget; -import com.lowdragmc.lowdraglib.LDLib; +import com.gregtechceu.gtceu.api.GTCEuAPI; + import com.lowdragmc.lowdraglib.gui.editor.annotation.ConfigSetter; import com.lowdragmc.lowdraglib.gui.editor.annotation.LDLRegister; import com.lowdragmc.lowdraglib.gui.editor.configurator.IConfigurableWidget; @@ -100,9 +101,9 @@ public static FluidStack drainFrom(Object ingredient) { @Override @OnlyIn(Dist.CLIENT) public List getPhantomTargets(Object ingredient) { - if (LDLib.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { + if (GTCEuAPI.Mods.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), (int) fluidStack.getAmount(), fluidStack.getTag()); - } else if (LDLib.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + } else if (GTCEuAPI.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { var key = emiStack.getKey(); if (key instanceof Fluid f) { int amount = emiStack.getAmount() == 0 ? 1000 : (int) emiStack.getAmount(); @@ -113,7 +114,7 @@ public List getPhantomTargets(Object ingredient) { } else { ingredient = null; } - } else if (LDLib.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { + } else if (GTCEuAPI.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { ingredient = jeiStack.getIngredient(); } @@ -132,11 +133,11 @@ public Rect2i getArea() { @Override public void accept(@Nonnull Object ingredient) { - if (LDLib.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { + if (GTCEuAPI.Mods.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), (int) fluidStack.getAmount(), fluidStack.getTag()); - } else if (LDLib.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + } else if (GTCEuAPI.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { var key = emiStack.getKey(); if (key instanceof Fluid f) { int amount = emiStack.getAmount() == 0 ? 1000 : (int) emiStack.getAmount(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java index 39addac870..bbada8312c 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.api.gui.widget; -import com.lowdragmc.lowdraglib.LDLib; +import com.gregtechceu.gtceu.api.GTCEuAPI; + import com.lowdragmc.lowdraglib.gui.editor.annotation.ConfigSetter; import com.lowdragmc.lowdraglib.gui.editor.annotation.Configurable; import com.lowdragmc.lowdraglib.gui.editor.annotation.LDLRegister; @@ -125,13 +126,13 @@ public boolean canPutStack(ItemStack stack) { @Override @OnlyIn(Dist.CLIENT) public List getPhantomTargets(Object ingredient) { - if (LDLib.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + if (GTCEuAPI.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { Item item = emiStack.getKeyOfType(Item.class); if (item != null) { ingredient = new ItemStack(item, (int) emiStack.getAmount()); ((ItemStack) ingredient).setTag(emiStack.getNbt()); } - } else if (LDLib.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { + } else if (GTCEuAPI.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { ingredient = jeiStack.getItemStack().orElse(null); } if (!(ingredient instanceof ItemStack)) { @@ -149,13 +150,13 @@ public Rect2i getArea() { @Override public void accept(@Nonnull Object ingredient) { - if (LDLib.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + if (GTCEuAPI.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { Item item = emiStack.getKeyOfType(Item.class); if (item != null) { ingredient = new ItemStack(item, (int) emiStack.getAmount()); ((ItemStack) ingredient).setTag(emiStack.getNbt()); } - } else if (LDLib.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { + } else if (GTCEuAPI.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { ingredient = jeiStack.getItemStack().orElse(null); } if (slotReference != null && ingredient instanceof ItemStack stack) { diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java index 192e5f2c39..e2ec24766e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java @@ -1,12 +1,12 @@ package com.gregtechceu.gtceu.api.gui.widget; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.integration.xei.entry.item.ItemEntryList; import com.gregtechceu.gtceu.integration.xei.entry.item.ItemStackList; import com.gregtechceu.gtceu.integration.xei.entry.item.ItemTagList; import com.gregtechceu.gtceu.integration.xei.handlers.item.CycleItemEntryHandler; import com.gregtechceu.gtceu.integration.xei.handlers.item.CycleItemStackHandler; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.gui.editor.annotation.LDLRegister; import com.lowdragmc.lowdraglib.gui.editor.configurator.ConfiguratorGroup; import com.lowdragmc.lowdraglib.gui.editor.configurator.WrapperConfigurator; @@ -204,11 +204,11 @@ public Object getXEIIngredientOverMouse(double mouseX, double mouseY) { } } - if (LDLib.isJeiLoaded() && !realStack.isEmpty()) { + if (GTCEuAPI.Mods.isJeiLoaded() && !realStack.isEmpty()) { return JEICallWrapper.getJEIStackClickable(realStack, getPosition(), getSize()); - } else if (LDLib.isReiLoaded()) { + } else if (GTCEuAPI.Mods.isReiLoaded()) { return EntryStacks.of(realStack); - } else if (LDLib.isEmiLoaded()) { + } else if (GTCEuAPI.Mods.isEmiLoaded()) { return EmiStack.of(realStack).setChance(getXEIChance()); } return realStack; @@ -230,11 +230,11 @@ public List getXEIIngredients() { } } - if (LDLib.isJeiLoaded() && !realStack.isEmpty()) { + if (GTCEuAPI.Mods.isJeiLoaded() && !realStack.isEmpty()) { return List.of(JEICallWrapper.getJEIStackClickable(realStack, getPosition(), getSize())); - } else if (LDLib.isReiLoaded()) { + } else if (GTCEuAPI.Mods.isReiLoaded()) { return List.of(EntryStacks.of(realStack)); - } else if (LDLib.isEmiLoaded()) { + } else if (GTCEuAPI.Mods.isEmiLoaded()) { return List.of(EmiStack.of(realStack).setChance(getXEIChance())); } return List.of(realStack); @@ -242,11 +242,11 @@ public List getXEIIngredients() { private List getXEIIngredients(CycleItemStackHandler handler, int index) { var stackList = handler.getStackList(index); - if (LDLib.isJeiLoaded()) { + if (GTCEuAPI.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredients(stackList, this::getRealStack); - } else if (LDLib.isReiLoaded()) { + } else if (GTCEuAPI.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(stackList, this::getRealStack); - } else if (LDLib.isEmiLoaded()) { + } else if (GTCEuAPI.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); @@ -254,11 +254,11 @@ private List getXEIIngredients(CycleItemStackHandler handler, int index) private List getXEIIngredientsClickable(CycleItemStackHandler handler, int index) { var stackList = handler.getStackList(index); - if (LDLib.isJeiLoaded()) { + if (GTCEuAPI.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredientsClickable(stackList, getPosition(), getSize(), this::getRealStack); - } else if (LDLib.isReiLoaded()) { + } else if (GTCEuAPI.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(stackList, this::getRealStack); - } else if (LDLib.isEmiLoaded()) { + } else if (GTCEuAPI.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); @@ -266,11 +266,11 @@ private List getXEIIngredientsClickable(CycleItemStackHandler handler, i private List getXEIIngredients(CycleItemEntryHandler handler, int index) { ItemEntryList entryList = handler.getEntry(index); - if (LDLib.isJeiLoaded()) { + if (GTCEuAPI.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredients(entryList, this::getRealStack); - } else if (LDLib.isReiLoaded()) { + } else if (GTCEuAPI.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(entryList, this::getRealStack); - } else if (LDLib.isEmiLoaded()) { + } else if (GTCEuAPI.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); @@ -278,11 +278,11 @@ private List getXEIIngredients(CycleItemEntryHandler handler, int index) private List getXEIIngredientsClickable(CycleItemEntryHandler handler, int index) { ItemEntryList entryList = handler.getEntry(index); - if (LDLib.isJeiLoaded()) { + if (GTCEuAPI.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredientsClickable(entryList, getPosition(), getSize(), this::getRealStack); - } else if (LDLib.isReiLoaded()) { + } else if (GTCEuAPI.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(entryList, this::getRealStack); - } else if (LDLib.isEmiLoaded()) { + } else if (GTCEuAPI.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java index b896b030e7..87483a22a9 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.api.gui.widget; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.client.TooltipsHandler; import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidEntryList; import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidStackList; @@ -7,7 +8,6 @@ import com.gregtechceu.gtceu.integration.xei.handlers.fluid.CycleFluidEntryHandler; import com.gregtechceu.gtceu.integration.xei.handlers.fluid.CycleFluidStackHandler; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.gui.editor.annotation.Configurable; import com.lowdragmc.lowdraglib.gui.editor.annotation.LDLRegister; import com.lowdragmc.lowdraglib.gui.editor.configurator.ConfiguratorGroup; @@ -202,11 +202,11 @@ public Object getXEIIngredientOverMouse(double mouseX, double mouseY) { return getXEIIngredientsClickable(entryHandler, tank).get(0); } - if (LDLib.isJeiLoaded()) { + if (GTCEuAPI.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIFluidClickable(lastFluidInTank, getPosition(), getSize()); - } else if (LDLib.isReiLoaded()) { + } else if (GTCEuAPI.Mods.isReiLoaded()) { return EntryStacks.of(REICallWrapper.toREIStack(lastFluidInTank)); - } else if (LDLib.isEmiLoaded()) { + } else if (GTCEuAPI.Mods.isEmiLoaded()) { return ForgeEmiStack.of(lastFluidInTank).setChance(XEIChance); } } @@ -223,11 +223,11 @@ public List getXEIIngredients() { return getXEIIngredientsClickable(entryHandler, tank); } - if (LDLib.isJeiLoaded()) { + if (GTCEuAPI.Mods.isJeiLoaded()) { return List.of(JEICallWrapper.getJEIFluidClickable(lastFluidInTank, getPosition(), getSize())); - } else if (LDLib.isReiLoaded()) { + } else if (GTCEuAPI.Mods.isReiLoaded()) { return List.of(EntryStacks.of(REICallWrapper.toREIStack(lastFluidInTank))); - } else if (LDLib.isEmiLoaded()) { + } else if (GTCEuAPI.Mods.isEmiLoaded()) { return List.of(ForgeEmiStack.of(lastFluidInTank).setChance(XEIChance)); } return List.of(lastFluidInTank); @@ -235,11 +235,11 @@ public List getXEIIngredients() { private List getXEIIngredients(CycleFluidStackHandler handler, int index) { FluidStackList stackList = handler.getStackList(index); - if (LDLib.isJeiLoaded()) { + if (GTCEuAPI.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredients(stackList); - } else if (LDLib.isReiLoaded()) { + } else if (GTCEuAPI.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(stackList); - } else if (LDLib.isEmiLoaded()) { + } else if (GTCEuAPI.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance()); } return Collections.emptyList(); @@ -247,11 +247,11 @@ private List getXEIIngredients(CycleFluidStackHandler handler, int index private List getXEIIngredientsClickable(CycleFluidStackHandler handler, int index) { FluidStackList stackList = handler.getStackList(index); - if (LDLib.isJeiLoaded()) { + if (GTCEuAPI.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredientsClickable(stackList, getPosition(), getSize()); - } else if (LDLib.isReiLoaded()) { + } else if (GTCEuAPI.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(stackList); - } else if (LDLib.isEmiLoaded()) { + } else if (GTCEuAPI.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance()); } return Collections.emptyList(); @@ -259,11 +259,11 @@ private List getXEIIngredientsClickable(CycleFluidStackHandler handler, private List getXEIIngredients(CycleFluidEntryHandler handler, int index) { FluidEntryList entryList = handler.getEntry(index); - if (LDLib.isJeiLoaded()) { + if (GTCEuAPI.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredients(entryList); - } else if (LDLib.isReiLoaded()) { + } else if (GTCEuAPI.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(entryList); - } else if (LDLib.isEmiLoaded()) { + } else if (GTCEuAPI.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance()); } return Collections.emptyList(); @@ -271,11 +271,11 @@ private List getXEIIngredients(CycleFluidEntryHandler handler, int index private List getXEIIngredientsClickable(CycleFluidEntryHandler handler, int index) { FluidEntryList entryList = handler.getEntry(index); - if (LDLib.isJeiLoaded()) { + if (GTCEuAPI.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredientsClickable(entryList, getPosition(), getSize()); - } else if (LDLib.isReiLoaded()) { + } else if (GTCEuAPI.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(entryList); - } else if (LDLib.isEmiLoaded()) { + } else if (GTCEuAPI.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance()); } return Collections.emptyList(); @@ -318,7 +318,7 @@ public List getFullTooltipTexts() { @Override public void setCurrentJEIRenderedIngredient(Object ingredient) { - if (LDLib.isJeiLoaded()) { + if (GTCEuAPI.Mods.isJeiLoaded()) { currentJEIRenderedIngredient = ingredient instanceof FluidStack f ? f : null; } else { currentJEIRenderedIngredient = null; diff --git a/src/main/java/com/gregtechceu/gtceu/api/item/component/ElectricStats.java b/src/main/java/com/gregtechceu/gtceu/api/item/component/ElectricStats.java index eff4f272f1..2d8d9e87be 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/item/component/ElectricStats.java +++ b/src/main/java/com/gregtechceu/gtceu/api/item/component/ElectricStats.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.item.component; -import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.GTCapabilityHelper; import com.gregtechceu.gtceu.api.capability.IElectricItem; @@ -104,7 +104,7 @@ public void inventoryTick(ItemStack stack, Level level, Entity entity, int slotI isInDischargeMode(stack) && electricItem.getCharge() > 0L) { long transferLimit = electricItem.getTransferLimit(); - if (GTCEu.isCuriosLoaded()) { + if (GTCEuAPI.Mods.isCuriosLoaded()) { IItemHandler curios = CuriosApi.getCuriosInventory(player) .map(ICuriosItemHandler::getEquippedCurios) .orElse(EmptyHandler.INSTANCE); diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java b/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java index 2fb3c5ba71..580f18e5d9 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.api.machine; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.block.BlockProperties; import com.gregtechceu.gtceu.api.block.IAppearance; import com.gregtechceu.gtceu.api.block.MetaMachineBlock; @@ -26,7 +27,6 @@ import com.gregtechceu.gtceu.common.cover.ItemFilterCover; import com.gregtechceu.gtceu.common.item.tool.behavior.ToolModeSwitchBehavior; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; import com.lowdragmc.lowdraglib.gui.texture.ResourceTexture; import com.lowdragmc.lowdraglib.syncdata.IEnhancedManaged; @@ -155,7 +155,7 @@ public BlockState getBlockState() { } public boolean isRemote() { - return getLevel() == null ? LDLib.isRemote() : getLevel().isClientSide; + return getLevel() == null ? GTCEuAPI.isClientThread() : getLevel().isClientSide; } public void notifyBlockUpdate() { diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IUIMachine.java b/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IUIMachine.java index 567a487526..877b94350d 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IUIMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IUIMachine.java @@ -1,8 +1,8 @@ package com.gregtechceu.gtceu.api.machine.feature; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.gui.factory.MachineUIFactory; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.gui.modular.IUIHolder; import net.minecraft.server.level.ServerPlayer; @@ -41,7 +41,7 @@ default boolean isInvalid() { @Override default boolean isRemote() { var level = self().getLevel(); - return level == null ? LDLib.isRemote() : level.isClientSide; + return level == null ? GTCEuAPI.isClientThread() : level.isClientSide; } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableItemStackHandler.java b/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableItemStackHandler.java index eb43aeb94d..3dfe771a4f 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableItemStackHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableItemStackHandler.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.machine.trait; -import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; @@ -26,7 +26,9 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.function.Function; /** @@ -166,7 +168,7 @@ public static List handleRecipe(IO io, GTRecipe recipe, List actions) { - if (!GTCEu.isKubeJSLoaded()) return null; + if (!GTCEuAPI.Mods.isKubeJSLoaded()) return null; // noinspection unchecked var actioned = KJSCallWrapper.applyIngredientAction(storage, index, (List) actions); if (!actioned.isEmpty()) return actioned; diff --git a/src/main/java/com/gregtechceu/gtceu/api/pattern/predicates/SimplePredicate.java b/src/main/java/com/gregtechceu/gtceu/api/pattern/predicates/SimplePredicate.java index 21160288f0..b6c23042ed 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/pattern/predicates/SimplePredicate.java +++ b/src/main/java/com/gregtechceu/gtceu/api/pattern/predicates/SimplePredicate.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.api.pattern.predicates; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.pattern.MultiblockState; import com.gregtechceu.gtceu.api.pattern.TraceabilityPredicate; @@ -7,7 +8,6 @@ import com.gregtechceu.gtceu.api.pattern.error.SinglePredicateError; import com.gregtechceu.gtceu.data.lang.LangHandler; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.utils.BlockInfo; import net.minecraft.client.Minecraft; @@ -173,7 +173,7 @@ public boolean testLayer(MultiblockState blockWorldState) { } public List getCandidates() { - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { return candidates == null ? Collections.emptyList() : Arrays.stream(this.candidates.get()).filter(info -> info.getBlockState().getBlock() != Blocks.AIR) .map(blockInfo -> blockInfo.getItemStackForm(Minecraft.getInstance().level, BlockPos.ZERO)) diff --git a/src/main/java/com/gregtechceu/gtceu/api/pipenet/IPipeNode.java b/src/main/java/com/gregtechceu/gtceu/api/pipenet/IPipeNode.java index 741185dd2b..a63fe42f5e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/pipenet/IPipeNode.java +++ b/src/main/java/com/gregtechceu/gtceu/api/pipenet/IPipeNode.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.api.pipenet; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.block.PipeBlock; import com.gregtechceu.gtceu.api.blockentity.IPaintable; import com.gregtechceu.gtceu.api.blockentity.ITickSubscription; @@ -7,8 +8,6 @@ import com.gregtechceu.gtceu.api.capability.ICoverable; import com.gregtechceu.gtceu.api.data.chemical.material.Material; -import com.lowdragmc.lowdraglib.LDLib; - import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; @@ -107,7 +106,7 @@ default boolean isInValid() { default boolean isRemote() { var level = getPipeLevel(); if (level == null) { - return LDLib.isRemote(); + return GTCEuAPI.isClientThread(); } return level.isClientSide; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/pipenet/PipeNetWalker.java b/src/main/java/com/gregtechceu/gtceu/api/pipenet/PipeNetWalker.java index 64d904b00e..25bb61229c 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/pipenet/PipeNetWalker.java +++ b/src/main/java/com/gregtechceu/gtceu/api/pipenet/PipeNetWalker.java @@ -3,8 +3,6 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.utils.GTUtil; -import com.lowdragmc.lowdraglib.LDLib; - import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; @@ -139,7 +137,7 @@ public void traversePipeNet(int maxWalks) { running = false; root.walked.clear(); if (i >= maxWalks) - LDLib.LOGGER.warn("The walker reached the maximum amount of walks {}", i); + GTCEu.LOGGER.warn("The walker reached the maximum amount of walks {}", i); invalid = true; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java index 9e147d54a0..f26e64a3da 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.api.recipe; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.recipe.chance.logic.ChanceLogic; @@ -36,7 +37,7 @@ */ public class GTRecipeSerializer implements RecipeSerializer { - public static final Codec CODEC = makeCodec(GTCEu.isKubeJSLoaded()); + public static final Codec CODEC = makeCodec(GTCEuAPI.Mods.isKubeJSLoaded()); public static final GTRecipeSerializer SERIALIZER = new GTRecipeSerializer(); @@ -131,7 +132,7 @@ public GTRecipe fromNetwork(@NotNull ResourceLocation id, @NotNull FriendlyByteB List conditions = buf.readCollection(c -> new ArrayList<>(), GTRecipeSerializer::conditionReader); List ingredientActions = new ArrayList<>(); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { ingredientActions = KJSCallWrapper.getIngredientActions(buf); } CompoundTag data = buf.readNbt(); @@ -186,7 +187,7 @@ public void toNetwork(FriendlyByteBuf buf, GTRecipe recipe) { (buf1, logic) -> buf1.writeUtf(GTRegistries.CHANCE_LOGICS.getKey(logic))); buf.writeCollection(recipe.conditions, GTRecipeSerializer::conditionWriter); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { KJSCallWrapper.writeIngredientActions(recipe.ingredientActions, buf); } buf.writeNbt(recipe.data); diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java index 5a96ac2d7b..594b99bf68 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.api.recipe.ui; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.capability.recipe.FluidRecipeCapability; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; @@ -19,7 +20,6 @@ import com.gregtechceu.gtceu.integration.jei.recipe.GTRecipeJEICategory; import com.gregtechceu.gtceu.integration.rei.recipe.GTRecipeREICategory; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.gui.editor.configurator.IConfigurableWidget; import com.lowdragmc.lowdraglib.gui.editor.data.Resources; @@ -101,7 +101,7 @@ public GTRecipeTypeUI(@NotNull GTRecipeType recipeType) { public CompoundTag getCustomUI() { if (this.customUICache == null) { ResourceManager resourceManager = null; - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { resourceManager = Minecraft.getInstance().getResourceManager(); } else if (Platform.getMinecraftServer() != null) { resourceManager = Platform.getMinecraftServer().getResourceManager(); @@ -239,25 +239,25 @@ public IEditableUI createEditableUITemplate(final boo progress.add(dualProgressWidget); }); // add recipe button - if (!isJEI && (LDLib.isReiLoaded() || LDLib.isJeiLoaded() || LDLib.isEmiLoaded())) { + if (!isJEI && (GTCEuAPI.Mods.isReiLoaded() || GTCEuAPI.Mods.isJeiLoaded() || GTCEuAPI.Mods.isEmiLoaded())) { for (Widget widget : progress) { template.addWidget(new ButtonWidget(widget.getPosition().x, widget.getPosition().y, widget.getSize().width, widget.getSize().height, IGuiTexture.EMPTY, cd -> { if (cd.isRemote) { - if (LDLib.isReiLoaded()) { + if (GTCEuAPI.Mods.isReiLoaded()) { ViewSearchBuilder.builder().addCategories( recipeType.getCategories().stream() .filter(GTRecipeCategory::isXEIVisible) .map(GTRecipeREICategory::machineCategory) .collect(Collectors.toList())) .open(); - } else if (LDLib.isJeiLoaded()) { + } else if (GTCEuAPI.Mods.isJeiLoaded()) { JEIPlugin.jeiRuntime.getRecipesGui().showTypes( recipeType.getCategories().stream() .filter(GTRecipeCategory::isXEIVisible) .map(GTRecipeJEICategory::machineType) .collect(Collectors.toList())); - } else if (LDLib.isEmiLoaded()) { + } else if (GTCEuAPI.Mods.isEmiLoaded()) { EmiApi.displayRecipeCategory( GTRecipeEMICategory.machineCategory(recipeType.getCategory())); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java b/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java index d0606c286e..13e93cdc5d 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.api.registry.registrate; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.block.IMachineBlock; import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; @@ -22,7 +23,6 @@ import com.gregtechceu.gtceu.common.data.GTRecipeModifiers; import com.gregtechceu.gtceu.config.ConfigHolder; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.client.renderer.IRenderer; import net.minecraft.MethodsReturnNonnullByDefault; @@ -60,7 +60,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; import java.util.function.*; import javax.annotation.ParametersAreNonnullByDefault; @@ -399,7 +402,7 @@ public DEFINITION register() { definition.setEditableUI(editableUI); } definition.setAppearance(appearance); - definition.setRenderer(LDLib.isClient() ? renderer.get() : IRenderer.EMPTY); + definition.setRenderer(GTCEuAPI.isClientSide() ? renderer.get() : IRenderer.EMPTY); definition.setShape(shape); definition.setDefaultPaintingColor(paintingColor); definition.setRenderXEIPreview(renderMultiblockXEIPreview); diff --git a/src/main/java/com/gregtechceu/gtceu/api/transfer/fluid/FluidHandlerList.java b/src/main/java/com/gregtechceu/gtceu/api/transfer/fluid/FluidHandlerList.java index 34e6e9fef7..7c26dd9688 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/transfer/fluid/FluidHandlerList.java +++ b/src/main/java/com/gregtechceu/gtceu/api/transfer/fluid/FluidHandlerList.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.transfer.fluid; -import com.lowdragmc.lowdraglib.LDLib; +import com.gregtechceu.gtceu.GTCEu; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -141,7 +141,7 @@ public CompoundTag serializeNBT() { if (handler instanceof INBTSerializable serializable) { list.add(serializable.serializeNBT()); } else { - LDLib.LOGGER.warn("[FluidHandlerList] internal tank doesn't support serialization"); + GTCEu.LOGGER.warn("[FluidHandlerList] internal tank doesn't support serialization"); } } tag.put("tanks", list); @@ -156,7 +156,7 @@ public void deserializeNBT(CompoundTag nbt) { if (handlers[i] instanceof INBTSerializable serializable) { serializable.deserializeNBT(list.get(i)); } else { - LDLib.LOGGER.warn("[FluidHandlerList] internal tank doesn't support serialization"); + GTCEu.LOGGER.warn("[FluidHandlerList] internal tank doesn't support serialization"); } } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/model/WorkableOverlayModel.java b/src/main/java/com/gregtechceu/gtceu/client/model/WorkableOverlayModel.java index eaae6ae24c..04e5e2ef58 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/model/WorkableOverlayModel.java +++ b/src/main/java/com/gregtechceu/gtceu/client/model/WorkableOverlayModel.java @@ -1,10 +1,10 @@ package com.gregtechceu.gtceu.client.model; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.client.util.StaticFaceBakery; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.utils.GTUtil; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.client.model.ModelFactory; import com.lowdragmc.lowdraglib.client.renderer.IItemRendererProvider; @@ -126,7 +126,7 @@ private TextureAtlasSprite getTextureAtlasSprite(boolean active, boolean working public WorkableOverlayModel(ResourceLocation location) { this.location = location; - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { this.sprites = new EnumMap<>(OverlayFace.class); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/block/PipeBlockRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/block/PipeBlockRenderer.java index 389b231f6a..ede172befc 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/block/PipeBlockRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/block/PipeBlockRenderer.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.client.renderer.block; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconType; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; import com.gregtechceu.gtceu.api.pipenet.IPipeNode; @@ -7,7 +8,6 @@ import com.gregtechceu.gtceu.client.renderer.cover.ICoverableRenderer; import com.gregtechceu.gtceu.common.data.GTMaterialBlocks; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.client.model.ModelFactory; import com.lowdragmc.lowdraglib.client.renderer.IRenderer; @@ -16,7 +16,7 @@ import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.model.*; +import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; @@ -49,7 +49,7 @@ public class PipeBlockRenderer implements IRenderer, ICoverableRenderer { public PipeBlockRenderer(PipeModel pipeModel) { this.pipeModel = pipeModel; - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { registerEvent(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/block/TextureOverrideRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/block/TextureOverrideRenderer.java index 71750efdc3..f7b9ad0f0a 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/block/TextureOverrideRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/block/TextureOverrideRenderer.java @@ -1,8 +1,8 @@ package com.gregtechceu.gtceu.client.renderer.block; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.client.model.SpriteOverrider; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.client.model.ModelFactory; import net.minecraft.client.renderer.block.model.BlockModel; @@ -40,7 +40,7 @@ public class TextureOverrideRenderer extends CTMModelRenderer { public TextureOverrideRenderer(ResourceLocation model, @NotNull Map override) { super(model); this.override = override; - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { registerEvent(); } } @@ -50,7 +50,7 @@ public TextureOverrideRenderer(ResourceLocation model, super(model); this.override = Collections.emptyMap(); this.overrideSupplier = overrideSupplier; - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { registerEvent(); } } @@ -58,7 +58,7 @@ public TextureOverrideRenderer(ResourceLocation model, public TextureOverrideRenderer(ResourceLocation model) { super(model); this.override = Collections.emptyMap(); - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { registerEvent(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/ConveyorCoverRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/ConveyorCoverRenderer.java index 8cbfc2a8f4..66aaa97eb8 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/ConveyorCoverRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/ConveyorCoverRenderer.java @@ -1,12 +1,12 @@ package com.gregtechceu.gtceu.client.renderer.cover; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.cover.CoverBehavior; import com.gregtechceu.gtceu.client.util.StaticFaceBakery; import com.gregtechceu.gtceu.common.cover.ConveyorCover; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.client.model.ModelFactory; import net.minecraft.client.renderer.block.model.BakedQuad; @@ -40,7 +40,7 @@ public class ConveyorCoverRenderer implements ICoverRenderer { .id("block/cover/overlay_conveyor_inverted_emissive"); protected ConveyorCoverRenderer() { - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { registerEvent(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/FluidRegulatorCoverRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/FluidRegulatorCoverRenderer.java index 735d502630..f0f37c124b 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/FluidRegulatorCoverRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/FluidRegulatorCoverRenderer.java @@ -1,12 +1,12 @@ package com.gregtechceu.gtceu.client.renderer.cover; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.cover.CoverBehavior; import com.gregtechceu.gtceu.client.util.StaticFaceBakery; import com.gregtechceu.gtceu.common.cover.PumpCover; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.client.model.ModelFactory; import net.minecraft.client.renderer.block.model.BakedQuad; @@ -37,7 +37,7 @@ public class FluidRegulatorCoverRenderer implements ICoverRenderer { public final static ResourceLocation PUMP_OVERLAY_IN = GTCEu.id("block/cover/overlay_pump_inverted"); protected FluidRegulatorCoverRenderer() { - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { registerEvent(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/PumpCoverRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/PumpCoverRenderer.java index 02efbe0c6e..d4d0b738fd 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/PumpCoverRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/PumpCoverRenderer.java @@ -1,12 +1,12 @@ package com.gregtechceu.gtceu.client.renderer.cover; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.cover.CoverBehavior; import com.gregtechceu.gtceu.client.util.StaticFaceBakery; import com.gregtechceu.gtceu.common.cover.PumpCover; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.client.model.ModelFactory; import net.minecraft.client.renderer.block.model.BakedQuad; @@ -37,7 +37,7 @@ public class PumpCoverRenderer implements ICoverRenderer { public final static ResourceLocation PUMP_OVERLAY_IN = GTCEu.id("block/cover/overlay_pump_inverted"); protected PumpCoverRenderer() { - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { registerEvent(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/RobotArmCoverRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/RobotArmCoverRenderer.java index 1a953cf9db..dc9d3b0df4 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/RobotArmCoverRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/RobotArmCoverRenderer.java @@ -1,12 +1,12 @@ package com.gregtechceu.gtceu.client.renderer.cover; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.cover.CoverBehavior; import com.gregtechceu.gtceu.client.util.StaticFaceBakery; import com.gregtechceu.gtceu.common.cover.RobotArmCover; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.client.model.ModelFactory; import net.minecraft.client.renderer.block.model.BakedQuad; @@ -34,7 +34,7 @@ public class RobotArmCoverRenderer implements ICoverRenderer { public final static ResourceLocation AR_OVERLAY_IN = GTCEu.id("block/cover/overlay_arm_inverted_emissive"); protected RobotArmCoverRenderer() { - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { registerEvent(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/SimpleCoverRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/SimpleCoverRenderer.java index 8f1d7f0f9d..21fbb44d4f 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/SimpleCoverRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/SimpleCoverRenderer.java @@ -1,9 +1,9 @@ package com.gregtechceu.gtceu.client.renderer.cover; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.cover.CoverBehavior; import com.gregtechceu.gtceu.client.util.StaticFaceBakery; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.client.model.ModelFactory; import com.lowdragmc.lowdraglib.utils.ResourceHelper; @@ -35,7 +35,7 @@ public class SimpleCoverRenderer implements ICoverRenderer { public SimpleCoverRenderer(ResourceLocation texture) { this.texture = texture; - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { registerEvent(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/FusionReactorRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/FusionReactorRenderer.java index 176f636da2..fe07f1d965 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/FusionReactorRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/FusionReactorRenderer.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.client.renderer.machine; -import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; import com.gregtechceu.gtceu.api.pattern.util.RelativeDirection; import com.gregtechceu.gtceu.client.renderer.GTRenderTypes; @@ -33,7 +33,7 @@ public void render(BlockEntity blockEntity, float partialTicks, PoseStack stack, int combinedLight, int combinedOverlay) { if (blockEntity instanceof IMachineBlockEntity machineBlockEntity && machineBlockEntity.getMetaMachine() instanceof FusionReactorMachine machine) { - if (GTCEu.isShimmerLoaded()) { + if (GTCEuAPI.Mods.isShimmerLoaded()) { PoseStack finalStack = RenderUtils.copyPoseStack(stack); BloomUtils.entityBloom(source -> renderLightRing(machine, partialTicks, finalStack, source)); } else { diff --git a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java index 985142e0de..5da51523e5 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java +++ b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java @@ -50,7 +50,6 @@ import com.gregtechceu.gtceu.integration.top.forge.TheOneProbePluginImpl; import com.gregtechceu.gtceu.utils.input.KeyBind; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.gui.factory.UIFactory; @@ -201,7 +200,7 @@ private static void initMaterials() { GTCEu.LOGGER.info("Registering addon Materials"); MaterialEvent materialEvent = new MaterialEvent(); ModLoader.get().postEvent(materialEvent); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { KJSEventWrapper.materialRegistry(); } @@ -209,7 +208,7 @@ private static void initMaterials() { // Block entirely new Materials from being added in the Post event managerInternal.closeRegistries(); ModLoader.get().postEvent(new PostMaterialEvent()); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { KJSEventWrapper.materialModification(); } @@ -243,7 +242,7 @@ public void commonSetup(FMLCommonSetupEvent event) { @SubscribeEvent public void loadComplete(FMLLoadCompleteEvent e) { e.enqueueWork(() -> { - if (LDLib.isModLoaded(GTValues.MODID_TOP)) { + if (GTCEuAPI.isModLoaded(GTValues.MODID_TOP)) { GTCEu.LOGGER.info("TheOneProbe found. Enabling integration..."); TheOneProbePluginImpl.init(); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedEnergyDetectorCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedEnergyDetectorCover.java index 4722ee30f0..5d7c06cd5e 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedEnergyDetectorCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedEnergyDetectorCover.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.common.cover.detector; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.capability.ICoverable; import com.gregtechceu.gtceu.api.capability.IEnergyInfoProvider; import com.gregtechceu.gtceu.api.cover.CoverDefinition; @@ -11,7 +12,6 @@ import com.gregtechceu.gtceu.utils.GTMath; import com.gregtechceu.gtceu.utils.RedstoneUtil; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.gui.widget.LabelWidget; import com.lowdragmc.lowdraglib.gui.widget.TextBoxWidget; import com.lowdragmc.lowdraglib.gui.widget.Widget; @@ -157,7 +157,7 @@ public void updateScreen() { } private void initializeMinMaxInputs(boolean wasPercent) { - if (LDLib.isRemote() || minValueInput == null || maxValueInput == null) + if (GTCEuAPI.isClientThread() || minValueInput == null || maxValueInput == null) return; long energyCapacity = getEnergyInfoProvider().getEnergyInfo().capacity().longValue(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java index 24b3247c2b..9e3eda3646 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java @@ -1,6 +1,5 @@ package com.gregtechceu.gtceu.common.data; -import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.data.DimensionMarker; import com.gregtechceu.gtceu.api.registry.GTRegistries; @@ -72,7 +71,7 @@ private static BlockEntry createMarker(String name) { public static void init() { ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.DIMENSION_MARKERS, DimensionMarker.class)); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistries.DIMENSION_MARKERS.getRegistryName()); } GTRegistries.DIMENSION_MARKERS.freeze(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java index 7c31949f65..c231003ea2 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java @@ -1,6 +1,5 @@ package com.gregtechceu.gtceu.common.data; -import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.addon.AddonFinder; import com.gregtechceu.gtceu.api.addon.IGTAddon; @@ -161,7 +160,7 @@ public static Element createAndRegister(long protons, long neutrons, long halfLi public static void init() { AddonFinder.getAddons().forEach(IGTAddon::registerElements); ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.ELEMENTS, Element.class)); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistries.ELEMENTS.getRegistryName()); } GTRegistries.ELEMENTS.freeze(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java index 3d6a960319..a28b8f1834 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java @@ -34,8 +34,6 @@ import com.gregtechceu.gtceu.utils.GTUtil; import com.gregtechceu.gtceu.utils.SupplierMemoizer; -import com.lowdragmc.lowdraglib.LDLib; - import net.minecraft.client.color.item.ItemColor; import net.minecraft.client.renderer.item.ItemProperties; import net.minecraft.client.renderer.item.ItemPropertyFunction; @@ -76,7 +74,8 @@ import java.util.function.Supplier; import java.util.stream.Collectors; -import static com.gregtechceu.gtceu.common.data.GTCreativeModeTabs.*; +import static com.gregtechceu.gtceu.common.data.GTCreativeModeTabs.ITEM; +import static com.gregtechceu.gtceu.common.data.GTCreativeModeTabs.TOOL; import static com.gregtechceu.gtceu.common.data.GTModels.createTextureModel; import static com.gregtechceu.gtceu.common.data.GTModels.overrideModel; import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; @@ -2655,7 +2654,7 @@ public static NonNullConsumer attach(IItemComponen public static NonNullConsumer modelPredicate(ResourceLocation predicate, Function property) { return item -> { - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { ItemProperties.register(item, predicate, (itemStack, c, l, i) -> property.apply(itemStack)); } }; @@ -2665,7 +2664,7 @@ public static NonNullConsumer modelPredicate(ResourceLocatio public static NonNullConsumer modelPredicate(ResourceLocation predicate, Supplier> property) { return item -> { - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { ItemProperties.register(item, predicate, property.get().get()); } }; diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java index c01c9c29bf..81cae115d3 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java @@ -7,8 +7,10 @@ import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; import com.gregtechceu.gtceu.api.data.RotationState; -import com.gregtechceu.gtceu.api.machine.*; -import com.gregtechceu.gtceu.api.machine.multiblock.*; +import com.gregtechceu.gtceu.api.machine.MachineDefinition; +import com.gregtechceu.gtceu.api.machine.SimpleTieredMachine; +import com.gregtechceu.gtceu.api.machine.multiblock.CleanroomType; +import com.gregtechceu.gtceu.api.machine.multiblock.PartAbility; import com.gregtechceu.gtceu.api.machine.steam.SimpleSteamMachine; import com.gregtechceu.gtceu.api.machine.steam.SteamBoilerMachine; import com.gregtechceu.gtceu.api.registry.GTRegistries; @@ -16,7 +18,6 @@ import com.gregtechceu.gtceu.client.util.TooltipHelper; import com.gregtechceu.gtceu.common.data.machines.*; import com.gregtechceu.gtceu.common.machine.electric.*; -import com.gregtechceu.gtceu.common.machine.multiblock.electric.*; import com.gregtechceu.gtceu.common.machine.multiblock.part.*; import com.gregtechceu.gtceu.common.machine.steam.SteamLiquidBoilerMachine; import com.gregtechceu.gtceu.common.machine.steam.SteamMinerMachine; @@ -41,16 +42,13 @@ import com.google.common.math.IntMath; import it.unimi.dsi.fastutil.Pair; -import java.util.*; +import java.util.List; import java.util.function.BiConsumer; import static com.gregtechceu.gtceu.api.GTValues.*; -import static com.gregtechceu.gtceu.api.capability.recipe.IO.*; -import static com.gregtechceu.gtceu.api.pattern.Predicates.*; -import static com.gregtechceu.gtceu.api.pattern.util.RelativeDirection.*; -import static com.gregtechceu.gtceu.common.data.GTBlocks.*; +import static com.gregtechceu.gtceu.api.capability.recipe.IO.IN; +import static com.gregtechceu.gtceu.api.capability.recipe.IO.OUT; import static com.gregtechceu.gtceu.common.data.GTCreativeModeTabs.MACHINE; -import static com.gregtechceu.gtceu.common.data.GTMaterials.*; import static com.gregtechceu.gtceu.common.data.GTRecipeTypes.DUMMY_RECIPES; import static com.gregtechceu.gtceu.common.data.GTRecipeTypes.STEAM_BOILER_RECIPES; import static com.gregtechceu.gtceu.common.data.machines.GTMachineUtils.*; @@ -1072,13 +1070,13 @@ public static void init() { GCYMMachines.init(); GTResearchMachines.init(); - if (GTCEu.isAE2Loaded()) { + if (GTCEuAPI.Mods.isAE2Loaded()) { GTAEMachines.init(); } GTMultiMachines.init(); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistries.MACHINES.getRegistryName()); } ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.MACHINES, MachineDefinition.class)); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java index 5ff36d3e8e..46a703cfad 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java @@ -48,7 +48,7 @@ public static void init() { // Remove these categories, so they don't get registered in XEI at all, dev or not GTRegistries.RECIPE_CATEGORIES.remove(DUMMY.registryKey); GTRegistries.RECIPE_CATEGORIES.remove(GTRecipeTypes.FURNACE_RECIPES.getCategory().registryKey); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistries.RECIPE_CATEGORIES.getRegistryName()); } ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.RECIPE_CATEGORIES, GTRecipeCategory.class)); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java index 390c30953e..8eb8cf7d2b 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java @@ -689,7 +689,7 @@ public static GTRecipeType register(String name, String group, RecipeType... public static void init() { GCYMRecipeTypes.init(); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistries.RECIPE_TYPES.getRegistryName()); } ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.RECIPE_TYPES, GTRecipeType.class)); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java index 34dcd6c6dd..4c55ded13f 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java @@ -17,7 +17,9 @@ import com.gregtechceu.gtceu.api.pattern.TraceabilityPredicate; import com.gregtechceu.gtceu.client.renderer.machine.gcym.LargeChemicalBathRenderer; import com.gregtechceu.gtceu.client.renderer.machine.gcym.LargeMixerRenderer; -import com.gregtechceu.gtceu.common.data.*; +import com.gregtechceu.gtceu.common.data.GTMaterials; +import com.gregtechceu.gtceu.common.data.GTRecipeModifiers; +import com.gregtechceu.gtceu.common.data.GTRecipeTypes; import com.gregtechceu.gtceu.common.machine.multiblock.electric.DistillationTowerMachine; import com.gregtechceu.gtceu.common.machine.multiblock.electric.gcym.LargeChemicalBathMachine; import com.gregtechceu.gtceu.common.machine.multiblock.electric.gcym.LargeMixerMachine; @@ -632,7 +634,7 @@ public static void init() {} .pattern(definition -> { TraceabilityPredicate casingPredicate = blocks(CASING_WATERTIGHT.get()).setMinGlobalLimited(40); TraceabilityPredicate exportPredicate = abilities(PartAbility.EXPORT_FLUIDS_1X); - if (GTCEu.isAE2Loaded()) + if (GTCEuAPI.Mods.isAE2Loaded()) exportPredicate = exportPredicate.or(blocks(GTAEMachines.FLUID_EXPORT_HATCH_ME.get())); exportPredicate.setMaxLayerLimited(1); return FactoryBlockPattern.start(RIGHT, BACK, UP) diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMultiMachines.java b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMultiMachines.java index 3d1dee1c12..67e4e2cb4a 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMultiMachines.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMultiMachines.java @@ -50,14 +50,13 @@ import java.util.Locale; import static com.gregtechceu.gtceu.api.GTValues.*; -import static com.gregtechceu.gtceu.api.GTValues.IV; import static com.gregtechceu.gtceu.api.pattern.Predicates.*; -import static com.gregtechceu.gtceu.api.pattern.Predicates.abilities; import static com.gregtechceu.gtceu.api.pattern.util.RelativeDirection.*; import static com.gregtechceu.gtceu.common.data.GTBlocks.*; import static com.gregtechceu.gtceu.common.data.GTMachines.*; -import static com.gregtechceu.gtceu.common.data.GTMaterials.*; -import static com.gregtechceu.gtceu.common.data.GTRecipeTypes.*; +import static com.gregtechceu.gtceu.common.data.GTMaterials.Aluminium; +import static com.gregtechceu.gtceu.common.data.GTMaterials.DrillingFluid; +import static com.gregtechceu.gtceu.common.data.GTRecipeTypes.DUMMY_RECIPES; import static com.gregtechceu.gtceu.common.data.machines.GTMachineUtils.*; import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; import static com.gregtechceu.gtceu.utils.FormattingUtil.toRomanNumeral; @@ -447,7 +446,7 @@ public class GTMultiMachines { .appearanceBlock(CASING_STAINLESS_CLEAN) .pattern(definition -> { TraceabilityPredicate exportPredicate = abilities(PartAbility.EXPORT_FLUIDS_1X); - if (GTCEu.isAE2Loaded()) + if (GTCEuAPI.Mods.isAE2Loaded()) exportPredicate = exportPredicate.or(blocks(GTAEMachines.FLUID_EXPORT_HATCH_ME.get())); exportPredicate.setMaxLayerLimited(1); return FactoryBlockPattern.start(RIGHT, BACK, UP) @@ -845,7 +844,7 @@ public class GTMultiMachines { tooltip.add(Component.translatable("gtceu.machine.cleanroom.tooltip.6")); tooltip.add(Component.translatable("gtceu.machine.cleanroom.tooltip.7")); // tooltip.add(Component.translatable("gtceu.machine.cleanroom.tooltip.8")); - if (GTCEu.isAE2Loaded()) { + if (GTCEuAPI.Mods.isAE2Loaded()) { tooltip.add( Component.translatable(AEConfig.instance().getChannelMode() == ChannelMode.INFINITE ? "gtceu.machine.cleanroom.tooltip.ae2.no_channels" : diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java b/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java index 6b06bb9a6e..84f69b40ca 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java @@ -1,6 +1,5 @@ package com.gregtechceu.gtceu.common.item; -import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.blockentity.IPaintable; @@ -234,7 +233,7 @@ private boolean handleSpecialBlockEntities(BlockEntity first, int limit, UseOnCo if (player == null) { return false; } - if (GTCEu.isAE2Loaded() && AE2CallWrapper.isAE2Cable(first)) { + if (GTCEuAPI.Mods.isAE2Loaded() && AE2CallWrapper.isAE2Cable(first)) { var collected = AE2CallWrapper.collect(first, limit); var ae2Color = color == null ? AEColor.TRANSPARENT : AEColor.values()[color.ordinal()]; for (var c : collected) { diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/ItemMagnetBehavior.java b/src/main/java/com/gregtechceu/gtceu/common/item/ItemMagnetBehavior.java index b4027fc726..df6c29ffe3 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/ItemMagnetBehavior.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/ItemMagnetBehavior.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.common.item; -import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.GTCapabilityHelper; import com.gregtechceu.gtceu.api.capability.IElectricItem; @@ -175,7 +175,7 @@ private boolean hasMagnet(@NotNull Player player) { } } - if (!GTCEu.isCuriosLoaded()) { + if (!GTCEuAPI.Mods.isCuriosLoaded()) { return false; } return CuriosUtils.hasMagnetCurios(player); diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/HullMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/HullMachine.java index c7fd20581e..510aa0b2ae 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/HullMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/HullMachine.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.common.machine.electric; -import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; import com.gregtechceu.gtceu.api.machine.multiblock.part.MultiblockPartMachine; @@ -35,7 +35,7 @@ public class HullMachine extends TieredPartMachine { public HullMachine(IMachineBlockEntity holder, int tier) { super(holder, tier); - if (GTCEu.isAE2Loaded()) { + if (GTCEuAPI.Mods.isAE2Loaded()) { this.gridNodeHost = new GridNodeHostTrait(this); } else { this.gridNodeHost = null; @@ -52,7 +52,7 @@ protected void reinitializeEnergyContainer() { @Override public void onLoad() { super.onLoad(); - if (GTCEu.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity && + if (GTCEuAPI.Mods.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity && getLevel() instanceof ServerLevel level) { level.getServer().tell(new TickTask(0, connectedBlockEntity::init)); } @@ -61,7 +61,7 @@ public void onLoad() { @Override public void onUnload() { super.onUnload(); - if (GTCEu.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity) { + if (GTCEuAPI.Mods.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity) { connectedBlockEntity.getMainNode().destroy(); } } @@ -70,7 +70,7 @@ public void onUnload() { public void setFrontFacing(Direction facing) { super.setFrontFacing(facing); if (isFacingValid(facing)) { - if (GTCEu.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity) { + if (GTCEuAPI.Mods.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity) { connectedBlockEntity.init(); } } @@ -84,7 +84,7 @@ public ManagedFieldHolder getFieldHolder() { @Override public void saveCustomPersistedData(@NotNull CompoundTag tag, boolean forDrop) { super.saveCustomPersistedData(tag, forDrop); - if (GTCEu.isAE2Loaded() && gridNodeHost instanceof IGridConnectedBlockEntity connectedBlockEntity) { + if (GTCEuAPI.Mods.isAE2Loaded() && gridNodeHost instanceof IGridConnectedBlockEntity connectedBlockEntity) { CompoundTag nbt = new CompoundTag(); connectedBlockEntity.getMainNode().saveToNBT(nbt); tag.put("grid_node", nbt); @@ -94,7 +94,7 @@ public void saveCustomPersistedData(@NotNull CompoundTag tag, boolean forDrop) { @Override public void loadCustomPersistedData(@NotNull CompoundTag tag) { super.loadCustomPersistedData(tag); - if (GTCEu.isAE2Loaded() && gridNodeHost instanceof IGridConnectedBlockEntity connectedBlockEntity) { + if (GTCEuAPI.Mods.isAE2Loaded() && gridNodeHost instanceof IGridConnectedBlockEntity connectedBlockEntity) { connectedBlockEntity.getMainNode().loadFromNBT(tag.getCompound("grid_node")); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/DiodePartMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/DiodePartMachine.java index 826a880069..ed1f941348 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/DiodePartMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/DiodePartMachine.java @@ -1,12 +1,12 @@ package com.gregtechceu.gtceu.common.machine.multiblock.part; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; import com.gregtechceu.gtceu.api.machine.multiblock.part.TieredIOPartMachine; import com.gregtechceu.gtceu.api.machine.trait.NotifiableEnergyContainer; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.syncdata.annotation.DescSynced; import com.lowdragmc.lowdraglib.syncdata.annotation.Persisted; import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder; @@ -69,7 +69,7 @@ protected int getMaxAmperage() { public void onLoad() { super.onLoad(); - if (!LDLib.isRemote()) + if (!GTCEuAPI.isClientThread()) reinitializeEnergyContainer(); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/owner/IMachineOwner.java b/src/main/java/com/gregtechceu/gtceu/common/machine/owner/IMachineOwner.java index 01107662b5..5105682751 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/owner/IMachineOwner.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/owner/IMachineOwner.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.common.machine.owner; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; import com.gregtechceu.gtceu.config.ConfigHolder; @@ -66,8 +67,8 @@ static boolean canBreakOwnerMachine(Player player, IMachineBlockEntity machine) enum MachineOwnerType { PLAYER, - FTB(GTCEu::isFTBTeamsLoaded, "FTB Teams"), - ARGONAUTS(GTCEu::isArgonautsLoaded, "Argonauts Guild"); + FTB(GTCEuAPI.Mods::isFTBTeamsLoaded, "FTB Teams"), + ARGONAUTS(GTCEuAPI.Mods::isArgonautsLoaded, "Argonauts Guild"); public static final MachineOwnerType[] VALUES = values(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/pipelike/cable/EnergyNetWalker.java b/src/main/java/com/gregtechceu/gtceu/common/pipelike/cable/EnergyNetWalker.java index a81994d1f2..c4404a0f6d 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/pipelike/cable/EnergyNetWalker.java +++ b/src/main/java/com/gregtechceu/gtceu/common/pipelike/cable/EnergyNetWalker.java @@ -1,13 +1,12 @@ package com.gregtechceu.gtceu.common.pipelike.cable; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.capability.IEnergyContainer; import com.gregtechceu.gtceu.api.capability.forge.GTCapability; import com.gregtechceu.gtceu.api.data.chemical.material.properties.WireProperties; import com.gregtechceu.gtceu.api.pipenet.PipeNetWalker; import com.gregtechceu.gtceu.common.blockentity.CableBlockEntity; -import com.lowdragmc.lowdraglib.LDLib; - import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.level.block.entity.BlockEntity; @@ -28,7 +27,7 @@ public static List createNetData(EnergyNet pipeNet, BlockPos so walker.traversePipeNet(); return walker.routes; } catch (Exception e) { - LDLib.LOGGER.error("error while create net data for energynet", e); + GTCEu.LOGGER.error("error while create net data for energynet", e); } return null; } diff --git a/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockFluidLoader.java b/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockFluidLoader.java index 18ea0b582d..b2ba6952a9 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockFluidLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockFluidLoader.java @@ -1,6 +1,5 @@ package com.gregtechceu.gtceu.data.loader; -import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.addon.AddonFinder; import com.gregtechceu.gtceu.api.addon.IGTAddon; @@ -52,7 +51,7 @@ protected void apply(Map resourceList, ResourceMa AddonFinder.getAddons().forEach(IGTAddon::registerFluidVeins); ModLoader.get().postEvent( new GTCEuAPI.RegisterEvent<>(GTRegistries.BEDROCK_FLUID_DEFINITIONS, BedrockFluidDefinition.class)); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { KJSCallWrapper.fireKJSEvent(); } RegistryOps ops = RegistryOps.create(JsonOps.INSTANCE, GTRegistries.builtinRegistry()); diff --git a/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java b/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java index a8f93b1da7..9235a3bab6 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java @@ -1,6 +1,5 @@ package com.gregtechceu.gtceu.data.loader; -import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.addon.AddonFinder; import com.gregtechceu.gtceu.api.addon.IGTAddon; @@ -55,7 +54,7 @@ protected void apply(Map resourceList, ResourceMa AddonFinder.getAddons().forEach(IGTAddon::registerBedrockOreVeins); ModLoader.get().postEvent( new GTCEuAPI.RegisterEvent<>(GTRegistries.BEDROCK_ORE_DEFINITIONS, BedrockOreDefinition.class)); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { KJSCallWrapper.fireKJSEvent(); } diff --git a/src/main/java/com/gregtechceu/gtceu/data/loader/GTOreLoader.java b/src/main/java/com/gregtechceu/gtceu/data/loader/GTOreLoader.java index 6bd92c81dc..f28ed5ad27 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/loader/GTOreLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/loader/GTOreLoader.java @@ -1,6 +1,5 @@ package com.gregtechceu.gtceu.data.loader; -import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.addon.AddonFinder; import com.gregtechceu.gtceu.api.addon.IGTAddon; @@ -56,7 +55,7 @@ protected void apply(Map resourceList, ResourceMa GTOres.init(); AddonFinder.getAddons().forEach(IGTAddon::registerOreVeins); ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.ORE_VEINS, GTOreDefinition.class)); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { KJSCallWrapper.fireKJSEvent(); } diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/CraftingComponent.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/CraftingComponent.java index 3e2c036b7a..0eccca7777 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/CraftingComponent.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/CraftingComponent.java @@ -1,6 +1,5 @@ package com.gregtechceu.gtceu.data.recipe; -import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.chemical.material.properties.BlastProperty; @@ -926,7 +925,7 @@ public static void initializeComponents() { }).collect(Collectors.toMap(data -> (Integer) data[0], data -> data[1]))); MinecraftForge.EVENT_BUS.post(new CraftingComponentModificationEvent()); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEuAPI.Mods.isKubeJSLoaded()) { KJSCallWrapper.craftingComponentModification(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/BlastingRecipeBuilder.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/BlastingRecipeBuilder.java index fc9bf7c98e..99ae06bf22 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/BlastingRecipeBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/BlastingRecipeBuilder.java @@ -1,8 +1,8 @@ package com.gregtechceu.gtceu.data.recipe.builder; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.recipe.ingredient.NBTIngredient; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.utils.NBTToJsonConverter; import net.minecraft.core.registries.BuiltInRegistries; @@ -101,7 +101,7 @@ public void toJson(JsonObject json) { } if (output.isEmpty()) { - LDLib.LOGGER.error("shapeless recipe {} output is empty", id); + GTCEu.LOGGER.error("shapeless recipe {} output is empty", id); throw new IllegalArgumentException(id + ": output items is empty"); } else { JsonObject result = new JsonObject(); diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/CampfireRecipeBuilder.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/CampfireRecipeBuilder.java index 1239b8d0cf..f6a670d3a0 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/CampfireRecipeBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/CampfireRecipeBuilder.java @@ -1,8 +1,8 @@ package com.gregtechceu.gtceu.data.recipe.builder; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.recipe.ingredient.NBTIngredient; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.utils.NBTToJsonConverter; import net.minecraft.core.registries.BuiltInRegistries; @@ -101,7 +101,7 @@ public void toJson(JsonObject json) { } if (output.isEmpty()) { - LDLib.LOGGER.error("shapeless recipe {} output is empty", id); + GTCEu.LOGGER.error("shapeless recipe {} output is empty", id); throw new IllegalArgumentException(id + ": output items is empty"); } else { JsonObject result = new JsonObject(); diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/ShapelessRecipeBuilder.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/ShapelessRecipeBuilder.java index a5d89f33a2..e53e5dda97 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/ShapelessRecipeBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/ShapelessRecipeBuilder.java @@ -1,8 +1,8 @@ package com.gregtechceu.gtceu.data.recipe.builder; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.recipe.ingredient.NBTIngredient; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.utils.NBTToJsonConverter; import net.minecraft.core.registries.BuiltInRegistries; @@ -106,7 +106,7 @@ public void toJson(JsonObject json) { json.add("ingredients", jsonarray); if (output.isEmpty()) { - LDLib.LOGGER.error("shapeless recipe {} output is empty", id); + GTCEu.LOGGER.error("shapeless recipe {} output is empty", id); throw new IllegalArgumentException(id + ": output items is empty"); } else { JsonObject result = new JsonObject(); diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/SmeltingRecipeBuilder.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/SmeltingRecipeBuilder.java index 1206bfa24f..5deb55832a 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/SmeltingRecipeBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/SmeltingRecipeBuilder.java @@ -1,8 +1,8 @@ package com.gregtechceu.gtceu.data.recipe.builder; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.recipe.ingredient.NBTIngredient; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.utils.NBTToJsonConverter; import net.minecraft.core.registries.BuiltInRegistries; @@ -101,7 +101,7 @@ public void toJson(JsonObject json) { } if (output.isEmpty()) { - LDLib.LOGGER.error("shapeless recipe {} output is empty", id); + GTCEu.LOGGER.error("shapeless recipe {} output is empty", id); throw new IllegalArgumentException(id + ": output items is empty"); } else { JsonObject result = new JsonObject(); diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/SmokingRecipeBuilder.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/SmokingRecipeBuilder.java index 2cf526d892..607332899f 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/SmokingRecipeBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/SmokingRecipeBuilder.java @@ -1,8 +1,8 @@ package com.gregtechceu.gtceu.data.recipe.builder; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.recipe.ingredient.NBTIngredient; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.utils.NBTToJsonConverter; import net.minecraft.core.registries.BuiltInRegistries; @@ -101,7 +101,7 @@ public void toJson(JsonObject json) { } if (output.isEmpty()) { - LDLib.LOGGER.error("shapeless recipe {} output is empty", id); + GTCEu.LOGGER.error("shapeless recipe {} output is empty", id); throw new IllegalArgumentException(id + ": output items is empty"); } else { JsonObject result = new JsonObject(); diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MachineRecipeLoader.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MachineRecipeLoader.java index 9da21d0b69..ced9c0afb1 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MachineRecipeLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MachineRecipeLoader.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.data.recipe.misc; -import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; import com.gregtechceu.gtceu.api.data.chemical.material.MarkerMaterial; @@ -1486,7 +1486,7 @@ private static void registerHatchConversion(Consumer provider) { VanillaRecipeHelper.addShapedRecipe(provider, "steam_bus_input_to_output", STEAM_IMPORT_BUS.asStack(), "d", "B", 'B', STEAM_EXPORT_BUS.asStack()); - if (GTCEu.isAE2Loaded()) { + if (GTCEuAPI.Mods.isAE2Loaded()) { VanillaRecipeHelper.addShapedRecipe(provider, "me_fluid_hatch_output_to_input", GTAEMachines.FLUID_IMPORT_HATCH_ME.asStack(), "d", "B", 'B', GTAEMachines.FLUID_EXPORT_HATCH_ME.asStack()); diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java index 46e9f13356..cd2f6f0ff5 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java @@ -1,6 +1,5 @@ package com.gregtechceu.gtceu.data.recipe.misc; -import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; @@ -554,7 +553,7 @@ public static void init(Consumer provider) { // ME Parts - if (GTCEu.isAE2Loaded()) { + if (GTCEuAPI.Mods.isAE2Loaded()) { ItemStack meInterface = AEParts.INTERFACE.stack(1); ItemStack accelerationCard = AEItems.SPEED_CARD.stack(2); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java index 2cb7261b5f..9bf60e5668 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.integration.emi; -import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.registry.GTRegistries; @@ -21,7 +21,6 @@ import com.gregtechceu.gtceu.integration.emi.recipe.GTEmiRecipeHandler; import com.gregtechceu.gtceu.integration.emi.recipe.GTRecipeEMICategory; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.gui.modular.ModularUIContainer; @@ -62,10 +61,10 @@ public void register(EmiRegistry registry) { } } registry.addRecipeHandler(ModularUIContainer.MENUTYPE, new GTEmiRecipeHandler()); - if (GTCEu.isAE2Loaded()) { + if (GTCEuAPI.Mods.isAE2Loaded()) { registry.addRecipeHandler(PatternEncodingTermMenu.TYPE, new Ae2PatternTerminalHandler<>()); } - if (LDLib.isModLoaded(GTValues.MODID_AE2WTLIB)) { + if (GTCEuAPI.isModLoaded(GTValues.MODID_AE2WTLIB)) { registry.addRecipeHandler(WETMenu.TYPE, new Ae2PatternTerminalHandler<>()); } registry.addCategory(GTProgrammedCircuitCategory.CATEGORY); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jade/GTJadePlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/jade/GTJadePlugin.java index e471257121..cdfa3df090 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jade/GTJadePlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/jade/GTJadePlugin.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.integration.jade; -import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; import com.gregtechceu.gtceu.common.blockentity.FluidPipeBlockEntity; import com.gregtechceu.gtceu.common.data.GTMaterialItems; @@ -42,7 +42,7 @@ public void register(IWailaCommonRegistration registration) { registration.registerBlockDataProvider(new HazardCleanerBlockProvider(), BlockEntity.class); registration.registerBlockDataProvider(new TransformerBlockProvider(), BlockEntity.class); registration.registerBlockDataProvider(new PrimitivePumpBlockProvider(), BlockEntity.class); - if (GTCEu.isAE2Loaded()) { + if (GTCEuAPI.Mods.isAE2Loaded()) { registration.registerBlockDataProvider(new MEPatternBufferProxyProvider(), BlockEntity.class); registration.registerBlockDataProvider(new MEPatternBufferProvider(), BlockEntity.class); } @@ -71,7 +71,7 @@ public void registerClient(IWailaClientRegistration registration) { registration.registerBlockComponent(new HazardCleanerBlockProvider(), Block.class); registration.registerBlockComponent(new TransformerBlockProvider(), Block.class); registration.registerBlockComponent(new PrimitivePumpBlockProvider(), Block.class); - if (GTCEu.isAE2Loaded()) { + if (GTCEuAPI.Mods.isAE2Loaded()) { registration.registerBlockComponent(new MEPatternBufferProxyProvider(), Block.class); registration.registerBlockComponent(new MEPatternBufferProvider(), Block.class); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java index 5eb9c6fd08..c2dcd56294 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.integration.jei; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTFluids; @@ -19,7 +20,6 @@ import com.gregtechceu.gtceu.integration.jei.recipe.GTRecipeJEICategory; import com.gregtechceu.gtceu.integration.jei.subtype.PotionFluidSubtypeInterpreter; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.Platform; import net.minecraft.MethodsReturnNonnullByDefault; @@ -59,7 +59,7 @@ public ResourceLocation getPluginUid() { @Override public void registerCategories(@NotNull IRecipeCategoryRegistration registry) { - if (LDLib.isReiLoaded() || LDLib.isEmiLoaded()) return; + if (GTCEuAPI.Mods.isReiLoaded() || GTCEuAPI.Mods.isEmiLoaded()) return; GTCEu.LOGGER.info("JEI register categories"); IJeiHelpers jeiHelpers = registry.getJeiHelpers(); registry.addRecipeCategories(new MultiblockInfoCategory(jeiHelpers)); @@ -79,7 +79,7 @@ public void registerCategories(@NotNull IRecipeCategoryRegistration registry) { @Override public void registerRecipeCatalysts(@NotNull IRecipeCatalystRegistration registration) { - if (LDLib.isReiLoaded() || LDLib.isEmiLoaded()) return; + if (GTCEuAPI.Mods.isReiLoaded() || GTCEuAPI.Mods.isEmiLoaded()) return; GTRecipeJEICategory.registerRecipeCatalysts(registration); if (!ConfigHolder.INSTANCE.compat.hideOreProcessingDiagrams) GTOreProcessingInfoCategory.registerRecipeCatalysts(registration); @@ -94,7 +94,7 @@ public void registerRecipeCatalysts(@NotNull IRecipeCatalystRegistration registr @Override public void registerRecipes(@NotNull IRecipeRegistration registration) { - if (LDLib.isReiLoaded() || LDLib.isEmiLoaded()) return; + if (GTCEuAPI.Mods.isReiLoaded() || GTCEuAPI.Mods.isEmiLoaded()) return; GTCEu.LOGGER.info("JEI register"); MultiblockInfoCategory.registerRecipes(registration); GTRecipeJEICategory.registerRecipes(registration); @@ -110,7 +110,7 @@ public void registerRecipes(@NotNull IRecipeRegistration registration) { @Override public void registerIngredients(@NotNull IModIngredientRegistration registry) { - if (LDLib.isReiLoaded() || LDLib.isEmiLoaded()) return; + if (GTCEuAPI.Mods.isReiLoaded() || GTCEuAPI.Mods.isEmiLoaded()) return; GTCEu.LOGGER.info("JEI register ingredients"); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java index 0a0dee9336..1f54587b0b 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.integration.xei.widgets; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.recipe.CWURecipeCapability; import com.gregtechceu.gtceu.api.capability.recipe.IO; @@ -17,7 +18,6 @@ import com.gregtechceu.gtceu.common.recipe.condition.DimensionCondition; import com.gregtechceu.gtceu.utils.FormattingUtil; -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup; import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; import com.lowdragmc.lowdraglib.gui.texture.TextTexture; @@ -233,7 +233,7 @@ private int getVoltageXOffset() { case IV -> 12; default -> 14; }; - if (!LDLib.isEmiLoaded()) { + if (!GTCEuAPI.Mods.isEmiLoaded()) { x -= 3; } return x; diff --git a/src/main/java/com/gregtechceu/gtceu/utils/GTUtil.java b/src/main/java/com/gregtechceu/gtceu/utils/GTUtil.java index 401acac5e0..f60f6591d8 100644 --- a/src/main/java/com/gregtechceu/gtceu/utils/GTUtil.java +++ b/src/main/java/com/gregtechceu/gtceu/utils/GTUtil.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.utils; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey; @@ -10,8 +11,6 @@ import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.data.recipe.CustomTags; -import com.lowdragmc.lowdraglib.LDLib; - import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; @@ -303,7 +302,7 @@ public static Class getActualTypeParameter(Class thisClas } public static boolean isShiftDown() { - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { var id = Minecraft.getInstance().getWindow().getWindow(); return InputConstants.isKeyDown(id, GLFW.GLFW_KEY_LEFT_SHIFT) || InputConstants.isKeyDown(id, GLFW.GLFW_KEY_LEFT_SHIFT); @@ -312,7 +311,7 @@ public static boolean isShiftDown() { } public static boolean isCtrlDown() { - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { var id = Minecraft.getInstance().getWindow().getWindow(); return InputConstants.isKeyDown(id, GLFW.GLFW_KEY_LEFT_CONTROL) || InputConstants.isKeyDown(id, GLFW.GLFW_KEY_RIGHT_CONTROL); @@ -321,7 +320,7 @@ public static boolean isCtrlDown() { } public static boolean isAltDown() { - if (LDLib.isClient()) { + if (GTCEuAPI.isClientSide()) { var id = Minecraft.getInstance().getWindow().getWindow(); return InputConstants.isKeyDown(id, GLFW.GLFW_KEY_LEFT_ALT) || InputConstants.isKeyDown(id, GLFW.GLFW_KEY_RIGHT_ALT); @@ -431,7 +430,7 @@ public static boolean canSeeSunClearly(Level world, BlockPos blockPos) { } ResourceLocation javdVoidBiome = new ResourceLocation("javd", "void"); - if (GTCEu.isJAVDLoaded() && + if (GTCEuAPI.Mods.isJAVDLoaded() && world.registryAccess().registryOrThrow(Registries.BIOME).getKey(biome).equals(javdVoidBiome)) { return !world.isDay(); } else return world.isDay(); From 4e216cb440dfd8b08920b377477b805ee81d0f8d Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 21 Dec 2024 11:06:34 +0200 Subject: [PATCH 10/24] feck --- docs/content/Development/General-Topics/Global-Data.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/Development/General-Topics/Global-Data.md b/docs/content/Development/General-Topics/Global-Data.md index 82a00718c1..0d40830191 100644 --- a/docs/content/Development/General-Topics/Global-Data.md +++ b/docs/content/Development/General-Topics/Global-Data.md @@ -18,7 +18,7 @@ When doing so, you need to ensure that remote and serverside instances don't get To make working with this requirement easier, You can use `SideLocal` to store your global data. It is similar to Java's `ThreadLocal`, but operates on the game's sides instead. -If you are currently on the remote side (`GTCEuAPI.isClientSide()` / on the client's `main` thread), it will return the +If you are currently on the remote side (`GTCEuAPI.isClientThread()` / on the client's `main` thread), it will return the remote side's instance of your data. Otherwise, you will get the server side's instance. ??? example "Example Usage" From aa1ddc2720d2c1c957cd869d081037b392a90245 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 21 Dec 2024 12:15:00 +0200 Subject: [PATCH 11/24] thanks tom --- .../com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java b/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java index 9ebcd293fd..5169df99f2 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/IMachineBlockEntity.java @@ -58,7 +58,7 @@ default long getOffsetTimer() { return getOffset(); } else if (level().isClientSide()) { return GTValues.CLIENT_TIME + getOffset(); - } else if (level().getServer() == null) { + } else if (level().getServer() != null) { return level().getServer().getTickCount() + getOffset(); } return getOffset(); From 577c6dd8f3b18ebbcf136c05beb371a13d4588d7 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sun, 22 Dec 2024 04:00:16 +0200 Subject: [PATCH 12/24] back into the gtceu class --- .../java/com/gregtechceu/gtceu/GTCEu.java | 74 +++++++++++++++++ .../com/gregtechceu/gtceu/api/GTCEuAPI.java | 81 +------------------ .../blockentity/MetaMachineBlockEntity.java | 4 +- .../gtceu/api/capability/ICoverable.java | 4 +- .../gtceu/api/cover/filter/FilterHandler.java | 4 +- .../material/info/MaterialIconSet.java | 4 +- .../material/info/MaterialIconType.java | 3 +- .../material/properties/HazardProperty.java | 6 +- .../gtceu/api/data/tag/TagPrefix.java | 2 +- .../api/data/worldgen/WorldGenLayers.java | 4 +- .../api/gui/editor/EditableMachineUI.java | 4 +- .../api/gui/factory/GTUIEditorFactory.java | 4 +- .../api/gui/fancy/FancyMachineUIWidget.java | 4 +- .../gtceu/api/gui/misc/IGhostFluidTarget.java | 8 +- .../gtceu/api/gui/misc/IGhostItemTarget.java | 6 +- .../api/gui/widget/EnumSelectorWidget.java | 4 +- .../api/gui/widget/NumberInputWidget.java | 4 +- .../api/gui/widget/PatternPreviewWidget.java | 5 +- .../api/gui/widget/PhantomFluidWidget.java | 12 +-- .../api/gui/widget/PhantomSlotWidget.java | 10 +-- .../gtceu/api/gui/widget/SlotWidget.java | 38 ++++----- .../gtceu/api/gui/widget/TankWidget.java | 40 ++++----- .../api/item/component/ElectricStats.java | 4 +- .../gtceu/api/machine/MetaMachine.java | 4 +- .../gtceu/api/machine/feature/IUIMachine.java | 4 +- .../trait/NotifiableItemStackHandler.java | 4 +- .../pattern/predicates/SimplePredicate.java | 4 +- .../gtceu/api/pipenet/IPipeNode.java | 4 +- .../gtceu/api/recipe/GTRecipeSerializer.java | 7 +- .../gtceu/api/recipe/ui/GTRecipeTypeUI.java | 12 +-- .../registry/registrate/MachineBuilder.java | 4 +- .../client/model/WorkableOverlayModel.java | 4 +- .../renderer/block/PipeBlockRenderer.java | 4 +- .../block/TextureOverrideRenderer.java | 8 +- .../renderer/cover/ConveyorCoverRenderer.java | 3 +- .../cover/FluidRegulatorCoverRenderer.java | 3 +- .../renderer/cover/PumpCoverRenderer.java | 3 +- .../renderer/cover/RobotArmCoverRenderer.java | 3 +- .../renderer/cover/SimpleCoverRenderer.java | 4 +- .../machine/FusionReactorRenderer.java | 4 +- .../gregtechceu/gtceu/common/CommonProxy.java | 6 +- .../detector/AdvancedEnergyDetectorCover.java | 4 +- .../gtceu/common/data/GTDimensionMarkers.java | 3 +- .../gtceu/common/data/GTElements.java | 3 +- .../gtceu/common/data/GTItems.java | 4 +- .../gtceu/common/data/GTRecipeCategories.java | 2 +- .../gtceu/common/data/GTRecipeTypes.java | 2 +- .../common/data/machines/GCYMMachines.java | 2 +- .../common/data/machines/GTMultiMachines.java | 4 +- .../common/item/ColorSprayBehaviour.java | 6 +- .../gtceu/common/item/ItemMagnetBehavior.java | 4 +- .../common/machine/electric/HullMachine.java | 14 ++-- .../multiblock/part/DiodePartMachine.java | 4 +- .../common/machine/owner/IMachineOwner.java | 5 +- .../gtceu/data/loader/BedrockFluidLoader.java | 3 +- .../gtceu/data/loader/BedrockOreLoader.java | 3 +- .../gtceu/data/loader/GTOreLoader.java | 3 +- .../gtceu/data/recipe/CraftingComponent.java | 3 +- .../data/recipe/misc/MachineRecipeLoader.java | 4 +- .../MetaTileEntityMachineRecipeLoader.java | 3 +- .../gtceu/integration/emi/GTEMIPlugin.java | 6 +- .../gtceu/integration/jade/GTJadePlugin.java | 6 +- .../gtceu/integration/jei/GTJEIPlugin.java | 9 +-- .../integration/map/GroupingMapRenderer.java | 8 +- .../integration/map/WaypointManager.java | 6 +- .../map/xaeros/XaerosMapPlugin.java | 4 +- .../xei/widgets/GTRecipeWidget.java | 4 +- .../com/gregtechceu/gtceu/utils/GTUtil.java | 9 +-- 68 files changed, 267 insertions(+), 275 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/GTCEu.java b/src/main/java/com/gregtechceu/gtceu/GTCEu.java index 0a022c9b98..6f8f1de894 100644 --- a/src/main/java/com/gregtechceu/gtceu/GTCEu.java +++ b/src/main/java/com/gregtechceu/gtceu/GTCEu.java @@ -1,16 +1,21 @@ package com.gregtechceu.gtceu; import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.client.ClientProxy; import com.gregtechceu.gtceu.common.CommonProxy; import com.gregtechceu.gtceu.utils.FormattingUtil; +import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.Platform; +import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.loading.FMLEnvironment; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,4 +60,73 @@ public static ResourceLocation appendId(String id) { public static boolean isHighTier() { return GTCEuAPI.isHighTier(); } + + public static boolean isModLoaded(String modId) { + return ModList.get().isLoaded(modId); + } + + /** + * @return if the current thread is the client thread + */ + public static boolean isClientThread() { + return isClientSide() && Minecraft.getInstance().isSameThread(); + } + + /** + * @return if the FML environment is a client + */ + public static boolean isClientSide() { + return FMLEnvironment.dist.isClient(); + } + + public static boolean isJeiLoaded() { + return !(isEmiLoaded() || isReiLoaded()) && isModLoaded(GTValues.MODID_JEI); + } + + public static boolean isReiLoaded() { + // todo: convert to base check after ui rework + return LDLib.isReiLoaded(); + } + + public static boolean isEmiLoaded() { + // todo: convert to base check after ui rework + return LDLib.isEmiLoaded(); + } + + public static boolean isKubeJSLoaded() { + return isModLoaded(GTValues.MODID_KUBEJS); + } + + public static boolean isIrisOculusLoaded() { + return isModLoaded(GTValues.MODID_IRIS) || isModLoaded(GTValues.MODID_OCULUS); + } + + public static boolean isSodiumRubidiumEmbeddiumLoaded() { + return isModLoaded(GTValues.MODID_SODIUM) || isModLoaded(GTValues.MODID_RUBIDIUM) || + isModLoaded(GTValues.MODID_EMBEDDIUM); + } + + public static boolean isAE2Loaded() { + return isModLoaded(GTValues.MODID_APPENG); + } + + public static boolean isCuriosLoaded() { + return isModLoaded(GTValues.MODID_CURIOS); + } + + public static boolean isShimmerLoaded() { + return isModLoaded(GTValues.MODID_SHIMMER); + } + + public static boolean isJAVDLoaded() { + return isModLoaded(GTValues.MODID_JAVD); + } + + public static boolean isFTBTeamsLoaded() { + return isModLoaded(GTValues.MODID_FTB_TEAMS); + } + + public static boolean isArgonautsLoaded() { + return isModLoaded(GTValues.MODID_ARGONAUTS); + } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java b/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java index 4128134a3e..d0f7a754ac 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java +++ b/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java @@ -11,19 +11,12 @@ import com.gregtechceu.gtceu.common.block.BatteryBlock; import com.gregtechceu.gtceu.common.block.CoilBlock; import com.gregtechceu.gtceu.config.ConfigHolder; - -import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.Platform; - -import net.minecraft.client.Minecraft; +import lombok.Getter; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import net.minecraftforge.eventbus.api.GenericEvent; -import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.event.IModBusEvent; -import net.minecraftforge.fml.loading.FMLEnvironment; - -import lombok.Getter; import org.jetbrains.annotations.ApiStatus; import java.util.HashMap; @@ -60,78 +53,6 @@ public static void initializeHighTier() { else GTCEu.LOGGER.info("High-Tier is Disabled."); } - public static boolean isModLoaded(java.lang.String modId) { - return ModList.get().isLoaded(modId); - } - - /** - * @return if the current thread is the client thread - */ - public static boolean isClientThread() { - return isClientSide() && Minecraft.getInstance().isSameThread(); - } - - /** - * @return if the FML environment is a client - */ - public static boolean isClientSide() { - return FMLEnvironment.dist.isClient(); - } - - public static class Mods { - - public static boolean isJeiLoaded() { - return !(isEmiLoaded() || isReiLoaded()) && isModLoaded(GTValues.MODID_JEI); - } - - public static boolean isReiLoaded() { - // todo: convert to base check after ui rework - return LDLib.isReiLoaded(); - } - - public static boolean isEmiLoaded() { - // todo: convert to base check after ui rework - return LDLib.isEmiLoaded(); - } - - public static boolean isKubeJSLoaded() { - return isModLoaded(GTValues.MODID_KUBEJS); - } - - public static boolean isIrisOculusLoaded() { - return isModLoaded(GTValues.MODID_IRIS) || isModLoaded(GTValues.MODID_OCULUS); - } - - public static boolean isSodiumRubidiumEmbeddiumLoaded() { - return isModLoaded(GTValues.MODID_SODIUM) || isModLoaded(GTValues.MODID_RUBIDIUM) || - isModLoaded(GTValues.MODID_EMBEDDIUM); - } - - public static boolean isAE2Loaded() { - return isModLoaded(GTValues.MODID_APPENG); - } - - public static boolean isCuriosLoaded() { - return isModLoaded(GTValues.MODID_CURIOS); - } - - public static boolean isShimmerLoaded() { - return isModLoaded(GTValues.MODID_SHIMMER); - } - - public static boolean isJAVDLoaded() { - return isModLoaded(GTValues.MODID_JAVD); - } - - public static boolean isFTBTeamsLoaded() { - return isModLoaded(GTValues.MODID_FTB_TEAMS); - } - - public static boolean isArgonautsLoaded() { - return isModLoaded(GTValues.MODID_ARGONAUTS); - } - } - public static class RegisterEvent extends GenericEvent implements IModBusEvent { private final GTRegistry registry; diff --git a/src/main/java/com/gregtechceu/gtceu/api/blockentity/MetaMachineBlockEntity.java b/src/main/java/com/gregtechceu/gtceu/api/blockentity/MetaMachineBlockEntity.java index 160a5683dd..024eeff757 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/blockentity/MetaMachineBlockEntity.java +++ b/src/main/java/com/gregtechceu/gtceu/api/blockentity/MetaMachineBlockEntity.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.blockentity; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.*; import com.gregtechceu.gtceu.api.capability.forge.GTCapability; @@ -272,7 +272,7 @@ public static LazyOptional getCapability(MetaMachine machine, @NotNull Ca return GTCapability.CAPABILITY_DATA_ACCESS.orEmpty(cap, LazyOptional.of(() -> list.get(0))); } } - if (GTCEuAPI.Mods.isAE2Loaded()) { + if (GTCEu.isAE2Loaded()) { if (cap == Capabilities.IN_WORLD_GRID_NODE_HOST) { if (machine instanceof IInWorldGridNodeHost nodeHost) { return Capabilities.IN_WORLD_GRID_NODE_HOST.orEmpty(cap, LazyOptional.of(() -> nodeHost)); diff --git a/src/main/java/com/gregtechceu/gtceu/api/capability/ICoverable.java b/src/main/java/com/gregtechceu/gtceu/api/capability/ICoverable.java index 16560da266..eaa8de82d9 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/capability/ICoverable.java +++ b/src/main/java/com/gregtechceu/gtceu/api/capability/ICoverable.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.capability; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.block.IAppearance; import com.gregtechceu.gtceu.api.blockentity.ITickSubscription; import com.gregtechceu.gtceu.api.cover.CoverBehavior; @@ -168,7 +168,7 @@ default boolean hasCover(Direction facing) { } default boolean isRemote() { - return getLevel() == null ? GTCEuAPI.isClientThread() : getLevel().isClientSide; + return getLevel() == null ? GTCEu.isClientThread() : getLevel().isClientSide; } default VoxelShape[] addCoverCollisionBoundingBox() { diff --git a/src/main/java/com/gregtechceu/gtceu/api/cover/filter/FilterHandler.java b/src/main/java/com/gregtechceu/gtceu/api/cover/filter/FilterHandler.java index 30f734d9cf..92a767cb4c 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/cover/filter/FilterHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/api/cover/filter/FilterHandler.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.cover.filter; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.cover.CoverBehavior; import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.api.gui.widget.SlotWidget; @@ -128,7 +128,7 @@ private CustomItemStackHandler getFilterSlot() { private void updateFilter() { var filterContainer = getFilterSlot(); - if (GTCEuAPI.isClientThread()) { + if (GTCEu.isClientThread()) { if (!filterContainer.getStackInSlot(0).isEmpty() && !this.filterItem.isEmpty()) { return; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java index ef13662299..edf2447771 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.data.chemical.material.info; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import com.google.common.base.Preconditions; @@ -98,7 +98,7 @@ public String toString() { } public static void init() { - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistryInfo.MATERIAL_ICON_SET.registryKey); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java index f018403900..19d4f58e4e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.api.data.chemical.material.info; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import com.lowdragmc.lowdraglib.Platform; @@ -128,7 +127,7 @@ public MaterialIconType(String name) { } public static void init() { - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistryInfo.MATERIAL_ICON_TYPE.registryKey); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/HazardProperty.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/HazardProperty.java index 69bacfa33f..f63a34822f 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/HazardProperty.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/HazardProperty.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.data.chemical.material.properties; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.stack.UnificationEntry; @@ -120,7 +120,7 @@ public boolean isProtected(LivingEntity livingEntity) { correctArmorItems.add(equipmentType); } } - if (!GTCEuAPI.Mods.isCuriosLoaded() || this.curioSlots.isEmpty()) { + if (!GTCEu.isCuriosLoaded() || this.curioSlots.isEmpty()) { return correctArmorItems.containsAll(equipmentTypes); } Set correctCurios = new HashSet<>(); @@ -153,7 +153,7 @@ public void damageEquipment(Player player, int amount) { armor.hurtAndBreak(amount, player, p -> p.broadcastBreakEvent(type.getSlot())); } } - if (GTCEuAPI.Mods.isCuriosLoaded()) { + if (GTCEu.isCuriosLoaded()) { ICuriosItemHandler curiosInventory = CuriosApi.getCuriosInventory(player) .resolve() .orElse(null); diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java b/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java index c95fc6c810..e113604677 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java @@ -75,7 +75,7 @@ public class TagPrefix { public static void init() { AddonFinder.getAddons().forEach(IGTAddon::registerTagPrefixes); - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistryInfo.TAG_PREFIX.registryKey); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java index a8878e9ef3..4aefcf064e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.data.worldgen; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.addon.AddonFinder; import com.gregtechceu.gtceu.api.addon.IGTAddon; import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; @@ -59,7 +59,7 @@ public enum WorldGenLayers implements IWorldGenLayer, StringRepresentable { public static void registerAll() { AddonFinder.getAddons().forEach(IGTAddon::registerWorldgenLayers); - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistryInfo.WORLD_GEN_LAYER.registryKey); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/editor/EditableMachineUI.java b/src/main/java/com/gregtechceu/gtceu/api/gui/editor/EditableMachineUI.java index 9a087e4774..5a525e1fe4 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/editor/EditableMachineUI.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/editor/EditableMachineUI.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.gui.editor; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.machine.MetaMachine; import com.lowdragmc.lowdraglib.Platform; @@ -76,7 +76,7 @@ public WidgetGroup createCustomUI() { public CompoundTag getCustomUI() { if (this.customUICache == null) { ResourceManager resourceManager = null; - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { resourceManager = Minecraft.getInstance().getResourceManager(); } else if (Platform.getMinecraftServer() != null) { resourceManager = Platform.getMinecraftServer().getResourceManager(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/factory/GTUIEditorFactory.java b/src/main/java/com/gregtechceu/gtceu/api/gui/factory/GTUIEditorFactory.java index b4514fb674..814491d6e6 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/factory/GTUIEditorFactory.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/factory/GTUIEditorFactory.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.gui.factory; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.gui.editor.GTUIEditor; import com.lowdragmc.lowdraglib.LDLib; @@ -44,7 +44,7 @@ public boolean isInvalid() { @Override public boolean isRemote() { - return GTCEuAPI.isClientThread(); + return GTCEu.isClientThread(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/FancyMachineUIWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/FancyMachineUIWidget.java index 52a4955d42..fd68a5135b 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/FancyMachineUIWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/FancyMachineUIWidget.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.gui.fancy; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.config.ConfigHolder; @@ -200,7 +200,7 @@ protected void setupFancyUI(IFancyUIProvider fancyUI, boolean showInventory) { Math.max(86, page.getSize().height + border * 2)); setSize(new Size(size.width, size.height + (!showInventory || playerInventory == null ? 0 : playerInventory.getSize().height))); - if (GTCEuAPI.isClientSide() && getGui() != null) { + if (GTCEu.isClientSide() && getGui() != null) { getGui().setSize(getSize().width, getSize().height); } this.sideTabsWidget.setSize(new Size(24, size.height)); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java index df00a8d959..fbfd9dc8fd 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.gui.misc; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.lowdragmc.lowdraglib.gui.ingredient.IGhostIngredientTarget; import com.lowdragmc.lowdraglib.gui.ingredient.Target; @@ -62,17 +62,17 @@ public void accept(@NotNull Object ingredient) { } default Object convertIngredient(Object ingredient) { - if (GTCEuAPI.Mods.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { + if (GTCEu.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), (int) fluidStack.getAmount(), fluidStack.getTag()); } - if (GTCEuAPI.Mods.isEmiLoaded() && ingredient instanceof EmiStack fluidEmiStack) { + if (GTCEu.isEmiLoaded() && ingredient instanceof EmiStack fluidEmiStack) { Fluid fluid = fluidEmiStack.getKeyOfType(Fluid.class); ingredient = fluid == null ? FluidStack.EMPTY : new FluidStack(fluid, (int) fluidEmiStack.getAmount(), fluidEmiStack.getNbt()); } - if (GTCEuAPI.Mods.isJeiLoaded() && ingredient instanceof net.minecraftforge.fluids.FluidStack fluidStack) { + if (GTCEu.isJeiLoaded() && ingredient instanceof net.minecraftforge.fluids.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), fluidStack.getAmount(), fluidStack.getTag()); } return ingredient; diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java index 39c0fc4dde..e92908d9eb 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.gui.misc; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.lowdragmc.lowdraglib.gui.ingredient.IGhostIngredientTarget; import com.lowdragmc.lowdraglib.gui.ingredient.Target; @@ -53,7 +53,7 @@ public void accept(@NotNull Object ingredient) { } default Object convertIngredient(Object ingredient) { - if (GTCEuAPI.Mods.isEmiLoaded() && ingredient instanceof EmiStack itemEmiStack) { + if (GTCEu.isEmiLoaded() && ingredient instanceof EmiStack itemEmiStack) { Item item = itemEmiStack.getKeyOfType(Item.class); ItemStack itemStack = item == null ? ItemStack.EMPTY : new ItemStack(item, (int) itemEmiStack.getAmount()); if (!itemStack.isEmpty()) { @@ -62,7 +62,7 @@ default Object convertIngredient(Object ingredient) { ingredient = itemStack; } - if (GTCEuAPI.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient itemJeiStack) { + if (GTCEu.isJeiLoaded() && ingredient instanceof ITypedIngredient itemJeiStack) { return itemJeiStack.getItemStack().orElse(ItemStack.EMPTY); } return ingredient; diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/EnumSelectorWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/EnumSelectorWidget.java index 0bcd01335a..440031c6f2 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/EnumSelectorWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/EnumSelectorWidget.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.gui.widget; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.data.lang.LangHandler; @@ -125,7 +125,7 @@ public void setSelected(@NotNull T value) { } private void updateTooltip() { - if (!GTCEuAPI.isClientThread()) + if (!GTCEu.isClientThread()) return; T selectedValue = getCurrentValue(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/NumberInputWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/NumberInputWidget.java index 0f722aeb1b..53c6c49327 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/NumberInputWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/NumberInputWidget.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.gui.widget; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.utils.GTUtil; @@ -133,7 +133,7 @@ private void buildUI() { private IGuiTexture getButtonTexture(String prefix, int buttonWidth) { var texture = new TextTexture(prefix + "1"); - if (!GTCEuAPI.isClientThread()) { + if (!GTCEu.isClientThread()) { return texture; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java index f91812ed41..59c237bc75 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.api.gui.widget; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.block.MetaMachineBlock; import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; @@ -255,10 +254,10 @@ public static BlockPos locateNextRegion(int range) { public void updateScreen() { super.updateScreen(); // I can only think of this way - if (!isLoaded && GTCEuAPI.Mods.isEmiLoaded() && Minecraft.getInstance().screen instanceof RecipeScreen) { + if (!isLoaded && GTCEu.isEmiLoaded() && Minecraft.getInstance().screen instanceof RecipeScreen) { setPage(0); isLoaded = true; - } else if (!isLoaded && GTCEuAPI.Mods.isReiLoaded() && + } else if (!isLoaded && GTCEu.isReiLoaded() && Minecraft.getInstance().screen instanceof AbstractDisplayViewingScreen) { setPage(0); isLoaded = true; diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java index f9928636c7..dec817539c 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.gui.widget; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.lowdragmc.lowdraglib.gui.editor.annotation.ConfigSetter; import com.lowdragmc.lowdraglib.gui.editor.annotation.LDLRegister; @@ -101,9 +101,9 @@ public static FluidStack drainFrom(Object ingredient) { @Override @OnlyIn(Dist.CLIENT) public List getPhantomTargets(Object ingredient) { - if (GTCEuAPI.Mods.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { + if (GTCEu.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), (int) fluidStack.getAmount(), fluidStack.getTag()); - } else if (GTCEuAPI.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + } else if (GTCEu.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { var key = emiStack.getKey(); if (key instanceof Fluid f) { int amount = emiStack.getAmount() == 0 ? 1000 : (int) emiStack.getAmount(); @@ -114,7 +114,7 @@ public List getPhantomTargets(Object ingredient) { } else { ingredient = null; } - } else if (GTCEuAPI.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { + } else if (GTCEu.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { ingredient = jeiStack.getIngredient(); } @@ -133,11 +133,11 @@ public Rect2i getArea() { @Override public void accept(@Nonnull Object ingredient) { - if (GTCEuAPI.Mods.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { + if (GTCEu.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), (int) fluidStack.getAmount(), fluidStack.getTag()); - } else if (GTCEuAPI.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + } else if (GTCEu.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { var key = emiStack.getKey(); if (key instanceof Fluid f) { int amount = emiStack.getAmount() == 0 ? 1000 : (int) emiStack.getAmount(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java index bbada8312c..e9fcbc55bc 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.gui.widget; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.lowdragmc.lowdraglib.gui.editor.annotation.ConfigSetter; import com.lowdragmc.lowdraglib.gui.editor.annotation.Configurable; @@ -126,13 +126,13 @@ public boolean canPutStack(ItemStack stack) { @Override @OnlyIn(Dist.CLIENT) public List getPhantomTargets(Object ingredient) { - if (GTCEuAPI.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + if (GTCEu.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { Item item = emiStack.getKeyOfType(Item.class); if (item != null) { ingredient = new ItemStack(item, (int) emiStack.getAmount()); ((ItemStack) ingredient).setTag(emiStack.getNbt()); } - } else if (GTCEuAPI.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { + } else if (GTCEu.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { ingredient = jeiStack.getItemStack().orElse(null); } if (!(ingredient instanceof ItemStack)) { @@ -150,13 +150,13 @@ public Rect2i getArea() { @Override public void accept(@Nonnull Object ingredient) { - if (GTCEuAPI.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + if (GTCEu.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { Item item = emiStack.getKeyOfType(Item.class); if (item != null) { ingredient = new ItemStack(item, (int) emiStack.getAmount()); ((ItemStack) ingredient).setTag(emiStack.getNbt()); } - } else if (GTCEuAPI.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { + } else if (GTCEu.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { ingredient = jeiStack.getItemStack().orElse(null); } if (slotReference != null && ingredient instanceof ItemStack stack) { diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java index e2ec24766e..df2a81c807 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.gui.widget; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.integration.xei.entry.item.ItemEntryList; import com.gregtechceu.gtceu.integration.xei.entry.item.ItemStackList; import com.gregtechceu.gtceu.integration.xei.entry.item.ItemTagList; @@ -204,11 +204,11 @@ public Object getXEIIngredientOverMouse(double mouseX, double mouseY) { } } - if (GTCEuAPI.Mods.isJeiLoaded() && !realStack.isEmpty()) { + if (GTCEu.isJeiLoaded() && !realStack.isEmpty()) { return JEICallWrapper.getJEIStackClickable(realStack, getPosition(), getSize()); - } else if (GTCEuAPI.Mods.isReiLoaded()) { + } else if (GTCEu.isReiLoaded()) { return EntryStacks.of(realStack); - } else if (GTCEuAPI.Mods.isEmiLoaded()) { + } else if (GTCEu.isEmiLoaded()) { return EmiStack.of(realStack).setChance(getXEIChance()); } return realStack; @@ -230,11 +230,11 @@ public List getXEIIngredients() { } } - if (GTCEuAPI.Mods.isJeiLoaded() && !realStack.isEmpty()) { + if (GTCEu.isJeiLoaded() && !realStack.isEmpty()) { return List.of(JEICallWrapper.getJEIStackClickable(realStack, getPosition(), getSize())); - } else if (GTCEuAPI.Mods.isReiLoaded()) { + } else if (GTCEu.isReiLoaded()) { return List.of(EntryStacks.of(realStack)); - } else if (GTCEuAPI.Mods.isEmiLoaded()) { + } else if (GTCEu.isEmiLoaded()) { return List.of(EmiStack.of(realStack).setChance(getXEIChance())); } return List.of(realStack); @@ -242,11 +242,11 @@ public List getXEIIngredients() { private List getXEIIngredients(CycleItemStackHandler handler, int index) { var stackList = handler.getStackList(index); - if (GTCEuAPI.Mods.isJeiLoaded()) { + if (GTCEu.isJeiLoaded()) { return JEICallWrapper.getJEIIngredients(stackList, this::getRealStack); - } else if (GTCEuAPI.Mods.isReiLoaded()) { + } else if (GTCEu.isReiLoaded()) { return REICallWrapper.getREIIngredients(stackList, this::getRealStack); - } else if (GTCEuAPI.Mods.isEmiLoaded()) { + } else if (GTCEu.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); @@ -254,11 +254,11 @@ private List getXEIIngredients(CycleItemStackHandler handler, int index) private List getXEIIngredientsClickable(CycleItemStackHandler handler, int index) { var stackList = handler.getStackList(index); - if (GTCEuAPI.Mods.isJeiLoaded()) { + if (GTCEu.isJeiLoaded()) { return JEICallWrapper.getJEIIngredientsClickable(stackList, getPosition(), getSize(), this::getRealStack); - } else if (GTCEuAPI.Mods.isReiLoaded()) { + } else if (GTCEu.isReiLoaded()) { return REICallWrapper.getREIIngredients(stackList, this::getRealStack); - } else if (GTCEuAPI.Mods.isEmiLoaded()) { + } else if (GTCEu.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); @@ -266,11 +266,11 @@ private List getXEIIngredientsClickable(CycleItemStackHandler handler, i private List getXEIIngredients(CycleItemEntryHandler handler, int index) { ItemEntryList entryList = handler.getEntry(index); - if (GTCEuAPI.Mods.isJeiLoaded()) { + if (GTCEu.isJeiLoaded()) { return JEICallWrapper.getJEIIngredients(entryList, this::getRealStack); - } else if (GTCEuAPI.Mods.isReiLoaded()) { + } else if (GTCEu.isReiLoaded()) { return REICallWrapper.getREIIngredients(entryList, this::getRealStack); - } else if (GTCEuAPI.Mods.isEmiLoaded()) { + } else if (GTCEu.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); @@ -278,11 +278,11 @@ private List getXEIIngredients(CycleItemEntryHandler handler, int index) private List getXEIIngredientsClickable(CycleItemEntryHandler handler, int index) { ItemEntryList entryList = handler.getEntry(index); - if (GTCEuAPI.Mods.isJeiLoaded()) { + if (GTCEu.isJeiLoaded()) { return JEICallWrapper.getJEIIngredientsClickable(entryList, getPosition(), getSize(), this::getRealStack); - } else if (GTCEuAPI.Mods.isReiLoaded()) { + } else if (GTCEu.isReiLoaded()) { return REICallWrapper.getREIIngredients(entryList, this::getRealStack); - } else if (GTCEuAPI.Mods.isEmiLoaded()) { + } else if (GTCEu.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java index 87483a22a9..ac1e25a6ca 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.gui.widget; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.client.TooltipsHandler; import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidEntryList; import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidStackList; @@ -202,11 +202,11 @@ public Object getXEIIngredientOverMouse(double mouseX, double mouseY) { return getXEIIngredientsClickable(entryHandler, tank).get(0); } - if (GTCEuAPI.Mods.isJeiLoaded()) { + if (GTCEu.isJeiLoaded()) { return JEICallWrapper.getJEIFluidClickable(lastFluidInTank, getPosition(), getSize()); - } else if (GTCEuAPI.Mods.isReiLoaded()) { + } else if (GTCEu.isReiLoaded()) { return EntryStacks.of(REICallWrapper.toREIStack(lastFluidInTank)); - } else if (GTCEuAPI.Mods.isEmiLoaded()) { + } else if (GTCEu.isEmiLoaded()) { return ForgeEmiStack.of(lastFluidInTank).setChance(XEIChance); } } @@ -223,11 +223,11 @@ public List getXEIIngredients() { return getXEIIngredientsClickable(entryHandler, tank); } - if (GTCEuAPI.Mods.isJeiLoaded()) { + if (GTCEu.isJeiLoaded()) { return List.of(JEICallWrapper.getJEIFluidClickable(lastFluidInTank, getPosition(), getSize())); - } else if (GTCEuAPI.Mods.isReiLoaded()) { + } else if (GTCEu.isReiLoaded()) { return List.of(EntryStacks.of(REICallWrapper.toREIStack(lastFluidInTank))); - } else if (GTCEuAPI.Mods.isEmiLoaded()) { + } else if (GTCEu.isEmiLoaded()) { return List.of(ForgeEmiStack.of(lastFluidInTank).setChance(XEIChance)); } return List.of(lastFluidInTank); @@ -235,11 +235,11 @@ public List getXEIIngredients() { private List getXEIIngredients(CycleFluidStackHandler handler, int index) { FluidStackList stackList = handler.getStackList(index); - if (GTCEuAPI.Mods.isJeiLoaded()) { + if (GTCEu.isJeiLoaded()) { return JEICallWrapper.getJEIIngredients(stackList); - } else if (GTCEuAPI.Mods.isReiLoaded()) { + } else if (GTCEu.isReiLoaded()) { return REICallWrapper.getREIIngredients(stackList); - } else if (GTCEuAPI.Mods.isEmiLoaded()) { + } else if (GTCEu.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance()); } return Collections.emptyList(); @@ -247,11 +247,11 @@ private List getXEIIngredients(CycleFluidStackHandler handler, int index private List getXEIIngredientsClickable(CycleFluidStackHandler handler, int index) { FluidStackList stackList = handler.getStackList(index); - if (GTCEuAPI.Mods.isJeiLoaded()) { + if (GTCEu.isJeiLoaded()) { return JEICallWrapper.getJEIIngredientsClickable(stackList, getPosition(), getSize()); - } else if (GTCEuAPI.Mods.isReiLoaded()) { + } else if (GTCEu.isReiLoaded()) { return REICallWrapper.getREIIngredients(stackList); - } else if (GTCEuAPI.Mods.isEmiLoaded()) { + } else if (GTCEu.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance()); } return Collections.emptyList(); @@ -259,11 +259,11 @@ private List getXEIIngredientsClickable(CycleFluidStackHandler handler, private List getXEIIngredients(CycleFluidEntryHandler handler, int index) { FluidEntryList entryList = handler.getEntry(index); - if (GTCEuAPI.Mods.isJeiLoaded()) { + if (GTCEu.isJeiLoaded()) { return JEICallWrapper.getJEIIngredients(entryList); - } else if (GTCEuAPI.Mods.isReiLoaded()) { + } else if (GTCEu.isReiLoaded()) { return REICallWrapper.getREIIngredients(entryList); - } else if (GTCEuAPI.Mods.isEmiLoaded()) { + } else if (GTCEu.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance()); } return Collections.emptyList(); @@ -271,11 +271,11 @@ private List getXEIIngredients(CycleFluidEntryHandler handler, int index private List getXEIIngredientsClickable(CycleFluidEntryHandler handler, int index) { FluidEntryList entryList = handler.getEntry(index); - if (GTCEuAPI.Mods.isJeiLoaded()) { + if (GTCEu.isJeiLoaded()) { return JEICallWrapper.getJEIIngredientsClickable(entryList, getPosition(), getSize()); - } else if (GTCEuAPI.Mods.isReiLoaded()) { + } else if (GTCEu.isReiLoaded()) { return REICallWrapper.getREIIngredients(entryList); - } else if (GTCEuAPI.Mods.isEmiLoaded()) { + } else if (GTCEu.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance()); } return Collections.emptyList(); @@ -318,7 +318,7 @@ public List getFullTooltipTexts() { @Override public void setCurrentJEIRenderedIngredient(Object ingredient) { - if (GTCEuAPI.Mods.isJeiLoaded()) { + if (GTCEu.isJeiLoaded()) { currentJEIRenderedIngredient = ingredient instanceof FluidStack f ? f : null; } else { currentJEIRenderedIngredient = null; diff --git a/src/main/java/com/gregtechceu/gtceu/api/item/component/ElectricStats.java b/src/main/java/com/gregtechceu/gtceu/api/item/component/ElectricStats.java index 2d8d9e87be..eff4f272f1 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/item/component/ElectricStats.java +++ b/src/main/java/com/gregtechceu/gtceu/api/item/component/ElectricStats.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.item.component; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.GTCapabilityHelper; import com.gregtechceu.gtceu.api.capability.IElectricItem; @@ -104,7 +104,7 @@ public void inventoryTick(ItemStack stack, Level level, Entity entity, int slotI isInDischargeMode(stack) && electricItem.getCharge() > 0L) { long transferLimit = electricItem.getTransferLimit(); - if (GTCEuAPI.Mods.isCuriosLoaded()) { + if (GTCEu.isCuriosLoaded()) { IItemHandler curios = CuriosApi.getCuriosInventory(player) .map(ICuriosItemHandler::getEquippedCurios) .orElse(EmptyHandler.INSTANCE); diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java b/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java index 580f18e5d9..9b8a88ab0b 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.machine; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.block.BlockProperties; import com.gregtechceu.gtceu.api.block.IAppearance; import com.gregtechceu.gtceu.api.block.MetaMachineBlock; @@ -155,7 +155,7 @@ public BlockState getBlockState() { } public boolean isRemote() { - return getLevel() == null ? GTCEuAPI.isClientThread() : getLevel().isClientSide; + return getLevel() == null ? GTCEu.isClientThread() : getLevel().isClientSide; } public void notifyBlockUpdate() { diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IUIMachine.java b/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IUIMachine.java index 877b94350d..81bb408d6f 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IUIMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IUIMachine.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.machine.feature; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.gui.factory.MachineUIFactory; import com.lowdragmc.lowdraglib.gui.modular.IUIHolder; @@ -41,7 +41,7 @@ default boolean isInvalid() { @Override default boolean isRemote() { var level = self().getLevel(); - return level == null ? GTCEuAPI.isClientThread() : level.isClientSide; + return level == null ? GTCEu.isClientThread() : level.isClientSide; } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableItemStackHandler.java b/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableItemStackHandler.java index 3dfe771a4f..c3e5304b05 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableItemStackHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableItemStackHandler.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.machine.trait; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; @@ -168,7 +168,7 @@ public static List handleRecipe(IO io, GTRecipe recipe, List actions) { - if (!GTCEuAPI.Mods.isKubeJSLoaded()) return null; + if (!GTCEu.isKubeJSLoaded()) return null; // noinspection unchecked var actioned = KJSCallWrapper.applyIngredientAction(storage, index, (List) actions); if (!actioned.isEmpty()) return actioned; diff --git a/src/main/java/com/gregtechceu/gtceu/api/pattern/predicates/SimplePredicate.java b/src/main/java/com/gregtechceu/gtceu/api/pattern/predicates/SimplePredicate.java index b6c23042ed..d4082a60db 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/pattern/predicates/SimplePredicate.java +++ b/src/main/java/com/gregtechceu/gtceu/api/pattern/predicates/SimplePredicate.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.pattern.predicates; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.pattern.MultiblockState; import com.gregtechceu.gtceu.api.pattern.TraceabilityPredicate; @@ -173,7 +173,7 @@ public boolean testLayer(MultiblockState blockWorldState) { } public List getCandidates() { - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { return candidates == null ? Collections.emptyList() : Arrays.stream(this.candidates.get()).filter(info -> info.getBlockState().getBlock() != Blocks.AIR) .map(blockInfo -> blockInfo.getItemStackForm(Minecraft.getInstance().level, BlockPos.ZERO)) diff --git a/src/main/java/com/gregtechceu/gtceu/api/pipenet/IPipeNode.java b/src/main/java/com/gregtechceu/gtceu/api/pipenet/IPipeNode.java index a63fe42f5e..84a0ce52ef 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/pipenet/IPipeNode.java +++ b/src/main/java/com/gregtechceu/gtceu/api/pipenet/IPipeNode.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.pipenet; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.block.PipeBlock; import com.gregtechceu.gtceu.api.blockentity.IPaintable; import com.gregtechceu.gtceu.api.blockentity.ITickSubscription; @@ -106,7 +106,7 @@ default boolean isInValid() { default boolean isRemote() { var level = getPipeLevel(); if (level == null) { - return GTCEuAPI.isClientThread(); + return GTCEu.isClientThread(); } return level.isClientSide; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java index f26e64a3da..9e147d54a0 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.api.recipe; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.recipe.chance.logic.ChanceLogic; @@ -37,7 +36,7 @@ */ public class GTRecipeSerializer implements RecipeSerializer { - public static final Codec CODEC = makeCodec(GTCEuAPI.Mods.isKubeJSLoaded()); + public static final Codec CODEC = makeCodec(GTCEu.isKubeJSLoaded()); public static final GTRecipeSerializer SERIALIZER = new GTRecipeSerializer(); @@ -132,7 +131,7 @@ public GTRecipe fromNetwork(@NotNull ResourceLocation id, @NotNull FriendlyByteB List conditions = buf.readCollection(c -> new ArrayList<>(), GTRecipeSerializer::conditionReader); List ingredientActions = new ArrayList<>(); - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { ingredientActions = KJSCallWrapper.getIngredientActions(buf); } CompoundTag data = buf.readNbt(); @@ -187,7 +186,7 @@ public void toNetwork(FriendlyByteBuf buf, GTRecipe recipe) { (buf1, logic) -> buf1.writeUtf(GTRegistries.CHANCE_LOGICS.getKey(logic))); buf.writeCollection(recipe.conditions, GTRecipeSerializer::conditionWriter); - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { KJSCallWrapper.writeIngredientActions(recipe.ingredientActions, buf); } buf.writeNbt(recipe.data); diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java index 594b99bf68..cd67f713c0 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.recipe.ui; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.capability.recipe.FluidRecipeCapability; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; @@ -101,7 +101,7 @@ public GTRecipeTypeUI(@NotNull GTRecipeType recipeType) { public CompoundTag getCustomUI() { if (this.customUICache == null) { ResourceManager resourceManager = null; - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { resourceManager = Minecraft.getInstance().getResourceManager(); } else if (Platform.getMinecraftServer() != null) { resourceManager = Platform.getMinecraftServer().getResourceManager(); @@ -239,25 +239,25 @@ public IEditableUI createEditableUITemplate(final boo progress.add(dualProgressWidget); }); // add recipe button - if (!isJEI && (GTCEuAPI.Mods.isReiLoaded() || GTCEuAPI.Mods.isJeiLoaded() || GTCEuAPI.Mods.isEmiLoaded())) { + if (!isJEI && (GTCEu.isReiLoaded() || GTCEu.isJeiLoaded() || GTCEu.isEmiLoaded())) { for (Widget widget : progress) { template.addWidget(new ButtonWidget(widget.getPosition().x, widget.getPosition().y, widget.getSize().width, widget.getSize().height, IGuiTexture.EMPTY, cd -> { if (cd.isRemote) { - if (GTCEuAPI.Mods.isReiLoaded()) { + if (GTCEu.isReiLoaded()) { ViewSearchBuilder.builder().addCategories( recipeType.getCategories().stream() .filter(GTRecipeCategory::isXEIVisible) .map(GTRecipeREICategory::machineCategory) .collect(Collectors.toList())) .open(); - } else if (GTCEuAPI.Mods.isJeiLoaded()) { + } else if (GTCEu.isJeiLoaded()) { JEIPlugin.jeiRuntime.getRecipesGui().showTypes( recipeType.getCategories().stream() .filter(GTRecipeCategory::isXEIVisible) .map(GTRecipeJEICategory::machineType) .collect(Collectors.toList())); - } else if (GTCEuAPI.Mods.isEmiLoaded()) { + } else if (GTCEu.isEmiLoaded()) { EmiApi.displayRecipeCategory( GTRecipeEMICategory.machineCategory(recipeType.getCategory())); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java b/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java index 13e93cdc5d..992634140c 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.api.registry.registrate; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.block.IMachineBlock; import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; @@ -402,7 +402,7 @@ public DEFINITION register() { definition.setEditableUI(editableUI); } definition.setAppearance(appearance); - definition.setRenderer(GTCEuAPI.isClientSide() ? renderer.get() : IRenderer.EMPTY); + definition.setRenderer(GTCEu.isClientSide() ? renderer.get() : IRenderer.EMPTY); definition.setShape(shape); definition.setDefaultPaintingColor(paintingColor); definition.setRenderXEIPreview(renderMultiblockXEIPreview); diff --git a/src/main/java/com/gregtechceu/gtceu/client/model/WorkableOverlayModel.java b/src/main/java/com/gregtechceu/gtceu/client/model/WorkableOverlayModel.java index 04e5e2ef58..d1bf380f27 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/model/WorkableOverlayModel.java +++ b/src/main/java/com/gregtechceu/gtceu/client/model/WorkableOverlayModel.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.client.model; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.client.util.StaticFaceBakery; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.utils.GTUtil; @@ -126,7 +126,7 @@ private TextureAtlasSprite getTextureAtlasSprite(boolean active, boolean working public WorkableOverlayModel(ResourceLocation location) { this.location = location; - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { this.sprites = new EnumMap<>(OverlayFace.class); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/block/PipeBlockRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/block/PipeBlockRenderer.java index ede172befc..fafbe4f1e7 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/block/PipeBlockRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/block/PipeBlockRenderer.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.client.renderer.block; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconType; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; import com.gregtechceu.gtceu.api.pipenet.IPipeNode; @@ -49,7 +49,7 @@ public class PipeBlockRenderer implements IRenderer, ICoverableRenderer { public PipeBlockRenderer(PipeModel pipeModel) { this.pipeModel = pipeModel; - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { registerEvent(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/block/TextureOverrideRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/block/TextureOverrideRenderer.java index f7b9ad0f0a..71ff630578 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/block/TextureOverrideRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/block/TextureOverrideRenderer.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.client.renderer.block; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.client.model.SpriteOverrider; import com.lowdragmc.lowdraglib.client.model.ModelFactory; @@ -40,7 +40,7 @@ public class TextureOverrideRenderer extends CTMModelRenderer { public TextureOverrideRenderer(ResourceLocation model, @NotNull Map override) { super(model); this.override = override; - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { registerEvent(); } } @@ -50,7 +50,7 @@ public TextureOverrideRenderer(ResourceLocation model, super(model); this.override = Collections.emptyMap(); this.overrideSupplier = overrideSupplier; - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { registerEvent(); } } @@ -58,7 +58,7 @@ public TextureOverrideRenderer(ResourceLocation model, public TextureOverrideRenderer(ResourceLocation model) { super(model); this.override = Collections.emptyMap(); - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { registerEvent(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/ConveyorCoverRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/ConveyorCoverRenderer.java index 66aaa97eb8..611d268076 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/ConveyorCoverRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/ConveyorCoverRenderer.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.client.renderer.cover; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.cover.CoverBehavior; import com.gregtechceu.gtceu.client.util.StaticFaceBakery; @@ -40,7 +39,7 @@ public class ConveyorCoverRenderer implements ICoverRenderer { .id("block/cover/overlay_conveyor_inverted_emissive"); protected ConveyorCoverRenderer() { - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { registerEvent(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/FluidRegulatorCoverRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/FluidRegulatorCoverRenderer.java index f0f37c124b..9ca4807998 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/FluidRegulatorCoverRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/FluidRegulatorCoverRenderer.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.client.renderer.cover; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.cover.CoverBehavior; import com.gregtechceu.gtceu.client.util.StaticFaceBakery; @@ -37,7 +36,7 @@ public class FluidRegulatorCoverRenderer implements ICoverRenderer { public final static ResourceLocation PUMP_OVERLAY_IN = GTCEu.id("block/cover/overlay_pump_inverted"); protected FluidRegulatorCoverRenderer() { - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { registerEvent(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/PumpCoverRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/PumpCoverRenderer.java index d4d0b738fd..30b92cff69 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/PumpCoverRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/PumpCoverRenderer.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.client.renderer.cover; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.cover.CoverBehavior; import com.gregtechceu.gtceu.client.util.StaticFaceBakery; @@ -37,7 +36,7 @@ public class PumpCoverRenderer implements ICoverRenderer { public final static ResourceLocation PUMP_OVERLAY_IN = GTCEu.id("block/cover/overlay_pump_inverted"); protected PumpCoverRenderer() { - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { registerEvent(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/RobotArmCoverRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/RobotArmCoverRenderer.java index dc9d3b0df4..3eae8fa24b 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/RobotArmCoverRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/RobotArmCoverRenderer.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.client.renderer.cover; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.cover.CoverBehavior; import com.gregtechceu.gtceu.client.util.StaticFaceBakery; @@ -34,7 +33,7 @@ public class RobotArmCoverRenderer implements ICoverRenderer { public final static ResourceLocation AR_OVERLAY_IN = GTCEu.id("block/cover/overlay_arm_inverted_emissive"); protected RobotArmCoverRenderer() { - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { registerEvent(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/SimpleCoverRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/SimpleCoverRenderer.java index 21fbb44d4f..b761f531ac 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/SimpleCoverRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/cover/SimpleCoverRenderer.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.client.renderer.cover; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.cover.CoverBehavior; import com.gregtechceu.gtceu.client.util.StaticFaceBakery; @@ -35,7 +35,7 @@ public class SimpleCoverRenderer implements ICoverRenderer { public SimpleCoverRenderer(ResourceLocation texture) { this.texture = texture; - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { registerEvent(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/FusionReactorRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/FusionReactorRenderer.java index fe07f1d965..176f636da2 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/FusionReactorRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/FusionReactorRenderer.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.client.renderer.machine; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; import com.gregtechceu.gtceu.api.pattern.util.RelativeDirection; import com.gregtechceu.gtceu.client.renderer.GTRenderTypes; @@ -33,7 +33,7 @@ public void render(BlockEntity blockEntity, float partialTicks, PoseStack stack, int combinedLight, int combinedOverlay) { if (blockEntity instanceof IMachineBlockEntity machineBlockEntity && machineBlockEntity.getMetaMachine() instanceof FusionReactorMachine machine) { - if (GTCEuAPI.Mods.isShimmerLoaded()) { + if (GTCEu.isShimmerLoaded()) { PoseStack finalStack = RenderUtils.copyPoseStack(stack); BloomUtils.entityBloom(source -> renderLightRing(machine, partialTicks, finalStack, source)); } else { diff --git a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java index 5da51523e5..2f529fbb21 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java +++ b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java @@ -200,7 +200,7 @@ private static void initMaterials() { GTCEu.LOGGER.info("Registering addon Materials"); MaterialEvent materialEvent = new MaterialEvent(); ModLoader.get().postEvent(materialEvent); - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { KJSEventWrapper.materialRegistry(); } @@ -208,7 +208,7 @@ private static void initMaterials() { // Block entirely new Materials from being added in the Post event managerInternal.closeRegistries(); ModLoader.get().postEvent(new PostMaterialEvent()); - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { KJSEventWrapper.materialModification(); } @@ -242,7 +242,7 @@ public void commonSetup(FMLCommonSetupEvent event) { @SubscribeEvent public void loadComplete(FMLLoadCompleteEvent e) { e.enqueueWork(() -> { - if (GTCEuAPI.isModLoaded(GTValues.MODID_TOP)) { + if (GTCEu.isModLoaded(GTValues.MODID_TOP)) { GTCEu.LOGGER.info("TheOneProbe found. Enabling integration..."); TheOneProbePluginImpl.init(); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedEnergyDetectorCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedEnergyDetectorCover.java index 5d7c06cd5e..8dc48f889f 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedEnergyDetectorCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/detector/AdvancedEnergyDetectorCover.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.common.cover.detector; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.capability.ICoverable; import com.gregtechceu.gtceu.api.capability.IEnergyInfoProvider; import com.gregtechceu.gtceu.api.cover.CoverDefinition; @@ -157,7 +157,7 @@ public void updateScreen() { } private void initializeMinMaxInputs(boolean wasPercent) { - if (GTCEuAPI.isClientThread() || minValueInput == null || maxValueInput == null) + if (GTCEu.isClientThread() || minValueInput == null || maxValueInput == null) return; long energyCapacity = getEnergyInfoProvider().getEnergyInfo().capacity().longValue(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java index 9e3eda3646..24b3247c2b 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.common.data; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.data.DimensionMarker; import com.gregtechceu.gtceu.api.registry.GTRegistries; @@ -71,7 +72,7 @@ private static BlockEntry createMarker(String name) { public static void init() { ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.DIMENSION_MARKERS, DimensionMarker.class)); - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistries.DIMENSION_MARKERS.getRegistryName()); } GTRegistries.DIMENSION_MARKERS.freeze(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java index c231003ea2..7c31949f65 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.common.data; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.addon.AddonFinder; import com.gregtechceu.gtceu.api.addon.IGTAddon; @@ -160,7 +161,7 @@ public static Element createAndRegister(long protons, long neutrons, long halfLi public static void init() { AddonFinder.getAddons().forEach(IGTAddon::registerElements); ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.ELEMENTS, Element.class)); - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistries.ELEMENTS.getRegistryName()); } GTRegistries.ELEMENTS.freeze(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java index a28b8f1834..decd93b956 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java @@ -2654,7 +2654,7 @@ public static NonNullConsumer attach(IItemComponen public static NonNullConsumer modelPredicate(ResourceLocation predicate, Function property) { return item -> { - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { ItemProperties.register(item, predicate, (itemStack, c, l, i) -> property.apply(itemStack)); } }; @@ -2664,7 +2664,7 @@ public static NonNullConsumer modelPredicate(ResourceLocatio public static NonNullConsumer modelPredicate(ResourceLocation predicate, Supplier> property) { return item -> { - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { ItemProperties.register(item, predicate, property.get().get()); } }; diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java index 46a703cfad..5ff36d3e8e 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java @@ -48,7 +48,7 @@ public static void init() { // Remove these categories, so they don't get registered in XEI at all, dev or not GTRegistries.RECIPE_CATEGORIES.remove(DUMMY.registryKey); GTRegistries.RECIPE_CATEGORIES.remove(GTRecipeTypes.FURNACE_RECIPES.getCategory().registryKey); - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistries.RECIPE_CATEGORIES.getRegistryName()); } ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.RECIPE_CATEGORIES, GTRecipeCategory.class)); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java index 8eb8cf7d2b..390c30953e 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java @@ -689,7 +689,7 @@ public static GTRecipeType register(String name, String group, RecipeType... public static void init() { GCYMRecipeTypes.init(); - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistries.RECIPE_TYPES.getRegistryName()); } ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.RECIPE_TYPES, GTRecipeType.class)); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java index 4c55ded13f..ec82bc3ada 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java @@ -634,7 +634,7 @@ public static void init() {} .pattern(definition -> { TraceabilityPredicate casingPredicate = blocks(CASING_WATERTIGHT.get()).setMinGlobalLimited(40); TraceabilityPredicate exportPredicate = abilities(PartAbility.EXPORT_FLUIDS_1X); - if (GTCEuAPI.Mods.isAE2Loaded()) + if (GTCEu.isAE2Loaded()) exportPredicate = exportPredicate.or(blocks(GTAEMachines.FLUID_EXPORT_HATCH_ME.get())); exportPredicate.setMaxLayerLimited(1); return FactoryBlockPattern.start(RIGHT, BACK, UP) diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMultiMachines.java b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMultiMachines.java index 4fab484afb..017fcd9c20 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMultiMachines.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMultiMachines.java @@ -446,7 +446,7 @@ public class GTMultiMachines { .appearanceBlock(CASING_STAINLESS_CLEAN) .pattern(definition -> { TraceabilityPredicate exportPredicate = abilities(PartAbility.EXPORT_FLUIDS_1X); - if (GTCEuAPI.Mods.isAE2Loaded()) + if (GTCEu.isAE2Loaded()) exportPredicate = exportPredicate.or(blocks(GTAEMachines.FLUID_EXPORT_HATCH_ME.get())); exportPredicate.setMaxLayerLimited(1); return FactoryBlockPattern.start(RIGHT, BACK, UP) @@ -844,7 +844,7 @@ public class GTMultiMachines { tooltip.add(Component.translatable("gtceu.machine.cleanroom.tooltip.6")); tooltip.add(Component.translatable("gtceu.machine.cleanroom.tooltip.7")); // tooltip.add(Component.translatable("gtceu.machine.cleanroom.tooltip.8")); - if (GTCEuAPI.Mods.isAE2Loaded()) { + if (GTCEu.isAE2Loaded()) { tooltip.add( Component.translatable(AEConfig.instance().getChannelMode() == ChannelMode.INFINITE ? "gtceu.machine.cleanroom.tooltip.ae2.no_channels" : diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java b/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java index 84f69b40ca..d51e189760 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.common.item; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.blockentity.IPaintable; import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; @@ -90,7 +90,7 @@ private static ResourceLocation getId(String modid, DyeColor color, String postf for (DyeColor color : DyeColor.values()) { // if there are > 16 colors (vanilla end) & tinted is loaded, use tinted blocks - if (color.ordinal() > 15 && GTCEuAPI.isModLoaded(GTValues.MODID_TINTED)) { + if (color.ordinal() > 15 && GTCEu.isModLoaded(GTValues.MODID_TINTED)) { glassBuilder.put(color, BuiltInRegistries.BLOCK.get(getId(GTValues.MODID_TINTED, color, "stained_glass"))); glassPaneBuilder.put(color, @@ -233,7 +233,7 @@ private boolean handleSpecialBlockEntities(BlockEntity first, int limit, UseOnCo if (player == null) { return false; } - if (GTCEuAPI.Mods.isAE2Loaded() && AE2CallWrapper.isAE2Cable(first)) { + if (GTCEu.isAE2Loaded() && AE2CallWrapper.isAE2Cable(first)) { var collected = AE2CallWrapper.collect(first, limit); var ae2Color = color == null ? AEColor.TRANSPARENT : AEColor.values()[color.ordinal()]; for (var c : collected) { diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/ItemMagnetBehavior.java b/src/main/java/com/gregtechceu/gtceu/common/item/ItemMagnetBehavior.java index df6c29ffe3..b4027fc726 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/ItemMagnetBehavior.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/ItemMagnetBehavior.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.common.item; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.GTCapabilityHelper; import com.gregtechceu.gtceu.api.capability.IElectricItem; @@ -175,7 +175,7 @@ private boolean hasMagnet(@NotNull Player player) { } } - if (!GTCEuAPI.Mods.isCuriosLoaded()) { + if (!GTCEu.isCuriosLoaded()) { return false; } return CuriosUtils.hasMagnetCurios(player); diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/HullMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/HullMachine.java index 510aa0b2ae..c7fd20581e 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/HullMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/HullMachine.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.common.machine.electric; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; import com.gregtechceu.gtceu.api.machine.multiblock.part.MultiblockPartMachine; @@ -35,7 +35,7 @@ public class HullMachine extends TieredPartMachine { public HullMachine(IMachineBlockEntity holder, int tier) { super(holder, tier); - if (GTCEuAPI.Mods.isAE2Loaded()) { + if (GTCEu.isAE2Loaded()) { this.gridNodeHost = new GridNodeHostTrait(this); } else { this.gridNodeHost = null; @@ -52,7 +52,7 @@ protected void reinitializeEnergyContainer() { @Override public void onLoad() { super.onLoad(); - if (GTCEuAPI.Mods.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity && + if (GTCEu.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity && getLevel() instanceof ServerLevel level) { level.getServer().tell(new TickTask(0, connectedBlockEntity::init)); } @@ -61,7 +61,7 @@ public void onLoad() { @Override public void onUnload() { super.onUnload(); - if (GTCEuAPI.Mods.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity) { + if (GTCEu.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity) { connectedBlockEntity.getMainNode().destroy(); } } @@ -70,7 +70,7 @@ public void onUnload() { public void setFrontFacing(Direction facing) { super.setFrontFacing(facing); if (isFacingValid(facing)) { - if (GTCEuAPI.Mods.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity) { + if (GTCEu.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity) { connectedBlockEntity.init(); } } @@ -84,7 +84,7 @@ public ManagedFieldHolder getFieldHolder() { @Override public void saveCustomPersistedData(@NotNull CompoundTag tag, boolean forDrop) { super.saveCustomPersistedData(tag, forDrop); - if (GTCEuAPI.Mods.isAE2Loaded() && gridNodeHost instanceof IGridConnectedBlockEntity connectedBlockEntity) { + if (GTCEu.isAE2Loaded() && gridNodeHost instanceof IGridConnectedBlockEntity connectedBlockEntity) { CompoundTag nbt = new CompoundTag(); connectedBlockEntity.getMainNode().saveToNBT(nbt); tag.put("grid_node", nbt); @@ -94,7 +94,7 @@ public void saveCustomPersistedData(@NotNull CompoundTag tag, boolean forDrop) { @Override public void loadCustomPersistedData(@NotNull CompoundTag tag) { super.loadCustomPersistedData(tag); - if (GTCEuAPI.Mods.isAE2Loaded() && gridNodeHost instanceof IGridConnectedBlockEntity connectedBlockEntity) { + if (GTCEu.isAE2Loaded() && gridNodeHost instanceof IGridConnectedBlockEntity connectedBlockEntity) { connectedBlockEntity.getMainNode().loadFromNBT(tag.getCompound("grid_node")); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/DiodePartMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/DiodePartMachine.java index ed1f941348..818f1d6b9d 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/DiodePartMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/DiodePartMachine.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.common.machine.multiblock.part; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; @@ -69,7 +69,7 @@ protected int getMaxAmperage() { public void onLoad() { super.onLoad(); - if (!GTCEuAPI.isClientThread()) + if (!GTCEu.isClientThread()) reinitializeEnergyContainer(); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/owner/IMachineOwner.java b/src/main/java/com/gregtechceu/gtceu/common/machine/owner/IMachineOwner.java index 5105682751..01107662b5 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/owner/IMachineOwner.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/owner/IMachineOwner.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.common.machine.owner; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; import com.gregtechceu.gtceu.config.ConfigHolder; @@ -67,8 +66,8 @@ static boolean canBreakOwnerMachine(Player player, IMachineBlockEntity machine) enum MachineOwnerType { PLAYER, - FTB(GTCEuAPI.Mods::isFTBTeamsLoaded, "FTB Teams"), - ARGONAUTS(GTCEuAPI.Mods::isArgonautsLoaded, "Argonauts Guild"); + FTB(GTCEu::isFTBTeamsLoaded, "FTB Teams"), + ARGONAUTS(GTCEu::isArgonautsLoaded, "Argonauts Guild"); public static final MachineOwnerType[] VALUES = values(); diff --git a/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockFluidLoader.java b/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockFluidLoader.java index b2ba6952a9..18ea0b582d 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockFluidLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockFluidLoader.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.data.loader; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.addon.AddonFinder; import com.gregtechceu.gtceu.api.addon.IGTAddon; @@ -51,7 +52,7 @@ protected void apply(Map resourceList, ResourceMa AddonFinder.getAddons().forEach(IGTAddon::registerFluidVeins); ModLoader.get().postEvent( new GTCEuAPI.RegisterEvent<>(GTRegistries.BEDROCK_FLUID_DEFINITIONS, BedrockFluidDefinition.class)); - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { KJSCallWrapper.fireKJSEvent(); } RegistryOps ops = RegistryOps.create(JsonOps.INSTANCE, GTRegistries.builtinRegistry()); diff --git a/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java b/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java index 9235a3bab6..a8f93b1da7 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.data.loader; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.addon.AddonFinder; import com.gregtechceu.gtceu.api.addon.IGTAddon; @@ -54,7 +55,7 @@ protected void apply(Map resourceList, ResourceMa AddonFinder.getAddons().forEach(IGTAddon::registerBedrockOreVeins); ModLoader.get().postEvent( new GTCEuAPI.RegisterEvent<>(GTRegistries.BEDROCK_ORE_DEFINITIONS, BedrockOreDefinition.class)); - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { KJSCallWrapper.fireKJSEvent(); } diff --git a/src/main/java/com/gregtechceu/gtceu/data/loader/GTOreLoader.java b/src/main/java/com/gregtechceu/gtceu/data/loader/GTOreLoader.java index f28ed5ad27..6bd92c81dc 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/loader/GTOreLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/loader/GTOreLoader.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.data.loader; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.addon.AddonFinder; import com.gregtechceu.gtceu.api.addon.IGTAddon; @@ -55,7 +56,7 @@ protected void apply(Map resourceList, ResourceMa GTOres.init(); AddonFinder.getAddons().forEach(IGTAddon::registerOreVeins); ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.ORE_VEINS, GTOreDefinition.class)); - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { KJSCallWrapper.fireKJSEvent(); } diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/CraftingComponent.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/CraftingComponent.java index 0eccca7777..3e2c036b7a 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/CraftingComponent.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/CraftingComponent.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.data.recipe; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.chemical.material.properties.BlastProperty; @@ -925,7 +926,7 @@ public static void initializeComponents() { }).collect(Collectors.toMap(data -> (Integer) data[0], data -> data[1]))); MinecraftForge.EVENT_BUS.post(new CraftingComponentModificationEvent()); - if (GTCEuAPI.Mods.isKubeJSLoaded()) { + if (GTCEu.isKubeJSLoaded()) { KJSCallWrapper.craftingComponentModification(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MachineRecipeLoader.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MachineRecipeLoader.java index ced9c0afb1..9da21d0b69 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MachineRecipeLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MachineRecipeLoader.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.data.recipe.misc; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; import com.gregtechceu.gtceu.api.data.chemical.material.MarkerMaterial; @@ -1486,7 +1486,7 @@ private static void registerHatchConversion(Consumer provider) { VanillaRecipeHelper.addShapedRecipe(provider, "steam_bus_input_to_output", STEAM_IMPORT_BUS.asStack(), "d", "B", 'B', STEAM_EXPORT_BUS.asStack()); - if (GTCEuAPI.Mods.isAE2Loaded()) { + if (GTCEu.isAE2Loaded()) { VanillaRecipeHelper.addShapedRecipe(provider, "me_fluid_hatch_output_to_input", GTAEMachines.FLUID_IMPORT_HATCH_ME.asStack(), "d", "B", 'B', GTAEMachines.FLUID_EXPORT_HATCH_ME.asStack()); diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java index cd2f6f0ff5..46e9f13356 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.data.recipe.misc; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; @@ -553,7 +554,7 @@ public static void init(Consumer provider) { // ME Parts - if (GTCEuAPI.Mods.isAE2Loaded()) { + if (GTCEu.isAE2Loaded()) { ItemStack meInterface = AEParts.INTERFACE.stack(1); ItemStack accelerationCard = AEItems.SPEED_CARD.stack(2); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java index af92b69d68..15925198b6 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.integration.emi; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.registry.GTRegistries; @@ -62,10 +62,10 @@ public void register(EmiRegistry registry) { } } registry.addRecipeHandler(ModularUIContainer.MENUTYPE, new GTEmiRecipeHandler()); - if (GTCEuAPI.Mods.isAE2Loaded()) { + if (GTCEu.isAE2Loaded()) { registry.addRecipeHandler(PatternEncodingTermMenu.TYPE, new Ae2PatternTerminalHandler<>()); } - if (GTCEuAPI.isModLoaded(GTValues.MODID_AE2WTLIB)) { + if (GTCEu.isModLoaded(GTValues.MODID_AE2WTLIB)) { registry.addRecipeHandler(WETMenu.TYPE, new Ae2PatternTerminalHandler<>()); } registry.addCategory(GTProgrammedCircuitCategory.CATEGORY); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jade/GTJadePlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/jade/GTJadePlugin.java index cdfa3df090..e471257121 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jade/GTJadePlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/jade/GTJadePlugin.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.integration.jade; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; import com.gregtechceu.gtceu.common.blockentity.FluidPipeBlockEntity; import com.gregtechceu.gtceu.common.data.GTMaterialItems; @@ -42,7 +42,7 @@ public void register(IWailaCommonRegistration registration) { registration.registerBlockDataProvider(new HazardCleanerBlockProvider(), BlockEntity.class); registration.registerBlockDataProvider(new TransformerBlockProvider(), BlockEntity.class); registration.registerBlockDataProvider(new PrimitivePumpBlockProvider(), BlockEntity.class); - if (GTCEuAPI.Mods.isAE2Loaded()) { + if (GTCEu.isAE2Loaded()) { registration.registerBlockDataProvider(new MEPatternBufferProxyProvider(), BlockEntity.class); registration.registerBlockDataProvider(new MEPatternBufferProvider(), BlockEntity.class); } @@ -71,7 +71,7 @@ public void registerClient(IWailaClientRegistration registration) { registration.registerBlockComponent(new HazardCleanerBlockProvider(), Block.class); registration.registerBlockComponent(new TransformerBlockProvider(), Block.class); registration.registerBlockComponent(new PrimitivePumpBlockProvider(), Block.class); - if (GTCEuAPI.Mods.isAE2Loaded()) { + if (GTCEu.isAE2Loaded()) { registration.registerBlockComponent(new MEPatternBufferProxyProvider(), Block.class); registration.registerBlockComponent(new MEPatternBufferProvider(), Block.class); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java index c2dcd56294..2c5c5ea015 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.integration.jei; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTFluids; @@ -59,7 +58,7 @@ public ResourceLocation getPluginUid() { @Override public void registerCategories(@NotNull IRecipeCategoryRegistration registry) { - if (GTCEuAPI.Mods.isReiLoaded() || GTCEuAPI.Mods.isEmiLoaded()) return; + if (GTCEu.isReiLoaded() || GTCEu.isEmiLoaded()) return; GTCEu.LOGGER.info("JEI register categories"); IJeiHelpers jeiHelpers = registry.getJeiHelpers(); registry.addRecipeCategories(new MultiblockInfoCategory(jeiHelpers)); @@ -79,7 +78,7 @@ public void registerCategories(@NotNull IRecipeCategoryRegistration registry) { @Override public void registerRecipeCatalysts(@NotNull IRecipeCatalystRegistration registration) { - if (GTCEuAPI.Mods.isReiLoaded() || GTCEuAPI.Mods.isEmiLoaded()) return; + if (GTCEu.isReiLoaded() || GTCEu.isEmiLoaded()) return; GTRecipeJEICategory.registerRecipeCatalysts(registration); if (!ConfigHolder.INSTANCE.compat.hideOreProcessingDiagrams) GTOreProcessingInfoCategory.registerRecipeCatalysts(registration); @@ -94,7 +93,7 @@ public void registerRecipeCatalysts(@NotNull IRecipeCatalystRegistration registr @Override public void registerRecipes(@NotNull IRecipeRegistration registration) { - if (GTCEuAPI.Mods.isReiLoaded() || GTCEuAPI.Mods.isEmiLoaded()) return; + if (GTCEu.isReiLoaded() || GTCEu.isEmiLoaded()) return; GTCEu.LOGGER.info("JEI register"); MultiblockInfoCategory.registerRecipes(registration); GTRecipeJEICategory.registerRecipes(registration); @@ -110,7 +109,7 @@ public void registerRecipes(@NotNull IRecipeRegistration registration) { @Override public void registerIngredients(@NotNull IModIngredientRegistration registry) { - if (GTCEuAPI.Mods.isReiLoaded() || GTCEuAPI.Mods.isEmiLoaded()) return; + if (GTCEu.isReiLoaded() || GTCEu.isEmiLoaded()) return; GTCEu.LOGGER.info("JEI register ingredients"); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/GroupingMapRenderer.java b/src/main/java/com/gregtechceu/gtceu/integration/map/GroupingMapRenderer.java index 5bf4a1ec01..7a407d7973 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/GroupingMapRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/GroupingMapRenderer.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.integration.map; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.worldgen.ores.GeneratedVeinMetadata; import com.gregtechceu.gtceu.api.gui.misc.ProspectorMode; @@ -26,13 +26,13 @@ public class GroupingMapRenderer extends GenericMapRenderer { static { Map renderers = new HashMap<>(); - if (GTCEuAPI.isModLoaded(GTValues.MODID_JOURNEYMAP)) { + if (GTCEu.isModLoaded(GTValues.MODID_JOURNEYMAP)) { renderers.put(GTValues.MODID_JOURNEYMAP, new JourneymapRenderer()); } - if (GTCEuAPI.isModLoaded(GTValues.MODID_XAEROS_MINIMAP)) { + if (GTCEu.isModLoaded(GTValues.MODID_XAEROS_MINIMAP)) { renderers.put(GTValues.MODID_XAEROS_MINIMAP, new XaerosRenderer()); } - if (GTCEuAPI.isModLoaded(GTValues.MODID_FTB_CHUNKS)) { + if (GTCEu.isModLoaded(GTValues.MODID_FTB_CHUNKS)) { // TODO FTB chunks support } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java b/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java index de881e108b..2acbb82f9e 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.integration.map; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.integration.map.journeymap.JourneymapWaypointHandler; import com.gregtechceu.gtceu.integration.map.xaeros.XaeroWaypointHandler; @@ -26,11 +26,11 @@ public class WaypointManager { private static boolean active = false; public static void init() { - if (GTCEuAPI.isModLoaded(GTValues.MODID_XAEROS_MINIMAP)) { + if (GTCEu.isModLoaded(GTValues.MODID_XAEROS_MINIMAP)) { WaypointManager.registerWaypointHandler(new XaeroWaypointHandler()); active = true; } - if (GTCEuAPI.isModLoaded(GTValues.MODID_JOURNEYMAP)) { + if (GTCEu.isModLoaded(GTValues.MODID_JOURNEYMAP)) { WaypointManager.registerWaypointHandler(new JourneymapWaypointHandler()); active = true; } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/xaeros/XaerosMapPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/map/xaeros/XaerosMapPlugin.java index a43a0cee4f..655a1df604 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/xaeros/XaerosMapPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/xaeros/XaerosMapPlugin.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.integration.map.xaeros; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import it.unimi.dsi.fastutil.objects.Object2BooleanMap; @@ -31,7 +31,7 @@ public static void toggleOption(String name, boolean active) { dimHighlightHandler.requestRefresh(); } - if (GTCEuAPI.isModLoaded(GTValues.MODID_XAEROS_WORLDMAP)) { + if (GTCEu.isModLoaded(GTValues.MODID_XAEROS_WORLDMAP)) { WorldMapSession session = WorldMapSession.getCurrentSession(); MapWorld world = session.getMapProcessor().getMapWorld(); for (MapDimension mapDim : world.getDimensionsList()) { diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java index 1f54587b0b..f8e740541e 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.integration.xei.widgets; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.recipe.CWURecipeCapability; import com.gregtechceu.gtceu.api.capability.recipe.IO; @@ -233,7 +233,7 @@ private int getVoltageXOffset() { case IV -> 12; default -> 14; }; - if (!GTCEuAPI.Mods.isEmiLoaded()) { + if (!GTCEu.isEmiLoaded()) { x -= 3; } return x; diff --git a/src/main/java/com/gregtechceu/gtceu/utils/GTUtil.java b/src/main/java/com/gregtechceu/gtceu/utils/GTUtil.java index f60f6591d8..a30e3ed52f 100644 --- a/src/main/java/com/gregtechceu/gtceu/utils/GTUtil.java +++ b/src/main/java/com/gregtechceu/gtceu/utils/GTUtil.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.utils; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey; @@ -302,7 +301,7 @@ public static Class getActualTypeParameter(Class thisClas } public static boolean isShiftDown() { - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { var id = Minecraft.getInstance().getWindow().getWindow(); return InputConstants.isKeyDown(id, GLFW.GLFW_KEY_LEFT_SHIFT) || InputConstants.isKeyDown(id, GLFW.GLFW_KEY_LEFT_SHIFT); @@ -311,7 +310,7 @@ public static boolean isShiftDown() { } public static boolean isCtrlDown() { - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { var id = Minecraft.getInstance().getWindow().getWindow(); return InputConstants.isKeyDown(id, GLFW.GLFW_KEY_LEFT_CONTROL) || InputConstants.isKeyDown(id, GLFW.GLFW_KEY_RIGHT_CONTROL); @@ -320,7 +319,7 @@ public static boolean isCtrlDown() { } public static boolean isAltDown() { - if (GTCEuAPI.isClientSide()) { + if (GTCEu.isClientSide()) { var id = Minecraft.getInstance().getWindow().getWindow(); return InputConstants.isKeyDown(id, GLFW.GLFW_KEY_LEFT_ALT) || InputConstants.isKeyDown(id, GLFW.GLFW_KEY_RIGHT_ALT); @@ -430,7 +429,7 @@ public static boolean canSeeSunClearly(Level world, BlockPos blockPos) { } ResourceLocation javdVoidBiome = new ResourceLocation("javd", "void"); - if (GTCEuAPI.Mods.isJAVDLoaded() && + if (GTCEu.isJAVDLoaded() && world.registryAccess().registryOrThrow(Registries.BIOME).getKey(biome).equals(javdVoidBiome)) { return !world.isDay(); } else return world.isDay(); From 3a0615be05314e56348b6ccb974f76d865e95b0b Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sun, 22 Dec 2024 05:03:47 +0200 Subject: [PATCH 13/24] more GTCEu less ldlib/platform --- .../java/com/gregtechceu/gtceu/GTCEu.java | 57 ++++++++++++++++++- .../com/gregtechceu/gtceu/api/GTCEuAPI.java | 7 ++- .../gtceu/api/block/MaterialBlock.java | 5 +- .../gregtechceu/gtceu/api/block/OreBlock.java | 5 +- .../material/info/MaterialIconType.java | 9 ++- .../properties/MaterialProperties.java | 4 +- .../api/gui/editor/EditableMachineUI.java | 5 +- .../gtceu/api/item/TagPrefixItem.java | 5 +- .../gtceu/api/item/tool/GTAxeItem.java | 5 +- .../gtceu/api/item/tool/GTHoeItem.java | 5 +- .../gtceu/api/item/tool/GTShovelItem.java | 5 +- .../gtceu/api/item/tool/GTSwordItem.java | 5 +- .../gtceu/api/item/tool/GTToolItem.java | 5 +- .../gtceu/api/machine/trait/RecipeLogic.java | 4 +- .../api/pattern/MultiblockWorldSavedData.java | 6 +- .../recipe/content/IContentSerializer.java | 5 +- .../api/recipe/lookup/GTRecipeLookup.java | 4 +- .../gtceu/api/recipe/ui/GTRecipeTypeUI.java | 5 +- .../gtceu/api/registry/GTRegistries.java | 4 +- .../gregtechceu/gtceu/client/ClientProxy.java | 5 +- .../gregtechceu/gtceu/common/CommonProxy.java | 3 +- .../gtceu/common/block/SurfaceRockBlock.java | 5 +- .../gtceu/common/commands/GTCommands.java | 4 +- .../gtceu/common/item/armor/Jetpack.java | 4 +- .../common/item/armor/NanoMuscleSuite.java | 4 +- .../common/item/armor/PowerlessJetpack.java | 4 +- .../common/item/armor/QuarkTechSuite.java | 4 +- .../packets/SCPacketShareProspection.java | 4 +- .../packets/SPacketSyncBedrockOreVeins.java | 5 +- .../packets/SPacketSyncFluidVeins.java | 5 +- .../network/packets/SPacketSyncOreVeins.java | 5 +- .../core/mixins/LootDataManagerMixin.java | 5 +- .../gtceu/data/loader/BedrockOreLoader.java | 4 +- .../gtceu/data/pack/GTDynamicDataPack.java | 4 +- .../data/pack/GTDynamicResourcePack.java | 12 ++-- .../gtceu/integration/emi/GTEMIPlugin.java | 3 +- .../emi/recipe/GTRecipeEMICategory.java | 6 +- .../gtceu/integration/jei/GTJEIPlugin.java | 4 +- .../jei/recipe/GTRecipeJEICategory.java | 6 +- .../gtceu/integration/rei/GTREIPlugin.java | 4 +- .../rei/recipe/GTRecipeREICategory.java | 6 +- .../gtceu/utils/input/KeyBind.java | 10 ++-- 42 files changed, 134 insertions(+), 132 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/GTCEu.java b/src/main/java/com/gregtechceu/gtceu/GTCEu.java index 6f8f1de894..aabab02419 100644 --- a/src/main/java/com/gregtechceu/gtceu/GTCEu.java +++ b/src/main/java/com/gregtechceu/gtceu/GTCEu.java @@ -7,18 +7,25 @@ import com.gregtechceu.gtceu.utils.FormattingUtil; import com.lowdragmc.lowdraglib.LDLib; -import com.lowdragmc.lowdraglib.Platform; import net.minecraft.client.Minecraft; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.common.Mod; - import net.minecraftforge.fml.loading.FMLEnvironment; +import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.fml.loading.FMLPaths; +import net.minecraftforge.server.ServerLifecycleHooks; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.nio.file.Path; + @Mod(GTCEu.MOD_ID) public class GTCEu { @@ -26,6 +33,8 @@ public class GTCEu { public static final String NAME = "GregTechCEu"; public static final Logger LOGGER = LoggerFactory.getLogger(NAME); + private static final RegistryAccess BLANK = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY); + public GTCEu() { GTCEu.init(); GTCEuAPI.instance = this; @@ -33,7 +42,7 @@ public GTCEu() { } public static void init() { - LOGGER.info("{} is initializing on platform: {}", NAME, Platform.platformName()); + LOGGER.info("{} is initializing...", NAME); } public static ResourceLocation id(String path) { @@ -61,6 +70,32 @@ public static boolean isHighTier() { return GTCEuAPI.isHighTier(); } + public static RegistryAccess getFrozenRegistry() { + // todo: see if this behaves correctly, the ldlib version just assigns it to a different var and returns it + if (BLANK == null && isClientThread()) { + if (Minecraft.getInstance().getConnection() != null) { + return Minecraft.getInstance().getConnection().registryAccess(); + } + } + return BLANK; + } + + public static boolean isProd() { + return FMLLoader.isProduction(); + } + + public static boolean isDev() { + return !isProd(); + } + + public static boolean isDataGen() { + return FMLLoader.getLaunchHandler().isData(); + } + + public static MinecraftServer getMinecraftServer() { + return ServerLifecycleHooks.getCurrentServer(); + } + public static boolean isModLoaded(String modId) { return ModList.get().isLoaded(modId); } @@ -79,6 +114,22 @@ public static boolean isClientSide() { return FMLEnvironment.dist.isClient(); } + /** + * @return if it's safe to access the {@code ServerLevel} + */ + public static boolean canGetServerLevel() { + if (isClientSide()) { + return Minecraft.getInstance().level != null; + } + var server = getMinecraftServer(); + return server != null && + !(server.isStopped() || server.isShutdown() || !server.isRunning() || server.isCurrentlySaving()); + } + + public static Path getGameDir() { + return FMLPaths.GAMEDIR.get(); + } + public static boolean isJeiLoaded() { return !(isEmiLoaded() || isReiLoaded()) && isModLoaded(GTValues.MODID_JEI); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java b/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java index d0f7a754ac..e9bdd6edac 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java +++ b/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java @@ -11,12 +11,13 @@ import com.gregtechceu.gtceu.common.block.BatteryBlock; import com.gregtechceu.gtceu.common.block.CoilBlock; import com.gregtechceu.gtceu.config.ConfigHolder; -import com.lowdragmc.lowdraglib.Platform; -import lombok.Getter; + import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import net.minecraftforge.eventbus.api.GenericEvent; import net.minecraftforge.fml.event.IModBusEvent; + +import lombok.Getter; import org.jetbrains.annotations.ApiStatus; import java.util.HashMap; @@ -46,7 +47,7 @@ public class GTCEuAPI { public static void initializeHighTier() { if (highTierInitialized) throw new IllegalStateException("High-Tier is already initialized."); highTier = ConfigHolder.INSTANCE.machines.highTierContent || - AddonFinder.getAddons().stream().anyMatch(IGTAddon::requiresHighTier) || Platform.isDevEnv(); + AddonFinder.getAddons().stream().anyMatch(IGTAddon::requiresHighTier) || GTCEu.isDev(); highTierInitialized = true; if (isHighTier()) GTCEu.LOGGER.info("High-Tier is Enabled."); diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java index ec684acbcb..be17a8e898 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/MaterialBlock.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.api.block; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.blockentity.PipeBlockEntity; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; @@ -10,8 +11,6 @@ import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.data.recipe.VanillaRecipeHelper; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.client.color.block.BlockColor; import net.minecraft.core.BlockPos; @@ -71,7 +70,7 @@ public MaterialBlock(Properties properties, TagPrefix tagPrefix, Material materi super(properties); this.material = material; this.tagPrefix = tagPrefix; - if (registerModel && Platform.isClient()) { + if (registerModel && GTCEu.isClientSide()) { MaterialBlockRenderer.create(this, tagPrefix.materialIconType(), material.getMaterialIconSet()); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/block/OreBlock.java b/src/main/java/com/gregtechceu/gtceu/api/block/OreBlock.java index 2058d6a857..257a0d4611 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/block/OreBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/api/block/OreBlock.java @@ -1,13 +1,12 @@ package com.gregtechceu.gtceu.api.block; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; import com.gregtechceu.gtceu.client.renderer.block.OreBlockRenderer; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.integration.map.cache.server.ServerCache; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; @@ -21,7 +20,7 @@ public class OreBlock extends MaterialBlock { public OreBlock(Properties properties, TagPrefix tagPrefix, Material material, boolean registerModel) { super(properties, tagPrefix, material, false); - if (registerModel && Platform.isClient()) { + if (registerModel && GTCEu.isClientSide()) { OreBlockRenderer.create(this); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java index 19d4f58e4e..efe88952e6 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java @@ -3,7 +3,6 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; -import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.utils.ResourceHelper; import net.minecraft.client.Minecraft; @@ -158,7 +157,7 @@ public ResourceLocation getBlockTexturePath(@NotNull MaterialIconSet materialIco MaterialIconSet iconSet = materialIconSet; // noinspection ConstantConditions - if (!Platform.isClient() || Minecraft.getInstance() == null || + if (!GTCEu.isClientSide() || Minecraft.getInstance() == null || Minecraft.getInstance().getResourceManager() == null) return null; // check minecraft for null for CI environments if (!iconSet.isRootIconset) { @@ -197,7 +196,7 @@ public ResourceLocation getBlockModelPath(@NotNull MaterialIconSet materialIconS MaterialIconSet iconSet = materialIconSet; // noinspection ConstantConditions - if (!iconSet.isRootIconset && Platform.isClient() && Minecraft.getInstance() != null && + if (!iconSet.isRootIconset && GTCEu.isClientSide() && Minecraft.getInstance() != null && Minecraft.getInstance().getResourceManager() != null) { // check minecraft for null for CI environments while (!iconSet.isRootIconset) { ResourceLocation location = GTCEu @@ -224,7 +223,7 @@ public ResourceLocation getItemModelPath(@NotNull MaterialIconSet materialIconSe MaterialIconSet iconSet = materialIconSet; // noinspection ConstantConditions - if (!iconSet.isRootIconset && Platform.isClient() && Minecraft.getInstance() != null && + if (!iconSet.isRootIconset && GTCEu.isClientSide() && Minecraft.getInstance() != null && Minecraft.getInstance().getResourceManager() != null) { // check minecraft for null for CI environments while (!iconSet.isRootIconset) { ResourceLocation location = GTCEu @@ -263,7 +262,7 @@ public ResourceLocation getItemTexturePath(@NotNull MaterialIconSet materialIcon MaterialIconSet iconSet = materialIconSet; // noinspection ConstantConditions - if (!iconSet.isRootIconset && Platform.isClient() && Minecraft.getInstance() != null && + if (!iconSet.isRootIconset && GTCEu.isClientSide() && Minecraft.getInstance() != null && Minecraft.getInstance().getResourceManager() != null) { // check minecraft for null for CI environments while (!iconSet.isRootIconset) { ResourceLocation location = GTCEu diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/MaterialProperties.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/MaterialProperties.java index 3838011fa3..f559c304f9 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/MaterialProperties.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/MaterialProperties.java @@ -3,8 +3,6 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.material.Material; -import com.lowdragmc.lowdraglib.Platform; - import java.util.*; public class MaterialProperties { @@ -74,7 +72,7 @@ public void verify() { if (propertyMap.keySet().stream().noneMatch(baseTypes::contains)) { if (propertyMap.isEmpty()) { - if (Platform.isDevEnv()) { + if (GTCEu.isDev()) { GTCEu.LOGGER.debug("Creating empty placeholder Material {}", material); } propertyMap.put(PropertyKey.EMPTY, PropertyKey.EMPTY.constructDefault()); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/editor/EditableMachineUI.java b/src/main/java/com/gregtechceu/gtceu/api/gui/editor/EditableMachineUI.java index 5a525e1fe4..6134c419e2 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/editor/EditableMachineUI.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/editor/EditableMachineUI.java @@ -3,7 +3,6 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.machine.MetaMachine; -import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.gui.editor.configurator.IConfigurableWidget; import com.lowdragmc.lowdraglib.gui.editor.data.Resources; import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; @@ -78,8 +77,8 @@ public CompoundTag getCustomUI() { ResourceManager resourceManager = null; if (GTCEu.isClientSide()) { resourceManager = Minecraft.getInstance().getResourceManager(); - } else if (Platform.getMinecraftServer() != null) { - resourceManager = Platform.getMinecraftServer().getResourceManager(); + } else if (GTCEu.getMinecraftServer() != null) { + resourceManager = GTCEu.getMinecraftServer().getResourceManager(); } if (resourceManager == null) { this.customUICache = new CompoundTag(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/item/TagPrefixItem.java b/src/main/java/com/gregtechceu/gtceu/api/item/TagPrefixItem.java index 11b23d0da7..fc103beb22 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/item/TagPrefixItem.java +++ b/src/main/java/com/gregtechceu/gtceu/api/item/TagPrefixItem.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.api.item; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.properties.DustProperty; @@ -9,8 +10,6 @@ import com.gregtechceu.gtceu.client.renderer.item.TagPrefixItemRenderer; import com.gregtechceu.gtceu.common.data.GTDamageTypes; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.client.color.item.ItemColor; import net.minecraft.network.chat.Component; @@ -47,7 +46,7 @@ public TagPrefixItem(Properties properties, TagPrefix tagPrefix, Material materi super(properties); this.tagPrefix = tagPrefix; this.material = material; - if (Platform.isClient()) { + if (GTCEu.isClientSide()) { TagPrefixItemRenderer.create(this, tagPrefix.materialIconType(), material.getMaterialIconSet()); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTAxeItem.java b/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTAxeItem.java index f3d1573194..6125513c54 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTAxeItem.java +++ b/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTAxeItem.java @@ -1,12 +1,11 @@ package com.gregtechceu.gtceu.api.item.tool; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.item.IGTTool; import com.gregtechceu.gtceu.api.sound.SoundEntry; import com.gregtechceu.gtceu.client.renderer.item.ToolItemRenderer; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -54,7 +53,7 @@ protected GTAxeItem(GTToolType toolType, MaterialToolTier tier, Material materia this.material = material; this.electricTier = toolType.electricTier; this.toolStats = toolStats; - if (Platform.isClient()) { + if (GTCEu.isClientSide()) { ToolItemRenderer.create(this, toolType); } definition$init(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTHoeItem.java b/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTHoeItem.java index 68a05d9b9e..c400840653 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTHoeItem.java +++ b/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTHoeItem.java @@ -1,12 +1,11 @@ package com.gregtechceu.gtceu.api.item.tool; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.item.IGTTool; import com.gregtechceu.gtceu.api.sound.SoundEntry; import com.gregtechceu.gtceu.client.renderer.item.ToolItemRenderer; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -53,7 +52,7 @@ protected GTHoeItem(GTToolType toolType, MaterialToolTier tier, Material materia this.material = material; this.electricTier = toolType.electricTier; this.toolStats = toolStats; - if (Platform.isClient()) { + if (GTCEu.isClientSide()) { ToolItemRenderer.create(this, toolType); } definition$init(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTShovelItem.java b/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTShovelItem.java index 4f031a34d3..ed4edaf533 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTShovelItem.java +++ b/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTShovelItem.java @@ -1,12 +1,11 @@ package com.gregtechceu.gtceu.api.item.tool; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.item.IGTTool; import com.gregtechceu.gtceu.api.sound.SoundEntry; import com.gregtechceu.gtceu.client.renderer.item.ToolItemRenderer; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -53,7 +52,7 @@ protected GTShovelItem(GTToolType toolType, MaterialToolTier tier, Material mate this.material = material; this.electricTier = toolType.electricTier; this.toolStats = toolStats; - if (Platform.isClient()) { + if (GTCEu.isClientSide()) { ToolItemRenderer.create(this, toolType); } definition$init(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTSwordItem.java b/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTSwordItem.java index f65cd3b950..ec679583cd 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTSwordItem.java +++ b/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTSwordItem.java @@ -1,12 +1,11 @@ package com.gregtechceu.gtceu.api.item.tool; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.item.IGTTool; import com.gregtechceu.gtceu.api.sound.SoundEntry; import com.gregtechceu.gtceu.client.renderer.item.ToolItemRenderer; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -53,7 +52,7 @@ protected GTSwordItem(GTToolType toolType, MaterialToolTier tier, Material mater this.material = material; this.electricTier = toolType.electricTier; this.toolStats = toolStats; - if (Platform.isClient()) { + if (GTCEu.isClientSide()) { ToolItemRenderer.create(this, toolType); } definition$init(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTToolItem.java b/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTToolItem.java index 9ad2a21888..552ff5ebc1 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTToolItem.java +++ b/src/main/java/com/gregtechceu/gtceu/api/item/tool/GTToolItem.java @@ -1,12 +1,11 @@ package com.gregtechceu.gtceu.api.item.tool; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.item.IGTTool; import com.gregtechceu.gtceu.api.sound.SoundEntry; import com.gregtechceu.gtceu.client.renderer.item.ToolItemRenderer; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; @@ -62,7 +61,7 @@ protected GTToolItem(GTToolType toolType, MaterialToolTier tier, Material materi this.material = material; this.electricTier = toolType.electricTier; this.toolStats = definition; - if (Platform.isClient()) { + if (GTCEu.isClientSide()) { ToolItemRenderer.create(this, toolType); } definition$init(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/trait/RecipeLogic.java b/src/main/java/com/gregtechceu/gtceu/api/machine/trait/RecipeLogic.java index 464b64f8af..ff38440bb7 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/trait/RecipeLogic.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/trait/RecipeLogic.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.api.machine.trait; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.capability.IWorkable; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; @@ -13,7 +14,6 @@ import com.gregtechceu.gtceu.api.sound.AutoReleasedSound; import com.gregtechceu.gtceu.config.ConfigHolder; -import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; import com.lowdragmc.lowdraglib.syncdata.IEnhancedManaged; import com.lowdragmc.lowdraglib.syncdata.annotation.DescSynced; @@ -178,7 +178,7 @@ public boolean needFuel() { * it should be called on the server side restrictively. */ public RecipeManager getRecipeManager() { - return Platform.getMinecraftServer().getRecipeManager(); + return GTCEu.getMinecraftServer().getRecipeManager(); } public void serverTick() { diff --git a/src/main/java/com/gregtechceu/gtceu/api/pattern/MultiblockWorldSavedData.java b/src/main/java/com/gregtechceu/gtceu/api/pattern/MultiblockWorldSavedData.java index 41a33fee61..5c41c7d7ac 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/pattern/MultiblockWorldSavedData.java +++ b/src/main/java/com/gregtechceu/gtceu/api/pattern/MultiblockWorldSavedData.java @@ -3,8 +3,6 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMultiController; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; @@ -114,7 +112,7 @@ public void removeAsyncLogic(IMultiController controller) { private void searchingTask() { try { - if (Platform.isServerNotSafe()) return; + if (!GTCEu.canGetServerLevel()) return; IN_SERVICE.set(true); for (var controller : controllers) { controller.asyncCheckPattern(periodID); @@ -128,7 +126,7 @@ private void searchingTask() { } public static boolean isThreadService() { - return IN_SERVICE.get() && !Platform.isServerNotSafe(); + return IN_SERVICE.get() && GTCEu.canGetServerLevel(); } public void releaseExecutorService() { diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java index 5a145a06f4..7b7f2bc761 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java @@ -4,7 +4,6 @@ import com.gregtechceu.gtceu.api.recipe.chance.logic.ChanceLogic; import com.lowdragmc.lowdraglib.LDLib; -import com.lowdragmc.lowdraglib.Platform; import net.minecraft.core.HolderLookup; import net.minecraft.nbt.NbtOps; @@ -20,12 +19,12 @@ public interface IContentSerializer { default void toNetwork(FriendlyByteBuf buf, T content) { - RegistryOps ops = RegistryOps.create(JsonOps.INSTANCE, Platform.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(JsonOps.INSTANCE, GTCEu.getFrozenRegistry()); buf.writeUtf(codec().encodeStart(ops, content).getOrThrow(false, GTCEu.LOGGER::error).toString()); } default T fromNetwork(FriendlyByteBuf buf) { - RegistryOps ops = RegistryOps.create(JsonOps.INSTANCE, Platform.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(JsonOps.INSTANCE, GTCEu.getFrozenRegistry()); return codec().parse(ops, LDLib.GSON.fromJson(buf.readUtf(), JsonElement.class)).getOrThrow(false, GTCEu.LOGGER::error); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/lookup/GTRecipeLookup.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/lookup/GTRecipeLookup.java index 626acd6ba1..e80ad531d6 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/lookup/GTRecipeLookup.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/lookup/GTRecipeLookup.java @@ -10,8 +10,6 @@ import com.gregtechceu.gtceu.common.item.armor.PowerlessJetpack; import com.gregtechceu.gtceu.config.ConfigHolder; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.item.ItemStack; @@ -515,7 +513,7 @@ private boolean recurseIngredientTreeAdd(@NotNull GTRecipe recipe, // handle the existing branch if (v.left().isEmpty() || v.left().get() != recipe) { // the recipe already there was not the one being added, so there is a conflict - if (ConfigHolder.INSTANCE.dev.debug || Platform.isDevEnv()) { + if (ConfigHolder.INSTANCE.dev.debug || GTCEu.isDev()) { GTCEu.LOGGER.warn( "Recipe duplicate or conflict found in GTRecipeType {} and was not added. See next lines for details", BuiltInRegistries.RECIPE_TYPE.getKey(this.recipeType)); diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java index cd67f713c0..557cdf2a29 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java @@ -20,7 +20,6 @@ import com.gregtechceu.gtceu.integration.jei.recipe.GTRecipeJEICategory; import com.gregtechceu.gtceu.integration.rei.recipe.GTRecipeREICategory; -import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.gui.editor.configurator.IConfigurableWidget; import com.lowdragmc.lowdraglib.gui.editor.data.Resources; import com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup; @@ -103,8 +102,8 @@ public CompoundTag getCustomUI() { ResourceManager resourceManager = null; if (GTCEu.isClientSide()) { resourceManager = Minecraft.getInstance().getResourceManager(); - } else if (Platform.getMinecraftServer() != null) { - resourceManager = Platform.getMinecraftServer().getResourceManager(); + } else if (GTCEu.getMinecraftServer() != null) { + resourceManager = GTCEu.getMinecraftServer().getResourceManager(); } if (resourceManager == null) { this.customUICache = new CompoundTag(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java b/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java index 4c831ed956..9f2921cc1c 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java +++ b/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java @@ -15,8 +15,6 @@ import com.gregtechceu.gtceu.api.recipe.condition.RecipeConditionType; import com.gregtechceu.gtceu.api.sound.SoundEntry; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.Registries; @@ -102,6 +100,6 @@ public static void init(IEventBus eventBus) { } public static RegistryAccess builtinRegistry() { - return Platform.getFrozenRegistry(); + return GTCEu.getFrozenRegistry(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java b/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java index b23b52183e..8befc007ba 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java +++ b/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.client; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreDefinition; @@ -18,8 +19,6 @@ import com.gregtechceu.gtceu.integration.map.layer.builtin.OreRenderLayer; import com.gregtechceu.gtceu.utils.input.KeyBind; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.client.model.BoatModel; import net.minecraft.client.model.ChestBoatModel; import net.minecraft.client.renderer.blockentity.HangingSignRenderer; @@ -53,7 +52,7 @@ public ClientProxy() { } public static void init() { - if (!Platform.isDatagen()) { + if (!GTCEu.isDataGen()) { ClientCacheManager.registerClientCache(GTClientCache.instance, "gtceu"); Layers.registerLayer(OreRenderLayer::new, "ore_veins"); Layers.registerLayer(FluidRenderLayer::new, "bedrock_fluids"); diff --git a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java index 2f529fbb21..02f143c8f6 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java +++ b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java @@ -50,7 +50,6 @@ import com.gregtechceu.gtceu.integration.top.forge.TheOneProbePluginImpl; import com.gregtechceu.gtceu.utils.input.KeyBind; -import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.gui.factory.UIFactory; import net.minecraft.core.registries.BuiltInRegistries; @@ -90,7 +89,7 @@ public CommonProxy() { GTCEuAPI.materialManager = MaterialRegistryManager.getInstance(); ConfigHolder.init(); GTCEuAPI.initializeHighTier(); - if (Platform.isDevEnv()) { + if (GTCEu.isDev()) { ConfigHolder.INSTANCE.recipes.generateLowQualityGems = true; ConfigHolder.INSTANCE.compat.energy.enableFEConverters = true; } diff --git a/src/main/java/com/gregtechceu/gtceu/common/block/SurfaceRockBlock.java b/src/main/java/com/gregtechceu/gtceu/common/block/SurfaceRockBlock.java index 9a0be75eaf..d04370bf9c 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/block/SurfaceRockBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/common/block/SurfaceRockBlock.java @@ -1,12 +1,11 @@ package com.gregtechceu.gtceu.common.block; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.item.SurfaceRockBlockItem; import com.gregtechceu.gtceu.client.renderer.block.SurfaceRockRenderer; import com.gregtechceu.gtceu.integration.map.cache.server.ServerCache; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.client.color.block.BlockColor; import net.minecraft.client.color.item.ItemColor; @@ -62,7 +61,7 @@ public SurfaceRockBlock(Properties properties, Material material) { registerDefaultState(this.defaultBlockState().setValue(FACING, Direction.DOWN)); - if (Platform.isClient()) { + if (GTCEu.isClientSide()) { SurfaceRockRenderer.create(this); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/commands/GTCommands.java b/src/main/java/com/gregtechceu/gtceu/common/commands/GTCommands.java index 13d213bd4c..98efb875b1 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/commands/GTCommands.java +++ b/src/main/java/com/gregtechceu/gtceu/common/commands/GTCommands.java @@ -17,8 +17,6 @@ import com.gregtechceu.gtceu.data.loader.GTOreLoader; import com.gregtechceu.gtceu.data.pack.GTDynamicDataPack; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandRuntimeException; import net.minecraft.commands.CommandSourceStack; @@ -102,7 +100,7 @@ public static void register(CommandDispatcher dispatcher, Co private static int dumpDataRegistry(CommandContext context, GTRegistry registry, Codec codec, String folder) { - Path parent = Platform.getGamePath().resolve("gtceu/dumped/data"); + Path parent = GTCEu.getGameDir().resolve("gtceu/dumped/data"); var ops = RegistryOps.create(JsonOps.INSTANCE, context.getSource().registryAccess()); int dumpedCount = 0; for (ResourceLocation id : registry.keys()) { diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/armor/Jetpack.java b/src/main/java/com/gregtechceu/gtceu/common/item/armor/Jetpack.java index 08d5dcc8ce..4c072ff9d7 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/armor/Jetpack.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/armor/Jetpack.java @@ -7,8 +7,6 @@ import com.gregtechceu.gtceu.api.item.armor.ArmorUtils; import com.gregtechceu.gtceu.utils.input.KeyBind; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleTypes; @@ -36,7 +34,7 @@ public class Jetpack extends ArmorLogicSuite implements IJetpack { public Jetpack(int energyPerUse, long capacity, int tier) { super(energyPerUse, capacity, tier, ArmorItem.Type.CHESTPLATE); - if (Platform.isClient() && this.shouldDrawHUD()) { + if (GTCEu.isClientSide() && this.shouldDrawHUD()) { // noinspection NewExpressionSideOnly HUD = new ArmorUtils.ModularHUD(); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/armor/NanoMuscleSuite.java b/src/main/java/com/gregtechceu/gtceu/common/item/armor/NanoMuscleSuite.java index de83d20583..eff73b53b0 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/armor/NanoMuscleSuite.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/armor/NanoMuscleSuite.java @@ -8,8 +8,6 @@ import com.gregtechceu.gtceu.common.data.GTItems; import com.gregtechceu.gtceu.utils.input.KeyBind; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.nbt.CompoundTag; @@ -40,7 +38,7 @@ public class NanoMuscleSuite extends ArmorLogicSuite implements IStepAssist { public NanoMuscleSuite(ArmorItem.Type slot, int energyPerUse, long maxCapacity, int tier) { super(energyPerUse, maxCapacity, tier, slot); - if (Platform.isClient() && this.shouldDrawHUD()) { + if (GTCEu.isClientSide() && this.shouldDrawHUD()) { // noinspection NewExpressionSideOnly HUD = new ArmorUtils.ModularHUD(); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/armor/PowerlessJetpack.java b/src/main/java/com/gregtechceu/gtceu/common/item/armor/PowerlessJetpack.java index b235375b84..13d8d41fcb 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/armor/PowerlessJetpack.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/armor/PowerlessJetpack.java @@ -11,8 +11,6 @@ import com.gregtechceu.gtceu.utils.GradientUtil; import com.gregtechceu.gtceu.utils.input.KeyBind; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; @@ -56,7 +54,7 @@ public class PowerlessJetpack implements IArmorLogic, IJetpack, IItemHUDProvider private ArmorUtils.ModularHUD HUD; public PowerlessJetpack() { - if (Platform.isClient()) + if (GTCEu.isClientSide()) HUD = new ArmorUtils.ModularHUD(); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/armor/QuarkTechSuite.java b/src/main/java/com/gregtechceu/gtceu/common/item/armor/QuarkTechSuite.java index c2dcc0cb7b..2862422ad8 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/armor/QuarkTechSuite.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/armor/QuarkTechSuite.java @@ -9,8 +9,6 @@ import com.gregtechceu.gtceu.core.IFireImmuneEntity; import com.gregtechceu.gtceu.utils.input.KeyBind; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.nbt.CompoundTag; @@ -63,7 +61,7 @@ public QuarkTechSuite(ArmorItem.Type slot, int energyPerUse, long capacity, int // potionRemovalCost.put(MobEffects.BAD_OMEN, 30000); potionRemovalCost.put(MobEffects.MOVEMENT_SLOWDOWN, 9000); potionRemovalCost.put(MobEffects.UNLUCK, 5000); - if (Platform.isClient() && this.shouldDrawHUD()) { + if (GTCEu.isClientSide() && this.shouldDrawHUD()) { HUD = new ArmorUtils.ModularHUD(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/network/packets/SCPacketShareProspection.java b/src/main/java/com/gregtechceu/gtceu/common/network/packets/SCPacketShareProspection.java index 55d858fd0b..091fa9a209 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/network/packets/SCPacketShareProspection.java +++ b/src/main/java/com/gregtechceu/gtceu/common/network/packets/SCPacketShareProspection.java @@ -1,9 +1,9 @@ package com.gregtechceu.gtceu.common.network.packets; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.common.network.GTNetwork; import com.gregtechceu.gtceu.integration.map.ClientCacheManager; -import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.networking.IHandlerContext; import com.lowdragmc.lowdraglib.networking.IPacket; @@ -80,7 +80,7 @@ public void execute(IHandlerContext handler) { isDimCache, dimension, data, first); GTNetwork.NETWORK.sendToPlayer(newPacket, - Platform.getMinecraftServer().getPlayerList().getPlayer(receiver)); + GTCEu.getMinecraftServer().getPlayerList().getPlayer(receiver)); } } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncBedrockOreVeins.java b/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncBedrockOreVeins.java index a42a9d5f8d..3a5a6623ef 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncBedrockOreVeins.java +++ b/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncBedrockOreVeins.java @@ -4,7 +4,6 @@ import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreDefinition; import com.gregtechceu.gtceu.client.ClientProxy; -import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.networking.IHandlerContext; import com.lowdragmc.lowdraglib.networking.IPacket; @@ -32,7 +31,7 @@ public SPacketSyncBedrockOreVeins() { @Override public void encode(FriendlyByteBuf buf) { - RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, Platform.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTCEu.getFrozenRegistry()); int size = veins.size(); buf.writeVarInt(size); for (var entry : veins.entrySet()) { @@ -45,7 +44,7 @@ public void encode(FriendlyByteBuf buf) { @Override public void decode(FriendlyByteBuf buf) { - RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, Platform.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTCEu.getFrozenRegistry()); Stream.generate(() -> { ResourceLocation id = buf.readResourceLocation(); CompoundTag tag = buf.readAnySizeNbt(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncFluidVeins.java b/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncFluidVeins.java index b6e68ca612..953b37a178 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncFluidVeins.java +++ b/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncFluidVeins.java @@ -4,7 +4,6 @@ import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; import com.gregtechceu.gtceu.client.ClientProxy; -import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.networking.IHandlerContext; import com.lowdragmc.lowdraglib.networking.IPacket; @@ -32,7 +31,7 @@ public SPacketSyncFluidVeins() { @Override public void encode(FriendlyByteBuf buf) { - RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, Platform.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTCEu.getFrozenRegistry()); int size = veins.size(); buf.writeVarInt(size); for (var entry : veins.entrySet()) { @@ -45,7 +44,7 @@ public void encode(FriendlyByteBuf buf) { @Override public void decode(FriendlyByteBuf buf) { - RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, Platform.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTCEu.getFrozenRegistry()); Stream.generate(() -> { ResourceLocation id = buf.readResourceLocation(); CompoundTag tag = buf.readAnySizeNbt(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncOreVeins.java b/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncOreVeins.java index 6ab3fa1673..80dac75920 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncOreVeins.java +++ b/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncOreVeins.java @@ -5,7 +5,6 @@ import com.gregtechceu.gtceu.client.ClientProxy; import com.gregtechceu.gtceu.integration.map.cache.client.GTClientCache; -import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.networking.IHandlerContext; import com.lowdragmc.lowdraglib.networking.IPacket; @@ -33,7 +32,7 @@ public SPacketSyncOreVeins() { @Override public void encode(FriendlyByteBuf buf) { - RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, Platform.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTCEu.getFrozenRegistry()); int size = veins.size(); buf.writeVarInt(size); for (var entry : veins.entrySet()) { @@ -46,7 +45,7 @@ public void encode(FriendlyByteBuf buf) { @Override public void decode(FriendlyByteBuf buf) { - RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, Platform.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTCEu.getFrozenRegistry()); Stream.generate(() -> { ResourceLocation id = buf.readResourceLocation(); CompoundTag tag = buf.readAnySizeNbt(); diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/LootDataManagerMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/LootDataManagerMixin.java index 60798c0805..cf6b93c9f9 100644 --- a/src/main/java/com/gregtechceu/gtceu/core/mixins/LootDataManagerMixin.java +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/LootDataManagerMixin.java @@ -1,9 +1,8 @@ package com.gregtechceu.gtceu.core.mixins; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.core.MixinHelpers; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.storage.loot.LootDataManager; import net.minecraft.world.level.storage.loot.LootDataType; @@ -22,7 +21,7 @@ public abstract class LootDataManagerMixin { @Inject(method = "apply", at = @At(value = "HEAD")) public void gtceu$injectLootTables(Map, Map> allElements, CallbackInfo ci) { - if (Platform.isDatagen()) return; + if (GTCEu.isDataGen()) return; Map lootTables = (Map) allElements .get(LootDataType.TABLE); diff --git a/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java b/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java index a8f93b1da7..5559de933a 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java @@ -9,8 +9,6 @@ import com.gregtechceu.gtceu.integration.kjs.GTCEuServerEvents; import com.gregtechceu.gtceu.integration.kjs.events.GTBedrockOreVeinEventJS; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.ResourceManager; @@ -79,7 +77,7 @@ protected void apply(Map resourceList, ResourceMa GTRegistries.BEDROCK_ORE_DEFINITIONS.freeze(); } - if (Platform.getMinecraftServer() != null) {} + if (GTCEu.getMinecraftServer() != null) {} } public static BedrockOreDefinition fromJson(ResourceLocation id, JsonObject json, RegistryOps ops) { diff --git a/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicDataPack.java b/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicDataPack.java index 4260a002f8..b8b64a3d17 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicDataPack.java +++ b/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicDataPack.java @@ -6,8 +6,6 @@ import com.gregtechceu.gtceu.common.data.GTRecipes; import com.gregtechceu.gtceu.config.ConfigHolder; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.SharedConstants; import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.network.chat.Component; @@ -66,7 +64,7 @@ public static void clearServer() { public static void addRecipe(FinishedRecipe recipe) { JsonObject recipeJson = recipe.serializeRecipe(); - Path parent = Platform.getGamePath().resolve("gtceu/dumped/data"); + Path parent = GTCEu.getGameDir().resolve("gtceu/dumped/data"); ResourceLocation recipeId = recipe.getId(); if (ConfigHolder.INSTANCE.dev.dumpRecipes) { writeJson(recipeId, "recipes", parent, recipeJson); diff --git a/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicResourcePack.java b/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicResourcePack.java index 7265b1f989..fb0b80aa16 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicResourcePack.java +++ b/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicResourcePack.java @@ -5,8 +5,6 @@ import com.gregtechceu.gtceu.api.addon.IGTAddon; import com.gregtechceu.gtceu.config.ConfigHolder; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.SharedConstants; import net.minecraft.network.chat.Component; @@ -73,7 +71,7 @@ public static void clearClient() { public static void addBlockModel(ResourceLocation loc, JsonElement obj) { ResourceLocation l = getModelLocation(loc); if (ConfigHolder.INSTANCE.dev.dumpAssets) { - Path parent = Platform.getGamePath().resolve("gtceu/dumped/assets"); + Path parent = GTCEu.getGameDir().resolve("gtceu/dumped/assets"); writeJson(l, null, parent, obj); } DATA.put(l, obj.toString().getBytes(StandardCharsets.UTF_8)); @@ -86,7 +84,7 @@ public static void addBlockModel(ResourceLocation loc, Supplier obj public static void addItemModel(ResourceLocation loc, JsonElement obj) { ResourceLocation l = getItemModelLocation(loc); if (ConfigHolder.INSTANCE.dev.dumpAssets) { - Path parent = Platform.getGamePath().resolve("gtceu/dumped/assets"); + Path parent = GTCEu.getGameDir().resolve("gtceu/dumped/assets"); writeJson(l, null, parent, obj); } DATA.put(l, obj.toString().getBytes(StandardCharsets.UTF_8)); @@ -99,7 +97,7 @@ public static void addItemModel(ResourceLocation loc, Supplier obj) public static void addBlockState(ResourceLocation loc, JsonElement stateJson) { ResourceLocation l = getBlockStateLocation(loc); if (ConfigHolder.INSTANCE.dev.dumpAssets) { - Path parent = Platform.getGamePath().resolve("gtceu/dumped/assets"); + Path parent = GTCEu.getGameDir().resolve("gtceu/dumped/assets"); writeJson(l, null, parent, stateJson); } DATA.put(l, stateJson.toString().getBytes(StandardCharsets.UTF_8)); @@ -112,7 +110,7 @@ public static void addBlockState(ResourceLocation loc, Supplier gen public static void addBlockTexture(ResourceLocation loc, byte[] data) { ResourceLocation l = getTextureLocation("block", loc); if (ConfigHolder.INSTANCE.dev.dumpAssets) { - Path parent = Platform.getGamePath().resolve("gtceu/dumped/assets"); + Path parent = GTCEu.getGameDir().resolve("gtceu/dumped/assets"); writeByteArray(l, null, parent, data); } DATA.put(l, data); @@ -121,7 +119,7 @@ public static void addBlockTexture(ResourceLocation loc, byte[] data) { public static void addItemTexture(ResourceLocation loc, byte[] data) { ResourceLocation l = getTextureLocation("item", loc); if (ConfigHolder.INSTANCE.dev.dumpAssets) { - Path parent = Platform.getGamePath().resolve("gtceu/dumped/assets"); + Path parent = GTCEu.getGameDir().resolve("gtceu/dumped/assets"); writeByteArray(l, null, parent, data); } DATA.put(l, data); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java index 15925198b6..3a892d0faf 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java @@ -22,7 +22,6 @@ import com.gregtechceu.gtceu.integration.emi.recipe.GTEmiRecipeHandler; import com.gregtechceu.gtceu.integration.emi.recipe.GTRecipeEMICategory; -import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.gui.modular.ModularUIContainer; import net.minecraft.core.registries.BuiltInRegistries; @@ -57,7 +56,7 @@ public void register(EmiRegistry registry) { if (ConfigHolder.INSTANCE.machines.doBedrockOres) registry.addCategory(GTBedrockOreEmiCategory.CATEGORY); for (GTRecipeCategory category : GTRegistries.RECIPE_CATEGORIES) { - if (Platform.isDevEnv() || category.isXEIVisible()) { + if (GTCEu.isDev() || category.isXEIVisible()) { registry.addCategory(GTRecipeEMICategory.CATEGORIES.apply(category)); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTRecipeEMICategory.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTRecipeEMICategory.java index 7a456e0321..6787276bcc 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTRecipeEMICategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/emi/recipe/GTRecipeEMICategory.java @@ -1,12 +1,12 @@ package com.gregtechceu.gtceu.integration.emi.recipe; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.machine.MachineDefinition; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTRecipeTypes; -import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.emi.IGui2Renderable; import net.minecraft.Util; @@ -32,7 +32,7 @@ private GTRecipeEMICategory(GTRecipeCategory category) { public static void registerDisplays(EmiRegistry registry) { for (GTRecipeCategory category : GTRegistries.RECIPE_CATEGORIES) { - if (!category.isXEIVisible() && !Platform.isDevEnv()) continue; + if (!category.isXEIVisible() && !GTCEu.isDev()) continue; var type = category.getRecipeType(); if (category == type.getCategory()) type.buildRepresentativeRecipes(); EmiRecipeCategory emiCategory = CATEGORIES.apply(category); @@ -48,7 +48,7 @@ public static void registerWorkStations(EmiRegistry registry) { for (GTRecipeType type : machine.getRecipeTypes()) { if (type == null) continue; for (GTRecipeCategory category : type.getCategories()) { - if (!category.isXEIVisible() && !Platform.isDevEnv()) continue; + if (!category.isXEIVisible() && !GTCEu.isDev()) continue; registry.addWorkstation(machineCategory(category), EmiStack.of(machine.asStack())); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java index 2c5c5ea015..6e5e362342 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java @@ -19,8 +19,6 @@ import com.gregtechceu.gtceu.integration.jei.recipe.GTRecipeJEICategory; import com.gregtechceu.gtceu.integration.jei.subtype.PotionFluidSubtypeInterpreter; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; @@ -69,7 +67,7 @@ public void registerCategories(@NotNull IRecipeCategoryRegistration registry) { if (ConfigHolder.INSTANCE.machines.doBedrockOres) registry.addRecipeCategories(new GTBedrockOreInfoCategory(jeiHelpers)); for (GTRecipeCategory category : GTRegistries.RECIPE_CATEGORIES) { - if (Platform.isDevEnv() || category.isXEIVisible()) { + if (GTCEu.isDev() || category.isXEIVisible()) { registry.addRecipeCategories(new GTRecipeJEICategory(jeiHelpers, category)); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/recipe/GTRecipeJEICategory.java b/src/main/java/com/gregtechceu/gtceu/integration/jei/recipe/GTRecipeJEICategory.java index 92aacb790d..4caa6eceb3 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/recipe/GTRecipeJEICategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/jei/recipe/GTRecipeJEICategory.java @@ -1,12 +1,12 @@ package com.gregtechceu.gtceu.integration.jei.recipe; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.machine.MachineDefinition; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTRecipeTypes; -import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.jei.IGui2IDrawable; import com.lowdragmc.lowdraglib.jei.ModularUIRecipeCategory; @@ -50,7 +50,7 @@ public GTRecipeJEICategory(IJeiHelpers helpers, public static void registerRecipes(IRecipeRegistration registration) { for (GTRecipeCategory category : GTRegistries.RECIPE_CATEGORIES) { - if (!category.isXEIVisible() && !Platform.isDevEnv()) continue; + if (!category.isXEIVisible() && !GTCEu.isDev()) continue; var type = category.getRecipeType(); if (category == type.getCategory()) type.buildRepresentativeRecipes(); var wrapped = type.getRecipesInCategory(category).stream() @@ -66,7 +66,7 @@ public static void registerRecipeCatalysts(IRecipeCatalystRegistration registrat for (GTRecipeType type : machine.getRecipeTypes()) { if (type == null) continue; for (GTRecipeCategory category : type.getCategories()) { - if (!category.isXEIVisible() && !Platform.isDevEnv()) continue; + if (!category.isXEIVisible() && !GTCEu.isDev()) continue; registration.addRecipeCatalyst(machine.asStack(), machineType(category)); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/GTREIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/rei/GTREIPlugin.java index 7bbefdcf36..c22fa50efb 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/GTREIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/rei/GTREIPlugin.java @@ -18,8 +18,6 @@ import com.gregtechceu.gtceu.integration.rei.orevein.GTOreVeinDisplayCategory; import com.gregtechceu.gtceu.integration.rei.recipe.GTRecipeREICategory; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.world.item.alchemy.Potion; @@ -60,7 +58,7 @@ public void registerCategories(CategoryRegistry registry) { if (ConfigHolder.INSTANCE.machines.doBedrockOres) registry.add(new GTBedrockOreDisplayCategory()); for (GTRecipeCategory category : GTRegistries.RECIPE_CATEGORIES) { - if (Platform.isDevEnv() || category.isXEIVisible()) { + if (GTCEu.isDev() || category.isXEIVisible()) { registry.add(new GTRecipeREICategory(category)); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/recipe/GTRecipeREICategory.java b/src/main/java/com/gregtechceu/gtceu/integration/rei/recipe/GTRecipeREICategory.java index e7a437f784..30b6a80de7 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/recipe/GTRecipeREICategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/rei/recipe/GTRecipeREICategory.java @@ -1,12 +1,12 @@ package com.gregtechceu.gtceu.integration.rei.recipe; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.machine.MachineDefinition; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTRecipeTypes; -import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.rei.IGui2Renderer; import com.lowdragmc.lowdraglib.rei.ModularUIDisplayCategory; import com.lowdragmc.lowdraglib.utils.Size; @@ -46,7 +46,7 @@ public GTRecipeREICategory(@NotNull GTRecipeCategory category) { public static void registerDisplays(DisplayRegistry registry) { for (GTRecipeCategory category : GTRegistries.RECIPE_CATEGORIES) { - if (!category.isXEIVisible() && !Platform.isDevEnv()) continue; + if (!category.isXEIVisible() && !GTCEu.isDev()) continue; var type = category.getRecipeType(); if (category == type.getCategory()) type.buildRepresentativeRecipes(); var identifier = CATEGORIES.apply(category); @@ -62,7 +62,7 @@ public static void registerWorkStations(CategoryRegistry registry) { for (GTRecipeType type : machine.getRecipeTypes()) { if (type == null) continue; for (GTRecipeCategory category : type.getCategories()) { - if (!category.isXEIVisible() && !Platform.isDevEnv()) continue; + if (!category.isXEIVisible() && !GTCEu.isDev()) continue; registry.addWorkstations(machineCategory(category), EntryStacks.of(machine.asStack())); } } diff --git a/src/main/java/com/gregtechceu/gtceu/utils/input/KeyBind.java b/src/main/java/com/gregtechceu/gtceu/utils/input/KeyBind.java index 6590f2d556..82e6a6b61d 100644 --- a/src/main/java/com/gregtechceu/gtceu/utils/input/KeyBind.java +++ b/src/main/java/com/gregtechceu/gtceu/utils/input/KeyBind.java @@ -4,8 +4,6 @@ import com.gregtechceu.gtceu.common.network.GTNetwork; import com.gregtechceu.gtceu.common.network.packets.CPacketKeysPressed; -import com.lowdragmc.lowdraglib.Platform; - import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; import net.minecraft.server.level.ServerPlayer; @@ -50,7 +48,7 @@ public enum KeyBind { public static void init() { GTCEu.LOGGER.info("Registering KeyBinds"); - if (Platform.isClient()) { + if (GTCEu.isClientSide()) { MinecraftForge.EVENT_BUS.register(KeyBind.class); } } @@ -115,19 +113,19 @@ public static boolean scrollingDown() { // For Vanilla/Other Mod keybinds // Double Supplier to keep client classes from loading KeyBind(Supplier> keybindingGetter) { - if (Platform.isClient()) { + if (GTCEu.isClientSide()) { this.keybindingGetter = keybindingGetter; } } KeyBind(String langKey, int button) { - if (Platform.isClient()) { + if (GTCEu.isClientSide()) { this.keybinding = new KeyMapping(langKey, button, GTCEu.NAME); } } KeyBind(String langKey, IKeyConflictContext ctx, int button) { - if (Platform.isClient()) { + if (GTCEu.isClientSide()) { this.keybinding = new KeyMapping(langKey, ctx, InputConstants.Type.KEYSYM, button, GTCEu.NAME); } } From 9f53581cf67f7fc1bd42c7908bdf9e06fa8ada81 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sun, 22 Dec 2024 08:37:03 +0200 Subject: [PATCH 14/24] javadoc --- .../java/com/gregtechceu/gtceu/GTCEu.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gregtechceu/gtceu/GTCEu.java b/src/main/java/com/gregtechceu/gtceu/GTCEu.java index aabab02419..1c743a8cbd 100644 --- a/src/main/java/com/gregtechceu/gtceu/GTCEu.java +++ b/src/main/java/com/gregtechceu/gtceu/GTCEu.java @@ -80,27 +80,47 @@ public static RegistryAccess getFrozenRegistry() { return BLANK; } + /** + * @return if we're running in a production environment + */ public static boolean isProd() { return FMLLoader.isProduction(); } + /** + * @return if we're not running in a production environment + */ public static boolean isDev() { return !isProd(); } + /** + * @return if we're running data generation + */ public static boolean isDataGen() { return FMLLoader.getLaunchHandler().isData(); } + /** + * A friendly reminder that the server instance is populated on the server side only, so null/side check it! + * + * @return the current minecraft server instance + */ public static MinecraftServer getMinecraftServer() { return ServerLifecycleHooks.getCurrentServer(); } + /** + * @param modId the mod id to check for + * @return if the mod whose id is {@code modId} is loaded or not + */ public static boolean isModLoaded(String modId) { return ModList.get().isLoaded(modId); } /** + * For async stuff use this, otherwise use {@link GTCEu isClientSide} + * * @return if the current thread is the client thread */ public static boolean isClientThread() { @@ -115,7 +135,10 @@ public static boolean isClientSide() { } /** - * @return if it's safe to access the {@code ServerLevel} + * This check isn't the same for client and server! + * + * @return if it's safe to access the current instance {@link net.minecraft.world.level.Level Level} on client or if + * it's safe to access any level on server. */ public static boolean canGetServerLevel() { if (isClientSide()) { @@ -126,6 +149,9 @@ public static boolean canGetServerLevel() { !(server.isStopped() || server.isShutdown() || !server.isRunning() || server.isCurrentlySaving()); } + /** + * @return the path to the minecraft instance directory + */ public static Path getGameDir() { return FMLPaths.GAMEDIR.get(); } From daa6c7d82c81047a3eced0a6c85235d3896305d4 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 28 Dec 2024 20:02:37 +0200 Subject: [PATCH 15/24] new one found --- .../gtceu/api/recipe/category/GTRecipeCategory.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/category/GTRecipeCategory.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/category/GTRecipeCategory.java index 76e128733f..a7ee12b579 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/category/GTRecipeCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/category/GTRecipeCategory.java @@ -6,7 +6,6 @@ import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTRecipeTypes; -import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; import com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture; @@ -71,7 +70,7 @@ public void addRecipe(GTRecipe recipe) { } public boolean shouldRegisterDisplays() { - return (isXEIVisible || Platform.isDevEnv()) && + return (isXEIVisible || GTCEu.isDev()) && this != GTRecipeTypes.FURNACE_RECIPES.getCategory(); } From cd8c3aa475462416b9c6b9ccf422ca41c163db08 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 28 Dec 2024 20:55:24 +0200 Subject: [PATCH 16/24] cursed --- .../java/com/gregtechceu/gtceu/GTCEu.java | 17 ++++++++-- .../gtceu/core/mixins/WorldLoaderMixin.java | 31 +++++++++++++++++++ src/main/resources/gtceu.mixins.json | 5 +-- 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java diff --git a/src/main/java/com/gregtechceu/gtceu/GTCEu.java b/src/main/java/com/gregtechceu/gtceu/GTCEu.java index 2dbaef814d..25b8af9acd 100644 --- a/src/main/java/com/gregtechceu/gtceu/GTCEu.java +++ b/src/main/java/com/gregtechceu/gtceu/GTCEu.java @@ -21,6 +21,7 @@ import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.server.ServerLifecycleHooks; +import org.jetbrains.annotations.ApiStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +35,7 @@ public class GTCEu { public static final Logger LOGGER = LoggerFactory.getLogger(NAME); private static final RegistryAccess BLANK = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY); + private static RegistryAccess FROZEN = BLANK; public GTCEu() { GTCEu.init(); @@ -65,14 +67,23 @@ public static ResourceLocation appendId(String id) { return new ResourceLocation(strings[0], strings[1]); } + /** + * You shouldn't call it, you should probably not even look at it just to be extra safe + * + * @param registryAccess the new value to set to the frozen registry access + */ + @ApiStatus.Internal + public static void updateFrozenRegistry(RegistryAccess registryAccess) { + FROZEN = registryAccess; + } + public static RegistryAccess getFrozenRegistry() { - // todo: see if this behaves correctly, the ldlib version just assigns it to a different var and returns it - if (BLANK == null && isClientThread()) { + if (FROZEN == BLANK && isClientThread()) { if (Minecraft.getInstance().getConnection() != null) { return Minecraft.getInstance().getConnection().registryAccess(); } } - return BLANK; + return FROZEN; } /** diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java new file mode 100644 index 0000000000..5ce3deb6a4 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java @@ -0,0 +1,31 @@ +package com.gregtechceu.gtceu.core.mixins; + +import com.gregtechceu.gtceu.GTCEu; + +import net.minecraft.core.RegistryAccess; +import net.minecraft.server.WorldLoader; + +import com.llamalad7.mixinextras.sugar.Local; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; + +@Mixin(value = WorldLoader.class, remap = false) +public class WorldLoaderMixin { + + @Inject(method = "load", + at = @At(value = "INVOKE", + target = "Lnet/minecraft/server/ReloadableServerResources;loadResources(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/core/RegistryAccess$Frozen;Lnet/minecraft/world/flag/FeatureFlagSet;Lnet/minecraft/commands/Commands$CommandSelection;ILjava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;")) + private static void ldlib$getRegistryAccess(WorldLoader.InitConfig initConfig, + WorldLoader.WorldDataSupplier loadContextSupplier, + WorldLoader.ResultFactory applierFactory, + Executor prepareExecutor, Executor applyExecutor, + CallbackInfoReturnable> cir, + @Local(ordinal = 2) RegistryAccess.Frozen frozen2) { + GTCEu.updateFrozenRegistry(frozen2); + } +} diff --git a/src/main/resources/gtceu.mixins.json b/src/main/resources/gtceu.mixins.json index 808773400e..dd2a3fd651 100644 --- a/src/main/resources/gtceu.mixins.json +++ b/src/main/resources/gtceu.mixins.json @@ -17,10 +17,10 @@ "MultiPlayerGameModeMixin", "journeymap.FullscreenMixin", "rei.FluidEntryRendererMixin", - "xaeroworldmap.GuiMapMixin", - "xaeroworldmap.MapElementRenderHandlerBuilderMixin", "xaerominimap.HighlighterRegistryMixin", "xaerominimap.MinimapFBORendererMixin", + "xaeroworldmap.GuiMapMixin", + "xaeroworldmap.MapElementRenderHandlerBuilderMixin", "xaeroworldmap.WorldMapSessionMixin" ], "mixins": [ @@ -60,6 +60,7 @@ "TagLoaderMixin", "TagManagerMixin", "TagValueAccessor", + "WorldLoaderMixin", "ae2.GenericStackInvAccessor", "embeddium.BiomeColorCacheMixin", "embeddium.VanillaColorAdapterMixin", From fe195e5d4584db01521a71130ce4c288e8aaae9b Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 28 Dec 2024 20:55:44 +0200 Subject: [PATCH 17/24] refactor is mod loaded into a subclass --- .../java/com/gregtechceu/gtceu/GTCEu.java | 79 ++++++++++--------- .../blockentity/MetaMachineBlockEntity.java | 2 +- .../material/info/MaterialIconSet.java | 2 +- .../material/info/MaterialIconType.java | 2 +- .../material/properties/HazardProperty.java | 4 +- .../gtceu/api/data/tag/TagPrefix.java | 2 +- .../api/data/worldgen/WorldGenLayers.java | 2 +- .../gtceu/api/gui/misc/IGhostFluidTarget.java | 6 +- .../gtceu/api/gui/misc/IGhostItemTarget.java | 4 +- .../api/gui/widget/PatternPreviewWidget.java | 4 +- .../api/gui/widget/PhantomFluidWidget.java | 10 +-- .../api/gui/widget/PhantomSlotWidget.java | 8 +- .../gtceu/api/gui/widget/SlotWidget.java | 36 ++++----- .../gtceu/api/gui/widget/TankWidget.java | 38 ++++----- .../api/item/component/ElectricStats.java | 2 +- .../trait/NotifiableItemStackHandler.java | 2 +- .../gtceu/api/recipe/GTRecipeSerializer.java | 6 +- .../gtceu/api/recipe/ui/GTRecipeTypeUI.java | 8 +- .../machine/FusionReactorRenderer.java | 2 +- .../gregtechceu/gtceu/common/CommonProxy.java | 4 +- .../gtceu/common/data/GTDimensionMarkers.java | 2 +- .../gtceu/common/data/GTElements.java | 2 +- .../gtceu/common/data/GTMachines.java | 4 +- .../gtceu/common/data/GTRecipeCategories.java | 2 +- .../gtceu/common/data/GTRecipeTypes.java | 2 +- .../common/data/machines/GCYMMachines.java | 2 +- .../common/data/machines/GTMultiMachines.java | 4 +- .../common/item/ColorSprayBehaviour.java | 2 +- .../gtceu/common/item/ItemMagnetBehavior.java | 2 +- .../common/machine/electric/HullMachine.java | 12 +-- .../common/machine/owner/IMachineOwner.java | 4 +- .../gtceu/data/loader/BedrockFluidLoader.java | 2 +- .../gtceu/data/loader/BedrockOreLoader.java | 2 +- .../gtceu/data/loader/GTOreLoader.java | 2 +- .../gtceu/data/recipe/CraftingComponent.java | 2 +- .../data/recipe/misc/MachineRecipeLoader.java | 2 +- .../MetaTileEntityMachineRecipeLoader.java | 2 +- .../gtceu/integration/emi/GTEMIPlugin.java | 2 +- .../gtceu/integration/jade/GTJadePlugin.java | 4 +- .../gtceu/integration/jei/GTJEIPlugin.java | 8 +- .../xei/widgets/GTRecipeWidget.java | 2 +- .../com/gregtechceu/gtceu/utils/GTUtil.java | 2 +- 42 files changed, 147 insertions(+), 144 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/GTCEu.java b/src/main/java/com/gregtechceu/gtceu/GTCEu.java index 25b8af9acd..a0e71f72b8 100644 --- a/src/main/java/com/gregtechceu/gtceu/GTCEu.java +++ b/src/main/java/com/gregtechceu/gtceu/GTCEu.java @@ -162,54 +162,57 @@ public static Path getGameDir() { return FMLPaths.GAMEDIR.get(); } - public static boolean isJeiLoaded() { - return !(isEmiLoaded() || isReiLoaded()) && isModLoaded(GTValues.MODID_JEI); - } + public static class Mods { - public static boolean isReiLoaded() { - // todo: convert to base check after ui rework - return LDLib.isReiLoaded(); - } + public static boolean isJeiLoaded() { + return !(isEmiLoaded() || isReiLoaded()) && isModLoaded(GTValues.MODID_JEI); + } - public static boolean isEmiLoaded() { - // todo: convert to base check after ui rework - return LDLib.isEmiLoaded(); - } + public static boolean isReiLoaded() { + // todo: convert to base check after ui rework + return LDLib.isReiLoaded(); + } - public static boolean isKubeJSLoaded() { - return isModLoaded(GTValues.MODID_KUBEJS); - } + public static boolean isEmiLoaded() { + // todo: convert to base check after ui rework + return LDLib.isEmiLoaded(); + } - public static boolean isIrisOculusLoaded() { - return isModLoaded(GTValues.MODID_IRIS) || isModLoaded(GTValues.MODID_OCULUS); - } + public static boolean isKubeJSLoaded() { + return isModLoaded(GTValues.MODID_KUBEJS); + } - public static boolean isSodiumRubidiumEmbeddiumLoaded() { - return isModLoaded(GTValues.MODID_SODIUM) || isModLoaded(GTValues.MODID_RUBIDIUM) || - isModLoaded(GTValues.MODID_EMBEDDIUM); - } + public static boolean isIrisOculusLoaded() { + return isModLoaded(GTValues.MODID_IRIS) || isModLoaded(GTValues.MODID_OCULUS); + } - public static boolean isAE2Loaded() { - return isModLoaded(GTValues.MODID_APPENG); - } + public static boolean isSodiumRubidiumEmbeddiumLoaded() { + return isModLoaded(GTValues.MODID_SODIUM) || isModLoaded(GTValues.MODID_RUBIDIUM) || + isModLoaded(GTValues.MODID_EMBEDDIUM); + } - public static boolean isCuriosLoaded() { - return isModLoaded(GTValues.MODID_CURIOS); - } + public static boolean isAE2Loaded() { + return isModLoaded(GTValues.MODID_APPENG); + } - public static boolean isShimmerLoaded() { - return isModLoaded(GTValues.MODID_SHIMMER); - } + public static boolean isCuriosLoaded() { + return isModLoaded(GTValues.MODID_CURIOS); + } - public static boolean isJAVDLoaded() { - return isModLoaded(GTValues.MODID_JAVD); - } + public static boolean isShimmerLoaded() { + return isModLoaded(GTValues.MODID_SHIMMER); + } - public static boolean isFTBTeamsLoaded() { - return isModLoaded(GTValues.MODID_FTB_TEAMS); - } + public static boolean isJAVDLoaded() { + return isModLoaded(GTValues.MODID_JAVD); + } - public static boolean isArgonautsLoaded() { - return isModLoaded(GTValues.MODID_ARGONAUTS); + public static boolean isFTBTeamsLoaded() { + return isModLoaded(GTValues.MODID_FTB_TEAMS); + } + + public static boolean isArgonautsLoaded() { + return isModLoaded(GTValues.MODID_ARGONAUTS); + } } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/blockentity/MetaMachineBlockEntity.java b/src/main/java/com/gregtechceu/gtceu/api/blockentity/MetaMachineBlockEntity.java index 024eeff757..4344734f2a 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/blockentity/MetaMachineBlockEntity.java +++ b/src/main/java/com/gregtechceu/gtceu/api/blockentity/MetaMachineBlockEntity.java @@ -272,7 +272,7 @@ public static LazyOptional getCapability(MetaMachine machine, @NotNull Ca return GTCapability.CAPABILITY_DATA_ACCESS.orEmpty(cap, LazyOptional.of(() -> list.get(0))); } } - if (GTCEu.isAE2Loaded()) { + if (GTCEu.Mods.isAE2Loaded()) { if (cap == Capabilities.IN_WORLD_GRID_NODE_HOST) { if (machine instanceof IInWorldGridNodeHost nodeHost) { return Capabilities.IN_WORLD_GRID_NODE_HOST.orEmpty(cap, LazyOptional.of(() -> nodeHost)); diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java index edf2447771..a015487b90 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java @@ -98,7 +98,7 @@ public String toString() { } public static void init() { - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistryInfo.MATERIAL_ICON_SET.registryKey); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java index efe88952e6..ad96915d1f 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java @@ -126,7 +126,7 @@ public MaterialIconType(String name) { } public static void init() { - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistryInfo.MATERIAL_ICON_TYPE.registryKey); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/HazardProperty.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/HazardProperty.java index f63a34822f..dbafcf9f5a 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/HazardProperty.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/HazardProperty.java @@ -120,7 +120,7 @@ public boolean isProtected(LivingEntity livingEntity) { correctArmorItems.add(equipmentType); } } - if (!GTCEu.isCuriosLoaded() || this.curioSlots.isEmpty()) { + if (!GTCEu.Mods.isCuriosLoaded() || this.curioSlots.isEmpty()) { return correctArmorItems.containsAll(equipmentTypes); } Set correctCurios = new HashSet<>(); @@ -153,7 +153,7 @@ public void damageEquipment(Player player, int amount) { armor.hurtAndBreak(amount, player, p -> p.broadcastBreakEvent(type.getSlot())); } } - if (GTCEu.isCuriosLoaded()) { + if (GTCEu.Mods.isCuriosLoaded()) { ICuriosItemHandler curiosInventory = CuriosApi.getCuriosInventory(player) .resolve() .orElse(null); diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java b/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java index 896abb34aa..748e205a4a 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java @@ -75,7 +75,7 @@ public class TagPrefix { public static void init() { AddonFinder.getAddons().forEach(IGTAddon::registerTagPrefixes); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistryInfo.TAG_PREFIX.registryKey); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java index 4aefcf064e..723d2e1eab 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java @@ -59,7 +59,7 @@ public enum WorldGenLayers implements IWorldGenLayer, StringRepresentable { public static void registerAll() { AddonFinder.getAddons().forEach(IGTAddon::registerWorldgenLayers); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistryInfo.WORLD_GEN_LAYER.registryKey); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java index fbfd9dc8fd..634f0a6815 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java @@ -62,17 +62,17 @@ public void accept(@NotNull Object ingredient) { } default Object convertIngredient(Object ingredient) { - if (GTCEu.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { + if (GTCEu.Mods.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), (int) fluidStack.getAmount(), fluidStack.getTag()); } - if (GTCEu.isEmiLoaded() && ingredient instanceof EmiStack fluidEmiStack) { + if (GTCEu.Mods.isEmiLoaded() && ingredient instanceof EmiStack fluidEmiStack) { Fluid fluid = fluidEmiStack.getKeyOfType(Fluid.class); ingredient = fluid == null ? FluidStack.EMPTY : new FluidStack(fluid, (int) fluidEmiStack.getAmount(), fluidEmiStack.getNbt()); } - if (GTCEu.isJeiLoaded() && ingredient instanceof net.minecraftforge.fluids.FluidStack fluidStack) { + if (GTCEu.Mods.isJeiLoaded() && ingredient instanceof net.minecraftforge.fluids.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), fluidStack.getAmount(), fluidStack.getTag()); } return ingredient; diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java index e92908d9eb..13c67de926 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java @@ -53,7 +53,7 @@ public void accept(@NotNull Object ingredient) { } default Object convertIngredient(Object ingredient) { - if (GTCEu.isEmiLoaded() && ingredient instanceof EmiStack itemEmiStack) { + if (GTCEu.Mods.isEmiLoaded() && ingredient instanceof EmiStack itemEmiStack) { Item item = itemEmiStack.getKeyOfType(Item.class); ItemStack itemStack = item == null ? ItemStack.EMPTY : new ItemStack(item, (int) itemEmiStack.getAmount()); if (!itemStack.isEmpty()) { @@ -62,7 +62,7 @@ default Object convertIngredient(Object ingredient) { ingredient = itemStack; } - if (GTCEu.isJeiLoaded() && ingredient instanceof ITypedIngredient itemJeiStack) { + if (GTCEu.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient itemJeiStack) { return itemJeiStack.getItemStack().orElse(ItemStack.EMPTY); } return ingredient; diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java index 59c237bc75..9f5e6d6172 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java @@ -254,10 +254,10 @@ public static BlockPos locateNextRegion(int range) { public void updateScreen() { super.updateScreen(); // I can only think of this way - if (!isLoaded && GTCEu.isEmiLoaded() && Minecraft.getInstance().screen instanceof RecipeScreen) { + if (!isLoaded && GTCEu.Mods.isEmiLoaded() && Minecraft.getInstance().screen instanceof RecipeScreen) { setPage(0); isLoaded = true; - } else if (!isLoaded && GTCEu.isReiLoaded() && + } else if (!isLoaded && GTCEu.Mods.isReiLoaded() && Minecraft.getInstance().screen instanceof AbstractDisplayViewingScreen) { setPage(0); isLoaded = true; diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java index dec817539c..861efb129c 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java @@ -101,9 +101,9 @@ public static FluidStack drainFrom(Object ingredient) { @Override @OnlyIn(Dist.CLIENT) public List getPhantomTargets(Object ingredient) { - if (GTCEu.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { + if (GTCEu.Mods.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), (int) fluidStack.getAmount(), fluidStack.getTag()); - } else if (GTCEu.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + } else if (GTCEu.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { var key = emiStack.getKey(); if (key instanceof Fluid f) { int amount = emiStack.getAmount() == 0 ? 1000 : (int) emiStack.getAmount(); @@ -114,7 +114,7 @@ public List getPhantomTargets(Object ingredient) { } else { ingredient = null; } - } else if (GTCEu.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { + } else if (GTCEu.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { ingredient = jeiStack.getIngredient(); } @@ -133,11 +133,11 @@ public Rect2i getArea() { @Override public void accept(@Nonnull Object ingredient) { - if (GTCEu.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { + if (GTCEu.Mods.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), (int) fluidStack.getAmount(), fluidStack.getTag()); - } else if (GTCEu.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + } else if (GTCEu.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { var key = emiStack.getKey(); if (key instanceof Fluid f) { int amount = emiStack.getAmount() == 0 ? 1000 : (int) emiStack.getAmount(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java index e9fcbc55bc..ba0c01664d 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java @@ -126,13 +126,13 @@ public boolean canPutStack(ItemStack stack) { @Override @OnlyIn(Dist.CLIENT) public List getPhantomTargets(Object ingredient) { - if (GTCEu.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + if (GTCEu.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { Item item = emiStack.getKeyOfType(Item.class); if (item != null) { ingredient = new ItemStack(item, (int) emiStack.getAmount()); ((ItemStack) ingredient).setTag(emiStack.getNbt()); } - } else if (GTCEu.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { + } else if (GTCEu.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { ingredient = jeiStack.getItemStack().orElse(null); } if (!(ingredient instanceof ItemStack)) { @@ -150,13 +150,13 @@ public Rect2i getArea() { @Override public void accept(@Nonnull Object ingredient) { - if (GTCEu.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + if (GTCEu.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { Item item = emiStack.getKeyOfType(Item.class); if (item != null) { ingredient = new ItemStack(item, (int) emiStack.getAmount()); ((ItemStack) ingredient).setTag(emiStack.getNbt()); } - } else if (GTCEu.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { + } else if (GTCEu.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { ingredient = jeiStack.getItemStack().orElse(null); } if (slotReference != null && ingredient instanceof ItemStack stack) { diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java index df2a81c807..c5251128b8 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java @@ -204,11 +204,11 @@ public Object getXEIIngredientOverMouse(double mouseX, double mouseY) { } } - if (GTCEu.isJeiLoaded() && !realStack.isEmpty()) { + if (GTCEu.Mods.isJeiLoaded() && !realStack.isEmpty()) { return JEICallWrapper.getJEIStackClickable(realStack, getPosition(), getSize()); - } else if (GTCEu.isReiLoaded()) { + } else if (GTCEu.Mods.isReiLoaded()) { return EntryStacks.of(realStack); - } else if (GTCEu.isEmiLoaded()) { + } else if (GTCEu.Mods.isEmiLoaded()) { return EmiStack.of(realStack).setChance(getXEIChance()); } return realStack; @@ -230,11 +230,11 @@ public List getXEIIngredients() { } } - if (GTCEu.isJeiLoaded() && !realStack.isEmpty()) { + if (GTCEu.Mods.isJeiLoaded() && !realStack.isEmpty()) { return List.of(JEICallWrapper.getJEIStackClickable(realStack, getPosition(), getSize())); - } else if (GTCEu.isReiLoaded()) { + } else if (GTCEu.Mods.isReiLoaded()) { return List.of(EntryStacks.of(realStack)); - } else if (GTCEu.isEmiLoaded()) { + } else if (GTCEu.Mods.isEmiLoaded()) { return List.of(EmiStack.of(realStack).setChance(getXEIChance())); } return List.of(realStack); @@ -242,11 +242,11 @@ public List getXEIIngredients() { private List getXEIIngredients(CycleItemStackHandler handler, int index) { var stackList = handler.getStackList(index); - if (GTCEu.isJeiLoaded()) { + if (GTCEu.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredients(stackList, this::getRealStack); - } else if (GTCEu.isReiLoaded()) { + } else if (GTCEu.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(stackList, this::getRealStack); - } else if (GTCEu.isEmiLoaded()) { + } else if (GTCEu.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); @@ -254,11 +254,11 @@ private List getXEIIngredients(CycleItemStackHandler handler, int index) private List getXEIIngredientsClickable(CycleItemStackHandler handler, int index) { var stackList = handler.getStackList(index); - if (GTCEu.isJeiLoaded()) { + if (GTCEu.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredientsClickable(stackList, getPosition(), getSize(), this::getRealStack); - } else if (GTCEu.isReiLoaded()) { + } else if (GTCEu.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(stackList, this::getRealStack); - } else if (GTCEu.isEmiLoaded()) { + } else if (GTCEu.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); @@ -266,11 +266,11 @@ private List getXEIIngredientsClickable(CycleItemStackHandler handler, i private List getXEIIngredients(CycleItemEntryHandler handler, int index) { ItemEntryList entryList = handler.getEntry(index); - if (GTCEu.isJeiLoaded()) { + if (GTCEu.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredients(entryList, this::getRealStack); - } else if (GTCEu.isReiLoaded()) { + } else if (GTCEu.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(entryList, this::getRealStack); - } else if (GTCEu.isEmiLoaded()) { + } else if (GTCEu.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); @@ -278,11 +278,11 @@ private List getXEIIngredients(CycleItemEntryHandler handler, int index) private List getXEIIngredientsClickable(CycleItemEntryHandler handler, int index) { ItemEntryList entryList = handler.getEntry(index); - if (GTCEu.isJeiLoaded()) { + if (GTCEu.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredientsClickable(entryList, getPosition(), getSize(), this::getRealStack); - } else if (GTCEu.isReiLoaded()) { + } else if (GTCEu.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(entryList, this::getRealStack); - } else if (GTCEu.isEmiLoaded()) { + } else if (GTCEu.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java index ac1e25a6ca..df0b4e63e1 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java @@ -202,11 +202,11 @@ public Object getXEIIngredientOverMouse(double mouseX, double mouseY) { return getXEIIngredientsClickable(entryHandler, tank).get(0); } - if (GTCEu.isJeiLoaded()) { + if (GTCEu.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIFluidClickable(lastFluidInTank, getPosition(), getSize()); - } else if (GTCEu.isReiLoaded()) { + } else if (GTCEu.Mods.isReiLoaded()) { return EntryStacks.of(REICallWrapper.toREIStack(lastFluidInTank)); - } else if (GTCEu.isEmiLoaded()) { + } else if (GTCEu.Mods.isEmiLoaded()) { return ForgeEmiStack.of(lastFluidInTank).setChance(XEIChance); } } @@ -223,11 +223,11 @@ public List getXEIIngredients() { return getXEIIngredientsClickable(entryHandler, tank); } - if (GTCEu.isJeiLoaded()) { + if (GTCEu.Mods.isJeiLoaded()) { return List.of(JEICallWrapper.getJEIFluidClickable(lastFluidInTank, getPosition(), getSize())); - } else if (GTCEu.isReiLoaded()) { + } else if (GTCEu.Mods.isReiLoaded()) { return List.of(EntryStacks.of(REICallWrapper.toREIStack(lastFluidInTank))); - } else if (GTCEu.isEmiLoaded()) { + } else if (GTCEu.Mods.isEmiLoaded()) { return List.of(ForgeEmiStack.of(lastFluidInTank).setChance(XEIChance)); } return List.of(lastFluidInTank); @@ -235,11 +235,11 @@ public List getXEIIngredients() { private List getXEIIngredients(CycleFluidStackHandler handler, int index) { FluidStackList stackList = handler.getStackList(index); - if (GTCEu.isJeiLoaded()) { + if (GTCEu.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredients(stackList); - } else if (GTCEu.isReiLoaded()) { + } else if (GTCEu.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(stackList); - } else if (GTCEu.isEmiLoaded()) { + } else if (GTCEu.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance()); } return Collections.emptyList(); @@ -247,11 +247,11 @@ private List getXEIIngredients(CycleFluidStackHandler handler, int index private List getXEIIngredientsClickable(CycleFluidStackHandler handler, int index) { FluidStackList stackList = handler.getStackList(index); - if (GTCEu.isJeiLoaded()) { + if (GTCEu.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredientsClickable(stackList, getPosition(), getSize()); - } else if (GTCEu.isReiLoaded()) { + } else if (GTCEu.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(stackList); - } else if (GTCEu.isEmiLoaded()) { + } else if (GTCEu.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance()); } return Collections.emptyList(); @@ -259,11 +259,11 @@ private List getXEIIngredientsClickable(CycleFluidStackHandler handler, private List getXEIIngredients(CycleFluidEntryHandler handler, int index) { FluidEntryList entryList = handler.getEntry(index); - if (GTCEu.isJeiLoaded()) { + if (GTCEu.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredients(entryList); - } else if (GTCEu.isReiLoaded()) { + } else if (GTCEu.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(entryList); - } else if (GTCEu.isEmiLoaded()) { + } else if (GTCEu.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance()); } return Collections.emptyList(); @@ -271,11 +271,11 @@ private List getXEIIngredients(CycleFluidEntryHandler handler, int index private List getXEIIngredientsClickable(CycleFluidEntryHandler handler, int index) { FluidEntryList entryList = handler.getEntry(index); - if (GTCEu.isJeiLoaded()) { + if (GTCEu.Mods.isJeiLoaded()) { return JEICallWrapper.getJEIIngredientsClickable(entryList, getPosition(), getSize()); - } else if (GTCEu.isReiLoaded()) { + } else if (GTCEu.Mods.isReiLoaded()) { return REICallWrapper.getREIIngredients(entryList); - } else if (GTCEu.isEmiLoaded()) { + } else if (GTCEu.Mods.isEmiLoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance()); } return Collections.emptyList(); @@ -318,7 +318,7 @@ public List getFullTooltipTexts() { @Override public void setCurrentJEIRenderedIngredient(Object ingredient) { - if (GTCEu.isJeiLoaded()) { + if (GTCEu.Mods.isJeiLoaded()) { currentJEIRenderedIngredient = ingredient instanceof FluidStack f ? f : null; } else { currentJEIRenderedIngredient = null; diff --git a/src/main/java/com/gregtechceu/gtceu/api/item/component/ElectricStats.java b/src/main/java/com/gregtechceu/gtceu/api/item/component/ElectricStats.java index eff4f272f1..a179e27287 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/item/component/ElectricStats.java +++ b/src/main/java/com/gregtechceu/gtceu/api/item/component/ElectricStats.java @@ -104,7 +104,7 @@ public void inventoryTick(ItemStack stack, Level level, Entity entity, int slotI isInDischargeMode(stack) && electricItem.getCharge() > 0L) { long transferLimit = electricItem.getTransferLimit(); - if (GTCEu.isCuriosLoaded()) { + if (GTCEu.Mods.isCuriosLoaded()) { IItemHandler curios = CuriosApi.getCuriosInventory(player) .map(ICuriosItemHandler::getEquippedCurios) .orElse(EmptyHandler.INSTANCE); diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableItemStackHandler.java b/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableItemStackHandler.java index c3e5304b05..b5eeade6d7 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableItemStackHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/trait/NotifiableItemStackHandler.java @@ -168,7 +168,7 @@ public static List handleRecipe(IO io, GTRecipe recipe, List actions) { - if (!GTCEu.isKubeJSLoaded()) return null; + if (!GTCEu.Mods.isKubeJSLoaded()) return null; // noinspection unchecked var actioned = KJSCallWrapper.applyIngredientAction(storage, index, (List) actions); if (!actioned.isEmpty()) return actioned; diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java index 9e147d54a0..8848adc348 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java @@ -36,7 +36,7 @@ */ public class GTRecipeSerializer implements RecipeSerializer { - public static final Codec CODEC = makeCodec(GTCEu.isKubeJSLoaded()); + public static final Codec CODEC = makeCodec(GTCEu.Mods.isKubeJSLoaded()); public static final GTRecipeSerializer SERIALIZER = new GTRecipeSerializer(); @@ -131,7 +131,7 @@ public GTRecipe fromNetwork(@NotNull ResourceLocation id, @NotNull FriendlyByteB List conditions = buf.readCollection(c -> new ArrayList<>(), GTRecipeSerializer::conditionReader); List ingredientActions = new ArrayList<>(); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { ingredientActions = KJSCallWrapper.getIngredientActions(buf); } CompoundTag data = buf.readNbt(); @@ -186,7 +186,7 @@ public void toNetwork(FriendlyByteBuf buf, GTRecipe recipe) { (buf1, logic) -> buf1.writeUtf(GTRegistries.CHANCE_LOGICS.getKey(logic))); buf.writeCollection(recipe.conditions, GTRecipeSerializer::conditionWriter); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { KJSCallWrapper.writeIngredientActions(recipe.ingredientActions, buf); } buf.writeNbt(recipe.data); diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java index 557cdf2a29..08abac76f4 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java @@ -238,25 +238,25 @@ public IEditableUI createEditableUITemplate(final boo progress.add(dualProgressWidget); }); // add recipe button - if (!isJEI && (GTCEu.isReiLoaded() || GTCEu.isJeiLoaded() || GTCEu.isEmiLoaded())) { + if (!isJEI && (GTCEu.Mods.isReiLoaded() || GTCEu.Mods.isJeiLoaded() || GTCEu.Mods.isEmiLoaded())) { for (Widget widget : progress) { template.addWidget(new ButtonWidget(widget.getPosition().x, widget.getPosition().y, widget.getSize().width, widget.getSize().height, IGuiTexture.EMPTY, cd -> { if (cd.isRemote) { - if (GTCEu.isReiLoaded()) { + if (GTCEu.Mods.isReiLoaded()) { ViewSearchBuilder.builder().addCategories( recipeType.getCategories().stream() .filter(GTRecipeCategory::isXEIVisible) .map(GTRecipeREICategory::machineCategory) .collect(Collectors.toList())) .open(); - } else if (GTCEu.isJeiLoaded()) { + } else if (GTCEu.Mods.isJeiLoaded()) { JEIPlugin.jeiRuntime.getRecipesGui().showTypes( recipeType.getCategories().stream() .filter(GTRecipeCategory::isXEIVisible) .map(GTRecipeJEICategory::machineType) .collect(Collectors.toList())); - } else if (GTCEu.isEmiLoaded()) { + } else if (GTCEu.Mods.isEmiLoaded()) { EmiApi.displayRecipeCategory( GTRecipeEMICategory.machineCategory(recipeType.getCategory())); } diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/FusionReactorRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/FusionReactorRenderer.java index 176f636da2..3476c1b384 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/FusionReactorRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/FusionReactorRenderer.java @@ -33,7 +33,7 @@ public void render(BlockEntity blockEntity, float partialTicks, PoseStack stack, int combinedLight, int combinedOverlay) { if (blockEntity instanceof IMachineBlockEntity machineBlockEntity && machineBlockEntity.getMetaMachine() instanceof FusionReactorMachine machine) { - if (GTCEu.isShimmerLoaded()) { + if (GTCEu.Mods.isShimmerLoaded()) { PoseStack finalStack = RenderUtils.copyPoseStack(stack); BloomUtils.entityBloom(source -> renderLightRing(machine, partialTicks, finalStack, source)); } else { diff --git a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java index 02f143c8f6..32882139d3 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java +++ b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java @@ -199,7 +199,7 @@ private static void initMaterials() { GTCEu.LOGGER.info("Registering addon Materials"); MaterialEvent materialEvent = new MaterialEvent(); ModLoader.get().postEvent(materialEvent); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { KJSEventWrapper.materialRegistry(); } @@ -207,7 +207,7 @@ private static void initMaterials() { // Block entirely new Materials from being added in the Post event managerInternal.closeRegistries(); ModLoader.get().postEvent(new PostMaterialEvent()); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { KJSEventWrapper.materialModification(); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java index 24b3247c2b..aec91b2262 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java @@ -72,7 +72,7 @@ private static BlockEntry createMarker(String name) { public static void init() { ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.DIMENSION_MARKERS, DimensionMarker.class)); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistries.DIMENSION_MARKERS.getRegistryName()); } GTRegistries.DIMENSION_MARKERS.freeze(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java index 7c31949f65..112ef22840 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java @@ -161,7 +161,7 @@ public static Element createAndRegister(long protons, long neutrons, long halfLi public static void init() { AddonFinder.getAddons().forEach(IGTAddon::registerElements); ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.ELEMENTS, Element.class)); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistries.ELEMENTS.getRegistryName()); } GTRegistries.ELEMENTS.freeze(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java index b906ca9806..e4291c6076 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java @@ -1075,11 +1075,11 @@ public static void init() { GCYMMachines.init(); GTResearchMachines.init(); - if (GTCEu.isAE2Loaded()) { + if (GTCEu.Mods.isAE2Loaded()) { GTAEMachines.init(); } - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistries.MACHINES.getRegistryName()); } ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.MACHINES, MachineDefinition.class)); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java index c006b57c6d..22fdc55b58 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java @@ -39,7 +39,7 @@ public static GTRecipeCategory register(String categoryName, @NotNull GTRecipeTy } public static void init() { - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistries.RECIPE_CATEGORIES.getRegistryName()); } ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.RECIPE_CATEGORIES, GTRecipeCategory.class)); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java index 627855cf05..685dbfde9b 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java @@ -681,7 +681,7 @@ public static GTRecipeType register(String name, String group, RecipeType... public static void init() { GCYMRecipeTypes.init(); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { GTRegistryInfo.registerFor(GTRegistries.RECIPE_TYPES.getRegistryName()); } ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.RECIPE_TYPES, GTRecipeType.class)); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java index ec82bc3ada..2e25302fc5 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GCYMMachines.java @@ -634,7 +634,7 @@ public static void init() {} .pattern(definition -> { TraceabilityPredicate casingPredicate = blocks(CASING_WATERTIGHT.get()).setMinGlobalLimited(40); TraceabilityPredicate exportPredicate = abilities(PartAbility.EXPORT_FLUIDS_1X); - if (GTCEu.isAE2Loaded()) + if (GTCEu.Mods.isAE2Loaded()) exportPredicate = exportPredicate.or(blocks(GTAEMachines.FLUID_EXPORT_HATCH_ME.get())); exportPredicate.setMaxLayerLimited(1); return FactoryBlockPattern.start(RIGHT, BACK, UP) diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMultiMachines.java b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMultiMachines.java index 113178bf06..7734e21e61 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMultiMachines.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMultiMachines.java @@ -438,7 +438,7 @@ public class GTMultiMachines { .appearanceBlock(CASING_STAINLESS_CLEAN) .pattern(definition -> { TraceabilityPredicate exportPredicate = abilities(PartAbility.EXPORT_FLUIDS_1X); - if (GTCEu.isAE2Loaded()) + if (GTCEu.Mods.isAE2Loaded()) exportPredicate = exportPredicate.or(blocks(GTAEMachines.FLUID_EXPORT_HATCH_ME.get())); exportPredicate.setMaxLayerLimited(1); return FactoryBlockPattern.start(RIGHT, BACK, UP) @@ -834,7 +834,7 @@ public class GTMultiMachines { tooltip.add(Component.translatable("gtceu.machine.cleanroom.tooltip.6")); tooltip.add(Component.translatable("gtceu.machine.cleanroom.tooltip.7")); // tooltip.add(Component.translatable("gtceu.machine.cleanroom.tooltip.8")); - if (GTCEu.isAE2Loaded()) { + if (GTCEu.Mods.isAE2Loaded()) { tooltip.add( Component.translatable(AEConfig.instance().getChannelMode() == ChannelMode.INFINITE ? "gtceu.machine.cleanroom.tooltip.ae2.no_channels" : diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java b/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java index d51e189760..48bf3de53d 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/ColorSprayBehaviour.java @@ -233,7 +233,7 @@ private boolean handleSpecialBlockEntities(BlockEntity first, int limit, UseOnCo if (player == null) { return false; } - if (GTCEu.isAE2Loaded() && AE2CallWrapper.isAE2Cable(first)) { + if (GTCEu.Mods.isAE2Loaded() && AE2CallWrapper.isAE2Cable(first)) { var collected = AE2CallWrapper.collect(first, limit); var ae2Color = color == null ? AEColor.TRANSPARENT : AEColor.values()[color.ordinal()]; for (var c : collected) { diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/ItemMagnetBehavior.java b/src/main/java/com/gregtechceu/gtceu/common/item/ItemMagnetBehavior.java index b4027fc726..1a3e706630 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/ItemMagnetBehavior.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/ItemMagnetBehavior.java @@ -175,7 +175,7 @@ private boolean hasMagnet(@NotNull Player player) { } } - if (!GTCEu.isCuriosLoaded()) { + if (!GTCEu.Mods.isCuriosLoaded()) { return false; } return CuriosUtils.hasMagnetCurios(player); diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/HullMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/HullMachine.java index c7fd20581e..e68d1bf795 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/HullMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/HullMachine.java @@ -35,7 +35,7 @@ public class HullMachine extends TieredPartMachine { public HullMachine(IMachineBlockEntity holder, int tier) { super(holder, tier); - if (GTCEu.isAE2Loaded()) { + if (GTCEu.Mods.isAE2Loaded()) { this.gridNodeHost = new GridNodeHostTrait(this); } else { this.gridNodeHost = null; @@ -52,7 +52,7 @@ protected void reinitializeEnergyContainer() { @Override public void onLoad() { super.onLoad(); - if (GTCEu.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity && + if (GTCEu.Mods.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity && getLevel() instanceof ServerLevel level) { level.getServer().tell(new TickTask(0, connectedBlockEntity::init)); } @@ -61,7 +61,7 @@ public void onLoad() { @Override public void onUnload() { super.onUnload(); - if (GTCEu.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity) { + if (GTCEu.Mods.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity) { connectedBlockEntity.getMainNode().destroy(); } } @@ -70,7 +70,7 @@ public void onUnload() { public void setFrontFacing(Direction facing) { super.setFrontFacing(facing); if (isFacingValid(facing)) { - if (GTCEu.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity) { + if (GTCEu.Mods.isAE2Loaded() && gridNodeHost instanceof GridNodeHostTrait connectedBlockEntity) { connectedBlockEntity.init(); } } @@ -84,7 +84,7 @@ public ManagedFieldHolder getFieldHolder() { @Override public void saveCustomPersistedData(@NotNull CompoundTag tag, boolean forDrop) { super.saveCustomPersistedData(tag, forDrop); - if (GTCEu.isAE2Loaded() && gridNodeHost instanceof IGridConnectedBlockEntity connectedBlockEntity) { + if (GTCEu.Mods.isAE2Loaded() && gridNodeHost instanceof IGridConnectedBlockEntity connectedBlockEntity) { CompoundTag nbt = new CompoundTag(); connectedBlockEntity.getMainNode().saveToNBT(nbt); tag.put("grid_node", nbt); @@ -94,7 +94,7 @@ public void saveCustomPersistedData(@NotNull CompoundTag tag, boolean forDrop) { @Override public void loadCustomPersistedData(@NotNull CompoundTag tag) { super.loadCustomPersistedData(tag); - if (GTCEu.isAE2Loaded() && gridNodeHost instanceof IGridConnectedBlockEntity connectedBlockEntity) { + if (GTCEu.Mods.isAE2Loaded() && gridNodeHost instanceof IGridConnectedBlockEntity connectedBlockEntity) { connectedBlockEntity.getMainNode().loadFromNBT(tag.getCompound("grid_node")); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/owner/IMachineOwner.java b/src/main/java/com/gregtechceu/gtceu/common/machine/owner/IMachineOwner.java index 01107662b5..b1d58bdada 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/owner/IMachineOwner.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/owner/IMachineOwner.java @@ -66,8 +66,8 @@ static boolean canBreakOwnerMachine(Player player, IMachineBlockEntity machine) enum MachineOwnerType { PLAYER, - FTB(GTCEu::isFTBTeamsLoaded, "FTB Teams"), - ARGONAUTS(GTCEu::isArgonautsLoaded, "Argonauts Guild"); + FTB(GTCEu.Mods::isFTBTeamsLoaded, "FTB Teams"), + ARGONAUTS(GTCEu.Mods::isArgonautsLoaded, "Argonauts Guild"); public static final MachineOwnerType[] VALUES = values(); diff --git a/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockFluidLoader.java b/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockFluidLoader.java index 18ea0b582d..f33419b26c 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockFluidLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockFluidLoader.java @@ -52,7 +52,7 @@ protected void apply(Map resourceList, ResourceMa AddonFinder.getAddons().forEach(IGTAddon::registerFluidVeins); ModLoader.get().postEvent( new GTCEuAPI.RegisterEvent<>(GTRegistries.BEDROCK_FLUID_DEFINITIONS, BedrockFluidDefinition.class)); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { KJSCallWrapper.fireKJSEvent(); } RegistryOps ops = RegistryOps.create(JsonOps.INSTANCE, GTRegistries.builtinRegistry()); diff --git a/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java b/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java index 5559de933a..630a260c22 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/loader/BedrockOreLoader.java @@ -53,7 +53,7 @@ protected void apply(Map resourceList, ResourceMa AddonFinder.getAddons().forEach(IGTAddon::registerBedrockOreVeins); ModLoader.get().postEvent( new GTCEuAPI.RegisterEvent<>(GTRegistries.BEDROCK_ORE_DEFINITIONS, BedrockOreDefinition.class)); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { KJSCallWrapper.fireKJSEvent(); } diff --git a/src/main/java/com/gregtechceu/gtceu/data/loader/GTOreLoader.java b/src/main/java/com/gregtechceu/gtceu/data/loader/GTOreLoader.java index 6bd92c81dc..ff822c58e2 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/loader/GTOreLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/loader/GTOreLoader.java @@ -56,7 +56,7 @@ protected void apply(Map resourceList, ResourceMa GTOres.init(); AddonFinder.getAddons().forEach(IGTAddon::registerOreVeins); ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.ORE_VEINS, GTOreDefinition.class)); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { KJSCallWrapper.fireKJSEvent(); } diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/CraftingComponent.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/CraftingComponent.java index 3e2c036b7a..4226b6294f 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/CraftingComponent.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/CraftingComponent.java @@ -926,7 +926,7 @@ public static void initializeComponents() { }).collect(Collectors.toMap(data -> (Integer) data[0], data -> data[1]))); MinecraftForge.EVENT_BUS.post(new CraftingComponentModificationEvent()); - if (GTCEu.isKubeJSLoaded()) { + if (GTCEu.Mods.isKubeJSLoaded()) { KJSCallWrapper.craftingComponentModification(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MachineRecipeLoader.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MachineRecipeLoader.java index 9da21d0b69..4f3f3cbaa0 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MachineRecipeLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MachineRecipeLoader.java @@ -1486,7 +1486,7 @@ private static void registerHatchConversion(Consumer provider) { VanillaRecipeHelper.addShapedRecipe(provider, "steam_bus_input_to_output", STEAM_IMPORT_BUS.asStack(), "d", "B", 'B', STEAM_EXPORT_BUS.asStack()); - if (GTCEu.isAE2Loaded()) { + if (GTCEu.Mods.isAE2Loaded()) { VanillaRecipeHelper.addShapedRecipe(provider, "me_fluid_hatch_output_to_input", GTAEMachines.FLUID_IMPORT_HATCH_ME.asStack(), "d", "B", 'B', GTAEMachines.FLUID_EXPORT_HATCH_ME.asStack()); diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java index 46e9f13356..00e7a51172 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityMachineRecipeLoader.java @@ -554,7 +554,7 @@ public static void init(Consumer provider) { // ME Parts - if (GTCEu.isAE2Loaded()) { + if (GTCEu.Mods.isAE2Loaded()) { ItemStack meInterface = AEParts.INTERFACE.stack(1); ItemStack accelerationCard = AEItems.SPEED_CARD.stack(2); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java index 354c3261ce..c699e3d000 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java @@ -61,7 +61,7 @@ public void register(EmiRegistry registry) { } } registry.addRecipeHandler(ModularUIContainer.MENUTYPE, new GTEmiRecipeHandler()); - if (GTCEu.isAE2Loaded()) { + if (GTCEu.Mods.isAE2Loaded()) { registry.addRecipeHandler(PatternEncodingTermMenu.TYPE, new Ae2PatternTerminalHandler<>()); } if (GTCEu.isModLoaded(GTValues.MODID_AE2WTLIB)) { diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jade/GTJadePlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/jade/GTJadePlugin.java index e471257121..269313b31d 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jade/GTJadePlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/jade/GTJadePlugin.java @@ -42,7 +42,7 @@ public void register(IWailaCommonRegistration registration) { registration.registerBlockDataProvider(new HazardCleanerBlockProvider(), BlockEntity.class); registration.registerBlockDataProvider(new TransformerBlockProvider(), BlockEntity.class); registration.registerBlockDataProvider(new PrimitivePumpBlockProvider(), BlockEntity.class); - if (GTCEu.isAE2Loaded()) { + if (GTCEu.Mods.isAE2Loaded()) { registration.registerBlockDataProvider(new MEPatternBufferProxyProvider(), BlockEntity.class); registration.registerBlockDataProvider(new MEPatternBufferProvider(), BlockEntity.class); } @@ -71,7 +71,7 @@ public void registerClient(IWailaClientRegistration registration) { registration.registerBlockComponent(new HazardCleanerBlockProvider(), Block.class); registration.registerBlockComponent(new TransformerBlockProvider(), Block.class); registration.registerBlockComponent(new PrimitivePumpBlockProvider(), Block.class); - if (GTCEu.isAE2Loaded()) { + if (GTCEu.Mods.isAE2Loaded()) { registration.registerBlockComponent(new MEPatternBufferProxyProvider(), Block.class); registration.registerBlockComponent(new MEPatternBufferProvider(), Block.class); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java index 397777757e..364d3d0268 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java @@ -56,7 +56,7 @@ public ResourceLocation getPluginUid() { @Override public void registerCategories(@NotNull IRecipeCategoryRegistration registry) { - if (GTCEu.isReiLoaded() || GTCEu.isEmiLoaded()) return; + if (GTCEu.Mods.isReiLoaded() || GTCEu.Mods.isEmiLoaded()) return; GTCEu.LOGGER.info("JEI register categories"); IJeiHelpers jeiHelpers = registry.getJeiHelpers(); registry.addRecipeCategories(new MultiblockInfoCategory(jeiHelpers)); @@ -76,7 +76,7 @@ public void registerCategories(@NotNull IRecipeCategoryRegistration registry) { @Override public void registerRecipeCatalysts(@NotNull IRecipeCatalystRegistration registration) { - if (GTCEu.isReiLoaded() || GTCEu.isEmiLoaded()) return; + if (GTCEu.Mods.isReiLoaded() || GTCEu.Mods.isEmiLoaded()) return; GTRecipeJEICategory.registerRecipeCatalysts(registration); if (!ConfigHolder.INSTANCE.compat.hideOreProcessingDiagrams) GTOreProcessingInfoCategory.registerRecipeCatalysts(registration); @@ -91,7 +91,7 @@ public void registerRecipeCatalysts(@NotNull IRecipeCatalystRegistration registr @Override public void registerRecipes(@NotNull IRecipeRegistration registration) { - if (GTCEu.isReiLoaded() || GTCEu.isEmiLoaded()) return; + if (GTCEu.Mods.isReiLoaded() || GTCEu.Mods.isEmiLoaded()) return; GTCEu.LOGGER.info("JEI register"); MultiblockInfoCategory.registerRecipes(registration); GTRecipeJEICategory.registerRecipes(registration); @@ -107,7 +107,7 @@ public void registerRecipes(@NotNull IRecipeRegistration registration) { @Override public void registerIngredients(@NotNull IModIngredientRegistration registry) { - if (GTCEu.isReiLoaded() || GTCEu.isEmiLoaded()) return; + if (GTCEu.Mods.isReiLoaded() || GTCEu.Mods.isEmiLoaded()) return; GTCEu.LOGGER.info("JEI register ingredients"); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java index f8e740541e..3c0f9f7bc2 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java @@ -233,7 +233,7 @@ private int getVoltageXOffset() { case IV -> 12; default -> 14; }; - if (!GTCEu.isEmiLoaded()) { + if (!GTCEu.Mods.isEmiLoaded()) { x -= 3; } return x; diff --git a/src/main/java/com/gregtechceu/gtceu/utils/GTUtil.java b/src/main/java/com/gregtechceu/gtceu/utils/GTUtil.java index a30e3ed52f..09fa0f4c18 100644 --- a/src/main/java/com/gregtechceu/gtceu/utils/GTUtil.java +++ b/src/main/java/com/gregtechceu/gtceu/utils/GTUtil.java @@ -429,7 +429,7 @@ public static boolean canSeeSunClearly(Level world, BlockPos blockPos) { } ResourceLocation javdVoidBiome = new ResourceLocation("javd", "void"); - if (GTCEu.isJAVDLoaded() && + if (GTCEu.Mods.isJAVDLoaded() && world.registryAccess().registryOrThrow(Registries.BIOME).getKey(biome).equals(javdVoidBiome)) { return !world.isDay(); } else return world.isDay(); From ffee50b8d1fac31e57ee3fb544714d3bc248ba02 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 28 Dec 2024 20:59:59 +0200 Subject: [PATCH 18/24] removed all ldlib from main gtceu class --- src/main/java/com/gregtechceu/gtceu/GTCEu.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/GTCEu.java b/src/main/java/com/gregtechceu/gtceu/GTCEu.java index a0e71f72b8..e843756b2e 100644 --- a/src/main/java/com/gregtechceu/gtceu/GTCEu.java +++ b/src/main/java/com/gregtechceu/gtceu/GTCEu.java @@ -6,8 +6,6 @@ import com.gregtechceu.gtceu.common.CommonProxy; import com.gregtechceu.gtceu.utils.FormattingUtil; -import com.lowdragmc.lowdraglib.LDLib; - import net.minecraft.client.Minecraft; import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; @@ -21,6 +19,8 @@ import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.server.ServerLifecycleHooks; +import dev.emi.emi.config.EmiConfig; +import me.shedaniel.rei.api.client.REIRuntime; import org.jetbrains.annotations.ApiStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -169,13 +169,11 @@ public static boolean isJeiLoaded() { } public static boolean isReiLoaded() { - // todo: convert to base check after ui rework - return LDLib.isReiLoaded(); + return isModLoaded(GTValues.MODID_REI) && !(isClientSide() || REIRuntime.getInstance().isOverlayVisible()); } public static boolean isEmiLoaded() { - // todo: convert to base check after ui rework - return LDLib.isEmiLoaded(); + return isModLoaded(GTValues.MODID_EMI) && !(isClientSide() || EmiConfig.enabled); } public static boolean isKubeJSLoaded() { From 9bb896dabac5c97b63688970751eff796a48ba70 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 28 Dec 2024 21:01:15 +0200 Subject: [PATCH 19/24] removed incorrect merge result --- .../java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java index 364d3d0268..91087af80a 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java @@ -67,7 +67,7 @@ public void registerCategories(@NotNull IRecipeCategoryRegistration registry) { if (ConfigHolder.INSTANCE.machines.doBedrockOres) registry.addRecipeCategories(new GTBedrockOreInfoCategory(jeiHelpers)); for (GTRecipeCategory category : GTRegistries.RECIPE_CATEGORIES) { - if (GTCEu.isDev() || category.shouldRegisterDisplays()) { + if (category.shouldRegisterDisplays()) { registry.addRecipeCategories(new GTRecipeJEICategory(jeiHelpers, category)); } } From 4860a5170dbc9419d659dd24f1fb0c5c4782fe9c Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 28 Dec 2024 21:14:47 +0200 Subject: [PATCH 20/24] rename --- .../gtceu/core/mixins/WorldLoaderMixin.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java index 5ce3deb6a4..114e3f90f3 100644 --- a/src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java @@ -20,12 +20,12 @@ public class WorldLoaderMixin { @Inject(method = "load", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/ReloadableServerResources;loadResources(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/core/RegistryAccess$Frozen;Lnet/minecraft/world/flag/FeatureFlagSet;Lnet/minecraft/commands/Commands$CommandSelection;ILjava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;")) - private static void ldlib$getRegistryAccess(WorldLoader.InitConfig initConfig, - WorldLoader.WorldDataSupplier loadContextSupplier, - WorldLoader.ResultFactory applierFactory, - Executor prepareExecutor, Executor applyExecutor, - CallbackInfoReturnable> cir, - @Local(ordinal = 2) RegistryAccess.Frozen frozen2) { + private static void gtceu$injectLoad(WorldLoader.InitConfig initConfig, + WorldLoader.WorldDataSupplier loadContextSupplier, + WorldLoader.ResultFactory applierFactory, + Executor prepareExecutor, Executor applyExecutor, + CallbackInfoReturnable> cir, + @Local(ordinal = 2) RegistryAccess.Frozen frozen2) { GTCEu.updateFrozenRegistry(frozen2); } } From b57dd7117fc51f5383cb77d0aee436d995ae7f38 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Sat, 28 Dec 2024 22:42:01 +0200 Subject: [PATCH 21/24] was working in runClient but not in production --- .../com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java index 114e3f90f3..7a8a064b8a 100644 --- a/src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java @@ -14,7 +14,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; -@Mixin(value = WorldLoader.class, remap = false) +@Mixin(value = WorldLoader.class) public class WorldLoaderMixin { @Inject(method = "load", From 2bac81d313f5d32da52c67fef230b36dfcc4e9f7 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Mon, 30 Dec 2024 11:01:09 +0200 Subject: [PATCH 22/24] capitalized properly mod names. replace xei loaded checks in jei loaded check with just the isModLoaded check. moved frozen registry shenanigans to GTRegistries and an event listener to replace the mixin (seems to be working fine). --- .../java/com/gregtechceu/gtceu/GTCEu.java | 34 +++-------------- .../gtceu/api/gui/misc/IGhostFluidTarget.java | 6 +-- .../gtceu/api/gui/misc/IGhostItemTarget.java | 4 +- .../api/gui/widget/PatternPreviewWidget.java | 4 +- .../api/gui/widget/PhantomFluidWidget.java | 10 ++--- .../api/gui/widget/PhantomSlotWidget.java | 8 ++-- .../gtceu/api/gui/widget/SlotWidget.java | 36 +++++++++--------- .../gtceu/api/gui/widget/TankWidget.java | 38 +++++++++---------- .../recipe/content/IContentSerializer.java | 5 ++- .../gtceu/api/recipe/ui/GTRecipeTypeUI.java | 8 ++-- .../gtceu/api/registry/GTRegistries.java | 23 ++++++++++- .../packets/SPacketSyncBedrockOreVeins.java | 5 ++- .../packets/SPacketSyncFluidVeins.java | 5 ++- .../network/packets/SPacketSyncOreVeins.java | 5 ++- .../gtceu/core/mixins/WorldLoaderMixin.java | 31 --------------- .../gtceu/forge/ForgeCommonEventListener.java | 5 +++ .../gtceu/integration/jei/GTJEIPlugin.java | 8 ++-- .../xei/widgets/GTRecipeWidget.java | 2 +- src/main/resources/gtceu.mixins.json | 1 - 19 files changed, 106 insertions(+), 132 deletions(-) delete mode 100644 src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java diff --git a/src/main/java/com/gregtechceu/gtceu/GTCEu.java b/src/main/java/com/gregtechceu/gtceu/GTCEu.java index e843756b2e..09fd3c85c3 100644 --- a/src/main/java/com/gregtechceu/gtceu/GTCEu.java +++ b/src/main/java/com/gregtechceu/gtceu/GTCEu.java @@ -7,8 +7,6 @@ import com.gregtechceu.gtceu.utils.FormattingUtil; import net.minecraft.client.Minecraft; -import net.minecraft.core.RegistryAccess; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraftforge.fml.DistExecutor; @@ -21,7 +19,6 @@ import dev.emi.emi.config.EmiConfig; import me.shedaniel.rei.api.client.REIRuntime; -import org.jetbrains.annotations.ApiStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,9 +31,6 @@ public class GTCEu { public static final String NAME = "GregTechCEu"; public static final Logger LOGGER = LoggerFactory.getLogger(NAME); - private static final RegistryAccess BLANK = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY); - private static RegistryAccess FROZEN = BLANK; - public GTCEu() { GTCEu.init(); GTCEuAPI.instance = this; @@ -67,25 +61,6 @@ public static ResourceLocation appendId(String id) { return new ResourceLocation(strings[0], strings[1]); } - /** - * You shouldn't call it, you should probably not even look at it just to be extra safe - * - * @param registryAccess the new value to set to the frozen registry access - */ - @ApiStatus.Internal - public static void updateFrozenRegistry(RegistryAccess registryAccess) { - FROZEN = registryAccess; - } - - public static RegistryAccess getFrozenRegistry() { - if (FROZEN == BLANK && isClientThread()) { - if (Minecraft.getInstance().getConnection() != null) { - return Minecraft.getInstance().getConnection().registryAccess(); - } - } - return FROZEN; - } - /** * @return if we're running in a production environment */ @@ -164,15 +139,16 @@ public static Path getGameDir() { public static class Mods { - public static boolean isJeiLoaded() { - return !(isEmiLoaded() || isReiLoaded()) && isModLoaded(GTValues.MODID_JEI); + public static boolean isJEILoaded() { + return !(isModLoaded(GTValues.MODID_EMI) || isModLoaded(GTValues.MODID_REI)) && + isModLoaded(GTValues.MODID_JEI); } - public static boolean isReiLoaded() { + public static boolean isREILoaded() { return isModLoaded(GTValues.MODID_REI) && !(isClientSide() || REIRuntime.getInstance().isOverlayVisible()); } - public static boolean isEmiLoaded() { + public static boolean isEMILoaded() { return isModLoaded(GTValues.MODID_EMI) && !(isClientSide() || EmiConfig.enabled); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java index 634f0a6815..3324b34e81 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostFluidTarget.java @@ -62,17 +62,17 @@ public void accept(@NotNull Object ingredient) { } default Object convertIngredient(Object ingredient) { - if (GTCEu.Mods.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { + if (GTCEu.Mods.isREILoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), (int) fluidStack.getAmount(), fluidStack.getTag()); } - if (GTCEu.Mods.isEmiLoaded() && ingredient instanceof EmiStack fluidEmiStack) { + if (GTCEu.Mods.isEMILoaded() && ingredient instanceof EmiStack fluidEmiStack) { Fluid fluid = fluidEmiStack.getKeyOfType(Fluid.class); ingredient = fluid == null ? FluidStack.EMPTY : new FluidStack(fluid, (int) fluidEmiStack.getAmount(), fluidEmiStack.getNbt()); } - if (GTCEu.Mods.isJeiLoaded() && ingredient instanceof net.minecraftforge.fluids.FluidStack fluidStack) { + if (GTCEu.Mods.isJEILoaded() && ingredient instanceof net.minecraftforge.fluids.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), fluidStack.getAmount(), fluidStack.getTag()); } return ingredient; diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java index 13c67de926..e26f1e3052 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/IGhostItemTarget.java @@ -53,7 +53,7 @@ public void accept(@NotNull Object ingredient) { } default Object convertIngredient(Object ingredient) { - if (GTCEu.Mods.isEmiLoaded() && ingredient instanceof EmiStack itemEmiStack) { + if (GTCEu.Mods.isEMILoaded() && ingredient instanceof EmiStack itemEmiStack) { Item item = itemEmiStack.getKeyOfType(Item.class); ItemStack itemStack = item == null ? ItemStack.EMPTY : new ItemStack(item, (int) itemEmiStack.getAmount()); if (!itemStack.isEmpty()) { @@ -62,7 +62,7 @@ default Object convertIngredient(Object ingredient) { ingredient = itemStack; } - if (GTCEu.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient itemJeiStack) { + if (GTCEu.Mods.isJEILoaded() && ingredient instanceof ITypedIngredient itemJeiStack) { return itemJeiStack.getItemStack().orElse(ItemStack.EMPTY); } return ingredient; diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java index 9f5e6d6172..54d1667b98 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java @@ -254,10 +254,10 @@ public static BlockPos locateNextRegion(int range) { public void updateScreen() { super.updateScreen(); // I can only think of this way - if (!isLoaded && GTCEu.Mods.isEmiLoaded() && Minecraft.getInstance().screen instanceof RecipeScreen) { + if (!isLoaded && GTCEu.Mods.isEMILoaded() && Minecraft.getInstance().screen instanceof RecipeScreen) { setPage(0); isLoaded = true; - } else if (!isLoaded && GTCEu.Mods.isReiLoaded() && + } else if (!isLoaded && GTCEu.Mods.isREILoaded() && Minecraft.getInstance().screen instanceof AbstractDisplayViewingScreen) { setPage(0); isLoaded = true; diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java index 861efb129c..d20076126d 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomFluidWidget.java @@ -101,9 +101,9 @@ public static FluidStack drainFrom(Object ingredient) { @Override @OnlyIn(Dist.CLIENT) public List getPhantomTargets(Object ingredient) { - if (GTCEu.Mods.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { + if (GTCEu.Mods.isREILoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), (int) fluidStack.getAmount(), fluidStack.getTag()); - } else if (GTCEu.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + } else if (GTCEu.Mods.isEMILoaded() && ingredient instanceof EmiStack emiStack) { var key = emiStack.getKey(); if (key instanceof Fluid f) { int amount = emiStack.getAmount() == 0 ? 1000 : (int) emiStack.getAmount(); @@ -114,7 +114,7 @@ public List getPhantomTargets(Object ingredient) { } else { ingredient = null; } - } else if (GTCEu.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { + } else if (GTCEu.Mods.isJEILoaded() && ingredient instanceof ITypedIngredient jeiStack) { ingredient = jeiStack.getIngredient(); } @@ -133,11 +133,11 @@ public Rect2i getArea() { @Override public void accept(@Nonnull Object ingredient) { - if (GTCEu.Mods.isReiLoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { + if (GTCEu.Mods.isREILoaded() && ingredient instanceof dev.architectury.fluid.FluidStack fluidStack) { ingredient = new FluidStack(fluidStack.getFluid(), (int) fluidStack.getAmount(), fluidStack.getTag()); - } else if (GTCEu.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + } else if (GTCEu.Mods.isEMILoaded() && ingredient instanceof EmiStack emiStack) { var key = emiStack.getKey(); if (key instanceof Fluid f) { int amount = emiStack.getAmount() == 0 ? 1000 : (int) emiStack.getAmount(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java index ba0c01664d..3864a6e6e0 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PhantomSlotWidget.java @@ -126,13 +126,13 @@ public boolean canPutStack(ItemStack stack) { @Override @OnlyIn(Dist.CLIENT) public List getPhantomTargets(Object ingredient) { - if (GTCEu.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + if (GTCEu.Mods.isEMILoaded() && ingredient instanceof EmiStack emiStack) { Item item = emiStack.getKeyOfType(Item.class); if (item != null) { ingredient = new ItemStack(item, (int) emiStack.getAmount()); ((ItemStack) ingredient).setTag(emiStack.getNbt()); } - } else if (GTCEu.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { + } else if (GTCEu.Mods.isJEILoaded() && ingredient instanceof ITypedIngredient jeiStack) { ingredient = jeiStack.getItemStack().orElse(null); } if (!(ingredient instanceof ItemStack)) { @@ -150,13 +150,13 @@ public Rect2i getArea() { @Override public void accept(@Nonnull Object ingredient) { - if (GTCEu.Mods.isEmiLoaded() && ingredient instanceof EmiStack emiStack) { + if (GTCEu.Mods.isEMILoaded() && ingredient instanceof EmiStack emiStack) { Item item = emiStack.getKeyOfType(Item.class); if (item != null) { ingredient = new ItemStack(item, (int) emiStack.getAmount()); ((ItemStack) ingredient).setTag(emiStack.getNbt()); } - } else if (GTCEu.Mods.isJeiLoaded() && ingredient instanceof ITypedIngredient jeiStack) { + } else if (GTCEu.Mods.isJEILoaded() && ingredient instanceof ITypedIngredient jeiStack) { ingredient = jeiStack.getItemStack().orElse(null); } if (slotReference != null && ingredient instanceof ItemStack stack) { diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java index c5251128b8..6ef83ff9c4 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java @@ -204,11 +204,11 @@ public Object getXEIIngredientOverMouse(double mouseX, double mouseY) { } } - if (GTCEu.Mods.isJeiLoaded() && !realStack.isEmpty()) { + if (GTCEu.Mods.isJEILoaded() && !realStack.isEmpty()) { return JEICallWrapper.getJEIStackClickable(realStack, getPosition(), getSize()); - } else if (GTCEu.Mods.isReiLoaded()) { + } else if (GTCEu.Mods.isREILoaded()) { return EntryStacks.of(realStack); - } else if (GTCEu.Mods.isEmiLoaded()) { + } else if (GTCEu.Mods.isEMILoaded()) { return EmiStack.of(realStack).setChance(getXEIChance()); } return realStack; @@ -230,11 +230,11 @@ public List getXEIIngredients() { } } - if (GTCEu.Mods.isJeiLoaded() && !realStack.isEmpty()) { + if (GTCEu.Mods.isJEILoaded() && !realStack.isEmpty()) { return List.of(JEICallWrapper.getJEIStackClickable(realStack, getPosition(), getSize())); - } else if (GTCEu.Mods.isReiLoaded()) { + } else if (GTCEu.Mods.isREILoaded()) { return List.of(EntryStacks.of(realStack)); - } else if (GTCEu.Mods.isEmiLoaded()) { + } else if (GTCEu.Mods.isEMILoaded()) { return List.of(EmiStack.of(realStack).setChance(getXEIChance())); } return List.of(realStack); @@ -242,11 +242,11 @@ public List getXEIIngredients() { private List getXEIIngredients(CycleItemStackHandler handler, int index) { var stackList = handler.getStackList(index); - if (GTCEu.Mods.isJeiLoaded()) { + if (GTCEu.Mods.isJEILoaded()) { return JEICallWrapper.getJEIIngredients(stackList, this::getRealStack); - } else if (GTCEu.Mods.isReiLoaded()) { + } else if (GTCEu.Mods.isREILoaded()) { return REICallWrapper.getREIIngredients(stackList, this::getRealStack); - } else if (GTCEu.Mods.isEmiLoaded()) { + } else if (GTCEu.Mods.isEMILoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); @@ -254,11 +254,11 @@ private List getXEIIngredients(CycleItemStackHandler handler, int index) private List getXEIIngredientsClickable(CycleItemStackHandler handler, int index) { var stackList = handler.getStackList(index); - if (GTCEu.Mods.isJeiLoaded()) { + if (GTCEu.Mods.isJEILoaded()) { return JEICallWrapper.getJEIIngredientsClickable(stackList, getPosition(), getSize(), this::getRealStack); - } else if (GTCEu.Mods.isReiLoaded()) { + } else if (GTCEu.Mods.isREILoaded()) { return REICallWrapper.getREIIngredients(stackList, this::getRealStack); - } else if (GTCEu.Mods.isEmiLoaded()) { + } else if (GTCEu.Mods.isEMILoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); @@ -266,11 +266,11 @@ private List getXEIIngredientsClickable(CycleItemStackHandler handler, i private List getXEIIngredients(CycleItemEntryHandler handler, int index) { ItemEntryList entryList = handler.getEntry(index); - if (GTCEu.Mods.isJeiLoaded()) { + if (GTCEu.Mods.isJEILoaded()) { return JEICallWrapper.getJEIIngredients(entryList, this::getRealStack); - } else if (GTCEu.Mods.isReiLoaded()) { + } else if (GTCEu.Mods.isREILoaded()) { return REICallWrapper.getREIIngredients(entryList, this::getRealStack); - } else if (GTCEu.Mods.isEmiLoaded()) { + } else if (GTCEu.Mods.isEMILoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); @@ -278,11 +278,11 @@ private List getXEIIngredients(CycleItemEntryHandler handler, int index) private List getXEIIngredientsClickable(CycleItemEntryHandler handler, int index) { ItemEntryList entryList = handler.getEntry(index); - if (GTCEu.Mods.isJeiLoaded()) { + if (GTCEu.Mods.isJEILoaded()) { return JEICallWrapper.getJEIIngredientsClickable(entryList, getPosition(), getSize(), this::getRealStack); - } else if (GTCEu.Mods.isReiLoaded()) { + } else if (GTCEu.Mods.isREILoaded()) { return REICallWrapper.getREIIngredients(entryList, this::getRealStack); - } else if (GTCEu.Mods.isEmiLoaded()) { + } else if (GTCEu.Mods.isEMILoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java index df0b4e63e1..660aa1cfc1 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java @@ -202,11 +202,11 @@ public Object getXEIIngredientOverMouse(double mouseX, double mouseY) { return getXEIIngredientsClickable(entryHandler, tank).get(0); } - if (GTCEu.Mods.isJeiLoaded()) { + if (GTCEu.Mods.isJEILoaded()) { return JEICallWrapper.getJEIFluidClickable(lastFluidInTank, getPosition(), getSize()); - } else if (GTCEu.Mods.isReiLoaded()) { + } else if (GTCEu.Mods.isREILoaded()) { return EntryStacks.of(REICallWrapper.toREIStack(lastFluidInTank)); - } else if (GTCEu.Mods.isEmiLoaded()) { + } else if (GTCEu.Mods.isEMILoaded()) { return ForgeEmiStack.of(lastFluidInTank).setChance(XEIChance); } } @@ -223,11 +223,11 @@ public List getXEIIngredients() { return getXEIIngredientsClickable(entryHandler, tank); } - if (GTCEu.Mods.isJeiLoaded()) { + if (GTCEu.Mods.isJEILoaded()) { return List.of(JEICallWrapper.getJEIFluidClickable(lastFluidInTank, getPosition(), getSize())); - } else if (GTCEu.Mods.isReiLoaded()) { + } else if (GTCEu.Mods.isREILoaded()) { return List.of(EntryStacks.of(REICallWrapper.toREIStack(lastFluidInTank))); - } else if (GTCEu.Mods.isEmiLoaded()) { + } else if (GTCEu.Mods.isEMILoaded()) { return List.of(ForgeEmiStack.of(lastFluidInTank).setChance(XEIChance)); } return List.of(lastFluidInTank); @@ -235,11 +235,11 @@ public List getXEIIngredients() { private List getXEIIngredients(CycleFluidStackHandler handler, int index) { FluidStackList stackList = handler.getStackList(index); - if (GTCEu.Mods.isJeiLoaded()) { + if (GTCEu.Mods.isJEILoaded()) { return JEICallWrapper.getJEIIngredients(stackList); - } else if (GTCEu.Mods.isReiLoaded()) { + } else if (GTCEu.Mods.isREILoaded()) { return REICallWrapper.getREIIngredients(stackList); - } else if (GTCEu.Mods.isEmiLoaded()) { + } else if (GTCEu.Mods.isEMILoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance()); } return Collections.emptyList(); @@ -247,11 +247,11 @@ private List getXEIIngredients(CycleFluidStackHandler handler, int index private List getXEIIngredientsClickable(CycleFluidStackHandler handler, int index) { FluidStackList stackList = handler.getStackList(index); - if (GTCEu.Mods.isJeiLoaded()) { + if (GTCEu.Mods.isJEILoaded()) { return JEICallWrapper.getJEIIngredientsClickable(stackList, getPosition(), getSize()); - } else if (GTCEu.Mods.isReiLoaded()) { + } else if (GTCEu.Mods.isREILoaded()) { return REICallWrapper.getREIIngredients(stackList); - } else if (GTCEu.Mods.isEmiLoaded()) { + } else if (GTCEu.Mods.isEMILoaded()) { return EMICallWrapper.getEMIIngredients(stackList, getXEIChance()); } return Collections.emptyList(); @@ -259,11 +259,11 @@ private List getXEIIngredientsClickable(CycleFluidStackHandler handler, private List getXEIIngredients(CycleFluidEntryHandler handler, int index) { FluidEntryList entryList = handler.getEntry(index); - if (GTCEu.Mods.isJeiLoaded()) { + if (GTCEu.Mods.isJEILoaded()) { return JEICallWrapper.getJEIIngredients(entryList); - } else if (GTCEu.Mods.isReiLoaded()) { + } else if (GTCEu.Mods.isREILoaded()) { return REICallWrapper.getREIIngredients(entryList); - } else if (GTCEu.Mods.isEmiLoaded()) { + } else if (GTCEu.Mods.isEMILoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance()); } return Collections.emptyList(); @@ -271,11 +271,11 @@ private List getXEIIngredients(CycleFluidEntryHandler handler, int index private List getXEIIngredientsClickable(CycleFluidEntryHandler handler, int index) { FluidEntryList entryList = handler.getEntry(index); - if (GTCEu.Mods.isJeiLoaded()) { + if (GTCEu.Mods.isJEILoaded()) { return JEICallWrapper.getJEIIngredientsClickable(entryList, getPosition(), getSize()); - } else if (GTCEu.Mods.isReiLoaded()) { + } else if (GTCEu.Mods.isREILoaded()) { return REICallWrapper.getREIIngredients(entryList); - } else if (GTCEu.Mods.isEmiLoaded()) { + } else if (GTCEu.Mods.isEMILoaded()) { return EMICallWrapper.getEMIIngredients(entryList, getXEIChance()); } return Collections.emptyList(); @@ -318,7 +318,7 @@ public List getFullTooltipTexts() { @Override public void setCurrentJEIRenderedIngredient(Object ingredient) { - if (GTCEu.Mods.isJeiLoaded()) { + if (GTCEu.Mods.isJEILoaded()) { currentJEIRenderedIngredient = ingredient instanceof FluidStack f ? f : null; } else { currentJEIRenderedIngredient = null; diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java index 7b7f2bc761..fbae53fd2f 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java @@ -2,6 +2,7 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.recipe.chance.logic.ChanceLogic; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.lowdragmc.lowdraglib.LDLib; @@ -19,12 +20,12 @@ public interface IContentSerializer { default void toNetwork(FriendlyByteBuf buf, T content) { - RegistryOps ops = RegistryOps.create(JsonOps.INSTANCE, GTCEu.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(JsonOps.INSTANCE, GTRegistries.builtinRegistry()); buf.writeUtf(codec().encodeStart(ops, content).getOrThrow(false, GTCEu.LOGGER::error).toString()); } default T fromNetwork(FriendlyByteBuf buf) { - RegistryOps ops = RegistryOps.create(JsonOps.INSTANCE, GTCEu.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(JsonOps.INSTANCE, GTRegistries.builtinRegistry()); return codec().parse(ops, LDLib.GSON.fromJson(buf.readUtf(), JsonElement.class)).getOrThrow(false, GTCEu.LOGGER::error); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java index 08abac76f4..bfb3d06797 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/ui/GTRecipeTypeUI.java @@ -238,25 +238,25 @@ public IEditableUI createEditableUITemplate(final boo progress.add(dualProgressWidget); }); // add recipe button - if (!isJEI && (GTCEu.Mods.isReiLoaded() || GTCEu.Mods.isJeiLoaded() || GTCEu.Mods.isEmiLoaded())) { + if (!isJEI && (GTCEu.Mods.isREILoaded() || GTCEu.Mods.isJEILoaded() || GTCEu.Mods.isEMILoaded())) { for (Widget widget : progress) { template.addWidget(new ButtonWidget(widget.getPosition().x, widget.getPosition().y, widget.getSize().width, widget.getSize().height, IGuiTexture.EMPTY, cd -> { if (cd.isRemote) { - if (GTCEu.Mods.isReiLoaded()) { + if (GTCEu.Mods.isREILoaded()) { ViewSearchBuilder.builder().addCategories( recipeType.getCategories().stream() .filter(GTRecipeCategory::isXEIVisible) .map(GTRecipeREICategory::machineCategory) .collect(Collectors.toList())) .open(); - } else if (GTCEu.Mods.isJeiLoaded()) { + } else if (GTCEu.Mods.isJEILoaded()) { JEIPlugin.jeiRuntime.getRecipesGui().showTypes( recipeType.getCategories().stream() .filter(GTRecipeCategory::isXEIVisible) .map(GTRecipeJEICategory::machineType) .collect(Collectors.toList())); - } else if (GTCEu.Mods.isEmiLoaded()) { + } else if (GTCEu.Mods.isEMILoaded()) { EmiApi.displayRecipeCategory( GTRecipeEMICategory.machineCategory(recipeType.getCategory())); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java b/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java index 9f2921cc1c..d99561ecd5 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java +++ b/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java @@ -15,8 +15,10 @@ import com.gregtechceu.gtceu.api.recipe.condition.RecipeConditionType; import com.gregtechceu.gtceu.api.sound.SoundEntry; +import net.minecraft.client.Minecraft; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; @@ -32,6 +34,7 @@ import net.minecraftforge.registries.ForgeRegistries; import com.mojang.serialization.Codec; +import org.jetbrains.annotations.ApiStatus; /** * @author KilaBash @@ -64,6 +67,9 @@ public final class GTRegistries { public static final GTRegistry.RL DIMENSION_MARKERS = new GTRegistry.RL<>( GTCEu.id("dimension_marker")); + private static final RegistryAccess BLANK = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY); + private static RegistryAccess FROZEN = BLANK; + public static final DeferredRegister> TRUNK_PLACER_TYPE = DeferredRegister .create(Registries.TRUNK_PLACER_TYPE, GTCEu.MOD_ID); public static final DeferredRegister> PLACEMENT_MODIFIER = DeferredRegister @@ -99,7 +105,22 @@ public static void init(IEventBus eventBus) { GLOBAL_LOOT_MODIFIES.register(eventBus); } + /** + * You shouldn't call it, you should probably not even look at it just to be extra safe + * + * @param registryAccess the new value to set to the frozen registry access + */ + @ApiStatus.Internal + public static void updateFrozenRegistry(RegistryAccess registryAccess) { + FROZEN = registryAccess; + } + public static RegistryAccess builtinRegistry() { - return GTCEu.getFrozenRegistry(); + if (FROZEN == BLANK && GTCEu.isClientThread()) { + if (Minecraft.getInstance().getConnection() != null) { + return Minecraft.getInstance().getConnection().registryAccess(); + } + } + return FROZEN; } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncBedrockOreVeins.java b/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncBedrockOreVeins.java index 3a5a6623ef..d74d959617 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncBedrockOreVeins.java +++ b/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncBedrockOreVeins.java @@ -2,6 +2,7 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreDefinition; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.client.ClientProxy; import com.lowdragmc.lowdraglib.networking.IHandlerContext; @@ -31,7 +32,7 @@ public SPacketSyncBedrockOreVeins() { @Override public void encode(FriendlyByteBuf buf) { - RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTCEu.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTRegistries.builtinRegistry()); int size = veins.size(); buf.writeVarInt(size); for (var entry : veins.entrySet()) { @@ -44,7 +45,7 @@ public void encode(FriendlyByteBuf buf) { @Override public void decode(FriendlyByteBuf buf) { - RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTCEu.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTRegistries.builtinRegistry()); Stream.generate(() -> { ResourceLocation id = buf.readResourceLocation(); CompoundTag tag = buf.readAnySizeNbt(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncFluidVeins.java b/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncFluidVeins.java index 953b37a178..450006be88 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncFluidVeins.java +++ b/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncFluidVeins.java @@ -2,6 +2,7 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.client.ClientProxy; import com.lowdragmc.lowdraglib.networking.IHandlerContext; @@ -31,7 +32,7 @@ public SPacketSyncFluidVeins() { @Override public void encode(FriendlyByteBuf buf) { - RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTCEu.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTRegistries.builtinRegistry()); int size = veins.size(); buf.writeVarInt(size); for (var entry : veins.entrySet()) { @@ -44,7 +45,7 @@ public void encode(FriendlyByteBuf buf) { @Override public void decode(FriendlyByteBuf buf) { - RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTCEu.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTRegistries.builtinRegistry()); Stream.generate(() -> { ResourceLocation id = buf.readResourceLocation(); CompoundTag tag = buf.readAnySizeNbt(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncOreVeins.java b/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncOreVeins.java index 80dac75920..522df81bab 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncOreVeins.java +++ b/src/main/java/com/gregtechceu/gtceu/common/network/packets/SPacketSyncOreVeins.java @@ -2,6 +2,7 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.client.ClientProxy; import com.gregtechceu.gtceu.integration.map.cache.client.GTClientCache; @@ -32,7 +33,7 @@ public SPacketSyncOreVeins() { @Override public void encode(FriendlyByteBuf buf) { - RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTCEu.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTRegistries.builtinRegistry()); int size = veins.size(); buf.writeVarInt(size); for (var entry : veins.entrySet()) { @@ -45,7 +46,7 @@ public void encode(FriendlyByteBuf buf) { @Override public void decode(FriendlyByteBuf buf) { - RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTCEu.getFrozenRegistry()); + RegistryOps ops = RegistryOps.create(NbtOps.INSTANCE, GTRegistries.builtinRegistry()); Stream.generate(() -> { ResourceLocation id = buf.readResourceLocation(); CompoundTag tag = buf.readAnySizeNbt(); diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java deleted file mode 100644 index 7a8a064b8a..0000000000 --- a/src/main/java/com/gregtechceu/gtceu/core/mixins/WorldLoaderMixin.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.gregtechceu.gtceu.core.mixins; - -import com.gregtechceu.gtceu.GTCEu; - -import net.minecraft.core.RegistryAccess; -import net.minecraft.server.WorldLoader; - -import com.llamalad7.mixinextras.sugar.Local; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; - -@Mixin(value = WorldLoader.class) -public class WorldLoaderMixin { - - @Inject(method = "load", - at = @At(value = "INVOKE", - target = "Lnet/minecraft/server/ReloadableServerResources;loadResources(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/core/RegistryAccess$Frozen;Lnet/minecraft/world/flag/FeatureFlagSet;Lnet/minecraft/commands/Commands$CommandSelection;ILjava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;")) - private static void gtceu$injectLoad(WorldLoader.InitConfig initConfig, - WorldLoader.WorldDataSupplier loadContextSupplier, - WorldLoader.ResultFactory applierFactory, - Executor prepareExecutor, Executor applyExecutor, - CallbackInfoReturnable> cir, - @Local(ordinal = 2) RegistryAccess.Frozen frozen2) { - GTCEu.updateFrozenRegistry(frozen2); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java b/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java index 9fa56ceb83..36c11814f4 100644 --- a/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java +++ b/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java @@ -605,4 +605,9 @@ public static void remapIds(MissingMappingsEvent event) { }); } } + + @SubscribeEvent + public static void onAddReloadableServerResources(AddReloadListenerEvent event) { + GTRegistries.updateFrozenRegistry(event.getRegistryAccess()); + } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java index 91087af80a..cd74ea5f99 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java @@ -56,7 +56,7 @@ public ResourceLocation getPluginUid() { @Override public void registerCategories(@NotNull IRecipeCategoryRegistration registry) { - if (GTCEu.Mods.isReiLoaded() || GTCEu.Mods.isEmiLoaded()) return; + if (GTCEu.Mods.isREILoaded() || GTCEu.Mods.isEMILoaded()) return; GTCEu.LOGGER.info("JEI register categories"); IJeiHelpers jeiHelpers = registry.getJeiHelpers(); registry.addRecipeCategories(new MultiblockInfoCategory(jeiHelpers)); @@ -76,7 +76,7 @@ public void registerCategories(@NotNull IRecipeCategoryRegistration registry) { @Override public void registerRecipeCatalysts(@NotNull IRecipeCatalystRegistration registration) { - if (GTCEu.Mods.isReiLoaded() || GTCEu.Mods.isEmiLoaded()) return; + if (GTCEu.Mods.isREILoaded() || GTCEu.Mods.isEMILoaded()) return; GTRecipeJEICategory.registerRecipeCatalysts(registration); if (!ConfigHolder.INSTANCE.compat.hideOreProcessingDiagrams) GTOreProcessingInfoCategory.registerRecipeCatalysts(registration); @@ -91,7 +91,7 @@ public void registerRecipeCatalysts(@NotNull IRecipeCatalystRegistration registr @Override public void registerRecipes(@NotNull IRecipeRegistration registration) { - if (GTCEu.Mods.isReiLoaded() || GTCEu.Mods.isEmiLoaded()) return; + if (GTCEu.Mods.isREILoaded() || GTCEu.Mods.isEMILoaded()) return; GTCEu.LOGGER.info("JEI register"); MultiblockInfoCategory.registerRecipes(registration); GTRecipeJEICategory.registerRecipes(registration); @@ -107,7 +107,7 @@ public void registerRecipes(@NotNull IRecipeRegistration registration) { @Override public void registerIngredients(@NotNull IModIngredientRegistration registry) { - if (GTCEu.Mods.isReiLoaded() || GTCEu.Mods.isEmiLoaded()) return; + if (GTCEu.Mods.isREILoaded() || GTCEu.Mods.isEMILoaded()) return; GTCEu.LOGGER.info("JEI register ingredients"); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java index 3c0f9f7bc2..10ca5b5c48 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java @@ -233,7 +233,7 @@ private int getVoltageXOffset() { case IV -> 12; default -> 14; }; - if (!GTCEu.Mods.isEmiLoaded()) { + if (!GTCEu.Mods.isEMILoaded()) { x -= 3; } return x; diff --git a/src/main/resources/gtceu.mixins.json b/src/main/resources/gtceu.mixins.json index dd2a3fd651..d9b0fff6ee 100644 --- a/src/main/resources/gtceu.mixins.json +++ b/src/main/resources/gtceu.mixins.json @@ -60,7 +60,6 @@ "TagLoaderMixin", "TagManagerMixin", "TagValueAccessor", - "WorldLoaderMixin", "ae2.GenericStackInvAccessor", "embeddium.BiomeColorCacheMixin", "embeddium.VanillaColorAdapterMixin", From 5d2573503b69145b10b0531c9c7bf1aeada90047 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Mon, 30 Dec 2024 17:48:05 +0200 Subject: [PATCH 23/24] what can I say, I guess I should take my adhd medicine more --- .../gregtechceu/gtceu/forge/ForgeCommonEventListener.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java b/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java index 36c11814f4..5dfc4b7289 100644 --- a/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java +++ b/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java @@ -284,6 +284,7 @@ public static void registerReloadListeners(AddReloadListenerEvent event) { event.addListener(new GTOreLoader()); event.addListener(new BedrockFluidLoader()); event.addListener(new BedrockOreLoader()); + GTRegistries.updateFrozenRegistry(event.getRegistryAccess()); } @SubscribeEvent @@ -605,9 +606,4 @@ public static void remapIds(MissingMappingsEvent event) { }); } } - - @SubscribeEvent - public static void onAddReloadableServerResources(AddReloadListenerEvent event) { - GTRegistries.updateFrozenRegistry(event.getRegistryAccess()); - } } From dc6613860cf814acb3ddbb3670c9ed45418b9153 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Tue, 31 Dec 2024 18:11:09 +0200 Subject: [PATCH 24/24] moved registry access closer to related functions --- .../com/gregtechceu/gtceu/api/registry/GTRegistries.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java b/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java index d99561ecd5..e8abf3052e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java +++ b/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java @@ -66,10 +66,6 @@ public final class GTRegistries { public static final GTRegistry.RL ORE_VEINS = new GTRegistry.RL<>(GTCEu.id("ore_vein")); public static final GTRegistry.RL DIMENSION_MARKERS = new GTRegistry.RL<>( GTCEu.id("dimension_marker")); - - private static final RegistryAccess BLANK = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY); - private static RegistryAccess FROZEN = BLANK; - public static final DeferredRegister> TRUNK_PLACER_TYPE = DeferredRegister .create(Registries.TRUNK_PLACER_TYPE, GTCEu.MOD_ID); public static final DeferredRegister> PLACEMENT_MODIFIER = DeferredRegister @@ -105,6 +101,9 @@ public static void init(IEventBus eventBus) { GLOBAL_LOOT_MODIFIES.register(eventBus); } + private static final RegistryAccess BLANK = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY); + private static RegistryAccess FROZEN = BLANK; + /** * You shouldn't call it, you should probably not even look at it just to be extra safe *