From d1275161af15d34bdef127232635017eb9ea9673 Mon Sep 17 00:00:00 2001 From: SirSengir Date: Tue, 21 Aug 2012 15:49:18 +0200 Subject: [PATCH] Hooked up oil world generation again. --- common/buildcraft/BuildCraftEnergy.java | 8 -------- .../core/render/BlockRenderingHandler.java | 1 - common/buildcraft/energy/OilPopulate.java | 16 +++++++++++++++- common/buildcraft/mod_BuildCraftEnergy.java | 11 +++-------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index e3758e21..a0ef9040 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -8,7 +8,6 @@ package buildcraft; -import java.util.Random; import java.util.TreeMap; import cpw.mods.fml.common.network.NetworkRegistry; @@ -33,7 +32,6 @@ import buildcraft.energy.GuiHandler; import buildcraft.energy.ItemBucketOil; import buildcraft.energy.ItemEngine; import buildcraft.energy.OilBucketHandler; -import buildcraft.energy.OilPopulate; import buildcraft.energy.TriggerEngineHeat; import buildcraft.energy.Engine.EnergyStage; @@ -41,7 +39,6 @@ import net.minecraft.src.Block; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; import net.minecraft.src.Material; -import net.minecraft.src.World; import net.minecraftforge.common.Configuration; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.Property; @@ -171,11 +168,6 @@ public class BuildCraftEnergy { Character.valueOf('p'), Block.pistonBase }); } - public static void generateSurface(World world, Random random, int i, int j) { - OilPopulate.doPopulate(world, i, j); - - } - // public static int createPollution (World world, int i, int j, int k, int // saturation) { // int remainingSaturation = saturation; diff --git a/common/buildcraft/core/render/BlockRenderingHandler.java b/common/buildcraft/core/render/BlockRenderingHandler.java index dcacb8ea..3fac460b 100644 --- a/common/buildcraft/core/render/BlockRenderingHandler.java +++ b/common/buildcraft/core/render/BlockRenderingHandler.java @@ -45,7 +45,6 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler { public BlockRenderingHandler() { initializeMarkerMatrix(); - System.out.println("BlockRenderingHandler registered"); } @Override diff --git a/common/buildcraft/energy/OilPopulate.java b/common/buildcraft/energy/OilPopulate.java index 37998cdc..1c45f0b4 100644 --- a/common/buildcraft/energy/OilPopulate.java +++ b/common/buildcraft/energy/OilPopulate.java @@ -11,18 +11,32 @@ package buildcraft.energy; import java.util.Random; +import cpw.mods.fml.common.IWorldGenerator; + import buildcraft.BuildCraftCore; import buildcraft.BuildCraftEnergy; import buildcraft.core.ProxyCore; import net.minecraft.src.BiomeGenBase; import net.minecraft.src.Block; +import net.minecraft.src.IChunkProvider; import net.minecraft.src.World; -public class OilPopulate { +public class OilPopulate implements IWorldGenerator { public static Random rand = null; + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, + IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { + + // shift to world coordinates + chunkX = chunkX << 4; + chunkZ = chunkZ << 4; + + doPopulate(world, chunkX, chunkZ); + } + public static void doPopulate(World world, int x, int z) { if (!BuildCraftCore.modifyWorld) { return; diff --git a/common/buildcraft/mod_BuildCraftEnergy.java b/common/buildcraft/mod_BuildCraftEnergy.java index 2b09ff61..12920e3c 100644 --- a/common/buildcraft/mod_BuildCraftEnergy.java +++ b/common/buildcraft/mod_BuildCraftEnergy.java @@ -9,20 +9,20 @@ package buildcraft; -import java.util.Random; - import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.PostInit; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; +import cpw.mods.fml.common.registry.GameRegistry; import buildcraft.BuildCraftEnergy; import buildcraft.core.DefaultProps; import buildcraft.core.network.PacketHandler; import buildcraft.core.render.BlockRenderingHandler; import buildcraft.core.render.BlockRenderingHandler.EntityRenderIndex; +import buildcraft.energy.OilPopulate; import buildcraft.energy.TileEngine; import buildcraft.energy.render.RenderEngine; import buildcraft.energy.render.TextureFuelFX; @@ -30,7 +30,6 @@ import buildcraft.energy.render.TextureOilFX; import buildcraft.energy.render.TextureOilFlowFX; import net.minecraft.src.ModLoader; -import net.minecraft.src.World; @Mod(name="BuildCraft Energy", version=DefaultProps.VERSION, useMetadata = false, modid = "BC|ENERGY") @@ -46,6 +45,7 @@ public class mod_BuildCraftEnergy { @Init public void init(FMLInitializationEvent event) { BuildCraftEnergy.load(); + GameRegistry.registerWorldGenerator(new OilPopulate()); } @PostInit @@ -82,9 +82,4 @@ public class mod_BuildCraftEnergy { * return null; } } */ - //@Override - public void generateSurface(World world, Random random, int i, int j) { - BuildCraftEnergy.generateSurface(world, random, i, j); - } - }