Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/8.0.x' into 8.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
afdw committed Jul 5, 2017
2 parents d8a0385 + ed7b3ab commit 1942641
Show file tree
Hide file tree
Showing 73 changed files with 2,270 additions and 708 deletions.
2 changes: 1 addition & 1 deletion BuildCraft-Localization
2 changes: 1 addition & 1 deletion BuildCraftAPI
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,15 @@ task allSrcJar(type: Jar, dependsOn:reobfJar) {
}
}

sourceJar.destinationDir = libsDir

// add api classes to main package
jar {
from sourceSets.api.output
}

// make sure all of these happen when we run build
build.dependsOn sourceJar, apiJar, deobfJar, javadocJar
build.dependsOn allSrcJar, apiJar, deobfJar, javadocJar

// --------------------
// maven section
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ public interface ITileForBlueprintBuilder extends ITileForSnapshotBuilder {

IItemTransactor getInvResources();

TankManager<Tank> getTankManager();
TankManager getTankManager();
}
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
39 changes: 13 additions & 26 deletions common/buildcraft/builders/tile/TileBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,30 +80,15 @@ public class TileBuilder extends TileBC_Neptune
public static final int NET_CAN_EXCAVATE = IDS.allocId("CAN_EXCAVATE");
public static final int NET_SNAPSHOT_TYPE = IDS.allocId("SNAPSHOT_TYPE");

public final ItemHandlerSimple invSnapshot = itemManager.addInvHandler(
"snapshot",
1,
EnumAccess.BOTH,
EnumPipePart.VALUES
);
public final ItemHandlerSimple invResources = itemManager.addInvHandler(
"resources",
27,
EnumAccess.BOTH,
EnumPipePart.VALUES
);
private final TankManager<Tank> tankManager = new TankManager<>();
public final ItemHandlerSimple invSnapshot;
public final ItemHandlerSimple invResources;

private final MjBattery battery = new MjBattery(1000 * MjAPI.MJ);
private boolean canExcavate = true;

/**
* Stores the real path - just a few block positions.
*/
/** Stores the real path - just a few block positions. */
public List<BlockPos> path = null;
/**
* Stores the real path plus all possible block positions inbetween.
*/
/** Stores the real path plus all possible block positions inbetween. */
private List<BlockPos> basePoses = new ArrayList<>();
private int currentBasePosIndex = 0;
private Snapshot snapshot = null;
Expand All @@ -117,6 +102,8 @@ public class TileBuilder extends TileBC_Neptune
private boolean isDone = false;

