Merge branch 'BuildCraft-5.0.x' into BuildCraft-5.1.x
This commit is contained in:
commit
2a57a81b51
5 changed files with 97 additions and 78 deletions
|
@ -81,7 +81,7 @@ this repository will have to be rejected.
|
|||
add the following to your build.gradle file
|
||||
```
|
||||
dependencies {
|
||||
compile 'com.mod-buildcraft:buildcraft:5.0.0.+'
|
||||
compile 'com.mod-buildcraft:buildcraft:5.0.0.+:dev'
|
||||
}
|
||||
```
|
||||
where `5.0.0` is the desired version of BuildCraft
|
||||
|
|
|
@ -8,10 +8,25 @@
|
|||
*/
|
||||
package buildcraft;
|
||||
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import buildcraft.api.fuels.IronEngineCoolant;
|
||||
import buildcraft.api.fuels.IronEngineFuel;
|
||||
import buildcraft.api.recipes.BuildcraftRecipes;
|
||||
import buildcraft.core.recipes.RefineryRecipeManager;
|
||||
import buildcraft.core.BlockIndex;
|
||||
import buildcraft.core.BlockSpring;
|
||||
import buildcraft.core.DefaultProps;
|
||||
|
@ -21,12 +36,11 @@ import buildcraft.core.proxy.CoreProxy;
|
|||
import buildcraft.core.triggers.BCTrigger;
|
||||
import buildcraft.energy.BlockBuildcraftFluid;
|
||||
import buildcraft.energy.BlockEngine;
|
||||
import buildcraft.energy.BptBlockEngine;
|
||||
import buildcraft.energy.BucketHandler;
|
||||
import buildcraft.energy.EnergyProxy;
|
||||
import buildcraft.energy.GuiHandler;
|
||||
import buildcraft.energy.ItemBucketBuildcraft;
|
||||
import buildcraft.energy.ItemEngine;
|
||||
import buildcraft.energy.BucketHandler;
|
||||
import buildcraft.energy.TileEngine.EnergyStage;
|
||||
import buildcraft.energy.triggers.TriggerEngineHeat;
|
||||
import buildcraft.energy.worldgen.BiomeGenOilDesert;
|
||||
|
@ -47,24 +61,6 @@ import cpw.mods.fml.common.registry.LanguageRegistry;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@Mod(name = "BuildCraft Energy", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Energy", dependencies = DefaultProps.DEPENDENCY_CORE)
|
||||
public class BuildCraftEnergy extends BuildCraftMod {
|
||||
|
||||
|
@ -94,7 +90,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
|
|||
public static BuildCraftEnergy instance;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent evt) {
|
||||
public void preInit(FMLPreInitializationEvent evt) {
|
||||
int oilDesertBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "biomeOilDesert", DefaultProps.BIOME_OIL_DESERT).getInt(DefaultProps.BIOME_OIL_DESERT);
|
||||
int oilOceanBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "biomeOilOcean", DefaultProps.BIOME_OIL_OCEAN).getInt(DefaultProps.BIOME_OIL_OCEAN);
|
||||
canOilBurn = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "burnOil", true, "Can oil burn?").getBoolean(true);
|
||||
|
@ -104,28 +100,26 @@ public class BuildCraftEnergy extends BuildCraftMod {
|
|||
double fuelFuelMultiplier = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "fuel.fuel.combustion", 1.0F, "adjust energy value of Fuel in Combustion Engines").getDouble(1.0F);
|
||||
BuildCraftCore.mainConfiguration.save();
|
||||
|
||||
class BiomeIdException extends RuntimeException {
|
||||
|
||||
public BiomeIdException(String biome, int id) {
|
||||
super(String.format("You have a Biome Id conflict at %d for %s", id, biome));
|
||||
}
|
||||
}
|
||||
|
||||
if (oilDesertBiomeId > 0) {
|
||||
if (BiomeGenBase.getBiomeGenArray () [oilDesertBiomeId] != null) {
|
||||
throw new BiomeIdException("oilDesert", oilDesertBiomeId);
|
||||
oilDesertBiomeId = findUnusedBiomeID("oilDesert");
|
||||
// save changes to config file
|
||||
BuildCraftCore.mainConfiguration.get("biomes", "biomeOilDesert", oilDesertBiomeId).set(oilDesertBiomeId);
|
||||
BuildCraftCore.mainConfiguration.save();
|
||||
}
|
||||
biomeOilDesert = BiomeGenOilDesert.makeBiome(oilDesertBiomeId);
|
||||
}
|
||||
|
||||
if (oilOceanBiomeId > 0) {
|
||||
if (BiomeGenBase.getBiomeGenArray () [oilOceanBiomeId] != null) {
|
||||
throw new BiomeIdException("oilOcean", oilOceanBiomeId);
|
||||
oilOceanBiomeId = findUnusedBiomeID("oilOcean");
|
||||
// save changes to config file
|
||||
BuildCraftCore.mainConfiguration.get("biomes", "biomeOilOcean", oilOceanBiomeId).set(oilOceanBiomeId);
|
||||
BuildCraftCore.mainConfiguration.save();
|
||||
}
|
||||
biomeOilOcean = BiomeGenOilOcean.makeBiome(oilOceanBiomeId);
|
||||
}
|
||||
|
||||
|
||||
engineBlock = new BlockEngine();
|
||||
CoreProxy.proxy.registerBlock(engineBlock, ItemEngine.class);
|
||||
|
||||
|
@ -148,7 +142,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
|
|||
blockOil = new BlockBuildcraftFluid(fluidOil, Material.water).setFlammable(canOilBurn).setFlammability(0);
|
||||
blockOil.setBlockName("blockOil");
|
||||
CoreProxy.proxy.registerBlock(blockOil);
|
||||
fluidOil.setBlock(blockOil);
|
||||
fluidOil.setBlock(blockOil);
|
||||
} else {
|
||||
blockOil = fluidOil.getBlock();
|
||||
}
|
||||
|
@ -163,7 +157,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
|
|||
blockFuel = new BlockBuildcraftFluid(fluidFuel, Material.water).setFlammable(true).setFlammability(5).setParticleColor(0.7F, 0.7F, 0.0F);
|
||||
blockFuel.setBlockName("blockFuel");
|
||||
CoreProxy.proxy.registerBlock(blockFuel);
|
||||
fluidFuel.setBlock(blockFuel);
|
||||
fluidFuel.setBlock(blockFuel);
|
||||
} else {
|
||||
blockFuel = fluidFuel.getBlock();
|
||||
}
|
||||
|
@ -209,8 +203,8 @@ public class BuildCraftEnergy extends BuildCraftMod {
|
|||
public void init(FMLInitializationEvent evt) {
|
||||
channels = NetworkRegistry.INSTANCE.newChannel
|
||||
(DefaultProps.NET_CHANNEL_NAME + "-ENERGY", new PacketHandlerTransport());
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
|
||||
|
||||
//new BptBlockEngine(engineBlock.blockID);
|
||||
|
||||
|
@ -248,6 +242,25 @@ public class BuildCraftEnergy extends BuildCraftMod {
|
|||
'g', Blocks.glass, 'G', BuildCraftCore.ironGearItem, 'p', Blocks.piston});
|
||||
}
|
||||
|
||||
private int findUnusedBiomeID (String biomeName) {
|
||||
int freeBiomeID = 0;
|
||||
// code to find a free biome
|
||||
for (int i = 1; i < 256; i++) {
|
||||
if (BiomeGenBase.getBiomeGenArray()[i] == null) {
|
||||
freeBiomeID = i;
|
||||
return freeBiomeID;
|
||||
}
|
||||
}
|
||||
// failed to find any free biome IDs
|
||||
class BiomeIdLimitException extends RuntimeException {
|
||||
public BiomeIdLimitException(String biome) {
|
||||
super(String.format("You have a run out of free Biome Ids for %s", biome));
|
||||
}
|
||||
}
|
||||
|
||||
throw new BiomeIdLimitException(biomeName);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void processIMCRequests(FMLInterModComms.IMCEvent event) {
|
||||
InterModComms.processIMC(event);
|
||||
|
|
|
@ -124,6 +124,6 @@ public class DefaultProps {
|
|||
public static final int FILLER_LIFESPAN_TOUGH = 20;
|
||||
public static final int FILLER_LIFESPAN_NORMAL = 6000;
|
||||
|
||||
public static int BIOME_OIL_OCEAN = 215;
|
||||
public static int BIOME_OIL_DESERT = 216;
|
||||
public static int BIOME_OIL_OCEAN = 126;
|
||||
public static int BIOME_OIL_DESERT = 127;
|
||||
}
|
||||
|
|
|
@ -19,29 +19,16 @@ public class BiomeInitializer {
|
|||
|
||||
@SubscribeEvent
|
||||
public void initBiomes(WorldTypeEvent.InitBiomeGens event) {
|
||||
int i;
|
||||
if (BuildCraftEnergy.biomeOilDesert != null) {
|
||||
event.newBiomeGens[0] = new GenLayerAddOilDesert(event.seed, 1500L, event.newBiomeGens[0]);
|
||||
event.newBiomeGens[1] = new GenLayerAddOilDesert(event.seed, 1500L, event.newBiomeGens[1]);
|
||||
event.newBiomeGens[2] = new GenLayerAddOilDesert(event.seed, 1500L, event.newBiomeGens[2]);
|
||||
for (i=0; i<event.newBiomeGens.length; i++) {
|
||||
event.newBiomeGens[i] = new GenLayerAddOilDesert(event.seed, 1500L, event.newBiomeGens[i]);
|
||||
}
|
||||
}
|
||||
if (BuildCraftEnergy.biomeOilOcean != null) {
|
||||
event.newBiomeGens[0] = new GenLayerAddOilOcean(event.seed, 1500L, event.newBiomeGens[0]);
|
||||
event.newBiomeGens[1] = new GenLayerAddOilOcean(event.seed, 1500L, event.newBiomeGens[1]);
|
||||
event.newBiomeGens[2] = new GenLayerAddOilOcean(event.seed, 1500L, event.newBiomeGens[2]);
|
||||
for (i=0; i<event.newBiomeGens.length; i++) {
|
||||
event.newBiomeGens[i] = new GenLayerAddOilOcean(event.seed, 1500L, event.newBiomeGens[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// int range = GenLayerBiomeReplacer.OFFSET_RANGE;
|
||||
// Random rand = new Random(event.seed);
|
||||
// double xOffset = rand.nextInt(range) - (range / 2);
|
||||
// double zOffset = rand.nextInt(range) - (range / 2);
|
||||
// double noiseScale = GenLayerAddOilOcean.NOISE_FIELD_SCALE;
|
||||
// double noiseThreshold = GenLayerAddOilOcean.NOISE_FIELD_THRESHOLD;
|
||||
// for (int x = -5000; x < 5000; x += 128) {
|
||||
// for (int z = -5000; z < 5000; z += 128) {
|
||||
// if (SimplexNoise.noise((x + xOffset) * noiseScale, (z + zOffset) * noiseScale) > noiseThreshold) {
|
||||
// System.out.printf("Oil Biome: %d, %d\n", x, z);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,15 +8,6 @@
|
|||
*/
|
||||
package buildcraft.factory;
|
||||
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import buildcraft.core.BlockIndex;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.core.fluids.FluidUtils;
|
||||
import buildcraft.core.fluids.Tank;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.BlockUtil;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
|
@ -26,12 +17,19 @@ import java.util.TreeMap;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.BlockFluidBase;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import buildcraft.core.BlockIndex;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.core.fluids.FluidUtils;
|
||||
import buildcraft.core.fluids.Tank;
|
||||
import buildcraft.core.utils.BlockUtil;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
||||
public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
|
||||
|
||||
|
@ -63,19 +61,22 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
|
|||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (worldObj.isRemote)
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (powered)
|
||||
if (powered) {
|
||||
return;
|
||||
}
|
||||
|
||||
tick++;
|
||||
if (tick % 16 == 0) {
|
||||
FluidStack fluidtoFill = tank.drain(FluidContainerRegistry.BUCKET_VOLUME, false);
|
||||
if (fluidtoFill != null && fluidtoFill.amount == FluidContainerRegistry.BUCKET_VOLUME) {
|
||||
Fluid fluid = fluidtoFill.getFluid();
|
||||
if (fluid == null || !fluid.canBePlacedInWorld())
|
||||
if (fluid == null || !fluid.canBePlacedInWorld()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fluid == FluidRegistry.WATER && worldObj.provider.dimensionId == -1) {
|
||||
tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true);
|
||||
|
@ -84,8 +85,9 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
|
|||
|
||||
if (tick % REBUILD_DELAY[rebuildDelay] == 0) {
|
||||
rebuildDelay++;
|
||||
if (rebuildDelay >= REBUILD_DELAY.length)
|
||||
if (rebuildDelay >= REBUILD_DELAY.length) {
|
||||
rebuildDelay = REBUILD_DELAY.length - 1;
|
||||
}
|
||||
rebuildQueue();
|
||||
}
|
||||
BlockIndex index = getNextIndexToFill(true);
|
||||
|
@ -100,14 +102,26 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
|
|||
|
||||
private boolean placeFluid(int x, int y, int z, Fluid fluid) {
|
||||
Block block = worldObj.getBlock(x, y, z);
|
||||
|
||||
if (canPlaceFluidAt(block, x, y, z)) {
|
||||
boolean placed = worldObj.setBlock(x, y, z, FluidUtils.getFluidBlock(fluid, true));
|
||||
boolean placed;
|
||||
Block b = FluidUtils.getFluidBlock(fluid, true);
|
||||
|
||||
if(b instanceof BlockFluidBase) {
|
||||
BlockFluidBase blockFluid = (BlockFluidBase) b;
|
||||
placed = worldObj.setBlock(x, y, z, b, blockFluid.getMaxRenderHeightMeta(), 3);
|
||||
} else {
|
||||
placed = worldObj.setBlock(x, y, z, b);
|
||||
}
|
||||
|
||||
if (placed) {
|
||||
queueAdjacent(x, y, z);
|
||||
expandQueue();
|
||||
}
|
||||
|
||||
return placed;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -119,8 +133,9 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
|
|||
Deque<BlockIndex> bottomLayer = pumpLayerQueues.firstEntry().getValue();
|
||||
|
||||
if (bottomLayer != null) {
|
||||
if (bottomLayer.isEmpty())
|
||||
if (bottomLayer.isEmpty()) {
|
||||
pumpLayerQueues.pollFirstEntry();
|
||||
}
|
||||
if (remove) {
|
||||
BlockIndex index = bottomLayer.pollFirst();
|
||||
return index;
|
||||
|
@ -154,8 +169,9 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
|
|||
}
|
||||
|
||||
private void expandQueue() {
|
||||
if (tank.getFluidType() == null)
|
||||
if (tank.getFluidType() == null) {
|
||||
return;
|
||||
}
|
||||
while (!fluidsFound.isEmpty()) {
|
||||
Deque<BlockIndex> fluidsToExpand = fluidsFound;
|
||||
fluidsFound = new LinkedList<BlockIndex>();
|
||||
|
@ -167,8 +183,9 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
|
|||
}
|
||||
|
||||
public void queueAdjacent(int x, int y, int z) {
|
||||
if (tank.getFluidType() == null)
|
||||
if (tank.getFluidType() == null) {
|
||||
return;
|
||||
}
|
||||
queueForFilling(x, y - 1, z);
|
||||
queueForFilling(x + 1, y, z);
|
||||
queueForFilling(x - 1, y, z);
|
||||
|
@ -179,8 +196,9 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
|
|||
public void queueForFilling(int x, int y, int z) {
|
||||
BlockIndex index = new BlockIndex(x, y, z);
|
||||
if (visitedBlocks.add(index)) {
|
||||
if ((x - xCoord) * (x - xCoord) + (z - zCoord) * (z - zCoord) > 64 * 64)
|
||||
if ((x - xCoord) * (x - xCoord) + (z - zCoord) * (z - zCoord) > 64 * 64) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = worldObj.getBlock(x, y, z);
|
||||
if (BlockUtil.getFluid(block) == tank.getFluidType()) {
|
||||
|
@ -200,8 +218,9 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
|
|||
boolean p = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
||||
if (powered != p) {
|
||||
powered = p;
|
||||
if (!p)
|
||||
if (!p) {
|
||||
rebuildQueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue