use of gregtech.api.pattern.TraceabilityPredicate in project GregTech by GregTechCEu.
the class MetaTileEntityLargeChemicalReactor method createStructurePattern.
@Override
protected BlockPattern createStructurePattern() {
TraceabilityPredicate casing = states(getCasingState()).setMinGlobalLimited(10);
TraceabilityPredicate abilities = autoAbilities();
return FactoryBlockPattern.start().aisle("XXX", "XCX", "XXX").aisle("XCX", "CPC", "XCX").aisle("XXX", "XSX", "XXX").where('S', selfPredicate()).where('X', casing.or(abilities)).where('P', states(getPipeCasingState())).where('C', states(MetaBlocks.WIRE_COIL.getState(BlockWireCoil.CoilType.CUPRONICKEL)).setMinGlobalLimited(1).setMaxGlobalLimited(1).or(abilities).or(casing)).build();
}
use of gregtech.api.pattern.TraceabilityPredicate in project GregTech by GregTechCEu.
the class MetaTileEntityProcessingArray method autoAbilities.
@Override
public TraceabilityPredicate autoAbilities(boolean checkEnergyIn, boolean checkMaintenance, boolean checkItemIn, boolean checkItemOut, boolean checkFluidIn, boolean checkFluidOut, boolean checkMuffler) {
TraceabilityPredicate predicate = super.autoAbilities(checkMaintenance, checkMuffler).or(checkEnergyIn ? abilities(MultiblockAbility.INPUT_ENERGY).setMinGlobalLimited(1).setMaxGlobalLimited(4).setPreviewCount(1) : new TraceabilityPredicate());
predicate = predicate.or(abilities(MultiblockAbility.IMPORT_ITEMS).setPreviewCount(1));
predicate = predicate.or(abilities(MultiblockAbility.EXPORT_ITEMS).setPreviewCount(1));
predicate = predicate.or(abilities(MultiblockAbility.IMPORT_FLUIDS).setPreviewCount(1));
predicate = predicate.or(abilities(MultiblockAbility.EXPORT_FLUIDS).setPreviewCount(1));
return predicate;
}
use of gregtech.api.pattern.TraceabilityPredicate in project GregTech by GregTechCEu.
the class MultiblockInfoRecipeWrapper method initializePattern.
private MBPattern initializePattern(MultiblockShapeInfo shapeInfo, Set<ItemStackKey> blockDrops) {
Map<BlockPos, BlockInfo> blockMap = new HashMap<>();
MultiblockControllerBase controllerBase = null;
BlockInfo[][][] blocks = shapeInfo.getBlocks();
for (int x = 0; x < blocks.length; x++) {
BlockInfo[][] aisle = blocks[x];
for (int y = 0; y < aisle.length; y++) {
BlockInfo[] column = aisle[y];
for (int z = 0; z < column.length; z++) {
if (column[z].getTileEntity() instanceof MetaTileEntityHolder && ((MetaTileEntityHolder) column[z].getTileEntity()).getMetaTileEntity() instanceof MultiblockControllerBase) {
controllerBase = (MultiblockControllerBase) ((MetaTileEntityHolder) column[z].getTileEntity()).getMetaTileEntity();
}
blockMap.put(new BlockPos(x, y, z), column[z]);
}
}
}
TrackedDummyWorld world = new TrackedDummyWorld();
ImmediateWorldSceneRenderer worldSceneRenderer = new ImmediateWorldSceneRenderer(world);
worldSceneRenderer.setClearColor(0xC6C6C6);
world.addBlocks(blockMap);
Vector3f size = world.getSize();
Vector3f minPos = world.getMinPos();
center = new Vector3f(minPos.x + size.x / 2, minPos.y + size.y / 2, minPos.z + size.z / 2);
worldSceneRenderer.addRenderedBlocks(world.renderedBlocks, null);
worldSceneRenderer.setOnLookingAt(ray -> {
});
worldSceneRenderer.setAfterWorldRender(renderer -> {
BlockPos look = worldSceneRenderer.getLastTraceResult() == null ? null : worldSceneRenderer.getLastTraceResult().getBlockPos();
if (look != null && look.equals(selected)) {
renderBlockOverLay(selected, 200, 75, 75);
return;
}
renderBlockOverLay(look, 150, 150, 150);
renderBlockOverLay(selected, 255, 0, 0);
});
world.updateEntities();
world.setRenderFilter(pos -> worldSceneRenderer.renderedBlocksMap.keySet().stream().anyMatch(c -> c.contains(pos)));
List<ItemStack> parts = gatherBlockDrops(worldSceneRenderer.world, blockMap, blockDrops).values().stream().sorted((one, two) -> {
if (one.isController)
return -1;
if (two.isController)
return +1;
if (one.isTile && !two.isTile)
return -1;
if (two.isTile && !one.isTile)
return +1;
if (one.blockId != two.blockId)
return two.blockId - one.blockId;
return two.amount - one.amount;
}).map(PartInfo::getItemStack).collect(Collectors.toList());
Map<BlockPos, TraceabilityPredicate> predicateMap = new HashMap<>();
if (controllerBase != null) {
controllerBase.structurePattern.cache.forEach((pos, blockInfo) -> predicateMap.put(BlockPos.fromLong(pos), (TraceabilityPredicate) blockInfo.getInfo()));
}
return new MBPattern(worldSceneRenderer, parts, predicateMap);
}
use of gregtech.api.pattern.TraceabilityPredicate in project GregTech by GregTechCEu.
the class MultiMapMultiblockController method autoAbilities.
@Override
public TraceabilityPredicate autoAbilities(boolean checkEnergyIn, boolean checkMaintenance, boolean checkItemIn, boolean checkItemOut, boolean checkFluidIn, boolean checkFluidOut, boolean checkMuffler) {
boolean checkedItemIn = false, checkedItemOut = false, checkedFluidIn = false, checkedFluidOut = false;
TraceabilityPredicate predicate = super.autoAbilities(checkMaintenance, checkMuffler).or(checkEnergyIn ? abilities(MultiblockAbility.INPUT_ENERGY).setMinGlobalLimited(1).setMaxGlobalLimited(3).setPreviewCount(1) : new TraceabilityPredicate());
for (RecipeMap<?> recipeMap : getAvailableRecipeMaps()) {
if (!checkedItemIn && checkItemIn) {
if (recipeMap.getMinInputs() > 0) {
checkedItemIn = true;
predicate = predicate.or(abilities(MultiblockAbility.IMPORT_ITEMS).setMinGlobalLimited(1).setPreviewCount(1));
} else if (recipeMap.getMaxInputs() > 0) {
checkedItemIn = true;
predicate = predicate.or(abilities(MultiblockAbility.IMPORT_ITEMS).setPreviewCount(1));
}
}
if (!checkedItemOut && checkItemOut) {
if (recipeMap.getMinOutputs() > 0) {
checkedItemOut = true;
predicate = predicate.or(abilities(MultiblockAbility.EXPORT_ITEMS).setMinGlobalLimited(1).setPreviewCount(1));
} else if (recipeMap.getMaxOutputs() > 0) {
checkedItemOut = true;
predicate = predicate.or(abilities(MultiblockAbility.EXPORT_ITEMS).setPreviewCount(1));
}
}
if (!checkedFluidIn && checkFluidIn) {
if (recipeMap.getMinFluidInputs() > 0) {
checkedFluidIn = true;
predicate = predicate.or(abilities(MultiblockAbility.IMPORT_FLUIDS).setMinGlobalLimited(1).setPreviewCount(recipeMap.getMinFluidInputs()));
} else if (recipeMap.getMaxFluidInputs() > 0) {
checkedFluidIn = true;
predicate = predicate.or(abilities(MultiblockAbility.IMPORT_FLUIDS).setPreviewCount(1));
}
}
if (!checkedFluidOut && checkFluidOut) {
if (recipeMap.getMinFluidOutputs() > 0) {
checkedFluidOut = true;
predicate = predicate.or(abilities(MultiblockAbility.EXPORT_FLUIDS).setMinGlobalLimited(1).setPreviewCount(recipeMap.getMinFluidOutputs()));
} else if (recipeMap.getMaxFluidOutputs() > 0) {
checkedFluidOut = true;
predicate = predicate.or(abilities(MultiblockAbility.EXPORT_FLUIDS).setPreviewCount(1));
}
}
}
return predicate;
}
use of gregtech.api.pattern.TraceabilityPredicate in project GregTech by GregTechCEu.
the class MultiblockInfoRecipeWrapper method drawInfo.
@Override
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
WorldSceneRenderer renderer = getCurrentRenderer();
int sceneHeight = recipeHeight - PARTS_HEIGHT;
renderer.render(recipeLayout.getPosX(), recipeLayout.getPosY(), recipeWidth, sceneHeight, mouseX + recipeLayout.getPosX(), mouseY + recipeLayout.getPosY());
drawMultiblockName(recipeWidth);
// reset colors (so any elements render after this point are not dark)
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
int iconX = recipeWidth - (ICON_SIZE + RIGHT_PADDING);
int iconY = 49;
this.infoIcon.draw(minecraft, iconX, iconY);
this.drawInfoIcon = iconX <= mouseX && mouseX <= iconX + ICON_SIZE && iconY <= mouseY && mouseY <= iconY + ICON_SIZE;
// draw parts slots
for (int i = 0; i < MAX_PARTS; ++i) {
this.slot.draw(minecraft, SLOT_SIZE * i - (SLOTS_PER_ROW * SLOT_SIZE) * (i / SLOTS_PER_ROW) + (SLOT_SIZE / 2) - 2, sceneHeight + SLOT_SIZE * (i / SLOTS_PER_ROW));
}
// draw candidates slots
for (int i = 0; i < predicates.size(); i++) {
this.slot.draw(minecraft, 5 + (i / 6) * SLOT_SIZE, (i % 6) * SLOT_SIZE + 10);
}
// draw buttons
for (GuiButton button : buttons.keySet()) {
button.drawButton(minecraft, mouseX, mouseY, 0.0f);
}
tooltipBlockStack = null;
this.predicateTips = null;
RayTraceResult rayTraceResult = renderer.getLastTraceResult();
boolean insideView = mouseX >= 0 && mouseY >= 0 && mouseX < recipeWidth && mouseY < sceneHeight;
boolean leftClickHeld = Mouse.isButtonDown(0);
boolean rightClickHeld = Mouse.isButtonDown(1);
if (insideView) {
for (GuiButton button : buttons.keySet()) {
if (button.isMouseOver()) {
insideView = false;
break;
}
}
}
if (insideView) {
if (leftClickHeld) {
rotationPitch += mouseX - lastMouseX + 360;
rotationPitch = rotationPitch % 360;
rotationYaw = (float) MathHelper.clamp(rotationYaw + (mouseY - lastMouseY), -89.9, 89.9);
} else if (rightClickHeld) {
int mouseDeltaY = mouseY - lastMouseY;
if (Math.abs(mouseDeltaY) > 1) {
this.zoom = (float) MathHelper.clamp(zoom + (mouseDeltaY > 0 ? 0.5 : -0.5), 3, 999);
}
}
renderer.setCameraLookAt(center, zoom, Math.toRadians(rotationPitch), Math.toRadians(rotationYaw));
}
if (!(leftClickHeld || rightClickHeld) && rayTraceResult != null && !renderer.world.isAirBlock(rayTraceResult.getBlockPos())) {
IBlockState blockState = renderer.world.getBlockState(rayTraceResult.getBlockPos());
ItemStack itemStack = blockState.getBlock().getPickBlock(blockState, rayTraceResult, renderer.world, rayTraceResult.getBlockPos(), minecraft.player);
TraceabilityPredicate predicates = patterns[currentRendererPage].predicateMap.get(rayTraceResult.getBlockPos());
if (predicates != null) {
BlockWorldState worldState = new BlockWorldState();
worldState.update(renderer.world, rayTraceResult.getBlockPos(), new PatternMatchContext(), new HashMap<>(), new HashMap<>(), predicates);
for (TraceabilityPredicate.SimplePredicate common : predicates.common) {
if (common.test(worldState)) {
predicateTips = common.getToolTips(predicates);
break;
}
}
if (predicateTips == null) {
for (TraceabilityPredicate.SimplePredicate limit : predicates.limited) {
if (limit.test(worldState)) {
predicateTips = limit.getToolTips(predicates);
break;
}
}
}
}
if (!itemStack.isEmpty()) {
tooltipBlockStack = itemStack;
}
}
lastRender = System.currentTimeMillis();
this.lastMouseX = mouseX;
this.lastMouseY = mouseY;
GlStateManager.disableRescaleNormal();
GlStateManager.disableLighting();
RenderHelper.disableStandardItemLighting();
}
Aggregations