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

This commit is contained in:
Adrian 2015-07-15 12:57:04 +02:00
commit 17b8dce6df
15 changed files with 192 additions and 85 deletions

View file

@ -22,12 +22,12 @@ apply plugin: 'forge' // adds the forge dependency
apply plugin: 'maven' // for uploading to a maven repo
apply plugin: 'checkstyle'
version = "7.0.15"
version = "7.0.16"
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]
minecraft {
version = "1.7.10-10.13.3.1388-1.7.10" // McVersion-ForgeVersion this variable is later changed to contain only the MC version, while the apiVersion variable is used for the forge version. Yeah its stupid, and will be changed eentually.
version = "1.7.10-10.13.4.1490-1.7.10" // McVersion-ForgeVersion this variable is later changed to contain only the MC version, while the apiVersion variable is used for the forge version. Yeah its stupid, and will be changed eentually.
runDir = "run" // the directory for ForgeGradle to run Minecraft in

View file

@ -1,5 +1,9 @@
Bugs fixed:
* [#2890] Integration Table messy extraction behaviour (asie)
* [#2889] Fix robots movement desync when going through fluids (hea3ven)
* Fix potential crash with invalid recipe in Stamping Table (asie)
* Fix the work in area and load/unload area allowing non map locations items as parameters (hea3ven)
* Fluid pipe behaviour regression (asie)
* Integrated hollow facade becoming non-hollow (asie)
* Rotating pipe orientation not working well in blueprints (asie)

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.15
1.7.10:BuildCraft:7.0.16

View file

@ -18,6 +18,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.client.event.ConfigChangedEvent;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
@ -33,6 +34,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
@ -143,6 +145,7 @@ import buildcraft.robotics.statements.ActionStationRequestItems;
import buildcraft.robotics.statements.ActionStationRequestItemsMachine;
import buildcraft.robotics.statements.RobotsActionProvider;
import buildcraft.robotics.statements.RobotsTriggerProvider;
import buildcraft.robotics.statements.StatementParameterMapLocation;
import buildcraft.robotics.statements.StatementParameterRobot;
import buildcraft.robotics.statements.TriggerRobotInStation;
import buildcraft.robotics.statements.TriggerRobotLinked;
@ -249,6 +252,7 @@ public class BuildCraftRobotics extends BuildCraftMod {
}
StatementManager.registerParameterClass(StatementParameterRobot.class);
StatementManager.registerParameterClass(StatementParameterMapLocation.class);
StatementManager.registerActionProvider(new RobotsActionProvider());
StatementManager.registerTriggerProvider(new RobotsTriggerProvider());
}

View file

@ -8,12 +8,12 @@
*/
package buildcraft.core.lib.utils;
public class Average {
public class AverageDouble {
private double[] data;
private int pos, precise;
private double averageRaw, tickValue;
public Average(int precise) {
public AverageDouble(int precise) {
this.precise = precise;
this.data = new double[precise];
this.pos = 0;

View file

@ -0,0 +1,53 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.lib.utils;
public class AverageInt {
private int[] data;
private int pos, precise;
private int averageRaw, tickValue;
public AverageInt(int precise) {
this.precise = precise;
this.data = new int[precise];
this.pos = 0;
}
public double getAverage() {
return (double) averageRaw / precise;
}
public void tick(int value) {
internalTick(tickValue + value);
tickValue = 0;
}
public void tick() {
internalTick(tickValue);
tickValue = 0;
}
private void internalTick(int value) {
pos = ++pos % precise;
int oldValue = data[pos];
data[pos] = value;
if (pos == 0) {
averageRaw = 0;
for (int iValue : data) {
averageRaw += iValue;
}
} else {
averageRaw = averageRaw - oldValue + value;
}
}
public void push(int value) {
tickValue += value;
}
}

View file

@ -33,6 +33,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.IAreaProvider;
import buildcraft.api.core.Position;
import buildcraft.api.power.IEngine;
import buildcraft.api.power.ILaserTarget;
import buildcraft.api.tiles.ITileAreaProvider;
import buildcraft.api.transport.IInjectable;
import buildcraft.api.transport.IPipeTile;
@ -91,7 +92,7 @@ public final class Utils {
TileEntity tileInventory = BlockUtils.getTileEntity(world, (int) pos.x, (int) pos.y, (int) pos.z);
ITransactor transactor = Transactor.getTransactorFor(tileInventory);
if (transactor != null && !(tileInventory instanceof IEngine) && transactor.add(stack, orientation.getOpposite(), false).stackSize > 0) {
if (transactor != null && !(tileInventory instanceof IEngine) && !(tileInventory instanceof ILaserTarget) && transactor.add(stack, orientation.getOpposite(), false).stackSize > 0) {
return transactor.add(stack, orientation.getOpposite(), true).stackSize;
}
}

View file

@ -365,6 +365,11 @@ public class EntityRobot extends EntityRobotBase implements
protected void updateEntityActionState() {
}
@Override
public boolean handleWaterMovement() {
return false;
}
@SideOnly(Side.CLIENT)
private void updateEnergyFX() {
energyFX += energySpendPerCycle;

View file

@ -16,7 +16,6 @@ import buildcraft.api.items.IMapLocation;
import buildcraft.api.statements.IActionInternal;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.StatementParameterItemStack;
import buildcraft.api.statements.StatementSlot;
import buildcraft.core.lib.utils.StringUtils;
import buildcraft.core.statements.BCStatement;
@ -91,7 +90,7 @@ public class ActionRobotWorkInArea extends BCStatement implements IActionInterna
@Override
public IStatementParameter createParameter(int index) {
return new StatementParameterItemStack();
return new StatementParameterMapLocation();
}
@Override

View file

@ -0,0 +1,25 @@
package buildcraft.robotics.statements;
import net.minecraft.item.ItemStack;
import buildcraft.api.items.IMapLocation;
import buildcraft.api.statements.IStatement;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.StatementMouseClick;
import buildcraft.api.statements.StatementParameterItemStack;
public class StatementParameterMapLocation extends StatementParameterItemStack {
@Override
public String getUniqueTag() {
return "buildcraft:maplocation";
}
@Override
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stackIn, StatementMouseClick mouse) {
ItemStack stack = stackIn;
if (stack != null && !(stack.getItem() instanceof IMapLocation)) {
stack = null;
}
super.onClick(source, stmt, stack, mouse);
}
}

View file

@ -15,7 +15,6 @@ import java.util.List;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -24,7 +23,6 @@ import net.minecraft.nbt.NBTTagString;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import buildcraft.BuildCraftCore;
@ -37,7 +35,6 @@ import buildcraft.core.lib.network.command.ICommandReceiver;
import buildcraft.core.lib.network.command.PacketCommand;
import buildcraft.core.lib.utils.NetworkUtils;
import buildcraft.core.lib.utils.StringUtils;
import buildcraft.core.lib.utils.Utils;
import buildcraft.core.recipes.AssemblyRecipeManager;
public class TileAssemblyTable extends TileLaserTableBase implements IInventory, IFlexibleCrafter, ICommandReceiver {
@ -95,23 +92,7 @@ public class TileAssemblyTable extends TileLaserTableBase implements IInventory,
setEnergy(0);
if (currentRecipe.canBeCrafted(this)) {
ItemStack remaining = currentRecipe.craft(this, false).crafted.copy();
if (remaining != null && remaining.stackSize > 0) {
remaining.stackSize -= Utils
.addToRandomInventoryAround(worldObj, xCoord, yCoord, zCoord, remaining);
}
if (remaining != null && remaining.stackSize > 0) {
remaining.stackSize -= Utils.addToRandomInjectableAround(worldObj, xCoord, yCoord, zCoord, ForgeDirection.UNKNOWN, remaining);
}
if (remaining != null && remaining.stackSize > 0) {
EntityItem entityitem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 0.7, zCoord + 0.5,
remaining);
worldObj.spawnEntityInWorld(entityitem);
}
outputStack(currentRecipe.craft(this, false).crafted.copy(), true);
setNextCurrentRecipe();
}

View file

@ -13,24 +13,22 @@ import java.util.List;
import io.netty.buffer.ByteBuf;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.recipes.BuildcraftRecipeRegistry;
import buildcraft.api.recipes.IIntegrationRecipe;
import buildcraft.core.lib.inventory.ITransactor;
import buildcraft.core.lib.inventory.InventoryMapper;
import buildcraft.core.lib.inventory.StackHelper;
import buildcraft.core.lib.inventory.Transactor;
import buildcraft.core.lib.utils.StringUtils;
import buildcraft.core.lib.utils.Utils;
public class TileIntegrationTable extends TileLaserTableBase {
public class TileIntegrationTable extends TileLaserTableBase implements ISidedInventory {
public static final int SLOT_OUTPUT = 9;
private static final int CYCLE_LENGTH = 16;
private static final int[] SLOTS = Utils.createSlotArray(0, 10);
private int tick = 0;
private IIntegrationRecipe activeRecipe;
private boolean activeRecipeValid = false;
private InventoryMapper mappedOutput = new InventoryMapper(this, SLOT_OUTPUT, 1, false);
private int maxExpCountClient;
@Override
@ -72,9 +70,6 @@ public class TileIntegrationTable extends TileLaserTableBase {
output = activeRecipe.craft(getStackInSlot(0), getExpansions(), false);
if (output != null) {
ITransactor trans = Transactor.getTransactorFor(mappedOutput);
trans.add(output, ForgeDirection.UP, true);
ItemStack input = getStackInSlot(0);
if (input.stackSize > output.stackSize) {
@ -83,6 +78,8 @@ public class TileIntegrationTable extends TileLaserTableBase {
setInventorySlotContents(0, null);
}
outputStack(output, this, 9, false);
for (int i = 1; i < 9; i++) {
if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) {
setInventorySlotContents(i, null);
@ -184,10 +181,9 @@ public class TileIntegrationTable extends TileLaserTableBase {
} else if (activeRecipe == null) {
return false;
} else if (slot < 9) {
if (activeRecipe.getMaximumExpansionCount(getStackInSlot(0)) > 0) {
if (slot > activeRecipe.getMaximumExpansionCount(getStackInSlot(0))) {
return false;
}
int expansionCount = activeRecipe.getMaximumExpansionCount(getStackInSlot(0));
if (expansionCount > 0 && slot > expansionCount) {
return false;
}
return activeRecipe.isValidExpansion(getStackInSlot(0), stack);
} else {
@ -250,4 +246,31 @@ public class TileIntegrationTable extends TileLaserTableBase {
private void updateRecipe() {
setNewActiveRecipe();
}
@Override
public int[] getAccessibleSlotsFromSide(int side) {
return SLOTS;
}
@Override
public boolean canInsertItem(int slot, ItemStack stack, int side) {
if (slot == 0) {
return true;
} else if (activeRecipe == null) {
return false;
} else if (slot < 9) {
int expansionCount = activeRecipe.getMaximumExpansionCount(getStackInSlot(0));
if (expansionCount > 0 && slot > expansionCount) {
return false;
}
return true;
} else {
return false;
}
}
@Override
public boolean canExtractItem(int slot, ItemStack stack, int side) {
return slot == 9;
}
}

View file

@ -8,26 +8,29 @@
*/
package buildcraft.silicon;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.power.ILaserTarget;
import buildcraft.api.tiles.IHasWork;
import buildcraft.core.lib.block.TileBuildCraft;
import buildcraft.core.lib.inventory.SimpleInventory;
import buildcraft.core.lib.utils.Average;
import buildcraft.core.lib.inventory.StackHelper;
import buildcraft.core.lib.utils.AverageInt;
import buildcraft.core.lib.utils.Utils;
public abstract class TileLaserTableBase extends TileBuildCraft implements ILaserTarget, IInventory, IHasWork {
public int clientRequiredEnergy = 0;
protected SimpleInventory inv = new SimpleInventory(getSizeInventory(), "inv", 64);
private int energy = 0;
private int recentEnergyAverage;
private Average recentEnergyAverageUtil = new Average(20);
private AverageInt recentEnergyAverageUtil = new AverageInt(20);
@Override
public void updateEntity() {
@ -112,7 +115,7 @@ public abstract class TileLaserTableBase extends TileBuildCraft implements ILase
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
return null;
return inv.getStackInSlotOnClosing(slot);
}
@Override
@ -152,6 +155,41 @@ public abstract class TileLaserTableBase extends TileBuildCraft implements ILase
energy = nbt.getInteger("energy");
}
protected void outputStack(ItemStack remaining, boolean autoEject) {
outputStack(remaining, null, 0, autoEject);
}
protected void outputStack(ItemStack remaining, IInventory inv, int slot, boolean autoEject) {
if (autoEject) {
if (remaining != null && remaining.stackSize > 0) {
remaining.stackSize -= Utils
.addToRandomInventoryAround(worldObj, xCoord, yCoord, zCoord, remaining);
}
if (remaining != null && remaining.stackSize > 0) {
remaining.stackSize -= Utils.addToRandomInjectableAround(worldObj, xCoord, yCoord, zCoord, ForgeDirection.UNKNOWN, remaining);
}
}
if (inv != null && remaining != null && remaining.stackSize > 0) {
ItemStack inside = inv.getStackInSlot(slot);
if (inside == null || inside.stackSize <= 0) {
inv.setInventorySlotContents(slot, remaining);
return;
} else if (StackHelper.canStacksMerge(inside, remaining)) {
remaining.stackSize -= StackHelper.mergeStacks(remaining, inside, true);
}
}
if (remaining != null && remaining.stackSize > 0) {
EntityItem entityitem = new EntityItem(worldObj, xCoord + 0.5, yCoord + 0.7, zCoord + 0.5,
remaining);
worldObj.spawnEntityInWorld(entityitem);
}
}
public void getGUINetworkData(int id, int data) {
int currentStored = energy;
int requiredEnergy = clientRequiredEnergy;

View file

@ -18,7 +18,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftCore;
import buildcraft.api.recipes.BuildcraftRecipeRegistry;
@ -28,7 +27,6 @@ import buildcraft.core.lib.network.command.ICommandReceiver;
import buildcraft.core.lib.network.command.PacketCommand;
import buildcraft.core.lib.utils.NetworkUtils;
import buildcraft.core.lib.utils.StringUtils;
import buildcraft.core.lib.utils.Utils;
public class TileProgrammingTable extends TileLaserTableBase implements IInventory, ISidedInventory, ICommandReceiver {
public static final int WIDTH = 6;
@ -67,27 +65,13 @@ public class TileProgrammingTable extends TileLaserTableBase implements IInvento
return;
}
if (optionId >= 0 && this.getStackInSlot(1) == null && getEnergy() >= currentRecipe.getEnergyCost(options.get(optionId))) {
if (optionId >= 0 && getEnergy() >= currentRecipe.getEnergyCost(options.get(optionId))) {
if (currentRecipe.canCraft(this.getStackInSlot(0))) {
ItemStack remaining = currentRecipe.craft(this.getStackInSlot(0), options.get(optionId));
if (remaining != null && remaining.stackSize > 0) {
setEnergy(0);
this.decrStackSize(0, remaining.stackSize);
if (remaining.stackSize > 0) {
remaining.stackSize -= Utils
.addToRandomInventoryAround(worldObj, xCoord, yCoord, zCoord, remaining);
}
if (remaining.stackSize > 0) {
remaining.stackSize -= Utils.addToRandomInjectableAround(worldObj, xCoord, yCoord, zCoord, ForgeDirection.UNKNOWN, remaining);
}
if (remaining.stackSize > 0) {
this.setInventorySlotContents(1, remaining);
} else {
this.setInventorySlotContents(1, null);
}
decrStackSize(0, remaining.stackSize);
outputStack(remaining, this, 1, false);
}
}
findRecipe();

View file

@ -134,33 +134,23 @@ public class TileStampingTable extends TileLaserTableBase implements IHasWork, I
IRecipe recipe = crafting.findRecipe();
ItemStack result = recipe != null ? recipe.getCraftingResult(crafting).copy() : null;
ItemStack resultInto = this.getStackInSlot(1);
if (recipe == null || result == null || result.stackSize <= 0) {
if (resultInto == null || StackHelper.canStacksMerge(input, resultInto)) {
this.setInventorySlotContents(0, null);
this.setInventorySlotContents(1, input);
}
return;
} else if (resultInto != null &&
(!StackHelper.canStacksMerge(result, resultInto) ||
resultInto.stackSize + result.stackSize > result.getMaxStackSize())) {
return;
}
addEnergy(-getRequiredEnergy());
craftSlot.onPickupFromSlot(internalPlayer, result);
handleLeftoverItems(crafting);
handleLeftoverItems(internalPlayer.inventory);
if (result != null) {
craftSlot.onPickupFromSlot(internalPlayer, result);
handleLeftoverItems(crafting);
handleLeftoverItems(internalPlayer.inventory);
if (resultInto == null) {
setInventorySlotContents(1, result);
outputStack(result, this, 1, false);
decrStackSize(0, 1);
} else {
resultInto.stackSize += result.stackSize;
ItemStack outputSlot = getStackInSlot(1);
if (outputSlot == null) {
setInventorySlotContents(1, getStackInSlot(0));
setInventorySlotContents(0, null);
}
}
decrStackSize(0, 1);
}
}