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
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
**/bin
/.gradle
**/.gradle
/.gradle-user
/.gradle-user-home
/minecraft
*/minecraft
/out
*/run
*/out
/run
/classes
**/remappedSrc
*_unpacked
unpacked_*.txt

# IDE nonsense that could go in source control but really shouldn't
.classpath
Expand All @@ -31,4 +36,4 @@ private.properties
# Files from bad operating systems :^)
Thumbs.db
.DS_Store
/.architectury-transformer/debug.log
/.architectury-transformer/debug.log
10 changes: 6 additions & 4 deletions api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import net.fabricmc.loom.task.RemapJarTask

archivesBaseName = rootProject.name + "-" + project.name
base {
archivesName = rootProject.name + "-" + project.name
}

loom {
accessWidenerPath = gradle.rootProject.project("fabric").file("src/main/resources/roughlyenoughitems.accessWidener")
}

dependencies {
modCompileOnly("net.fabricmc:fabric-loader:${project.fabricloader_version}")
modApi("me.shedaniel.cloth:cloth-config:${cloth_config_version}")
modApi("dev.architectury:architectury:${architectury_version}")
compileOnly("net.fabricmc:fabric-loader:${project.fabricloader_version}")
api("me.shedaniel.cloth:cloth-config:${cloth_config_version}")
api("dev.architectury:architectury:${architectury_version}")
}

architectury {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.components.Renderable;
import org.jetbrains.annotations.ApiStatus;
import org.joml.Matrix3x2f;
Expand Down Expand Up @@ -105,6 +106,14 @@ public final boolean isMouseOver(double mouseX, double mouseY) {
public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouseY, float delta) {
render(graphics, mouseX, mouseY, delta);
}

public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
}

@Override
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float delta) {
render(graphics instanceof GuiGraphics guiGraphics ? guiGraphics : new GuiGraphics(graphics), mouseX, mouseY, delta);
}

@ApiStatus.Experimental
public double getZRenderingPriority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouse
render(graphics, mouseX, mouseY, delta);
getBounds().setBounds(clone);
}

@Override
public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
render(graphics, getBounds(), mouseX, mouseY, delta);
}

@ApiStatus.Experimental
public final WidgetWithBounds withPadding(int padding) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public int countRecipeCrafts(List<List<ItemStack>> list, int maxCrafts, @Nullabl
}

private ItemKey ofKey(ItemStack itemStack) {
return keys.intern(new ItemKey(itemStack.getItemHolder(), itemStack.getComponentsPatch()));
return keys.intern(new ItemKey(itemStack.typeHolder(), itemStack.getComponentsPatch()));
}

private Ingredient ofKeys(int index, List<ItemStack> itemStack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes;
import me.shedaniel.rei.impl.Internals;
import me.shedaniel.rei.impl.common.InternalLogger;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderGetter;
import net.minecraft.core.HolderSet;
Expand All @@ -41,6 +43,7 @@
import net.minecraft.util.context.ContextMap;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ItemStackTemplate;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.display.SlotDisplay;
import net.minecraft.world.item.crafting.display.SlotDisplayContext;
Expand Down Expand Up @@ -68,6 +71,10 @@ public static EntryIngredient of(ItemLike stack, int amount) {
public static EntryIngredient of(ItemStack stack) {
return EntryIngredient.of(EntryStacks.of(stack));
}

public static EntryIngredient of(ItemStackTemplate stack) {
return EntryIngredient.of(EntryStacks.of(stack.create()));
}

public static EntryIngredient of(Fluid fluid) {
return EntryIngredient.of(EntryStacks.of(fluid));
Expand Down Expand Up @@ -229,21 +236,34 @@ public static EntryIngredient ofSlotDisplay(SlotDisplay slot) {
}
yield builder.build();
}
// TODO: Bad idea
case SlotDisplay.AnyFuel s -> EntryIngredient.empty();
default -> {
RegistryAccess access = Internals.getRegistryAccess();
try {
yield ofItemStacks(slot.resolveForStacks(new ContextMap.Builder()
.withParameter(SlotDisplayContext.REGISTRIES, access)
.create(SlotDisplayContext.CONTEXT)));
} catch (Exception e) {
InternalLogger.getInstance().warn("Failed to resolve slot display: " + slot, e);
yield EntryIngredient.empty();
}
}
case SlotDisplay.AnyFuel s -> resolveSlotDisplay(s);
default -> resolveSlotDisplay(slot);
};
}

public static ContextMap slotDisplayContext() {
Minecraft client = Minecraft.getInstance();
if (client.level != null) {
return SlotDisplayContext.fromLevel(client.level);
}

ContextMap.Builder builder = new ContextMap.Builder()
.withParameter(SlotDisplayContext.REGISTRIES, Internals.getRegistryAccess());
ClientPacketListener connection = client.getConnection();
if (connection != null) {
builder.withParameter(SlotDisplayContext.FUEL_VALUES, connection.fuelValues());
}
return builder.create(SlotDisplayContext.CONTEXT);
}

private static EntryIngredient resolveSlotDisplay(SlotDisplay slot) {
try {
return ofItemStacks(slot.resolveForStacks(slotDisplayContext()));
} catch (Exception e) {
InternalLogger.getInstance().warn("Failed to resolve slot display: " + slot, e);
return EntryIngredient.empty();
}
}

public static List<EntryIngredient> ofSlotDisplays(Iterable<SlotDisplay> slots) {
if (slots instanceof Collection<?> collection && collection.isEmpty()) return Collections.emptyList();
Expand Down
Binary file added architectury-19.0.9999.jar
Binary file not shown.
Loading