use of buildcraft.api.statements.IStatementParameter in project BuildCraft by BuildCraft.
the class GuiElementStatementDrag method drawForeground.
@Override
public void drawForeground(float partialTicks) {
if (isDragging) {
boolean canPlace = false;
for (IGuiElement element : gui.getElementsAt(gui.mouse.getX(), gui.mouse.getY())) {
if (element instanceof IReference<?>) {
if (checkCanSet((IReference<?>) element, dragging)) {
canPlace = true;
break;
}
}
}
GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT);
if (!canPlace) {
GlStateManager.color(1.0f, 0.7f, 0.7f);
}
double x = gui.mouse.getX() - 9;
double y = gui.mouse.getY() - 9;
if (dragging instanceof IStatementParameter) {
ParameterRenderer.draw((IStatementParameter) dragging, x, y);
} else {
GuiIcon background = GuiElementStatement.SLOT_COLOUR;
if (dragging instanceof StatementWrapper) {
EnumPipePart part = ((StatementWrapper) dragging).sourcePart;
if (part != EnumPipePart.CENTER) {
background = background.offset(0, (1 + part.getIndex()) * 18);
}
}
background.drawAt(x, y);
if (dragging != null) {
ISprite sprite = dragging.getSprite();
if (sprite != null) {
GuiIcon.drawAt(sprite, x + 1, y + 1, 16);
}
}
}
GlStateManager.color(1, 1, 1);
}
}
use of buildcraft.api.statements.IStatementParameter in project BuildCraft by BuildCraft.
the class GuiElementStatementSource method drawGuiSlot.
public static void drawGuiSlot(@Nullable IGuiSlot guiSlot, double x, double y) {
if (guiSlot instanceof IStatementParameter) {
ParameterRenderer.draw((IStatementParameter) guiSlot, x, y);
return;
}
GuiIcon background = GuiElementStatement.SLOT_COLOUR;
if (guiSlot instanceof StatementWrapper) {
EnumPipePart part = ((StatementWrapper) guiSlot).sourcePart;
if (part != EnumPipePart.CENTER) {
background = background.offset(0, (1 + part.getIndex()) * 18);
}
}
background.drawAt(x, y);
if (guiSlot != null) {
ISprite sprite = guiSlot.getSprite();
if (sprite != null) {
GuiIcon.drawAt(sprite, x + 1, y + 1, 16);
}
}
}
use of buildcraft.api.statements.IStatementParameter in project BuildCraft by BuildCraft.
the class ActionRobotFilterTool method getGateFilterStacks.
public static Collection<ItemStack> getGateFilterStacks(DockingStation station) {
ArrayList<ItemStack> result = new ArrayList<>();
for (StatementSlot slot : station.getActiveActions()) {
if (slot.statement instanceof ActionRobotFilterTool) {
for (IStatementParameter p : slot.parameters) {
if (p != null && p instanceof StatementParameterItemStack) {
StatementParameterItemStack param = (StatementParameterItemStack) p;
ItemStack stack = param.getItemStack();
if (stack != null) {
result.add(stack);
}
}
}
}
}
return result;
}
use of buildcraft.api.statements.IStatementParameter in project BuildCraft by BuildCraft.
the class ShapePatternsTester method testSphereEquality.
/**
* Ensure that (for the same implicit size sphere) SPHERE, SPHERE_HALF, SPHERE_QUARTER, and SPHERE_EIGHTH all
* generate the same sphere.
*
* @param size an eighth of the size of the entire sphere.
*/
@Theory
public void testSphereEquality(BlockPos size) {
BlockPos fullSize = new BlockPos(size.getX() * 2, size.getY() * 2, size.getZ() * 2);
System.out.println("Testing spheres for equality in " + StringUtilBC.blockPosToString(fullSize));
IStatementParameter[] fullParams = new IStatementParameter[] { //
PatternParameterHollow.HOLLOW };
IFilledTemplate filledTemplateFull = createFilledTemplate(fullSize);
Assert.assertTrue(BCBuildersStatements.PATTERN_SPHERE.fillTemplate(filledTemplateFull, fullParams));
System.out.println("Full:\n" + filledTemplateFull);
// Test halfs
for (EnumFacing face : EnumFacing.VALUES) {
BlockPos halfSize = VecUtil.replaceValue(fullSize, face.getAxis(), VecUtil.getValue(size, face.getAxis()));
IStatementParameter[] params = new IStatementParameter[] { //
PatternParameterHollow.HOLLOW, //
PatternParameterFacing.get(face) };
IFilledTemplate filledTemplateHalf = createFilledTemplate(halfSize);
Assert.assertTrue(BCBuildersStatements.PATTERN_HEMI_SPHERE.fillTemplate(filledTemplateHalf, params));
System.out.println("Half:\n" + filledTemplateHalf);
int dx = face == EnumFacing.WEST ? filledTemplateHalf.getSize().getX() : 0;
int dy = face == EnumFacing.DOWN ? filledTemplateHalf.getSize().getY() : 0;
int dz = face == EnumFacing.NORTH ? filledTemplateHalf.getSize().getZ() : 0;
for (int z = 0; z <= filledTemplateHalf.getMax().getZ(); z++) {
for (int y = 0; y <= filledTemplateHalf.getMax().getY(); y++) {
for (int x = 0; x <= filledTemplateHalf.getMax().getX(); x++) {
if (filledTemplateFull.get(x + dx, y + dy, z + dz) != filledTemplateHalf.get(x, y, z)) {
Assert.fail(String.format("Half sphere[%s] didn't match full sphere at (%s, %s, %s)", face, x, y, z));
}
}
}
}
}
// TODO: Test quarters
}
use of buildcraft.api.statements.IStatementParameter in project BuildCraft by BuildCraft.
the class ShapePatternsTester method testTinyTemplate.
@Theory
public void testTinyTemplate(IFillerPatternShape pattern, BlockPos size) {
System.out.print("Testing pattern " + pattern.getUniqueTag() + " in " + StringUtilBC.blockPosToString(size));
try {
IStatementParameter[] params = new IStatementParameter[pattern.maxParameters()];
for (int i = 0; i < params.length; i++) {
params[i] = pattern.createParameter(i);
}
IFilledTemplate filledTemplate = createFilledTemplate(size);
boolean b = pattern.fillTemplate(filledTemplate, params);
if (pattern == BCBuildersStatements.PATTERN_NONE) {
Assert.assertFalse(b);
} else {
Assert.assertTrue(b);
}
System.out.println(" -> success");
} catch (Throwable t) {
System.out.println(" -> fail");
throw t;
}
}
Aggregations