use of igwmod.gui.LocatedString in project PneumaticCraft by MineMaarten.
the class IntegratorAssembly method onCommandInvoke.
@Override
public void onCommandInvoke(String[] arguments, List<IReservedSpace> reservedSpaces, List<LocatedString> locatedStrings, List<LocatedStack> locatedStacks, List<IWidget> locatedTextures) throws IllegalArgumentException {
if (arguments.length != 3 && arguments.length != 4)
throw new IllegalArgumentException("Code needs 3 or 4 arguments!");
int x;
try {
x = Integer.parseInt(arguments[0]);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("The first parameter (the x coordinate) contains an invalid number. Check for invalid characters!");
}
int y;
try {
y = Integer.parseInt(arguments[1]);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("The second parameter (the y coordinate) contains an invalid number. Check for invalid characters!");
}
locatedTextures.add(new LocatedTexture(TextureSupplier.getTexture(Textures.ICON_LOCATION + "textures/wiki/assemblyLineRecipe.png"), x, y, 1 / GuiWiki.TEXT_SCALE));
int recipeIndex = 0;
if (arguments.length == 4) {
try {
recipeIndex = Integer.parseInt(arguments[3]);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("The fourth parameter (the recipeIndex) contains an invalid number. Check for invalid characters!");
}
}
int[] hits = new int[] { recipeIndex };
int program = ItemAssemblyProgram.DRILL_LASER_DAMAGE;
AssemblyRecipe foundRecipe = findRecipe(hits, AssemblyRecipe.drillRecipes, arguments[2]);
if (foundRecipe == null) {
foundRecipe = findRecipe(hits, AssemblyRecipe.laserRecipes, arguments[2]);
} else {
program = ItemAssemblyProgram.DRILL_DAMAGE;
}
if (foundRecipe == null) {
foundRecipe = findRecipe(hits, AssemblyRecipe.drillLaserRecipes, arguments[2]);
} else {
program = ItemAssemblyProgram.LASER_DAMAGE;
}
if (foundRecipe == null)
throw new IllegalArgumentException("No recipe found for the string " + arguments[2] + " and the requested index " + recipeIndex + ".");
locatedStacks.add(new LocatedStack(foundRecipe.getInput(), (int) (GuiWiki.TEXT_SCALE * x) + 1, (int) (GuiWiki.TEXT_SCALE * y) + 46));
locatedStacks.add(new LocatedStack(foundRecipe.getOutput(), (int) (GuiWiki.TEXT_SCALE * x) + 68, (int) (GuiWiki.TEXT_SCALE * y) + 46));
locatedStacks.add(new LocatedStack(new ItemStack(Itemss.assemblyProgram, 1, program), (int) (GuiWiki.TEXT_SCALE * x) + 78, (int) (GuiWiki.TEXT_SCALE * y) + 15));
locatedStrings.add(new LocatedString("Program:", x + 150, y + 5, 0xFF000000, false));
locatedStrings.add(new LocatedString("Assembly Line", x + 40, y + 30, 0xFF000000, false));
}
use of igwmod.gui.LocatedString in project PneumaticCraft by MineMaarten.
the class IntegratorPressureChamber method onCommandInvoke.
@Override
public void onCommandInvoke(String[] arguments, List<IReservedSpace> reservedSpaces, List<LocatedString> locatedStrings, List<LocatedStack> locatedStacks, List<IWidget> locatedTextures) throws IllegalArgumentException {
if (arguments.length != 3)
throw new IllegalArgumentException("Code needs 3 arguments!");
int x;
try {
x = Integer.parseInt(arguments[0]);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("The first parameter (the x coordinate) contains an invalid number. Check for invalid characters!");
}
int y;
try {
y = Integer.parseInt(arguments[1]);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("The second parameter (the y coordinate) contains an invalid number. Check for invalid characters!");
}
locatedTextures.add(new LocatedTexture(TextureSupplier.getTexture(Textures.ICON_LOCATION + "textures/wiki/pressureChamberRecipe.png"), x, y, 1 / GuiWiki.TEXT_SCALE));
if (arguments[2].equals("disenchanting")) {
handleDisenchanting(x, y, locatedStacks);
} else if (arguments[2].equals("villagers")) {
handleVillagers(x, y, locatedTextures);
} else {
PressureChamberRecipe foundRecipe = null;
for (PressureChamberRecipe recipe : PressureChamberRecipe.chamberRecipes) {
for (ItemStack output : recipe.output) {
if (WikiUtils.getNameFromStack(output).equals(arguments[2])) {
foundRecipe = recipe;
break;
}
}
}
if (foundRecipe == null)
throw new IllegalArgumentException("No recipe found for the key " + arguments[2]);
locatedStrings.add(new LocatedString(I18n.format("igwmod.pressureChamber.requiredPressure") + ":", x + 180, y + 10, 0xFF000000, false));
locatedStrings.add(new LocatedString(foundRecipe.pressure + " bar", x + 215, y + 20, 0xFF000000, false));
for (int i = 0; i < foundRecipe.input.length; i++) {
LocatedStack stack = new LocatedStack(PneumaticRecipeRegistry.getSingleStack(foundRecipe.input[i]), (int) ((x + 36 + i % 3 * 34) * GuiWiki.TEXT_SCALE), (int) ((y + 102 - i / 3 * 34) * GuiWiki.TEXT_SCALE));
locatedStacks.add(stack);
}
for (int i = 0; i < foundRecipe.output.length; i++) {
LocatedStack stack = new LocatedStack(foundRecipe.output[i], (int) ((x + 180 + i % 3 * 36) * GuiWiki.TEXT_SCALE), (int) ((y + 60 + i / 3 * 36) * GuiWiki.TEXT_SCALE));
locatedStacks.add(stack);
}
}
}
Aggregations