Merge branch '6.5.x' of github.com:BuildCraft/BuildCraft into 7.1.x

This commit is contained in:
Adrian 2015-07-11 17:31:48 +02:00
commit 0d3b5b2eb7
21 changed files with 181 additions and 145 deletions

View file

@ -38,7 +38,7 @@ public abstract class Schematic {
* Blocks are build in various stages, in order to make sure that a block
* can indeed be placed, and that it's unlikely to disturb other blocks.
*/
public static enum BuildingStage {
public enum BuildingStage {
/**
* Standalone blocks can be placed in the air, and they don't change
* once placed.

View file

@ -194,9 +194,9 @@ public class AIRobot {
if (aiRobotClass != null) {
delegateAI = (AIRobot) aiRobotClass.getConstructor(EntityRobotBase.class)
.newInstance(robot);
delegateAI.parentAI = this;
if (delegateAI.canLoadFromNBT()) {
delegateAI.parentAI = this;
delegateAI.loadFromNBT(sub);
}
}

View file

@ -22,7 +22,7 @@ apply plugin: 'forge' // adds the forge dependency
apply plugin: 'maven' // for uploading to a maven repo
apply plugin: 'checkstyle'
version = "7.0.13"
version = "7.0.14"
group= "com.mod-buildcraft"
archivesBaseName = "buildcraft" // the name that all artifacts will use as a base. artifacts names follow this pattern: [baseName]-[appendix]-[version]-[classifier].[extension]

View file

@ -0,0 +1,19 @@
Improvements:
* Quarries now dig through light fluids and stop on dense fluids. Behaviour might change later, so watch out! (asie)
Bugs fixed:
* [#2880] Try to fix fluid pipe bug (asie)
* [#2878] Robot NPE for robots prior to 7.0.13 fix (asie)
* [#2877] Survival blueprint crash (asie)
* [#2841] Another crash with Oil in the Nether (asie)
* [#2837] Massive lag with Construction Markers (hea3ven)
* [#2831] Robots sinking through the ground (hea3ven)
* [#2825, #2618, #1777] Quarry issues with just about every translucent block (asie)
* Allow Builders to use arbitrary IPathProviders (asie)
* Block breaking robots sleeping in mid air (hea3ven)
* Error in robot AI loading (hea3ven)
* Incorrect Request Needed Items action name (asie)
* Packages crashing Minecraft if mods are removed (asie)
* Robots ignoring gate config on their linked station when equipping items (hea3ven)

View file

@ -1,3 +1,3 @@
1.6.4:BuildCraft:4.2.2
1.7.2:BuildCraft:6.0.16
1.7.10:BuildCraft:7.0.13
1.7.10:BuildCraft:7.0.14

View file

@ -489,7 +489,6 @@ public class BuildCraftCore extends BuildCraftMod {
BuildCraftAPI.softBlocks.add(Blocks.snow);
BuildCraftAPI.softBlocks.add(Blocks.vine);
BuildCraftAPI.softBlocks.add(Blocks.fire);
BuildCraftAPI.softBlocks.add(Blocks.air);
FMLCommonHandler.instance().bus().register(new TickHandlerCore());

View file

@ -152,22 +152,26 @@ public class LibraryDatabase {
int sepIndex = fileName.lastIndexOf(LibraryId.BPT_SEP_CHARACTER);
int dotIndex = fileName.lastIndexOf('.');
String extension = fileName.substring(dotIndex + 1);
if (dotIndex > 0) {
String extension = fileName.substring(dotIndex + 1);
if (sepIndex > 0) {
String prefix = fileName.substring(0, sepIndex);
String suffix = fileName.substring(sepIndex + 1);
if (sepIndex > 0) {
String prefix = fileName.substring(0, sepIndex);
String suffix = fileName.substring(sepIndex + 1);
id.name = prefix;
id.uniqueId = LibraryId.toBytes(suffix.substring(0, suffix.length() - (extension.length() + 1)));
id.name = prefix;
id.uniqueId = LibraryId.toBytes(suffix.substring(0, suffix.length() - (extension.length() + 1)));
} else {
id.name = fileName.substring(0, dotIndex);
id.uniqueId = new byte[0];
}
id.extension = extension;
if (!blueprintIds.contains(id)) {
blueprintIds.add(id);
}
} else {
id.name = fileName.substring(0, dotIndex);
id.uniqueId = new byte[0];
}
id.extension = extension;
if (!blueprintIds.contains(id)) {
blueprintIds.add(id);
BCLog.logger.warn("Found incorrectly named (no extension) blueprint file: '%s'!", fileName);
}
}

View file

@ -209,7 +209,6 @@ public class TileConstructionMarker extends TileBuildCraft implements IBuildingI
@Override
public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) {
if (side.isServer() && "uploadBuildersInAction".equals(command)) {
BuildCraftCore.instance.sendToServer(new PacketCommand(this, "uploadBuildersInAction", null));
for (BuildingItem i : buildersInAction) {
BuildCraftCore.instance.sendToPlayer((EntityPlayer) sender, createLaunchItemPacket(i));
}

View file

@ -17,6 +17,7 @@ import com.google.common.collect.Sets;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
@ -31,6 +32,7 @@ import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.ForgeChunkManager.Type;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.IFluidBlock;
import buildcraft.BuildCraftBuilders;
import buildcraft.BuildCraftCore;
@ -313,9 +315,7 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
if (!columnVisitListIsUpdated) { // nextTarget may not be accurate, at least search the target column for changes
for (int y = nextTarget[1] + 1; y < yCoord + 3; y++) {
Block block = worldObj.getBlock(nextTarget[0], y, nextTarget[2]);
if (BlockUtils.isAnObstructingBlock(block, worldObj, nextTarget[0], y, nextTarget[2])
|| !BuildCraftAPI.isSoftBlock(worldObj, nextTarget[0], y, nextTarget[2])) {
if (isQuarriableBlock(nextTarget[0], y, nextTarget[2])) {
createColumnVisitList();
columnVisitListIsUpdated = true;
nextTarget = null;
@ -340,8 +340,6 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
*/
private void createColumnVisitList() {
visitList.clear();
Integer[][] columnHeights = new Integer[builder.blueprint.sizeX - 2][builder.blueprint.sizeZ - 2];
boolean[][] blockedColumns = new boolean[builder.blueprint.sizeX - 2][builder.blueprint.sizeZ - 2];
for (int searchY = yCoord + 3; searchY >= 1; --searchY) {
@ -372,29 +370,16 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
for (int searchZ = startZ; searchZ != endZ; searchZ += incZ) {
if (!blockedColumns[searchX][searchZ]) {
Integer height = columnHeights[searchX][searchZ];
int bx = box.xMin + searchX + 1, by = searchY, bz = box.zMin + searchZ + 1;
if (height == null) {
columnHeights[searchX][searchZ] = height = worldObj.getHeightValue(bx, bz);
}
if (height > 0 && height < by && worldObj.provider.dimensionId != -1) {
continue;
}
Block block = worldObj.getBlock(bx, by, bz);
if (!BlockUtils.canChangeBlock(block, worldObj, bx, by, bz)) {
blockedColumns[searchX][searchZ] = true;
} else if (!BuildCraftAPI.isSoftBlock(worldObj, bx, by, bz)) {
} else if (!BuildCraftAPI.isSoftBlock(worldObj, bx, by, bz) && !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock)) {
visitList.add(new int[]{bx, by, bz});
}
if (height == 0 && !worldObj.isAirBlock(bx, by, bz)) {
columnHeights[searchX][searchZ] = by;
}
// Stop at two planes - generally any obstructions will have been found and will force a recompute prior to this
if (visitList.size() > builder.blueprint.sizeZ * builder.blueprint.sizeX * 2) {
@ -487,7 +472,8 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
private boolean isQuarriableBlock(int bx, int by, int bz) {
Block block = worldObj.getBlock(bx, by, bz);
return BlockUtils.canChangeBlock(block, worldObj, bx, by, bz)
&& !BuildCraftAPI.isSoftBlock(worldObj, bx, by, bz);
&& !BuildCraftAPI.isSoftBlock(worldObj, bx, by, bz)
&& !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock);
}
@Override

View file

@ -11,7 +11,6 @@ package buildcraft.core;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import io.netty.buffer.ByteBuf;

View file

@ -265,8 +265,10 @@ public class BptBuilderBlueprint extends BptBuilderBase {
private int getBuildListCount() {
int out = 0;
for (int i = 0; i < buildStageOccurences.length; i++) {
out += buildStageOccurences[i];
if (buildStageOccurences != null) {
for (int i = 0; i < buildStageOccurences.length; i++) {
out += buildStageOccurences[i];
}
}
return out;
}

View file

@ -186,7 +186,7 @@ public class BlockBuildCraftFluid extends BlockFluidClassic {
}
@Override
public boolean canDropFromExplosion(Explosion p_149659_1_) {
public boolean canDropFromExplosion(Explosion explosion) {
return false;
}
}

View file

@ -119,6 +119,7 @@ public final class BlockUtils {
world.spawnEntityInWorld(entityitem);
}
@Deprecated
public static boolean isAnObstructingBlock(Block block, World world, int x, int y, int z) {
if (block == null || block.isAir(world, x, y, z)) {
return false;
@ -139,13 +140,13 @@ public final class BlockUtils {
return false;
}
// TODO: Make this support all "heavy" liquids, not just oil/lava
if (block instanceof IFluidBlock && ((IFluidBlock) block).getFluid() != null && "oil".equals(((IFluidBlock) block).getFluid().getName())) {
return false;
}
if (block == Blocks.lava || block == Blocks.flowing_lava) {
return false;
} else if (block instanceof IFluidBlock && ((IFluidBlock) block).getFluid() != null) {
Fluid f = ((IFluidBlock) block).getFluid();
if (f.getDensity(world, x, y, z) >= 3000) {
return false;
}
}
return true;

View file

@ -14,7 +14,6 @@ import net.minecraft.world.IBlockAccess;
import buildcraft.api.core.BuildCraftAPI;
public class WorldPropertyIsSoft extends WorldProperty {
@Override
public boolean get(IBlockAccess blockAccess, Block block, int meta, int x, int y, int z) {
return block == null

View file

@ -62,7 +62,10 @@ public class DockingStationPipe extends DockingStation {
public IPipeTile getPipe() {
if (pipe == null) {
pipe = (IPipeTile) world.getTileEntity(x(), y(), z());
TileEntity tile = world.getTileEntity(x(), y(), z());
if (tile instanceof IPipeTile) {
pipe = (IPipeTile) tile;
}
}
if (pipe == null || ((TileEntity) pipe).isInvalid()) {

View file

@ -10,11 +10,10 @@ package buildcraft.robotics.ai;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStation;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.lib.inventory.ITransactor;
import buildcraft.core.lib.inventory.Transactor;
@ -37,18 +36,24 @@ public class AIRobotFetchAndEquipItemStack extends AIRobot {
filter = new AggregateFilter(ActionRobotFilterTool.getGateFilter(iRobot.getLinkedStation()), iFilter);
}
@Override
public void start() {
startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, 1));
}
@Override
public void update() {
if (robot.getDockingStation() == null) {
startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, 1));
} else {
if (delay++ > 40) {
if (equipItemStack()) {
terminate();
} else {
delay = 0;
startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, 1));
}
setSuccess(false);
terminate();
}
if (delay++ > 40) {
if (equipItemStack()) {
terminate();
} else {
delay = 0;
startDelegateAI(new AIRobotGotoStationToLoad(robot, filter, 1));
}
}
}
@ -71,31 +76,20 @@ public class AIRobotFetchAndEquipItemStack extends AIRobot {
}
private boolean equipItemStack() {
if (robot.getDockingStation() != null) {
DockingStation station = robot.getDockingStation();
ItemStack itemFound = null;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity nearbyTile = robot.worldObj.getTileEntity(station.x() + dir.offsetX,
station.y() + dir.offsetY, station.z() + dir.offsetZ);
if (nearbyTile != null && nearbyTile instanceof IInventory) {
ITransactor trans = Transactor.getTransactorFor(nearbyTile);
itemFound = trans.remove(filter, dir.getOpposite(), true);
if (itemFound != null) {
break;
}
}
}
if (itemFound != null) {
robot.setItemInUse(itemFound);
return true;
}
IInventory tileInventory = robot.getDockingStation().getItemInput();
if (tileInventory == null) {
return false;
}
ITransactor trans = Transactor.getTransactorFor(tileInventory);
ItemStack itemFound = trans.remove(filter, ForgeDirection.UNKNOWN, true);
if (itemFound != null) {
robot.setItemInUse(itemFound);
return true;
}
return false;
}
}

View file

@ -36,7 +36,7 @@ public class AIRobotGoAndLinkToDock extends AIRobot {
if (station == robot.getLinkedStation() && station == robot.getDockingStation()) {
terminate();
} else {
if (station.takeAsMain(robot)) {
if (station != null && station.takeAsMain(robot)) {
startDelegateAI(new AIRobotGotoBlock(robot,
station.x() + station.side().offsetX * 2,
station.y() + station.side().offsetY * 2,
@ -52,10 +52,10 @@ public class AIRobotGoAndLinkToDock extends AIRobot {
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotGotoBlock) {
if (ai.success()) {
startDelegateAI(new AIRobotStraightMoveTo(robot,
station.x() + 0.5F + station.side().offsetX * 0.5F,
station.y() + 0.5F + station.side().offsetY * 0.5F,
station.z() + 0.5F + station.side().offsetZ * 0.5F));
startDelegateAI(new AIRobotStraightMoveTo(robot,
station.x() + 0.5F + station.side().offsetX * 0.5F,
station.y() + 0.5F + station.side().offsetY * 0.5F,
station.z() + 0.5F + station.side().offsetZ * 0.5F));
} else {
terminate();
}

View file

@ -15,7 +15,7 @@ import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.lib.inventory.filters.IStackFilter;
import buildcraft.robotics.ai.AIRobotBreak;
import buildcraft.robotics.ai.AIRobotFetchAndEquipItemStack;
import buildcraft.robotics.ai.AIRobotSleep;
import buildcraft.robotics.ai.AIRobotGotoSleep;
public abstract class BoardRobotGenericBreakBlock extends BoardRobotGenericSearchBlock {
@ -45,7 +45,7 @@ public abstract class BoardRobotGenericBreakBlock extends BoardRobotGenericSearc
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotFetchAndEquipItemStack) {
if (!ai.success()) {
startDelegateAI(new AIRobotSleep(robot));
startDelegateAI(new AIRobotGotoSleep(robot));
}
} else if (ai instanceof AIRobotBreak) {
releaseBlockFound(ai.success());

View file

@ -112,7 +112,12 @@ public class TileStampingTable extends TileLaserTableBase implements IHasWork, I
NBTTagCompound tag = NBTUtils.getItemData(input);
for (int i = 0; i < 9; i++) {
if (tag.hasKey("item" + i)) {
crafting.setInventorySlotContents(i, ItemStack.loadItemStackFromNBT(tag.getCompoundTag("item" + i)));
ItemStack is = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("item" + i));
if (is != null) {
crafting.setInventorySlotContents(i, is);
} else {
return;
}
} else {
crafting.setInventorySlotContents(i, null);
}

View file

@ -47,18 +47,22 @@ public class PackageFontRenderer extends FontRenderer {
if (pkgTag.hasKey("item" + slotPos)) {
ItemStack slotStack = ItemStack.loadItemStackFromNBT(pkgTag.getCompoundTag("item" + slotPos));
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
GL11.glScalef(0.5F, 0.5F, 0.5F);
FontRenderer font = slotStack.getItem().getFontRenderer(slotStack);
itemRender.zLevel = 200.0F;
if (slotStack != null) {
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
GL11.glScalef(0.5F, 0.5F, 0.5F);
FontRenderer font = slotStack.getItem().getFontRenderer(slotStack);
itemRender.zLevel = 200.0F;
if (font == null || font instanceof PackageFontRenderer) {
font = Minecraft.getMinecraft().fontRenderer;
if (font == null || font instanceof PackageFontRenderer) {
font = Minecraft.getMinecraft().fontRenderer;
}
itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), slotStack, rx * 2, y * 2);
itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), slotStack, rx * 2, y * 2);
itemRender.zLevel = 0.0F;
} else {
realRenderer.drawString("X", rx, y, 0xFF0000);
}
itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), slotStack, rx * 2, y * 2);
itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), slotStack, rx * 2, y * 2);
itemRender.zLevel = 0.0F;
}
rx += 7;

View file

@ -226,9 +226,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
return;
}
if (fluidType != null) {
moveFluids();
}
moveFluids();
if (networkSyncTracker.markTimeIfDelay(container.getWorldObj())) {
boolean init = false;
@ -245,17 +243,22 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
}
private void moveFluids() {
short newTimeSlot = (short) (container.getWorldObj().getTotalWorldTime() % travelDelay);
short outputCount = computeCurrentConnectionStatesAndTickFlows(newTimeSlot > 0 && newTimeSlot < travelDelay ? newTimeSlot : 0);
if (fluidType != null) {
short newTimeSlot = (short) (container.getWorldObj().getTotalWorldTime() % travelDelay);
int outputCount = computeCurrentConnectionStatesAndTickFlows(newTimeSlot > 0 && newTimeSlot < travelDelay ? newTimeSlot : 0);
moveFromPipe(outputCount);
moveFromCenter();
moveToCenter();
if (fluidType != null) {
moveFromPipe(outputCount);
moveFromCenter();
moveToCenter();
}
} else {
computeTTLs();
}
}
private void moveFromPipe(short outputCount) {
private void moveFromPipe(int outputCount) {
// Move liquid from the non-center to the connected output blocks
boolean pushed = false;
if (outputCount > 0) {
for (ForgeDirection o : directions) {
if (transferState[o.ordinal()] == TransferState.Output) {
@ -270,7 +273,6 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
if (liquidToPush.amount > 0) {
int filled = ((IFluidHandler) target).fill(o.getOpposite(), liquidToPush, true);
section.drain(filled, true);
pushed = true;
if (filled <= 0) {
outputTTL[o.ordinal()]--;
}
@ -278,19 +280,6 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
}
}
}
if (pushed) {
boolean hasFluid = false;
for (PipeSection s: sections) {
if (s.amount > 0) {
hasFluid = true;
break;
}
}
if (!hasFluid) {
setFluidType(null);
}
}
}
private void moveFromCenter() {
@ -361,43 +350,76 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
}
}
private short computeCurrentConnectionStatesAndTickFlows(short newTimeSlot) {
short outputCount = 0;
private void computeTTLs() {
for (int i = 0; i < 6; i++) {
if (transferState[i] == TransferState.Input) {
if (inputTTL[i] > 0) {
inputTTL[i]--;
} else {
transferState[i] = TransferState.None;
}
}
// Processes all interna4al tanks
if (outputCooldown[i] > 0) {
outputCooldown[i]--;
} else {
if (outputTTL[i] > 0) {
outputTTL[i]--;
} else {
transferState[i] = TransferState.None;
}
}
}
}
private int computeCurrentConnectionStatesAndTickFlows(short newTimeSlot) {
int outputCount = 0;
int fluidAmount = 0;
// Processes all internal tanks
for (ForgeDirection direction : orientations) {
sections[direction.ordinal()].setTime(newTimeSlot);
sections[direction.ordinal()].moveFluids();
int dirI = direction.ordinal();
PipeSection section = sections[dirI];
fluidAmount += section.amount;
section.setTime(newTimeSlot);
section.moveFluids();
// Input processing
if (direction == ForgeDirection.UNKNOWN) {
continue;
}
if (transferState[direction.ordinal()] == TransferState.Input) {
inputTTL[direction.ordinal()]--;
if (inputTTL[direction.ordinal()] <= 0) {
transferState[direction.ordinal()] = TransferState.None;
if (transferState[dirI] == TransferState.Input) {
inputTTL[dirI]--;
if (inputTTL[dirI] <= 0) {
transferState[dirI] = TransferState.None;
}
continue;
}
if (!container.pipe.outputOpen(direction)) {
transferState[direction.ordinal()] = TransferState.None;
transferState[dirI] = TransferState.None;
continue;
}
if (outputCooldown[direction.ordinal()] > 0) {
outputCooldown[direction.ordinal()]--;
if (outputCooldown[dirI] > 0) {
outputCooldown[dirI]--;
continue;
}
if (outputTTL[direction.ordinal()] <= 0) {
transferState[direction.ordinal()] = TransferState.None;
outputCooldown[direction.ordinal()] = OUTPUT_COOLDOWN;
outputTTL[direction.ordinal()] = OUTPUT_TTL;
if (outputTTL[dirI] <= 0) {
transferState[dirI] = TransferState.None;
outputCooldown[dirI] = OUTPUT_COOLDOWN;
outputTTL[dirI] = OUTPUT_TTL;
continue;
}
if (canReceiveCache[direction.ordinal()] && outputOpen(direction)) {
transferState[direction.ordinal()] = TransferState.Output;
if (canReceiveCache[dirI] && outputOpen(direction)) {
transferState[dirI] = TransferState.Output;
outputCount++;
}
}
if (fluidAmount == 0) {
setFluidType(null);
}
return outputCount;
}