Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/forge.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jei = "15.20.0.115"
rei = "12.1.785"
emi = "1.1.22+1.20.1"
ae2 = "15.0.18"
mui = "3.3.0-SNAPSHOT"
mui = "3.3.1-SNAPSHOT"
kubejs = "2001.6.5-build.16"
rhino = "2001.2.3-build.10"
architectury = "9.2.14"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class MutableSchema implements ISchema {
protected final Level level = new SchemaLevel();
@Getter
protected @NotNull BlockPos origin = BlockPos.ZERO;
@Getter
protected @NotNull Vector3f center = new Vector3f();
@Getter
private BlockPos controllerPos = BlockPos.ZERO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public InteractionResultHolder<ItemStack> use(Item item, Level level, Player pla

private ModularPanel<?> clientPanel() {
MultiblockPreviewWidget previewWidget = new MultiblockPreviewWidget(this.multiblockDefinition,
this.multiblockSchemaInfo)
this.multiblockSchemaInfo, 200, 200)
.setControllerPos(this.controllerPos)
.setFrontFacing(this.frontFacing).setUpFacing(this.upFacing).setFlipped(this.isFlipped);
previewWidget.refreshSchema();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ private static boolean isAllFloorBlocks(Level level, BlockPos.MutableBlockPos po

public static Function<MultiblockMachineDefinition, IBlockPattern> getPattern() {
return (definition) -> {
PatternPredicate wallPredicate = getValidFloorBlocks().or(states(getCasingState(), getGlassState()));
PatternPredicate wallPredicate = states(getCasingState(), getGlassState()).or(getValidFloorBlocks());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getValidFloorBlocks() shouldn't even exist IMO, just make plastcrete part of the cleanroom floors tag

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope

PatternPredicate energyPredicate = autoAbilities(true, false, false).or(abilities(PartAbility.INPUT_ENERGY)
.setMinGlobalLimited(1).setMaxGlobalLimited(3));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,40 @@

import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition;
import com.gregtechceu.gtceu.api.multiblock.pattern.BlockPattern;
import com.gregtechceu.gtceu.api.multiblock.pattern.ExpandablePattern;
import com.gregtechceu.gtceu.api.multiblock.pattern.IBlockPattern;
import com.gregtechceu.gtceu.api.multiblock.util.AbstractStructureHelper;
import com.gregtechceu.gtceu.api.multiblock.util.BlockInfo;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.common.data.machines.GTMultiMachines;
import com.gregtechceu.gtceu.integration.recipeviewer.widgets.MultiblockPreviewWidget;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;

import brachy.modularui.integration.emi.recipe.ModularUIEmiRecipe;
import dev.emi.emi.api.EmiRegistry;
import dev.emi.emi.api.recipe.EmiRecipeCategory;
import dev.emi.emi.api.stack.EmiIngredient;
import dev.emi.emi.api.stack.EmiStack;
import dev.emi.emi.api.widget.SlotWidget;
import dev.emi.emi.api.widget.WidgetHolder;
import it.unimi.dsi.fastutil.Pair;
import it.unimi.dsi.fastutil.ints.Int2IntArrayMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.gregtechceu.gtceu.api.machine.multiblock.MultiblockControllerMachine.DEFAULT_STRUCTURE;

public class MultiblockInfoEmiCategory extends EmiRecipeCategory {

Expand All @@ -45,22 +62,48 @@ public Component getName() {
public static class MultiblockInfoEmiWrapper extends ModularUIEmiRecipe {

private final MultiblockMachineDefinition definition;
private SlotWidget slotWidget;
private final List<EmiIngredient> containedBlocks = new ArrayList<>();

public MultiblockInfoEmiWrapper(MultiblockMachineDefinition definition) {
super(definition.getId(), () -> new MultiblockPreviewWidget(definition, null));
super(definition.getId(), () -> new MultiblockPreviewWidget(definition, null, 200, 180));
Comment thread
YoungOnionMC marked this conversation as resolved.
this.definition = definition;
initializeContainedBlocks();
}

private void initializeContainedBlocks() {
Map<BlockPos, BlockInfo> resultStructure = new HashMap<>();
IBlockPattern pattern = definition.getStructurePatterns().get(DEFAULT_STRUCTURE).get();
AbstractStructureHelper structureHelper = null;
if (pattern instanceof BlockPattern blockPattern) {
var sliceRepeats = new Int2IntArrayMap();
for (int i = 0; i < blockPattern.getSlices().length; i++) {
sliceRepeats.put(i, blockPattern.getSlices()[i].getMinRepeats());
}
structureHelper = AbstractStructureHelper.blockPattern(sliceRepeats);
} else if (pattern instanceof ExpandablePattern expandablePattern) {
Comment thread
YoungOnionMC marked this conversation as resolved.
var userDimensions = new IntArrayList();
expandablePattern.getBoundsConstraints().apply().stream()
.mapToInt(Pair::left)
.forEach(userDimensions::add);
structureHelper = AbstractStructureHelper.expandable(userDimensions);
}
if (structureHelper != null) {
Comment thread
YoungOnionMC marked this conversation as resolved.
structureHelper.populate(resultStructure, pattern, null,
definition.getRotationState().defaultDirection, switch (definition.getRotationState()) {
case Y_AXIS -> Direction.NORTH;
case ALL, NON_Y_AXIS, NONE -> Direction.UP;
}, false);

Object2IntMap<Block> blockCount = new Object2IntOpenHashMap<>();
resultStructure.forEach(
(pos, state) -> blockCount.mergeInt(state.getBlockState().getBlock(), 1, Integer::sum));
blockCount.forEach((block, count) -> containedBlocks.add(EmiStack.of(block.asItem(), count)));
}
}

@Override
public void addWidgets(WidgetHolder widgets) {
super.addWidgets(widgets);
// numbers gotten from the size of the widget
slotWidget = new SlotWidget(EmiStack.of(definition.getItem().asItem()), 138, 12)
.recipeContext(this)
.drawBack(false);

widgets.add(slotWidget);
}

@Override
Expand All @@ -75,12 +118,12 @@ public EmiRecipeCategory getCategory() {

@Override
public List<EmiIngredient> getInputs() {
return List.of();
return containedBlocks;
}

@Override
public List<EmiStack> getOutputs() {
return List.of(EmiStack.of(definition.getItem()));
return List.of(EmiStack.of(definition.getBlock()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class MultiblockInfoJeiCategory extends
private final IDrawable icon;

public MultiblockInfoJeiCategory(IJeiHelpers helpers) {
super(v -> new MultiblockPreviewWidget(v.definition, null), v -> v.definition.getId());
super(v -> new MultiblockPreviewWidget(v.definition, null, 200, 180), v -> v.definition.getId());
IGuiHelper guiHelper = helpers.getGuiHelper();
this.background = guiHelper.createBlankDrawable(160, 160);
this.icon = guiHelper.createDrawableItemStack(GTMultiMachines.ELECTRIC_BLAST_FURNACE.asStack());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,41 @@

import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition;
import com.gregtechceu.gtceu.api.multiblock.pattern.BlockPattern;
import com.gregtechceu.gtceu.api.multiblock.pattern.ExpandablePattern;
import com.gregtechceu.gtceu.api.multiblock.pattern.IBlockPattern;
import com.gregtechceu.gtceu.api.multiblock.util.AbstractStructureHelper;
import com.gregtechceu.gtceu.api.multiblock.util.BlockInfo;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.common.data.machines.GTMultiMachines;
import com.gregtechceu.gtceu.integration.recipeviewer.widgets.MultiblockPreviewWidget;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.block.Block;

import brachy.modularui.integration.rei.recipe.ModularUIREIDisplay;
import brachy.modularui.integration.rei.recipe.ModularUIREIDisplayCategory;
import it.unimi.dsi.fastutil.Pair;
import it.unimi.dsi.fastutil.ints.Int2IntArrayMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import me.shedaniel.rei.api.client.gui.Renderer;
import me.shedaniel.rei.api.client.registry.display.DisplayRegistry;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import me.shedaniel.rei.api.common.util.EntryStacks;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.gregtechceu.gtceu.api.machine.multiblock.MultiblockControllerMachine.DEFAULT_STRUCTURE;

public class MultiblockInfoReiCategory extends
ModularUIREIDisplayCategory<MultiblockInfoReiCategory.MultiblockInfoDisplay> {

Expand Down Expand Up @@ -62,8 +84,55 @@ public Renderer getIcon() {

public static class MultiblockInfoDisplay extends ModularUIREIDisplay {

private final MultiblockMachineDefinition definition;
private final List<EntryIngredient> containedBlocks = new ArrayList<>();

public MultiblockInfoDisplay(MultiblockMachineDefinition definition) {
super(definition.getId(), () -> new MultiblockPreviewWidget(definition, null), CATEGORY);
super(definition.getId(), () -> new MultiblockPreviewWidget(definition, null, 200, 180), CATEGORY);
this.definition = definition;
initializeContainedBlocks();
}

private void initializeContainedBlocks() {
Map<BlockPos, BlockInfo> resultStructure = new HashMap<>();
IBlockPattern pattern = definition.getStructurePatterns().get(DEFAULT_STRUCTURE).get();
AbstractStructureHelper structureHelper = null;
if (pattern instanceof BlockPattern blockPattern) {
var sliceRepeats = new Int2IntArrayMap();
for (int i = 0; i < blockPattern.getSlices().length; i++) {
sliceRepeats.put(i, blockPattern.getSlices()[i].getMinRepeats());
}
structureHelper = AbstractStructureHelper.blockPattern(sliceRepeats);
} else if (pattern instanceof ExpandablePattern expandablePattern) {
var userDimensions = new IntArrayList();
expandablePattern.getBoundsConstraints().apply().stream()
.mapToInt(Pair::left)
.forEach(userDimensions::add);
structureHelper = AbstractStructureHelper.expandable(userDimensions);
}
if (structureHelper != null) {
structureHelper.populate(resultStructure, pattern, null,
definition.getRotationState().defaultDirection, switch (definition.getRotationState()) {
case Y_AXIS -> Direction.NORTH;
case ALL, NON_Y_AXIS, NONE -> Direction.UP;
}, false);

Object2IntMap<Block> blockCount = new Object2IntOpenHashMap<>();
resultStructure.forEach(
(pos, state) -> blockCount.mergeInt(state.getBlockState().getBlock(), 1, Integer::sum));

blockCount.forEach((block, count) -> containedBlocks.add(EntryIngredients.of(block.asItem(), count)));
}
}

@Override
public List<EntryIngredient> getInputEntries() {
return containedBlocks;
}

@Override
public List<EntryIngredient> getOutputEntries() {
return List.of(EntryIngredients.of(definition.getBlock()));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.gregtechceu.gtceu.integration.recipeviewer.widgets;

import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition;
import com.gregtechceu.gtceu.api.mui.MultiblockSchemaInfo;
import com.gregtechceu.gtceu.api.multiblock.PatternPredicate;
Expand Down Expand Up @@ -29,6 +30,8 @@
import brachy.modularui.drawable.ItemDrawable;
import brachy.modularui.drawable.SchemaRenderer;
import brachy.modularui.drawable.schema.BlockHighlight;
import brachy.modularui.integration.recipeviewer.RecipeSlotRole;
import brachy.modularui.integration.recipeviewer.RecipeViewerSlotWidget;
import brachy.modularui.utils.Alignment;
import brachy.modularui.utils.Color;
import brachy.modularui.value.BoolValue;
Expand Down Expand Up @@ -85,8 +88,10 @@ public class MultiblockPreviewWidget extends ParentWidget<MultiblockPreviewWidge
@Setter
private @Nullable Runnable onSchemaRefresh;

public MultiblockPreviewWidget(MultiblockMachineDefinition definition, MultiblockSchemaInfo schemaInfo) {
public MultiblockPreviewWidget(MultiblockMachineDefinition definition, MultiblockSchemaInfo schemaInfo, int width,
int height) {
this.multiblockDefinition = definition;
if (!GTCEu.isClientThread()) return;
this.frontFacing = definition.getRotationState().defaultDirection;
this.upFacing = switch (definition.getRotationState()) {
case Y_AXIS -> Direction.NORTH;
Expand Down Expand Up @@ -116,11 +121,15 @@ public MultiblockPreviewWidget(MultiblockMachineDefinition definition, Multibloc
// NOTE wrapped flows require a fixed size in their axis, relative/coverChildren does not work
.wrap()
.coverChildrenWidth(20)
.height(200)
.height(height)
.children(this.multiblockSchemaInfo.getBlockCounts().reference2IntEntrySet(), e -> {
ItemStack stack = new ItemStack(e.getKey(), e.getIntValue());
return new ItemDrawable(stack)
.asWidget().size(18).margin(1)
return RecipeViewerSlotWidget.create()
.recipeSlotRole(RecipeSlotRole.OUTPUT)
.value(stack)
.background(IDrawable.EMPTY)
.size(16)
.margin(1)
.tooltip(r -> r.addFromItem(stack));
}));

Expand Down Expand Up @@ -148,7 +157,9 @@ public MultiblockPreviewWidget(MultiblockMachineDefinition definition, Multibloc
List<Map.Entry<String, IBlockPattern>> patterns = multiblockDefinition.getStructurePatterns()
.entrySet().stream().map(e -> Map.entry(e.getKey(), e.getValue().get())).toList();

this.multiblockSchemaInfo.setMultiSchema(this.multiblockSchemaInfo.getRenderer().asWidget()
this.multiblockSchemaInfo.getRenderer().camera().setPosAndLookAt(0, 0, -10,
this.multiblockSchemaInfo.getMapSchema().getCenter());
SchemaWidget schema = this.multiblockSchemaInfo.getRenderer().asWidget()
.listenGuiAction(setBlockOnClick)
.tooltipDynamic(text -> {
BlockHitResult hit = this.multiblockSchemaInfo.getRenderer().lastRayTrace();
Expand All @@ -161,7 +172,9 @@ public MultiblockPreviewWidget(MultiblockMachineDefinition definition, Multibloc
text.addFromItem(pickedItem);
}
}).tooltipAutoUpdate(true)
.size(200));
.size(width, height);

this.multiblockSchemaInfo.setMultiSchema(schema);
this.multiblockSchemaInfo.getMultiSchema().getSchemaRenderer().updateRenderFilter((pos, state) -> {
if (yLevel == -1) {
return true;
Expand Down
Loading