Skip to content

Commit

Permalink
Restores REI recipe displays.
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Dec 24, 2023
1 parent 2963d5d commit aff7a7f
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 93 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ artifact_basename=appliedenergistics2-neoforge
minecraft_release=1.20
minecraft_version=1.20.4
minecraft_version_range=[1.20.4,1.20.5)
neoforge_version=20.4.55-beta
neoforge_version=20.4.57-beta
neoforge_version_range=[20.4,)

#########################################################
Expand All @@ -35,7 +35,7 @@ jade_file_id=4845321

# Pick which item list mod gets picked at runtime in dev
# Available options: jei, rei, none
runtime_itemlist_mod=none
runtime_itemlist_mod=rei

# Set to wthit, jade, or top to pick which tooltip mod gets picked at runtime
# for the dev environment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public List<Widget> setupDisplay(AttunementDisplay display, Rectangle bounds) {
widgets.add(Widgets.createRecipeBase(bounds));
widgets.add(Widgets.createArrow(new Point(startPoint.x + 27, startPoint.y + 4)));
widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 5)));
// TODO 1.19.3 widgets.add(Widgets.createSlot(new Point(startPoint.x + 4, startPoint.y + 5))
// TODO 1.19.3 .entries(display.getInputEntries().get(0)).markInput());
// TODO 1.19.3 widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 5))
// TODO 1.19.3 .entries(display.getOutputEntries().get(0)).disableBackground().markOutput());
widgets.add(Widgets.createSlot(new Point(startPoint.x + 4, startPoint.y + 5))
.entries(display.getInputEntries().get(0)).markInput());
widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 5))
.entries(display.getOutputEntries().get(0)).disableBackground().markOutput());
return widgets;
}

Expand Down
56 changes: 31 additions & 25 deletions src/main/java/appeng/integration/modules/rei/ChargerCategory.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import me.shedaniel.rei.api.common.util.EntryStacks;

import appeng.blockentity.misc.ChargerBlockEntity;
import appeng.blockentity.misc.CrankBlockEntity;
import appeng.core.definitions.AEBlocks;
import appeng.core.localization.ItemModText;

public class ChargerCategory implements DisplayCategory<ChargerDisplay> {
private final Renderer icon;
Expand Down Expand Up @@ -46,34 +50,36 @@ public List<Widget> setupDisplay(ChargerDisplay display, Rectangle bounds) {
var y = bounds.y;
widgets.add(Widgets.createRecipeBase(bounds));

// TODO 1.19.3 widgets.add(
// TODO 1.19.3 Widgets.createSlot(new Point(x + 31, y + 8))
// TODO 1.19.3 .markInput()
// TODO 1.19.3 .backgroundEnabled(true)
// TODO 1.19.3 .entries(EntryIngredients.ofIngredient(display.recipe().getIngredient())));
// TODO 1.19.3 widgets.add(
// TODO 1.19.3 Widgets.createSlot(new Point(x + 81, y + 8))
// TODO 1.19.3 .markOutput()
// TODO 1.19.3 .backgroundEnabled(true)
// TODO 1.19.3 .entry(EntryStacks.of(display.recipe().getResultItem())));
// TODO 1.19.3
// TODO 1.19.3 widgets.add(
// TODO 1.19.3 Widgets.createSlot(new Point(x + 3, y + 30))
// TODO 1.19.3 .unmarkInputOrOutput()
// TODO 1.19.3 .backgroundEnabled(false)
// TODO 1.19.3 .entry(EntryStacks.of(AEBlocks.CRANK.stack())));
var recipe = display.holder().value();

widgets.add(
Widgets.createSlot(new Point(x + 31, y + 8))
.markInput()
.backgroundEnabled(true)
.entries(EntryIngredients.ofIngredient(recipe.getIngredient())));
widgets.add(
Widgets.createSlot(new Point(x + 81, y + 8))
.markOutput()
.backgroundEnabled(true)
.entry(EntryStacks.of(recipe.getResultItem())));

widgets.add(
Widgets.createSlot(new Point(x + 3, y + 30))
.unmarkInputOrOutput()
.backgroundEnabled(false)
.entry(EntryStacks.of(AEBlocks.CRANK.stack())));

widgets.add(Widgets.createArrow(new Point(x + 52, y + 8)));

// TODO 1.19.3 var turns = (ChargerBlockEntity.POWER_MAXIMUM_AMOUNT + CrankBlockEntity.POWER_PER_CRANK_TURN - 1)
// TODO 1.19.3 / CrankBlockEntity.POWER_PER_CRANK_TURN;
// TODO 1.19.3 widgets.add(Widgets
// TODO 1.19.3 .createLabel(new Point(x + 20, y + 35),
// TODO 1.19.3 ItemModText.CHARGER_REQUIRED_POWER.text(turns, ChargerBlockEntity.POWER_MAXIMUM_AMOUNT))
// TODO 1.19.3 .color(0x7E7E7E)
// TODO 1.19.3 .noShadow()
// TODO 1.19.3 .leftAligned());
// TODO 1.19.3
var turns = (ChargerBlockEntity.POWER_MAXIMUM_AMOUNT + CrankBlockEntity.POWER_PER_CRANK_TURN - 1)
/ CrankBlockEntity.POWER_PER_CRANK_TURN;
widgets.add(Widgets
.createLabel(new Point(x + 20, y + 35),
ItemModText.CHARGER_REQUIRED_POWER.text(turns, ChargerBlockEntity.POWER_MAXIMUM_AMOUNT))
.color(0x7E7E7E)
.noShadow()
.leftAligned());

return widgets;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.gui.Renderer;
import me.shedaniel.rei.api.client.gui.widgets.Slot;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
Expand Down Expand Up @@ -101,15 +102,13 @@ public List<Widget> setupDisplay(CondenserOutputDisplay recipeDisplay, Rectangle
}
}));

