Skip to content

Commit

Permalink
Merge branch 'raw-ores-patch' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	dependencies.gradle
#	settings.gradle
  • Loading branch information
Dream-Master committed Apr 24, 2024
2 parents 997feb1 + dd93558 commit be6ce02
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ class DiagramBuilder {
private final RecipeHandler recipeHandler;

private final ItemComponent rawOre;
private final Optional<ItemComponent> trueRawOre;
private final Set<Component> craftingComponents;
private final Set<Component> usageComponents;
private final Diagram.Builder diagramBuilder;

DiagramBuilder(LayoutHandler layoutHandler, LabelHandler labelHandler, RecipeHandler recipeHandler,
List<ItemComponent> rawOres) {
List<ItemComponent> rawOres, Optional<ItemComponent> trueRawOre) {
this.layoutHandler = layoutHandler;
this.labelHandler = labelHandler;
this.recipeHandler = recipeHandler;
Expand All @@ -71,14 +72,25 @@ class DiagramBuilder {
this.rawOre = rawOres.get(0);
}

this.trueRawOre = trueRawOre;

this.craftingComponents = new HashSet<>(filteredRawOres);
this.trueRawOre.ifPresent(this.craftingComponents::add);
this.usageComponents = new HashSet<>(filteredRawOres);
this.trueRawOre.ifPresent(this.usageComponents::add);
this.diagramBuilder = Diagram.builder();
}

void buildDiagram(ComponentDiagramMatcher.Builder matcherBuilder) {
diagramBuilder.addAllOptionalLayouts(layoutHandler.layouts())
.insertIntoSlot(LayoutHandler.SlotKeys.RAW_ORE, DisplayComponent.builder(rawOre).build());
trueRawOre.ifPresent(v -> {
diagramBuilder.insertIntoSlot(LayoutHandler.SlotKeys.TRUE_RAW_ORE, DisplayComponent.builder(v).build());
Optional<ItemComponent> crushedOreOptional = handleRecipes(
RecipeHandler.RecipeMap.MACERATOR,
v,
LayoutHandler.SlotGroupKeys.TRUE_RAW_ORE_MACERATE);
});

Optional<ItemComponent> crushedOreOptional = handleRecipes(
RecipeHandler.RecipeMap.MACERATOR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,15 @@ public DiagramGroup generate() {
OTHER_ORE_PREFIXES
.forEach(prefix -> rawOres.addAll(GregTechOreDictUtil.getAllComponents(prefix, material)));

buildDiagram(matcherBuilder, rawOres);
Optional<ItemComponent> trueRawOre = GregTechOreDictUtil.getComponent(OrePrefixes.rawOre, material);

buildDiagram(matcherBuilder, rawOres, trueRawOre);
}

if (Registry.ModDependency.BARTWORKS.isLoaded()) {
for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) {
Optional<ItemComponent> rawOre = BartWorksOreDictUtil.getComponent(OrePrefixes.ore, werkstoff);
Optional<ItemComponent> trueRawOre = BartWorksOreDictUtil.getComponent(OrePrefixes.rawOre, werkstoff);
if (!rawOre.isPresent()) {
continue;
}
Expand All @@ -110,7 +113,7 @@ public DiagramGroup generate() {
OTHER_ORE_PREFIXES.forEach(
prefix -> BartWorksOreDictUtil.getComponent(prefix, werkstoff).ifPresent(rawOres::add));

buildDiagram(matcherBuilder, rawOres);
buildDiagram(matcherBuilder, rawOres, trueRawOre);
}
}

Expand All @@ -122,15 +125,21 @@ public DiagramGroup generate() {
continue;
}

buildDiagram(matcherBuilder, ImmutableList.of(ItemComponent.create(ore)));
buildDiagram(matcherBuilder, ImmutableList.of(ItemComponent.create(ore)), Optional.ofNullable(null));
}
}

return new DiagramGroup(info, matcherBuilder.build());
}

