aboutsummaryrefslogtreecommitdiff
path: root/api/src/main/java/me
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2024-03-02 03:09:05 +0900
committershedaniel <daniel@shedaniel.me>2024-03-02 03:09:05 +0900
commit52a6bf840ed665a2086ed37bbe0f99907d160350 (patch)
tree75687fc5f19a5d6880e396e0c316a70f88d6ea7f /api/src/main/java/me
parente4cf4d7a272dbf5da9a8ca868d003f011f5b0fc9 (diff)
downloadRoughlyEnoughItems-52a6bf840ed665a2086ed37bbe0f99907d160350.tar.gz
RoughlyEnoughItems-52a6bf840ed665a2086ed37bbe0f99907d160350.tar.bz2
RoughlyEnoughItems-52a6bf840ed665a2086ed37bbe0f99907d160350.zip
Update to 24w09a
Diffstat (limited to 'api/src/main/java/me')
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/util/SpriteRenderer.java26
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparator.java34
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/FluidComparatorRegistry.java4
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java12
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/transfer/RecipeFinder.java3
-rw-r--r--api/src/main/java/me/shedaniel/rei/impl/Internals.java7
6 files changed, 44 insertions, 42 deletions
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<T> {
}
/**
- * 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<ItemStack> itemNbt() {
- EntryComparator<Tag> nbtHasher = nbt("Count");
+ static EntryComparator<ItemStack> itemComponents() {
+ EntryComparator<DataComponentMap> 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<FluidStack> fluidNbt() {
- EntryComparator<Tag> nbtHasher = nbt("Amount");
+ static EntryComparator<FluidStack> fluidComponents() {
+ EntryComparator<DataComponentMap> 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<Tag> nbt(String... ignoredKeys) {
- return Internals.getNbtHasher(ignoredKeys);
+ static EntryComparator<DataComponentMap> 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<FluidSt
* @param fluid the fluid to compare
*/
default void registerNbt(Fluid fluid) {
- register(EntryComparator.fluidNbt(), fluid);
+ register(EntryComparator.fluidComponents(), fluid);
}
/**
@@ -55,6 +55,6 @@ public interface FluidComparatorRegistry extends EntryComparatorRegistry<FluidSt
* @param fluids the fluids to compare
*/
default void registerNbt(Fluid... fluids) {
- register(EntryComparator.fluidNbt(), fluids);
+ register(EntryComparator.fluidComponents(), fluids);
}
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java
index fd9ed4f5c..2aea3e166 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java
@@ -41,20 +41,20 @@ public interface ItemComparatorRegistry extends EntryComparatorRegistry<ItemStac
}
/**
- * Registers an item to compare via its nbt.
+ * Registers an item to compare via its components.
*
* @param item the item to compare
*/
- default void registerNbt(Item item) {
- register(EntryComparator.itemNbt(), item);
+ default void registerComponents(Item item) {
+ register(EntryComparator.itemComponents(), item);
}
/**
- * Registers items to compare via their nbt.
+ * Registers items to compare via their components.
*
* @param items the items to compare
*/
- default void registerNbt(Item... items) {
- register(EntryComparator.itemNbt(), items);
+ default void registerComponents(Item... items) {
+ register(EntryComparator.itemComponents(), items);
}
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/transfer/RecipeFinder.java b/api/src/main/java/me/shedaniel/rei/api/common/transfer/RecipeFinder.java
index dee0825db..88283efdf 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/transfer/RecipeFinder.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/transfer/RecipeFinder.java
@@ -26,6 +26,7 @@ package me.shedaniel.rei.api.common.transfer;
import com.google.common.collect.Lists;
import it.unimi.dsi.fastutil.ints.*;
import net.minecraft.core.NonNullList;
+import net.minecraft.core.component.DataComponents;
import net.minecraft.world.entity.player.StackedContents;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
@@ -47,7 +48,7 @@ public class RecipeFinder {
}
public void addNormalItem(ItemStack stack) {
- if (!stack.isDamaged() && !stack.isEnchanted() && !stack.hasCustomHoverName()) {
+ if (!stack.isDamaged() && !stack.isEnchanted() && !stack.has(DataComponents.CUSTOM_NAME)) {
this.addItem(stack);
}
}
diff --git a/api/src/main/java/me/shedaniel/rei/impl/Internals.java b/api/src/main/java/me/shedaniel/rei/impl/Internals.java
index 112b030ce..9666c4b5f 100644
--- a/api/src/main/java/me/shedaniel/rei/impl/Internals.java
+++ b/api/src/main/java/me/shedaniel/rei/impl/Internals.java
@@ -35,7 +35,8 @@ import me.shedaniel.rei.api.common.plugins.REIPlugin;
import me.shedaniel.rei.api.common.plugins.REIServerPlugin;
import me.shedaniel.rei.api.common.transfer.info.MenuInfoRegistry;
import me.shedaniel.rei.impl.common.InternalLogger;
-import net.minecraft.nbt.Tag;
+import net.minecraft.core.component.DataComponentMap;
+import net.minecraft.core.component.DataComponentType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Unit;
import org.jetbrains.annotations.ApiStatus;
@@ -105,7 +106,7 @@ public final class Internals {
return serverPluginManager.get();
}
- public static EntryComparator<Tag> getNbtHasher(String[] ignoredKeys) {
+ public static EntryComparator<DataComponentMap> getComponentHasher(DataComponentType<?>[] ignoredKeys) {
return nbtHasherProvider.get().provide(ignoredKeys);
}
@@ -138,6 +139,6 @@ public final class Internals {
}
public interface NbtHasherProvider {
- EntryComparator<Tag> provide(String... ignoredKeys);
+ EntryComparator<DataComponentMap> provide(DataComponentType<?>... ignoredKeys);
}
}