// TODO 1.19.3 Slot outputSlot = Widgets.createSlot(new Point(origin.x + 55, origin.y +
// 27)).disableBackground().markOutput()
// TODO 1.19.3 .entries(recipeDisplay.getOutputEntries().get(0));
// TODO 1.19.3 widgets.add(outputSlot);
// TODO 1.19.3
// TODO 1.19.3 Slot storageCellSlot = Widgets.createSlot(new Point(origin.x + 51, origin.y +
// 1)).disableBackground()
// TODO 1.19.3 .markInput().entries(recipeDisplay.getViableStorageComponents());
// TODO 1.19.3 widgets.add(storageCellSlot);
Slot outputSlot = Widgets.createSlot(new Point(origin.x + 55, origin.y + 27)).disableBackground().markOutput()
.entries(recipeDisplay.getOutputEntries().get(0));
widgets.add(outputSlot);

Slot storageCellSlot = Widgets.createSlot(new Point(origin.x + 51, origin.y + 1)).disableBackground()
.markInput().entries(recipeDisplay.getViableStorageComponents());
widgets.add(storageCellSlot);

return widgets;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.gui.Renderer;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
Expand Down Expand Up @@ -75,14 +76,14 @@ public List<Widget> setupDisplay(InscriberRecipeWrapper recipeDisplay, Rectangle
List<EntryIngredient> ingredients = recipeDisplay.getInputEntries();
EntryIngredient output = recipeDisplay.getOutputEntries().get(0);

// TODO 1.19.3 widgets.add(Widgets.createSlot(new Point(innerX + 1, innerY + 1)).disableBackground().markInput()
// TODO 1.19.3 .entries(ingredients.get(SLOT_INPUT_TOP)));
// TODO 1.19.3 widgets.add(Widgets.createSlot(new Point(innerX + 19, innerY + 24)).disableBackground().markInput()
// TODO 1.19.3 .entries(ingredients.get(SLOT_INPUT_MIDDLE)));
// TODO 1.19.3 widgets.add(Widgets.createSlot(new Point(innerX + 1, innerY + 47)).disableBackground().markInput()
// TODO 1.19.3 .entries(ingredients.get(SLOT_INPUT_BOTTOM)));
// TODO 1.19.3 widgets.add(Widgets.createSlot(new Point(innerX + 69, innerY + 25)).disableBackground().markOutput()
// TODO 1.19.3 .entries(output));
widgets.add(Widgets.createSlot(new Point(innerX + 1, innerY + 1)).disableBackground().markInput()
.entries(ingredients.get(SLOT_INPUT_TOP)));
widgets.add(Widgets.createSlot(new Point(innerX + 19, innerY + 24)).disableBackground().markInput()
.entries(ingredients.get(SLOT_INPUT_MIDDLE)));
widgets.add(Widgets.createSlot(new Point(innerX + 1, innerY + 47)).disableBackground().markInput()
.entries(ingredients.get(SLOT_INPUT_BOTTOM)));
widgets.add(Widgets.createSlot(new Point(innerX + 69, innerY + 25)).disableBackground().markOutput()
.entries(output));

return widgets;
}
Expand Down
88 changes: 44 additions & 44 deletions src/main/java/appeng/integration/modules/rei/TransformCategory.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ public List<Widget> setupDisplay(TransformRecipeWrapper display, Rectangle bound
// so ingredients lists with less than two rows get centered vertically
y += 9 * (3 - nInputs);
}
// TODO 1.19.3 for (var input : display.getInputEntries()) {
// TODO 1.19.3 var slot = Widgets.createSlot(new Point(x, y))
// TODO 1.19.3 .entries(input)
// TODO 1.19.3 .markInput();
// TODO 1.19.3 y += slot.getBounds().height;
// TODO 1.19.3 if (y >= bounds.y + 64) {
// TODO 1.19.3 // we don't actually have room to make multiple columns of ingredients look nice,
// TODO 1.19.3 // but this is better than just overflowing downwards.
// TODO 1.19.3 y -= 54;
// TODO 1.19.3 x += 18;
// TODO 1.19.3 }
// TODO 1.19.3 widgets.add(slot);
// TODO 1.19.3 }
for (var input : display.getInputEntries()) {
var slot = Widgets.createSlot(new Point(x, y))
.entries(input)
.markInput();
y += slot.getBounds().height;
if (y >= bounds.y + 64) {
// we don't actually have room to make multiple columns of ingredients look nice,
// but this is better than just overflowing downwards.
y -= 54;
x += 18;
}
widgets.add(slot);
}

