add shift-click support to statement parameters, close #2107 (at last)
This commit is contained in:
parent
927f081c06
commit
da8d4513c4
10 changed files with 42 additions and 15 deletions
|
@ -46,7 +46,7 @@ public interface IStatementParameter {
|
|||
*/
|
||||
String getDescription();
|
||||
|
||||
void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton);
|
||||
void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse);
|
||||
|
||||
void readFromNBT(NBTTagCompound compound);
|
||||
|
||||
|
|
19
api/buildcraft/api/statements/StatementMouseClick.java
Normal file
19
api/buildcraft/api/statements/StatementMouseClick.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package buildcraft.api.statements;
|
||||
|
||||
public final class StatementMouseClick {
|
||||
private int button;
|
||||
private boolean shift;
|
||||
|
||||
public StatementMouseClick(int button, boolean shift) {
|
||||
this.button = button;
|
||||
this.shift = shift;
|
||||
}
|
||||
|
||||
public boolean isShift() {
|
||||
return shift;
|
||||
}
|
||||
|
||||
public int getButton() {
|
||||
return button;
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ public class StatementParameterItemStack implements IStatementParameter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse) {
|
||||
if (stack != null) {
|
||||
this.stack = stack.copy();
|
||||
this.stack.stackSize = 1;
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*/
|
||||
package buildcraft.core;
|
||||
|
||||
import buildcraft.api.gates.IAction;
|
||||
|
||||
/**
|
||||
* Left only to stop certain mods depending on it from crashing.
|
||||
* Please move to the classes contained in builcraft.api.tiles
|
||||
|
|
|
@ -215,7 +215,8 @@ public class Blueprint extends BlueprintBase {
|
|||
}
|
||||
|
||||
if (block != null) {
|
||||
contents[x][y][z] = SchematicRegistry.INSTANCE.createSchematicBlock(block, cpt.getInteger("blockMeta"));
|
||||
int meta = cpt.getInteger("blockMeta");
|
||||
contents[x][y][z] = SchematicRegistry.INSTANCE.createSchematicBlock(block, meta);
|
||||
if (contents[x][y][z] != null) {
|
||||
contents[x][y][z].readSchematicFromNBT(cpt, mapping);
|
||||
|
||||
|
@ -226,6 +227,9 @@ public class Blueprint extends BlueprintBase {
|
|||
case ALL:
|
||||
break;
|
||||
case CREATIVE_ONLY:
|
||||
System.out.println("FOUND CREATIVE BUILDING PERMISSION");
|
||||
System.out.println("- block: " + Block.blockRegistry.getNameForObject(block));
|
||||
System.out.println("- meta: " + meta);
|
||||
if (buildingPermission == BuildingPermission.ALL) {
|
||||
buildingPermission = BuildingPermission.CREATIVE_ONLY;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import buildcraft.api.gates.IGate;
|
|||
import buildcraft.api.statements.IStatement;
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import buildcraft.api.statements.StatementMouseClick;
|
||||
import buildcraft.api.transport.IPipe;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
|
@ -48,10 +49,10 @@ public class StatementParameterDirection implements IStatementParameter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse) {
|
||||
if (source.getTile() instanceof TileGenericPipe) {
|
||||
do {
|
||||
direction = ForgeDirection.getOrientation((direction.ordinal() + (mouseButton > 0 ? -1 : 1)) % 6);
|
||||
direction = ForgeDirection.getOrientation((direction.ordinal() + (mouse.getButton() > 0 ? -1 : 1)) % 6);
|
||||
} while (((TileGenericPipe) source.getTile()).isPipeConnected(direction));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import buildcraft.api.core.NetworkData;
|
|||
import buildcraft.api.statements.IStatement;
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import buildcraft.api.statements.StatementMouseClick;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
public class StatementParameterRedstoneGateSideOnly implements
|
||||
|
@ -36,7 +37,7 @@ public class StatementParameterRedstoneGateSideOnly implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse) {
|
||||
isOn = !isOn;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import buildcraft.api.statements.IStatement;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import buildcraft.api.statements.StatementMouseClick;
|
||||
import buildcraft.core.gui.AdvancedSlot;
|
||||
import buildcraft.core.gui.GuiAdvancedInterface;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
@ -473,7 +474,8 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
}
|
||||
|
||||
if (param != null) {
|
||||
param.onClick(gate, statement.getStatement(), mc.thePlayer.inventory.getItemStack(), k);
|
||||
param.onClick(gate, statement.getStatement(), mc.thePlayer.inventory.getItemStack(),
|
||||
new StatementMouseClick(k, isShiftKeyDown()));
|
||||
paramSlot.setParameter(param, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import buildcraft.api.core.NetworkData;
|
|||
import buildcraft.api.statements.IStatement;
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import buildcraft.api.statements.StatementMouseClick;
|
||||
import buildcraft.api.transport.PipeWire;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
|
@ -41,13 +42,13 @@ public class ActionParameterSignal implements IStatementParameter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse) {
|
||||
if (color == null) {
|
||||
color = mouseButton == 0 ? PipeWire.RED : PipeWire.YELLOW;
|
||||
} else if (color == (mouseButton == 0 ? PipeWire.YELLOW : PipeWire.RED)) {
|
||||
color = mouse.getButton() == 0 ? PipeWire.RED : PipeWire.YELLOW;
|
||||
} else if (color == (mouse.getButton() == 0 ? PipeWire.YELLOW : PipeWire.RED)) {
|
||||
color = null;
|
||||
} else {
|
||||
color = PipeWire.values()[mouseButton == 0 ? color.ordinal() + 1 : color.ordinal() - 1];
|
||||
color = PipeWire.values()[mouse.getButton() == 0 ? color.ordinal() + 1 : color.ordinal() - 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import buildcraft.api.core.NetworkData;
|
|||
import buildcraft.api.statements.IStatement;
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import buildcraft.api.statements.StatementMouseClick;
|
||||
import buildcraft.api.transport.PipeWire;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.transport.Gate;
|
||||
|
@ -54,8 +55,8 @@ public class TriggerParameterSignal implements IStatementParameter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
if (mouseButton == 0) {
|
||||
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse) {
|
||||
if (mouse.getButton() == 0) {
|
||||
if (color == null) {
|
||||
active = true;
|
||||
color = PipeWire.RED;
|
||||
|
|
Loading…
Reference in a new issue