From 7b65d8da73dca85911f075b2f2d7495c5c3ca129 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Thu, 29 Feb 2024 18:16:31 +0900 Subject: [PATCH] Update to 24w09a Signed-off-by: shedaniel --- .github/workflows/1.20.3_push.yml | 2 +- build.gradle | 2 +- .../core/item/ArchitecturySpawnEggItem.java | 7 +-- .../injected/InjectedGameEventExtension.java | 30 ---------- .../impl/RegistrySupplierImpl.java | 5 ++ .../mixin/inject/MixinGameEvent.java | 28 ---------- .../level/entity/SpawnPlacementsRegistry.java | 3 +- .../level/entity/trade/SimpleTrade.java | 7 ++- .../resources/architectury-common.mixins.json | 1 - .../main/resources/architectury.accessWidener | 6 +- .../main/resources/architectury.common.json | 3 - fabric/build.gradle | 2 +- .../fabric/ArchitecturyFlowingFluidImpl.java | 6 +- .../ArchitecturyFluidAttributesFabric.java | 6 +- .../ArchitecturyFluidRenderingFabric.java | 34 ++++++----- .../fluid/fabric/FluidStackImpl.java | 26 ++++----- .../fluid/fabric/FluidStackHooksFabric.java | 25 ++++----- .../fluid/fabric/FluidStackHooksImpl.java | 56 ++++++++++++------- .../mixin/fabric/MixinCatSpawner.java | 2 +- .../mixin/fabric/MixinChunkMap.java | 4 +- .../mixin/fabric/MixinChunkSerializer.java | 11 +--- .../architectury/mixin/fabric/MixinLevel.java | 5 +- .../mixin/fabric/MixinPhantomSpawner.java | 3 +- .../fabric/client/MixinEffectInstance.java | 6 +- .../fabric/client/MixinGameRenderer.java | 6 +- .../mixin/fabric/client/MixinMinecraft.java | 4 +- .../fabric/client/MixinMouseHandler.java | 4 +- .../fabric/BufCustomPacketPayload.java | 50 +++++++++++++++++ .../networking/fabric/NetworkManagerImpl.java | 41 ++++++++++---- .../fabric/SpawnPlacementsRegistryImpl.java | 3 +- .../menu/fabric/MenuRegistryImpl.java | 21 ++++++- gradle.properties | 14 ++--- settings.gradle | 10 ++-- .../test/recipes/TestRecipeSerializer.java | 12 +++- .../test/registry/TestRegistries.java | 2 +- .../architectury/test/trade/TestTrades.java | 6 +- .../main/resources/architectury.common.json | 3 - 37 files changed, 249 insertions(+), 207 deletions(-) delete mode 100644 common/src/main/java/dev/architectury/extensions/injected/InjectedGameEventExtension.java delete mode 100644 common/src/main/java/dev/architectury/mixin/inject/MixinGameEvent.java create mode 100644 fabric/src/main/java/dev/architectury/networking/fabric/BufCustomPacketPayload.java diff --git a/.github/workflows/1.20.3_push.yml b/.github/workflows/1.20.3_push.yml index 3ad816d55..78312a6d5 100644 --- a/.github/workflows/1.20.3_push.yml +++ b/.github/workflows/1.20.3_push.yml @@ -7,7 +7,7 @@ on: - '**.properties' - '**/src/**' branches: - - "1.20.4" + - "1.20.5" workflow_dispatch: inputs: norelease: diff --git a/build.gradle b/build.gradle index adabc626f..1a52fe733 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { 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.+" apply false id "maven-publish" diff --git a/common/src/main/java/dev/architectury/core/item/ArchitecturySpawnEggItem.java b/common/src/main/java/dev/architectury/core/item/ArchitecturySpawnEggItem.java index 254cbedf3..7df05cf64 100644 --- a/common/src/main/java/dev/architectury/core/item/ArchitecturySpawnEggItem.java +++ b/common/src/main/java/dev/architectury/core/item/ArchitecturySpawnEggItem.java @@ -24,7 +24,6 @@ import net.minecraft.core.dispenser.BlockSource; import net.minecraft.core.dispenser.DefaultDispenseItemBehavior; import net.minecraft.core.dispenser.DispenseItemBehavior; -import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MobSpawnType; @@ -48,7 +47,7 @@ protected static DispenseItemBehavior createDispenseItemBehavior() { @Override public ItemStack execute(BlockSource source, ItemStack stack) { Direction direction = source.state().getValue(DispenserBlock.FACING); - EntityType entityType = ((SpawnEggItem) stack.getItem()).getType(stack.getTag()); + EntityType entityType = ((SpawnEggItem) stack.getItem()).getType(stack); try { entityType.spawn(source.level(), stack, null, source.pos().relative(direction), MobSpawnType.DISPENSER, direction != Direction.UP, false); @@ -86,8 +85,8 @@ public ArchitecturySpawnEggItem(RegistrySupplier getType(@Nullable CompoundTag compoundTag) { - EntityType type = super.getType(compoundTag); + public EntityType getType(ItemStack itemStack) { + EntityType type = super.getType(itemStack); return type == null ? entityType.get() : type; } } diff --git a/common/src/main/java/dev/architectury/extensions/injected/InjectedGameEventExtension.java b/common/src/main/java/dev/architectury/extensions/injected/InjectedGameEventExtension.java deleted file mode 100644 index 89c509861..000000000 --- a/common/src/main/java/dev/architectury/extensions/injected/InjectedGameEventExtension.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is part of architectury. - * Copyright (C) 2020, 2021, 2022 architectury - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package dev.architectury.extensions.injected; - -import net.minecraft.core.Holder; -import net.minecraft.world.level.gameevent.GameEvent; - -public interface InjectedGameEventExtension extends InjectedRegistryEntryExtension { - @Override - default Holder arch$holder() { - return ((GameEvent) this).builtInRegistryHolder(); - } -} diff --git a/common/src/main/java/dev/architectury/impl/RegistrySupplierImpl.java b/common/src/main/java/dev/architectury/impl/RegistrySupplierImpl.java index dd11c205c..3811590c0 100644 --- a/common/src/main/java/dev/architectury/impl/RegistrySupplierImpl.java +++ b/common/src/main/java/dev/architectury/impl/RegistrySupplierImpl.java @@ -69,6 +69,11 @@ default boolean is(TagKey tagKey) { return holder != null && holder.is(tagKey); } + @Override + default boolean is(Holder holder) { + return holder.is(getKey()); + } + @Override default Stream> tags() { Holder holder = getHolder(); diff --git a/common/src/main/java/dev/architectury/mixin/inject/MixinGameEvent.java b/common/src/main/java/dev/architectury/mixin/inject/MixinGameEvent.java deleted file mode 100644 index a71fc8945..000000000 --- a/common/src/main/java/dev/architectury/mixin/inject/MixinGameEvent.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of architectury. - * Copyright (C) 2020, 2021, 2022 architectury - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package dev.architectury.mixin.inject; - -import dev.architectury.extensions.injected.InjectedGameEventExtension; -import net.minecraft.world.level.gameevent.GameEvent; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(GameEvent.class) -public class MixinGameEvent implements InjectedGameEventExtension { -} diff --git a/common/src/main/java/dev/architectury/registry/level/entity/SpawnPlacementsRegistry.java b/common/src/main/java/dev/architectury/registry/level/entity/SpawnPlacementsRegistry.java index 386e9ffb2..6b85223b5 100644 --- a/common/src/main/java/dev/architectury/registry/level/entity/SpawnPlacementsRegistry.java +++ b/common/src/main/java/dev/architectury/registry/level/entity/SpawnPlacementsRegistry.java @@ -22,6 +22,7 @@ import dev.architectury.injectables.annotations.ExpectPlatform; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.SpawnPlacementType; import net.minecraft.world.entity.SpawnPlacements; import net.minecraft.world.level.levelgen.Heightmap; @@ -38,7 +39,7 @@ public final class SpawnPlacementsRegistry { * @see net.minecraft.world.entity.SpawnPlacements */ @ExpectPlatform - public static void register(Supplier> type, SpawnPlacements.Type spawnPlacement, Heightmap.Types heightmapType, SpawnPlacements.SpawnPredicate spawnPredicate) { + public static void register(Supplier> type, SpawnPlacementType spawnPlacement, Heightmap.Types heightmapType, SpawnPlacements.SpawnPredicate spawnPredicate) { throw new AssertionError(); } } diff --git a/common/src/main/java/dev/architectury/registry/level/entity/trade/SimpleTrade.java b/common/src/main/java/dev/architectury/registry/level/entity/trade/SimpleTrade.java index c21daa334..1bfc07ee0 100644 --- a/common/src/main/java/dev/architectury/registry/level/entity/trade/SimpleTrade.java +++ b/common/src/main/java/dev/architectury/registry/level/entity/trade/SimpleTrade.java @@ -23,9 +23,12 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.npc.VillagerTrades; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.trading.ItemCost; import net.minecraft.world.item.trading.MerchantOffer; import org.jetbrains.annotations.Nullable; +import java.util.Optional; + /** * This class is the easiest implementation of a trade object. * All trades added by vanilla do have custom classes like {@link VillagerTrades.EmeraldForItems}, but they aren't accessible. @@ -36,7 +39,7 @@ * or * {@link TradeRegistry#registerTradeForWanderingTrader(boolean, VillagerTrades.ItemListing...)}. */ -public record SimpleTrade(ItemStack primaryPrice, ItemStack secondaryPrice, +public record SimpleTrade(ItemCost primaryPrice, Optional secondaryPrice, ItemStack sale, int maxTrades, int experiencePoints, float priceMultiplier) implements VillagerTrades.ItemListing { /** @@ -44,7 +47,7 @@ public record SimpleTrade(ItemStack primaryPrice, ItemStack secondaryPrice, * You can take a look at all the values the vanilla game uses right here {@link VillagerTrades#TRADES}. * * @param primaryPrice The first price a player has to pay to get the 'sale' stack. - * @param secondaryPrice A optional, secondary price to pay as well as the primary one. If not needed just use {@link ItemStack#EMPTY}. + * @param secondaryPrice An optional, secondary price to pay as well as the primary one. If not needed just use {@link Optional#empty()}. * @param sale The ItemStack which a player can purchase in exchange for the two prices. * @param maxTrades The amount of trades one villager or wanderer can do. When the amount is surpassed, the trade can't be purchased anymore. * @param experiencePoints How much experience points does the player get, when trading. Vanilla uses between 2 and 30 for this. diff --git a/common/src/main/resources/architectury-common.mixins.json b/common/src/main/resources/architectury-common.mixins.json index dbe32348d..e370e0aa4 100644 --- a/common/src/main/resources/architectury-common.mixins.json +++ b/common/src/main/resources/architectury-common.mixins.json @@ -11,7 +11,6 @@ "inject.MixinEntityType", "inject.MixinFluid", "inject.MixinFoodPropertiesBuilder", - "inject.MixinGameEvent", "inject.MixinItem", "inject.MixinItemProperties", "inject.MixinLiquidBlock", diff --git a/common/src/main/resources/architectury.accessWidener b/common/src/main/resources/architectury.accessWidener index 662bc644c..9538a243e 100644 --- a/common/src/main/resources/architectury.accessWidener +++ b/common/src/main/resources/architectury.accessWidener @@ -141,10 +141,7 @@ transitive-accessible class net/minecraft/world/item/CreativeModeTab$TabVisibili ############################## # Constructors of non-abstract item classes -transitive-accessible method net/minecraft/world/item/AxeItem (Lnet/minecraft/world/item/Tier;FFLnet/minecraft/world/item/Item$Properties;)V -transitive-accessible method net/minecraft/world/item/DiggerItem (FFLnet/minecraft/world/item/Tier;Lnet/minecraft/tags/TagKey;Lnet/minecraft/world/item/Item$Properties;)V -transitive-accessible method net/minecraft/world/item/HoeItem (Lnet/minecraft/world/item/Tier;IFLnet/minecraft/world/item/Item$Properties;)V -transitive-accessible method net/minecraft/world/item/PickaxeItem (Lnet/minecraft/world/item/Tier;IFLnet/minecraft/world/item/Item$Properties;)V +transitive-accessible method net/minecraft/world/item/DiggerItem (Lnet/minecraft/world/item/Tier;Lnet/minecraft/tags/TagKey;Lnet/minecraft/world/item/Item$Properties;)V transitive-accessible method net/minecraft/world/item/RecordItem (ILnet/minecraft/sounds/SoundEvent;Lnet/minecraft/world/item/Item$Properties;I)V # Constructors of non-abstract block classes @@ -304,6 +301,7 @@ transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDE transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_TRIPWIRE_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_END_PORTAL_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_END_GATEWAY_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; +transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_CLOUDS_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_LINES_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_GUI_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_GUI_OVERLAY_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; diff --git a/common/src/main/resources/architectury.common.json b/common/src/main/resources/architectury.common.json index 3b8c79681..3df2138a2 100644 --- a/common/src/main/resources/architectury.common.json +++ b/common/src/main/resources/architectury.common.json @@ -19,9 +19,6 @@ "net/minecraft/class_1755": [ "dev/architectury/extensions/injected/InjectedBucketItemExtension" ], - "net/minecraft/class_5712": [ - "dev/architectury/extensions/injected/InjectedGameEventExtension" - ], "net/minecraft/class_4174$class_4175": [ "dev/architectury/extensions/injected/InjectedFoodPropertiesBuilderExtension" ], diff --git a/fabric/build.gradle b/fabric/build.gradle index 6ab455742..70cc13836 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -128,7 +128,7 @@ unifiedPublishing { curseforge { token = CURSE_API_KEY id = rootProject.curseforge_id - gameVersions.addAll "Java 17", project.minecraft_version + gameVersions.addAll "Java 17", "1.20.5-Snapshot"//, project.minecraft_version } } diff --git a/fabric/src/main/java/dev/architectury/core/fluid/fabric/ArchitecturyFlowingFluidImpl.java b/fabric/src/main/java/dev/architectury/core/fluid/fabric/ArchitecturyFlowingFluidImpl.java index 23d517598..848c7872b 100644 --- a/fabric/src/main/java/dev/architectury/core/fluid/fabric/ArchitecturyFlowingFluidImpl.java +++ b/fabric/src/main/java/dev/architectury/core/fluid/fabric/ArchitecturyFlowingFluidImpl.java @@ -23,19 +23,17 @@ import dev.architectury.utils.Env; import dev.architectury.utils.EnvExecutor; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; -import net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRendering; -import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariantAttributes; import net.minecraft.world.level.material.FlowingFluid; public class ArchitecturyFlowingFluidImpl { public static void addFabricFluidAttributes(FlowingFluid fluid, ArchitecturyFluidAttributes attributes) { - FluidVariantAttributes.register(fluid, new ArchitecturyFluidAttributesFabric(attributes)); + // TODO: FluidVariantAttributes.register(fluid, new ArchitecturyFluidAttributesFabric(attributes)); EnvExecutor.runInEnv(Env.CLIENT, () -> () -> Client.run(fluid, attributes)); } private static class Client { private static void run(FlowingFluid fluid, ArchitecturyFluidAttributes attributes) { - FluidVariantRendering.register(fluid, new ArchitecturyFluidRenderingFabric(attributes)); + // TODO: FluidVariantRendering.register(fluid, new ArchitecturyFluidRenderingFabric(attributes)); FluidRenderHandlerRegistry.INSTANCE.register(fluid, new ArchitecturyFluidRenderingFabric(attributes)); } } diff --git a/fabric/src/main/java/dev/architectury/core/fluid/fabric/ArchitecturyFluidAttributesFabric.java b/fabric/src/main/java/dev/architectury/core/fluid/fabric/ArchitecturyFluidAttributesFabric.java index 9f6b0ad55..a6d0145be 100644 --- a/fabric/src/main/java/dev/architectury/core/fluid/fabric/ArchitecturyFluidAttributesFabric.java +++ b/fabric/src/main/java/dev/architectury/core/fluid/fabric/ArchitecturyFluidAttributesFabric.java @@ -22,8 +22,6 @@ import dev.architectury.core.fluid.ArchitecturyFluidAttributes; import dev.architectury.fluid.FluidStack; import dev.architectury.hooks.fluid.fabric.FluidStackHooksFabric; -import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; -import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariantAttributeHandler; import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.level.Level; @@ -32,7 +30,7 @@ import java.util.Optional; @SuppressWarnings("UnstableApiUsage") -class ArchitecturyFluidAttributesFabric implements FluidVariantAttributeHandler { +class ArchitecturyFluidAttributesFabric {} /*implements FluidVariantAttributeHandler { private final ArchitecturyFluidAttributes attributes; public ArchitecturyFluidAttributesFabric(ArchitecturyFluidAttributes attributes) { @@ -73,4 +71,4 @@ public int getViscosity(FluidVariant variant, @Nullable Level world) { public boolean isLighterThanAir(FluidVariant variant) { return attributes.isLighterThanAir(FluidStackHooksFabric.fromFabric(variant, FluidStack.bucketAmount())); } -} +}*/ diff --git a/fabric/src/main/java/dev/architectury/core/fluid/fabric/ArchitecturyFluidRenderingFabric.java b/fabric/src/main/java/dev/architectury/core/fluid/fabric/ArchitecturyFluidRenderingFabric.java index 6159fa5ad..47ec9cbb3 100644 --- a/fabric/src/main/java/dev/architectury/core/fluid/fabric/ArchitecturyFluidRenderingFabric.java +++ b/fabric/src/main/java/dev/architectury/core/fluid/fabric/ArchitecturyFluidRenderingFabric.java @@ -25,8 +25,6 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler; -import net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRenderHandler; -import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -40,7 +38,7 @@ @SuppressWarnings("UnstableApiUsage") @Environment(EnvType.CLIENT) -class ArchitecturyFluidRenderingFabric implements FluidVariantRenderHandler, FluidRenderHandler { +class ArchitecturyFluidRenderingFabric implements /*FluidVariantRenderHandler,*/ FluidRenderHandler { private final ArchitecturyFluidAttributes attributes; private final TextureAtlasSprite[] sprites = new TextureAtlasSprite[3]; private final TextureAtlasSprite[] spritesOther = new TextureAtlasSprite[3]; @@ -49,22 +47,22 @@ public ArchitecturyFluidRenderingFabric(ArchitecturyFluidAttributes attributes) this.attributes = attributes; } - @Override - @Nullable - public TextureAtlasSprite[] getSprites(FluidVariant variant) { - FluidStack stack = FluidStackHooksFabric.fromFabric(variant, FluidStack.bucketAmount()); - Function atlas = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS); - sprites[0] = atlas.apply(attributes.getSourceTexture(stack)); - sprites[1] = atlas.apply(attributes.getFlowingTexture(stack)); - ResourceLocation overlayTexture = attributes.getOverlayTexture(stack); - sprites[2] = overlayTexture == null ? null : atlas.apply(overlayTexture); - return sprites; - } +// @Override +// @Nullable +// public TextureAtlasSprite[] getSprites(FluidVariant variant) { +// FluidStack stack = FluidStackHooksFabric.fromFabric(variant, FluidStack.bucketAmount()); +// Function atlas = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS); +// sprites[0] = atlas.apply(attributes.getSourceTexture(stack)); +// sprites[1] = atlas.apply(attributes.getFlowingTexture(stack)); +// ResourceLocation overlayTexture = attributes.getOverlayTexture(stack); +// sprites[2] = overlayTexture == null ? null : atlas.apply(overlayTexture); +// return sprites; +// } - @Override - public int getColor(FluidVariant variant, @Nullable BlockAndTintGetter view, @Nullable BlockPos pos) { - return attributes.getColor(FluidStackHooksFabric.fromFabric(variant, FluidStack.bucketAmount()), view, pos); - } +// @Override +// public int getColor(FluidVariant variant, @Nullable BlockAndTintGetter view, @Nullable BlockPos pos) { +// return attributes.getColor(FluidStackHooksFabric.fromFabric(variant, FluidStack.bucketAmount()), view, pos); +// } @Override public TextureAtlasSprite[] getFluidSprites(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, FluidState state) { diff --git a/fabric/src/main/java/dev/architectury/fluid/fabric/FluidStackImpl.java b/fabric/src/main/java/dev/architectury/fluid/fabric/FluidStackImpl.java index 9d90cf972..9fc0e88cb 100644 --- a/fabric/src/main/java/dev/architectury/fluid/fabric/FluidStackImpl.java +++ b/fabric/src/main/java/dev/architectury/fluid/fabric/FluidStackImpl.java @@ -20,7 +20,6 @@ package dev.architectury.fluid.fabric; import dev.architectury.fluid.FluidStack; -import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.material.FlowingFluid; import net.minecraft.world.level.material.Fluid; @@ -49,10 +48,11 @@ public static FluidStack.FluidStackAdapter adapt(Function fluid, long amount, CompoundTa if (fluidType instanceof FlowingFluid flowingFluid) { fluidType = flowingFluid.getSource(); } - return new Pair(FluidVariant.of(fluidType, tag == null ? null : tag.copy()), amount); + return new Pair(fluidType/*, tag == null ? null : tag.copy())*/, amount); } @Override public Supplier getRawFluidSupplier(FluidStackImpl.Pair object) { - return object.variant::getFluid; + return () -> object.variant; } @Override public Fluid getFluid(FluidStackImpl.Pair object) { - return object.variant.getFluid(); + return object.variant; } @Override @@ -89,28 +89,28 @@ public void setAmount(FluidStackImpl.Pair object, long amount) { @Override public CompoundTag getTag(FluidStackImpl.Pair value) { - return value.variant.getNbt(); + return null; // value.variant.getNbt(); } @Override public void setTag(FluidStackImpl.Pair value, CompoundTag tag) { - value.variant = FluidVariant.of(value.variant.getFluid(), tag); + // value.variant = FluidVariant.of(value.variant.getFluid(), tag); } @Override public FluidStackImpl.Pair copy(FluidStackImpl.Pair value) { - return new Pair(FluidVariant.of(value.variant.getFluid(), value.variant.copyNbt()), value.amount); + return new Pair(value.variant/*FluidVariant.of(value.variant.getFluid(), value.variant.copyNbt())*/, value.amount); } @Override public int hashCode(FluidStackImpl.Pair value) { var pair = (Pair) value; var code = 1; - code = 31 * code + pair.variant.getFluid().hashCode(); + code = 31 * code + pair.variant.hashCode(); code = 31 * code + Long.hashCode(pair.amount); - var tag = pair.variant.getNbt(); - if (tag != null) - code = 31 * code + tag.hashCode(); +// var tag = pair.variant.getNbt(); +// if (tag != null) +// code = 31 * code + tag.hashCode(); return code; } } diff --git a/fabric/src/main/java/dev/architectury/hooks/fluid/fabric/FluidStackHooksFabric.java b/fabric/src/main/java/dev/architectury/hooks/fluid/fabric/FluidStackHooksFabric.java index 83cf94aab..ae5526ae7 100644 --- a/fabric/src/main/java/dev/architectury/hooks/fluid/fabric/FluidStackHooksFabric.java +++ b/fabric/src/main/java/dev/architectury/hooks/fluid/fabric/FluidStackHooksFabric.java @@ -21,23 +21,22 @@ import dev.architectury.fluid.FluidStack; import dev.architectury.fluid.fabric.FluidStackImpl; -import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; -import net.fabricmc.fabric.api.transfer.v1.storage.StorageView; @SuppressWarnings("UnstableApiUsage") public final class FluidStackHooksFabric { private FluidStackHooksFabric() { } - public static FluidStack fromFabric(StorageView storageView) { - return fromFabric(storageView.getResource(), storageView.getAmount()); - } - - public static FluidStack fromFabric(FluidVariant variant, long amount) { - return FluidStackImpl.fromValue.apply(new FluidStackImpl.Pair(variant, amount)); - } - - public static FluidVariant toFabric(FluidStack stack) { - return ((FluidStackImpl.Pair) FluidStackImpl.toValue.apply(stack)).variant; - } +// TODO +// public static FluidStack fromFabric(StorageView storageView) { +// return fromFabric(storageView.getResource(), storageView.getAmount()); +// } + +// public static FluidStack fromFabric(FluidVariant variant, long amount) { +// return FluidStackImpl.fromValue.apply(new FluidStackImpl.Pair(variant, amount)); +// } + +// public static FluidVariant toFabric(FluidStack stack) { +// return ((FluidStackImpl.Pair) FluidStackImpl.toValue.apply(stack)).variant; +// } } \ No newline at end of file diff --git a/fabric/src/main/java/dev/architectury/hooks/fluid/fabric/FluidStackHooksImpl.java b/fabric/src/main/java/dev/architectury/hooks/fluid/fabric/FluidStackHooksImpl.java index d21dfb7d5..3379f242c 100644 --- a/fabric/src/main/java/dev/architectury/hooks/fluid/fabric/FluidStackHooksImpl.java +++ b/fabric/src/main/java/dev/architectury/hooks/fluid/fabric/FluidStackHooksImpl.java @@ -23,9 +23,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; -import net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRendering; -import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; -import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariantAttributes; +import net.minecraft.Util; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.core.BlockPos; import net.minecraft.core.registries.BuiltInRegistries; @@ -36,6 +34,8 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.FlowingFluid; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; @@ -45,7 +45,14 @@ public class FluidStackHooksImpl { public static Component getName(FluidStack stack) { - return FluidVariantAttributes.getName(FluidStackHooksFabric.toFabric(stack)); + var block = stack.getFluid().defaultFluidState().createLegacyBlock().getBlock(); + + if (!stack.isEmpty() && block == Blocks.AIR) { + return Component.translatable(Util.makeDescriptionId("block", BuiltInRegistries.FLUID.getKey(stack.getFluid()))); + } else { + return block.getName(); + } + // TODO: return FluidVariantAttributes.getName(FluidStackHooksFabric.toFabric(stack)); } public static String getTranslationKey(FluidStack stack) { @@ -112,15 +119,17 @@ public static TextureAtlasSprite getStillTexture(@Nullable BlockAndTintGetter le @Environment(EnvType.CLIENT) @Nullable public static TextureAtlasSprite getStillTexture(FluidStack stack) { - var sprites = FluidVariantRendering.getSprites(FluidStackHooksFabric.toFabric(stack)); - return sprites == null ? null : sprites[0]; + return getStillTexture(null, null, stack.getFluid().defaultFluidState()); + // var sprites = FluidVariantRendering.getSprites(FluidStackHooksFabric.toFabric(stack)); + // return sprites == null ? null : sprites[0]; } @Environment(EnvType.CLIENT) @Nullable public static TextureAtlasSprite getStillTexture(Fluid fluid) { - var sprites = FluidVariantRendering.getSprites(FluidVariant.of(fluid)); - return sprites == null ? null : sprites[0]; + return getStillTexture(null, null, fluid.defaultFluidState()); + // var sprites = FluidVariantRendering.getSprites(FluidVariant.of(fluid)); + // return sprites == null ? null : sprites[0]; } @Environment(EnvType.CLIENT) @@ -137,15 +146,17 @@ public static TextureAtlasSprite getFlowingTexture(@Nullable BlockAndTintGetter @Environment(EnvType.CLIENT) @Nullable public static TextureAtlasSprite getFlowingTexture(FluidStack stack) { - var sprites = FluidVariantRendering.getSprites(FluidStackHooksFabric.toFabric(stack)); - return sprites == null ? null : sprites[1]; + return getFlowingTexture(null, null, stack.getFluid().defaultFluidState()); + // var sprites = FluidVariantRendering.getSprites(FluidStackHooksFabric.toFabric(stack)); + // return sprites == null ? null : sprites[1]; } @Environment(EnvType.CLIENT) @Nullable public static TextureAtlasSprite getFlowingTexture(Fluid fluid) { - var sprites = FluidVariantRendering.getSprites(FluidVariant.of(fluid)); - return sprites == null ? null : sprites[1]; + return getFlowingTexture(null, null, fluid.defaultFluidState()); + // var sprites = FluidVariantRendering.getSprites(FluidVariant.of(fluid)); + // return sprites == null ? null : sprites[1]; } @Environment(EnvType.CLIENT) @@ -158,7 +169,8 @@ public static int getColor(@Nullable BlockAndTintGetter level, @Nullable BlockPo @Environment(EnvType.CLIENT) public static int getColor(FluidStack stack) { - return FluidVariantRendering.getColor(FluidStackHooksFabric.toFabric(stack)); + return getColor(stack.getFluid()); + // return FluidVariantRendering.getColor(FluidStackHooksFabric.toFabric(stack)); } @Environment(EnvType.CLIENT) @@ -170,26 +182,32 @@ public static int getColor(Fluid fluid) { } public static int getLuminosity(FluidStack fluid, @Nullable Level level, @Nullable BlockPos pos) { - return FluidVariantAttributes.getLuminance(FluidStackHooksFabric.toFabric(fluid)); + return fluid.getFluid().defaultFluidState().createLegacyBlock().getLightEmission(); + // return FluidVariantAttributes.getLuminance(FluidStackHooksFabric.toFabric(fluid)); } public static int getLuminosity(Fluid fluid, @Nullable Level level, @Nullable BlockPos pos) { - return FluidVariantAttributes.getLuminance(FluidVariant.of(fluid)); + return fluid.defaultFluidState().createLegacyBlock().getLightEmission(); + // return FluidVariantAttributes.getLuminance(FluidVariant.of(fluid)); } public static int getTemperature(FluidStack fluid, @Nullable Level level, @Nullable BlockPos pos) { - return FluidVariantAttributes.getTemperature(FluidStackHooksFabric.toFabric(fluid)); + return 300; + // return FluidVariantAttributes.getTemperature(FluidStackHooksFabric.toFabric(fluid)); } public static int getTemperature(Fluid fluid, @Nullable Level level, @Nullable BlockPos pos) { - return FluidVariantAttributes.getTemperature(FluidVariant.of(fluid)); + return 300; + // return FluidVariantAttributes.getTemperature(FluidVariant.of(fluid)); } public static int getViscosity(FluidStack fluid, @Nullable Level level, @Nullable BlockPos pos) { - return FluidVariantAttributes.getViscosity(FluidStackHooksFabric.toFabric(fluid), level); + return fluid.getFluid() instanceof FlowingFluid flowingFluid && level != null ? flowingFluid.getTickDelay(level) * 200 : 1000; + // return FluidVariantAttributes.getViscosity(FluidStackHooksFabric.toFabric(fluid), level); } public static int getViscosity(Fluid fluid, @Nullable Level level, @Nullable BlockPos pos) { - return FluidVariantAttributes.getViscosity(FluidVariant.of(fluid), level); + return fluid instanceof FlowingFluid flowingFluid && level != null ? flowingFluid.getTickDelay(level) * 200 : 1000; + // return FluidVariantAttributes.getViscosity(FluidVariant.of(fluid), level); } } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinCatSpawner.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinCatSpawner.java index e6add754f..97d313c9e 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinCatSpawner.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinCatSpawner.java @@ -37,7 +37,7 @@ public abstract class MixinCatSpawner { method = "spawnCat", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/entity/animal/Cat;finalizeSpawn(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/MobSpawnType;Lnet/minecraft/world/entity/SpawnGroupData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/world/entity/SpawnGroupData;", + target = "Lnet/minecraft/world/entity/animal/Cat;finalizeSpawn(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/MobSpawnType;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;", ordinal = 0 ), cancellable = true, diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkMap.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkMap.java index 6c17c911c..7f821ead4 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkMap.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkMap.java @@ -25,7 +25,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.chunk.ChunkAccess; -import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.status.ChunkStatus; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -42,7 +42,7 @@ public class MixinChunkMap { @Inject( method = "save", - at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;write(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/nbt/CompoundTag;)V", ordinal = 0), + at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;write(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/nbt/CompoundTag;)Ljava/util/concurrent/CompletableFuture;", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD ) private void save(ChunkAccess chunkAccess, CallbackInfoReturnable cir, ChunkPos pos, ChunkStatus chunkStatus, CompoundTag nbt) { diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkSerializer.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkSerializer.java index d9492b380..843a939f7 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkSerializer.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkSerializer.java @@ -29,13 +29,8 @@ import net.minecraft.world.entity.ai.village.poi.PoiManager; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.chunk.ChunkAccess; -import net.minecraft.world.level.chunk.ChunkSource; -import net.minecraft.world.level.chunk.ChunkStatus; -import net.minecraft.world.level.chunk.LevelChunkSection; -import net.minecraft.world.level.chunk.PalettedContainer; -import net.minecraft.world.level.chunk.ProtoChunk; -import net.minecraft.world.level.chunk.UpgradeData; +import net.minecraft.world.level.chunk.*; +import net.minecraft.world.level.chunk.status.ChunkType; import net.minecraft.world.level.chunk.storage.ChunkSerializer; import net.minecraft.world.level.levelgen.blending.BlendingData; import net.minecraft.world.level.lighting.LevelLightEngine; @@ -53,7 +48,7 @@ private static void load(ServerLevel serverLevel, PoiManager poiManager, ChunkPo boolean bl, ListTag listTag, int i, LevelChunkSection[] levelChunkSections, boolean bl2, ChunkSource chunkSource, LevelLightEngine levelLightEngine, Registry registry, Codec>> codec, boolean bl3, long m, - ChunkStatus.ChunkType chunkType, BlendingData blendingData, ChunkAccess chunkAccess) { + ChunkType chunkType, BlendingData blendingData, ChunkAccess chunkAccess) { ChunkEvent.LOAD_DATA.invoker().load(chunkAccess, serverLevel, compoundTag); } } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinLevel.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinLevel.java index c6472b88f..03a56f345 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinLevel.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinLevel.java @@ -20,6 +20,7 @@ package dev.architectury.mixin.fabric; import dev.architectury.event.events.common.ExplosionEvent; +import net.minecraft.core.Holder; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.damagesource.DamageSource; @@ -35,9 +36,9 @@ @Mixin(Level.class) public class MixinLevel { - @Inject(method = "explode(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Level$ExplosionInteraction;ZLnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/sounds/SoundEvent;)Lnet/minecraft/world/level/Explosion;", + @Inject(method = "explode(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Level$ExplosionInteraction;ZLnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/Holder;)Lnet/minecraft/world/level/Explosion;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Explosion;explode()V"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) - private void explodePre(Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionDamageCalculator, double d, double e, double f, float g, boolean bl, Level.ExplosionInteraction explosionInteraction, boolean bl2, ParticleOptions particleOptions, ParticleOptions particleOptions2, SoundEvent soundEvent, CallbackInfoReturnable cir, Explosion.BlockInteraction blockInteraction, Explosion explosion) { + private void explodePre(Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionDamageCalculator, double d, double e, double f, float g, boolean bl, Level.ExplosionInteraction explosionInteraction, boolean bl2, ParticleOptions particleOptions, ParticleOptions particleOptions2, Holder soundEvent, CallbackInfoReturnable cir, Explosion.BlockInteraction blockInteraction, Explosion explosion) { if (ExplosionEvent.PRE.invoker().explode((Level) (Object) this, explosion).isFalse()) { cir.setReturnValue(explosion); } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinPhantomSpawner.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinPhantomSpawner.java index 8f9de9a88..6c074b5e9 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinPhantomSpawner.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinPhantomSpawner.java @@ -29,7 +29,6 @@ import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.entity.SpawnGroupData; import net.minecraft.world.entity.monster.Phantom; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.PhantomSpawner; import net.minecraft.world.level.material.FluidState; @@ -48,7 +47,7 @@ public abstract class MixinPhantomSpawner { method = "tick", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/entity/monster/Phantom;finalizeSpawn(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/MobSpawnType;Lnet/minecraft/world/entity/SpawnGroupData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/world/entity/SpawnGroupData;", + target = "Lnet/minecraft/world/entity/monster/Phantom;finalizeSpawn(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/MobSpawnType;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;", ordinal = 0, shift = At.Shift.BEFORE ), diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinEffectInstance.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinEffectInstance.java index a6c94cdd6..83cdb43bd 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinEffectInstance.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinEffectInstance.java @@ -22,7 +22,7 @@ import com.mojang.blaze3d.shaders.Program; import net.minecraft.client.renderer.EffectInstance; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.server.packs.resources.ResourceProvider; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -37,7 +37,7 @@ public class MixinEffectInstance { target = "(Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation;", ordinal = 0) ) - private ResourceLocation mojangPls(String _0, ResourceManager rm, String str) { + private ResourceLocation mojangPls(String _0, ResourceProvider rm, String str) { return mojangPls(new ResourceLocation(str), ".json"); } @@ -47,7 +47,7 @@ private ResourceLocation mojangPls(String _0, ResourceManager rm, String str) { target = "(Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation;", ordinal = 0) ) - private static ResourceLocation mojangPls(String _0, ResourceManager rm, Program.Type type, String str) { + private static ResourceLocation mojangPls(String _0, ResourceProvider rm, Program.Type type, String str) { return mojangPls(new ResourceLocation(str), type.getExtension()); } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinGameRenderer.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinGameRenderer.java index 2d0b44051..df7c61fc6 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinGameRenderer.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinGameRenderer.java @@ -21,7 +21,6 @@ import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.shaders.Program; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.datafixers.util.Pair; import dev.architectury.event.events.client.ClientGuiEvent; import dev.architectury.event.events.client.ClientReloadShadersEvent; @@ -31,6 +30,7 @@ import net.minecraft.client.renderer.ShaderInstance; import net.minecraft.server.packs.resources.ResourceProvider; import org.joml.Matrix4f; +import org.joml.Matrix4fStack; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -51,7 +51,7 @@ public abstract class MixinGameRenderer { @Inject(method = "render(FJZ)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;renderWithTooltip(Lnet/minecraft/client/gui/GuiGraphics;IIF)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILEXCEPTION, cancellable = true) - public void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo ci, float speedAppliedTickDelta, boolean isGameLoadFinished, int mouseX, int mouseY, Window window, Matrix4f matrix, PoseStack matrices, GuiGraphics graphics) { + public void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo ci, float speedAppliedTickDelta, boolean isGameLoadFinished, int mouseX, int mouseY, Window window, Matrix4f matrix, Matrix4fStack matrices, GuiGraphics graphics) { if (ClientGuiEvent.RENDER_PRE.invoker().render(minecraft.screen, graphics, mouseX, mouseY, minecraft.getDeltaFrameTime()).isFalse()) { ci.cancel(); } @@ -60,7 +60,7 @@ public void renderScreenPre(float tickDelta, long startTime, boolean tick, Callb @Inject(method = "render(FJZ)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;renderWithTooltip(Lnet/minecraft/client/gui/GuiGraphics;IIF)V", shift = At.Shift.AFTER, ordinal = 0), locals = LocalCapture.CAPTURE_FAILEXCEPTION) - public void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo ci, float speedAppliedTickDelta, boolean isGameLoadFinished, int mouseX, int mouseY, Window window, Matrix4f matrix, PoseStack matrices, GuiGraphics graphics) { + public void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo ci, float speedAppliedTickDelta, boolean isGameLoadFinished, int mouseX, int mouseY, Window window, Matrix4f matrix, Matrix4fStack matrices, GuiGraphics graphics) { ClientGuiEvent.RENDER_POST.invoker().render(minecraft.screen, graphics, mouseX, mouseY, minecraft.getDeltaFrameTime()); } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft.java index 7bbfaf718..52579df41 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMinecraft.java @@ -57,9 +57,9 @@ public abstract class MixinMinecraft { @Unique private ThreadLocal setScreenCancelled = new ThreadLocal<>(); - @Inject(method = "disconnect(Lnet/minecraft/client/gui/screens/Screen;)V", + @Inject(method = "disconnect(Lnet/minecraft/client/gui/screens/Screen;Z)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/GameNarrator;clear()V")) - private void handleLogin(Screen screen, CallbackInfo ci) { + private void handleLogin(Screen screen, boolean retainDownloadedPacks, CallbackInfo ci) { ClientPlayerEvent.CLIENT_PLAYER_QUIT.invoker().quit(player); } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMouseHandler.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMouseHandler.java index f616e1756..c641d1cde 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMouseHandler.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinMouseHandler.java @@ -152,7 +152,7 @@ private static void onGuiMouseReleasedPost(boolean[] bls, Screen screen, double } @SuppressWarnings("UnresolvedMixinReference") - @Inject(method = {"method_1602", "lambda$onMove$11"}, at = @At("HEAD"), cancellable = true, remap = false) + @Inject(method = {"method_55795", "lambda$handleAccumulatedMovement$11"}, at = @At("HEAD"), cancellable = true, remap = false) private void onGuiMouseDraggedPre(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY, CallbackInfo ci) { if (ClientScreenInputEvent.MOUSE_DRAGGED_PRE.invoker().mouseDragged(Minecraft.getInstance(), screen, mouseX, mouseY, this.activeButton, deltaX, deltaY).isPresent()) { ci.cancel(); @@ -160,7 +160,7 @@ private void onGuiMouseDraggedPre(Screen screen, double mouseX, double mouseY, d } @SuppressWarnings({"UnresolvedMixinReference", "DefaultAnnotationParam"}) - @Redirect(method = {"method_1602", "lambda$onMove$11"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;mouseDragged(DDIDD)Z", remap = true), remap = false) + @Redirect(method = {"method_55795", "lambda$handleAccumulatedMovement$11"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;mouseDragged(DDIDD)Z", remap = true), remap = false) private boolean onGuiMouseDraggedPost(Screen screen, double mouseX, double mouseY, int button, double deltaX, double deltaY) { if (screen.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)) { return true; diff --git a/fabric/src/main/java/dev/architectury/networking/fabric/BufCustomPacketPayload.java b/fabric/src/main/java/dev/architectury/networking/fabric/BufCustomPacketPayload.java new file mode 100644 index 000000000..22349ec35 --- /dev/null +++ b/fabric/src/main/java/dev/architectury/networking/fabric/BufCustomPacketPayload.java @@ -0,0 +1,50 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021, 2022 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package dev.architectury.networking.fabric; + +import io.netty.buffer.ByteBuf; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; + +/** + * Wraps a {@link FriendlyByteBuf}. + */ +public record BufCustomPacketPayload(Type _type, + byte[] payload) implements CustomPacketPayload { + public BufCustomPacketPayload(Type _type, RegistryFriendlyByteBuf payload) { + this(_type, payload.readByteArray()); + } + + @Override + public Type type() { + return this._type(); + } + + public void write(RegistryFriendlyByteBuf buf) { + buf.writeByteArray(payload); + } + + public static StreamCodec streamCodec(Type type) { + return ByteBufCodecs.BYTE_ARRAY.map(bytes -> new BufCustomPacketPayload(type, bytes), BufCustomPacketPayload::payload); + } +} diff --git a/fabric/src/main/java/dev/architectury/networking/fabric/NetworkManagerImpl.java b/fabric/src/main/java/dev/architectury/networking/fabric/NetworkManagerImpl.java index 2401a39cb..023b2a950 100644 --- a/fabric/src/main/java/dev/architectury/networking/fabric/NetworkManagerImpl.java +++ b/fabric/src/main/java/dev/architectury/networking/fabric/NetworkManagerImpl.java @@ -26,15 +26,16 @@ import dev.architectury.networking.transformers.PacketSink; import dev.architectury.networking.transformers.PacketTransformer; import dev.architectury.utils.Env; +import io.netty.buffer.ByteBufUtil; +import io.netty.buffer.Unpooled; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; -import net.fabricmc.fabric.api.networking.v1.PacketSender; +import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; @@ -49,6 +50,8 @@ import java.util.Objects; public class NetworkManagerImpl { + private static final Map> C2S_TYPE = new HashMap<>(); + private static final Map> S2C_TYPE = new HashMap<>(); private static final Map C2S_RECEIVER = new HashMap<>(); private static final Map S2C_RECEIVER = new HashMap<>(); private static final Map C2S_TRANSFORMERS = new HashMap<>(); @@ -70,9 +73,13 @@ public static void registerReceiver(NetworkManager.Side side, ResourceLocation i private static void registerC2SReceiver(ResourceLocation id, List packetTransformers, NetworkReceiver receiver) { LOGGER.info("Registering C2S receiver with id {}", id); C2S_RECEIVER.put(id, receiver); + CustomPacketPayload.Type type = new CustomPacketPayload.Type<>(id); + C2S_TYPE.put(id, type); + PayloadTypeRegistry.playC2S().register(type, BufCustomPacketPayload.streamCodec(type)); PacketTransformer transformer = PacketTransformer.concat(packetTransformers); - ServerPlayNetworking.registerGlobalReceiver(id, (server, player, handler, buf, sender) -> { - var context = context(player, server, false); + ServerPlayNetworking.registerGlobalReceiver(type, (payload, fabricContext) -> { + var context = context(fabricContext.player(), fabricContext.player().server, false); + FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.wrappedBuffer(payload.payload())); transformer.inbound(NetworkManager.Side.C2S, id, buf, context, (side, id1, buf1) -> { NetworkReceiver networkReceiver = side == NetworkManager.Side.C2S ? C2S_RECEIVER.get(id1) : S2C_RECEIVER.get(id1); if (networkReceiver == null) { @@ -80,6 +87,7 @@ private static void registerC2SReceiver(ResourceLocation id, List packetTransformers, NetworkReceiver receiver) { LOGGER.info("Registering S2C receiver with id {}", id); S2C_RECEIVER.put(id, receiver); + CustomPacketPayload.Type type = new CustomPacketPayload.Type<>(id); + S2C_TYPE.put(id, type); + PayloadTypeRegistry.playS2C().register(type, BufCustomPacketPayload.streamCodec(type)); PacketTransformer transformer = PacketTransformer.concat(packetTransformers); - ClientPlayNetworking.registerGlobalReceiver(id, new ClientPlayNetworking.PlayChannelHandler() { + ClientPlayNetworking.registerGlobalReceiver(type, new ClientPlayNetworking.PlayPayloadHandler<>() { @Override - public void receive(Minecraft client, ClientPacketListener handler, FriendlyByteBuf buf, PacketSender sender) { - var context = context(client.player, client, true); + public void receive(BufCustomPacketPayload payload, ClientPlayNetworking.Context fabricContext) { + var context = context(fabricContext.player(), fabricContext.client(), true); + FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.wrappedBuffer(payload.payload())); transformer.inbound(NetworkManager.Side.S2C, id, buf, context, (side, id1, buf1) -> { NetworkReceiver networkReceiver = side == NetworkManager.Side.C2S ? C2S_RECEIVER.get(id1) : S2C_RECEIVER.get(id1); if (networkReceiver == null) { @@ -101,6 +113,7 @@ public void receive(Minecraft client, ClientPacketListener handler, FriendlyByte } networkReceiver.receive(buf1, context); }); + buf.release(); } }); S2C_TRANSFORMERS.put(id, transformer); @@ -161,10 +174,18 @@ public static Packet createAddEntityPacket(Entity enti @Environment(EnvType.CLIENT) private static Packet toC2SPacket(ResourceLocation id, FriendlyByteBuf buf) { - return ClientPlayNetworking.createC2SPacket(id, buf); + CustomPacketPayload.Type type = C2S_TYPE.get(id); + if (type == null) { + throw new IllegalArgumentException("Unknown packet id: " + id); + } + return ClientPlayNetworking.createC2SPacket(new BufCustomPacketPayload(type, ByteBufUtil.getBytes(buf))); } private static Packet toS2CPacket(ResourceLocation id, FriendlyByteBuf buf) { - return ServerPlayNetworking.createS2CPacket(id, buf); + CustomPacketPayload.Type type = S2C_TYPE.get(id); + if (type == null) { + throw new IllegalArgumentException("Unknown packet id: " + id); + } + return ServerPlayNetworking.createS2CPacket(new BufCustomPacketPayload(type, ByteBufUtil.getBytes(buf))); } } diff --git a/fabric/src/main/java/dev/architectury/registry/level/entity/fabric/SpawnPlacementsRegistryImpl.java b/fabric/src/main/java/dev/architectury/registry/level/entity/fabric/SpawnPlacementsRegistryImpl.java index 962efd22c..22707dab8 100644 --- a/fabric/src/main/java/dev/architectury/registry/level/entity/fabric/SpawnPlacementsRegistryImpl.java +++ b/fabric/src/main/java/dev/architectury/registry/level/entity/fabric/SpawnPlacementsRegistryImpl.java @@ -21,13 +21,14 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.SpawnPlacementType; import net.minecraft.world.entity.SpawnPlacements; import net.minecraft.world.level.levelgen.Heightmap; import java.util.function.Supplier; public class SpawnPlacementsRegistryImpl { - public static void register(Supplier> type, SpawnPlacements.Type spawnPlacement, Heightmap.Types heightmapType, SpawnPlacements.SpawnPredicate spawnPredicate) { + public static void register(Supplier> type, SpawnPlacementType spawnPlacement, Heightmap.Types heightmapType, SpawnPlacements.SpawnPredicate spawnPredicate) { SpawnPlacements.register(type.get(), spawnPlacement, heightmapType, spawnPredicate); } } diff --git a/fabric/src/main/java/dev/architectury/registry/menu/fabric/MenuRegistryImpl.java b/fabric/src/main/java/dev/architectury/registry/menu/fabric/MenuRegistryImpl.java index 3bf8b15f7..c012b53be 100644 --- a/fabric/src/main/java/dev/architectury/registry/menu/fabric/MenuRegistryImpl.java +++ b/fabric/src/main/java/dev/architectury/registry/menu/fabric/MenuRegistryImpl.java @@ -23,8 +23,11 @@ import dev.architectury.registry.menu.MenuRegistry.ExtendedMenuTypeFactory; import dev.architectury.registry.menu.MenuRegistry.ScreenFactory; import dev.architectury.registry.menu.MenuRegistry.SimpleMenuTypeFactory; +import io.netty.buffer.ByteBufUtil; +import io.netty.buffer.Unpooled; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory; import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType; import net.minecraft.client.gui.screens.MenuScreens; @@ -32,6 +35,7 @@ import net.minecraft.client.gui.screens.inventory.MenuAccess; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; +import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; @@ -40,12 +44,18 @@ import net.minecraft.world.inventory.MenuType; import org.jetbrains.annotations.Nullable; +import java.util.function.Function; + public class MenuRegistryImpl { public static void openExtendedMenu(ServerPlayer player, ExtendedMenuProvider provider) { - player.openMenu(new ExtendedScreenHandlerFactory() { + player.openMenu(new ExtendedScreenHandlerFactory() { @Override - public void writeScreenOpeningData(ServerPlayer player, FriendlyByteBuf buf) { + public byte[] getScreenOpeningData(ServerPlayer player) { + FriendlyByteBuf buf = PacketByteBufs.create(); provider.saveExtraData(buf); + byte[] bytes = ByteBufUtil.getBytes(buf); + buf.release(); + return bytes; } @Override @@ -66,7 +76,12 @@ public static MenuType of(SimpleMenuTypeFac } public static MenuType ofExtended(ExtendedMenuTypeFactory factory) { - return new ExtendedScreenHandlerType<>(factory::create); + return new ExtendedScreenHandlerType<>((syncId, inventory, data) -> { + FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.wrappedBuffer(data)); + T menu = factory.create(syncId, inventory, buf); + buf.release(); + return menu; + }, ByteBufCodecs.BYTE_ARRAY.mapStream(Function.identity())); } @Environment(EnvType.CLIENT) diff --git a/gradle.properties b/gradle.properties index 5372496e4..b257c5add 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,20 +1,20 @@ org.gradle.jvmargs=-Xmx6G org.gradle.daemon=false -platforms=fabric,forge,neoforge +platforms=fabric -minecraft_version=1.20.4 -supported_version=1.20.4 +minecraft_version=24w09a +supported_version=1.20.5 (24w09a) -artifact_type=release +artifact_type=beta archives_base_name=architectury archives_base_name_snapshot=architectury-snapshot -base_version=11.1 +base_version=12.0 maven_group=dev.architectury -fabric_loader_version=0.15.3 -fabric_api_version=0.92.0+1.20.4 +fabric_loader_version=0.15.7 +fabric_api_version=0.96.5+1.20.5 mod_menu_version=9.0.0 forge_version=49.0.14 diff --git a/settings.gradle b/settings.gradle index e11ead5d2..7f514a9ea 100644 --- a/settings.gradle +++ b/settings.gradle @@ -13,12 +13,12 @@ if (JavaVersion.current().ordinal() + 1 < 17) { include("common") include("fabric") -include("forge") -include("minecraftforge") -include("neoforge") +//include("forge") +//include("minecraftforge") +//include("neoforge") include("testmod-common") include("testmod-fabric") -include("testmod-forge") -include("testmod-neoforge") +//include("testmod-forge") +//include("testmod-neoforge") rootProject.name = "architectury" diff --git a/testmod-common/src/main/java/dev/architectury/test/recipes/TestRecipeSerializer.java b/testmod-common/src/main/java/dev/architectury/test/recipes/TestRecipeSerializer.java index c55626eab..ffbf20722 100644 --- a/testmod-common/src/main/java/dev/architectury/test/recipes/TestRecipeSerializer.java +++ b/testmod-common/src/main/java/dev/architectury/test/recipes/TestRecipeSerializer.java @@ -22,6 +22,8 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.crafting.*; public class TestRecipeSerializer implements RecipeSerializer { @@ -31,6 +33,7 @@ public class TestRecipeSerializer implements RecipeSerializer { .forGetter(CraftingRecipe::category) ).apply(instance, FireworkRocketRecipe::new) ); + private static final StreamCodec STREAM_CODEC = StreamCodec.of(TestRecipeSerializer::toNetwork, TestRecipeSerializer::fromNetwork); @Override public Codec codec() { @@ -38,13 +41,16 @@ public Codec codec() { } @Override - public CustomRecipe fromNetwork(FriendlyByteBuf buf) { + public StreamCodec streamCodec() { + return STREAM_CODEC; + } + + public static CustomRecipe fromNetwork(FriendlyByteBuf buf) { CraftingBookCategory category = buf.readEnum(CraftingBookCategory.class); return new FireworkRocketRecipe(category); } - @Override - public void toNetwork(FriendlyByteBuf buf, CustomRecipe recipe) { + public static void toNetwork(FriendlyByteBuf buf, CustomRecipe recipe) { buf.writeEnum(recipe.category()); } } diff --git a/testmod-common/src/main/java/dev/architectury/test/registry/TestRegistries.java b/testmod-common/src/main/java/dev/architectury/test/registry/TestRegistries.java index bd72bc849..a4bd6620f 100644 --- a/testmod-common/src/main/java/dev/architectury/test/registry/TestRegistries.java +++ b/testmod-common/src/main/java/dev/architectury/test/registry/TestRegistries.java @@ -114,7 +114,7 @@ public TestInt(int value) { new EquippableTickingItem(new Item.Properties().arch$tab(TestRegistries.TEST_TAB))); public static final RegistrySupplier TEST_EDIBLE = ITEMS.register("test_edible", () -> { FoodProperties.Builder fpBuilder = new FoodProperties.Builder().nutrition(8).saturationMod(0.8F).meat(); - FoodPropertiesHooks.effect(fpBuilder, () -> new MobEffectInstance(TEST_EFFECT.get(), 100), 1); + FoodPropertiesHooks.effect(fpBuilder, () -> new MobEffectInstance(TEST_EFFECT, 100), 1); return new Item(new Item.Properties().food(fpBuilder.build()).arch$tab(TestRegistries.TEST_TAB)); }); public static final RegistrySupplier TEST_SPAWN_EGG = ITEMS.register("test_spawn_egg", () -> diff --git a/testmod-common/src/main/java/dev/architectury/test/trade/TestTrades.java b/testmod-common/src/main/java/dev/architectury/test/trade/TestTrades.java index f20330c2f..337132f79 100644 --- a/testmod-common/src/main/java/dev/architectury/test/trade/TestTrades.java +++ b/testmod-common/src/main/java/dev/architectury/test/trade/TestTrades.java @@ -23,8 +23,10 @@ import dev.architectury.registry.level.entity.trade.TradeRegistry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.entity.npc.VillagerTrades; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.item.trading.ItemCost; + +import java.util.Optional; public class TestTrades { public static void init() { @@ -35,7 +37,7 @@ public static void init() { } private static VillagerTrades.ItemListing[] createTrades() { - var trade = new SimpleTrade(Items.APPLE.getDefaultInstance(), ItemStack.EMPTY, Items.ACACIA_BOAT.getDefaultInstance(), 1, 0, 1.0F); + var trade = new SimpleTrade(new ItemCost(Items.APPLE), Optional.empty(), Items.ACACIA_BOAT.getDefaultInstance(), 1, 0, 1.0F); return new VillagerTrades.ItemListing[]{trade}; } } diff --git a/testmod-common/src/main/resources/architectury.common.json b/testmod-common/src/main/resources/architectury.common.json index c3f28aa68..e1535b2d0 100644 --- a/testmod-common/src/main/resources/architectury.common.json +++ b/testmod-common/src/main/resources/architectury.common.json @@ -18,9 +18,6 @@ "net/minecraft/class_1755": [ "dev/architectury/extensions/injected/InjectedBucketItemExtension" ], - "net/minecraft/class_5712": [ - "dev/architectury/extensions/injected/InjectedGameEventExtension" - ], "net/minecraft/class_4174$class_4175": [ "dev/architectury/extensions/injected/InjectedFoodPropertiesBuilderExtension" ],