Skip to content

Commit

Permalink
enable generation in non-vanilla dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Pilzinsel64 committed Jan 4, 2025
1 parent f7efddc commit 346d5cb
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/de/pilz/plantmegapackfix/PMPFix.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
version = Tags.VERSION,
name = "PlantMegaPack Fixes",
acceptedMinecraftVersions = "[1.7.10]",
dependencies = "required-after:plantmegapack")
dependencies = "required-after:plantmegapack",
acceptableRemoteVersions = "*")
public class PMPFix {

public static final String MODID = "plantmegapackfix";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public List<String> getMixins(Set<String> loadedMods) {
// PlantMegaPack
if (loadedMods.contains("plantmegapack")) {
list.add("PMPGenVineMixin");
list.add("PMPWorldGeneratorMixin");
}

return list;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package de.pilz.plantmegapackfix.mixins.late;

import java.util.Random;

import net.minecraft.world.World;
import net.minecraft.world.WorldProviderEnd;
import net.minecraft.world.WorldProviderHell;
import net.minecraft.world.WorldProviderSurface;
import net.minecraft.world.chunk.IChunkProvider;

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 plantmegapack.PlantMegaPack;

@Mixin(plantmegapack.worldgen.PMPWorldGenerator.class)
public abstract class PMPWorldGeneratorMixin {

@Shadow(remap = false)
private void generateNether(World world, Random random, int chunkX, int chunkZ) {}

@Shadow(remap = false)
private void generateSurface(World world, Random random, int chunkX, int chunkZ) {}

@Shadow(remap = false)
private void generateEnd(World world, Random random, int chunkX, int chunkZ) {}

@Inject(method = "generate", at = @At("RETURN"), cancellable = false, remap = false)
private void pmpfix$$checkWorldProviderSuface(Random random, int chunkX, int chunkZ, World world,
IChunkProvider chunkGenerator, IChunkProvider chunkProvider, CallbackInfo callback) {
if (world.provider.dimensionId == 0 || world.provider.dimensionId == -1 || world.provider.dimensionId == 1) {
// Handled by original already
return;
}
if (world.provider instanceof WorldProviderSurface) {
if (PlantMegaPack.settingsGeneral.worldgenOverworldRate > 0) {
generateSurface(world, random, chunkX * 16, chunkZ * 16);
}
} else if (world.provider instanceof WorldProviderHell) {
if (PlantMegaPack.settingsGeneral.worldgenNetherRate > 0) {
generateNether(world, random, chunkX * 16, chunkZ * 16);
}
} else if (world.provider instanceof WorldProviderEnd) {
if (PlantMegaPack.settingsGeneral.worldgenOverworldRate > 0) {
generateEnd(world, random, chunkX * 16, chunkZ * 16);
}
}
}
}

0 comments on commit 346d5cb

Please sign in to comment.