add stripes pipe direction control, add stripes handler priority system to API, add IBlueprintItem API thing
This commit is contained in:
parent
36ec39a59e
commit
5cb7c9fe00
7 changed files with 87 additions and 16 deletions
11
api/buildcraft/api/items/IBlueprintItem.java
Normal file
11
api/buildcraft/api/items/IBlueprintItem.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package buildcraft.api.items;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IBlueprintItem extends INamedItem {
|
||||
public enum Type {
|
||||
TEMPLATE, BLUEPRINT;
|
||||
}
|
||||
|
||||
Type getType(ItemStack stack);
|
||||
}
|
|
@ -9,6 +9,8 @@
|
|||
package buildcraft.api.transport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -25,6 +27,8 @@ public abstract class PipeManager {
|
|||
new HashMap<String, Class<? extends PipePluggable>>();
|
||||
private static Map<Class<? extends PipePluggable>, String> pipePluggableByNames =
|
||||
new HashMap<Class<? extends PipePluggable>, String>();
|
||||
private static Map<IStripesHandler, Integer> stripesHandlerPriorities =
|
||||
new HashMap<IStripesHandler, Integer>();
|
||||
|
||||
@Deprecated
|
||||
public static boolean canExtractItems(Object extractor, World world, int i, int j, int k) {
|
||||
|
@ -36,8 +40,26 @@ public abstract class PipeManager {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void registerStripesHandler(IStripesHandler handler) {
|
||||
registerStripesHandler(handler, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a Stripes Pipe handler.
|
||||
* @param handler The handler.
|
||||
* @param priority The priority - 0 is normal, higher numbers have higher priority.
|
||||
*/
|
||||
public static void registerStripesHandler(IStripesHandler handler, int priority) {
|
||||
stripesHandlers.add(handler);
|
||||
stripesHandlerPriorities.put(handler, priority);
|
||||
|
||||
Collections.sort(stripesHandlers, new Comparator<IStripesHandler>() {
|
||||
@Override
|
||||
public int compare(IStripesHandler o1, IStripesHandler o2) {
|
||||
return stripesHandlerPriorities.get(o2) - stripesHandlerPriorities.get(o1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void registerPipePluggable(Class<? extends PipePluggable> pluggable, String name) {
|
||||
|
|
|
@ -18,7 +18,8 @@ Additions:
|
|||
* Extending or retracting a Stripes Pipe now carries over all its gates, pipe wires and pluggables (asie)
|
||||
* You can now extend pipe wires by putting them into a Stripes Pipe (asie)
|
||||
* PlaceBlock now works directly in front of a block again (asie)
|
||||
* Made items in pipes move at a much smoother rate (asie)
|
||||
* Stripes Pipes can now have their output direction controlled with Gates (asie)
|
||||
* Made items in pipes move at a much smoother rate (rendering) (asie)
|
||||
* Robots:
|
||||
* Improved robot light handling - the light now denotes sleep state and battery charge level (asie)
|
||||
* New Robot triggers and actions: Linked, Reserved, In Station and Robot Mandatory (asie)
|
||||
|
|
|
@ -502,15 +502,15 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
StatementManager.registerTriggerProvider(new PipeTriggerProvider());
|
||||
StatementManager.registerActionProvider(new PipeActionProvider());
|
||||
|
||||
PipeManager.registerStripesHandler(new StripesHandlerRightClick());
|
||||
PipeManager.registerStripesHandler(new StripesHandlerBucket());
|
||||
PipeManager.registerStripesHandler(new StripesHandlerArrow());
|
||||
PipeManager.registerStripesHandler(new StripesHandlerShears());
|
||||
PipeManager.registerStripesHandler(new StripesHandlerPipes());
|
||||
PipeManager.registerStripesHandler(new StripesHandlerPipeWires());
|
||||
PipeManager.registerStripesHandler(new StripesHandlerEntityInteract());
|
||||
PipeManager.registerStripesHandler(new StripesHandlerPlaceBlock());
|
||||
PipeManager.registerStripesHandler(new StripesHandlerHoe());
|
||||
PipeManager.registerStripesHandler(new StripesHandlerRightClick(), -65536);
|
||||
PipeManager.registerStripesHandler(new StripesHandlerBucket(), 0);
|
||||
PipeManager.registerStripesHandler(new StripesHandlerArrow(), 0);
|
||||
PipeManager.registerStripesHandler(new StripesHandlerShears(), 0);
|
||||
PipeManager.registerStripesHandler(new StripesHandlerPipes(), 0);
|
||||
PipeManager.registerStripesHandler(new StripesHandlerPipeWires(), 0);
|
||||
PipeManager.registerStripesHandler(new StripesHandlerEntityInteract(), 0);
|
||||
PipeManager.registerStripesHandler(new StripesHandlerPlaceBlock(), -32768);
|
||||
PipeManager.registerStripesHandler(new StripesHandlerHoe(), 0);
|
||||
|
||||
PipeManager.registerPipePluggable(FacadePluggable.class, "facade");
|
||||
PipeManager.registerPipePluggable(GatePluggable.class, "gate");
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
package buildcraft.transport.pipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -24,6 +26,7 @@ import cofh.api.energy.IEnergyHandler;
|
|||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.statements.IActionInternal;
|
||||
import buildcraft.api.transport.IStripesHandler;
|
||||
import buildcraft.api.transport.IStripesHandler.StripesHandlerType;
|
||||
import buildcraft.api.transport.IStripesPipe;
|
||||
|
@ -36,10 +39,14 @@ import buildcraft.transport.PipeIconProvider;
|
|||
import buildcraft.transport.PipeTransportItems;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import buildcraft.transport.TravelingItem;
|
||||
import buildcraft.transport.gates.StatementSlot;
|
||||
import buildcraft.transport.pipes.events.PipeEventItem;
|
||||
import buildcraft.transport.statements.ActionPipeDirection;
|
||||
import buildcraft.transport.utils.TransportUtils;
|
||||
|
||||
public class PipeItemsStripes extends Pipe<PipeTransportItems> implements IEnergyHandler, IStripesPipe {
|
||||
private ForgeDirection actionDir = ForgeDirection.UNKNOWN;
|
||||
|
||||
public PipeItemsStripes(Item item) {
|
||||
super(new PipeTransportItems(), item);
|
||||
}
|
||||
|
@ -57,16 +64,21 @@ public class PipeItemsStripes extends Pipe<PipeTransportItems> implements IEnerg
|
|||
if (container.getWorldObj().isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
ForgeDirection direction = actionDir;
|
||||
if (direction == ForgeDirection.UNKNOWN) {
|
||||
direction = event.direction;
|
||||
}
|
||||
|
||||
Position p = new Position(container.xCoord, container.yCoord,
|
||||
container.zCoord, event.direction);
|
||||
container.zCoord, direction);
|
||||
p.moveForwards(1.0);
|
||||
|
||||
ItemStack stack = event.entity.getEntityItem();
|
||||
EntityPlayer player = CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld(),
|
||||
(int) p.x, (int) p.y, (int) p.z).get();
|
||||
|
||||
switch (event.direction) {
|
||||
switch (direction) {
|
||||
case DOWN:
|
||||
player.rotationPitch = 90;
|
||||
player.rotationYaw = 0;
|
||||
|
@ -102,7 +114,7 @@ public class PipeItemsStripes extends Pipe<PipeTransportItems> implements IEnerg
|
|||
if (handler.getType() == StripesHandlerType.ITEM_USE
|
||||
&& handler.shouldHandle(stack)) {
|
||||
if (handler.handle(getWorld(), (int) p.x, (int) p.y, (int) p.z,
|
||||
event.direction, stack, player, this)) {
|
||||
direction, stack, player, this)) {
|
||||
event.entity = null;
|
||||
return;
|
||||
}
|
||||
|
@ -117,7 +129,31 @@ public class PipeItemsStripes extends Pipe<PipeTransportItems> implements IEnerg
|
|||
p.moveForwards(1.0);
|
||||
|
||||
InvUtils.dropItems(getWorld(), itemStack, (int) p.x, (int) p.y, (int) p.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedList<IActionInternal> getActions() {
|
||||
LinkedList<IActionInternal> action = super.getActions();
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (!container.isPipeConnected(direction)) {
|
||||
action.add(BuildCraftTransport.actionPipeDirection[direction.ordinal()]);
|
||||
}
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionsActivated(Collection<StatementSlot> actions) {
|
||||
super.actionsActivated(actions);
|
||||
|
||||
actionDir = ForgeDirection.UNKNOWN;
|
||||
|
||||
for (StatementSlot action : actions) {
|
||||
if (action.statement instanceof ActionPipeDirection) {
|
||||
actionDir = ((ActionPipeDirection) action.statement).direction;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,7 +35,7 @@ import buildcraft.transport.PipeTransportItems;
|
|||
import buildcraft.transport.TravelingItem;
|
||||
|
||||
public class PipeItemsWood extends Pipe<PipeTransportItems> implements IEnergyHandler {
|
||||
protected RFBattery battery = new RFBattery(2560, 2560 / 8, 0);
|
||||
protected RFBattery battery = new RFBattery(2560, 80, 0);
|
||||
|
||||
protected int standardIconIndex = PipeIconProvider.TYPE.PipeItemsWood_Standard.ordinal();
|
||||
protected int solidIconIndex = PipeIconProvider.TYPE.PipeAllWood_Solid.ordinal();
|
||||
|
@ -225,7 +225,8 @@ public class PipeItemsWood extends Pipe<PipeTransportItems> implements IEnergyHa
|
|||
if (doRemove) {
|
||||
int maxStackSize = slot.stackSize;
|
||||
int stackSize = Math.min(maxStackSize, battery.getEnergyStored() / 10);
|
||||
speedMultiplier = Math.min(4.0F, battery.getEnergyStored() * 10 / stackSize);
|
||||
// TODO: Look into the Speed Multiplier again someday.
|
||||
//speedMultiplier = Math.min(4.0F, battery.getEnergyStored() * 10 / stackSize);
|
||||
int energyUsed = (int) (stackSize * 10 * speedMultiplier);
|
||||
battery.useEnergy(energyUsed, energyUsed, false);
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ public class PipeExtensionListener {
|
|||
if (!retract) {
|
||||
r.stack.stackSize--;
|
||||
}
|
||||
|
||||
|
||||
if (r.stack.stackSize > 0) {
|
||||
sendItem(items, r.stack, r.o.getOpposite());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue