-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
109 additions
and
14 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
31 changes: 31 additions & 0 deletions
31
src/main/java/com/hugman/uhc/mixin/ThreadedAnvilChunkStorageMixin.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,31 @@ | ||
package com.hugman.uhc.mixin; | ||
|
||
import com.hugman.uhc.util.ChunkGeneratorSettingsProvider; | ||
import net.minecraft.server.world.ThreadedAnvilChunkStorage; | ||
import net.minecraft.world.gen.chunk.ChunkGenerator; | ||
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings; | ||
import org.spongepowered.asm.mixin.Final; | ||
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.Redirect; | ||
|
||
/** | ||
* Temporary fix, see <a href="https://github.com/NucleoidMC/fantasy/pull/29">Nucleoid/fantasy #29</a> | ||
*/ | ||
@Mixin(ThreadedAnvilChunkStorage.class) | ||
public class ThreadedAnvilChunkStorageMixin { | ||
@Shadow | ||
@Final | ||
private ChunkGenerator chunkGenerator; | ||
|
||
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/gen/chunk/ChunkGeneratorSettings;createMissingSettings()Lnet/minecraft/world/gen/chunk/ChunkGeneratorSettings;")) | ||
private ChunkGeneratorSettings fantasy$useProvidedChunkGeneratorSettings() { | ||
if (this.chunkGenerator instanceof ChunkGeneratorSettingsProvider provider) { | ||
ChunkGeneratorSettings settings = provider.getSettings(); | ||
if (settings != null) return settings; | ||
} | ||
|
||
return ChunkGeneratorSettings.createMissingSettings(); | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/hugman/uhc/util/ChunkGeneratorSettingsProvider.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,12 @@ | ||
package com.hugman.uhc.util; | ||
|
||
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Allows chunk generators other than noise chunk generators to provide custom chunk generator settings. | ||
*/ | ||
public interface ChunkGeneratorSettingsProvider { | ||
@Nullable | ||
ChunkGeneratorSettings getSettings(); | ||
} |
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,12 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "com.hugman.uhc.mixin", | ||
"compatibilityLevel": "JAVA_17", | ||
"mixins": [ | ||
"ThreadedAnvilChunkStorageMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |