Permalink
Browse files

Add MetaData support to SetBlockAbove/Below

  • Loading branch information...
me4502 committed Apr 25, 2012
1 parent aad7f34 commit 537d1ff8417cc8ea8bf8b4139065d7d8ac720157
@@ -47,11 +47,14 @@ public String getSignTitle() {
return "SET BLOCK ABOVE";
}
- //TODO: add block metadata support
@Override
public void trigger(ChipState chip) {
- String sblock = getSign().getLine(2).toUpperCase().trim();
+ String sblockdat = getSign().getLine(2).toUpperCase().trim();
+ String sblock = sblockdat.split(":")[0];
+ String smeta = "";
+ if(sblockdat.split(":").length>1)
+ smeta = sblockdat.split(":")[1];
String force = getSign().getLine(3).toUpperCase().trim();
chip.setOutput(0, chip.getInput(0));
@@ -68,6 +71,15 @@ public void trigger(ChipState chip) {
return;
}
+ byte meta = -1;
+ try {
+ if(!smeta.equalsIgnoreCase(""))
+ meta = Byte.parseByte(smeta);
+ } catch (Exception e) {
+ return;
+ }
+
+
Block body = SignUtil.getBackBlock(getSign().getBlock());
int x = body.getX();
@@ -76,6 +88,8 @@ public void trigger(ChipState chip) {
if(force.equals("FORCE") || body.getWorld().getBlockAt(x, y+1, z).getType() == Material.AIR) {
body.getWorld().getBlockAt(x, y+1, z).setTypeId(block);
+ if(!(meta==-1))
+ body.getWorld().getBlockAt(x, y+1, z).setData(meta);
}
}
@@ -47,11 +47,14 @@ public String getSignTitle() {
return "SET BLOCK BELOW";
}
- //TODO: add block metadata support
@Override
public void trigger(ChipState chip) {
- String sblock = getSign().getLine(2).toUpperCase().trim();
+ String sblockdat = getSign().getLine(2).toUpperCase().trim();
+ String sblock = sblockdat.split(":")[0];
+ String smeta = "";
+ if(sblockdat.split(":").length>1)
+ smeta = sblockdat.split(":")[1];
String force = getSign().getLine(3).toUpperCase().trim();
chip.setOutput(0, chip.getInput(0));
@@ -67,6 +70,14 @@ public void trigger(ChipState chip) {
} catch (Exception e) {
return;
}
+
+ byte meta = -1;
+ try {
+ if(!smeta.equalsIgnoreCase(""))
+ meta = Byte.parseByte(smeta);
+ } catch (Exception e) {
+ return;
+ }
Block body = SignUtil.getBackBlock(getSign().getBlock());
@@ -76,6 +87,9 @@ public void trigger(ChipState chip) {
if(force.equals("FORCE") || body.getWorld().getBlockAt(x, y-1, z).getType() == Material.AIR) {
body.getWorld().getBlockAt(x, y-1, z).setTypeId(block);
+ if(!(meta==-1))
+ body.getWorld().getBlockAt(x, y-1, z).setData(meta);
+
}
}

0 comments on commit 537d1ff

Please sign in to comment.