That's not the complete story. You'd need something to process the bracket syntax you want to use for the schematic blocks. If that bracket handler generates values of type, say, SchematicBlock, then your addSchematic method would receive arguments of the type (String, SchematicBlock[]).
The bracket handler would be the most annoying part, so I made one up for you (untested, may contain some errors):
- : [Select all] [/] [] ()
public class SchematicBlockBracketHandler implements IBracketHandler {
public static SchematicBlock getBlock(int x, int y, int z, IItemStack item) {
return new SchematicBlock(x, y, z, item);
}
private final IJavaMethod method;
private final ItemBracketHandler itemHandler;
public SchematicBlockBracketHandler() {
itemHandler = new ItemBracketHandler();
method = MineTweakerAPI.getJavaMethod(
SchematicBlockBracketHandler.class,
"getBlock",
int.class, int.class, int.class, IItemStack.class);
}
@Override
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
if (tokens.size() < 8)
return null;
if (!tokens.get(0).getValue().equals("sb"))
return null;
if (tokens.get(1).getType() != ZenTokener.T_COLON
|| tokens.get(2).getType() != ZenTokener.T_INTVALUE
|| tokens.get(3).getType() != ZenTokener.T_COLON
|| tokens.get(4).getType() != ZenTokener.T_INTVALUE
|| tokens.get(5).getType() != ZenTokener.T_COLON
|| tokens.get(6).getType() != ZenTokener.T_INTVALUE
|| tokens.get(7).getType() != ZenTokener.T_COLON)
return null;
int x
= Integer.
parseInt(tokens.
get(2).
getValue()); int y
= Integer.
parseInt(tokens.
get(4).
getValue()); int z
= Integer.
parseInt(tokens.
get(6).
getValue()); IZenSymbol itemStack = itemHandler.resolve(environment, tokens.subList(8, tokens.size()));
return new SchematicBlockSymbol(environment, x, y, z, itemStack);
}
private class ItemReferenceSymbol implements IZenSymbol {
private final IEnvironmentGlobal environment;
private final int x;
private final int y;
private final int z;
private final IZenSymbol itemStack;
public ItemReferenceSymbol(IEnvironmentGlobal environment, int x, int y, int z, IZenSymbol itemStack) {
this.environment = environment;
this.x = x;
this.y = y;
this.z = z;
this.itemStack = itemStack;
}
@Override
public IPartialExpression instance(ZenPosition position) {
return new ExpressionCallStatic(
position,
environment,
method,
new ExpressionInt(position, x, ZenType.INT),
new ExpressionInt(position, y, ZenType.INT),
new ExpressionInt(position, z, ZenType.INT),
itemStack.instance(position).eval());
}
}
}
- GeSHi © Codebox Plus
Sorry if this is a bit cumbersome, next release will have easier ways of doing things like this.
Besides the bracket syntax handler, all you'd need is an integration class, which would be the easy part;
- : [Select all] [/] [] ()
@ZenClass("mods.mymod.Schematics")
class Schematics {
@ZenMethod
public static void addSchematic
(String schematicName, SchematicBlock
[] blocks
) { ...
register your schematic ...
} }
- GeSHi © Codebox Plus
Don't forget to register both classes using the corresponding register methods in MineTweakerAPI!