mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
74 lines
2.1 KiB
Java
74 lines
2.1 KiB
Java
package com.hbm.handler;
|
|
|
|
import java.util.List;
|
|
import java.util.Map.Entry;
|
|
|
|
import com.hbm.saveddata.RadiationSavedData;
|
|
|
|
import net.minecraft.init.Blocks;
|
|
import net.minecraft.world.ChunkCoordIntPair;
|
|
import net.minecraft.world.World;
|
|
import net.minecraft.world.WorldServer;
|
|
import net.minecraft.world.chunk.Chunk;
|
|
import net.minecraft.world.gen.ChunkProviderServer;
|
|
|
|
public class RadiationWorldHandler {
|
|
|
|
public static void handleWorldDestruction(World world) {
|
|
|
|
if(!(world instanceof WorldServer))
|
|
return;
|
|
|
|
WorldServer serv = (WorldServer)world;
|
|
|
|
RadiationSavedData data = RadiationSavedData.getData(serv);
|
|
List<Chunk> loadedChunks = ((ChunkProviderServer) serv.getChunkProvider()).func_152380_a();
|
|
|
|
int count = 50;//MainRegistry.worldRad;
|
|
int threshold = 5;//MainRegistry.worldRadThreshold;
|
|
|
|
Object[] entries = data.contamination.entrySet().toArray();
|
|
|
|
if(entries.length == 0)
|
|
return;
|
|
|
|
Entry<ChunkCoordIntPair, Float> randEnt = (Entry<ChunkCoordIntPair, Float>) entries[world.rand.nextInt(entries.length)];
|
|
|
|
ChunkCoordIntPair coords = randEnt.getKey();
|
|
Chunk chunk = world.getChunkFromChunkCoords(coords.chunkXPos, coords.chunkZPos);
|
|
|
|
for(int i = 0; i < 1; i++) {
|
|
|
|
|
|
if(randEnt == null || randEnt.getValue() < threshold)
|
|
continue;
|
|
|
|
if(chunk != null && loadedChunks.contains(chunk)) {
|
|
|
|
for(int a = 0; a < 16; a ++) {
|
|
for(int b = 0; b < 16; b ++) {
|
|
|
|
if(world.rand.nextInt(3) != 0)
|
|
continue;
|
|
|
|
int x = coords.getCenterXPos() - 8 + a;
|
|
int z = coords.getCenterZPosition() - 8 + b;
|
|
int y = world.getHeightValue(x, z) - world.rand.nextInt(2);
|
|
|
|
if(world.getBlock(x, y, z) == Blocks.grass) {
|
|
world.setBlock(x, y, z, Blocks.dirt);
|
|
} else if(world.getBlock(x, y, z) == Blocks.tallgrass) {
|
|
world.setBlock(x, y, z, Blocks.air);
|
|
} else if(world.getBlock(x, y, z) == Blocks.leaves) {
|
|
world.setBlock(x, y, z, Blocks.air);
|
|
} else if(world.getBlock(x, y, z) == Blocks.leaves2) {
|
|
world.setBlock(x, y, z, Blocks.air);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|