Skip to content

Commit

Permalink
Merge pull request #427 from WaitingIdly/rftools-dimensions-data
Browse files Browse the repository at this point in the history
Fully Unregister RFTools Dimensions
  • Loading branch information
ACGaming authored Apr 8, 2024
2 parents 10a64b2 + 0de5806 commit 0b07ef3
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ All changes are toggleable via config files.
* **Duplication Fixes:** Fixes various duplication exploits
* **Quark**
* **Duplication Fixes:** Fixes various duplication exploits
* **RFTools Dimension**
* **Properly Unregister Dimensions:** Fixes a bug where joining a world or server with any RFTools Dimension registered would disallow entering another world without that dimension until restarting.
* **Roost**
* **Early Register CT Chickens:** Improves load time by registering ContentTweaker chickens early for Roost to detect them
* **Simple Difficulty**
Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ dependencies {
compileOnly rfg.deobf('net.darkhax.gamestages:GameStages-1.12.2:2.0.120')
compileOnly rfg.deobf('net.darkhax.itemstages:ItemStages-1.12.2:2.0.51')
compileOnly rfg.deobf('net.darkhax.mobstages:MobStages-1.12.2:2.0.13')
compileOnly rfg.deobf('curse.maven:mcjtylib-233105:2745846')
compileOnly rfg.deobf('curse.maven:rftools-224641:2861573')
compileOnly rfg.deobf('curse.maven:rftools-dimensions-240950:2707390')
compileOnly 'curse.maven:actuallyaditions-228404:2844115'
compileOnly 'curse.maven:applecore-224472:2969118'
compileOnly 'curse.maven:arcanearchives-311357:3057332'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ public class UTConfigMods
@Config.Name("Quark")
public static final QuarkCategory QUARK = new QuarkCategory();

@Config.LangKey("cfg.universaltweaks.modintegration.rftoolsdimensions")
@Config.Name("RFTools Dimensions")
public static final RFToolsDimensionsCategory RFTOOLS_DIMENSIONS = new RFToolsDimensionsCategory();

@Config.LangKey("cfg.universaltweaks.modintegration.roost")
@Config.Name("Roost")
public static final RoostCategory ROOST = new RoostCategory();
Expand Down Expand Up @@ -571,6 +575,14 @@ public static class RoostCategory
public boolean utRoostEarlyRegisterCTChickens = true;
}

public static class RFToolsDimensionsCategory
{
@Config.RequiresMcRestart
@Config.Name("Fully Unregister Dimensions")
@Config.Comment("Fixes a bug where joining a world or server with any RFTools Dimension registered would disallow entering another world without that dimension until restarting")
public boolean utFullyUnregisterDimensions = true;
}

public static class SimpleDifficultyCategory
{
@Config.RequiresMcRestart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public List<String> getMixinConfigs()
configs.add("mixins.mods.nuclearcraft.json");
configs.add("mixins.mods.quark.dupes.json");
configs.add("mixins.mods.reskillable.json");
configs.add("mixins.mods.rftoolsdimensions.json");
configs.add("mixins.mods.roost.contenttweaker.json");
configs.add("mixins.mods.simpledifficulty.json");
configs.add("mixins.mods.spiceoflife.dupes.json");
Expand Down Expand Up @@ -188,6 +189,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
return Loader.isModLoaded("quark") && UTConfigMods.QUARK.utDuplicationFixesToggle;
case "mixins.mods.reskillable.json":
return Loader.isModLoaded("reskillable");
case "mixins.mods.rftoolsdimensions.json":
return Loader.isModLoaded("rftoolsdim");
case "mixins.mods.roost.contenttweaker.json":
return Loader.isModLoaded("contenttweaker");
case "mixins.mods.simpledifficulty.json":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package mod.acgaming.universaltweaks.mods.rftoolsdimension.mixin;

import mcjty.rftoolsdim.dimensions.RfToolsDimensionManager;
import mcjty.rftoolsdim.dimensions.description.DimensionDescriptor;
import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigMods;
import net.minecraftforge.common.DimensionManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Map;

// Courtesy of WaitingIdly
@Mixin(value = RfToolsDimensionManager.class, remap = false)
public abstract class UTDimensionManager
{
@Shadow
private static RfToolsDimensionManager clientInstance;

@Inject(method = "cleanupDimensionInformation", at = @At("HEAD"))
private static void utClearClientInstance(CallbackInfo ci)
{
if (!UTConfigMods.RFTOOLS_DIMENSIONS.utFullyUnregisterDimensions) return;
if (clientInstance != null)
{
UniversalTweaks.LOGGER.info("UTDimensionManager ::: Cleaning up RFTools dimensions for the clientInstance");

for (int id : clientInstance.getDimensions().keySet())
{
if (DimensionManager.isDimensionRegistered(id))
{
UniversalTweaks.LOGGER.info("UTDimensionManager ::: Unregister dimension: " + id);

try
{
DimensionManager.unregisterDimension(id);
}
catch (Exception e)
{
UniversalTweaks.LOGGER.error("UTDimensionManager ::: Error unregistering dimension: " + id, e);
}
}
else
{
UniversalTweaks.LOGGER.info("UTDimensionManager ::: Already unregistered! Dimension: " + id);
}
}
clientInstance.getDimensions().clear();
((UTRfToolsDimensionManagerAccessor) clientInstance).getDimensionToID().clear();
((UTRfToolsDimensionManagerAccessor) clientInstance).getDimensionInformation().clear();
((UTRfToolsDimensionManagerAccessor) clientInstance).getReclaimedIds().clear();
clientInstance = null;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package mod.acgaming.universaltweaks.mods.rftoolsdimension.mixin;

import mcjty.rftoolsdim.dimensions.DimensionInformation;
import mcjty.rftoolsdim.dimensions.RfToolsDimensionManager;
import mcjty.rftoolsdim.dimensions.description.DimensionDescriptor;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import java.util.Map;
import java.util.Set;

@Mixin(value = RfToolsDimensionManager.class, remap = false)
public interface UTRfToolsDimensionManagerAccessor
{
@Accessor("dimensionToID")
Map<DimensionDescriptor, Integer> getDimensionToID();

@Accessor("dimensionInformation")
Map<Integer, DimensionInformation> getDimensionInformation();

@Accessor("reclaimedIds")
Set<Integer> getReclaimedIds();
}
1 change: 1 addition & 0 deletions src/main/resources/assets/universaltweaks/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ cfg.universaltweaks.modintegration.netherrocks=Netherrocks
cfg.universaltweaks.modintegration.nuclearcraft=NuclearCraft
cfg.universaltweaks.modintegration.projectred=ProjectRed
cfg.universaltweaks.modintegration.quark=Quark
cfg.universaltweaks.modintegration.rftoolsdimensions=RFTools Dimensions
cfg.universaltweaks.modintegration.roost=Roost
cfg.universaltweaks.modintegration.sd=Storage Drawers
cfg.universaltweaks.modintegration.simpledifficulty=Simple Difficulty
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/mixins.mods.rftoolsdimensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.mods.rftoolsdimension.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTDimensionManager", "UTRfToolsDimensionManagerAccessor"]
}

0 comments on commit 0b07ef3

Please sign in to comment.