use of gregtech.api.pattern.TraceabilityPredicate in project GregTech by GregTechCEu.
the class MultiblockInfoRecipeWrapper method handleClick.
@Override
public boolean handleClick(@Nonnull Minecraft minecraft, int mouseX, int mouseY, int mouseButton) {
for (Entry<GuiButton, Runnable> button : buttons.entrySet()) {
if (button.getKey().mousePressed(minecraft, mouseX, mouseY)) {
button.getValue().run();
selected = null;
return true;
}
}
if (mouseButton == 1) {
if (getCurrentRenderer().getLastTraceResult() == null) {
if (this.selected != null) {
this.selected = null;
for (int i = 0; i < predicates.size(); i++) {
recipeLayout.getItemStacks().set(i + MAX_PARTS, ItemStack.EMPTY);
}
predicates.clear();
this.father = null;
return true;
}
return false;
}
BlockPos selected = getCurrentRenderer().getLastTraceResult().getBlockPos();
if (!Objects.equals(this.selected, selected)) {
for (int i = 0; i < predicates.size(); i++) {
recipeLayout.getItemStacks().set(i + MAX_PARTS, ItemStack.EMPTY);
}
predicates.clear();
this.father = null;
this.selected = selected;
TraceabilityPredicate predicate = patterns[currentRendererPage].predicateMap.get(this.selected);
if (predicate != null) {
predicates.addAll(predicate.common);
predicates.addAll(predicate.limited);
predicates.removeIf(p -> p.candidates == null);
this.father = predicate;
setItemStackGroup();
}
return true;
}
}
return false;
}
Aggregations