Merge branch 'BuildCraft-5.1.x' into NextGen
This commit is contained in:
commit
eb6293b0fe
5 changed files with 75 additions and 52 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
|
||||
|
|
|
@ -113,28 +113,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(CreativeTabBuildCraft.TIER_1);
|
||||
CoreProxy.proxy.registerBlock(engineBlock, ItemEngine.class);
|
||||
|
||||
|
@ -292,6 +290,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);
|
||||
|
|
|
@ -136,6 +136,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…
Add table
Reference in a new issue