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

This commit is contained in:
Adrian 2015-07-23 18:58:36 +02:00
commit bf9ea681b3
20 changed files with 199 additions and 92 deletions

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.16"
version = "7.0.17"
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,16 @@
Improvements:
* Packages can now be thrown via Dispensers and Stripes Pipes (asie)
Bugs fixed:
* [#2904] Crash on corrupt facade (asie)
* [#2892] Disconnect on large-resolution Zone Planner fullscreen (asie)
* [#2891] Boxes ignoring the south and east boundaries when rounding (hea3ven)
* Accidentally setting an area in the Zone Planner GUI upon pressing fullscreen (asie)
* Compact Lens->Filter "diodes" not acting correctly (asie)
* Gate Copiers not clearing correctly (asie)
* Paintbrush not being re-dyeable if not fully used (asie)
* Robots going to unreachable stations passing through walls (hea3ven)
* Stripes Pipe "breaking" fluid blocks (asie)
* Wrench failing to rotate double chests and beds (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.16
1.7.10:BuildCraft:7.0.17

View file

@ -609,10 +609,12 @@ public class BuildCraftCore extends BuildCraftMod {
CoreProxy.proxy.addCraftingRecipe(new ItemStack(paintbrushItem), " iw", " gi", "s ",
's', "stickWood", 'g', "gearWood", 'w', new ItemStack(Blocks.wool, 1, 0), 'i', Items.string);
ItemStack anyPaintbrush = new ItemStack(paintbrushItem, 1, OreDictionary.WILDCARD_VALUE);
for (int i = 0; i < 16; i++) {
ItemStack outputStack = new ItemStack(paintbrushItem);
NBTUtils.getItemData(outputStack).setByte("color", (byte) i);
CoreProxy.proxy.addShapelessRecipe(outputStack, paintbrushItem, EnumColor.fromId(i).getDye());
CoreProxy.proxy.addShapelessRecipe(outputStack, anyPaintbrush, EnumColor.fromId(i).getDye());
}
if (Loader.isModLoaded("BuildCraft|Silicon")) {

View file

@ -9,6 +9,7 @@
package buildcraft;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDispenser;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
@ -55,6 +56,7 @@ import buildcraft.silicon.TilePackager;
import buildcraft.silicon.TileProgrammingTable;
import buildcraft.silicon.TileStampingTable;
import buildcraft.silicon.network.PacketHandlerSilicon;
import buildcraft.transport.stripes.StripesHandlerDispenser;
@Mod(name = "BuildCraft Silicon", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Silicon", dependencies = DefaultProps.DEPENDENCY_CORE)
public class BuildCraftSilicon extends BuildCraftMod {
@ -143,6 +145,9 @@ public class BuildCraftSilicon extends BuildCraftMod {
loadRecipes();
}
BlockDispenser.dispenseBehaviorRegistry.putObject(packageItem, new ItemPackage.DispenseBehaviour());
StripesHandlerDispenser.items.add(packageItem);
SiliconProxy.proxy.registerRenderers();
}

View file

@ -17,6 +17,7 @@ import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import buildcraft.api.core.BlockIndex;
import buildcraft.api.core.IAreaProvider;
@ -155,6 +156,10 @@ public class Box implements IBox, ISerializable {
@Override
public boolean contains(double x, double y, double z) {
return contains(MathHelper.floor_double(x), MathHelper.floor_double(y), MathHelper.floor_double(z));
}
public boolean contains(int x, int y, int z) {
return x >= xMin && x <= xMax && y >= yMin && y <= yMax && z >= zMin && z <= zMax;
}

View file

@ -12,6 +12,7 @@ import java.util.HashSet;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBed;
import net.minecraft.block.BlockButton;
import net.minecraft.block.BlockChest;
import net.minecraft.block.BlockLever;
@ -22,10 +23,11 @@ import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.tools.IToolWrench;
import buildcraft.core.lib.items.ItemBuildCraft;
import buildcraft.core.lib.utils.BlockUtils;
public class ItemWrench extends ItemBuildCraft implements IToolWrench {
private final Set<Class<? extends Block>> shiftRotations = new HashSet<Class<? extends Block>>();
private final Set<Class<? extends Block>> blacklistedRotations = new HashSet<Class<? extends Block>>();
public ItemWrench() {
super();
@ -35,11 +37,12 @@ public class ItemWrench extends ItemBuildCraft implements IToolWrench {
shiftRotations.add(BlockLever.class);
shiftRotations.add(BlockButton.class);
shiftRotations.add(BlockChest.class);
blacklistedRotations.add(BlockBed.class);
setHarvestLevel("wrench", 0);
}
private boolean isShiftRotation(Class<? extends Block> cls) {
for (Class<? extends Block> shift : shiftRotations) {
private boolean isClass(Set<Class<? extends Block>> set, Class<? extends Block> cls) {
for (Class<? extends Block> shift : set) {
if (shift.isAssignableFrom(cls)) {
return true;
}
@ -51,11 +54,16 @@ public class ItemWrench extends ItemBuildCraft implements IToolWrench {
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
Block block = world.getBlock(x, y, z);
if (block == null) {
if (block == null || isClass(blacklistedRotations, block.getClass())) {
return false;
}
if (player.isSneaking() != isShiftRotation(block.getClass())) {
if (player.isSneaking() != isClass(shiftRotations, block.getClass())) {
return false;
}
// Double chests should NOT be rotated.
if (block instanceof BlockChest && BlockUtils.getOtherDoubleChest(world.getTileEntity(x, y, z)) != null) {
return false;
}

View file

@ -22,6 +22,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.IInvSlot;
import buildcraft.core.lib.inventory.filters.IStackFilter;
import buildcraft.core.lib.utils.BlockUtils;
public final class InvUtils {
@ -218,26 +219,7 @@ public final class InvUtils {
*/
public static IInventory getInventory(IInventory inv) {
if (inv instanceof TileEntityChest) {
TileEntityChest chest = (TileEntityChest) inv;
TileEntityChest adjacent = null;
if (chest.adjacentChestXNeg != null) {
adjacent = chest.adjacentChestXNeg;
}
if (chest.adjacentChestXPos != null) {
adjacent = chest.adjacentChestXPos;
}
if (chest.adjacentChestZNeg != null) {
adjacent = chest.adjacentChestZNeg;
}
if (chest.adjacentChestZPos != null) {
adjacent = chest.adjacentChestZPos;
}
TileEntityChest adjacent = BlockUtils.getOtherDoubleChest((TileEntityChest) inv);
if (adjacent != null) {
return new InventoryLargeChest("", inv, adjacent);
}

View file

@ -20,14 +20,13 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.server.S27PacketExplosion;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;
@ -302,4 +301,31 @@ public final class BlockUtils {
}
return done;
}
public static TileEntityChest getOtherDoubleChest(TileEntity inv) {
if (inv instanceof TileEntityChest) {
TileEntityChest chest = (TileEntityChest) inv;
TileEntityChest adjacent = null;
if (chest.adjacentChestXNeg != null) {
adjacent = chest.adjacentChestXNeg;
}
if (chest.adjacentChestXPos != null) {
adjacent = chest.adjacentChestXPos;
}
if (chest.adjacentChestZNeg != null) {
adjacent = chest.adjacentChestZNeg;
}
if (chest.adjacentChestZPos != null) {
adjacent = chest.adjacentChestZPos;
}
return adjacent;
}
return null;
}
}

View file

@ -261,23 +261,19 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
public void readData(ByteBuf stream) {
for (int i = 0; i < 6; i++) {
blockedSides[i] = stream.readBoolean();
System.out.println("Rsides=" + i + "=" + blockedSides[i]);
}
}
@Override
public void writeData(ByteBuf stream) {
for (int i = 0; i < 6; i++) {
System.out.println("Wsides=" + i + "=" + blockedSides[i]);
stream.writeBoolean(blockedSides[i]);
}
}
public void switchSide(ForgeDirection side) {
System.out.println("Csides=" + side.ordinal() + "=" + blockedSides[side.ordinal()]);
if (side.ordinal() != 1) {
blockedSides[side.ordinal()] = !blockedSides[side.ordinal()];
System.out.println("Ssides=" + side.ordinal() + "=" + blockedSides[side.ordinal()]);
rebuildQueue();
sendNetworkUpdate();

View file

@ -65,10 +65,14 @@ public class AIRobotGotoStation extends AIRobot {
if (station == null) {
terminate();
} else if (ai instanceof AIRobotGotoBlock) {
startDelegateAI(new AIRobotStraightMoveTo(robot,
stationIndex.x + 0.5F + stationSide.offsetX * 0.5F,
stationIndex.y + 0.5F + stationSide.offsetY * 0.5F,
stationIndex.z + 0.5F + stationSide.offsetZ * 0.5F));
if (ai.success()) {
startDelegateAI(new AIRobotStraightMoveTo(robot,
stationIndex.x + 0.5F + stationSide.offsetX * 0.5F,
stationIndex.y + 0.5F + stationSide.offsetY * 0.5F,
stationIndex.z + 0.5F + stationSide.offsetZ * 0.5F));
} else {
terminate();
}
} else {
setSuccess(true);
if (stationSide.offsetY == 0) {

View file

@ -27,8 +27,10 @@ import buildcraft.core.lib.network.command.PacketCommand;
import buildcraft.core.lib.render.DynamicTextureBC;
import buildcraft.core.lib.utils.NetworkUtils;
import buildcraft.robotics.TileZonePlan;
import buildcraft.robotics.map.MapWorld;
public class ContainerZonePlan extends BuildCraftContainer implements ICommandReceiver {
private static final int MAX_PACKET_LENGTH = 30000;
public DynamicTextureBC mapTexture;
public ZonePlan currentAreaSelection;
@ -92,9 +94,10 @@ public class ContainerZonePlan extends BuildCraftContainer implements ICommandRe
gui.refreshSelectedArea();
} else if ("receiveImage".equals(command)) {
int size = stream.readUnsignedMedium();
int pos = stream.readUnsignedMedium();
for (int i = 0; i < size; ++i) {
mapTexture.colorMap[i] = 0xFF000000 | MapColor.mapColorArray[stream.readUnsignedByte()].colorValue;
for (int i = 0; i < Math.min(size - pos, MAX_PACKET_LENGTH); ++i) {
mapTexture.colorMap[pos + i] = 0xFF000000 | MapColor.mapColorArray[stream.readUnsignedByte()].colorValue;
}
}
} else if (side.isServer()) {
@ -123,28 +126,36 @@ public class ContainerZonePlan extends BuildCraftContainer implements ICommandRe
private void computeMap(int cx, int cz, int width, int height, int blocksPerPixel, EntityPlayer player) {
final byte[] textureData = new byte[width * height];
MapWorld w = BuildCraftRobotics.manager.getWorld(map.getWorldObj());
int startX = cx - width * blocksPerPixel / 2;
int startZ = cz - height * blocksPerPixel / 2;
int mapStartX = map.chunkStartX << 4;
int mapStartZ = map.chunkStartZ << 4;
for (int i = 0; i < width; ++i) {
for (int j = 0; j < height; ++j) {
int x = startX + i * blocksPerPixel;
int z = startZ + j * blocksPerPixel;
int ix = x - (map.chunkStartX << 4);
int iz = z - (map.chunkStartZ << 4);
int ix = x - mapStartX;
int iz = z - mapStartZ;
if (ix >= 0 && iz >= 0 && ix < TileZonePlan.RESOLUTION && iz < TileZonePlan.RESOLUTION) {
textureData[i + j * width] = (byte) BuildCraftRobotics.manager.getWorld(map.getWorldObj())
.getColor(x, z);
textureData[i + j * width] = (byte) w.getColor(x, z);
}
}
}
BuildCraftCore.instance.sendToPlayer(player, new PacketCommand(this, "receiveImage", new CommandWriter() {
public void write(ByteBuf data) {
data.writeMedium(textureData.length);
data.writeBytes(textureData);
}
}));
final int len = MAX_PACKET_LENGTH;
for (int i = 0; i < textureData.length; i += len) {
final int pos = i;
BuildCraftCore.instance.sendToPlayer(player, new PacketCommand(this, "receiveImage", new CommandWriter() {
public void write(ByteBuf data) {
data.writeMedium(textureData.length);
data.writeMedium(pos);
data.writeBytes(textureData, pos, Math.min(textureData.length - pos, len));
}
}));
}
}
}

View file

@ -234,10 +234,6 @@ public class GuiZonePlan extends GuiAdvancedInterface {
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton);
textField.mouseClicked(mouseX - guiLeft, mouseY - guiTop, mouseButton);
int blocksX = (mouseX - mapXMin) * zoomLevel;
int blocksZ = (mouseY - mapYMin) * zoomLevel;
@ -255,22 +251,27 @@ public class GuiZonePlan extends GuiAdvancedInterface {
uploadMap();
refreshSelectedArea();
return;
} else {
inSelection = true;
selX1 = mouseX;
selY1 = mouseY;
selX2 = 0;
selY2 = 0;
return;
}
} else {
AdvancedSlot slot = getSlotAtLocation(mouseX, mouseY);
}
if (slot instanceof AreaSlot) {
colorSelected = (AreaSlot) slot;
super.mouseClicked(mouseX, mouseY, mouseButton);
textField.mouseClicked(mouseX - guiLeft, mouseY - guiTop, mouseButton);
newSelection.setColor(0, 0, colorSelected.color.getDarkHex(), alpha);
getContainer().loadArea(colorSelected.color.ordinal());
}
AdvancedSlot slot = getSlotAtLocation(mouseX, mouseY);
if (slot instanceof AreaSlot) {
colorSelected = (AreaSlot) slot;
newSelection.setColor(0, 0, colorSelected.color.getDarkHex(), alpha);
getContainer().loadArea(colorSelected.color.ordinal());
}
}

View file

@ -25,6 +25,11 @@ public class EntityPackage extends EntityThrowable {
this.pkg = stack;
}
public EntityPackage(World world, double x, double y, double z, ItemStack stack) {
super(world, x, y, z);
this.pkg = stack;
}
@Override
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);

View file

@ -2,12 +2,16 @@ package buildcraft.silicon;
import java.util.List;
import net.minecraft.block.BlockDispenser;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -17,6 +21,25 @@ import buildcraft.core.lib.utils.NBTUtils;
import buildcraft.silicon.render.PackageFontRenderer;
public class ItemPackage extends ItemBuildCraft {
public static final class DispenseBehaviour extends BehaviorDefaultDispenseItem {
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
if (stack != null && stack.getItem() instanceof ItemPackage) {
World world = source.getWorld();
EnumFacing enumfacing = BlockDispenser.func_149937_b(source.getBlockMetadata());
EntityPackage entityPackage = new EntityPackage(source.getWorld(),
source.getX() + enumfacing.getFrontOffsetX(),
source.getY() + enumfacing.getFrontOffsetY(),
source.getZ() + enumfacing.getFrontOffsetZ(), stack.copy());
entityPackage.setThrowableHeading(enumfacing.getFrontOffsetX(), enumfacing.getFrontOffsetY() + 0.1F, enumfacing.getFrontOffsetZ(), 1.1F, 6.0F);
world.spawnEntityInWorld(entityPackage);
stack.splitStack(1);
}
return stack;
}
}
public ItemPackage() {
super();
setMaxStackSize(1);

View file

@ -156,7 +156,9 @@ public class ItemFacade extends ItemBuildCraft implements IFacadeItem, IPipePlug
public String getItemStackDisplayName(ItemStack itemstack) {
switch (getFacadeType(itemstack)) {
case Basic:
return super.getItemStackDisplayName(itemstack) + ": " + getFacadeStateDisplayName(getFacadeStates(itemstack)[0]);
FacadeState[] states = getFacadeStates(itemstack);
String displayName = states.length > 0 ? getFacadeStateDisplayName(states[0]) : "CORRUPT";
return super.getItemStackDisplayName(itemstack) + ": " + displayName;
case Phased:
return StringUtils.localize("item.FacadePhased.name");
default:

View file

@ -75,7 +75,10 @@ public class ItemGateCopier extends ItemBuildCraft {
player.addChatMessage(new ChatComponentTranslation("chat.gateCopier.clear"));
return true;
}
data = new NBTTagCompound();
stack.setTagCompound(data);
gate.writeStatementsToNBT(data);
data.setByte("material", (byte) gate.material.ordinal());
data.setByte("logic", (byte) gate.logic.ordinal());

View file

@ -22,12 +22,17 @@ public class LensFilterHandler {
for (ForgeDirection dir: event.destinations) {
int sideColor = -1;
int sideLensColor = -1;
// Get the side's color
// (1/2) From this pipe's outpost
PipePluggable pluggable = container.getPipePluggable(dir);
if (pluggable != null && pluggable instanceof LensPluggable && ((LensPluggable) pluggable).isFilter) {
sideColor = ((LensPluggable) pluggable).color;
if (pluggable != null && pluggable instanceof LensPluggable) {
if (((LensPluggable) pluggable).isFilter) {
sideColor = ((LensPluggable) pluggable).color;
} else {
sideLensColor = ((LensPluggable) pluggable).color;
}
}
// (2/2) From the other pipe's outpost
@ -37,8 +42,11 @@ public class LensFilterHandler {
pluggable = otherContainer.getPipePluggable(dir.getOpposite());
if (pluggable != null && pluggable instanceof LensPluggable && ((LensPluggable) pluggable).isFilter) {
int otherColor = ((LensPluggable) pluggable).color;
// Check if colors conflict - if so, the side is unpassable
if (sideColor >= 0 && otherColor != sideColor) {
// Filter colors conflict - the side is unpassable
continue;
} else if (sideLensColor != -1 && sideColor != otherColor) {
// The closer lens color differs from the further away filter color - the side is unpassable
continue;
} else {
sideColor = otherColor;

View file

@ -13,12 +13,14 @@ import java.util.Collection;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.IFluidBlock;
import cofh.api.energy.IEnergyHandler;
import buildcraft.BuildCraftTransport;
@ -216,7 +218,11 @@ public class PipeItemsStripes extends Pipe<PipeTransportItems> implements IEnerg
if (!BlockUtils.isUnbreakableBlock(getWorld(), (int) p.x, (int) p.y, (int) p.z)) {
Block block = getWorld().getBlock((int) p.x, (int) p.y, (int) p.z);
int metadata = getWorld().getBlockMetadata((int) p.x, (int) p.y, (int) p.z);
if (block instanceof BlockLiquid || block instanceof IFluidBlock) {
return maxReceive;
}
ItemStack stack = new ItemStack(block, 1, metadata);
EntityPlayer player = CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld(),
(int) p.x, (int) p.y, (int) p.z).get();

View file

@ -43,40 +43,44 @@ public class StripesHandlerBucket implements IStripesHandler {
ForgeDirection direction, ItemStack stack, EntityPlayer player,
IStripesActivator activator) {
if (world.isAirBlock(x, y, z)) {
Block underblock = world.getBlock(x, y - 1, z);
if (((ItemBucket) stack.getItem()).tryPlaceContainedLiquid(world, x, y - 1, z)) {
if (((ItemBucket) stack.getItem()).tryPlaceContainedLiquid(world, x, direction.ordinal() < 2 ? y : (y - 1), z)) {
activator.sendItem(emptyBucket, direction.getOpposite());
stack.stackSize--;
if (stack.stackSize > 0) {
activator.sendItem(stack, direction.getOpposite());
}
return true;
} else {
if (!FluidContainerRegistry.isEmptyContainer(stack)) {
activator.sendItem(stack, direction.getOpposite());
return true;
}
FluidStack fluidStack = BlockUtils.drainBlock(underblock, world, x, y - 1, z, true);
ItemStack filledBucket = getFilledBucket(fluidStack, underblock);
if (fluidStack == null || filledBucket == null) {
activator.sendItem(stack, direction.getOpposite());
return true;
}
activator.sendItem(filledBucket, direction.getOpposite());
stack.stackSize--;
if (stack.stackSize > 0) {
activator.sendItem(stack, direction.getOpposite());
}
return true;
}
}
return false;
if (!FluidContainerRegistry.isEmptyContainer(stack)) {
activator.sendItem(stack, direction.getOpposite());
return true;
}
Block targetBlock = world.getBlock(x, y, z);
FluidStack fluidStack = BlockUtils.drainBlock(targetBlock, world, x, y, z, true);
if (fluidStack == null) {
targetBlock = world.getBlock(x, y - 1, z);
fluidStack = BlockUtils.drainBlock(targetBlock, world, x, y - 1, z, true);
}
ItemStack filledBucket = getFilledBucket(fluidStack, targetBlock);
if (fluidStack == null || filledBucket == null) {
activator.sendItem(stack, direction.getOpposite());
return true;
}
activator.sendItem(filledBucket, direction.getOpposite());
stack.stackSize--;
if (stack.stackSize > 0) {
activator.sendItem(stack, direction.getOpposite());
}
return true;
}
}