use of com.simibubi.create.foundation.utility.Pair in project Create by Creators-of-Create.
the class BasinCategory method draw.
@Override
public void draw(BasinRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) {
List<Pair<Ingredient, MutableInt>> actualIngredients = ItemHelper.condenseIngredients(recipe.getIngredients());
int size = actualIngredients.size() + recipe.getFluidIngredients().size();
int outSize = recipe.getFluidResults().size() + recipe.getRollableResults().size();
int xOffset = size < 3 ? (3 - size) * 19 / 2 : 0;
HeatCondition requiredHeat = recipe.getRequiredHeat();
int yOffset = 0;
for (int i = 0; i < size; i++) AllGuiTextures.JEI_SLOT.render(matrixStack, 16 + xOffset + (i % 3) * 19, 50 - (i / 3) * 19 + yOffset);
boolean noHeat = requiredHeat == HeatCondition.NONE;
int vRows = (1 + outSize) / 2;
for (int i = 0; i < outSize; i++) AllGuiTextures.JEI_SLOT.render(matrixStack, 141 - (outSize % 2 != 0 && i == outSize - 1 ? 0 : i % 2 == 0 ? 10 : -9), -19 * (i / 2) + 50 + yOffset);
if (vRows <= 2)
AllGuiTextures.JEI_DOWN_ARROW.render(matrixStack, 136, -19 * (vRows - 1) + 32 + yOffset);
AllGuiTextures shadow = noHeat ? AllGuiTextures.JEI_SHADOW : AllGuiTextures.JEI_LIGHT;
shadow.render(matrixStack, 81, 58 + (noHeat ? 10 : 30));
if (!needsHeating)
return;
AllGuiTextures heatBar = noHeat ? AllGuiTextures.JEI_NO_HEAT_BAR : AllGuiTextures.JEI_HEAT_BAR;
heatBar.render(matrixStack, 4, 80);
Minecraft.getInstance().font.draw(matrixStack, Lang.translate(requiredHeat.getTranslationKey()), 9, 86, requiredHeat.getColor());
}
use of com.simibubi.create.foundation.utility.Pair in project Create by Creators-of-Create.
the class AttributeFilterScreen method referenceItemChanged.
private void referenceItemChanged(ItemStack stack) {
lastItemScanned = stack;
if (stack.isEmpty()) {
attributeSelector.active = false;
attributeSelector.visible = false;
attributeSelectorLabel.text = referenceH.plainCopy().withStyle(ChatFormatting.ITALIC);
add.active = false;
addInverted.active = false;
attributeSelector.calling(s -> {
});
return;
}
add.active = true;
addInverted.active = true;
attributeSelector.titled(stack.getHoverName().plainCopy().append("..."));
attributesOfItem.clear();
for (ItemAttribute itemAttribute : ItemAttribute.types) attributesOfItem.addAll(itemAttribute.listAttributesOf(stack, minecraft.level));
List<Component> options = attributesOfItem.stream().map(a -> a.format(false)).collect(Collectors.toList());
attributeSelector.forOptions(options);
attributeSelector.active = true;
attributeSelector.visible = true;
attributeSelector.setState(0);
attributeSelector.calling(i -> {
attributeSelectorLabel.setTextAndTrim(options.get(i), true, 112);
ItemAttribute selected = attributesOfItem.get(i);
for (Pair<ItemAttribute, Boolean> existing : menu.selectedAttributes) {
CompoundTag testTag = new CompoundTag();
CompoundTag testTag2 = new CompoundTag();
existing.getFirst().serializeNBT(testTag);
selected.serializeNBT(testTag2);
if (testTag.equals(testTag2)) {
add.active = false;
addInverted.active = false;
return;
}
}
add.active = true;
addInverted.active = true;
});
attributeSelector.onChanged();
}
use of com.simibubi.create.foundation.utility.Pair in project Create by Creators-of-Create.
the class PumpTileEntity method searchForEndpointRecursively.
protected boolean searchForEndpointRecursively(Map<BlockPos, Pair<Integer, Map<Direction, Boolean>>> pipeGraph, Set<BlockFace> targets, Map<Integer, Set<BlockFace>> validFaces, BlockFace currentFace, boolean pull) {
BlockPos currentPos = currentFace.getPos();
if (!pipeGraph.containsKey(currentPos))
return false;
Pair<Integer, Map<Direction, Boolean>> pair = pipeGraph.get(currentPos);
int distance = pair.getFirst();
boolean atLeastOneBranchSuccessful = false;
for (Direction nextFacing : Iterate.directions) {
if (nextFacing == currentFace.getFace())
continue;
Map<Direction, Boolean> map = pair.getSecond();
if (!map.containsKey(nextFacing))
continue;
BlockFace localTarget = new BlockFace(currentPos, nextFacing);
if (targets.contains(localTarget)) {
validFaces.computeIfAbsent(distance, $ -> new HashSet<>()).add(localTarget);
atLeastOneBranchSuccessful = true;
continue;
}
if (map.get(nextFacing) != pull)
continue;
if (!searchForEndpointRecursively(pipeGraph, targets, validFaces, new BlockFace(currentPos.relative(nextFacing), nextFacing.getOpposite()), pull))
continue;
validFaces.computeIfAbsent(distance, $ -> new HashSet<>()).add(localTarget);
atLeastOneBranchSuccessful = true;
}
if (atLeastOneBranchSuccessful)
validFaces.computeIfAbsent(distance, $ -> new HashSet<>()).add(currentFace);
return atLeastOneBranchSuccessful;
}
use of com.simibubi.create.foundation.utility.Pair in project Create by Creators-of-Create.
the class FluidPropagator method propagateChangedPipe.
public static void propagateChangedPipe(LevelAccessor world, BlockPos pipePos, BlockState pipeState) {
List<Pair<Integer, BlockPos>> frontier = new ArrayList<>();
Set<BlockPos> visited = new HashSet<>();
Set<Pair<PumpTileEntity, Direction>> discoveredPumps = new HashSet<>();
frontier.add(Pair.of(0, pipePos));
// Visit all connected pumps to update their network
while (!frontier.isEmpty()) {
Pair<Integer, BlockPos> pair = frontier.remove(0);
BlockPos currentPos = pair.getSecond();
if (visited.contains(currentPos))
continue;
visited.add(currentPos);
BlockState currentState = currentPos.equals(pipePos) ? pipeState : world.getBlockState(currentPos);
FluidTransportBehaviour pipe = getPipe(world, currentPos);
if (pipe == null)
continue;
pipe.wipePressure();
for (Direction direction : getPipeConnections(currentState, pipe)) {
BlockPos target = currentPos.relative(direction);
if (!world.isAreaLoaded(target, 0))
continue;
BlockEntity tileEntity = world.getBlockEntity(target);
BlockState targetState = world.getBlockState(target);
if (tileEntity instanceof PumpTileEntity) {
if (!AllBlocks.MECHANICAL_PUMP.has(targetState) || targetState.getValue(PumpBlock.FACING).getAxis() != direction.getAxis())
continue;
discoveredPumps.add(Pair.of((PumpTileEntity) tileEntity, direction.getOpposite()));
continue;
}
if (visited.contains(target))
continue;
FluidTransportBehaviour targetPipe = getPipe(world, target);
if (targetPipe == null)
continue;
Integer distance = pair.getFirst();
if (distance >= getPumpRange() && !targetPipe.hasAnyPressure())
continue;
if (targetPipe.canHaveFlowToward(targetState, direction.getOpposite()))
frontier.add(Pair.of(distance + 1, target));
}
}
discoveredPumps.forEach(pair -> pair.getFirst().updatePipesOnSide(pair.getSecond()));
}
Aggregations