diff --git a/build.gradle b/build.gradle index ee58b43b..0d4afc14 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.6-SNAPSHOT" apply false + id "dev.architectury.loom" version "1.7-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/fluid/ArchitecturyFlowingFluid.java b/common/src/main/java/dev/architectury/core/fluid/ArchitecturyFlowingFluid.java index 040e89c9..a1aa9bb4 100644 --- a/common/src/main/java/dev/architectury/core/fluid/ArchitecturyFlowingFluid.java +++ b/common/src/main/java/dev/architectury/core/fluid/ArchitecturyFlowingFluid.java @@ -23,11 +23,11 @@ import dev.architectury.injectables.annotations.ExpectPlatform; import dev.architectury.platform.Platform; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Block; @@ -78,7 +78,7 @@ public abstract class ArchitecturyFlowingFluid extends FlowingFluid { } @Override - protected boolean canConvertToSource(Level level) { + protected boolean canConvertToSource(ServerLevel level) { return attributes.canConvertToSource(); } 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 7df05cf6..d3b137f8 100644 --- a/common/src/main/java/dev/architectury/core/item/ArchitecturySpawnEggItem.java +++ b/common/src/main/java/dev/architectury/core/item/ArchitecturySpawnEggItem.java @@ -24,9 +24,9 @@ import net.minecraft.core.Direction; import net.minecraft.core.dispenser.BlockSource; import net.minecraft.core.dispenser.DefaultDispenseItemBehavior; import net.minecraft.core.dispenser.DispenseItemBehavior; +import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SpawnEggItem; import net.minecraft.world.level.block.DispenserBlock; @@ -50,7 +50,7 @@ public class ArchitecturySpawnEggItem extends SpawnEggItem { EntityType entityType = ((SpawnEggItem) stack.getItem()).getType(stack); try { - entityType.spawn(source.level(), stack, null, source.pos().relative(direction), MobSpawnType.DISPENSER, direction != Direction.UP, false); + entityType.spawn(source.level(), stack, null, source.pos().relative(direction), EntitySpawnReason.DISPENSER, direction != Direction.UP, false); } catch (Exception var6) { LOGGER.error("Error while dispensing spawn egg from dispenser at {}", source.pos(), var6); return ItemStack.EMPTY; diff --git a/common/src/main/java/dev/architectury/event/CompoundEventResult.java b/common/src/main/java/dev/architectury/event/CompoundEventResult.java index 551b7d6f..10f41695 100644 --- a/common/src/main/java/dev/architectury/event/CompoundEventResult.java +++ b/common/src/main/java/dev/architectury/event/CompoundEventResult.java @@ -19,8 +19,6 @@ package dev.architectury.event; -import net.minecraft.world.InteractionResultHolder; - /** * A result from an event, determines if the event should continue to other listeners, * determines the outcome of the event, and provides extra result for the outcome. @@ -170,13 +168,4 @@ public class CompoundEventResult { public T object() { return object; } - - /** - * Returns the Minecraft-facing result, however ignores {@link #interruptsFurtherEvaluation()}. - * - * @return the Minecraft-facing result - */ - public InteractionResultHolder asMinecraft() { - return new InteractionResultHolder<>(result.asMinecraft(), object); - } } diff --git a/common/src/main/java/dev/architectury/event/EventFactory.java b/common/src/main/java/dev/architectury/event/EventFactory.java index 37270fa5..08fc5889 100644 --- a/common/src/main/java/dev/architectury/event/EventFactory.java +++ b/common/src/main/java/dev/architectury/event/EventFactory.java @@ -23,6 +23,7 @@ import com.google.common.reflect.AbstractInvocationHandler; import dev.architectury.annotations.ForgeEvent; import dev.architectury.annotations.ForgeEventCancellable; import dev.architectury.injectables.annotations.ExpectPlatform; +import net.minecraft.world.InteractionResult; import org.jetbrains.annotations.ApiStatus; import java.lang.invoke.MethodHandles; @@ -110,6 +111,28 @@ public final class EventFactory { })); } + @SafeVarargs + public static Event createInteractionResult(T... typeGetter) { + if (typeGetter.length != 0) throw new IllegalStateException("array must be empty!"); + return createInteractionResult((Class) typeGetter.getClass().getComponentType()); + } + + @SuppressWarnings("UnstableApiUsage") + public static Event createInteractionResult(Class clazz) { + return of(listeners -> (T) Proxy.newProxyInstance(EventFactory.class.getClassLoader(), new Class[]{clazz}, new AbstractInvocationHandler() { + @Override + protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable { + for (var listener : listeners) { + var result = (InteractionResult) Objects.requireNonNull(invokeMethod(listener, method, args)); + if (result != InteractionResult.PASS) { + return result; + } + } + return InteractionResult.PASS; + } + })); + } + @SafeVarargs public static Event> createConsumerLoop(T... typeGetter) { if (typeGetter.length != 0) throw new IllegalStateException("array must be empty!"); diff --git a/common/src/main/java/dev/architectury/event/events/client/ClientRecipeUpdateEvent.java b/common/src/main/java/dev/architectury/event/events/client/ClientRecipeUpdateEvent.java index 98e85847..bd75ba56 100644 --- a/common/src/main/java/dev/architectury/event/events/client/ClientRecipeUpdateEvent.java +++ b/common/src/main/java/dev/architectury/event/events/client/ClientRecipeUpdateEvent.java @@ -23,20 +23,47 @@ import dev.architectury.event.Event; import dev.architectury.event.EventFactory; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.world.item.crafting.RecipeManager; +import net.minecraft.network.protocol.game.ClientboundRecipeBookAddPacket; +import net.minecraft.world.item.crafting.RecipeAccess; +import net.minecraft.world.item.crafting.display.RecipeDisplayId; +import org.jetbrains.annotations.ApiStatus; + +import java.util.List; @Environment(EnvType.CLIENT) public interface ClientRecipeUpdateEvent { /** - * @see ClientRecipeUpdateEvent#update(RecipeManager) + * @see ClientRecipeUpdateEvent#update(RecipeAccess) */ Event EVENT = EventFactory.createLoop(); + /** + * @see ClientRecipeUpdateEvent.Add#add(RecipeAccess, List) + */ + @ApiStatus.Experimental + Event ADD = EventFactory.createLoop(); + + /** + * @see ClientRecipeUpdateEvent.Remove#remove(RecipeAccess, List) + */ + @ApiStatus.Experimental + Event REMOVE = EventFactory.createLoop(); + /** * Invoked when the client has received an updated list of recipes from the server. * Equivalent to Forge's {@code RecipesUpdatedEvent} event. * - * @param recipeManager The recipe manager. + * @param recipeAccess The recipe access. */ - void update(RecipeManager recipeManager); + void update(RecipeAccess recipeAccess); + + @ApiStatus.Experimental + interface Add { + void add(RecipeAccess recipeAccess, List entries); + } + + @ApiStatus.Experimental + interface Remove { + void remove(RecipeAccess recipeAccess, List ids); + } } diff --git a/common/src/main/java/dev/architectury/event/events/client/ClientReloadShadersEvent.java b/common/src/main/java/dev/architectury/event/events/client/ClientReloadShadersEvent.java deleted file mode 100644 index ac12bddb..00000000 --- a/common/src/main/java/dev/architectury/event/events/client/ClientReloadShadersEvent.java +++ /dev/null @@ -1,47 +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.event.events.client; - -import dev.architectury.event.Event; -import dev.architectury.event.EventFactory; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.renderer.ShaderInstance; -import net.minecraft.server.packs.resources.ResourceProvider; - -import java.util.function.Consumer; - -@Environment(EnvType.CLIENT) -@FunctionalInterface -public interface ClientReloadShadersEvent { - /** - * Invoked when client reloads shaders. - * - * @see net.minecraft.client.renderer.GameRenderer#reloadShaders(ResourceProvider) - */ - Event EVENT = EventFactory.createLoop(); - - void reload(ResourceProvider provider, ShadersSink sink); - - @FunctionalInterface - interface ShadersSink { - void registerShader(ShaderInstance shader, Consumer callback); - } -} diff --git a/common/src/main/java/dev/architectury/event/events/client/ClientTooltipEvent.java b/common/src/main/java/dev/architectury/event/events/client/ClientTooltipEvent.java index 64dd037d..ccb90674 100644 --- a/common/src/main/java/dev/architectury/event/events/client/ClientTooltipEvent.java +++ b/common/src/main/java/dev/architectury/event/events/client/ClientTooltipEvent.java @@ -49,10 +49,6 @@ public interface ClientTooltipEvent { * @see RenderModifyPosition#renderTooltip(GuiGraphics, PositionContext) */ Event RENDER_MODIFY_POSITION = EventFactory.createLoop(); - /** - * @see RenderModifyColor#renderTooltip(GuiGraphics, int, int, ColorContext) - */ - Event RENDER_MODIFY_COLOR = EventFactory.createLoop(); static AdditionalContexts additionalContexts() { return TooltipAdditionalContextsImpl.get(); @@ -107,19 +103,6 @@ public interface ClientTooltipEvent { void renderTooltip(GuiGraphics graphics, PositionContext context); } - @Environment(EnvType.CLIENT) - interface RenderModifyColor { - /** - * Event to manipulate the color of the tooltip. - * - * @param graphics The graphics context. - * @param x The x-coordinate of the tooltip. - * @param y The y-coordinate of the tooltip. - * @param context The current color context. - */ - void renderTooltip(GuiGraphics graphics, int x, int y, ColorContext context); - } - @Environment(EnvType.CLIENT) interface PositionContext { int getTooltipX(); @@ -130,19 +113,4 @@ public interface ClientTooltipEvent { void setTooltipY(int y); } - - @Environment(EnvType.CLIENT) - interface ColorContext { - int getBackgroundColor(); - - void setBackgroundColor(int color); - - int getOutlineGradientTopColor(); - - void setOutlineGradientTopColor(int color); - - int getOutlineGradientBottomColor(); - - void setOutlineGradientBottomColor(int color); - } } diff --git a/common/src/main/java/dev/architectury/event/events/common/ChunkEvent.java b/common/src/main/java/dev/architectury/event/events/common/ChunkEvent.java index 5ce8dc76..e855038f 100644 --- a/common/src/main/java/dev/architectury/event/events/common/ChunkEvent.java +++ b/common/src/main/java/dev/architectury/event/events/common/ChunkEvent.java @@ -28,11 +28,11 @@ import org.jetbrains.annotations.Nullable; public interface ChunkEvent { /** - * @see SaveData#save(ChunkAccess, ServerLevel, CompoundTag) + * @see SaveData#save(ChunkAccess, ServerLevel) */ Event SAVE_DATA = EventFactory.createLoop(); /** - * @see LoadData#load(ChunkAccess, ServerLevel, CompoundTag) + * @see LoadData#load(ChunkAccess, ServerLevel) */ Event LOAD_DATA = EventFactory.createLoop(); @@ -44,9 +44,8 @@ public interface ChunkEvent { * * @param chunk The chunk that is saved. * @param level The level the chunk is in. - * @param nbt The chunk data that is written to the save file. */ - void save(ChunkAccess chunk, ServerLevel level, CompoundTag nbt); + void save(ChunkAccess chunk, ServerLevel level); } interface LoadData { @@ -57,8 +56,7 @@ public interface ChunkEvent { * * @param chunk The chunk that is loaded. * @param level The level the chunk is in, may be {@code null}. - * @param nbt The chunk data that was read from the save file. */ - void load(ChunkAccess chunk, @Nullable ServerLevel level, CompoundTag nbt); + void load(ChunkAccess chunk, @Nullable ServerLevel level); } } diff --git a/common/src/main/java/dev/architectury/event/events/common/EntityEvent.java b/common/src/main/java/dev/architectury/event/events/common/EntityEvent.java index 69e492e5..84718d4a 100644 --- a/common/src/main/java/dev/architectury/event/events/common/EntityEvent.java +++ b/common/src/main/java/dev/architectury/event/events/common/EntityEvent.java @@ -22,11 +22,10 @@ package dev.architectury.event.events.common; import dev.architectury.event.Event; import dev.architectury.event.EventFactory; import dev.architectury.event.EventResult; -import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.BaseSpawner; @@ -44,7 +43,7 @@ public interface EntityEvent { */ Event LIVING_HURT = EventFactory.createEventResult(); /** - * @see LivingCheckSpawn#canSpawn(LivingEntity, LevelAccessor, double, double, double, MobSpawnType, BaseSpawner) + * @see LivingCheckSpawn#canSpawn(LivingEntity, LevelAccessor, double, double, double, EntitySpawnReason, BaseSpawner) */ Event LIVING_CHECK_SPAWN = EventFactory.createEventResult(); /** @@ -102,10 +101,10 @@ public interface EntityEvent { * @param z The z-coordinate the spawn position. * @param type The source of spawning. * @param spawner The spawner. Can be {@code null}. - * @return A {@link InteractionResultHolder} determining the outcome of the event, + * @return A {@link EventResult} determining the outcome of the event, * if an outcome is set, the vanilla result is overridden. */ - EventResult canSpawn(LivingEntity entity, LevelAccessor world, double x, double y, double z, MobSpawnType type, @Nullable BaseSpawner spawner); + EventResult canSpawn(LivingEntity entity, LevelAccessor world, double x, double y, double z, EntitySpawnReason type, @Nullable BaseSpawner spawner); } interface Add { diff --git a/common/src/main/java/dev/architectury/event/events/common/InteractionEvent.java b/common/src/main/java/dev/architectury/event/events/common/InteractionEvent.java index f315d709..44ca2461 100644 --- a/common/src/main/java/dev/architectury/event/events/common/InteractionEvent.java +++ b/common/src/main/java/dev/architectury/event/events/common/InteractionEvent.java @@ -19,16 +19,15 @@ package dev.architectury.event.events.common; -import dev.architectury.event.CompoundEventResult; import dev.architectury.event.Event; import dev.architectury.event.EventFactory; import dev.architectury.event.EventResult; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; @@ -36,15 +35,15 @@ public interface InteractionEvent { /** * @see LeftClickBlock#click(Player, InteractionHand, BlockPos, Direction) */ - Event LEFT_CLICK_BLOCK = EventFactory.createEventResult(); + Event LEFT_CLICK_BLOCK = EventFactory.createInteractionResult(); /** * @see RightClickBlock#click(Player, InteractionHand, BlockPos, Direction) */ - Event RIGHT_CLICK_BLOCK = EventFactory.createEventResult(); + Event RIGHT_CLICK_BLOCK = EventFactory.createInteractionResult(); /** * @see RightClickItem#click(Player, InteractionHand) */ - Event RIGHT_CLICK_ITEM = EventFactory.createCompoundEventResult(); + Event RIGHT_CLICK_ITEM = EventFactory.createInteractionResult(); /** * @see ClientLeftClickAir#click(Player, InteractionHand) */ @@ -60,7 +59,7 @@ public interface InteractionEvent { /** * @see FarmlandTrample#trample(Level, BlockPos, BlockState, float, Entity) */ - Event FARMLAND_TRAMPLE = EventFactory.createEventResult(); + Event FARMLAND_TRAMPLE = EventFactory.createInteractionResult(); interface RightClickBlock { /** @@ -71,10 +70,10 @@ public interface InteractionEvent { * @param hand The hand that is used. * @param pos The position of the block in the level. * @param face The face of the block clicked. - * @return A {@link EventResult} determining the outcome of the event, + * @return A {@link InteractionResult} determining the outcome of the event, * the action may be cancelled by the result. */ - EventResult click(Player player, InteractionHand hand, BlockPos pos, Direction face); + InteractionResult click(Player player, InteractionHand hand, BlockPos pos, Direction face); } interface LeftClickBlock { @@ -86,10 +85,10 @@ public interface InteractionEvent { * @param hand The hand that is used. * @param pos The position of the block in the level. Use {@link Player#getCommandSenderWorld()} to get the level. * @param face The face of the block clicked. - * @return A {@link EventResult} determining the outcome of the event, + * @return A {@link InteractionResult} determining the outcome of the event, * the action may be cancelled by the result. */ - EventResult click(Player player, InteractionHand hand, BlockPos pos, Direction face); + InteractionResult click(Player player, InteractionHand hand, BlockPos pos, Direction face); } interface RightClickItem { @@ -99,10 +98,10 @@ public interface InteractionEvent { * * @param player The player right clicking the block. * @param hand The hand that is used. - * @return A {@link EventResult} determining the outcome of the event, + * @return A {@link InteractionResult} determining the outcome of the event, * the action may be cancelled by the result. */ - CompoundEventResult click(Player player, InteractionHand hand); + InteractionResult click(Player player, InteractionHand hand); } interface ClientRightClickAir { @@ -153,9 +152,9 @@ public interface InteractionEvent { * @param state The state of the block. * @param distance The distance of the player to the block. * @param entity The entity trampling. - * @return A {@link EventResult} determining the outcome of the event, + * @return A {@link InteractionResult} determining the outcome of the event, * the action may be cancelled by the result. */ - EventResult trample(Level world, BlockPos pos, BlockState state, float distance, Entity entity); + InteractionResult trample(Level world, BlockPos pos, BlockState state, float distance, Entity entity); } } diff --git a/common/src/main/java/dev/architectury/event/events/common/PlayerEvent.java b/common/src/main/java/dev/architectury/event/events/common/PlayerEvent.java index 0734d188..c0f8a8b2 100644 --- a/common/src/main/java/dev/architectury/event/events/common/PlayerEvent.java +++ b/common/src/main/java/dev/architectury/event/events/common/PlayerEvent.java @@ -19,7 +19,6 @@ package dev.architectury.event.events.common; -import dev.architectury.event.CompoundEventResult; import dev.architectury.event.Event; import dev.architectury.event.EventFactory; import dev.architectury.event.EventResult; @@ -28,6 +27,7 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.Container; import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; @@ -94,7 +94,7 @@ public interface PlayerEvent { /** * @see FillBucket#fill(Player, Level, ItemStack, HitResult) */ - Event FILL_BUCKET = EventFactory.createCompoundEventResult(); + Event FILL_BUCKET = EventFactory.createInteractionResult(); /** * @see AttackEntity#attack(Player, Level, Entity, InteractionHand, EntityHitResult) */ @@ -265,9 +265,9 @@ public interface PlayerEvent { * @param level The level the player is in. * @param stack The bucket stack. * @param target The target which the player has aimed at. - * @return A {@link CompoundEventResult} determining the outcome of the event. + * @return A {@link InteractionResult} determining the outcome of the event. */ - CompoundEventResult fill(Player player, Level level, ItemStack stack, @Nullable HitResult target); + InteractionResult fill(Player player, Level level, ItemStack stack, @Nullable HitResult target); } interface AttackEntity { diff --git a/common/src/main/java/dev/architectury/extensions/injected/InjectedFoodPropertiesBuilderExtension.java b/common/src/main/java/dev/architectury/extensions/injected/InjectedFoodPropertiesBuilderExtension.java deleted file mode 100644 index 9a2d6cd0..00000000 --- a/common/src/main/java/dev/architectury/extensions/injected/InjectedFoodPropertiesBuilderExtension.java +++ /dev/null @@ -1,33 +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 dev.architectury.hooks.item.food.FoodPropertiesHooks; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.food.FoodProperties; - -import java.util.function.Supplier; - -public interface InjectedFoodPropertiesBuilderExtension { - default FoodProperties.Builder arch$effect(Supplier effectSupplier, float chance) { - FoodPropertiesHooks.effect((FoodProperties.Builder) this, effectSupplier, chance); - return (FoodProperties.Builder) this; - } -} diff --git a/common/src/main/java/dev/architectury/hooks/item/food/FoodPropertiesHooks.java b/common/src/main/java/dev/architectury/hooks/item/food/FoodPropertiesHooks.java deleted file mode 100644 index 4fb36752..00000000 --- a/common/src/main/java/dev/architectury/hooks/item/food/FoodPropertiesHooks.java +++ /dev/null @@ -1,37 +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.hooks.item.food; - -import dev.architectury.injectables.annotations.ExpectPlatform; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.food.FoodProperties; - -import java.util.function.Supplier; - -public final class FoodPropertiesHooks { - private FoodPropertiesHooks() { - } - - @ExpectPlatform - public static void effect(FoodProperties.Builder builder, - Supplier effectSupplier, float chance) { - throw new AssertionError(); - } -} diff --git a/common/src/main/java/dev/architectury/hooks/level/ExplosionHooks.java b/common/src/main/java/dev/architectury/hooks/level/ExplosionHooks.java deleted file mode 100644 index 7eeee2ba..00000000 --- a/common/src/main/java/dev/architectury/hooks/level/ExplosionHooks.java +++ /dev/null @@ -1,41 +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.hooks.level; - -import net.minecraft.world.level.Explosion; -import net.minecraft.world.phys.Vec3; - -/** - * @deprecated no longer needed. - */ -@Deprecated(forRemoval = true) -public final class ExplosionHooks { - private ExplosionHooks() { - } - - /** - * @deprecated no longer needed. - * @see Explosion#center() - */ - @Deprecated(forRemoval = true) - public static Vec3 getPosition(Explosion explosion) { - return explosion.center(); - } -} diff --git a/common/src/main/java/dev/architectury/hooks/level/biome/BiomeHooks.java b/common/src/main/java/dev/architectury/hooks/level/biome/BiomeHooks.java index 70679638..952e0457 100644 --- a/common/src/main/java/dev/architectury/hooks/level/biome/BiomeHooks.java +++ b/common/src/main/java/dev/architectury/hooks/level/biome/BiomeHooks.java @@ -349,8 +349,8 @@ public final class BiomeHooks { } @Override - public Iterable>> getCarvers(GenerationStep.Carving carving) { - return settings.getCarvers(carving); + public Iterable>> getCarvers() { + return settings.getCarvers(); } @Override diff --git a/common/src/main/java/dev/architectury/hooks/level/biome/GenerationProperties.java b/common/src/main/java/dev/architectury/hooks/level/biome/GenerationProperties.java index 0a4836b2..e6873474 100644 --- a/common/src/main/java/dev/architectury/hooks/level/biome/GenerationProperties.java +++ b/common/src/main/java/dev/architectury/hooks/level/biome/GenerationProperties.java @@ -29,7 +29,7 @@ import org.jetbrains.annotations.ApiStatus; import java.util.List; public interface GenerationProperties { - Iterable>> getCarvers(GenerationStep.Carving carving); + Iterable>> getCarvers(); Iterable> getFeatures(GenerationStep.Decoration decoration); @@ -41,13 +41,13 @@ public interface GenerationProperties { @ApiStatus.Experimental Mutable addFeature(GenerationStep.Decoration decoration, ResourceKey feature); - Mutable addCarver(GenerationStep.Carving carving, Holder> feature); + Mutable addCarver(Holder> feature); @ApiStatus.Experimental - Mutable addCarver(GenerationStep.Carving carving, ResourceKey> feature); + Mutable addCarver(ResourceKey> feature); Mutable removeFeature(GenerationStep.Decoration decoration, ResourceKey feature); - Mutable removeCarver(GenerationStep.Carving carving, ResourceKey> feature); + Mutable removeCarver(ResourceKey> feature); } } diff --git a/common/src/main/java/dev/architectury/impl/TooltipEventColorContextImpl.java b/common/src/main/java/dev/architectury/impl/TooltipEventColorContextImpl.java deleted file mode 100644 index 7de4c76f..00000000 --- a/common/src/main/java/dev/architectury/impl/TooltipEventColorContextImpl.java +++ /dev/null @@ -1,69 +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.impl; - -import dev.architectury.event.events.client.ClientTooltipEvent; -import org.jetbrains.annotations.ApiStatus; - -@ApiStatus.Internal -public class TooltipEventColorContextImpl implements ClientTooltipEvent.ColorContext { - public static final ThreadLocal CONTEXT = ThreadLocal.withInitial(TooltipEventColorContextImpl::new); - private int backgroundColor; - private int outlineGradientTopColor; - private int outlineGradientBottomColor; - - public TooltipEventColorContextImpl reset() { - this.backgroundColor = 0xf0100010; - this.outlineGradientTopColor = 0x505000ff; - this.outlineGradientBottomColor = 0x5028007f; - - return this; - } - - @Override - public int getBackgroundColor() { - return backgroundColor; - } - - @Override - public void setBackgroundColor(int color) { - this.backgroundColor = color; - } - - @Override - public int getOutlineGradientTopColor() { - return outlineGradientTopColor; - } - - @Override - public void setOutlineGradientTopColor(int color) { - this.outlineGradientTopColor = color; - } - - @Override - public int getOutlineGradientBottomColor() { - return outlineGradientBottomColor; - } - - @Override - public void setOutlineGradientBottomColor(int color) { - this.outlineGradientBottomColor = color; - } -} diff --git a/common/src/main/java/dev/architectury/mixin/inject/MixinFoodPropertiesBuilder.java b/common/src/main/java/dev/architectury/mixin/inject/MixinFoodPropertiesBuilder.java deleted file mode 100644 index 13dad400..00000000 --- a/common/src/main/java/dev/architectury/mixin/inject/MixinFoodPropertiesBuilder.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.InjectedFoodPropertiesBuilderExtension; -import net.minecraft.world.food.FoodProperties; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(FoodProperties.Builder.class) -public class MixinFoodPropertiesBuilder implements InjectedFoodPropertiesBuilderExtension { -} diff --git a/common/src/main/java/dev/architectury/networking/SpawnEntityPacket.java b/common/src/main/java/dev/architectury/networking/SpawnEntityPacket.java index f1c2b8f2..9492346e 100644 --- a/common/src/main/java/dev/architectury/networking/SpawnEntityPacket.java +++ b/common/src/main/java/dev/architectury/networking/SpawnEntityPacket.java @@ -37,6 +37,7 @@ import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerEntity; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.EntityType; import java.util.UUID; @@ -74,7 +75,7 @@ public class SpawnEntityPacket { if (Minecraft.getInstance().level == null) { throw new IllegalStateException("Client world is null!"); } - var entity = payload.entityType().create(Minecraft.getInstance().level); + var entity = payload.entityType().create(Minecraft.getInstance().level, EntitySpawnReason.LOAD); if (entity == null) { throw new IllegalStateException("Created entity is null!"); } diff --git a/common/src/main/java/dev/architectury/registry/fuel/FuelRegistry.java b/common/src/main/java/dev/architectury/registry/fuel/FuelRegistry.java index 11bdc70c..8da69a90 100644 --- a/common/src/main/java/dev/architectury/registry/fuel/FuelRegistry.java +++ b/common/src/main/java/dev/architectury/registry/fuel/FuelRegistry.java @@ -19,9 +19,7 @@ package dev.architectury.registry.fuel; -import dev.architectury.injectables.annotations.ExpectPlatform; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.ItemLike; public final class FuelRegistry { private FuelRegistry() { @@ -34,10 +32,10 @@ public final class FuelRegistry { * and {@code -1} to use vanilla logic * @param items the array of items to register for */ - @ExpectPlatform + /*@ExpectPlatform public static void register(int time, ItemLike... items) { throw new AssertionError(); - } + }*/ /** * Returns the burn time of an {@link ItemStack}. @@ -45,8 +43,8 @@ public final class FuelRegistry { * @param stack the stack * @return the burn time of the stack, returns {@code 0} if not a fuel */ - @ExpectPlatform + /*@ExpectPlatform public static int get(ItemStack stack) { throw new AssertionError(); - } + }*/ } diff --git a/common/src/main/java/dev/architectury/registry/registries/RegistrarManager.java b/common/src/main/java/dev/architectury/registry/registries/RegistrarManager.java index 4d869783..e7dbd4f7 100644 --- a/common/src/main/java/dev/architectury/registry/registries/RegistrarManager.java +++ b/common/src/main/java/dev/architectury/registry/registries/RegistrarManager.java @@ -84,7 +84,7 @@ public final class RegistrarManager { public static ResourceLocation getId(T object, @Nullable ResourceKey> fallback) { if (fallback == null) return null; - return getId(object, (Registry) BuiltInRegistries.REGISTRY.get(fallback.location())); + return getId(object, (Registry) BuiltInRegistries.REGISTRY.getValue(fallback.location())); } /** diff --git a/common/src/main/resources/architectury-common.mixins.json b/common/src/main/resources/architectury-common.mixins.json index e370e0aa..17a78c11 100644 --- a/common/src/main/resources/architectury-common.mixins.json +++ b/common/src/main/resources/architectury-common.mixins.json @@ -10,7 +10,6 @@ "inject.MixinBucketItem", "inject.MixinEntityType", "inject.MixinFluid", - "inject.MixinFoodPropertiesBuilder", "inject.MixinItem", "inject.MixinItemProperties", "inject.MixinLiquidBlock", diff --git a/common/src/main/resources/architectury.accessWidener b/common/src/main/resources/architectury.accessWidener index bd20e6a2..3a808866 100644 --- a/common/src/main/resources/architectury.accessWidener +++ b/common/src/main/resources/architectury.accessWidener @@ -113,10 +113,6 @@ accessible field net/minecraft/world/item/ShovelItem FLATTENABLES Ljava/util/Map mutable field net/minecraft/world/item/ShovelItem FLATTENABLES Ljava/util/Map; accessible field net/minecraft/world/item/HoeItem TILLABLES Ljava/util/Map; mutable field net/minecraft/world/item/HoeItem TILLABLES Ljava/util/Map; -transitive-accessible field net/minecraft/world/level/Explosion source Lnet/minecraft/world/entity/Entity; -transitive-mutable field net/minecraft/world/level/Explosion source Lnet/minecraft/world/entity/Entity; -transitive-accessible field net/minecraft/world/level/Explosion radius F -transitive-mutable field net/minecraft/world/level/Explosion radius F transitive-accessible method net/minecraft/world/entity/player/Player closeContainer ()V transitive-accessible method net/minecraft/client/renderer/RenderType create (Ljava/lang/String;Lcom/mojang/blaze3d/vertex/VertexFormat;Lcom/mojang/blaze3d/vertex/VertexFormat$Mode;ILnet/minecraft/client/renderer/RenderType$CompositeState;)Lnet/minecraft/client/renderer/RenderType$CompositeRenderType; transitive-accessible method net/minecraft/client/renderer/RenderType create (Ljava/lang/String;Lcom/mojang/blaze3d/vertex/VertexFormat;Lcom/mojang/blaze3d/vertex/VertexFormat$Mode;IZZLnet/minecraft/client/renderer/RenderType$CompositeState;)Lnet/minecraft/client/renderer/RenderType$CompositeRenderType; @@ -139,7 +135,7 @@ accessible field net/minecraft/client/multiplayer/MultiPlayerGameMode connection ############################## # Constructors of non-abstract item classes -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/DiggerItem (Lnet/minecraft/world/item/ToolMaterial;Lnet/minecraft/tags/TagKey;FFLnet/minecraft/world/item/Item$Properties;)V # Constructors of non-abstract block classes transitive-accessible method net/minecraft/world/level/block/AttachedStemBlock (Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V @@ -157,13 +153,14 @@ transitive-accessible method net/minecraft/world/level/block/CakeBlock (L transitive-accessible method net/minecraft/world/level/block/CandleCakeBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/CartographyTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/CarvedPumpkinBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V -transitive-accessible method net/minecraft/world/level/block/ChestBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;Ljava/util/function/Supplier;)V +transitive-accessible method net/minecraft/world/level/block/ChestBlock (Ljava/util/function/Supplier;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/ChorusFlowerBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/ChorusPlantBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/CoralFanBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/CoralPlantBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/CoralWallFanBlock (Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/CraftingTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V +transitive-accessible method net/minecraft/world/level/block/CreakingHeartBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/CropBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/DeadBushBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/DecoratedPotBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V @@ -175,7 +172,6 @@ transitive-accessible method net/minecraft/world/level/block/EndGatewayBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/EndRodBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/EnderChestBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V -transitive-accessible method net/minecraft/world/level/block/EquipableCarvedPumpkinBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/FarmBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/FletchingTableBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V transitive-accessible method net/minecraft/world/level/block/FungusBlock (Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/block/Block;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V @@ -248,12 +244,17 @@ transitive-accessible field net/minecraft/client/renderer/RenderStateShard LIGHT transitive-accessible field net/minecraft/client/renderer/RenderStateShard GLINT_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard CRUMBLING_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard TRANSLUCENT_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard; +transitive-accessible field net/minecraft/client/renderer/RenderStateShard VIGNETTE_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard; +transitive-accessible field net/minecraft/client/renderer/RenderStateShard CROSSHAIR_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard; +transitive-accessible field net/minecraft/client/renderer/RenderStateShard MOJANG_LOGO_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard; +transitive-accessible field net/minecraft/client/renderer/RenderStateShard NAUSEA_OVERLAY_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard NO_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_COLOR_LIGHTMAP_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_TEX_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_COLOR_TEX_LIGHTMAP_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_COLOR_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; +transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_TEXTURE_COLOR_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_SOLID_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_CUTOUT_MIPPED_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_CUTOUT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; @@ -265,7 +266,6 @@ transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDE transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_CUTOUT_NO_CULL_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_CUTOUT_NO_CULL_Z_OFFSET_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ITEM_ENTITY_TRANSLUCENT_CULL_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; -transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_TRANSLUCENT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_TRANSLUCENT_EMISSIVE_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_SMOOTH_CUTOUT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; @@ -283,7 +283,6 @@ transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDE transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_GLINT_TRANSLUCENT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_GLINT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_GLINT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; -transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_GLINT_DIRECT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_CRUMBLING_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_TEXT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_TEXT_BACKGROUND_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; @@ -324,6 +323,7 @@ transitive-accessible field net/minecraft/client/renderer/RenderStateShard DEPTH transitive-accessible field net/minecraft/client/renderer/RenderStateShard NO_LAYERING Lnet/minecraft/client/renderer/RenderStateShard$LayeringStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard POLYGON_OFFSET_LAYERING Lnet/minecraft/client/renderer/RenderStateShard$LayeringStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard VIEW_OFFSET_Z_LAYERING Lnet/minecraft/client/renderer/RenderStateShard$LayeringStateShard; +transitive-accessible field net/minecraft/client/renderer/RenderStateShard VIEW_OFFSET_Z_LAYERING_FORWARD Lnet/minecraft/client/renderer/RenderStateShard$LayeringStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard MAIN_TARGET Lnet/minecraft/client/renderer/RenderStateShard$OutputStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard OUTLINE_TARGET Lnet/minecraft/client/renderer/RenderStateShard$OutputStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard TRANSLUCENT_TARGET Lnet/minecraft/client/renderer/RenderStateShard$OutputStateShard; diff --git a/common/src/main/resources/architectury.common.json b/common/src/main/resources/architectury.common.json index 3df2138a..ec7579de 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_4174$class_4175": [ - "dev/architectury/extensions/injected/InjectedFoodPropertiesBuilderExtension" - ], "net/minecraft/class_2404": [ "dev/architectury/extensions/injected/InjectedLiquidBlockExtension" ] diff --git a/fabric/build.gradle b/fabric/build.gradle index 53d30461..15ceeb97 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 21", project.minecraft_version + gameVersions.addAll "Java 21", "1.21.2-Snapshot"//, project.minecraft_version } } diff --git a/fabric/src/main/java/dev/architectury/event/fabric/EventHandlerImpl.java b/fabric/src/main/java/dev/architectury/event/fabric/EventHandlerImpl.java index 6cd47e39..9e2aa699 100644 --- a/fabric/src/main/java/dev/architectury/event/fabric/EventHandlerImpl.java +++ b/fabric/src/main/java/dev/architectury/event/fabric/EventHandlerImpl.java @@ -78,9 +78,9 @@ public class EventHandlerImpl { CommandRegistrationCallback.EVENT.register((dispatcher, registry, selection) -> CommandRegistrationEvent.EVENT.invoker().register(dispatcher, registry, selection)); - UseItemCallback.EVENT.register((player, world, hand) -> InteractionEvent.RIGHT_CLICK_ITEM.invoker().click(player, hand).asMinecraft()); - UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> InteractionEvent.RIGHT_CLICK_BLOCK.invoker().click(player, hand, hitResult.getBlockPos(), hitResult.getDirection()).asMinecraft()); - AttackBlockCallback.EVENT.register((player, world, hand, pos, face) -> InteractionEvent.LEFT_CLICK_BLOCK.invoker().click(player, hand, pos, face).asMinecraft()); + UseItemCallback.EVENT.register((player, world, hand) -> InteractionEvent.RIGHT_CLICK_ITEM.invoker().click(player, hand)); + UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> InteractionEvent.RIGHT_CLICK_BLOCK.invoker().click(player, hand, hitResult.getBlockPos(), hitResult.getDirection())); + AttackBlockCallback.EVENT.register((player, world, hand, pos, face) -> InteractionEvent.LEFT_CLICK_BLOCK.invoker().click(player, hand, pos, face)); AttackEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> PlayerEvent.ATTACK_ENTITY.invoker().attack(player, world, entity, hand, hitResult).asMinecraft()); LootTableEvents.MODIFY.register((key, tableBuilder, source) -> LootEvent.MODIFY_LOOT_TABLE.invoker().modifyLootTable(key, new LootTableModificationContextImpl(tableBuilder), source.isBuiltin())); diff --git a/fabric/src/main/java/dev/architectury/hooks/item/fabric/ItemStackHooksImpl.java b/fabric/src/main/java/dev/architectury/hooks/item/fabric/ItemStackHooksImpl.java index ec578e02..5d8965f6 100644 --- a/fabric/src/main/java/dev/architectury/hooks/item/fabric/ItemStackHooksImpl.java +++ b/fabric/src/main/java/dev/architectury/hooks/item/fabric/ItemStackHooksImpl.java @@ -19,18 +19,15 @@ package dev.architectury.hooks.item.fabric; -import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; public class ItemStackHooksImpl { public static boolean hasCraftingRemainingItem(ItemStack stack) { - return stack.getItem().hasCraftingRemainingItem(); + return !getCraftingRemainingItem(stack).isEmpty(); } public static ItemStack getCraftingRemainingItem(ItemStack stack) { - if (!hasCraftingRemainingItem(stack)) return ItemStack.EMPTY; - Item item = stack.getItem().getCraftingRemainingItem(); - return item == null || item == Items.AIR ? ItemStack.EMPTY : item.getDefaultInstance(); + ItemStack remainder = stack.getItem().getRecipeRemainder(stack); + return remainder == null || remainder.isEmpty() ? ItemStack.EMPTY : remainder; } } diff --git a/fabric/src/main/java/dev/architectury/hooks/item/food/fabric/FoodPropertiesHooksImpl.java b/fabric/src/main/java/dev/architectury/hooks/item/food/fabric/FoodPropertiesHooksImpl.java deleted file mode 100644 index 09af1510..00000000 --- a/fabric/src/main/java/dev/architectury/hooks/item/food/fabric/FoodPropertiesHooksImpl.java +++ /dev/null @@ -1,33 +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.hooks.item.food.fabric; - -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.food.FoodProperties; - -import java.util.function.Supplier; - -public class FoodPropertiesHooksImpl { - public static void effect(FoodProperties.Builder builder, - Supplier effectSupplier, float chance) { - // Fabric doesn't have deferred registration, so the mob effect should always be available anyway - builder.effect(effectSupplier.get(), chance); - } -} diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinBaseSpawner.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinBaseSpawner.java index 326f7b9a..362aab83 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinBaseSpawner.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinBaseSpawner.java @@ -20,8 +20,8 @@ package dev.architectury.mixin.fabric; import dev.architectury.event.events.common.EntityEvent; +import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.level.BaseSpawner; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelReader; @@ -35,17 +35,17 @@ public abstract class MixinBaseSpawner { method = "serverTick", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/entity/Mob;checkSpawnRules(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/world/entity/MobSpawnType;)Z", + target = "Lnet/minecraft/world/entity/Mob;checkSpawnRules(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/world/entity/EntitySpawnReason;)Z", ordinal = 0 ) ) - private boolean checkSpawnerSpawn(Mob mob, LevelAccessor level, MobSpawnType type) { + private boolean checkSpawnerSpawn(Mob mob, LevelAccessor level, EntitySpawnReason reason) { var result = EntityEvent.LIVING_CHECK_SPAWN.invoker() - .canSpawn(mob, level, mob.getX(), mob.getY(), mob.getZ(), type, (BaseSpawner) (Object) this); + .canSpawn(mob, level, mob.getX(), mob.getY(), mob.getZ(), reason, (BaseSpawner) (Object) this); if (result.value() != null) { return result.value(); } - return mob.checkSpawnRules(level, type) && mob.checkSpawnObstruction(level); + return mob.checkSpawnRules(level, reason) && mob.checkSpawnObstruction(level); } @Redirect( diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinBucketItem.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinBucketItem.java index eaf23167..76cb0d8d 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinBucketItem.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinBucketItem.java @@ -21,7 +21,7 @@ package dev.architectury.mixin.fabric; import dev.architectury.event.events.common.PlayerEvent; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.BucketItem; import net.minecraft.world.item.ItemStack; @@ -46,10 +46,10 @@ public class MixinBucketItem { locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true ) - public void fillBucket(Level level, Player player, InteractionHand hand, CallbackInfoReturnable> cir, ItemStack stack, BlockHitResult target) { + public void fillBucket(Level level, Player player, InteractionHand hand, CallbackInfoReturnable cir, ItemStack stack, BlockHitResult target) { var result = PlayerEvent.FILL_BUCKET.invoker().fill(player, level, stack, target); - if (result.interruptsFurtherEvaluation() && result.value() != null) { - cir.setReturnValue(result.asMinecraft()); + if (result != InteractionResult.PASS) { + cir.setReturnValue(result); cir.cancel(); } } 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 97d313c9..4afb804d 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinCatSpawner.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinCatSpawner.java @@ -19,17 +19,17 @@ package dev.architectury.mixin.fabric; +import com.llamalad7.mixinextras.sugar.Local; import dev.architectury.event.events.common.EntityEvent; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.MobSpawnType; +import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.animal.Cat; import net.minecraft.world.entity.npc.CatSpawner; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(CatSpawner.class) public abstract class MixinCatSpawner { @@ -37,14 +37,15 @@ 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/world/entity/SpawnGroupData;", - ordinal = 0 + target = "Lnet/minecraft/world/entity/EntityType;create(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/EntitySpawnReason;)Lnet/minecraft/world/entity/Entity;", + ordinal = 0, + shift = At.Shift.BY, + by = 3 ), - cancellable = true, - locals = LocalCapture.CAPTURE_FAILHARD + cancellable = true ) - private void checkCatSpawn(BlockPos pos, ServerLevel level, CallbackInfoReturnable cir, Cat entity) { - if (EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, pos.getX(), pos.getY(), pos.getZ(), MobSpawnType.NATURAL, null).value() == Boolean.FALSE) { + private void checkCatSpawn(BlockPos pos, ServerLevel level, CallbackInfoReturnable cir, @Local Cat entity) { + if (EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, pos.getX(), pos.getY(), pos.getZ(), EntitySpawnReason.NATURAL, null).value() == Boolean.FALSE) { cir.setReturnValue(0); cir.cancel(); } 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 7f821ead..1a875a0e 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkMap.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkMap.java @@ -20,12 +20,9 @@ package dev.architectury.mixin.fabric; import dev.architectury.event.events.common.ChunkEvent; -import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ChunkMap; 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.status.ChunkStatus; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -42,10 +39,10 @@ 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;)Ljava/util/concurrent/CompletableFuture;", ordinal = 0), + at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;write(Lnet/minecraft/world/level/ChunkPos;Ljava/util/function/Supplier;)Ljava/util/concurrent/CompletableFuture;", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD ) - private void save(ChunkAccess chunkAccess, CallbackInfoReturnable cir, ChunkPos pos, ChunkStatus chunkStatus, CompoundTag nbt) { - ChunkEvent.SAVE_DATA.invoker().save(chunkAccess, this.level, nbt); + private void save(ChunkAccess chunkAccess, CallbackInfoReturnable cir) { + ChunkEvent.SAVE_DATA.invoker().save(chunkAccess, this.level); } } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkSerializer.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkSerializer.java deleted file mode 100644 index a4a9f17b..00000000 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkSerializer.java +++ /dev/null @@ -1,55 +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.fabric; - -import com.mojang.serialization.Codec; -import dev.architectury.event.events.common.ChunkEvent; -import net.minecraft.core.Holder; -import net.minecraft.core.Registry; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.server.level.ServerLevel; -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.*; -import net.minecraft.world.level.chunk.status.ChunkType; -import net.minecraft.world.level.chunk.storage.ChunkSerializer; -import net.minecraft.world.level.chunk.storage.RegionStorageInfo; -import net.minecraft.world.level.levelgen.blending.BlendingData; -import net.minecraft.world.level.lighting.LevelLightEngine; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -@Mixin(ChunkSerializer.class) -public class MixinChunkSerializer { - @Inject(method = "read", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD) - private static void load(ServerLevel serverLevel, PoiManager poiManager, RegionStorageInfo regionStorageInfo, ChunkPos chunkPos, CompoundTag compoundTag, - CallbackInfoReturnable cir, ChunkPos chunkPos2, UpgradeData upgradeData, - boolean bl, ListTag listTag, int i, LevelChunkSection[] levelChunkSections, boolean bl2, - ChunkSource chunkSource, LevelLightEngine levelLightEngine, Registry registry, - Codec>> codec, boolean bl3, long m, - 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/MixinEntity.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinEntity.java index 10c0472d..09bbb0f1 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinEntity.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinEntity.java @@ -19,15 +19,29 @@ package dev.architectury.mixin.fabric; +import dev.architectury.event.events.common.EntityEvent; import dev.architectury.hooks.level.entity.fabric.EntityHooksImpl; +import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.entity.EntityInLevelCallback; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Entity.class) public class MixinEntity { + @Inject(method = "hurtClient", at = @At("HEAD"), cancellable = true) + private void hurtClient(DamageSource damageSource, CallbackInfoReturnable cir) { + if ((Object) this instanceof Player) return; + if (EntityEvent.LIVING_HURT.invoker().hurt((LivingEntity) (Object) this, damageSource, 0).isFalse()) { + cir.setReturnValue(false); + } + } + @ModifyVariable(method = "setLevelCallback", argsOnly = true, ordinal = 0, at = @At("HEAD")) public EntityInLevelCallback modifyLevelCallback_setLevelCallback(EntityInLevelCallback callback) { return EntityHooksImpl.wrapEntityInLevelCallback((Entity) (Object) this, callback); diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinFallingBlockEntity.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinFallingBlockEntity.java index b87d7058..f09e6887 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinFallingBlockEntity.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinFallingBlockEntity.java @@ -19,20 +19,19 @@ package dev.architectury.mixin.fabric; +import com.llamalad7.mixinextras.sugar.Local; import dev.architectury.event.events.common.BlockEvent; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.item.FallingBlockEntity; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(FallingBlockEntity.class) public abstract class MixinFallingBlockEntity extends Entity { @@ -44,9 +43,8 @@ public abstract class MixinFallingBlockEntity extends Entity { private BlockState blockState; @Inject(method = "tick", at = @At(value = "INVOKE", - target = "Lnet/minecraft/world/level/block/Fallable;onLand(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/entity/item/FallingBlockEntity;)V"), - locals = LocalCapture.CAPTURE_FAILHARD) - public void handleLand(CallbackInfo ci, Block block, BlockPos blockPos2, boolean bl, boolean bl2, double d, BlockState blockState) { - BlockEvent.FALLING_LAND.invoker().onLand(this.level(), blockPos2, this.blockState, blockState, (FallingBlockEntity) (Object) this); + target = "Lnet/minecraft/world/level/block/Fallable;onLand(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/entity/item/FallingBlockEntity;)V")) + public void handleLand(CallbackInfo ci, @Local BlockPos blockPos, @Local BlockState blockState) { + BlockEvent.FALLING_LAND.invoker().onLand(this.level(), blockPos, this.blockState, blockState, (FallingBlockEntity) (Object) this); } } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinFarmBlock.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinFarmBlock.java index 22b8b167..cb6ae9e4 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinFarmBlock.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinFarmBlock.java @@ -21,6 +21,7 @@ package dev.architectury.mixin.fabric; import dev.architectury.event.events.common.InteractionEvent; import net.minecraft.core.BlockPos; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.FarmBlock; @@ -54,7 +55,7 @@ public abstract class MixinFarmBlock { var triple = turnToDirtLocal.get(); turnToDirtLocal.remove(); if (triple != null && triple.getLeft() == pos.asLong() && triple.getRight() == entity) { - if (InteractionEvent.FARMLAND_TRAMPLE.invoker().trample(level, pos, state, triple.getMiddle(), entity).value() != null) { + if (InteractionEvent.FARMLAND_TRAMPLE.invoker().trample(level, pos, state, triple.getMiddle(), entity) != InteractionResult.PASS) { ci.cancel(); } } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinLevel.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinLevel.java deleted file mode 100644 index 03a56f34..00000000 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinLevel.java +++ /dev/null @@ -1,46 +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.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; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.ExplosionDamageCalculator; -import net.minecraft.world.level.Level; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -@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/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, 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/MixinLivingEntity.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinLivingEntity.java index 47445f22..1957fbe0 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinLivingEntity.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinLivingEntity.java @@ -21,6 +21,7 @@ package dev.architectury.mixin.fabric; import dev.architectury.event.events.common.EntityEvent; import dev.architectury.extensions.ItemExtension; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; @@ -33,8 +34,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(LivingEntity.class) public class MixinLivingEntity { - @Inject(method = "hurt", at = @At("HEAD"), cancellable = true) - private void hurt(DamageSource damageSource, float f, CallbackInfoReturnable cir) { + @Inject(method = "hurtServer", at = @At("HEAD"), cancellable = true) + private void hurtServer(ServerLevel level, DamageSource damageSource, float f, CallbackInfoReturnable cir) { if ((Object) this instanceof Player) return; if (EntityEvent.LIVING_HURT.invoker().hurt((LivingEntity) (Object) this, damageSource, f).isFalse()) { cir.setReturnValue(false); diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinNaturalSpawner.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinNaturalSpawner.java index 36687bd0..d8ae0575 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinNaturalSpawner.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinNaturalSpawner.java @@ -21,8 +21,8 @@ package dev.architectury.mixin.fabric; import dev.architectury.event.events.common.EntityEvent; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.NaturalSpawner; import org.spongepowered.asm.mixin.Mixin; @@ -46,7 +46,7 @@ public abstract class MixinNaturalSpawner { ) ) private static boolean overrideNaturalSpawnCondition(ServerLevel level, Mob entity, double f) { - var result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, entity.xOld, entity.yOld, entity.zOld, MobSpawnType.NATURAL, null); + var result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, entity.xOld, entity.yOld, entity.zOld, EntitySpawnReason.NATURAL, null); if (result.value() != null) { return result.value(); } else { @@ -58,16 +58,16 @@ public abstract class MixinNaturalSpawner { method = "spawnMobsForChunkGeneration", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/entity/Mob;checkSpawnRules(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/world/entity/MobSpawnType;)Z", + target = "Lnet/minecraft/world/entity/Mob;checkSpawnRules(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/world/entity/EntitySpawnReason;)Z", ordinal = 0 ) ) - private static boolean overrideChunkGenSpawnCondition(Mob mob, LevelAccessor level, MobSpawnType type) { - var result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(mob, level, mob.xOld, mob.yOld, mob.zOld, MobSpawnType.CHUNK_GENERATION, null); + private static boolean overrideChunkGenSpawnCondition(Mob mob, LevelAccessor level, EntitySpawnReason reason) { + var result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(mob, level, mob.xOld, mob.yOld, mob.zOld, reason, null); if (result.value() != null) { return result.value(); } else { - return mob.checkSpawnRules(level, type); + return mob.checkSpawnRules(level, reason); } } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinPatrolSpawner.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinPatrolSpawner.java index dc8cff49..f2b6ce8a 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinPatrolSpawner.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinPatrolSpawner.java @@ -19,21 +19,18 @@ package dev.architectury.mixin.fabric; +import com.llamalad7.mixinextras.sugar.Local; import dev.architectury.event.events.common.EntityEvent; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; -import net.minecraft.world.entity.MobSpawnType; +import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.monster.PatrollingMonster; -import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.PatrolSpawner; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import java.util.Random; @Mixin(PatrolSpawner.class) public abstract class MixinPatrolSpawner { @@ -42,16 +39,15 @@ public abstract class MixinPatrolSpawner { method = "spawnPatrolMember", at = @At( value = "INVOKE_ASSIGN", - target = "Lnet/minecraft/world/entity/EntityType;create(Lnet/minecraft/world/level/Level;)Lnet/minecraft/world/entity/Entity;", + target = "Lnet/minecraft/world/entity/EntityType;create(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/EntitySpawnReason;)Lnet/minecraft/world/entity/Entity;", ordinal = 0, shift = At.Shift.BY, by = 2 ), - cancellable = true, - locals = LocalCapture.CAPTURE_FAILHARD + cancellable = true ) - private void checkPatrolSpawn(ServerLevel level, BlockPos pos, RandomSource r, boolean b, CallbackInfoReturnable cir, BlockState blockState, PatrollingMonster entity) { - var result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, pos.getX(), pos.getY(), pos.getZ(), MobSpawnType.PATROL, null); + private void checkPatrolSpawn(ServerLevel level, BlockPos pos, RandomSource r, boolean b, CallbackInfoReturnable cir, @Local PatrollingMonster entity) { + var result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, pos.getX(), pos.getY(), pos.getZ(), EntitySpawnReason.PATROL, null); if (result.value() != null) { cir.setReturnValue(result.value()); } 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 6c074b5e..c96e9d71 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinPhantomSpawner.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinPhantomSpawner.java @@ -19,26 +19,17 @@ package dev.architectury.mixin.fabric; +import com.llamalad7.mixinextras.sugar.Local; import dev.architectury.event.events.common.EntityEvent; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.stats.ServerStatsCounter; -import net.minecraft.util.RandomSource; -import net.minecraft.world.DifficultyInstance; -import net.minecraft.world.entity.MobSpawnType; -import net.minecraft.world.entity.SpawnGroupData; +import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.monster.Phantom; -import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.PhantomSpawner; -import net.minecraft.world.level.material.FluidState; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import java.util.Iterator; @Mixin(PhantomSpawner.class) public abstract class MixinPhantomSpawner { @@ -47,18 +38,15 @@ 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/world/entity/SpawnGroupData;", + target = "Lnet/minecraft/world/entity/EntityType;create(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/EntitySpawnReason;)Lnet/minecraft/world/entity/Entity;", ordinal = 0, - shift = At.Shift.BEFORE + shift = At.Shift.BY, + by = 3 ), - cancellable = true, - locals = LocalCapture.CAPTURE_FAILSOFT // SOFT, because this will break in 2 seconds + cancellable = true ) - private void checkPhantomSpawn(ServerLevel level, boolean bl, boolean bl2, CallbackInfoReturnable cir, - RandomSource random, int i, Iterator it, ServerPlayer player, BlockPos pos, DifficultyInstance diff, - ServerStatsCounter serverStatsCounter, int j, int k, BlockPos pos2, - BlockState blockState, FluidState fluidState, SpawnGroupData sgd, int l, int m, Phantom entity) { - if (EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, pos.getX(), pos.getY(), pos.getZ(), MobSpawnType.NATURAL, null).value() == Boolean.FALSE) { + private void checkPhantomSpawn(ServerLevel level, boolean bl, boolean bl2, CallbackInfoReturnable cir, @Local(ordinal = 1) BlockPos pos, @Local Phantom entity) { + if (EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(entity, level, pos.getX(), pos.getY(), pos.getZ(), EntitySpawnReason.NATURAL, null).value() == Boolean.FALSE) { cir.setReturnValue(0); cir.cancel(); } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinSerializableChunkData.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinSerializableChunkData.java new file mode 100644 index 00000000..315e2aad --- /dev/null +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinSerializableChunkData.java @@ -0,0 +1,45 @@ +/* + * 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.fabric; + +import com.llamalad7.mixinextras.sugar.Local; +import dev.architectury.event.events.common.ChunkEvent; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.ai.village.poi.PoiManager; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ProtoChunk; +import net.minecraft.world.level.chunk.storage.RegionStorageInfo; +import net.minecraft.world.level.chunk.storage.SerializableChunkData; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(SerializableChunkData.class) +public class MixinSerializableChunkData { + @Inject(method = "read", at = @At("RETURN")) + private void load(ServerLevel serverLevel, PoiManager poiManager, RegionStorageInfo regionStorageInfo, ChunkPos chunkPos, + CallbackInfoReturnable cir, + @Local ChunkAccess chunkAccess) { + // TODO: Get the CompoundTag from constructor somewhere + ChunkEvent.LOAD_DATA.invoker().load(chunkAccess, serverLevel); + } +} diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinExplosion.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinServerExplosion.java similarity index 63% rename from fabric/src/main/java/dev/architectury/mixin/fabric/MixinExplosion.java rename to fabric/src/main/java/dev/architectury/mixin/fabric/MixinServerExplosion.java index 4988b0d8..4475996b 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinExplosion.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinServerExplosion.java @@ -19,32 +19,27 @@ package dev.architectury.mixin.fabric; +import com.llamalad7.mixinextras.sugar.Local; import dev.architectury.event.events.common.ExplosionEvent; -import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.Level; -import org.spongepowered.asm.mixin.Final; +import net.minecraft.world.level.ServerExplosion; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import java.util.List; -import java.util.Set; -@Mixin(Explosion.class) -public class MixinExplosion { +@Mixin(ServerExplosion.class) +public abstract class MixinServerExplosion { @Shadow - @Final - private Level level; + public abstract ServerLevel level(); @SuppressWarnings("InvalidInjectorMethodSignature") - @Inject(method = "explode", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;(DDD)V", ordinal = 1), - locals = LocalCapture.CAPTURE_FAILHARD) - private void explodePost(CallbackInfo ci, Set set, int i, float q, int r, int s, int t, int u, int v, int w, List list) { - ExplosionEvent.DETONATE.invoker().explode(level, (Explosion) (Object) this, list); + @Inject(method = "hurtEntities", at = @At(value = "INVOKE", target = "Ljava/util/List;iterator()Ljava/util/Iterator;", ordinal = 0)) + private void explodePost(CallbackInfo ci, @Local List list) { + ExplosionEvent.DETONATE.invoker().explode(level(), (ServerExplosion) (Object) this, list); } } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinServerLevel.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinServerLevel.java index ab28b35d..7cf26708 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinServerLevel.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinServerLevel.java @@ -19,11 +19,21 @@ package dev.architectury.mixin.fabric; +import com.llamalad7.mixinextras.sugar.Local; +import dev.architectury.event.events.common.ExplosionEvent; import dev.architectury.event.events.common.LifecycleEvent; import dev.architectury.hooks.fabric.PersistentEntitySectionManagerHooks; +import net.minecraft.core.Holder; +import net.minecraft.core.particles.ParticleOptions; import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundEvent; import net.minecraft.util.ProgressListener; +import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.ExplosionDamageCalculator; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.ServerExplosion; import net.minecraft.world.level.entity.PersistentEntitySectionManager; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -50,4 +60,12 @@ public class MixinServerLevel { private void addEntity(Entity entity, CallbackInfoReturnable cir) { ((PersistentEntitySectionManagerHooks) this.entityManager).architectury_attachLevel((ServerLevel) (Object) this); } + + @Inject(method = "explode(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Level$ExplosionInteraction;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/Holder;)V", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/ServerExplosion;explode()V"), cancellable = true) + private void explodePre(Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionDamageCalculator, double d, double e, double f, float g, boolean bl, Level.ExplosionInteraction explosionInteraction, ParticleOptions particleOptions, ParticleOptions particleOptions2, Holder soundEvent, CallbackInfo ci, @Local Explosion.BlockInteraction blockInteraction, @Local ServerExplosion explosion) { + if (ExplosionEvent.PRE.invoker().explode((Level) (Object) this, explosion).isFalse()) { + ci.cancel(); + } + } } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/PlayerAttackInvoker.java b/fabric/src/main/java/dev/architectury/mixin/fabric/PlayerAttackInvoker.java index 8b5a0a8a..fd8d0184 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/PlayerAttackInvoker.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/PlayerAttackInvoker.java @@ -20,6 +20,7 @@ package dev.architectury.mixin.fabric; import dev.architectury.event.events.common.EntityEvent; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; @@ -30,8 +31,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(value = {Player.class}) public class PlayerAttackInvoker { - @Inject(method = "hurt", at = @At("HEAD"), cancellable = true) - private void hurt(DamageSource damageSource, float f, CallbackInfoReturnable cir) { + @Inject(method = "hurtServer", at = @At("HEAD"), cancellable = true) + private void hurtServer(ServerLevel level, DamageSource damageSource, float f, CallbackInfoReturnable cir) { if (EntityEvent.LIVING_HURT.invoker().hurt((LivingEntity) (Object) this, damageSource, f).isFalse() && (Object) this instanceof Player) { cir.setReturnValue(false); } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/ClientPlayerAttackInvoker.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/ClientPlayerAttackInvoker.java index 9800a67a..c03763d3 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/ClientPlayerAttackInvoker.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/client/ClientPlayerAttackInvoker.java @@ -20,7 +20,6 @@ package dev.architectury.mixin.fabric.client; import dev.architectury.event.events.common.EntityEvent; -import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.RemotePlayer; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.LivingEntity; @@ -30,11 +29,11 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(value = {LocalPlayer.class, RemotePlayer.class}) +@Mixin(value = {RemotePlayer.class}) public class ClientPlayerAttackInvoker { - @Inject(method = "hurt", at = @At("HEAD"), cancellable = true) - private void hurt(DamageSource damageSource, float f, CallbackInfoReturnable cir) { - if (EntityEvent.LIVING_HURT.invoker().hurt((LivingEntity) (Object) this, damageSource, f).isFalse() && (Object) this instanceof Player) { + @Inject(method = "hurtClient", at = @At("HEAD"), cancellable = true) + private void hurt(DamageSource damageSource, CallbackInfoReturnable cir) { + if (EntityEvent.LIVING_HURT.invoker().hurt((LivingEntity) (Object) this, damageSource, 0).isFalse() && (Object) this instanceof Player) { cir.setReturnValue(false); } } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinClientLevel.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinClientLevel.java index 67baefae..de99c7ca 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinClientLevel.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinClientLevel.java @@ -26,21 +26,19 @@ import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.core.Holder; import net.minecraft.resources.ResourceKey; -import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; import net.minecraft.world.level.dimension.DimensionType; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.function.Supplier; +import java.util.logging.Level; @Mixin(ClientLevel.class) public class MixinClientLevel { @Inject(method = "", at = @At("RETURN")) - private void construct(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey resourceKey, Holder holder, int i, int j, Supplier supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci) { + private void construct(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey resourceKey, Holder holder, int i, int j, LevelRenderer levelRenderer, boolean bl, long l, int k, CallbackInfo ci) { ClientLifecycleEvent.CLIENT_LEVEL_LOAD.invoker().act((ClientLevel) (Object) this); } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinClientPacketListener.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinClientPacketListener.java index e6151fc2..7355eda0 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinClientPacketListener.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinClientPacketListener.java @@ -30,11 +30,8 @@ import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.multiplayer.CommonListenerCookie; import net.minecraft.client.player.LocalPlayer; import net.minecraft.network.Connection; -import net.minecraft.network.protocol.game.ClientboundLoginPacket; -import net.minecraft.network.protocol.game.ClientboundRespawnPacket; -import net.minecraft.network.protocol.game.ClientboundUpdateRecipesPacket; -import net.minecraft.world.item.crafting.RecipeManager; -import org.spongepowered.asm.mixin.Final; +import net.minecraft.network.protocol.game.*; +import net.minecraft.world.item.crafting.RecipeAccess; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -44,11 +41,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ClientPacketListener.class) public abstract class MixinClientPacketListener extends ClientCommonPacketListenerImpl { - @Shadow - @Final - private RecipeManager recipeManager; @Shadow private ClientLevel level; + + @Shadow + public abstract RecipeAccess recipes(); + @Unique private LocalPlayer tmpPlayer; @@ -75,7 +73,17 @@ public abstract class MixinClientPacketListener extends ClientCommonPacketListen @Inject(method = "handleUpdateRecipes", at = @At("RETURN")) private void handleUpdateRecipes(ClientboundUpdateRecipesPacket clientboundUpdateRecipesPacket, CallbackInfo ci) { - ClientRecipeUpdateEvent.EVENT.invoker().update(recipeManager); + ClientRecipeUpdateEvent.EVENT.invoker().update(recipes()); + } + + @Inject(method = "handleRecipeBookAdd", at = @At("RETURN")) + private void handleRecipeBookAdd(ClientboundRecipeBookAddPacket packet, CallbackInfo ci) { + ClientRecipeUpdateEvent.ADD.invoker().add(recipes(), packet.entries()); + } + + @Inject(method = "handleRecipeBookRemove", at = @At("RETURN")) + private void handleRecipeBookRemove(ClientboundRecipeBookRemovePacket packet, CallbackInfo ci) { + ClientRecipeUpdateEvent.REMOVE.invoker().remove(recipes(), packet.recipes()); } @Inject(method = "sendChat(Ljava/lang/String;)V", at = @At(value = "HEAD"), cancellable = true) 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 deleted file mode 100644 index e518a771..00000000 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinEffectInstance.java +++ /dev/null @@ -1,57 +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.fabric.client; - -import com.mojang.blaze3d.shaders.Program; -import net.minecraft.client.renderer.EffectInstance; -import net.minecraft.resources.ResourceLocation; -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; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Unique -@Mixin(value = EffectInstance.class, priority = 950) -public class MixinEffectInstance { - @Redirect( - method = "", - at = @At(value = "INVOKE", - target = "Lnet/minecraft/resources/ResourceLocation;withDefaultNamespace(Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation;", - ordinal = 0) - ) - private ResourceLocation mojangPls(String _0, ResourceProvider rm, String str) { - return mojangPls(ResourceLocation.parse(str), ".json"); - } - - @Redirect( - method = "getOrCreate", - at = @At(value = "INVOKE", - target = "Lnet/minecraft/resources/ResourceLocation;withDefaultNamespace(Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation;", - ordinal = 0) - ) - private static ResourceLocation mojangPls(String _0, ResourceProvider rm, Program.Type type, String str) { - return mojangPls(ResourceLocation.parse(str), type.getExtension()); - } - - private static ResourceLocation mojangPls(ResourceLocation rl, String ext) { - return ResourceLocation.fromNamespaceAndPath(rl.getNamespace(), "shaders/program/" + rl.getPath() + ext); - } -} 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 10c3e1f9..cc3b8ee8 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 @@ -19,29 +19,18 @@ package dev.architectury.mixin.fabric.client; -import com.mojang.blaze3d.platform.Window; -import com.mojang.blaze3d.shaders.Program; -import com.mojang.datafixers.util.Pair; +import com.llamalad7.mixinextras.sugar.Local; import dev.architectury.event.events.client.ClientGuiEvent; -import dev.architectury.event.events.client.ClientReloadShadersEvent; import net.minecraft.client.DeltaTracker; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.GameRenderer; -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; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import java.util.List; -import java.util.function.Consumer; @Mixin(value = GameRenderer.class, priority = 1100) public abstract class MixinGameRenderer { @@ -54,8 +43,8 @@ public abstract class MixinGameRenderer { @Inject(method = "render(Lnet/minecraft/client/DeltaTracker;Z)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(DeltaTracker tickDelta, boolean tick, CallbackInfo ci, boolean isGameLoadFinished, int mouseX, int mouseY, Window window, Matrix4f matrix, Matrix4fStack matrices, GuiGraphics graphics) { + ordinal = 0), cancellable = true) + public void renderScreenPre(DeltaTracker tickDelta, boolean tick, CallbackInfo ci, @Local(ordinal = 0) int mouseX, @Local(ordinal = 1) int mouseY, @Local GuiGraphics graphics) { if (ClientGuiEvent.RENDER_PRE.invoker().render(minecraft.screen, graphics, mouseX, mouseY, tickDelta).isFalse()) { ci.cancel(); } @@ -63,16 +52,8 @@ public abstract class MixinGameRenderer { @Inject(method = "render(Lnet/minecraft/client/DeltaTracker;Z)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(DeltaTracker tickDelta, boolean tick, CallbackInfo ci, boolean isGameLoadFinished, int mouseX, int mouseY, Window window, Matrix4f matrix, Matrix4fStack matrices, GuiGraphics graphics) { + shift = At.Shift.AFTER, ordinal = 0)) + public void renderScreenPost(DeltaTracker tickDelta, boolean tick, CallbackInfo ci, @Local(ordinal = 0) int mouseX, @Local(ordinal = 1) int mouseY, @Local GuiGraphics graphics) { ClientGuiEvent.RENDER_POST.invoker().render(minecraft.screen, graphics, mouseX, mouseY, tickDelta); } - - @Inject(method = "reloadShaders", - at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", ordinal = 0), locals = LocalCapture.CAPTURE_FAILEXCEPTION) - public void reloadShaders(ResourceProvider provider, CallbackInfo ci, List programs, List>> shaders) { - ClientReloadShadersEvent.EVENT.invoker().reload(provider, (shader, callback) -> { - shaders.add(Pair.of(shader, callback)); - }); - } } \ No newline at end of file diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinGuiGraphics.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinGuiGraphics.java index afbcafef..8c5135ad 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinGuiGraphics.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinGuiGraphics.java @@ -20,13 +20,14 @@ package dev.architectury.mixin.fabric.client; import dev.architectury.event.events.client.ClientTooltipEvent; -import dev.architectury.impl.TooltipEventColorContextImpl; import dev.architectury.impl.TooltipEventPositionContextImpl; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -52,28 +53,25 @@ public abstract class MixinGuiGraphics { } @Inject(method = "renderTooltipInternal", at = @At("HEAD"), cancellable = true) - private void renderTooltip(Font font, List list, int x, int y, ClientTooltipPositioner positioner, CallbackInfo ci) { + private void renderTooltip(Font font, List list, int x, int y, ClientTooltipPositioner positioner, @Nullable ResourceLocation background, CallbackInfo ci) { if (!list.isEmpty()) { - var colorContext = TooltipEventColorContextImpl.CONTEXT.get(); - colorContext.reset(); var positionContext = tooltipPositionContext.get(); positionContext.reset(x, y); if (ClientTooltipEvent.RENDER_PRE.invoker().renderTooltip((GuiGraphics) (Object) this, list, x, y).isFalse()) { ci.cancel(); } else { - ClientTooltipEvent.RENDER_MODIFY_COLOR.invoker().renderTooltip((GuiGraphics) (Object) this, x, y, colorContext); ClientTooltipEvent.RENDER_MODIFY_POSITION.invoker().renderTooltip((GuiGraphics) (Object) this, positionContext); } } } - @ModifyVariable(method = "renderTooltipInternal(Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;)V", + @ModifyVariable(method = "renderTooltipInternal", at = @At(value = "HEAD"), ordinal = 0, argsOnly = true) private int modifyTooltipX(int original) { return tooltipPositionContext.get().getTooltipX(); } - @ModifyVariable(method = "renderTooltipInternal(Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;)V", + @ModifyVariable(method = "renderTooltipInternal", at = @At(value = "HEAD"), ordinal = 1, argsOnly = true) private int modifyTooltipY(int original) { return tooltipPositionContext.get().getTooltipY(); diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinKeyboardHandler.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinKeyboardHandler.java index c215a3ea..b28e4128 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinKeyboardHandler.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinKeyboardHandler.java @@ -19,6 +19,7 @@ package dev.architectury.mixin.fabric.client; +import com.llamalad7.mixinextras.sugar.Local; import dev.architectury.event.EventResult; import dev.architectury.event.events.client.ClientRawInputEvent; import dev.architectury.event.events.client.ClientScreenInputEvent; @@ -34,7 +35,6 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(KeyboardHandler.class) public class MixinKeyboardHandler { @@ -42,7 +42,7 @@ public class MixinKeyboardHandler { @Final private Minecraft minecraft; - @ModifyVariable(method = {"method_1458", "lambda$charTyped$5"}, at = @At("HEAD"), ordinal = 0, argsOnly = true) + @ModifyVariable(method = {"method_1458", "lambda$charTyped$6"}, at = @At("HEAD"), ordinal = 0, argsOnly = true) private static GuiEventListener wrapCharTypedFirst(GuiEventListener screen) { if (screen instanceof ScreenInputDelegate delegate) { return delegate.architectury_delegateInputs(); @@ -50,7 +50,7 @@ public class MixinKeyboardHandler { return screen; } - @ModifyVariable(method = {"method_1473", "lambda$charTyped$6"}, at = @At("HEAD"), ordinal = 0, argsOnly = true) + @ModifyVariable(method = {"method_1473", "lambda$charTyped$7"}, at = @At("HEAD"), ordinal = 0, argsOnly = true) private static GuiEventListener wrapCharTypedSecond(GuiEventListener screen) { if (screen instanceof ScreenInputDelegate delegate) { return delegate.architectury_delegateInputs(); @@ -79,9 +79,9 @@ public class MixinKeyboardHandler { @Inject(method = "keyPress", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;wrapScreenError(Ljava/lang/Runnable;Ljava/lang/String;Ljava/lang/String;)V", - ordinal = 0, shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD, + ordinal = 0, shift = At.Shift.AFTER), cancellable = true) - public void onKeyAfter(long long_1, int int_1, int int_2, int int_3, int int_4, CallbackInfo info, boolean f3Pressed, Screen screen, boolean[] bls) { + public void onKeyAfter(long long_1, int int_1, int int_2, int int_3, int int_4, CallbackInfo info, @Local Screen screen, @Local boolean[] bls) { if (!info.isCancelled() && !bls[0]) { EventResult result; if (int_3 != 1 && int_3 != 2) { diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinTooltipRenderUtil.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinTooltipRenderUtil.java deleted file mode 100644 index cfd04602..00000000 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinTooltipRenderUtil.java +++ /dev/null @@ -1,44 +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.fabric.client; - -import dev.architectury.impl.TooltipEventColorContextImpl; -import net.minecraft.client.gui.screens.inventory.tooltip.TooltipRenderUtil; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.Constant; -import org.spongepowered.asm.mixin.injection.ModifyConstant; - -@Mixin(TooltipRenderUtil.class) -public abstract class MixinTooltipRenderUtil { - @ModifyConstant(method = "renderTooltipBackground", constant = @Constant(intValue = 0xf0100010)) - private static int modifyTooltipBackgroundColor(int original) { - return TooltipEventColorContextImpl.CONTEXT.get().getBackgroundColor(); - } - - @ModifyConstant(method = "renderTooltipBackground", constant = @Constant(intValue = 0x505000ff)) - private static int modifyTooltipOutlineGradientTopColor(int original) { - return TooltipEventColorContextImpl.CONTEXT.get().getOutlineGradientTopColor(); - } - - @ModifyConstant(method = "renderTooltipBackground", constant = @Constant(intValue = 0x5028007f)) - private static int modifyTooltipOutlineGradientBottomColor(int original) { - return TooltipEventColorContextImpl.CONTEXT.get().getOutlineGradientBottomColor(); - } -} diff --git a/fabric/src/main/java/dev/architectury/registry/fabric/CreativeTabRegistryImpl.java b/fabric/src/main/java/dev/architectury/registry/fabric/CreativeTabRegistryImpl.java index fdc930ca..b457de62 100644 --- a/fabric/src/main/java/dev/architectury/registry/fabric/CreativeTabRegistryImpl.java +++ b/fabric/src/main/java/dev/architectury/registry/fabric/CreativeTabRegistryImpl.java @@ -109,7 +109,7 @@ public class CreativeTabRegistryImpl { private void resolve() { if (this.tab == null) { - this.tab = BuiltInRegistries.CREATIVE_MODE_TAB.get(name); + this.tab = BuiltInRegistries.CREATIVE_MODE_TAB.getValue(name); } } }; diff --git a/fabric/src/main/java/dev/architectury/registry/fabric/ReloadListenerRegistryImpl.java b/fabric/src/main/java/dev/architectury/registry/fabric/ReloadListenerRegistryImpl.java index e1ded51c..a422505d 100644 --- a/fabric/src/main/java/dev/architectury/registry/fabric/ReloadListenerRegistryImpl.java +++ b/fabric/src/main/java/dev/architectury/registry/fabric/ReloadListenerRegistryImpl.java @@ -59,8 +59,8 @@ public class ReloadListenerRegistryImpl { } @Override - public CompletableFuture reload(PreparationBarrier preparationBarrier, ResourceManager resourceManager, ProfilerFiller profilerFiller, ProfilerFiller profilerFiller2, Executor executor, Executor executor2) { - return listener.reload(preparationBarrier, resourceManager, profilerFiller, profilerFiller2, executor, executor2); + public CompletableFuture reload(PreparationBarrier preparationBarrier, ResourceManager resourceManager, Executor executor, Executor executor2) { + return listener.reload(preparationBarrier, resourceManager, executor, executor2); } }); } diff --git a/fabric/src/main/java/dev/architectury/registry/fuel/fabric/FuelRegistryImpl.java b/fabric/src/main/java/dev/architectury/registry/fuel/fabric/FuelRegistryImpl.java index 9b0c9337..eb0b0b19 100644 --- a/fabric/src/main/java/dev/architectury/registry/fuel/fabric/FuelRegistryImpl.java +++ b/fabric/src/main/java/dev/architectury/registry/fuel/fabric/FuelRegistryImpl.java @@ -19,23 +19,23 @@ package dev.architectury.registry.fuel.fabric; -import net.fabricmc.fabric.api.registry.FuelRegistry; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ItemLike; public class FuelRegistryImpl { public static void register(int time, ItemLike... items) { - for (var item : items) { + /*for (var item : items) { if (time >= 0) { FuelRegistry.INSTANCE.add(item, time); } else { FuelRegistry.INSTANCE.remove(item); } - } + }*/ } public static int get(ItemStack stack) { - var time = FuelRegistry.INSTANCE.get(stack.getItem()); - return time == null ? 0 : time; + /*var time = FuelRegistry.INSTANCE.get(stack.getItem()); + return time == null ? 0 : time;*/ + return 0; } } diff --git a/fabric/src/main/java/dev/architectury/registry/level/biome/fabric/BiomeModificationsImpl.java b/fabric/src/main/java/dev/architectury/registry/level/biome/fabric/BiomeModificationsImpl.java index 3065f811..57ffd0f2 100644 --- a/fabric/src/main/java/dev/architectury/registry/level/biome/fabric/BiomeModificationsImpl.java +++ b/fabric/src/main/java/dev/architectury/registry/level/biome/fabric/BiomeModificationsImpl.java @@ -154,10 +154,10 @@ public class BiomeModificationsImpl { } @Override - public Mutable addCarver(GenerationStep.Carving carving, Holder> feature) { + public Mutable addCarver(Holder> feature) { Either>, ConfiguredWorldCarver> unwrap = feature.unwrap(); if (unwrap.left().isPresent()) { - this.context.addCarver(carving, unwrap.left().get()); + this.context.addCarver(unwrap.left().get()); } else { throw new UnsupportedOperationException("Cannot add a carver that is not registered: " + unwrap.right().orElseThrow()); } @@ -165,8 +165,8 @@ public class BiomeModificationsImpl { } @Override - public Mutable addCarver(GenerationStep.Carving carving, ResourceKey> feature) { - this.context.addCarver(carving, feature); + public Mutable addCarver(ResourceKey> feature) { + this.context.addCarver(feature); return this; } @@ -177,8 +177,8 @@ public class BiomeModificationsImpl { } @Override - public Mutable removeCarver(GenerationStep.Carving carving, ResourceKey> feature) { - context.removeCarver(carving, feature); + public Mutable removeCarver(ResourceKey> feature) { + context.removeCarver(feature); return this; } } diff --git a/fabric/src/main/java/dev/architectury/registry/registries/fabric/RegistrarManagerImpl.java b/fabric/src/main/java/dev/architectury/registry/registries/fabric/RegistrarManagerImpl.java index c3d19516..b11d106a 100644 --- a/fabric/src/main/java/dev/architectury/registry/registries/fabric/RegistrarManagerImpl.java +++ b/fabric/src/main/java/dev/architectury/registry/registries/fabric/RegistrarManagerImpl.java @@ -52,7 +52,7 @@ public class RegistrarManagerImpl { private static void listen(ResourceKey resourceKey, ResourceLocation id, Consumer listener) { if (LISTENED_REGISTRIES.add(resourceKey)) { - Registry registry = java.util.Objects.requireNonNull(BuiltInRegistries.REGISTRY.get(resourceKey.location()), "Registry " + resourceKey + " not found!"); + Registry registry = java.util.Objects.requireNonNull(BuiltInRegistries.REGISTRY.getValue(resourceKey.location()), "Registry " + resourceKey + " not found!"); RegistryEntryAddedCallback.event(registry).register((rawId, entryId, object) -> { RegistryEntryId registryEntryId = new RegistryEntryId<>(resourceKey, entryId); for (Consumer consumer : LISTENERS.get(registryEntryId)) { @@ -78,7 +78,7 @@ public class RegistrarManagerImpl { @Override public Registrar get(ResourceKey> key) { - return new RegistrarImpl<>(modId, (Registry) java.util.Objects.requireNonNull(BuiltInRegistries.REGISTRY.get(key.location()), "Registry " + key + " not found!")); + return new RegistrarImpl<>(modId, (Registry) java.util.Objects.requireNonNull(BuiltInRegistries.REGISTRY.getValue(key.location()), "Registry " + key + " not found!")); } @Override @@ -250,7 +250,7 @@ public class RegistrarManagerImpl { @Override public @Nullable T get(ResourceLocation id) { - return delegate.get(id); + return delegate.getValue(id); } @Override @@ -286,7 +286,7 @@ public class RegistrarManagerImpl { @Override @Nullable public Holder getHolder(ResourceKey key) { - return delegate.getHolder(key).orElse(null); + return delegate.get(key).orElse(null); } @Override diff --git a/fabric/src/main/resources/architectury.mixins.json b/fabric/src/main/resources/architectury.mixins.json index ac8a1b37..a4bd41f8 100644 --- a/fabric/src/main/resources/architectury.mixins.json +++ b/fabric/src/main/resources/architectury.mixins.json @@ -11,7 +11,6 @@ "client.MixinClientLevel", "client.MixinClientPacketListener", "client.MixinDebugScreenOverlay", - "client.MixinEffectInstance", "client.MixinFabricClientCommandSource", "client.MixinGameRenderer", "client.MixinGuiGraphics", @@ -20,8 +19,7 @@ "client.MixinMinecraft", "client.MixinMouseHandler", "client.MixinMultiPlayerGameMode", - "client.MixinScreen", - "client.MixinTooltipRenderUtil" + "client.MixinScreen" ], "mixins": [ "BiomeAccessor", @@ -34,17 +32,14 @@ "MixinBucketItem", "MixinCatSpawner", "MixinChunkMap", - "MixinChunkSerializer", "MixinCommands", "MixinDedicatedServer", "MixinEntity", - "MixinExplosion", "MixinFallingBlockEntity", "MixinFarmBlock", "MixinFurnaceResultSlot", "MixinInventory", "MixinItemEntity", - "MixinLevel", "MixinLivingEntity", "MixinNaturalSpawner", "MixinOcelot", @@ -55,6 +50,8 @@ "MixinPlayerAdvancements", "MixinPlayerList", "MixinResultSlot", + "MixinSerializableChunkData", + "MixinServerExplosion", "MixinServerLevel", "MixinServerPlayer", "MixinServerPlayerGameMode", diff --git a/gradle.properties b/gradle.properties index d6ae6fc8..63ed672a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,21 +1,21 @@ org.gradle.jvmargs=-Xmx6G org.gradle.daemon=false -platforms=fabric,neoforge +platforms=fabric -minecraft_version=1.21 -supported_version=1.21 +minecraft_version=24w40a +supported_version=1.21.2 (24w40a) -artifact_type=release +artifact_type=beta archives_base_name=architectury archives_base_name_snapshot=architectury-snapshot -base_version=13.0 +base_version=14.0 maven_group=dev.architectury version_suffix= -fabric_loader_version=0.15.11 -fabric_api_version=0.100.0+1.21 +fabric_loader_version=0.16.5 +fabric_api_version=0.105.2+1.21.2 mod_menu_version=11.0.1 forge_version=51.0.0 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 17655d0e..0d184210 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 2d3f37cb..8c6bf287 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,10 +15,10 @@ include("common") include("fabric") //include("forge") //include("minecraftforge") -include("neoforge") +//include("neoforge") include("testmod-common") include("testmod-fabric") //include("testmod-forge") -include("testmod-neoforge") +//include("testmod-neoforge") rootProject.name = "architectury" diff --git a/testmod-common/src/main/java/dev/architectury/test/TestMod.java b/testmod-common/src/main/java/dev/architectury/test/TestMod.java index 157778e5..1f64b0b6 100644 --- a/testmod-common/src/main/java/dev/architectury/test/TestMod.java +++ b/testmod-common/src/main/java/dev/architectury/test/TestMod.java @@ -45,20 +45,12 @@ import dev.architectury.utils.EnvExecutor; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.renderer.entity.CowRenderer; -import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.core.registries.Registries; -import net.minecraft.data.registries.VanillaRegistries; import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.enchantment.Enchantments; -import net.minecraft.world.item.enchantment.ItemEnchantments; import net.minecraft.world.level.block.Blocks; -import java.util.Collections; -import java.util.List; - public class TestMod { public static final MessageSink SINK = EnvExecutor.getEnvSpecific(() -> ClientOverlayMessageSink::new, () -> ConsoleMessageSink::new); public static final String MOD_ID = "architectury_test"; @@ -75,7 +67,7 @@ public class TestMod { TestLoot.init(); TestWorldGeneration.initialize(); EnvExecutor.runInEnv(Env.CLIENT, () -> TestMod.Client::initializeClient); - CreativeTabRegistry.modifyBuiltin(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.BUILDING_BLOCKS), (flags, output, canUseGameMasterBlocks) -> { + CreativeTabRegistry.modifyBuiltin(BuiltInRegistries.CREATIVE_MODE_TAB.getValue(CreativeModeTabs.BUILDING_BLOCKS), (flags, output, canUseGameMasterBlocks) -> { ItemStack sword = Items.DIAMOND_SWORD.getDefaultInstance(); output.acceptBefore(new ItemStack(Items.OAK_WOOD), sword); output.acceptAfter(Blocks.STRIPPED_OAK_LOG, Items.BEDROCK); diff --git a/testmod-common/src/main/java/dev/architectury/test/entity/TestEntity.java b/testmod-common/src/main/java/dev/architectury/test/entity/TestEntity.java index a123654c..0314715d 100644 --- a/testmod-common/src/main/java/dev/architectury/test/entity/TestEntity.java +++ b/testmod-common/src/main/java/dev/architectury/test/entity/TestEntity.java @@ -20,14 +20,15 @@ package dev.architectury.test.entity; import com.google.common.base.Suppliers; -import dev.architectury.injectables.targets.ArchitecturyTarget; import dev.architectury.networking.NetworkManager; +import dev.architectury.test.TestMod; import io.netty.buffer.Unpooled; +import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerEntity; import net.minecraft.server.level.ServerPlayer; @@ -39,8 +40,8 @@ import net.minecraft.world.level.Level; import java.util.function.Supplier; public class TestEntity extends Cow { - public static final Supplier> TYPE = Suppliers.memoize(() -> EntityType.Builder.of(TestEntity::new, MobCategory.MISC).sized(0.98F, 0.7F).clientTrackingRange(8).build("test_entity")); - public static final Supplier> TYPE_2 = Suppliers.memoize(() -> EntityType.Builder.of(TestEntity::new, MobCategory.MISC).sized(0.98F, 0.7F).clientTrackingRange(8).build("test_entity_2")); + public static final Supplier> TYPE = Suppliers.memoize(() -> EntityType.Builder.of(TestEntity::new, MobCategory.MISC).sized(0.98F, 0.7F).clientTrackingRange(8).build(ResourceKey.create(Registries.ENTITY_TYPE, ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "test_entity")))); + public static final Supplier> TYPE_2 = Suppliers.memoize(() -> EntityType.Builder.of(TestEntity::new, MobCategory.MISC).sized(0.98F, 0.7F).clientTrackingRange(8).build(ResourceKey.create(Registries.ENTITY_TYPE, ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "test_entity_2")))); public TestEntity(EntityType entityType, Level level) { super(entityType, level); diff --git a/testmod-common/src/main/java/dev/architectury/test/events/DebugEvents.java b/testmod-common/src/main/java/dev/architectury/test/events/DebugEvents.java index 53aedd2c..7d93fa78 100644 --- a/testmod-common/src/main/java/dev/architectury/test/events/DebugEvents.java +++ b/testmod-common/src/main/java/dev/architectury/test/events/DebugEvents.java @@ -24,7 +24,6 @@ import dev.architectury.event.CompoundEventResult; import dev.architectury.event.EventResult; import dev.architectury.event.events.client.*; import dev.architectury.event.events.common.*; -import dev.architectury.hooks.level.ExplosionHooks; import dev.architectury.platform.Platform; import dev.architectury.test.TestMod; import dev.architectury.utils.Env; @@ -37,6 +36,7 @@ import net.minecraft.core.Position; import net.minecraft.core.Vec3i; import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.player.Player; @@ -134,19 +134,19 @@ public class DebugEvents { return EventResult.pass(); })); ExplosionEvent.DETONATE.register((world, explosion, affectedEntities) -> { - TestMod.SINK.accept(world.dimension().location() + " explodes at " + toShortString(ExplosionHooks.getPosition(explosion)) + logSide(world)); + TestMod.SINK.accept(world.dimension().location() + " explodes at " + toShortString(explosion.center()) + logSide(world)); }); InteractionEvent.LEFT_CLICK_BLOCK.register((player, hand, pos, face) -> { TestMod.SINK.accept(player.getScoreboardName() + " left clicks " + toShortString(pos) + logSide(player.level())); - return EventResult.pass(); + return InteractionResult.PASS; }); InteractionEvent.RIGHT_CLICK_BLOCK.register((player, hand, pos, face) -> { TestMod.SINK.accept(player.getScoreboardName() + " right clicks " + toShortString(pos) + logSide(player.level())); - return EventResult.pass(); + return InteractionResult.PASS; }); InteractionEvent.RIGHT_CLICK_ITEM.register((player, hand) -> { TestMod.SINK.accept(player.getScoreboardName() + " uses " + (hand == InteractionHand.MAIN_HAND ? "main hand" : "off hand") + logSide(player.level())); - return CompoundEventResult.pass(); + return InteractionResult.PASS; }); InteractionEvent.INTERACT_ENTITY.register((player, entity, hand) -> { TestMod.SINK.accept(player.getScoreboardName() + " interacts with " + entity.getScoreboardName() + " using " + (hand == InteractionHand.MAIN_HAND ? "main hand" : "off hand") + logSide(player.level())); @@ -154,10 +154,10 @@ public class DebugEvents { }); InteractionEvent.FARMLAND_TRAMPLE.register((level, pos, state, distance, entity) -> { if (entity instanceof Player && ((Player) entity).getItemBySlot(EquipmentSlot.FEET).getItem() == Items.DIAMOND_BOOTS) { - return EventResult.interrupt(false); + return InteractionResult.FAIL; } TestMod.SINK.accept("%s trampled farmland (%s) at %s in %s (Fall height: %f blocks)", entity, state, pos, level, distance); - return EventResult.pass(); + return InteractionResult.PASS; }); LifecycleEvent.SERVER_BEFORE_START.register(instance -> { TestMod.SINK.accept("Server ready to start"); @@ -201,16 +201,16 @@ public class DebugEvents { TestMod.SINK.accept(player.getScoreboardName() + " was awarded with %s" + logSide(player.level()), Advancement.name(advancement)); }); PlayerEvent.CRAFT_ITEM.register((player, constructed, inventory) -> { - TestMod.SINK.accept(player.getScoreboardName() + " crafts " + Component.translatable(constructed.getDescriptionId()).getString() + logSide(player.level())); + TestMod.SINK.accept(player.getScoreboardName() + " crafts " + Component.translatable(constructed.getItem().getDescriptionId()).getString() + logSide(player.level())); }); PlayerEvent.SMELT_ITEM.register((player, smelted) -> { - TestMod.SINK.accept(player.getScoreboardName() + " smelts " + Component.translatable(smelted.getDescriptionId()).getString() + logSide(player.level())); + TestMod.SINK.accept(player.getScoreboardName() + " smelts " + Component.translatable(smelted.getItem().getDescriptionId()).getString() + logSide(player.level())); }); PlayerEvent.PICKUP_ITEM_POST.register((player, entity, stack) -> { - TestMod.SINK.accept(player.getScoreboardName() + " picks up " + Component.translatable(stack.getDescriptionId()).getString() + logSide(player.level())); + TestMod.SINK.accept(player.getScoreboardName() + " picks up " + Component.translatable(stack.getItem().getDescriptionId()).getString() + logSide(player.level())); }); PlayerEvent.DROP_ITEM.register((player, entity) -> { - TestMod.SINK.accept(player.getScoreboardName() + " drops " + Component.translatable(entity.getItem().getDescriptionId()).getString() + logSide(player.level())); + TestMod.SINK.accept(player.getScoreboardName() + " drops " + Component.translatable(entity.getItem().getItem().getDescriptionId()).getString() + logSide(player.level())); return EventResult.pass(); }); PlayerEvent.OPEN_MENU.register((player, menu) -> { @@ -224,15 +224,15 @@ public class DebugEvents { }); PlayerEvent.FILL_BUCKET.register(((player, level, stack, target) -> { TestMod.SINK.accept("%s used a bucket (%s) in %s%s while looking at %s", player.getScoreboardName(), stack, level.dimension().location(), logSide(level), target == null ? "nothing" : target.getLocation()); - return CompoundEventResult.pass(); + return InteractionResult.PASS; })); LightningEvent.STRIKE.register((bolt, level, pos, toStrike) -> { TestMod.SINK.accept(bolt.getScoreboardName() + " struck at " + toShortString(pos) + logSide(level)); }); - ChunkEvent.LOAD_DATA.register((chunk, level, nbt) -> { + ChunkEvent.LOAD_DATA.register((chunk, level) -> { // TestMod.SINK.accept("Chunk loaded at x=" + chunk.getPos().x + ", z=" + chunk.getPos().z + " in dimension '" + level.dimension().location() + "'"); }); - ChunkEvent.SAVE_DATA.register((chunk, level, nbt) -> { + ChunkEvent.SAVE_DATA.register((chunk, level) -> { // TestMod.SINK.accept("Chunk saved at x=" + chunk.getPos().x + ", z=" + chunk.getPos().z + " in dimension '" + level.dimension().location() + "'"); }); } @@ -359,11 +359,6 @@ public class DebugEvents { TestMod.SINK.accept("Screen has been changed to " + toSimpleName(screen)); return CompoundEventResult.pass(); }); - ClientTooltipEvent.RENDER_MODIFY_COLOR.register((matrices, x, y, context) -> { - context.setBackgroundColor(0xf0ffeded); - context.setOutlineGradientTopColor(0xf0ff5c5c); - context.setOutlineGradientBottomColor(0xf0f74d4d); - }); } private static String chunkPos(int x, int z) { diff --git a/testmod-common/src/main/java/dev/architectury/test/item/TestBlockInteractions.java b/testmod-common/src/main/java/dev/architectury/test/item/TestBlockInteractions.java index d10caa48..82c92334 100644 --- a/testmod-common/src/main/java/dev/architectury/test/item/TestBlockInteractions.java +++ b/testmod-common/src/main/java/dev/architectury/test/item/TestBlockInteractions.java @@ -41,7 +41,7 @@ public final class TestBlockInteractions { if (!ctx.getLevel().isClientSide) { Player player = ctx.getPlayer(); if (player != null) - player.sendSystemMessage(Component.literal("Thou has successfully committed the dark arts of alchemy!!")); + player.displayClientMessage(Component.literal("Thou has successfully committed the dark arts of alchemy!!"), false); } }, ctx -> { return Blocks.DIAMOND_BLOCK.defaultBlockState(); diff --git a/testmod-common/src/main/java/dev/architectury/test/networking/ButtonClickedMessage.java b/testmod-common/src/main/java/dev/architectury/test/networking/ButtonClickedMessage.java index c0828944..c1d81c1b 100644 --- a/testmod-common/src/main/java/dev/architectury/test/networking/ButtonClickedMessage.java +++ b/testmod-common/src/main/java/dev/architectury/test/networking/ButtonClickedMessage.java @@ -51,6 +51,6 @@ public class ButtonClickedMessage extends BaseC2SMessage { @Override public void handle(NetworkManager.PacketContext context) { - context.getPlayer().sendSystemMessage(Component.literal("You clicked button #" + buttonId)); + context.getPlayer().displayClientMessage(Component.literal("You clicked button #" + buttonId), false); } } \ No newline at end of file diff --git a/testmod-common/src/main/java/dev/architectury/test/networking/SyncDataMessage.java b/testmod-common/src/main/java/dev/architectury/test/networking/SyncDataMessage.java index ceb10afe..b6979287 100644 --- a/testmod-common/src/main/java/dev/architectury/test/networking/SyncDataMessage.java +++ b/testmod-common/src/main/java/dev/architectury/test/networking/SyncDataMessage.java @@ -54,6 +54,6 @@ public class SyncDataMessage extends BaseS2CMessage { @Override public void handle(NetworkManager.PacketContext context) { - context.getPlayer().sendSystemMessage(Component.literal("Received data from server: " + serverData)); + context.getPlayer().displayClientMessage(Component.literal("Received data from server: " + serverData), false); } } \ No newline at end of file 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 8a6cb112..f4f860d2 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 @@ -22,7 +22,6 @@ package dev.architectury.test.registry; import dev.architectury.core.fluid.ArchitecturyFluidAttributes; import dev.architectury.core.fluid.SimpleArchitecturyFluidAttributes; import dev.architectury.core.item.ArchitecturySpawnEggItem; -import dev.architectury.hooks.item.food.FoodPropertiesHooks; import dev.architectury.hooks.level.entity.EntityHooks; import dev.architectury.platform.Platform; import dev.architectury.registry.CreativeTabRegistry; @@ -37,8 +36,10 @@ import dev.architectury.test.recipes.TestRecipeSerializer; import dev.architectury.test.registry.objects.EquippableTickingItem; import dev.architectury.test.registry.objects.ItemWithTooltip; import net.minecraft.core.BlockPos; +import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectCategory; @@ -49,6 +50,8 @@ import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.component.Consumables; +import net.minecraft.world.item.consume_effects.ApplyStatusEffectsConsumeEffect; import net.minecraft.world.item.crafting.CustomRecipe; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; @@ -64,6 +67,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import java.lang.reflect.InvocationTargetException; +import java.util.List; import java.util.function.Supplier; import static dev.architectury.test.TestMod.SINK; @@ -109,27 +113,32 @@ public class TestRegistries { }); public static final RegistrySupplier TEST_ITEM = ITEMS.register("test_item", () -> - new Item(new Item.Properties().arch$tab(TestRegistries.TEST_TAB))); + new Item(new Item.Properties().arch$tab(TestRegistries.TEST_TAB).setId(id(Registries.ITEM, "test_item")))); public static final RegistrySupplier TEST_EQUIPPABLE = ITEMS.register("test_eqippable", () -> - new EquippableTickingItem(new Item.Properties().arch$tab(TestRegistries.TEST_TAB))); + new EquippableTickingItem(new Item.Properties().arch$tab(TestRegistries.TEST_TAB).setId(id(Registries.ITEM, "test_eqippable")))); public static final RegistrySupplier TEST_EDIBLE = ITEMS.register("test_edible", () -> { - FoodProperties.Builder fpBuilder = new FoodProperties.Builder().nutrition(8).saturationModifier(0.8F); - FoodPropertiesHooks.effect(fpBuilder, () -> new MobEffectInstance(TEST_EFFECT, 100), 1); - return new Item(new Item.Properties().food(fpBuilder.build()).arch$tab(TestRegistries.TEST_TAB)); + return new Item(new Item.Properties() + .food(new FoodProperties.Builder().nutrition(8).saturationModifier(0.8F).build(), + Consumables.defaultFood() + .onConsume( + new ApplyStatusEffectsConsumeEffect(List.of(new MobEffectInstance(TEST_EFFECT, 100, 1))) + ).build()) + .arch$tab(TestRegistries.TEST_TAB) + .setId(id(Registries.ITEM, "test_edible"))); }); public static final RegistrySupplier TEST_SPAWN_EGG = ITEMS.register("test_spawn_egg", () -> new ArchitecturySpawnEggItem(TestRegistries.TEST_ENTITY, 0xFF000000, 0xFFFFFFFF, - new Item.Properties().arch$tab(TestRegistries.TEST_TAB))); + new Item.Properties().arch$tab(TestRegistries.TEST_TAB).setId(id(Registries.ITEM, "test_spawn_egg")))); public static final RegistrySupplier TEST_SPAWN_EGG_2 = ITEMS.register("test_spawn_egg_2", () -> new ArchitecturySpawnEggItem(TestRegistries.TEST_ENTITY_2, 0xFFFFFFFF, 0xFF000000, - new Item.Properties().arch$tab(TestRegistries.TEST_TAB))); + new Item.Properties().arch$tab(TestRegistries.TEST_TAB).setId(id(Registries.ITEM, "test_spawn_egg_2")))); public static final RegistrySupplier TEST_FLUID_BUCKET = ITEMS.register("test_fluid_bucket", () -> { try { // In example mod the forge class isn't being replaced, this is not required in mods depending on architectury return (Item) Class.forName(!Platform.isForge() ? "dev.architectury.core.item.ArchitecturyBucketItem" : "dev.architectury.core.item.forge.imitator.ArchitecturyBucketItem") .getDeclaredConstructor(Supplier.class, Item.Properties.class) - .newInstance(TestRegistries.TEST_FLUID, new Item.Properties().arch$tab(TestRegistries.TEST_TAB)); + .newInstance(TestRegistries.TEST_FLUID, new Item.Properties().arch$tab(TestRegistries.TEST_TAB).setId(id(Registries.ITEM, "test_fluid_bucket"))); } catch (InstantiationException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { throw new RuntimeException(e); @@ -137,12 +146,12 @@ public class TestRegistries { }); public static final RegistrySupplier TEST_TOOLTIP = ITEMS.register("test_tooltip", - () -> new ItemWithTooltip(new Item.Properties().arch$tab(TestRegistries.TEST_TAB))); + () -> new ItemWithTooltip(new Item.Properties().arch$tab(TestRegistries.TEST_TAB).setId(id(Registries.ITEM, "test_tooltip")))); public static final RegistrySupplier TEST_BLOCK = BLOCKS.register("test_block", () -> - new Block(BlockBehaviour.Properties.ofLegacyCopy(Blocks.STONE))); + new Block(BlockBehaviour.Properties.ofLegacyCopy(Blocks.STONE).setId(id(Registries.BLOCK, "test_block")))); public static final RegistrySupplier COLLISION_BLOCK = BLOCKS.register("collision_block", () -> - new Block(BlockBehaviour.Properties.ofLegacyCopy(Blocks.STONE)) { + new Block(BlockBehaviour.Properties.ofLegacyCopy(Blocks.STONE).setId(id(Registries.BLOCK, "collision_block"))) { @Override public VoxelShape getCollisionShape(BlockState state, BlockGetter bg, BlockPos pos, CollisionContext ctx) { SINK.accept(EntityHooks.fromCollision(ctx) + " is colliding with " + state); @@ -155,7 +164,7 @@ public class TestRegistries { // In example mod the forge class isn't being replaced, this is not required in mods depending on architectury return (LiquidBlock) Class.forName(!Platform.isForge() ? "dev.architectury.core.block.ArchitecturyLiquidBlock" : "dev.architectury.core.block.forge.imitator.ArchitecturyLiquidBlock") .getDeclaredConstructor(Supplier.class, BlockBehaviour.Properties.class) - .newInstance(TestRegistries.TEST_FLUID, BlockBehaviour.Properties.ofLegacyCopy(Blocks.WATER).noCollission().strength(100.0F).noLootTable()); + .newInstance(TestRegistries.TEST_FLUID, BlockBehaviour.Properties.ofLegacyCopy(Blocks.WATER).noCollission().strength(100.0F).noLootTable().setId(id(Registries.BLOCK, "test_fluid"))); } catch (InstantiationException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { throw new RuntimeException(e); @@ -187,9 +196,9 @@ public class TestRegistries { }); public static final RegistrySupplier TEST_BLOCK_ITEM = ITEMS.register("test_block", () -> - new BlockItem(TEST_BLOCK.get(), new Item.Properties().arch$tab(TestRegistries.TEST_TAB))); + new BlockItem(TEST_BLOCK.get(), new Item.Properties().arch$tab(TestRegistries.TEST_TAB).setId(id(Registries.ITEM, "test_block")))); public static final RegistrySupplier COLLISION_BLOCK_ITEM = ITEMS.register("collision_block", () -> - new BlockItem(COLLISION_BLOCK.get(), new Item.Properties().arch$tab(TestRegistries.TEST_TAB))); + new BlockItem(COLLISION_BLOCK.get(), new Item.Properties().arch$tab(TestRegistries.TEST_TAB).setId(id(Registries.ITEM, "collision_block")))); public static final RegistrySupplier> TEST_ENTITY = ENTITY_TYPES.register("test_entity", TestEntity.TYPE); public static final RegistrySupplier> TEST_ENTITY_2 = ENTITY_TYPES.register("test_entity_2", TestEntity.TYPE_2); @@ -224,4 +233,8 @@ public class TestRegistries { System.out.println("Registered recipe type!"); }); } + + private static ResourceKey id(ResourceKey> key, String string) { + return ResourceKey.create(key, ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, string)); + } } diff --git a/testmod-common/src/main/java/dev/architectury/test/registry/objects/EquippableTickingItem.java b/testmod-common/src/main/java/dev/architectury/test/registry/objects/EquippableTickingItem.java index 69a7092e..100dabea 100644 --- a/testmod-common/src/main/java/dev/architectury/test/registry/objects/EquippableTickingItem.java +++ b/testmod-common/src/main/java/dev/architectury/test/registry/objects/EquippableTickingItem.java @@ -35,7 +35,7 @@ public class EquippableTickingItem extends Item implements ItemExtension { @Override public void tickArmor(ItemStack stack, Player player) { - TestMod.SINK.accept("Ticking " + Component.translatable(stack.getDescriptionId()).getString()); + TestMod.SINK.accept("Ticking " + Component.translatable(stack.getItem().getDescriptionId()).getString()); } @Nullable diff --git a/testmod-common/src/main/java/dev/architectury/test/registry/objects/ItemWithTooltip.java b/testmod-common/src/main/java/dev/architectury/test/registry/objects/ItemWithTooltip.java index f983d8b4..6f53ed62 100644 --- a/testmod-common/src/main/java/dev/architectury/test/registry/objects/ItemWithTooltip.java +++ b/testmod-common/src/main/java/dev/architectury/test/registry/objects/ItemWithTooltip.java @@ -42,13 +42,13 @@ public class ItemWithTooltip extends Item { } public record MyTooltipComponent(int count) implements TooltipComponent { - + } @Environment(EnvType.CLIENT) public record MyClientTooltipComponent(MyTooltipComponent component) implements ClientTooltipComponent { @Override - public int getHeight() { + public int getHeight(Font font) { return 100; } @@ -58,10 +58,10 @@ public class ItemWithTooltip extends Item { } @Override - public void renderImage(Font font, int x, int y, GuiGraphics graphics) { + public void renderImage(Font font, int x, int y, int w, int h, GuiGraphics graphics) { graphics.pose().pushPose(); graphics.pose().translate(0, 0, 400); - graphics.drawString(font, "Count: " + component.count, x + getWidth(font) / 2, y + (getHeight() - font.lineHeight) / 2, 0xFF00FF00); + graphics.drawString(font, "Count: " + component.count, x + getWidth(font) / 2, y + (getHeight(font) - font.lineHeight) / 2, 0xFF00FF00); graphics.pose().popPose(); } } diff --git a/testmod-common/src/main/resources/architectury.common.json b/testmod-common/src/main/resources/architectury.common.json index e1535b2d..bbead642 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_4174$class_4175": [ - "dev/architectury/extensions/injected/InjectedFoodPropertiesBuilderExtension" - ], "net/minecraft/class_2404": [ "dev/architectury/extensions/injected/InjectedLiquidBlockExtension" ]