private void buildDiagram(ComponentDiagramMatcher.Builder matcherBuilder, List<ItemComponent> rawOres) {
DiagramBuilder diagramBuilder = new DiagramBuilder(layoutHandler, labelHandler, recipeHandler, rawOres);
private void buildDiagram(ComponentDiagramMatcher.Builder matcherBuilder, List<ItemComponent> rawOres,
Optional<ItemComponent> trueRawOre) {
DiagramBuilder diagramBuilder = new DiagramBuilder(
layoutHandler,
labelHandler,
recipeHandler,
rawOres,
trueRawOre);
diagramBuilder.buildDiagram(matcherBuilder);

Logger.GREGTECH_5_ORE_PROCESSING.debug("Generated diagram [{}]", rawOres.get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ class LayoutHandler {
static final class SlotKeys {

static final Layout.SlotKey RAW_ORE = Layout.SlotKey.create("raw-ore");
static final Layout.SlotKey TRUE_RAW_ORE = Layout.SlotKey.create("true-raw-ore");
}

static final class SlotGroupKeys {

static final Layout.SlotGroupKey RAW_ORE_MACERATE = Layout.SlotGroupKey.create("raw-ore-macerate");
static final Layout.SlotGroupKey TRUE_RAW_ORE_MACERATE = Layout.SlotGroupKey.create("true-raw-ore-macerate");
static final Layout.SlotGroupKey CRUSHED_ORE_MACERATE = Layout.SlotGroupKey.create("crushed-ore-macerate");
static final Layout.SlotGroupKey CRUSHED_ORE_WASH = Layout.SlotGroupKey.create("crushed-ore-wash");
static final Layout.SlotGroupKey CRUSHED_ORE_BATH_MERCURY = Layout.SlotGroupKey
Expand Down Expand Up @@ -69,7 +71,9 @@ static final class AdditionalRecipeLabelPositions {
void initialize() {
ImmutableList.Builder<Layout> layoutsBuilder = new ImmutableList.Builder<>();
layoutsBuilder.add(buildRawOreLayout());
layoutsBuilder.add(buildTrueRawOreLayout());
layoutsBuilder.add(buildRawOreMacerateLayout());
layoutsBuilder.add(buildTrueRawOreMacerateLayout());
layoutsBuilder.add(buildCrushedOreWashLayout());
layoutsBuilder.add(buildCrushedOreBathMercuryLayout());
layoutsBuilder.add(buildCrushedOreBathSodiumPersulfateLayout());
Expand All @@ -90,8 +94,9 @@ ImmutableList<Layout> layouts() {
return layouts;
}

// Ores Block
private Layout buildRawOreLayout() {
Slot inputSlot = Slot.builder(Grid.GRID.grid(6, 4)).setDrawFunction(Draw::drawBigSlot)
Slot inputSlot = Slot.builder(Grid.GRID.grid(4, 2)).setDrawFunction(Draw::drawBigSlot)
.setTooltip(Tooltip.create(Lang.GREGTECH_5_ORE_PROCESSING.trans("oreslot"), Tooltip.SLOT_FORMATTING))
.build();

Expand All @@ -100,13 +105,20 @@ private Layout buildRawOreLayout() {
return Layout.builder().putSlot(SlotKeys.RAW_ORE, inputSlot).addInteractable(allDiagramsButton).build();
}

private Layout buildRawOreMacerateLayout() {
Lines lines = Lines.builder(Grid.GRID.grid(6, 4)).addSegment(Grid.GRID.grid(4, 4))
.addArrow(Grid.GRID.edge(4, 10, Grid.Direction.N)).build();
// Raw Ores Item
private Layout buildTrueRawOreLayout() {
Slot inputSlot = Slot.builder(Grid.GRID.grid(6, 2)).setDrawFunction(Draw::drawBigSlot)
.setTooltip(Tooltip.create(Lang.GREGTECH_5_ORE_PROCESSING.trans("raworeslot"), Tooltip.SLOT_FORMATTING))
.build();

return Layout.builder().putSlot(SlotKeys.TRUE_RAW_ORE, inputSlot).build();
}

CustomInteractable label = labelHandler.buildLabel(LabelHandler.ItemLabel.MACERATOR, Grid.GRID.grid(4, 8));
private Layout buildRawOreMacerateLayout() {
Lines lines = Lines.builder(Grid.GRID.grid(4, 2)).addArrow(Grid.GRID.edge(4, 7, Grid.Direction.N)).build();
CustomInteractable label = labelHandler.buildLabel(LabelHandler.ItemLabel.MACERATOR, Grid.GRID.grid(4, 5));

SlotGroup outputSlots = SlotGroup.builder(1, 2, Grid.GRID.grid(4, 10), Grid.Direction.S)
SlotGroup outputSlots = SlotGroup.builder(1, 2, Grid.GRID.grid(4, 7), Grid.Direction.S)
.setDefaultTooltip(
Tooltip.create(Lang.GREGTECH_5_ORE_PROCESSING.trans("maceratorslot"), Tooltip.SLOT_FORMATTING))
.build();
Expand All @@ -115,8 +127,23 @@ private Layout buildRawOreMacerateLayout() {
.putSlotGroup(SlotGroupKeys.RAW_ORE_MACERATE, outputSlots).build();
}

private Layout buildTrueRawOreMacerateLayout() {
Lines lines = Lines.builder(Grid.GRID.grid(6, 2)).addArrow(Grid.GRID.edge(6, 7, Grid.Direction.N)).build();
Lines lines2 = Lines.builder(Grid.GRID.grid(4, 7)).addSegment(Grid.GRID.grid(6, 7)).build();
CustomInteractable label = labelHandler.buildLabel(LabelHandler.ItemLabel.MACERATOR, Grid.GRID.grid(6, 5));

SlotGroup outputSlots = SlotGroup.builder(1, 2, Grid.GRID.grid(6, 7), Grid.Direction.S)
.setDefaultTooltip(
Tooltip.create(Lang.GREGTECH_5_ORE_PROCESSING.trans("maceratorslot"), Tooltip.SLOT_FORMATTING))
.build();

return Layout.builder().addLines(lines).addLines(lines2).addInteractable(label)
.putSlotGroup(SlotGroupKeys.TRUE_RAW_ORE_MACERATE, outputSlots).build();
}

private Layout buildCrushedOreMacerateLayout() {
Lines lines = Lines.builder(Grid.GRID.grid(4, 10)).addSegment(Grid.GRID.grid(2, 10))
Lines lines = Lines.builder(Grid.GRID.grid(4, 7)).addSegment(Grid.GRID.grid(3, 7))
.addSegment(Grid.GRID.grid(3, 10)).addSegment(Grid.GRID.grid(2, 10))
.addArrow(Grid.GRID.edge(2, 14, Grid.Direction.N)).build();

CustomInteractable label = labelHandler.buildLabel(LabelHandler.ItemLabel.MACERATOR, Grid.GRID.grid(2, 12));
Expand All @@ -131,8 +158,7 @@ private Layout buildCrushedOreMacerateLayout() {
}

private Layout buildCrushedOreWashLayout() {
Lines lines = Lines.builder(Grid.GRID.grid(4, 10)).addSegment(Grid.GRID.grid(5, 10))
.addSegment(Grid.GRID.grid(5, 8)).addSegment(Grid.GRID.grid(8, 8))
Lines lines = Lines.builder(Grid.GRID.grid(4, 7)).addSegment(Grid.GRID.grid(8, 7))
.addArrow(Grid.GRID.edge(8, 10, Grid.Direction.N)).build();

CustomInteractable label = labelHandler
Expand All @@ -147,7 +173,8 @@ private Layout buildCrushedOreWashLayout() {
}

private Layout buildCrushedOreBathMercuryLayout() {
Lines lines = Lines.builder(Grid.GRID.grid(4, 10)).addSegment(Grid.GRID.grid(0, 10))
Lines lines = Lines.builder(Grid.GRID.grid(4, 7)).addSegment(Grid.GRID.grid(3, 7))
.addSegment(Grid.GRID.grid(3, 10)).addSegment(Grid.GRID.grid(0, 10))
.addArrow(Grid.GRID.edge(0, 6, Grid.Direction.S)).build();

CustomInteractable label = labelHandler.buildLabel(LabelHandler.ItemLabel.CHEMICAL_BATH, Grid.GRID.grid(0, 8));
Expand All @@ -170,7 +197,8 @@ private Layout buildCrushedOreBathMercuryLayout() {
}

private Layout buildCrushedOreBathSodiumPersulfateLayout() {
Lines lines = Lines.builder(Grid.GRID.grid(4, 10)).addSegment(Grid.GRID.grid(2, 10))
Lines lines = Lines.builder(Grid.GRID.grid(4, 7)).addSegment(Grid.GRID.grid(3, 7))
.addSegment(Grid.GRID.grid(3, 10)).addSegment(Grid.GRID.grid(2, 10))
.addArrow(Grid.GRID.edge(2, 6, Grid.Direction.S)).build();

CustomInteractable label = labelHandler.buildLabel(LabelHandler.ItemLabel.CHEMICAL_BATH, Grid.GRID.grid(2, 8));
Expand Down Expand Up @@ -209,11 +237,11 @@ private Layout buildPurifiedOreMacerateLayout() {

private Layout buildPurifiedOreSiftLayout() {
Lines lines = Lines.builder(Grid.GRID.grid(8, 10)).addSegment(Grid.GRID.grid(10, 10))
.addArrow(Grid.GRID.edge(10, 6, Grid.Direction.S)).build();
.addArrow(Grid.GRID.edge(10, 5, Grid.Direction.S)).build();

CustomInteractable label = labelHandler.buildLabel(LabelHandler.ItemLabel.SIFTER, Grid.GRID.grid(10, 8));

SlotGroup outputSlots = SlotGroup.builder(3, 3, Grid.GRID.grid(10, 6), Grid.Direction.N)
SlotGroup outputSlots = SlotGroup.builder(3, 3, Grid.GRID.grid(10, 5), Grid.Direction.N)
.setDefaultTooltip(
Tooltip.create(Lang.GREGTECH_5_ORE_PROCESSING.trans("sifterslot"), Tooltip.SLOT_FORMATTING))
.build();
Expand Down Expand Up @@ -271,7 +299,7 @@ private Layout buildPurifiedDustElectromagneticSeparateLayout() {
}

private Layout buildOreThermalCentrifugeLayout() {
Lines lines = Lines.builder(Grid.GRID.grid(4, 10)).addSegment(Grid.GRID.grid(5, 10))
Lines lines = Lines.builder(Grid.GRID.grid(4, 7)).addSegment(Grid.GRID.grid(5, 7))
.addSegment(Grid.GRID.grid(5, 12)).addSegment(Grid.GRID.grid(7, 12)).addSegment(Grid.GRID.grid(7, 10))
.addSegment(Grid.GRID.grid(8, 10)).move(Grid.GRID.grid(6, 12))
.addArrow(Grid.GRID.edge(6, 14, Grid.Direction.N)).build();
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/neicustomdiagram/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ neicustomdiagram.generators.gregtech5.oreprefixes.prefixlabel=Ore prefix: %s

neicustomdiagram.generators.gregtech5.oreprocessing.groupname=GregTech Ore Processing
neicustomdiagram.generators.gregtech5.oreprocessing.oreslot=Processed ore
neicustomdiagram.generators.gregtech5.oreprocessing.raworeslot=Processed raw ore
neicustomdiagram.generators.gregtech5.oreprocessing.maceratorlabel=Macerator
neicustomdiagram.generators.gregtech5.oreprocessing.maceratorslot=Macerator output
neicustomdiagram.generators.gregtech5.oreprocessing.orewashingplantlabel=Ore Washing Plant
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/neicustomdiagram/lang/zh_CN.lang
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ neicustomdiagram.generators.gregtech5.oreprefixes.prefixlabel=矿辞前缀:%s

neicustomdiagram.generators.gregtech5.oreprocessing.groupname=GT矿物处理
neicustomdiagram.generators.gregtech5.oreprocessing.oreslot=已处理矿物
neicustomdiagram.generators.gregtech5.oreprocessing.raworeslot=Processed raw ore
neicustomdiagram.generators.gregtech5.oreprocessing.maceratorlabel=粉碎机
neicustomdiagram.generators.gregtech5.oreprocessing.maceratorslot=粉碎机输出
neicustomdiagram.generators.gregtech5.oreprocessing.orewashingplantlabel=洗矿机
Expand Down

0 comments on commit be6ce02

Please sign in to comment.