mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
fix crash in highlands mod due to it using a deprecated biome hook
This commit is contained in:
parent
18dabf7e8c
commit
176a2e58ee
@ -21,6 +21,7 @@ import com.hbm.util.WeightedRandomGeneric;
|
||||
import com.hbm.world.dungeon.*;
|
||||
import com.hbm.world.feature.*;
|
||||
import com.hbm.world.feature.BedrockOre.BedrockOreDefinition;
|
||||
import com.hbm.world.gen.MapGenChainloader;
|
||||
import com.hbm.world.generator.CellularDungeonFactory;
|
||||
import com.hbm.world.generator.DungeonToolbox;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
@ -40,6 +41,11 @@ public class HbmWorldGen implements IWorldGenerator {
|
||||
|
||||
@Override
|
||||
public void generate(Random rand, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
|
||||
// quick fix for bad generators
|
||||
if(world.provider.dimensionId == 0) {
|
||||
MapGenChainloader.repairBadGeneration(world, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
switch (world.provider.dimensionId) {
|
||||
case -1:
|
||||
generateNether(world, rand, chunkX * 16, chunkZ * 16); break;
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
package com.hbm.world.gen;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.MapGenBase;
|
||||
@ -32,6 +34,9 @@ public class MapGenChainloader extends MapGenBase {
|
||||
// Hack to provide the current generating chunk's block metas to the generation function
|
||||
private static byte[] blockMetas;
|
||||
|
||||
// Double hack to check we actually get the damn metas, if not we will have to do a quick bit of post gen!
|
||||
private static HashMap<ChunkCoordIntPair, byte[]> blockMetaMap = new HashMap<>();
|
||||
|
||||
// Executes our chainloaded parent, and all our child generators
|
||||
@Override
|
||||
public void func_151539_a(IChunkProvider chunk, World world, int chunkX, int chunkZ, Block[] blocks) {
|
||||
@ -62,6 +67,24 @@ public class MapGenChainloader extends MapGenBase {
|
||||
netherGenerators.add(generator);
|
||||
}
|
||||
|
||||
public static void repairBadGeneration(World world, int chunkX, int chunkZ) {
|
||||
ChunkCoordIntPair coords = new ChunkCoordIntPair(chunkX, chunkZ);
|
||||
if(MapGenChainloader.blockMetaMap.containsKey(coords)) {
|
||||
byte[] metas = MapGenChainloader.blockMetaMap.get(coords);
|
||||
for(int i = 0; i < metas.length; i++) {
|
||||
if(metas[i] == 0) continue;
|
||||
int y = i % 256;
|
||||
int xz = (i - y) / 256;
|
||||
int z = xz % 16;
|
||||
int x = (xz - z) / 16;
|
||||
|
||||
world.setBlockMetadataWithNotify(chunkX * 16 + x, y, chunkZ * 16 + z, metas[i], 3);
|
||||
}
|
||||
|
||||
MapGenChainloader.blockMetaMap.remove(coords);
|
||||
}
|
||||
}
|
||||
|
||||
public static class MapGenEventHandler {
|
||||
|
||||
// Register as late as possible to pick up any modded cave generators
|
||||
@ -84,7 +107,14 @@ public class MapGenChainloader extends MapGenBase {
|
||||
|
||||
@SubscribeEvent
|
||||
public void storeLatestBlockMeta(ReplaceBiomeBlocks event) {
|
||||
blockMetas = event.metaArray;
|
||||
if(event.metaArray.length == 256) {
|
||||
// a mod is using a deprecated forge hook! fuck!
|
||||
// we will store our own meta array and apply metas _after_ chunk gen has finished
|
||||
blockMetas = new byte[65536];
|
||||
blockMetaMap.put(new ChunkCoordIntPair(event.chunkX, event.chunkZ), blockMetas);
|
||||
} else {
|
||||
blockMetas = event.metaArray;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ public class MapGenBubble extends MapGenBase {
|
||||
double radiusSqr = (radius * radius) / 2; // original OilBubble implementation divided the square by 2 for some reason
|
||||
|
||||
int yMin = Math.max(1, MathHelper.floor_double(yCoord - radius));
|
||||
int yMax = MathHelper.ceiling_double_int(yCoord + radius);
|
||||
int yMax = Math.min(127, MathHelper.ceiling_double_int(yCoord + radius));
|
||||
|
||||
for(int bx = 15; bx >= 0; bx--) // bx, bz is the coordinate of the block we're modifying, relative to the generating chunk origin
|
||||
for(int bz = 15; bz >= 0; bz--)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user