-
-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust structure placement in GoG skyblock
Fixes #4712 using code snippets from Carpet Skyblock Additions that use the original noise generator to emulate the non-skyblock heightmap for placing height-sensitive structures.
- Loading branch information
1 parent
1d4d462
commit beba017
Showing
3 changed files
with
73 additions
and
20 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
45 changes: 45 additions & 0 deletions
45
Xplat/src/main/java/vazkii/botania/mixin/PlacementContextMixin.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,45 @@ | ||
package vazkii.botania.mixin; | ||
|
||
import net.minecraft.world.level.LevelHeightAccessor; | ||
import net.minecraft.world.level.WorldGenLevel; | ||
import net.minecraft.world.level.chunk.ChunkGenerator; | ||
import net.minecraft.world.level.levelgen.Heightmap; | ||
import net.minecraft.world.level.levelgen.WorldGenerationContext; | ||
import net.minecraft.world.level.levelgen.placement.PlacementContext; | ||
|
||
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.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import vazkii.botania.common.world.SkyblockChunkGenerator; | ||
|
||
/** | ||
* Based on code from CarpetSkyAdditions. Ensures terrain-sensitive structures generate where they should. | ||
*/ | ||
@Mixin(PlacementContext.class) | ||
public class PlacementContextMixin extends WorldGenerationContext { | ||
@Shadow | ||
@Final | ||
private ChunkGenerator generator; | ||
|
||
@Shadow | ||
@Final | ||
private WorldGenLevel level; | ||
|
||
public PlacementContextMixin(ChunkGenerator generator, LevelHeightAccessor levelHeightAccessor) { | ||
super(generator, levelHeightAccessor); | ||
} | ||
|
||
/** | ||
* For Garden of Glass, use generation heightmap instead of empty actual heightmap to place features/structures. | ||
*/ | ||
@Inject(method = "getHeight", cancellable = true, at = @At("HEAD")) | ||
private void useGenerationHeightmap(Heightmap.Types heightmap, int x, int z, CallbackInfoReturnable<Integer> cir) { | ||
if (generator instanceof SkyblockChunkGenerator skyblockChunkGenerator) { | ||
cir.setReturnValue(skyblockChunkGenerator.getBaseHeightInEquivalentNoiseWorld(x, z, heightmap, level)); | ||
} | ||
} | ||
} |
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