public TileBuilder() {
invSnapshot = itemManager.addInvHandler("snapshot", 1, EnumAccess.BOTH, EnumPipePart.VALUES);
invResources = itemManager.addInvHandler("resources", 27, EnumAccess.BOTH, EnumPipePart.VALUES);
for (int i = 1; i <= 4; i++) {
tankManager.add(new Tank("fluid" + i, Fluid.BUCKET_VOLUME * 8, this));
}
Expand All @@ -130,10 +117,8 @@ public IdAllocator getIdAllocator() {
}

@Override
protected void onSlotChange(IItemHandlerModifiable itemHandler,
int slot,
@Nonnull ItemStack before,
@Nonnull ItemStack after) {
protected void onSlotChange(IItemHandlerModifiable itemHandler, int slot, @Nonnull ItemStack before,
@Nonnull ItemStack after) {
if (itemHandler == invSnapshot) {
if (!world.isRemote) {
currentBasePosIndex = 0;
Expand Down Expand Up @@ -232,8 +217,10 @@ public void onPlacedBy(EntityLivingBase placer, ItemStack stack) {
public void update() {
battery.tick(getWorld(), getPos());
battery.addPowerChecking(64 * MjAPI.MJ, false);
if (getBuilder() != null) {
if (isDone = getBuilder().tick()) {
SnapshotBuilder<?> builder = getBuilder();
if (builder != null) {
isDone = builder.tick();
if (isDone) {
if (currentBasePosIndex < basePoses.size() - 1) {
currentBasePosIndex++;
if (currentBasePosIndex >= basePoses.size()) {
Expand Down Expand Up @@ -439,7 +426,7 @@ public IItemTransactor getInvResources() {
}

@Override
public TankManager<Tank> getTankManager() {
public TankManager getTankManager() {
return tankManager;
}
}
21 changes: 12 additions & 9 deletions common/buildcraft/builders/tile/TileQuarry.java
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,6 @@ private abstract class Task {
public long clientPower;
public long prevClientPower;

@SuppressWarnings("WeakerAccess")
public Task() {
}

Expand All @@ -687,7 +686,6 @@ public void fromBytes(PacketBufferBC buffer) {
power = buffer.readLong();
}

@SuppressWarnings("WeakerAccess")
public void clientTick() {
prevClientPower = clientPower;
clientPower = power;
Expand All @@ -709,7 +707,6 @@ public final long getPower() {
/**
* @return True if this task has been completed, or cancelled.
*/
@SuppressWarnings("WeakerAccess")
public final boolean addPower(long microJoules) {
power += microJoules;
if (power >= getTarget()) {
Expand All @@ -726,11 +723,9 @@ public final boolean addPower(long microJoules) {
public class TaskBreakBlock extends Task {
public BlockPos breakPos = BlockPos.ORIGIN;

@SuppressWarnings("WeakerAccess")
public TaskBreakBlock() {
}

@SuppressWarnings("WeakerAccess")
public TaskBreakBlock(BlockPos pos) {
this.breakPos = pos;
}
Expand All @@ -746,6 +741,10 @@ public NBTTagCompound serializeNBT() {
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
breakPos = NBTUtilBC.readBlockPos(nbt.getTag("breakPos"));
if (breakPos == null) {
// We failed to read, abort
currentTask = null;
}
}

@Override
Expand Down Expand Up @@ -828,11 +827,9 @@ public boolean equals(Object o) {
public class TaskAddFrame extends Task {
public BlockPos framePos = BlockPos.ORIGIN;

@SuppressWarnings("WeakerAccess")
public TaskAddFrame() {
}

@SuppressWarnings("WeakerAccess")
public TaskAddFrame(BlockPos framePos) {
this.framePos = framePos;
}
Expand All @@ -848,6 +845,10 @@ public NBTTagCompound serializeNBT() {
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
framePos = NBTUtilBC.readBlockPos(nbt.getTag("framePos"));
if (framePos == null) {
// We failed to read, abort
currentTask = null;
}
}

@Override
Expand Down Expand Up @@ -893,11 +894,9 @@ private class TaskMoveDrill extends Task {
public Vec3d from = Vec3d.ZERO;
public Vec3d to = Vec3d.ZERO;

@SuppressWarnings("WeakerAccess")
public TaskMoveDrill() {
}

@SuppressWarnings("WeakerAccess")
public TaskMoveDrill(Vec3d from, Vec3d to) {
this.from = from;
this.to = to;
Expand All @@ -916,6 +915,10 @@ public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
from = NBTUtilBC.readVec3d(nbt.getTag("from"));
to = NBTUtilBC.readVec3d(nbt.getTag("to"));
if (from == null || to == null) {
// We failed to read. Abort.
currentTask = null;
}
}

@Override
Expand Down
16 changes: 16 additions & 0 deletions common/buildcraft/core/block/BlockSpring.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package buildcraft.core.block;

import java.util.Random;
import java.util.function.Supplier;

import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
Expand All @@ -16,6 +17,7 @@
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand Down Expand Up @@ -82,6 +84,20 @@ public void updateTick(World world, BlockPos pos, IBlockState state, Random rand
generateSpringBlock(world, pos, state);
}

@Override
public boolean hasTileEntity(IBlockState state) {
return state.getValue(SPRING_TYPE).tileConstructor != null;
}

@Override
public TileEntity createTileEntity(World world, IBlockState state) {
Supplier<TileEntity> constructor = state.getValue(SPRING_TYPE).tileConstructor;
if (constructor != null) {
return constructor.get();
}
return null;
}

// @Override
// public void onNeighborBlockChange(World world, int x, int y, int z, int blockid) {
// assertSpring(world, x, y, z);
Expand Down
15 changes: 8 additions & 7 deletions common/buildcraft/core/item/ItemMapLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import buildcraft.lib.misc.LocaleUtil;
import buildcraft.lib.misc.NBTUtilBC;
import buildcraft.lib.misc.StackUtil;
import buildcraft.lib.misc.StringUtilBC;
import buildcraft.lib.misc.data.Box;

import buildcraft.robotics.zone.ZonePlan;
Expand Down Expand Up @@ -110,12 +111,9 @@ public void addInformation(ItemStack stack, EntityPlayer player, List<String> st

if (pathNBT.tagCount() > 0) {
BlockPos first = NBTUtilBC.readBlockPos(pathNBT.get(0));

int x = first.getX();
int y = first.getY();
int z = first.getZ();

strings.add(LocaleUtil.localize("{" + x + ", " + y + ", " + z + "} + " + (pathNBT.tagCount() - 1) + " elements"));
if (first != null) {
strings.add(StringUtilBC.blockPosToString(first) + (pathNBT.tagCount() - 1) + " elements");
}
}
}
break;
Expand Down Expand Up @@ -332,7 +330,10 @@ public List<BlockPos> getPath(@Nonnull ItemStack item) {
List<BlockPos> indexList = new ArrayList<>();
NBTTagList pathNBT = (NBTTagList) cpt.getTag("path");
for (int i = 0; i < pathNBT.tagCount(); i++) {
indexList.add(NBTUtilBC.readBlockPos(pathNBT.get(i)));
BlockPos pos = NBTUtilBC.readBlockPos(pathNBT.get(i));
if (pos != null){
indexList.add(pos);
}
}
return indexList;
}
Expand Down
7 changes: 5 additions & 2 deletions common/buildcraft/energy/BCEnergy.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import buildcraft.energy.generation.BiomeInitializer;
import buildcraft.energy.generation.BiomeOilDesert;
import buildcraft.energy.generation.BiomeOilOcean;
import buildcraft.energy.generation.OilPopulate;
import buildcraft.energy.generation.OilGenerator;

//@formatter:off
@Mod(modid = BCEnergy.MODID,
Expand All @@ -52,6 +52,8 @@ public static void preInit(FMLPreInitializationEvent evt) {
BCEnergyBlocks.preInit();
BCEnergyEntities.preInit();

GameRegistry.registerWorldGenerator(OilGenerator.INSTANCE, 0);

NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, BCEnergyProxy.getProxy());
GameRegistry.register(BiomeOilOcean.INSTANCE);
GameRegistry.register(BiomeOilDesert.INSTANCE);
Expand All @@ -78,7 +80,7 @@ public static void init(FMLInitializationEvent evt) {

@Mod.EventHandler
public static void postInit(FMLPostInitializationEvent evt) {
MinecraftForge.EVENT_BUS.register(OilPopulate.INSTANCE);
// MinecraftForge.EVENT_BUS.register(OilPopulate.INSTANCE);
BCEnergyProxy.getProxy().fmlPostInit();
registerMigrations();
}
Expand All @@ -102,6 +104,7 @@ private static void registerMigrations() {
// Tiles
registerTag("tile.engine.stone").reg("engine.stone");
registerTag("tile.engine.iron").reg("engine.iron");
registerTag("tile.spring.oil").reg("spring.oil");

endBatch(TagManager.prependTags("buildcraftenergy:", EnumTagType.REGISTRY_NAME, EnumTagType.MODEL_LOCATION).andThen(TagManager.setTab("buildcraft.main")));
}
Expand Down
12 changes: 10 additions & 2 deletions common/buildcraft/energy/BCEnergyBlocks.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
/* Copyright (c) 2016 SpaceToad and the BuildCraft team
/*
* Copyright (c) 2016 SpaceToad and the BuildCraft team
*
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
* distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package buildcraft.energy;

import buildcraft.api.enums.EnumEngineType;
import buildcraft.api.enums.EnumSpring;

import buildcraft.lib.tile.TileBC_Neptune;

import buildcraft.core.BCCoreBlocks;
import buildcraft.energy.tile.TileEngineIron_BC8;
import buildcraft.energy.tile.TileEngineStone_BC8;
import buildcraft.energy.tile.TileSpringOil;

public class BCEnergyBlocks {
public static void preInit() {
EnumSpring.OIL.liquidBlock = BCEnergyFluids.crudeOil[0].getBlock().getDefaultState();
EnumSpring.OIL.tileConstructor = TileSpringOil::new;
TileBC_Neptune.registerTile(TileSpringOil.class, "tile.spring.oil");

if (BCCoreBlocks.engine != null) {
TileBC_Neptune.registerTile(TileEngineStone_BC8.class, "tile.engine.stone");
BCCoreBlocks.engine.registerEngine(EnumEngineType.STONE, TileEngineStone_BC8::new);
Expand Down
2 changes: 1 addition & 1 deletion common/buildcraft/energy/BCEnergyFluids.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static void preInit() {
{ 1200, 4000, 3, 4, 0x10_0F_10, 0x42_10_42 },// Residue
{ 850, 1800, 3, 6, 0xA0_8F_1F, 0x42_35_20 },// Heavy Oil
{ 950, 1600, 3, 5, 0x87_6E_77, 0x42_24_24 },// Dense Oil
{ 750, 1400, 2, 8, 0xE4_BF_78, 0xA4_8F_00 },// Distilled Oil
{ 750, 1400, 2, 8, 0xE4_AF_78, 0xB4_7F_00 },// Distilled Oil
{ 600, 800, 2, 7, 0xFF_AF_3F, 0xE0_7F_00 },// Dense Fuel
{ 700, 1000, 2, 7, 0xF2_A7_00, 0xC4_87_00 },// Mixed Heavy Fuels
{ 400, 600, 1, 8, 0xFF_FF_30, 0xE4_CF_00 },// Light Fuel
Expand Down
Loading

0 comments on commit 1942641

Please sign in to comment.