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

This commit is contained in:
asiekierka 2015-03-03 20:08:16 +01:00
commit 727c0e205b
43 changed files with 465 additions and 248 deletions

View file

@ -36,6 +36,7 @@ public enum EnumColor {
MAGENTA,
ORANGE,
WHITE;
public static final EnumColor[] VALUES = values();
public static final String[] DYES = {
"dyeBlack",

View file

@ -0,0 +1,8 @@
package buildcraft.api.items;
import net.minecraft.item.ItemStack;
public interface IList {
String getLabel(ItemStack stack);
boolean matches(ItemStack stackList, ItemStack item);
}

View file

@ -0,0 +1,57 @@
package buildcraft.api.items;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.BlockIndex;
import buildcraft.api.core.IBox;
import buildcraft.api.core.IZone;
/**
* Created by asie on 2/28/15.
*/
public interface IMapLocation {
public enum MapLocationType {
CLEAN, SPOT, AREA, PATH, ZONE
}
MapLocationType getType(ItemStack stack);
/**
* This function can be used for SPOT types.
* @param stack
* @return The point representing the map location.
*/
BlockIndex getPoint(ItemStack stack);
/**
* This function can be used for SPOT and AREA types.
* @param stack
* @return The box representing the map location.
*/
IBox getBox(ItemStack stack);
/**
* This function can be used for SPOT, AREA and ZONE types.
* The PATH type needs to be handled separately.
* @param stack
* @return An IZone representing the map location - also an instance of
* IBox for SPOT and AREA types.
*/
IZone getZone(ItemStack stack);
/**
* This function can be used for SPOT and PATH types.
* @param stack
* @return A list of BlockIndexes representing the path the Map Location
* stores.
*/
List<BlockIndex> getPath(ItemStack stack);
/**
* This function can be used for SPOT types only.
* @param stack
* @return The side of the spot.
*/
ForgeDirection getPointSide(ItemStack stack);
}

View file

@ -0,0 +1,12 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|items")
package buildcraft.api.items;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,16 @@
Additions:
* IList, IMapLocation APIs for modders in the new buildcraft.api.items
Bugfixes:
* [#2518] Exceptions in Pump Robots (hea3ven)
* [#2517] Programming Table crash in certain Java configurations (asie)
* [#2510] Entity stripes handler duplicating items (hea3ven)
* {#2509] Robot gets stuck in recharge mode (asie)
* [#2506] Builder causes lag in 6.4.1 (asie)
* [#2502] Combustion Engine not recognized as tank from front (asie)
* Incorrect Forge version dependency (Vexatos)
* Infinite loop when looping through direction parameters and no pipes are connected (hea3ven)
* Invalid power scale for laser colours (asie)
* Low/High Energy Stored trigger works as expected again (asie)
* Robots fly away when searching for a station to recharge (hea3ven)
* Robots are charged wirelessly (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:6.4.1
1.7.10:BuildCraft:6.4.2

View file

@ -185,7 +185,7 @@ import buildcraft.robots.boards.BoardRobotPump;
import buildcraft.robots.boards.BoardRobotShovelman;
import buildcraft.robots.boards.BoardRobotStripes;
@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.7.10,1.8)", dependencies = "required-after:Forge@[10.13.0.1236,)")
@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.7.10,1.8)", dependencies = "required-after:Forge@[10.13.2.1236,)")
public class BuildCraftCore extends BuildCraftMod {
@Mod.Instance("BuildCraft|Core")
@ -215,7 +215,7 @@ public class BuildCraftCore extends BuildCraftMod {
public static Item diamondGearItem;
public static Item wrenchItem;
public static Item mapLocationItem;
public static Item listItem;
public static ItemList listItem;
@SideOnly(Side.CLIENT)
public static IIcon redLaserTexture;
@SideOnly(Side.CLIENT)
@ -347,7 +347,7 @@ public class BuildCraftCore extends BuildCraftMod {
mapLocationItem = (new ItemMapLocation()).setUnlocalizedName("mapLocation");
CoreProxy.proxy.registerItem(mapLocationItem);
listItem = (new ItemList()).setUnlocalizedName("list");
listItem = (ItemList) ((new ItemList()).setUnlocalizedName("list"));
CoreProxy.proxy.registerItem(listItem);
Property modifyWorldProp = BuildCraftCore.mainConfiguration.get("general", "modifyWorld", true);

View file

@ -151,6 +151,7 @@ import buildcraft.transport.statements.TriggerRedstoneFaderInput;
import buildcraft.transport.stripes.StripesHandlerArrow;
import buildcraft.transport.stripes.StripesHandlerBucket;
import buildcraft.transport.stripes.StripesHandlerEntityInteract;
import buildcraft.transport.stripes.StripesHandlerHoe;
import buildcraft.transport.stripes.StripesHandlerPipes;
import buildcraft.transport.stripes.StripesHandlerPlaceBlock;
import buildcraft.transport.stripes.StripesHandlerRightClick;
@ -467,6 +468,7 @@ public class BuildCraftTransport extends BuildCraftMod {
PipeManager.registerStripesHandler(new StripesHandlerPipes());
PipeManager.registerStripesHandler(new StripesHandlerEntityInteract());
PipeManager.registerStripesHandler(new StripesHandlerPlaceBlock());
PipeManager.registerStripesHandler(new StripesHandlerHoe());
PipeManager.registerPipePluggable(FacadePluggable.class, "facade");
PipeManager.registerPipePluggable(GatePluggable.class, "gate");

View file

@ -25,9 +25,9 @@ import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftCore;
import buildcraft.api.events.BlockInteractionEvent;
import buildcraft.api.items.IMapLocation;
import buildcraft.core.BlockBuildCraft;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.ItemMapLocation;
import buildcraft.core.utils.Utils;
public class BlockMarker extends BlockBuildCraft {
@ -98,7 +98,7 @@ public class BlockMarker extends BlockBuildCraft {
@Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) {
if (entityplayer.inventory.getCurrentItem() != null
&& entityplayer.inventory.getCurrentItem().getItem() instanceof ItemMapLocation) {
&& entityplayer.inventory.getCurrentItem().getItem() instanceof IMapLocation) {
return false;
}

View file

@ -10,6 +10,7 @@ package buildcraft.compat;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.common.Loader;
@ -44,6 +45,14 @@ public class CompatHooks {
return null;
}
public Block getVisualBlock(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
return null;
}
public int getVisualMeta(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
return -1;
}
public Block getBlock(Class<? extends Block> klazz) {
Block block = null;

View file

@ -10,7 +10,7 @@ package buildcraft.core;
/**
* Left only to stop certain mods depending on it from crashing.
* Please move to the classes contained in builcraft.api.tiles
* Please move to the classes contained in buildcraft.api.tiles
* and IPipeConnection from .transport.
*/
@Deprecated

View file

@ -30,10 +30,11 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import buildcraft.BuildCraftCore;
import buildcraft.api.items.IList;
import buildcraft.core.inventory.StackHelper;
import buildcraft.core.utils.NBTUtils;
public class ItemList extends ItemBuildCraft {
public class ItemList extends ItemBuildCraft implements IList {
private IIcon baseIcon;
private IIcon writtenIcon;
@ -288,11 +289,13 @@ public class ItemList extends ItemBuildCraft {
return result;
}
public static String getLabel(ItemStack stack) {
@Override
public String getLabel(ItemStack stack) {
return NBTUtils.getItemData(stack).getString("label");
}
public static boolean matches(ItemStack stackList, ItemStack item) {
@Override
public boolean matches(ItemStack stackList, ItemStack item) {
StackLine[] lines = getLines(stackList);
for (StackLine line : lines) {

View file

@ -8,6 +8,7 @@
*/
package buildcraft.core;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
@ -29,12 +30,13 @@ import buildcraft.api.boards.RedstoneBoardRegistry;
import buildcraft.api.core.BlockIndex;
import buildcraft.api.core.IBox;
import buildcraft.api.core.IZone;
import buildcraft.api.items.IMapLocation;
import buildcraft.builders.TileMarker;
import buildcraft.builders.TilePathMarker;
import buildcraft.core.utils.NBTUtils;
import buildcraft.core.utils.StringUtils;
public class ItemMapLocation extends ItemBuildCraft {
public class ItemMapLocation extends ItemBuildCraft implements IMapLocation {
public IIcon clean;
public IIcon spot;
@ -181,21 +183,8 @@ public class ItemMapLocation extends ItemBuildCraft {
return true;
}
public static BlockIndex getBlockIndex(ItemStack item) {
NBTTagCompound cpt = NBTUtils.getItemData(item);
if (cpt.hasKey("kind") && cpt.getByte("kind") == 0) {
int x = cpt.getInteger("x");
int y = cpt.getInteger("y");
int z = cpt.getInteger("z");
return new BlockIndex(x, y, z);
} else {
return null;
}
}
public static IBox getBox(ItemStack item) {
@Override
public IBox getBox(ItemStack item) {
NBTTagCompound cpt = NBTUtils.getItemData(item);
if (cpt.hasKey("kind") && cpt.getByte("kind") == 1) {
@ -207,6 +196,8 @@ public class ItemMapLocation extends ItemBuildCraft {
int zMax = cpt.getInteger("zMax");
return new Box(xMin, yMin, zMin, xMax, yMax, zMax);
} else if (cpt.hasKey("kind") && cpt.getByte("kind") == 0) {
return getPointBox(item);
} else {
return null;
}
@ -226,7 +217,8 @@ public class ItemMapLocation extends ItemBuildCraft {
}
}
public static ForgeDirection getSide(ItemStack item) {
@Override
public ForgeDirection getPointSide(ItemStack item) {
NBTTagCompound cpt = NBTUtils.getItemData(item);
if (cpt.hasKey("kind") && cpt.getByte("kind") == 0) {
@ -236,7 +228,19 @@ public class ItemMapLocation extends ItemBuildCraft {
}
}
public static IZone getZone(ItemStack item) {
@Override
public BlockIndex getPoint(ItemStack item) {
NBTTagCompound cpt = NBTUtils.getItemData(item);
if (cpt.hasKey("kind") && cpt.getByte("kind") == 0) {
return new BlockIndex(cpt.getInteger("x"), cpt.getInteger("y"), cpt.getInteger("z"));
} else {
return null;
}
}
@Override
public IZone getZone(ItemStack item) {
NBTTagCompound cpt = NBTUtils.getItemData(item);
if (cpt.hasKey("kind") && cpt.getByte("kind") == 3) {
@ -253,10 +257,36 @@ public class ItemMapLocation extends ItemBuildCraft {
}
}
@Override
public List<BlockIndex> getPath(ItemStack item) {
NBTTagCompound cpt = NBTUtils.getItemData(item);
if (cpt.hasKey("kind") && cpt.getByte("kind") == 2) {
List<BlockIndex> indexList = new ArrayList<BlockIndex>();
NBTTagList pathNBT = cpt.getTagList("path", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < pathNBT.tagCount(); i++) {
indexList.add(new BlockIndex(pathNBT.getCompoundTagAt(i)));
}
return indexList;
} else if (cpt.hasKey("kind") && cpt.getByte("kind") == 0) {
List<BlockIndex> indexList = new ArrayList<BlockIndex>();
indexList.add(new BlockIndex(cpt.getInteger("x"), cpt.getInteger("y"), cpt.getInteger("z")));
return indexList;
} else {
return null;
}
}
public static void setZone(ItemStack item, ZonePlan plan) {
NBTTagCompound cpt = NBTUtils.getItemData(item);
cpt.setByte("kind", (byte) 3);
plan.writeToNBT(cpt);
}
@Override
public MapLocationType getType(ItemStack stack) {
NBTTagCompound cpt = NBTUtils.getItemData(stack);
return MapLocationType.values()[cpt.getByte("kind")];
}
}

View file

@ -198,7 +198,9 @@ public class BptBuilderBlueprint extends BptBuilderBase {
initialize();
for (BuildingSlotBlock b : buildList) {
if (!b.schematic.doNotBuild()) {
if (b.mode == Mode.ClearIfInvalid) {
context.world.setBlockToAir(b.x, b.y, b.z);
} else if (!b.schematic.doNotBuild()) {
b.stackConsumed = new LinkedList<ItemStack>();
try {

View file

@ -13,6 +13,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import buildcraft.BuildCraftCore;
import buildcraft.core.DefaultProps;
import buildcraft.core.ItemList;
@ -118,7 +119,7 @@ public class GuiList extends GuiAdvancedInterface {
textField = new GuiTextField(this.fontRendererObj, 10, 10, 156, 12);
textField.setMaxStringLength(32);
textField.setText(ItemList.getLabel(player.getCurrentEquippedItem()));
textField.setText(BuildCraftCore.listItem.getLabel(player.getCurrentEquippedItem()));
textField.setFocused(false);
}

View file

@ -12,7 +12,7 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import buildcraft.core.ItemList;
import buildcraft.api.items.IList;
public class StackHelper {
@ -46,10 +46,12 @@ public class StackHelper {
return false;
}
if (stack1.getItem() instanceof ItemList) {
return ItemList.matches(stack1, stack2);
} else if (stack2.getItem() instanceof ItemList) {
return ItemList.matches(stack2, stack1);
if (stack1.getItem() instanceof IList) {
IList list = (IList) stack1.getItem();
return list.matches(stack1, stack2);
} else if (stack2.getItem() instanceof IList) {
IList list = (IList) stack2.getItem();
return list.matches(stack2, stack1);
}
if (!stack1.isItemEqual(stack2)) {
@ -137,10 +139,12 @@ public class StackHelper {
return false;
}
if (a.getItem() instanceof ItemList) {
return ItemList.matches(a, b);
} else if (b.getItem() instanceof ItemList) {
return ItemList.matches(b, a);
if (a.getItem() instanceof IList) {
IList list = (IList) a.getItem();
return list.matches(a, b);
} else if (b.getItem() instanceof IList) {
IList list = (IList) b.getItem();
return list.matches(b, a);
}
return isMatchingItem(a, b, true, false);

View file

@ -17,11 +17,6 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import cofh.api.energy.IEnergyConnection;
import cofh.api.energy.IEnergyHandler;
import cofh.api.energy.IEnergyProvider;
import cofh.api.energy.IEnergyReceiver;
import buildcraft.BuildCraftCore;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.ITriggerExternal;
@ -63,20 +58,18 @@ public class DefaultTriggerProvider implements ITriggerProvider {
res.add(BuildCraftCore.triggerMachineInactive);
}
if (tile instanceof IEnergyConnection && ((IEnergyConnection) tile).canConnectEnergy(side.getOpposite())) {
if ((tile instanceof IEnergyHandler && ((IEnergyHandler) tile).getMaxEnergyStored(side.getOpposite()) > 0)
|| (tile instanceof IEnergyReceiver && ((IEnergyReceiver) tile).getMaxEnergyStored(side.getOpposite()) > 0)
|| (tile instanceof IEnergyProvider && ((IEnergyProvider) tile).getMaxEnergyStored(side.getOpposite()) > 0)) {
res.add((ITriggerExternal) BuildCraftCore.triggerEnergyHigh);
res.add((ITriggerExternal) BuildCraftCore.triggerEnergyLow);
}
}
return res;
}
@Override
public LinkedList<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
return null;
LinkedList<ITriggerInternal> res = new LinkedList<ITriggerInternal>();
if (TriggerEnergy.isTriggeringPipe(container.getTile()) || TriggerEnergy.getTriggeringNeighbor(container.getTile()) != null) {
res.add((ITriggerInternal) BuildCraftCore.triggerEnergyHigh);
res.add((ITriggerInternal) BuildCraftCore.triggerEnergyLow);
}
return res;
}
}

View file

@ -49,9 +49,13 @@ public class StatementParameterDirection implements IStatementParameter {
@Override
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse) {
if (source.getTile() instanceof TileGenericPipe) {
do {
for (int i = 0; i < 6; i++) {
direction = ForgeDirection.getOrientation((direction.ordinal() + (mouse.getButton() > 0 ? -1 : 1)) % 6);
} while (!((TileGenericPipe) source.getTile()).isPipeConnected(direction));
if (((TileGenericPipe) source.getTile()).isPipeConnected(direction)) {
return;
}
}
direction = ForgeDirection.UNKNOWN;
}
}

View file

@ -23,10 +23,20 @@ import cofh.api.energy.IEnergyReceiver;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.ITriggerExternal;
import buildcraft.api.statements.ITriggerInternal;
import buildcraft.api.transport.IPipeTile;
import buildcraft.core.utils.StringUtils;
public class TriggerEnergy extends BCStatement implements ITriggerExternal {
public class TriggerEnergy extends BCStatement implements ITriggerInternal {
public static class Neighbor {
public TileEntity tile;
public ForgeDirection side;
public Neighbor(TileEntity tile, ForgeDirection side) {
this.tile = tile;
this.side = side;
}
}
private boolean high;
@ -67,20 +77,69 @@ public class TriggerEnergy extends BCStatement implements ITriggerExternal {
return false;
}
@Override
public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer container, IStatementParameter[] parameters) {
if (tile instanceof IEnergyHandler || tile instanceof IEnergyProvider || tile instanceof IEnergyReceiver) {
if (((IEnergyConnection) tile).canConnectEnergy(side.getOpposite())) {
protected static boolean isTriggered(Object tile, ForgeDirection side) {
return (tile instanceof IEnergyHandler || tile instanceof IEnergyProvider || tile instanceof IEnergyReceiver)
&& (((IEnergyConnection) tile).canConnectEnergy(side.getOpposite()));
}
protected boolean isActive(Object tile, ForgeDirection side) {
if (isTriggered(tile, side)) {
return isTriggeredEnergyHandler((IEnergyConnection) tile, side.getOpposite());
}
}
return false;
}
public static boolean isTriggeringPipe(TileEntity tile) {
if (tile instanceof IPipeTile) {
IPipeTile pipeTile = (IPipeTile) tile;
if (pipeTile.getPipeType() == IPipeTile.PipeType.POWER && pipeTile.getPipe() instanceof IEnergyHandler) {
return true;
}
}
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon("buildcraft:triggers/trigger_machine_energy_" + (high ? "high" : "low"));
}
@Override
public boolean isTriggerActive(IStatementContainer source, IStatementParameter[] parameters) {
// Internal check
if (isTriggeringPipe(source.getTile())) {
return isActive(((IPipeTile) source.getTile()).getPipe(), ForgeDirection.UNKNOWN);
}
Neighbor triggeringNeighbor = getTriggeringNeighbor(source.getTile());
if (triggeringNeighbor != null) {
return isActive(triggeringNeighbor.tile, triggeringNeighbor.side);
}
return false;
}
public static Neighbor getTriggeringNeighbor(TileEntity parent) {
if (parent instanceof IPipeTile) {
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tile = ((IPipeTile) parent).getNeighborTile(side);
if (tile != null && isTriggered(tile, side)) {
return new Neighbor(tile, side);
}
}
} else {
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tile = parent.getWorldObj().getTileEntity(
parent.xCoord + side.offsetX,
parent.yCoord + side.offsetY,
parent.zCoord + side.offsetZ
);
if (tile != null && isTriggered(tile, side)) {
return new Neighbor(tile, side);
}
}
}
return null;
}
}

View file

@ -65,7 +65,9 @@ public class PathFindingSearch implements IIterableAlgorithm {
}
BlockIndex delta = blockIter.next();
BlockIndex block = new BlockIndex(start.x + delta.x, start.y + delta.y, start.z + delta.z);
BlockIndex block = new BlockIndex(start.x + delta.x,
((start.y + delta.y) > 0) ? start.y + delta.y : 0,
start.z + delta.z);
if (isLoadedChunk(block.x, block.z)) {
if (isTarget(block)) {
pathFinders.add(new PathFinding(world, start, block, 0, maxDistance));

View file

@ -393,9 +393,6 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection direction) {
if (direction == orientation) {
return null;
}
return tankManager.getTankInfo(direction);
}

View file

@ -255,7 +255,8 @@ public class RobotStationPluggable extends PipePluggable implements IPipePluggab
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
if (station != null && station.isTaken() && station.robotTaking() != null && station.robotTaking().getBattery() != null) {
if (station != null && station.isTaken() && station.robotTaking() != null && station.robotTaking().getBattery() != null
&& station.robotTaking().getDockingStation() == station) {
return station.robotTaking().getBattery().receiveEnergy(maxReceive, simulate);
}
return 0;

View file

@ -19,10 +19,15 @@ public class AIRobotMain extends AIRobot {
super(iRobot);
}
@Override
public int getEnergyCost() {
return 0;
}
@Override
public void preempt(AIRobot ai) {
if (!(ai instanceof AIRobotRecharge)) {
if (robot.getEnergy() < EntityRobotBase.SAFETY_ENERGY) {
if (robot.getEnergy() < EntityRobotBase.SAFETY_ENERGY) {
startDelegateAI(new AIRobotRecharge(robot));
} else if (overridingAI != null && ai != overridingAI) {
startDelegateAI(overridingAI);

View file

@ -26,6 +26,9 @@ public class AIRobotRecharge extends AIRobot {
@Override
public void start() {
robot.getRegistry().releaseResources(robot);
robot.motionX = 0;
robot.motionY = 0;
robot.motionZ = 0;
startDelegateAI(new AIRobotSearchAndGotoStation(robot, new IStationFilter() {
@Override
@ -35,6 +38,11 @@ public class AIRobotRecharge extends AIRobot {
}, null));
}
@Override
public int getEnergyCost() {
return 0;
}
@Override
public void update() {
if (robot.getEnergy() >= EntityRobotBase.MAX_ENERGY) {

View file

@ -11,6 +11,7 @@ import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.utils.IBlockFilter;
import buildcraft.core.utils.concurrency.IterableAlgorithmRunner;
import buildcraft.core.utils.concurrency.PathFindingSearch;
import buildcraft.robots.ResourceIdBlock;
public class AIRobotSearchBlockBase extends AIRobot {
@ -26,6 +27,8 @@ public class AIRobotSearchBlockBase extends AIRobot {
pathFound = iPathFound;
blockIter = iBlockIter;
blockFound = null;
path = null;
}
@Override
@ -66,6 +69,11 @@ public class AIRobotSearchBlockBase extends AIRobot {
}
}
@Override
public boolean success() {
return blockFound != null;
}
@Override
public void writeSelfToNBT(NBTTagCompound nbt) {
super.writeSelfToNBT(nbt);
@ -86,6 +94,15 @@ public class AIRobotSearchBlockBase extends AIRobot {
}
}
public boolean takeResource() {
boolean taken = false;
if (robot.getRegistry().take(new ResourceIdBlock(blockFound), robot)) {
taken = true;
}
unreserve();
return taken;
}
public void unreserve() {
blockScanner.unreserve(blockFound);
}

View file

@ -24,12 +24,8 @@ import buildcraft.api.transport.IStripesHandler.StripesHandlerType;
import buildcraft.api.transport.PipeManager;
import buildcraft.core.inventory.InvUtils;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.transport.stripes.StripesHandlerDefault;
public class AIRobotStripesHandler extends AIRobot implements IStripesActivator {
private static IStripesHandler defaultItemsHandler = new StripesHandlerDefault();
private BlockIndex useToBlock;
private int useCycles = 0;
@ -77,17 +73,11 @@ public class AIRobotStripesHandler extends AIRobot implements IStripesActivator
}
}
}
if (defaultItemsHandler.handle(robot.worldObj, (int) p.x, (int) p.y,
(int) p.z, direction, stack, player, this)) {
robot.setItemInUse(null);
}
terminate();
}
}
private ForgeDirection getDirection() {
return null;
}

View file

@ -22,7 +22,6 @@ import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.inventory.filters.IStackFilter;
import buildcraft.core.utils.IBlockFilter;
import buildcraft.robots.ResourceIdBlock;
import buildcraft.robots.RobotRegistry;
import buildcraft.robots.ai.AIRobotFetchAndEquipItemStack;
import buildcraft.robots.ai.AIRobotGotoBlock;
import buildcraft.robots.ai.AIRobotGotoSleep;
@ -66,24 +65,17 @@ public class BoardRobotFarmer extends RedstoneBoardRobot {
@Override
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotSearchBlock) {
AIRobotSearchBlock searchAI = (AIRobotSearchBlock) ai;
if (searchAI.blockFound != null
&& RobotRegistry.getRegistry(robot.worldObj).take(
new ResourceIdBlock(searchAI.blockFound), robot)) {
((AIRobotSearchBlock) ai).unreserve();
if (blockFound != null) {
robot.getRegistry().release(new ResourceIdBlock(blockFound));
}
blockFound = searchAI.blockFound;
startDelegateAI(new AIRobotGotoBlock(robot, searchAI.path));
} else {
if (searchAI.blockFound != null) {
((AIRobotSearchBlock) ai).unreserve();
}
if (!ai.success()) {
startDelegateAI(new AIRobotGotoSleep(robot));
} else {
releaseBlockFound();
AIRobotSearchBlock searchAI = (AIRobotSearchBlock) ai;
if (searchAI.takeResource()) {
blockFound = searchAI.blockFound;
startDelegateAI(new AIRobotGotoBlock(robot, searchAI.path));
} else {
startDelegateAI(new AIRobotGotoSleep(robot));
}
}
} else if (ai instanceof AIRobotGotoBlock) {
startDelegateAI(new AIRobotUseToolOnBlock(robot, blockFound));
@ -92,6 +84,12 @@ public class BoardRobotFarmer extends RedstoneBoardRobot {
startDelegateAI(new AIRobotGotoSleep(robot));
}
} else if (ai instanceof AIRobotUseToolOnBlock) {
releaseBlockFound();
}
}
private void releaseBlockFound() {
if (blockFound != null) {
robot.getRegistry().release(new ResourceIdBlock(blockFound));
blockFound = null;
}
@ -99,9 +97,7 @@ public class BoardRobotFarmer extends RedstoneBoardRobot {
@Override
public void end() {
if (blockFound != null) {
robot.getRegistry().release(new ResourceIdBlock(blockFound));
}
releaseBlockFound();
}
@Override

View file

@ -92,23 +92,28 @@ public abstract class BoardRobotGenericBreakBlock extends RedstoneBoardRobot {
@Override
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotSearchBlock) {
if (indexStored != null) {
robot.getRegistry().release(new ResourceIdBlock(indexStored));
}
indexStored = ((AIRobotSearchBlock) ai).blockFound;
if (indexStored == null) {
if (!ai.success()) {
startDelegateAI(new AIRobotGotoSleep(robot));
} else {
if (robot.getRegistry().take(new ResourceIdBlock(indexStored), robot)) {
startDelegateAI(new AIRobotGotoBlock(robot, ((AIRobotSearchBlock) ai).path));
releaseBlockFound();
AIRobotSearchBlock searchAI = (AIRobotSearchBlock) ai;
if (searchAI.takeResource()) {
indexStored = searchAI.blockFound;
startDelegateAI(new AIRobotGotoBlock(robot, searchAI.path));
} else {
startDelegateAI(new AIRobotGotoSleep(robot));
}
((AIRobotSearchBlock) ai).unreserve();
}
} else if (ai instanceof AIRobotGotoBlock) {
startDelegateAI(new AIRobotBreak(robot, indexStored));
} else if (ai instanceof AIRobotBreak) {
releaseBlockFound();
startDelegateAI(new AIRobotGotoSleep(robot));
}
}
private void releaseBlockFound() {
if (indexStored != null) {
robot.getRegistry().release(new ResourceIdBlock(indexStored));
indexStored = null;
}
@ -116,9 +121,7 @@ public abstract class BoardRobotGenericBreakBlock extends RedstoneBoardRobot {
@Override
public void end() {
if (indexStored != null) {
robot.getRegistry().release(new ResourceIdBlock(indexStored));
}
releaseBlockFound();
}
public final void updateFilter() {

View file

@ -36,7 +36,6 @@ import buildcraft.robots.ResourceIdBlock;
import buildcraft.robots.ai.AIRobotFetchAndEquipItemStack;
import buildcraft.robots.ai.AIRobotGotoBlock;
import buildcraft.robots.ai.AIRobotGotoSleep;
import buildcraft.robots.ai.AIRobotSearchBlockBase;
import buildcraft.robots.ai.AIRobotSearchRandomBlock;
import buildcraft.robots.ai.AIRobotUseToolOnBlock;
import buildcraft.robots.statements.ActionRobotFilter;
@ -122,28 +121,23 @@ public class BoardRobotPlanter extends RedstoneBoardRobot {
@Override
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotSearchRandomBlock) {
AIRobotSearchBlockBase gotoBlock = (AIRobotSearchBlockBase) ai;
if (gotoBlock.blockFound != null
&& robot.getRegistry().take(new ResourceIdBlock(gotoBlock.blockFound), robot)) {
if (blockFound != null) {
robot.getRegistry().release(new ResourceIdBlock(blockFound));
}
gotoBlock.unreserve();
blockFound = gotoBlock.blockFound;
gotoBlock.path.removeLast();
startDelegateAI(new AIRobotGotoBlock(robot, gotoBlock.path));
} else {
if (gotoBlock.blockFound != null) {
gotoBlock.unreserve();
}
if (!ai.success()) {
startDelegateAI(new AIRobotGotoSleep(robot));
} else {
releaseBlockFound();
AIRobotSearchRandomBlock searchAI = (AIRobotSearchRandomBlock) ai;
if (searchAI.takeResource()) {
blockFound = searchAI.blockFound;
searchAI.path.removeLast();
startDelegateAI(new AIRobotGotoBlock(robot, searchAI.path));
} else {
startDelegateAI(new AIRobotGotoSleep(robot));
}
}
} else if (ai instanceof AIRobotGotoBlock) {
startDelegateAI(new AIRobotUseToolOnBlock(robot, blockFound));
} else if (ai instanceof AIRobotUseToolOnBlock) {
releaseBlockFound();
} else if (ai instanceof AIRobotFetchAndEquipItemStack) {
if (robot.getHeldItem() == null) {
startDelegateAI(new AIRobotGotoSleep(robot));
@ -151,6 +145,13 @@ public class BoardRobotPlanter extends RedstoneBoardRobot {
}
}
private void releaseBlockFound() {
if (blockFound != null) {
robot.getRegistry().release(new ResourceIdBlock(blockFound));
blockFound = null;
}
}
private static class PlantableFilter implements IStackFilter {
@Override
public boolean matches(ItemStack stack) {

View file

@ -84,15 +84,14 @@ public class BoardRobotPump extends RedstoneBoardRobot {
if (!ai.success()) {
startDelegateAI(new AIRobotGotoSleep(robot));
} else {
blockFound = ((AIRobotSearchBlock) ai).blockFound;
if (!robot.getRegistry().take(new ResourceIdBlock (blockFound), robot)) {
blockFound = null;
startDelegateAI(new AIRobotGotoSleep(robot));
releaseBlockFound();
AIRobotSearchBlock searchAI = (AIRobotSearchBlock) ai;
if (searchAI.takeResource()) {
blockFound = searchAI.blockFound;
startDelegateAI(new AIRobotGotoBlock(robot, searchAI.path));
} else {
startDelegateAI(new AIRobotGotoBlock(robot, ((AIRobotSearchBlock) ai).path));
startDelegateAI(new AIRobotGotoSleep(robot));
}
((AIRobotSearchBlock) ai).unreserve();
}
} else if (ai instanceof AIRobotGotoBlock) {
if (!ai.success()) {
@ -101,7 +100,7 @@ public class BoardRobotPump extends RedstoneBoardRobot {
startDelegateAI(new AIRobotPumpBlock(robot, blockFound));
}
} else if (ai instanceof AIRobotGotoStationAndUnloadFluids) {
robot.getRegistry().take(new ResourceIdBlock (blockFound), robot);
releaseBlockFound();
if (!ai.success()) {
startDelegateAI(new AIRobotGotoSleep(robot));
@ -109,6 +108,13 @@ public class BoardRobotPump extends RedstoneBoardRobot {
}
}
private void releaseBlockFound() {
if (blockFound != null) {
robot.getRegistry().release(new ResourceIdBlock(blockFound));
blockFound = null;
}
}
public void updateFilter() {
fluidFilter.clear();

View file

@ -20,7 +20,6 @@ import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.inventory.filters.IStackFilter;
import buildcraft.core.utils.IBlockFilter;
import buildcraft.robots.ResourceIdBlock;
import buildcraft.robots.RobotRegistry;
import buildcraft.robots.ai.AIRobotFetchAndEquipItemStack;
import buildcraft.robots.ai.AIRobotGotoBlock;
import buildcraft.robots.ai.AIRobotGotoSleep;
@ -63,24 +62,17 @@ public class BoardRobotStripes extends RedstoneBoardRobot {
@Override
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotSearchRandomBlock) {
AIRobotSearchRandomBlock searchAI = (AIRobotSearchRandomBlock) ai;
if (searchAI.blockFound != null
&& RobotRegistry.getRegistry(robot.worldObj).take(
new ResourceIdBlock(searchAI.blockFound), robot)) {
searchAI.unreserve();
if (blockFound != null) {
robot.getRegistry().release(new ResourceIdBlock(blockFound));
}
blockFound = searchAI.blockFound;
startDelegateAI(new AIRobotGotoBlock(robot, searchAI.path));
} else {
if (searchAI.blockFound != null) {
searchAI.unreserve();
}
if (!ai.success()) {
startDelegateAI(new AIRobotGotoSleep(robot));
} else {
releaseBlockFound();
AIRobotSearchRandomBlock searchAI = (AIRobotSearchRandomBlock) ai;
if (searchAI.takeResource()) {
blockFound = searchAI.blockFound;
startDelegateAI(new AIRobotGotoBlock(robot, searchAI.path));
} else {
startDelegateAI(new AIRobotGotoSleep(robot));
}
}
} else if (ai instanceof AIRobotGotoBlock) {
startDelegateAI(new AIRobotStripesHandler(robot, blockFound));
@ -89,6 +81,12 @@ public class BoardRobotStripes extends RedstoneBoardRobot {
startDelegateAI(new AIRobotGotoSleep(robot));
}
} else if (ai instanceof AIRobotStripesHandler) {
releaseBlockFound();
}
}
private void releaseBlockFound() {
if (blockFound != null) {
robot.getRegistry().release(new ResourceIdBlock(blockFound));
blockFound = null;
}

View file

@ -14,13 +14,13 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.BlockIndex;
import buildcraft.api.items.IMapLocation;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.statements.IActionInternal;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.StatementParameterItemStack;
import buildcraft.api.transport.IPipeTile;
import buildcraft.core.ItemMapLocation;
import buildcraft.core.statements.BCStatement;
import buildcraft.core.utils.StringUtils;
import buildcraft.robots.DockingStation;
@ -71,11 +71,12 @@ public class ActionRobotGotoStation extends BCStatement implements IActionIntern
StatementParameterItemStack stackParam = (StatementParameterItemStack) parameters[0];
ItemStack item = stackParam.getItemStack();
if (item != null && item.getItem() instanceof ItemMapLocation) {
BlockIndex index = ItemMapLocation.getBlockIndex(item);
if (item != null && item.getItem() instanceof IMapLocation) {
IMapLocation map = (IMapLocation) item.getItem();
BlockIndex index = map.getPoint(item);
if (index != null) {
ForgeDirection side = ItemMapLocation.getSide(item);
ForgeDirection side = map.getPointSide(item);
DockingStation paramStation = (DockingStation)
registry.getStation(index.x,
index.y, index.z, side);

View file

@ -12,11 +12,11 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import buildcraft.api.core.IZone;
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.core.ItemMapLocation;
import buildcraft.core.statements.BCStatement;
import buildcraft.core.utils.StringUtils;
import buildcraft.transport.gates.StatementSlot;
@ -44,11 +44,12 @@ public class ActionRobotWorkInArea extends BCStatement implements IActionInterna
ItemStack stack = slot.parameters[0].getItemStack();
if (!(stack.getItem() instanceof ItemMapLocation)) {
if (stack == null || !(stack.getItem() instanceof IMapLocation)) {
return null;
}
return ItemMapLocation.getZone(stack);
IMapLocation map = (IMapLocation) stack.getItem();
return map.getZone(stack);
}
@Override

View file

@ -137,7 +137,6 @@ public class TileLaser extends TileBuildCraft implements IHasWork, IControllable
}
protected boolean isValidTable() {
if (laserTarget == null || laserTarget.isInvalidTarget() || !laserTarget.requiresLaserEnergy()) {
return false;
}
@ -308,11 +307,11 @@ public class TileLaser extends TileBuildCraft implements IHasWork, IControllable
public ResourceLocation getTexture() {
double avg = powerAverage / POWER_AVERAGING;
if (avg <= 1.0) {
if (avg <= 10.0) {
return EntityLaser.LASER_TEXTURES[0];
} else if (avg <= 2.0) {
} else if (avg <= 20.0) {
return EntityLaser.LASER_TEXTURES[1];
} else if (avg <= 3.0) {
} else if (avg <= 30.0) {
return EntityLaser.LASER_TEXTURES[2];
} else {
return EntityLaser.LASER_TEXTURES[3];

View file

@ -1,6 +1,7 @@
package buildcraft.silicon.boards;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import net.minecraft.item.ItemStack;
@ -38,7 +39,7 @@ public class BoardProgrammingRecipe implements IProgrammingRecipe {
nbt.createBoard(NBTUtils.getItemData(stack));
options.add(stack);
}
options.sort(new BoardSorter(this));
Collections.sort(options, new BoardSorter(this));
return options;
}

View file

@ -55,6 +55,7 @@ import buildcraft.api.events.PipePlacedEvent;
import buildcraft.api.events.RobotPlacementEvent;
import buildcraft.api.gates.GateExpansions;
import buildcraft.api.gates.IGateExpansion;
import buildcraft.api.items.IMapLocation;
import buildcraft.api.tools.IToolWrench;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipeTile;
@ -64,7 +65,6 @@ import buildcraft.api.transport.pluggable.PipePluggable;
import buildcraft.core.BlockBuildCraft;
import buildcraft.core.CoreConstants;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.ItemMapLocation;
import buildcraft.core.TileBuffer;
import buildcraft.core.utils.MatrixTranformations;
import buildcraft.core.utils.Utils;
@ -617,7 +617,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
// Only check the instance at this point. Call the IToolWrench
// interface callbacks for the individual pipe/logic calls
return pipe.blockActivated(player);
} else if (currentItem.getItem() instanceof ItemMapLocation) {
} else if (currentItem.getItem() instanceof IMapLocation) {
// We want to be able to record pipe locations
return false;
} else if (PipeWire.RED.isPipeWire(currentItem)) {

View file

@ -193,54 +193,56 @@ public class PipeTransportPower extends PipeTransport {
for (int j = 0; j < 6; ++j) {
if (j != i && powerQuery[j] > 0) {
Object ep = getEnergyProvider(j);
if (ep instanceof TileGenericPipe || ep instanceof IEnergyReceiver || ep instanceof IEnergyHandler) {
if (ep instanceof IPipeTile || ep instanceof IEnergyReceiver || ep instanceof IEnergyHandler) {
totalPowerQuery += powerQuery[j];
}
}
}
for (int j = 0; j < 6; ++j) {
if (j != i && powerQuery[j] > 0) {
Object ep = getEnergyProvider(j);
int watts = (int) Math.floor(internalPower[i] * powerQuery[j] / totalPowerQuery);
if (totalPowerQuery > 0) {
for (int j = 0; j < 6; ++j) {
if (j != i && powerQuery[j] > 0) {
Object ep = getEnergyProvider(j);
int watts = (int) Math.floor(internalPower[i] * powerQuery[j] / totalPowerQuery);
if (ep instanceof IPipeTile) {
Pipe<?> nearbyPipe = (Pipe<?>) ((IPipeTile) ep).getPipe();
PipeTransportPower nearbyTransport = (PipeTransportPower) nearbyPipe.transport;
watts = nearbyTransport.receiveEnergy(
ForgeDirection.VALID_DIRECTIONS[j].getOpposite(),
watts);
internalPower[i] -= watts;
} else if (ep instanceof IEnergyHandler) {
IEnergyHandler handler = (IEnergyHandler) ep;
if (handler.canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite())) {
watts = handler.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite(),
watts, false);
internalPower[i] -= watts;
}
} else if (ep instanceof IEnergyReceiver) {
IEnergyReceiver handler = (IEnergyReceiver) ep;
if (handler.canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite())) {
watts = handler.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite(),
watts, false);
if (ep instanceof IPipeTile) {
Pipe<?> nearbyPipe = (Pipe<?>) ((IPipeTile) ep).getPipe();
PipeTransportPower nearbyTransport = (PipeTransportPower) nearbyPipe.transport;
watts = nearbyTransport.receiveEnergy(
ForgeDirection.VALID_DIRECTIONS[j].getOpposite(),
watts);
internalPower[i] -= watts;
} else if (ep instanceof IEnergyHandler) {
IEnergyHandler handler = (IEnergyHandler) ep;
if (handler.canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite())) {
watts = handler.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite(),
watts, false);
internalPower[i] -= watts;
}
} else if (ep instanceof IEnergyReceiver) {
IEnergyReceiver handler = (IEnergyReceiver) ep;
if (handler.canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite())) {
watts = handler.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite(),
watts, false);
internalPower[i] -= watts;
}
}
displayPower[j] += watts;
displayPower[i] += watts;
}
displayPower[j] += watts;
displayPower[i] += watts;
}
}
}
}
double highestPower = 0.0;
float highestPower = 0.0F;
for (int i = 0; i < 6; i++) {
displayPower[i] = (short) ((prevDisplayPower[i] * (DISPLAY_SMOOTHING - 1.0F) + displayPower[i]) / DISPLAY_SMOOTHING);
displayPower[i] = (short) Math.floor((float) (prevDisplayPower[i] * (DISPLAY_SMOOTHING - 1) + displayPower[i]) / DISPLAY_SMOOTHING);
if (displayPower[i] > highestPower) {
highestPower = displayPower[i];
}
}
overload += highestPower > ((double) maxPower) * 0.95 ? 1 : -1;
overload += highestPower > ((float) maxPower) * 0.95F ? 1 : -1;
if (overload < 0) {
overload = 0;
}
@ -248,7 +250,7 @@ public class PipeTransportPower extends PipeTransport {
overload = OVERLOAD_TICKS;
}
// Compute the tiles requesting energy that are not power pipes
// Compute the tiles requesting energy that are not power pipes
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (!outputOpen(dir)) {
continue;
@ -295,17 +297,15 @@ public class PipeTransportPower extends PipeTransport {
// Transfer the requested energy to nearby pipes
for (int i = 0; i < 6; ++i) {
if (transferQuery[i] != 0) {
if (tiles[i] != null) {
TileEntity entity = tiles[i];
if (entity instanceof TileGenericPipe) {
TileGenericPipe nearbyTile = (TileGenericPipe) entity;
if (nearbyTile.pipe == null) {
continue;
}
PipeTransportPower nearbyTransport = (PipeTransportPower) nearbyTile.pipe.transport;
nearbyTransport.requestEnergy(ForgeDirection.VALID_DIRECTIONS[i].getOpposite(), transferQuery[i]);
if (transferQuery[i] != 0 && tiles[i] != null) {
TileEntity entity = tiles[i];
if (entity instanceof IPipeTile) {
IPipeTile nearbyTile = (IPipeTile) entity;
if (nearbyTile.getPipe() == null) {
continue;
}
PipeTransportPower nearbyTransport = (PipeTransportPower) ((Pipe) nearbyTile.getPipe()).transport;
nearbyTransport.requestEnergy(ForgeDirection.VALID_DIRECTIONS[i].getOpposite(), transferQuery[i]);
}
}
}

View file

@ -14,8 +14,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import cofh.api.energy.IEnergyHandler;
import buildcraft.BuildCraftCore;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.ITriggerExternal;
@ -74,11 +72,6 @@ public class PipeTriggerProvider implements ITriggerProvider {
public LinkedList<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
LinkedList<ITriggerExternal> result = new LinkedList<ITriggerExternal>();
if (tile instanceof IEnergyHandler && ((IEnergyHandler) tile).getMaxEnergyStored(side) > 0) {
result.add((ITriggerExternal) BuildCraftCore.triggerEnergyHigh);
result.add((ITriggerExternal) BuildCraftCore.triggerEnergyLow);
}
return result;
}
}

View file

@ -37,13 +37,9 @@ import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TileGenericPipe;
import buildcraft.transport.TravelingItem;
import buildcraft.transport.pipes.events.PipeEventItem;
import buildcraft.transport.stripes.StripesHandlerDefault;
import buildcraft.transport.utils.TransportUtils;
public class PipeItemsStripes extends Pipe<PipeTransportItems> implements IEnergyHandler, IStripesPipe {
private static IStripesHandler defaultItemsHandler = new StripesHandlerDefault();
public PipeItemsStripes(Item item) {
super(new PipeTransportItems(), item);
}
@ -112,11 +108,6 @@ public class PipeItemsStripes extends Pipe<PipeTransportItems> implements IEnerg
}
}
}
if (defaultItemsHandler.handle(getWorld(), (int) p.x, (int) p.y, (int) p.z,
event.direction, stack, player, this)) {
event.entity = null;
}
}
@Override

View file

@ -8,6 +8,7 @@ import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.transport.pluggable.IFacadePluggable;
import buildcraft.api.transport.pluggable.PipePluggable;
import buildcraft.compat.CompatHooks;
import buildcraft.transport.BlockGenericPipe;
import buildcraft.transport.TileGenericPipe;
@ -22,12 +23,15 @@ public class FacadeBlockAccess implements IBlockAccess {
@Override
public Block getBlock(int x, int y, int z) {
//System.out.println("Querying block at " + x + ", " + y + ", " + z);
Block compatBlock = CompatHooks.INSTANCE.getVisualBlock(world, x, y, z, side);
if (compatBlock != null) {
return compatBlock;
}
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileGenericPipe) {
PipePluggable p = ((TileGenericPipe) tile).getPipePluggable(side);
if (p instanceof IFacadePluggable) {
//System.out.println("Found facade");
return ((IFacadePluggable) p).getCurrentBlock();
}
}
@ -46,7 +50,11 @@ public class FacadeBlockAccess implements IBlockAccess {
@Override
public int getBlockMetadata(int x, int y, int z) {
//System.out.println("Querying block metadata at " + x + ", " + y + ", " + z);
int compatMeta = CompatHooks.INSTANCE.getVisualMeta(world, x, y, z, side);
if (compatMeta >= 0) {
return compatMeta;
}
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileGenericPipe) {
PipePluggable p = ((TileGenericPipe) tile).getPipePluggable(side);

View file

@ -66,7 +66,7 @@ public class StripesHandlerEntityInteract implements IStripesHandler {
successful = true;
dropItemsExcept(stack, player, activator, direction);
}
if (stack.stackSize > 0) {
if (stack.stackSize > 0 && successful) {
activator.sendItem(stack, direction.getOpposite());
}

View file

@ -9,38 +9,36 @@
package buildcraft.transport.stripes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.transport.IStripesActivator;
import buildcraft.api.transport.IStripesHandler;
public class StripesHandlerDefault implements IStripesHandler {
public class StripesHandlerHoe implements IStripesHandler {
@Override
public StripesHandlerType getType() {
return StripesHandlerType.ITEM_USE;
}
@Override
public boolean shouldHandle(ItemStack stack) {
return true;
return stack.getItem() instanceof ItemHoe;
}
@Override
public boolean handle(World world, int x, int y, int z,
ForgeDirection direction, ItemStack stack, EntityPlayer player,
IStripesActivator activator) {
if (!world.isAirBlock(x, y, z)) {
return false;
if (!world.isAirBlock(x, y - 1, z) && stack.tryPlaceItemIntoWorld(player, world, x, y - 1, z, 1, 0.0f, 0.0f, 0.0f)) {
if (stack.stackSize > 0) {
activator.sendItem(stack, direction.getOpposite());
}
return true;
}
if (!stack.tryPlaceItemIntoWorld(player, world, x, y - 1, z, 1, 0.0f, 0.0f, 0.0f)) {
return false;
}
activator.sendItem(stack, direction.getOpposite());
return true;
return false;
}
}

View file

@ -34,10 +34,10 @@ public class StripesHandlerPlaceBlock implements IStripesHandler {
public boolean handle(World world, int x, int y, int z,
ForgeDirection direction, ItemStack stack, EntityPlayer player,
IStripesActivator activator) {
if (!world.isAirBlock(x, y, z)) {
return false;
if (!world.isAirBlock(x, y, z) && stack.tryPlaceItemIntoWorld(player, world, x, y, z, 1, 0.0f, 0.0f, 0.0f)) {
return true;
}
return stack.tryPlaceItemIntoWorld(player, world, x, y, z, 1, 0.0f, 0.0f, 0.0f);
return false;
}
}