// To center everything but the ingredients vertically
int yOffset = bounds.y + 28;
Expand All @@ -88,37 +88,37 @@ public List<Widget> setupDisplay(TransformRecipeWrapper display, Rectangle bound
var arrow1 = Widgets.createArrow(new Point(col2, yOffset));
widgets.add(arrow1);

// TODO 1.19.3 // Third column is water block
// TODO 1.19.3 final int col3 = col2 + arrow1.getBounds().getWidth() + 6;
// TODO 1.19.3 var catalystSlot = Widgets.createSlot(new Point(col3, yOffset))
// TODO 1.19.3 .entries(getCatalystForRendering(display))
// TODO 1.19.3 .markInput()
// TODO 1.19.3 .backgroundEnabled(false);
// TODO 1.19.3 widgets.add(catalystSlot);
// TODO 1.19.3
// TODO 1.19.3 // Fourth column is arrow pointing to results
// TODO 1.19.3 final int col4 = col3 + 16 + 5;
// TODO 1.19.3 var arrow2 = Widgets.createArrow(new Point(col4, yOffset));
// TODO 1.19.3 widgets.add(arrow2);
// TODO 1.19.3
// TODO 1.19.3 // Fifth column is the result
// TODO 1.19.3 final int col5 = arrow2.getBounds().getMaxX() + 10;
// TODO 1.19.3 var slot = Widgets.createSlot(new Point(col5, yOffset))
// TODO 1.19.3 .entries(display.getOutputEntries().get(0))
// TODO 1.19.3 .markOutput();
// TODO 1.19.3 widgets.add(slot);
// TODO 1.19.3
// TODO 1.19.3 Component circumstance;
// TODO 1.19.3 if (display.getTransformCircumstance().isExplosion()) {
// TODO 1.19.3 circumstance = ItemModText.EXPLOSION.text();
// TODO 1.19.3 } else {
// TODO 1.19.3 circumstance = ItemModText.SUBMERGE_IN.text();
// TODO 1.19.3 }
// TODO 1.19.3
// TODO 1.19.3 widgets.add(Widgets.createLabel(new Point(bounds.getCenterX(), bounds.y + 15), circumstance)
// TODO 1.19.3 .color(0x7E7E7E)
// TODO 1.19.3 .noShadow());
// TODO 1.19.3
// Third column is water block
final int col3 = col2 + arrow1.getBounds().getWidth() + 6;
var catalystSlot = Widgets.createSlot(new Point(col3, yOffset))
.entries(getCatalystForRendering(display))
.markInput()
.backgroundEnabled(false);
widgets.add(catalystSlot);

// Fourth column is arrow pointing to results
final int col4 = col3 + 16 + 5;
var arrow2 = Widgets.createArrow(new Point(col4, yOffset));
widgets.add(arrow2);

// Fifth column is the result
final int col5 = arrow2.getBounds().getMaxX() + 10;
var slot = Widgets.createSlot(new Point(col5, yOffset))
.entries(display.getOutputEntries().get(0))
.markOutput();
widgets.add(slot);

Component circumstance;
if (display.getTransformCircumstance().isExplosion()) {
circumstance = ItemModText.EXPLOSION.text();
} else {
circumstance = ItemModText.SUBMERGE_IN.text();
}

widgets.add(Widgets.createLabel(new Point(bounds.getCenterX(), bounds.y + 15), circumstance)
.color(0x7E7E7E)
.noShadow());

return widgets;
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/appeng/server/testplots/TestPlots.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.jetbrains.annotations.Nullable;

import net.minecraft.SharedConstants;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down

0 comments on commit aff7a7f

Please sign in to comment.