Skip to content

Commit

Permalink
Adressing review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethryan committed Apr 24, 2024
1 parent d792834 commit c8bc86f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DiagramBuilder {
private final Diagram.Builder diagramBuilder;

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

this.trueRawOre = trueRawOres;
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.autoInsertIntoSlotGroup(LayoutHandler.SlotGroupKeys.TRUE_RAW_ORE)
.insertIntoNextSlot(DisplayComponent.builder(v).build());
diagramBuilder.insertIntoSlot(LayoutHandler.SlotKeys.TRUE_RAW_ORE, DisplayComponent.builder(v).build());
Optional<ItemComponent> crushedOreOptional = handleRecipes(
RecipeHandler.RecipeMap.MACERATOR,
v,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.common.blocks.GT_Block_Ores_Abstract;
import gregtech.common.items.GT_MetaGenerated_Item_03;
import gtPlusPlus.core.block.base.BlockBaseOre;
import gtPlusPlus.core.material.Material;

Expand All @@ -47,8 +46,7 @@ public final class GregTechOreProcessing implements DiagramGenerator {
OrePrefixes.oreSmall,
OrePrefixes.orePoor,
OrePrefixes.oreEndstone,
OrePrefixes.oreEnd,
OrePrefixes.rawOre);
OrePrefixes.oreEnd);

private final DiagramGroupInfo info;

Expand Down Expand Up @@ -96,9 +94,9 @@ public DiagramGroup generate() {
OTHER_ORE_PREFIXES
.forEach(prefix -> rawOres.addAll(GregTechOreDictUtil.getAllComponents(prefix, material)));

ItemComponent trueRawOres = GregTechOreDictUtil.getAllComponents(OrePrefixes.rawOre, material).get(0);
Optional<ItemComponent> trueRawOre = GregTechOreDictUtil.getComponent(OrePrefixes.rawOre, material);

buildDiagram(matcherBuilder, rawOres, Optional.ofNullable(trueRawOres));
buildDiagram(matcherBuilder, rawOres, trueRawOre);
}

if (Registry.ModDependency.BARTWORKS.isLoaded()) {
Expand Down Expand Up @@ -151,11 +149,4 @@ static boolean isGregTechOreBlock(ItemComponent itemComponent) {
Block block = Block.getBlockFromItem(itemComponent.item());
return block instanceof GT_Block_Ores_Abstract;
}

static boolean isGregTechRawOreItem(ItemComponent itemComponent) {
if (itemComponent == null) {
return false;
}
return itemComponent.item() instanceof GT_MetaGenerated_Item_03;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ 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 TRUE_RAW_ORE = Layout.SlotGroupKey.create("true-raw-ore");
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");
Expand Down Expand Up @@ -105,17 +105,15 @@ private Layout buildRawOreLayout() {

// Raw Ores Item
private Layout buildTrueRawOreLayout() {
SlotGroup inputSlot = SlotGroup.builder(1, 1, Grid.GRID.grid(6, 2), Grid.Direction.S)
.setDefaultDrawFunction(Draw::drawBigSlot)
.setDefaultTooltip(
Tooltip.create(Lang.GREGTECH_5_ORE_PROCESSING.trans("oreslot"), Tooltip.SLOT_FORMATTING))
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().putSlotGroup(SlotGroupKeys.TRUE_RAW_ORE, inputSlot).build();
return Layout.builder().putSlot(SlotKeys.TRUE_RAW_ORE, inputSlot).build();
}

private Layout buildRawOreMacerateLayout() {
Lines lines = Lines.builder(Grid.GRID.grid(4, 2)).addArrow(Grid.GRID.edge(4, 8, Grid.Direction.N)).build();
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));

Expand All @@ -129,7 +127,7 @@ private Layout buildRawOreMacerateLayout() {
}

private Layout buildTrueRawOreMacerateLayout() {
Lines lines = Lines.builder(Grid.GRID.grid(6, 2)).addArrow(Grid.GRID.edge(6, 8, Grid.Direction.N)).build();
Lines lines = Lines.builder(Grid.GRID.grid(6, 2)).addArrow(Grid.GRID.edge(6, 7, Grid.Direction.N)).build();

CustomInteractable label = labelHandler.buildLabel(LabelHandler.ItemLabel.MACERATOR, Grid.GRID.grid(6, 5));

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=加工原矿
neicustomdiagram.generators.gregtech5.oreprocessing.maceratorlabel=粉碎机
neicustomdiagram.generators.gregtech5.oreprocessing.maceratorslot=粉碎机输出
neicustomdiagram.generators.gregtech5.oreprocessing.orewashingplantlabel=洗矿机
Expand Down

0 comments on commit c8bc86f

Please sign in to comment.