int mode = itemStack.getTagCompound().getInteger("CreatorMode");
ForgeDirection dir = ForgeDirection.getOrientation(sideinput);
if(dir == ForgeDirection.UNKNOWN) return false;
CoreRoutedPipe pipe = (CoreRoutedPipe) ((LogisticsTileGenericPipe)tile).pipe;
if(pipe == null) { return false; }
if(!player.isSneaking()) {
if(pipe.hasPipeSign(dir)) {
pipe.activatePipeSign(dir, player);
return true;
} else if(mode >= 0 && mode < signTypes.size()) {
Class<? extends IPipeSign> signClass = signTypes.get(mode);
try {
IPipeSign sign = signClass.newInstance();
if(sign.isAllowedFor(pipe)) {
itemStack.damageItem(1, player);
sign.addSignTo(pipe, dir, player);
return true;
} else {
return false;
}
} catch(InstantiationException e) {
throw new RuntimeException(e);
} catch(IllegalAccessException e) {
throw new RuntimeException(e);
}
} else {
return false;
}
} else {
if(pipe.hasPipeSign(dir)) {
pipe.removePipeSign(dir, player);
itemStack.damageItem(-1, player);
}
return true;
}
}