diff options
| author | shedaniel <daniel@shedaniel.me> | 2024-03-02 03:09:05 +0900 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2024-03-02 03:09:05 +0900 |
| commit | 52a6bf840ed665a2086ed37bbe0f99907d160350 (patch) | |
| tree | 75687fc5f19a5d6880e396e0c316a70f88d6ea7f | |
| parent | e4cf4d7a272dbf5da9a8ca868d003f011f5b0fc9 (diff) | |
| download | RoughlyEnoughItems-52a6bf840ed665a2086ed37bbe0f99907d160350.tar.gz RoughlyEnoughItems-52a6bf840ed665a2086ed37bbe0f99907d160350.tar.bz2 RoughlyEnoughItems-52a6bf840ed665a2086ed37bbe0f99907d160350.zip | |
Update to 24w09a
49 files changed, 374 insertions, 344 deletions
diff --git a/.github/workflows/curseforge.yml b/.github/workflows/curseforge.yml index 319c719d3..60f6d0eec 100644 --- a/.github/workflows/curseforge.yml +++ b/.github/workflows/curseforge.yml @@ -18,6 +18,7 @@ on: - 12.x-1.20 - 13.x-1.20.2 - 14.x-1.20.4 + - 15.x-1.20.5 jobs: build: @@ -32,7 +33,7 @@ jobs: - name: Upload Mod uses: gradle/gradle-build-action@v2 with: - arguments: build publish forge:publishUnified neoforge:publishUnified fabric:publishUnified --stacktrace + arguments: build publish publishUnified --stacktrace env: danielshe_curse_api_key: ${{ secrets.CF_API_KEY }} modrinth_key: ${{ secrets.MODRINTH_KEY }} 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); } } diff --git a/build.gradle b/build.gradle index b288a32e3..cac71adbb 100755 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id("architectury-plugin") version("3.4-SNAPSHOT") - id("dev.architectury.loom") version("1.4-SNAPSHOT") apply false + id("dev.architectury.loom") version("1.5-SNAPSHOT") apply false id("org.cadixdev.licenser") version("0.6.1") id("me.shedaniel.unified-publishing") version("0.1.+") id("maven-publish") diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java index ea61c622f..f1c4267ac 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java @@ -24,6 +24,7 @@ package me.shedaniel.rei.plugin.client; import com.google.common.collect.*; +import com.google.gson.internal.LinkedTreeMap; import dev.architectury.event.EventResult; import dev.architectury.networking.NetworkManager; import dev.architectury.platform.Platform; @@ -80,7 +81,9 @@ import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.inventory.*; import net.minecraft.client.gui.screens.recipebook.RecipeUpdateListener; +import net.minecraft.core.Holder; import net.minecraft.core.Registry; +import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; @@ -92,7 +95,7 @@ import net.minecraft.world.inventory.*; import net.minecraft.world.item.*; import net.minecraft.world.item.alchemy.Potion; import net.minecraft.world.item.alchemy.PotionBrewing; -import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.item.alchemy.PotionContents; import net.minecraft.world.item.crafting.*; import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Block; @@ -293,8 +296,8 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin ReferenceSet<Potion> registeredPotions = new ReferenceOpenHashSet<>(); EntryRegistry.getInstance().getEntryStacks().filter(entry -> entry.getValueType() == ItemStack.class && entry.<ItemStack>castValue().getItem() == Items.LINGERING_POTION).forEach(entry -> { ItemStack itemStack = (ItemStack) entry.getValue(); - Potion potion = PotionUtils.getPotion(itemStack); - if (registeredPotions.add(potion)) { + PotionContents potionContents = itemStack.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY); + if (potionContents.potion().isPresent() && registeredPotions.add(potionContents.potion().get().value())) { List<EntryIngredient> input = new ArrayList<>(); for (int i = 0; i < 4; i++) input.add(arrowStack); @@ -302,8 +305,7 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin for (int i = 0; i < 4; i++) input.add(arrowStack); ItemStack outputStack = new ItemStack(Items.TIPPED_ARROW, 8); - PotionUtils.setPotion(outputStack, potion); - PotionUtils.setCustomEffects(outputStack, PotionUtils.getCustomEffects(itemStack)); + outputStack.set(DataComponents.POTION_CONTENTS, potionContents); EntryIngredient output = EntryIngredients.of(outputStack); registry.add(new DefaultCustomDisplay(null, input, Collections.singletonList(output))); } @@ -337,31 +339,34 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin registry.add(new DefaultOxidationScrapingDisplay(EntryStacks.of(set.getKey()), EntryStacks.of(set.getValue()))); }); if (Platform.isFabric()) { - Set<Potion> potions = Sets.newLinkedHashSet(); + Set<Holder<Potion>> potions = Collections.newSetFromMap(new LinkedTreeMap<>(Comparator.comparing(Holder::getRegisteredName), false)); for (Ingredient container : PotionBrewing.ALLOWED_CONTAINERS) { for (PotionBrewing.Mix<Potion> mix : PotionBrewing.POTION_MIXES) { - Potion from = mix.from; - Ingredient ingredient = mix.ingredient; - Potion to = mix.to; + Holder<Potion> from = mix.from(); + Ingredient ingredient = mix.ingredient(); + Holder<Potion> to = mix.to(); Ingredient base = Ingredient.of(Arrays.stream(container.getItems()) .map(ItemStack::copy) - .map(stack -> PotionUtils.setPotion(stack, from))); + .peek(stack -> stack.set(DataComponents.POTION_CONTENTS, new PotionContents(from)))); ItemStack output = Arrays.stream(container.getItems()) .map(ItemStack::copy) - .map(stack -> PotionUtils.setPotion(stack, to)) + .peek(stack -> stack.set(DataComponents.POTION_CONTENTS, new PotionContents(to))) .findFirst().orElse(ItemStack.EMPTY); registerBrewingRecipe(base, ingredient, output); potions.add(from); potions.add(to); } } - for (Potion potion : potions) { + for (Holder<Potion> potion : potions) { for (PotionBrewing.Mix<Item> mix : PotionBrewing.CONTAINER_MIXES) { - Item from = mix.from; - Ingredient ingredient = mix.ingredient; - Item to = mix.to; - Ingredient base = Ingredient.of(PotionUtils.setPotion(new ItemStack(from), potion)); - ItemStack output = PotionUtils.setPotion(new ItemStack(to), potion); + Holder<Item> from = mix.from(); + Ingredient ingredient = mix.ingredient(); + Holder<Item> to = mix.to(); + ItemStack baseStack = new ItemStack(from); + baseStack.set(DataComponents.POTION_CONTENTS, new PotionContents(potion)); + Ingredient base = Ingredient.of(baseStack); + ItemStack output = new ItemStack(to); + output.set(DataComponents.POTION_CONTENTS, new PotionContents(potion)); registerBrewingRecipe(base, ingredient, output); } } @@ -375,7 +380,7 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin } protected void registerForgePotions(DisplayRegistry registry, BuiltinClientPlugin clientPlugin) { - + } @Override @@ -438,8 +443,8 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin } public static class DummyShovelItem extends ShovelItem { - public DummyShovelItem(Tier tier, float f, float g, Properties properties) { - super(tier, f, g, properties); + public DummyShovelItem(Tier tier, Properties properties) { + super(tier, properties); } public static Map<Block, BlockState> getPathBlocksMap() { @@ -448,8 +453,8 @@ public class DefaultClientPlugin implements REIClientPlugin, Buil |
