Added direction triggers to Iron and Daizuli Pipes
Someone made these nice icons and never used them!
Before Width: | Height: | Size: 445 B After Width: | Height: | Size: 445 B |
Before Width: | Height: | Size: 441 B After Width: | Height: | Size: 441 B |
Before Width: | Height: | Size: 439 B After Width: | Height: | Size: 439 B |
Before Width: | Height: | Size: 441 B After Width: | Height: | Size: 441 B |
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 440 B |
Before Width: | Height: | Size: 439 B After Width: | Height: | Size: 439 B |
|
@ -70,6 +70,7 @@ import buildcraft.transport.pipes.PipePowerWood;
|
|||
import buildcraft.transport.pipes.PipeStructureCobblestone;
|
||||
import buildcraft.transport.triggers.ActionEnergyPulser;
|
||||
import buildcraft.transport.triggers.ActionPipeColor;
|
||||
import buildcraft.transport.triggers.ActionPipeDirection;
|
||||
import buildcraft.transport.triggers.ActionSignalOutput;
|
||||
import buildcraft.transport.triggers.ActionSingleEnergyPulse;
|
||||
import buildcraft.transport.triggers.TriggerFilteredBufferInventoryLevel;
|
||||
|
@ -100,6 +101,7 @@ import net.minecraft.item.ItemBlock;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.Property;
|
||||
|
||||
@Mod(version = Version.VERSION, modid = "BuildCraft|Transport", name = "Buildcraft Transport", dependencies = DefaultProps.DEPENDENCY_CORE)
|
||||
|
@ -172,6 +174,7 @@ public class BuildCraftTransport {
|
|||
public static BCAction actionEnergyPulser = new ActionEnergyPulser(DefaultProps.ACTION_ENERGY_PULSER);
|
||||
public static BCAction actionSingleEnergyPulse = new ActionSingleEnergyPulse(DefaultProps.ACTION_SINGLE_ENERGY_PULSE);
|
||||
public static BCAction[] actionPipeColor = new BCAction[16];
|
||||
public static BCAction[] actionPipeDirection = new BCAction[16];
|
||||
@Instance("BuildCraft|Transport")
|
||||
public static BuildCraftTransport instance;
|
||||
public IIconProvider pipeIconProvider = new PipeIconProvider();
|
||||
|
@ -410,6 +413,10 @@ public class BuildCraftTransport {
|
|||
for (EnumColor color : EnumColor.VALUES) {
|
||||
actionPipeColor[color.ordinal()] = new ActionPipeColor(-1, color);
|
||||
}
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||
actionPipeDirection[direction.ordinal()] = new ActionPipeDirection(-1, direction);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadRecipes() {
|
||||
|
|
|
@ -47,7 +47,7 @@ public class PipeFluidsIron extends Pipe<PipeTransportFluids> {
|
|||
|
||||
@Override
|
||||
public void onNeighborBlockChange(int blockId) {
|
||||
logic.onNeighborBlockChange(blockId);
|
||||
logic.switchOnRedstone();
|
||||
super.onNeighborBlockChange(blockId);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import buildcraft.api.core.Position;
|
|||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.core.network.TileNetworkData;
|
||||
import buildcraft.core.triggers.BCTrigger;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.EntityData;
|
||||
|
@ -23,6 +24,7 @@ import buildcraft.transport.PipeIconProvider;
|
|||
import buildcraft.transport.PipeTransportItems;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import buildcraft.transport.triggers.ActionPipeColor;
|
||||
import buildcraft.transport.triggers.ActionPipeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.Arrays;
|
||||
|
@ -89,12 +91,6 @@ public class PipeItemsDaizuli extends Pipe<PipeTransportItems> implements IPipeT
|
|||
return logic.blockActivated(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(int blockId) {
|
||||
logic.onNeighborBlockChange(blockId);
|
||||
super.onNeighborBlockChange(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlaced() {
|
||||
logic.onBlockPlaced();
|
||||
|
@ -165,13 +161,24 @@ public class PipeItemsDaizuli extends Pipe<PipeTransportItems> implements IPipeT
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<IAction, Boolean> action : actions.entrySet()) {
|
||||
if (action.getKey() instanceof ActionPipeDirection && action.getValue() != null && action.getValue()) {
|
||||
logic.setFacing(((ActionPipeDirection) action.getKey()).direction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedList<IAction> getActions() {
|
||||
LinkedList<IAction> result = super.getActions();
|
||||
result.addAll(Arrays.asList(BuildCraftTransport.actionPipeColor));
|
||||
return result;
|
||||
LinkedList<IAction> action = super.getActions();
|
||||
action.addAll(Arrays.asList(BuildCraftTransport.actionPipeColor));
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (container.isPipeConnected(direction))
|
||||
action.add(BuildCraftTransport.actionPipeDirection[direction.ordinal()]);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,12 +9,18 @@ package buildcraft.transport.pipes;
|
|||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.PipeTransportItems;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import buildcraft.transport.triggers.ActionPipeColor;
|
||||
import buildcraft.transport.triggers.ActionPipeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -55,7 +61,7 @@ public class PipeItemsIron extends Pipe<PipeTransportItems> {
|
|||
|
||||
@Override
|
||||
public void onNeighborBlockChange(int blockId) {
|
||||
logic.onNeighborBlockChange(blockId);
|
||||
logic.switchOnRedstone();
|
||||
super.onNeighborBlockChange(blockId);
|
||||
}
|
||||
|
||||
|
@ -96,6 +102,28 @@ public class PipeItemsIron extends Pipe<PipeTransportItems> {
|
|||
return BuildCraftTransport.instance.pipeIconProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionsActivated(Map<IAction, Boolean> actions) {
|
||||
super.actionsActivated(actions);
|
||||
|
||||
for (Map.Entry<IAction, Boolean> action : actions.entrySet()) {
|
||||
if (action.getKey() instanceof ActionPipeDirection && action.getValue() != null && action.getValue()) {
|
||||
logic.setFacing(((ActionPipeDirection) action.getKey()).direction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedList<IAction> getActions() {
|
||||
LinkedList<IAction> action = super.getActions();
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (container.isPipeConnected(direction))
|
||||
action.add(BuildCraftTransport.actionPipeDirection[direction.ordinal()]);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone() {
|
||||
return true;
|
||||
|
|
|
@ -22,7 +22,7 @@ public abstract class PipeLogicIron {
|
|||
this.pipe = pipe;
|
||||
}
|
||||
|
||||
private void switchPower() {
|
||||
public void switchOnRedstone() {
|
||||
boolean currentPower = pipe.container.worldObj.isBlockIndirectlyGettingPowered(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord);
|
||||
|
||||
if (currentPower != lastPower) {
|
||||
|
@ -33,21 +33,14 @@ public abstract class PipeLogicIron {
|
|||
}
|
||||
|
||||
private void switchPosition() {
|
||||
int meta = pipe.container.worldObj.getBlockMetadata(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord);
|
||||
|
||||
ForgeDirection newFacing = null;
|
||||
int meta = pipe.container.getBlockMetadata();
|
||||
|
||||
for (int i = meta + 1; i <= meta + 6; ++i) {
|
||||
ForgeDirection facing = ForgeDirection.getOrientation(i % 6);
|
||||
if (isValidFacing(facing)) {
|
||||
newFacing = facing;
|
||||
break;
|
||||
if (setFacing(facing)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (newFacing != null && newFacing.ordinal() != meta) {
|
||||
pipe.container.worldObj.setBlockMetadataWithNotify(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, newFacing.ordinal(), 3);
|
||||
pipe.container.scheduleRenderUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean isValidFacing(ForgeDirection facing);
|
||||
|
@ -61,6 +54,15 @@ public abstract class PipeLogicIron {
|
|||
switchPosition();
|
||||
}
|
||||
|
||||
public boolean setFacing(ForgeDirection facing) {
|
||||
if (isValidFacing(facing) && facing.ordinal() != pipe.container.getBlockMetadata()) {
|
||||
pipe.container.worldObj.setBlockMetadataWithNotify(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, facing.ordinal(), 3);
|
||||
pipe.container.scheduleRenderUpdate();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
Item equipped = entityplayer.getCurrentEquippedItem() != null ? entityplayer.getCurrentEquippedItem().getItem() : null;
|
||||
if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(entityplayer, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord)) {
|
||||
|
@ -74,10 +76,6 @@ public abstract class PipeLogicIron {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange(int blockId) {
|
||||
switchPower();
|
||||
}
|
||||
|
||||
public boolean outputOpen(ForgeDirection to) {
|
||||
return to.ordinal() == pipe.container.getBlockMetadata();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011 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.transport.triggers;
|
||||
|
||||
import buildcraft.core.triggers.BCAction;
|
||||
import java.util.Locale;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class ActionPipeDirection extends BCAction {
|
||||
|
||||
private Icon icon;
|
||||
public final ForgeDirection direction;
|
||||
|
||||
public ActionPipeDirection(int id, ForgeDirection direction) {
|
||||
super(id, "buildcraft.pipe.dir." + direction.name().toLowerCase(Locale.ENGLISH));
|
||||
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return direction.name().substring(0, 1) + direction.name().substring(1).toLowerCase(Locale.ENGLISH) + " Pipe Direction";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister iconRegister) {
|
||||
icon = iconRegister.registerIcon("buildcraft:triggers/trigger_dir_" + direction.name().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
}
|