Skip to content

Commit

Permalink
Temp work.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexIIL committed Jun 6, 2017
1 parent 0c12b67 commit 7f5ba0a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
5 changes: 3 additions & 2 deletions common/buildcraft/builders/snapshot/SchematicBlockFluid.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ public List<ItemStack> computeRequiredItems(SchematicBlockContext context) {
@Override
public List<FluidStack> computeRequiredFluids(SchematicBlockContext context) {
List<FluidStack> requiredFluids = new ArrayList<>();
if (BlockUtil.drainBlock(context.world, context.pos, false) != null) {
requiredFluids.add(BlockUtil.drainBlock(context.world, context.pos, false));
FluidStack fluid = BlockUtil.drainBlock(context.world, context.pos, false);
if (fluid != null) {
requiredFluids.add(fluid);
}
return requiredFluids;
}
Expand Down
5 changes: 5 additions & 0 deletions common/buildcraft/energy/generation/IHeightFunction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package buildcraft.energy.generation;

public interface IHeightFunction {
int[][] genHeights(int cx, int cz);
}
2 changes: 2 additions & 0 deletions common/buildcraft/energy/generation/OilGenStructure.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ protected void generateWithin(World world, Box intersect) {

public static class Spout extends OilGenStructure {
// FIXME (AlexIIL): This won't support cubic chunks - we'll have to do this differently in compat
// TODO: Use a terrain generator from mc terrain generation to get the height of the world
// A hook will go in compat for help when using cubic chunks or a different type of terrain generator
public final BlockPos start;
public final int radius;
public final int height;
Expand Down
20 changes: 20 additions & 0 deletions common/buildcraft/energy/generation/OilGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderServer;

import net.minecraftforge.fml.common.IWorldGenerator;

Expand Down Expand Up @@ -93,6 +94,25 @@ public static void addStructures(List<OilGenStructure> structures, World world,
return;
}

// FIXME: Half implemented!
int[][] heights;
IChunkProvider provider = world.getChunkProvider();
if (provider instanceof IHeightFunction) {
heights = ((IHeightFunction) provider).genHeights(cx, cz);
} else if (provider instanceof ChunkProviderServer) {
IChunkGenerator gen = ((ChunkProviderServer) provider).chunkGenerator;
if (gen instanceof IHeightFunction) {
heights = ((IHeightFunction) gen).genHeights(cx, cz);
} else {
heights = new int[16][16];
for (int hx = 0; hx < 16; hx++) {
for (int hz = 0; hz < 16; hz++) {
heights[hx][hz] = world.getSeaLevel();
}
}
}
}

if (type != GenType.LAKE) {
// Generate a spherical cave deposit
int wellY = 20 + rand.nextInt(10);
Expand Down

0 comments on commit 7f5ba0a

Please sign in to comment.