-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #427 from WaitingIdly/rftools-dimensions-data
Fully Unregister RFTools Dimensions
- Loading branch information
Showing
8 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...ain/java/mod/acgaming/universaltweaks/mods/rftoolsdimension/mixin/UTDimensionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...gaming/universaltweaks/mods/rftoolsdimension/mixin/UTRfToolsDimensionManagerAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
} |