diff --git a/buildcraft_resources/mods/buildcraft/textures/blocks/oil.png b/buildcraft_resources/mods/buildcraft/textures/blocks/oil.png index bc09b4f6..68c27cc3 100644 Binary files a/buildcraft_resources/mods/buildcraft/textures/blocks/oil.png and b/buildcraft_resources/mods/buildcraft/textures/blocks/oil.png differ diff --git a/buildcraft_resources/mods/buildcraft/textures/blocks/oil.txt b/buildcraft_resources/mods/buildcraft/textures/blocks/oil.txt index d8fe765a..371ff436 100644 --- a/buildcraft_resources/mods/buildcraft/textures/blocks/oil.txt +++ b/buildcraft_resources/mods/buildcraft/textures/blocks/oil.txt @@ -1,32 +1,32 @@ -0*2 -1*2 -2*2 -3*2 -4*2 -5*2 -6*2 -7*2 -8*2 -9*2 -10*2 -11*2 -12*2 -13*2 -14*2 -15*2 -16*2 -17*2 -18*2 -19*2 -20*2 -21*2 -22*2 -23*2 -24*2 -25*2 -26*2 -27*2 -28*2 -29*2 -30*2 -31*2 +0*4 +1*4 +2*4 +3*4 +4*4 +5*4 +6*4 +7*4 +8*4 +9*4 +10*4 +11*4 +12*4 +13*4 +14*4 +15*4 +16*4 +17*4 +18*4 +19*4 +20*4 +21*4 +22*4 +23*4 +24*4 +25*4 +26*4 +27*4 +28*4 +29*4 +30*4 +31*4 diff --git a/buildcraft_resources/mods/buildcraft/textures/blocks/oil_flow.png b/buildcraft_resources/mods/buildcraft/textures/blocks/oil_flow.png index a5b8c520..85053e04 100644 Binary files a/buildcraft_resources/mods/buildcraft/textures/blocks/oil_flow.png and b/buildcraft_resources/mods/buildcraft/textures/blocks/oil_flow.png differ diff --git a/buildcraft_resources/mods/buildcraft/textures/blocks/oil_flow.txt b/buildcraft_resources/mods/buildcraft/textures/blocks/oil_flow.txt index e69de29b..d8fe765a 100644 --- a/buildcraft_resources/mods/buildcraft/textures/blocks/oil_flow.txt +++ b/buildcraft_resources/mods/buildcraft/textures/blocks/oil_flow.txt @@ -0,0 +1,32 @@ +0*2 +1*2 +2*2 +3*2 +4*2 +5*2 +6*2 +7*2 +8*2 +9*2 +10*2 +11*2 +12*2 +13*2 +14*2 +15*2 +16*2 +17*2 +18*2 +19*2 +20*2 +21*2 +22*2 +23*2 +24*2 +25*2 +26*2 +27*2 +28*2 +29*2 +30*2 +31*2 diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 77af7cdd..4e44ad87 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -1,11 +1,10 @@ /** * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile - * or run the code. It does *NOT* grant the right to redistribute this software - * or its modifications in any form, binary or source, except if expressively + * BuildCraft Open Source License. It grants rights to read, modify, compile or + * run the code. It does *NOT* grant the right to redistribute this software or + * its modifications in any form, binary or source, except if expressively * granted by the copyright holder. */ - package buildcraft; import java.util.TreeMap; @@ -47,45 +46,42 @@ import buildcraft.energy.ItemEngine; import buildcraft.energy.OilBucketHandler; import buildcraft.energy.OilPopulate; import buildcraft.energy.TriggerEngineHeat; +import com.google.common.base.Splitter; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.PreInit; import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.logging.Level; +import java.util.logging.Logger; +import net.minecraft.world.biome.BiomeGenBase; @Mod(name = "BuildCraft Energy", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Energy", dependencies = DefaultProps.DEPENDENCY_CORE) -@NetworkMod(channels = { DefaultProps.NET_CHANNEL_NAME }, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true) +@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true) public class BuildCraftEnergy { public final static int ENERGY_REMOVE_BLOCK = 25; public final static int ENERGY_EXTRACT_ITEM = 2; - public static BlockEngine engineBlock; - public static Block oilMoving; public static Block oilStill; public static Item bucketOil; public static Item bucketFuel; - public static Item fuel; - public static LiquidStack oilLiquid; public static LiquidStack fuelLiquid; - public static TreeMap saturationStored = new TreeMap(); - public static BCTrigger triggerBlueEngineHeat = new TriggerEngineHeat(DefaultProps.TRIGGER_BLUE_ENGINE_HEAT, EnergyStage.Blue); public static BCTrigger triggerGreenEngineHeat = new TriggerEngineHeat(DefaultProps.TRIGGER_GREEN_ENGINE_HEAT, EnergyStage.Green); public static BCTrigger triggerYellowEngineHeat = new TriggerEngineHeat(DefaultProps.TRIGGER_YELLOW_ENGINE_HEAT, EnergyStage.Yellow); public static BCTrigger triggerRedEngineHeat = new TriggerEngineHeat(DefaultProps.TRIGGER_RED_ENGINE_HEAT, EnergyStage.Red); - @Instance("BuildCraft|Energy") public static BuildCraftEnergy instance; @@ -134,8 +130,9 @@ public class BuildCraftEnergy { CoreProxy.proxy.registerBlock(oilMoving); // Oil and fuel - if (oilMoving.blockID + 1 != oilStill.blockID) + if (oilMoving.blockID + 1 != oilStill.blockID) { throw new RuntimeException("Oil Still id must be Oil Moving id + 1"); + } fuel = new ItemBuildCraft(itemFuelId.getInt(DefaultProps.FUEL_ID)).setUnlocalizedName("fuel"); LanguageRegistry.addName(fuel, "Fuel"); @@ -182,14 +179,48 @@ public class BuildCraftEnergy { public static void loadRecipes() { CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 0), - new Object[] { "www", " g ", "GpG", Character.valueOf('w'), "plankWood", Character.valueOf('g'), Block.glass, Character.valueOf('G'), - BuildCraftCore.woodenGearItem, Character.valueOf('p'), Block.pistonBase }); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 1), new Object[] { "www", " g ", "GpG", Character.valueOf('w'), Block.cobblestone, - Character.valueOf('g'), Block.glass, Character.valueOf('G'), BuildCraftCore.stoneGearItem, Character.valueOf('p'), Block.pistonBase }); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 2), new Object[] { "www", " g ", "GpG", Character.valueOf('w'), Item.ingotIron, - Character.valueOf('g'), Block.glass, Character.valueOf('G'), BuildCraftCore.ironGearItem, Character.valueOf('p'), Block.pistonBase }); + new Object[]{"www", " g ", "GpG", Character.valueOf('w'), "plankWood", Character.valueOf('g'), Block.glass, Character.valueOf('G'), + BuildCraftCore.woodenGearItem, Character.valueOf('p'), Block.pistonBase}); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 1), new Object[]{"www", " g ", "GpG", Character.valueOf('w'), Block.cobblestone, + Character.valueOf('g'), Block.glass, Character.valueOf('G'), BuildCraftCore.stoneGearItem, Character.valueOf('p'), Block.pistonBase}); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 2), new Object[]{"www", " g ", "GpG", Character.valueOf('w'), Item.ingotIron, + Character.valueOf('g'), Block.glass, Character.valueOf('G'), BuildCraftCore.ironGearItem, Character.valueOf('p'), Block.pistonBase}); } + @Mod.IMCCallback + public void processIMCRequests(FMLInterModComms.IMCEvent event) { + for (FMLInterModComms.IMCMessage m : event.getMessages()) { + if (m.key.equals("oil-lake-biome")) { + try { + String biomeID = m.getStringValue().trim(); + int id = Integer.valueOf(biomeID); + if (id >= BiomeGenBase.biomeList.length) { + throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.biomeList.length); + } + OilPopulate.surfaceDepositBiomes.add(id); + } catch (Exception ex) { + Logger.getLogger("Buildcraft").log(Level.WARNING, + String.format("Received an invalid oil-lake-biome request %s from mod %s", m.getStringValue(), m.getSender())); + } + Logger.getLogger("Buildcraft").log(Level.INFO, + String.format("Received an successfull oil-lake-biome request %s from mod %s", m.getStringValue(), m.getSender())); + } else if (m.key.equals("oil-gen-exclude")) { + try { + String biomeID = m.getStringValue().trim(); + int id = Integer.valueOf(biomeID); + if (id >= BiomeGenBase.biomeList.length) { + throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.biomeList.length); + } + OilPopulate.excludedBiomes.add(id); + } catch (Exception ex) { + Logger.getLogger("Buildcraft").log(Level.WARNING, + String.format("Received an invalid oil-gen-exclude request %s from mod %s", m.getStringValue(), m.getSender())); + } + Logger.getLogger("Buildcraft").log(Level.INFO, + String.format("Received an successfull oil-gen-exclude request %s from mod %s", m.getStringValue(), m.getSender())); + } + } + } // public static int createPollution (World world, int i, int j, int k, int // saturation) { // int remainingSaturation = saturation; diff --git a/common/buildcraft/energy/OilPopulate.java b/common/buildcraft/energy/OilPopulate.java index 86dccb49..b8b31f73 100644 --- a/common/buildcraft/energy/OilPopulate.java +++ b/common/buildcraft/energy/OilPopulate.java @@ -17,16 +17,20 @@ import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.TerrainGen; import buildcraft.BuildCraftCore; import buildcraft.BuildCraftEnergy; -import buildcraft.core.BlockSpring; import java.util.HashSet; import java.util.Set; +import net.minecraft.block.BlockFlower; public class OilPopulate { public static final Set surfaceDepositBiomes = new HashSet(); + public static final Set excludedBiomes = new HashSet(); static { surfaceDepositBiomes.add(BiomeGenBase.desert.biomeID); + + excludedBiomes.add(BiomeGenBase.sky.biomeID); + excludedBiomes.add(BiomeGenBase.hell.biomeID); } @ForgeSubscribe @@ -48,28 +52,20 @@ public class OilPopulate { public static void doPopulate(World world, Random rand, int x, int z) { BiomeGenBase biome = world.getBiomeGenForCoords(x + 16, z + 16); - // Do not generate oil in the End - if (biome.biomeID == BiomeGenBase.sky.biomeID || biome.biomeID == BiomeGenBase.hell.biomeID) { + // Do not generate oil in the End or Nether + if (excludedBiomes.contains(biome.biomeID)) { return; } + // Generate a surface oil lake if (surfaceDepositBiomes.contains(biome.biomeID) && rand.nextFloat() > 0.97) { - // Generate a small desert deposit + int lakeX = rand.nextInt(10) + 2 + x; + int lakeY = world.getTopSolidOrLiquidBlock(x, z) - 1; + int lakeZ = rand.nextInt(10) + 2 + z; - int startX = rand.nextInt(10) + 2; - int startZ = rand.nextInt(10) + 2; - - for (int j = 128; j > 65; --j) { - int i = startX + x; - int k = startZ + z; - - int blockId = world.getBlockId(i, j, k); - if (blockId != 0) { - if (blockId == Block.sand.blockID) { - generateSurfaceDeposit(world, rand, i, j, k, 3); - } - break; - } + int blockId = world.getBlockId(lakeX, lakeY, lakeZ); + if (blockId == biome.topBlock) { + generateSurfaceDeposit(world, rand, lakeX, lakeY, lakeZ, 3); } } @@ -126,7 +122,8 @@ public class OilPopulate { world.setBlock(baseX, y, baseZ, BuildCraftEnergy.oilStill.blockID); } else { int blockId = world.getBlockId(baseX, y, baseZ); - if (blockId != 0 && blockId != Block.leaves.blockID && blockId != Block.wood.blockID && blockId != Block.grass.blockID) { + Block block = Block.blocksList[blockId]; + if (blockId != 0 && !block.isLeaves(world, baseX, y, baseZ) && !block.isWood(world, baseX, y, baseZ)) { started = true; if (largeDeposit) { @@ -154,16 +151,17 @@ public class OilPopulate { } public static void generateSurfaceDeposit(World world, Random rand, int x, int y, int z, int radius) { - setOilWithProba(world, rand, 1, x, y, z, true); + int depth = rand.nextDouble() < 0.5 ? 1 : 2; + setOilWithProba(world, rand, 1, x, y, z, true, depth); for (int w = 1; w <= radius; ++w) { float proba = (float) (radius - w + 4) / (float) (radius + 4); for (int d = -w; d <= w; ++d) { - setOilWithProba(world, rand, proba, x + d, y, z + w, false); - setOilWithProba(world, rand, proba, x + d, y, z - w, false); - setOilWithProba(world, rand, proba, x + w, y, z + d, false); - setOilWithProba(world, rand, proba, x - w, y, z + d, false); + setOilWithProba(world, rand, proba, x + d, y, z + w, false, depth); + setOilWithProba(world, rand, proba, x + d, y, z - w, false, depth); + setOilWithProba(world, rand, proba, x + w, y, z + d, false, depth); + setOilWithProba(world, rand, proba, x - w, y, z + d, false, depth); } } @@ -173,7 +171,7 @@ public class OilPopulate { if (world.getBlockId(dx, y - 1, dz) != BuildCraftEnergy.oilStill.blockID) { if (isOil(world, dx + 1, y - 1, dz) && isOil(world, dx - 1, y - 1, dz) && isOil(world, dx, y - 1, dz + 1) && isOil(world, dx, y - 1, dz - 1)) { - setOilWithProba(world, rand, 1.0F, dx, y, dz, true); + setOilWithProba(world, rand, 1.0F, dx, y, dz, true, depth); } } } @@ -181,10 +179,11 @@ public class OilPopulate { } private static boolean isOil(World world, int x, int y, int z) { - return (world.getBlockId(x, y, z) == BuildCraftEnergy.oilStill.blockID || world.getBlockId(x, y, z) == BuildCraftEnergy.oilMoving.blockID); + int blockId = world.getBlockId(x, y, z); + return (blockId == BuildCraftEnergy.oilStill.blockID || blockId == BuildCraftEnergy.oilMoving.blockID); } - public static void setOilWithProba(World world, Random rand, float proba, int x, int y, int z, boolean force) { + public static void setOilWithProba(World world, Random rand, float proba, int x, int y, int z, boolean force, int depth) { if ((rand.nextFloat() <= proba && world.getBlockId(x, y - 2, z) != 0) || force) { boolean adjacentOil = false; @@ -195,14 +194,18 @@ public class OilPopulate { } if (adjacentOil || force) { - if (world.getBlockId(x, y, z) == Block.waterMoving.blockID || world.getBlockId(x, y, z) == Block.waterStill.blockID || isOil(world, x, y, z)) { + if (world.isAirBlock(x, y + 1, z) || Block.blocksList[world.getBlockId(x, y + 1, z)] instanceof BlockFlower) { + int blockId = world.getBlockId(x, y, z); + if (blockId == Block.waterMoving.blockID || blockId == Block.waterStill.blockID || isOil(world, x, y, z)) { + world.setBlock(x, y, z, BuildCraftEnergy.oilStill.blockID); + } else { + world.setBlockToAir(x, y, z); + } - world.setBlock(x, y, z, BuildCraftEnergy.oilStill.blockID); - } else { - world.setBlock(x, y, z, 0); + for (int i = depth; i > 0; i--) { + world.setBlock(x, y - i, z, BuildCraftEnergy.oilStill.blockID); + } } - - world.setBlock(x, y - 1, z, BuildCraftEnergy.oilStill.blockID); } } }