From 52a6bf840ed665a2086ed37bbe0f99907d160350 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 2 Mar 2024 03:09:05 +0900 Subject: Update to 24w09a --- .../rei/api/client/util/SpriteRenderer.java | 26 +++++++++-------- .../common/entry/comparison/EntryComparator.java | 34 ++++++++++------------ .../entry/comparison/FluidComparatorRegistry.java | 4 +-- .../entry/comparison/ItemComparatorRegistry.java | 12 ++++---- .../rei/api/common/transfer/RecipeFinder.java | 3 +- .../main/java/me/shedaniel/rei/impl/Internals.java | 7 +++-- 6 files changed, 44 insertions(+), 42 deletions(-) (limited to 'api/src/main/java') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/util/SpriteRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/util/SpriteRenderer.java index e1d9ab421..ceaee76e6 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/util/SpriteRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/util/SpriteRenderer.java @@ -35,6 +35,7 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.resources.ResourceLocation; import org.joml.Matrix3f; import org.joml.Matrix4f; +import org.joml.Vector3f; @Environment(EnvType.CLIENT) public class SpriteRenderer { @@ -240,37 +241,38 @@ public class SpriteRenderer { this.consumer = consumers.getBuffer(layer); - this.consumer.vertex(this.model, x, y + nSY, z1) + normal(this.consumer.vertex(this.model, x, y + nSY, z1) .color(this.r, this.g, this.b, this.a) .uv(this.uStart, this.vEnd - dY) .overlayCoords(this.u, this.v) - .uv2(this.l) - .normal(this.normal, this.nX, this.nY, this.nZ) + .uv2(this.l), this.normal, this.nX, this.nY, this.nZ) .endVertex(); - this.consumer.vertex(this.model, x + nSX, y + nSY, z1) + normal(this.consumer.vertex(this.model, x + nSX, y + nSY, z1) .color(this.r, this.g, this.b, this.a) .uv(this.uEnd - dX, this.vEnd - dY) .overlayCoords(this.u, this.v) - .uv2(this.l) - .normal(this.normal, this.nX, this.nY, this.nZ) + .uv2(this.l), this.normal, this.nX, this.nY, this.nZ) .endVertex(); - this.consumer.vertex(this.model, x + nSX, y, z1) + normal(this.consumer.vertex(this.model, x + nSX, y, z1) .color(this.r, this.g, this.b, this.a) .uv(this.uEnd - dX, this.vStart) .overlayCoords(this.u, this.v) - .uv2(this.l) - .normal(this.normal, this.nX, this.nY, this.nZ) + .uv2(this.l), this.normal, this.nX, this.nY, this.nZ) .endVertex(); - this.consumer.vertex(this.model, x, y, z1) + normal(this.consumer.vertex(this.model, x, y, z1) .color(this.r, this.g, this.b, this.a) .uv(this.uStart, this.vStart) .overlayCoords(this.u, this.v) - .uv2(this.l) - .normal(this.normal, this.nX, this.nY, this.nZ) + .uv2(this.l), this.normal, this.nX, this.nY, this.nZ) .endVertex(); } } } + + private static VertexConsumer normal(VertexConsumer consumer, Matrix3f var1, float var2, float var3, float var4) { + Vector3f var5 = var1.transform(new Vector3f(var2, var3, var4)); + return consumer.normal(var5.x(), var5.y(), var5.z()); + } } } \ No newline at end of file diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparator.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparator.java index 03dfc162b..5e24c6ccf 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparator.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparator.java @@ -25,8 +25,8 @@ package me.shedaniel.rei.api.common.entry.comparison; import dev.architectury.fluid.FluidStack; import me.shedaniel.rei.impl.Internals; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; +import net.minecraft.core.component.DataComponentMap; +import net.minecraft.core.component.DataComponentType; import net.minecraft.world.item.ItemStack; import java.util.Objects; @@ -47,40 +47,38 @@ public interface EntryComparator { } /** - * Creates an {@link EntryComparator} that compares the {@link ItemStack}'s NBT. + * Creates an {@link EntryComparator} that compares the {@link ItemStack}'s components. * - * @return an {@link EntryComparator} that compares the {@link ItemStack}'s NBT + * @return an {@link EntryComparator} that compares the {@link ItemStack}'s components */ - static EntryComparator itemNbt() { - EntryComparator nbtHasher = nbt("Count"); + static EntryComparator itemComponents() { + EntryComparator componentHasher = component(); return (context, stack) -> { - CompoundTag tag = stack.getTag(); - return tag == null ? 0L : nbtHasher.hash(context, tag); + return componentHasher.hash(context, stack.getComponents()); }; } /** - * Creates an {@link EntryComparator} that compares the {@link FluidStack}'s NBT. + * Creates an {@link EntryComparator} that compares the {@link FluidStack}'s components. * - * @return an {@link EntryComparator} that compares the {@link FluidStack}'s NBT + * @return an {@link EntryComparator} that compares the {@link FluidStack}'s components */ - static EntryComparator fluidNbt() { - EntryComparator nbtHasher = nbt("Amount"); + static EntryComparator fluidComponents() { + EntryComparator componentHasher = component(); return (context, stack) -> { - CompoundTag tag = stack.getTag(); - return tag == null ? 0L : nbtHasher.hash(context, tag); + return 0L; }; } /** - * Creates an {@link EntryComparator} that compares the nbt, but + * Creates an {@link EntryComparator} that compares the components, but * ignoring some given keys. * * @param ignoredKeys the keys to ignore - * @return an {@link EntryComparator} that compares the nbt + * @return an {@link EntryComparator} that compares the components */ - static EntryComparator nbt(String... ignoredKeys) { - return Internals.getNbtHasher(ignoredKeys); + static EntryComparator component(DataComponentType... ignoredKeys) { + return Internals.getComponentHasher(ignoredKeys); } /** diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/FluidComparatorRegistry.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/FluidComparatorRegistry.java index 643ff7d91..6f6968c0e 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/FluidComparatorRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/FluidComparatorRegistry.java @@ -46,7 +46,7 @@ public interface FluidComparatorRegistry extends EntryComparatorRegistry getNbtHasher(String[] ignoredKeys) { + public static EntryComparator getComponentHasher(DataComponentType[] ignoredKeys) { return nbtHasherProvider.get().provide(ignoredKeys); } @@ -138,6 +139,6 @@ public final class Internals { } public interface NbtHasherProvider { - EntryComparator provide(String... ignoredKeys); + EntryComparator provide(DataComponentType... ignoredKeys); } } -- cgit