-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Syncing Properties Between Dim
- Loading branch information
1 parent
aa16cee
commit f6c516d
Showing
7 changed files
with
84 additions
and
3 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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/nomiceu/nomilabs/mixin/DerivedWorldInfoMixin.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,26 @@ | ||
package com.nomiceu.nomilabs.mixin; | ||
|
||
import net.minecraft.world.storage.DerivedWorldInfo; | ||
import net.minecraft.world.storage.WorldInfo; | ||
|
||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
import com.nomiceu.nomilabs.mixinhelper.AccessibleDerivedWorldInfo; | ||
|
||
/** | ||
* Allows Accessing the Delegate of Derived World Infos. | ||
*/ | ||
@Mixin(DerivedWorldInfo.class) | ||
public class DerivedWorldInfoMixin implements AccessibleDerivedWorldInfo { | ||
|
||
@Shadow | ||
@Final | ||
private WorldInfo delegate; | ||
|
||
@Override | ||
public WorldInfo getDelegate() { | ||
return delegate; | ||
} | ||
} |
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,33 @@ | ||
package com.nomiceu.nomilabs.mixin; | ||
|
||
import net.minecraft.profiler.Profiler; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.WorldProvider; | ||
import net.minecraft.world.storage.ISaveHandler; | ||
import net.minecraft.world.storage.WorldInfo; | ||
|
||
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 com.nomiceu.nomilabs.config.LabsConfig; | ||
import com.nomiceu.nomilabs.mixinhelper.AccessibleDerivedWorldInfo; | ||
|
||
/** | ||
* Allows Syncing of Properties Between Dimensions. | ||
*/ | ||
@Mixin(World.class) | ||
public class WorldMixin { | ||
|
||
@Shadow | ||
protected WorldInfo worldInfo; | ||
|
||
@Inject(method = "<init>", at = @At("RETURN")) | ||
private void findProperWorldInfo(ISaveHandler saveHandlerIn, WorldInfo info, WorldProvider providerIn, | ||
Profiler profilerIn, boolean client, CallbackInfo ci) { | ||
if (LabsConfig.advanced.syncDimProperties && info instanceof AccessibleDerivedWorldInfo adri) | ||
worldInfo = adri.getDelegate(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/nomiceu/nomilabs/mixinhelper/AccessibleDerivedWorldInfo.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,8 @@ | ||
package com.nomiceu.nomilabs.mixinhelper; | ||
|
||
import net.minecraft.world.storage.WorldInfo; | ||
|
||
public interface AccessibleDerivedWorldInfo { | ||
|
||
WorldInfo getDelegate(); | ||
} |
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