diff --git a/gradle.properties b/gradle.properties index df505016..39dae480 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,10 +9,10 @@ maven_version=3.4.9 maven_description=Fabric mod to connect to EVERY Minecraft server version (Release, Beta, Alpha, Classic, Snapshots, Bedrock) with QoL fixes to the gameplay # Minecraft/Fabric -minecraft_version=1.21.1 -yarn_version=1.21.1+build.3 +minecraft_version=1.21.2 +yarn_version=1.21.2+build.1 loader_version=0.16.7 -fabric_api_version=0.105.0+1.21.1 +fabric_api_version=0.106.1+1.21.2 # Set to empty to use the Minecraft version above -supported_versions=>=1.21 <=1.21.1 \ No newline at end of file +supported_versions=1.21.2 diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/data/EntityDimensionDiff.java b/src/main/java/de/florianmichael/viafabricplus/fixes/data/EntityDimensionDiff.java index 85de5b3b..d5a6e2e8 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/data/EntityDimensionDiff.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/data/EntityDimensionDiff.java @@ -71,9 +71,9 @@ public class EntityDimensionDiff { ProtocolVersion.v1_7_6, EntityDimensionsBuilder.create(EntityType.OCELOT).withChangingDimensions(0.6F, 0.8F).build(), ProtocolVersion.v1_8, EntityType.OCELOT.getDimensions() ), - EntityType.BOAT, linkedHashMap( - ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.BOAT).withChangingDimensions(1.5F, 0.6F).build(), - ProtocolVersion.v1_9, EntityType.BOAT.getDimensions() + EntityType.OAK_BOAT, linkedHashMap( + ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.OAK_BOAT).withChangingDimensions(1.5F, 0.6F).build(), + ProtocolVersion.v1_9, EntityType.OAK_BOAT.getDimensions() ), EntityType.CREEPER, linkedHashMap( ProtocolVersion.v1_8, EntityDimensionsBuilder.create(EntityType.CREEPER).withChangingDimensions(0.6F, 1.8F).build(), diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/AddBannerPatternRecipe.java b/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/AddBannerPatternRecipe.java index 4b513383..214c8c54 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/AddBannerPatternRecipe.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/AddBannerPatternRecipe.java @@ -29,7 +29,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.recipe.RecipeSerializer; import net.minecraft.recipe.SpecialCraftingRecipe; -import net.minecraft.recipe.SpecialRecipeSerializer; import net.minecraft.recipe.book.CraftingRecipeCategory; import net.minecraft.recipe.input.CraftingRecipeInput; import net.minecraft.registry.RegistryKeys; @@ -48,7 +47,7 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe { @Override public boolean matches(CraftingRecipeInput inv, World world) { boolean foundBanner = false; - for (int i = 0; i < inv.getSize(); i++) { + for (int i = 0; i < inv.size(); i++) { ItemStack stack = inv.getStackInSlot(i); if (stack.getItem() instanceof BannerItem) { if (foundBanner) @@ -65,7 +64,7 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe { public ItemStack craft(CraftingRecipeInput inv, RegistryWrapper.WrapperLookup lookup) { ItemStack result = ItemStack.EMPTY; - for (int i = 0; i < inv.getSize(); i++) { + for (int i = 0; i < inv.size(); i++) { ItemStack stack = inv.getStackInSlot(i); if (!stack.isEmpty() && stack.getItem() instanceof BannerItem) { result = stack.copy(); @@ -76,9 +75,9 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe { final BannerPattern_1_13_2 pattern = getBannerPattern(inv); if (pattern != null) { - final var patternKey = lookup.getWrapperOrThrow(RegistryKeys.BANNER_PATTERN).getOrThrow(pattern.getKey()); + final var patternKey = lookup.getOrThrow(RegistryKeys.BANNER_PATTERN).getOrThrow(pattern.getKey()); DyeColor color = ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2) ? DyeColor.BLACK : DyeColor.WHITE; - for (int i = 0; i < inv.getSize(); i++) { + for (int i = 0; i < inv.size(); i++) { Item item = inv.getStackInSlot(i).getItem(); if (item instanceof DyeItem dyeItem) { color = dyeItem.getColor(); @@ -96,11 +95,6 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe { return result; } - @Override - public boolean fits(int width, int height) { - return width >= 3 && height >= 3; - } - @Override public RecipeSerializer getSerializer() { return SERIALIZER; @@ -115,7 +109,7 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe { if (pattern.hasBaseStack()) { boolean foundBaseItem = false; boolean foundDye = false; - for (int i = 0; i < inv.getSize(); i++) { + for (int i = 0; i < inv.size(); i++) { ItemStack stack = inv.getStackInSlot(i); if (!stack.isEmpty() && !(stack.getItem() instanceof BannerItem)) { if (stack.getItem() instanceof DyeItem) { @@ -134,9 +128,9 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe { } } if (!foundBaseItem || (!foundDye && ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_10))) matches = false; - } else if (inv.getSize() == pattern.getRecipePattern().length * pattern.getRecipePattern()[0].length()) { + } else if (inv.size() == pattern.getRecipePattern().length * pattern.getRecipePattern()[0].length()) { DyeColor patternColor = null; - for (int i = 0; i < inv.getSize(); i++) { + for (int i = 0; i < inv.size(); i++) { int row = i / 3; int col = i % 3; ItemStack stack = inv.getStackInSlot(i); diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/BoatModel1_8.java b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/BoatModel1_8.java index 1ebd9dad..773f51f1 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/BoatModel1_8.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/BoatModel1_8.java @@ -19,23 +19,21 @@ package de.florianmichael.viafabricplus.fixes.versioned.visual; -import com.google.common.collect.ImmutableList; import net.minecraft.client.model.*; -import net.minecraft.client.render.entity.model.CompositeEntityModel; +import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.client.render.entity.model.EntityModelLayer; -import net.minecraft.entity.vehicle.BoatEntity; +import net.minecraft.client.render.entity.state.BoatEntityRenderState; import net.minecraft.util.Identifier; /** * Model for boats in 1.8 and lower. */ -public class BoatModel1_8 extends CompositeEntityModel { +public class BoatModel1_8 extends EntityModel { public static final EntityModelLayer MODEL_LAYER = new EntityModelLayer(Identifier.of("viafabricplus", "boat1_8"), "main"); - private final ImmutableList parts; public BoatModel1_8(ModelPart root) { - this.parts = ImmutableList.of(root.getChild("bottom"), root.getChild("back"), root.getChild("front"), root.getChild("right"), root.getChild("left")); + super(root); } public static TexturedModelData getTexturedModelData() { @@ -54,12 +52,7 @@ public class BoatModel1_8 extends CompositeEntityModel { } @Override - public Iterable getParts() { - return parts; - } - - @Override - public void setAngles(BoatEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) { + public void setAngles(BoatEntityRenderState state) { } } diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/BoatRenderer1_8.java b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/BoatRenderer1_8.java index 37800dc6..6ec3f161 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/BoatRenderer1_8.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/BoatRenderer1_8.java @@ -20,12 +20,14 @@ package de.florianmichael.viafabricplus.fixes.versioned.visual; import net.minecraft.client.render.OverlayTexture; +import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.EntityRenderer; +import net.minecraft.client.render.entity.AbstractBoatEntityRenderer; import net.minecraft.client.render.entity.EntityRendererFactory; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.render.entity.state.BoatEntityRenderState; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RotationAxis; @@ -33,7 +35,7 @@ import net.minecraft.util.math.RotationAxis; /** * Renderer for boats in 1.8 and lower. */ -public class BoatRenderer1_8 extends EntityRenderer { +public class BoatRenderer1_8 extends AbstractBoatEntityRenderer { private static final Identifier TEXTURE = Identifier.of("viafabricplus", "textures/boat1_8.png"); private final BoatModel1_8 model; @@ -45,33 +47,32 @@ public class BoatRenderer1_8 extends EntityRenderer { } @Override - public Identifier getTexture(BoatEntity entity) { - return TEXTURE; + protected EntityModel getModel() { + return this.model; } @Override - public void render(BoatEntity entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) { + protected RenderLayer getRenderLayer() { + return this.model.getLayer(TEXTURE); + } + + @Override + public void render(BoatEntityRenderState state, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) { matrices.push(); matrices.translate(0, 0.25, 0); - matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180 - yaw)); + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180 - state.yaw)); - float damageWobbleTicks = entity.getDamageWobbleTicks() - tickDelta; - float damageWobbleStrength = entity.getDamageWobbleStrength() - tickDelta; - - if (damageWobbleStrength < 0) { - damageWobbleStrength = 0; - } - if (damageWobbleTicks > 0) { - matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(MathHelper.sin(damageWobbleTicks) * damageWobbleTicks * damageWobbleStrength / 10 * entity.getDamageWobbleSide())); + if (state.damageWobbleTicks > 0) { + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(MathHelper.sin(state.damageWobbleTicks) * state.damageWobbleTicks * state.damageWobbleStrength / 10 * state.damageWobbleSide)); } matrices.scale(-1, -1, 1); - model.setAngles(entity, tickDelta, 0, -0.1f, 0, 0); + model.setAngles(state); VertexConsumer vertexConsumer = vertexConsumers.getBuffer(model.getLayer(TEXTURE)); model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV); matrices.pop(); - super.render(entity, yaw, tickDelta, matrices, vertexConsumers, light); + super.render(state, matrices, vertexConsumers, light); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/BuiltinEmptyGlyph1_12_2.java b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/BuiltinEmptyGlyph1_12_2.java index db9a526e..4daa3f63 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/BuiltinEmptyGlyph1_12_2.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/BuiltinEmptyGlyph1_12_2.java @@ -19,8 +19,8 @@ package de.florianmichael.viafabricplus.fixes.versioned.visual; +import net.minecraft.client.font.BakedGlyph; import net.minecraft.client.font.Glyph; -import net.minecraft.client.font.GlyphRenderer; import net.minecraft.client.font.RenderableGlyph; import java.util.function.Function; @@ -41,7 +41,7 @@ public enum BuiltinEmptyGlyph1_12_2 implements Glyph { } @Override - public GlyphRenderer bake(Function glyphRendererGetter) { + public BakedGlyph bake(Function glyphRendererGetter) { return glyphRendererGetter.apply(new RenderableGlyph() { @Override diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinClientWorld.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinClientWorld.java index afabe394..11e3adf7 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinClientWorld.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinClientWorld.java @@ -22,9 +22,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft; import de.florianmichael.viafabricplus.fixes.versioned.PendingUpdateManager1_18_2; import de.florianmichael.viafabricplus.injection.access.IEntity; import de.florianmichael.viafabricplus.settings.impl.DebugSettings; -import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PendingUpdateManager; -import net.minecraft.client.render.WorldRenderer; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; @@ -33,7 +31,7 @@ import net.minecraft.registry.Registries; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.profiler.Profiler; +import net.minecraft.util.profiler.Profilers; import net.minecraft.world.EntityList; import net.minecraft.world.MutableWorldProperties; import net.minecraft.world.World; @@ -43,8 +41,6 @@ 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; - @Mixin(value = ClientWorld.class, priority = 900) public abstract class MixinClientWorld extends World { @@ -57,12 +53,12 @@ public abstract class MixinClientWorld extends World { @Final private PendingUpdateManager pendingUpdateManager; - protected MixinClientWorld(MutableWorldProperties properties, RegistryKey registryRef, DynamicRegistryManager registryManager, RegistryEntry dimensionEntry, Supplier profiler, boolean isClient, boolean debugWorld, long biomeAccess, int maxChainedNeighborUpdates) { - super(properties, registryRef, registryManager, dimensionEntry, profiler, isClient, debugWorld, biomeAccess, maxChainedNeighborUpdates); + protected MixinClientWorld(MutableWorldProperties properties, RegistryKey registryRef, DynamicRegistryManager registryManager, RegistryEntry dimensionEntry, boolean isClient, boolean debugWorld, long seed, int maxChainedNeighborUpdates) { + super(properties, registryRef, registryManager, dimensionEntry, isClient, debugWorld, seed, maxChainedNeighborUpdates); } @Inject(method = "", at = @At("RETURN")) - private void removePendingUpdateManager(ClientPlayNetworkHandler networkHandler, ClientWorld.Properties properties, RegistryKey registryRef, RegistryEntry dimensionTypeEntry, int loadDistance, int simulationDistance, Supplier profiler, WorldRenderer worldRenderer, boolean debugWorld, long seed, CallbackInfo ci) { + private void removePendingUpdateManager(CallbackInfo ci) { if (DebugSettings.global().disableSequencing.isEnabled()) { this.pendingUpdateManager = new PendingUpdateManager1_18_2(); } @@ -78,9 +74,9 @@ public abstract class MixinClientWorld extends World { final IEntity mixinEntity = (IEntity) entity; if (mixinEntity.viaFabricPlus$isInLoadedChunkAndShouldTick() || entity.isSpectator()) { entity.age++; - this.getProfiler().push(() -> Registries.ENTITY_TYPE.getId(entity.getType()).toString()); + Profilers.get().push(() -> Registries.ENTITY_TYPE.getId(entity.getType()).toString()); entity.tick(); - this.getProfiler().pop(); + Profilers.get().pop(); } this.viaFabricPlus$checkChunk(entity); @@ -120,7 +116,6 @@ public abstract class MixinClientWorld extends World { @Unique private void viaFabricPlus$checkChunk(Entity entity) { - this.getProfiler().push("chunkCheck"); final IEntity mixinEntity = (IEntity) entity; final int chunkX = MathHelper.floor(entity.getX() / 16.0D); final int chunkZ = MathHelper.floor(entity.getZ() / 16.0D); @@ -129,7 +124,6 @@ public abstract class MixinClientWorld extends World { mixinEntity.viaFabricPlus$setInLoadedChunkAndShouldTick(true); } } - this.getProfiler().pop(); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinGameRenderer.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinGameRenderer.java index a4762f09..fa8dfbb5 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinGameRenderer.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinGameRenderer.java @@ -40,7 +40,7 @@ public abstract class MixinGameRenderer { @Shadow @Final - MinecraftClient client; + private MinecraftClient client; @ModifyExpressionValue(method = "findCrosshairTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;raycast(DFZ)Lnet/minecraft/util/hit/HitResult;")) private HitResult bedrockReachAroundRaycast(HitResult hitResult) { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractSignBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractSignBlock.java index cf4a8a8f..846515e3 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractSignBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractSignBlock.java @@ -28,8 +28,8 @@ import net.minecraft.item.DyeItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.ItemActionResult; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -42,14 +42,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; public abstract class MixinAbstractSignBlock { @Inject(method = "onUseWithItem", at = @At("HEAD"), cancellable = true) - private void changeInteractionCalculation(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { + private void changeInteractionCalculation(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if (!world.isClient) { return; } if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) { // <= 1.14.4 doesn't have any sign interactions. - cir.setReturnValue(ItemActionResult.SUCCESS); + cir.setReturnValue(ActionResult.SUCCESS); } else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_4)) { // Removes the isWaxed() condition and reverts the interaction changes from 1.19.4 -> 1.20 when signs // got a front and back side. @@ -57,7 +57,7 @@ public abstract class MixinAbstractSignBlock { final Item item = itemStack.getItem(); final boolean isSuccess = (item instanceof DyeItem || itemStack.isOf(Items.GLOW_INK_SAC) || itemStack.isOf(Items.INK_SAC)) && player.canModifyBlocks(); - cir.setReturnValue(isSuccess ? ItemActionResult.SUCCESS : ItemActionResult.CONSUME); + cir.setReturnValue(isSuccess ? ActionResult.SUCCESS : ActionResult.CONSUME); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAnvilBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAnvilBlock.java index 4e3cb814..5b8e91f3 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAnvilBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAnvilBlock.java @@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.block.*; -import net.minecraft.state.property.DirectionProperty; +import net.minecraft.state.property.EnumProperty; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.shape.VoxelShape; @@ -47,7 +47,7 @@ public abstract class MixinAnvilBlock extends FallingBlock { @Shadow @Final - public static DirectionProperty FACING; + public static EnumProperty FACING; public MixinAnvilBlock(Settings settings) { super(settings); @@ -66,11 +66,11 @@ public abstract class MixinAnvilBlock extends FallingBlock { } @Override - public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) { + protected VoxelShape getCullingShape(BlockState state) { // Workaround for https://github.com/ViaVersion/ViaFabricPlus/issues/246 // MoreCulling is caching the culling shape and doesn't reload it, so we have to force vanilla's shape here. viaFabricPlus$requireOriginalShape = true; - return super.getCullingShape(state, world, pos); + return super.getCullingShape(state); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinBedBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinBedBlock.java index 3861ec0b..0e815ba8 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinBedBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinBedBlock.java @@ -64,11 +64,11 @@ public abstract class MixinBedBlock extends HorizontalFacingBlock { } @Override - public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) { + public VoxelShape getCullingShape(BlockState state) { // Workaround for https://github.com/ViaVersion/ViaFabricPlus/issues/246 // MoreCulling is caching the culling shape and doesn't reload it, so we have to force vanilla's shape here. viaFabricPlus$requireOriginalShape = true; - return super.getCullingShape(state, world, pos); + return super.getCullingShape(state); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinCauldronBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinCauldronBlock.java index 1d5ac418..813eba06 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinCauldronBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinCauldronBlock.java @@ -60,11 +60,11 @@ public abstract class MixinCauldronBlock extends AbstractCauldronBlock { } @Override - public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) { + public VoxelShape getCullingShape(BlockState state) { // Workaround for https://github.com/ViaVersion/ViaFabricPlus/issues/246 // MoreCulling is caching the culling shape and doesn't reload it, so we have to force vanilla's shape here. viaFabricPlus$requireOriginalShape = true; - return super.getCullingShape(state, world, pos); + return super.getCullingShape(state); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinChestBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinChestBlock.java index 0d269f47..eda479f6 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinChestBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinChestBlock.java @@ -76,7 +76,7 @@ public abstract class MixinChestBlock extends AbstractChestBlock cir) { + private void alwaysPass(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_2)) { - cir.setReturnValue(ItemActionResult.SKIP_DEFAULT_BLOCK_INTERACTION); + cir.setReturnValue(ActionResult.PASS); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinEnderChestBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinEnderChestBlock.java index d5a59eaf..79978a9c 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinEnderChestBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinEnderChestBlock.java @@ -55,11 +55,11 @@ public abstract class MixinEnderChestBlock extends BlockWithEntity { } @Override - public VoxelShape getCullingShape(BlockState state, BlockView view, BlockPos pos) { + public VoxelShape getCullingShape(BlockState state) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) { return SHAPE; } else { - return super.getCullingShape(state, view, pos); + return super.getCullingShape(state); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinFarmlandBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinFarmlandBlock.java index 5cb29213..1f78c735 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinFarmlandBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinFarmlandBlock.java @@ -55,11 +55,11 @@ public abstract class MixinFarmlandBlock extends Block { } @Override - public VoxelShape getCullingShape(BlockState state, BlockView view, BlockPos pos) { + public VoxelShape getCullingShape(BlockState state) { if (ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_9_3)) { return SHAPE; } else { - return super.getCullingShape(state, view, pos); + return super.getCullingShape(state); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinFenceBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinFenceBlock.java index adc1ef30..918b8677 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinFenceBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinFenceBlock.java @@ -22,7 +22,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.block.*; -import net.minecraft.util.ItemActionResult; +import net.minecraft.util.ActionResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; @@ -52,9 +52,9 @@ public abstract class MixinFenceBlock extends HorizontalConnectingBlock { } @Inject(method = "onUseWithItem", at = @At("HEAD"), cancellable = true) - private void alwaysSuccess(CallbackInfoReturnable cir) { + private void alwaysSuccess(CallbackInfoReturnable cir) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_10)) { - cir.setReturnValue(ItemActionResult.SUCCESS); + cir.setReturnValue(ActionResult.SUCCESS); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinHopperBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinHopperBlock.java index 913013e6..06608ade 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinHopperBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinHopperBlock.java @@ -67,10 +67,10 @@ public abstract class MixinHopperBlock extends BlockWithEntity { } @Override - public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) { + public VoxelShape getCullingShape(BlockState state) { // Workaround for https://github.com/ViaVersion/ViaFabricPlus/issues/45 viaFabricPlus$requireOriginalShape = true; - return super.getCullingShape(state, world, pos); + return super.getCullingShape(state); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinNoteBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinNoteBlock.java index 381229a9..4e6f0041 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinNoteBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinNoteBlock.java @@ -22,7 +22,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.block.NoteBlock; -import net.minecraft.util.ItemActionResult; +import net.minecraft.util.ActionResult; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -32,9 +32,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; public abstract class MixinNoteBlock { @Inject(method = "onUseWithItem", at = @At("HEAD"), cancellable = true) - private void cancelMobHeadUsage(CallbackInfoReturnable cir) { + private void cancelMobHeadUsage(CallbackInfoReturnable cir) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_4)) { - cir.setReturnValue(ItemActionResult.SUCCESS); + cir.setReturnValue(ActionResult.SUCCESS); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinPistonBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinPistonBlock.java index 7c5f0fd1..cb284a33 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinPistonBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinPistonBlock.java @@ -75,7 +75,7 @@ public abstract class MixinPistonBlock extends FacingBlock { } @Override - public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) { + public VoxelShape getCullingShape(BlockState state) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_1)) { if (state.get(PistonBlock.EXTENDED)) { return switch (state.get(FACING)) { @@ -90,7 +90,7 @@ public abstract class MixinPistonBlock extends FacingBlock { return VoxelShapes.fullCube(); } } else { - return super.getCullingShape(state, world, pos); + return super.getCullingShape(state); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinWallBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinWallBlock.java index b6abd416..1f019c20 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinWallBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinWallBlock.java @@ -99,11 +99,11 @@ public abstract class MixinWallBlock extends Block { } @Override - public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) { + public VoxelShape getCullingShape(BlockState state) { if (state.get(WallBlock.UP) && ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) { return this.shapeMap.get(state); } else { - return super.getCullingShape(state, world, pos); + return super.getCullingShape(state); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinBoatEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAbstractBoatEntity.java similarity index 98% rename from src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinBoatEntity.java rename to src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAbstractBoatEntity.java index ce644e16..ad20e63a 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinBoatEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAbstractBoatEntity.java @@ -30,6 +30,7 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.MovementType; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.vehicle.AbstractBoatEntity; import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.entity.vehicle.VehicleEntity; import net.minecraft.particle.ParticleTypes; @@ -51,8 +52,8 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(BoatEntity.class) -public abstract class MixinBoatEntity extends VehicleEntity { +@Mixin(AbstractBoatEntity.class) +public abstract class MixinAbstractBoatEntity extends VehicleEntity { @Shadow private double x; @@ -72,9 +73,6 @@ public abstract class MixinBoatEntity extends VehicleEntity { @Shadow private BoatEntity.Location location; - @Shadow - public abstract LivingEntity getControllingPassenger(); - @Unique private double viaFabricPlus$speedMultiplier = 0.07D; @@ -84,8 +82,8 @@ public abstract class MixinBoatEntity extends VehicleEntity { @Unique private Vec3d viaFabricPlus$boatVelocity = Vec3d.ZERO; - public MixinBoatEntity(EntityType type, World world) { - super(type, world); + public MixinAbstractBoatEntity(EntityType entityType, World world) { + super(entityType, world); } @Redirect(method = "interact", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/vehicle/VehicleEntity;interact(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;")) diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityRenderDispatcher.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityRenderDispatcher.java index 9a8e0f86..a0ec9b92 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityRenderDispatcher.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntityRenderDispatcher.java @@ -35,7 +35,6 @@ 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.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(EntityRenderDispatcher.class) public abstract class MixinEntityRenderDispatcher { @@ -50,9 +49,9 @@ public abstract class MixinEntityRenderDispatcher { @SuppressWarnings("unchecked") @Inject(method = "getRenderer", at = @At("HEAD"), cancellable = true) - private void useBoatRenderer1_8(T entity, CallbackInfoReturnable> ci) { + private void useBoatRenderer1_8(T entity, CallbackInfoReturnable> cir) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8) && entity instanceof BoatEntity) { - ci.setReturnValue((EntityRenderer) viaFabricPlus$boatRenderer); + cir.setReturnValue((EntityRenderer) viaFabricPlus$boatRenderer); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java index 3c78bdc2..2bff637e 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java @@ -25,10 +25,8 @@ import net.minecraft.component.type.AttributeModifiersComponent; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ArmorItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; import net.minecraft.world.World; import net.raphimc.vialegacy.api.LegacyProtocolVersion; import org.spongepowered.asm.mixin.Mixin; @@ -44,9 +42,9 @@ public abstract class MixinArmorItem extends Item { } @Inject(method = "use", at = @At("HEAD"), cancellable = true) - private void disableRightClick(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> cir) { + private void disableRightClick(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable cir) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_6tor1_4_7)) { - cir.setReturnValue(new TypedActionResult<>(ActionResult.FAIL, user.getStackInHand(hand))); + cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBowItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBowItem.java index 30b008ee..6373ae8b 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBowItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBowItem.java @@ -23,9 +23,9 @@ import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BowItem; import net.minecraft.item.ItemStack; +import net.minecraft.item.consume.UseAction; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; -import net.minecraft.util.UseAction; import net.minecraft.world.World; import net.raphimc.vialegacy.api.LegacyProtocolVersion; import org.spongepowered.asm.mixin.Mixin; @@ -51,15 +51,14 @@ public abstract class MixinBowItem { } @Inject(method = "use", at = @At("HEAD"), cancellable = true) - private void makeInstantUsable(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> cir) { + private void makeInstantUsable(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable cir) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_7tob1_7_3)) { - final ItemStack stack = user.getStackInHand(hand); - final ItemStack arrowStack = user.getProjectileType(stack); + final ItemStack arrowStack = user.getProjectileType(user.getStackInHand(hand)); if (arrowStack.isEmpty()) { - cir.setReturnValue(TypedActionResult.fail(stack)); + cir.setReturnValue(ActionResult.FAIL); } else { arrowStack.decrement(1); - cir.setReturnValue(TypedActionResult.pass(stack)); + cir.setReturnValue(ActionResult.PASS); } } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinEnderPearlItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinEnderPearlItem.java index d1dea215..e4f972d3 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinEnderPearlItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinEnderPearlItem.java @@ -23,9 +23,8 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnderPearlItem; -import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -36,9 +35,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; public abstract class MixinEnderPearlItem { @Inject(method = "use", at = @At("HEAD"), cancellable = true) - private void removeCreativeModeEnderPearl(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> ci) { + private void removeCreativeModeEnderPearl(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable ci) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8) && user.getAbilities().creativeMode) { - ci.setReturnValue(TypedActionResult.pass(user.getStackInHand(hand))); + ci.setReturnValue(ActionResult.PASS); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinFishingRodItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinFishingRodItem.java index 39a253a6..617cf49b 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinFishingRodItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinFishingRodItem.java @@ -23,9 +23,8 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.FishingRodItem; -import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -36,7 +35,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; public abstract class MixinFishingRodItem { @Inject(method = "use", at = @At("RETURN")) - private void swingHand(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> cir) { + private void swingHand(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable cir) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) { user.swingHand(hand); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemCooldownManager.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemCooldownManager.java index e4ced24e..e33fe557 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemCooldownManager.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemCooldownManager.java @@ -21,7 +21,6 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; import de.florianmichael.viafabricplus.settings.impl.DebugSettings; import net.minecraft.entity.player.ItemCooldownManager; -import net.minecraft.item.Item; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -30,8 +29,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(value = ItemCooldownManager.class) public abstract class MixinItemCooldownManager { - @Inject(method = "set", at = @At("HEAD"), cancellable = true) - private void dontSetCooldown(Item item, int duration, CallbackInfo ci) { + @Inject(method = "set(Lnet/minecraft/util/Identifier;I)V", at = @At("HEAD"), cancellable = true) + private void dontSetCooldown(CallbackInfo ci) { if (DebugSettings.global().removeCooldowns.isEnabled()) { ci.cancel(); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemRenderer.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemRenderer.java index d8f0f457..f5950694 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemRenderer.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemRenderer.java @@ -41,7 +41,7 @@ public abstract class MixinItemRenderer { @Final private ItemModels models; - @Inject(method = "getModel", at = @At("HEAD"), cancellable = true) + @Inject(method = "getModel(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;I)Lnet/minecraft/client/render/model/BakedModel;", at = @At("HEAD"), cancellable = true) private void removeModel(ItemStack stack, World world, LivingEntity entity, int seed, CallbackInfoReturnable cir) { if (VisualSettings.global().replacePetrifiedOakSlab.isEnabled() && world != null /* world is null in gui rendering */ && stack.isOf(Items.PETRIFIED_OAK_SLAB)) { cir.setReturnValue(this.models.getModelManager().getMissingModel()); diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java index 03c4ad67..52ef9ee0 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java @@ -38,7 +38,9 @@ import net.minecraft.item.tooltip.TooltipType; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtList; -import net.minecraft.registry.*; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.text.Text; import net.minecraft.util.math.MathHelper; @@ -115,7 +117,7 @@ public abstract class MixinItemStack { value.ifPresent(e -> { final int lvl = enchantment.getInt("lvl"); if (registryLookup != null) { - final Optional> v = registryLookup.getWrapperOrThrow(RegistryKeys.ENCHANTMENT).getOptional(e); + final Optional> v = registryLookup.getOrThrow(RegistryKeys.ENCHANTMENT).getOptional(e); v.ifPresent(enchantmentReference -> tooltip.accept(Enchantment.getName(enchantmentReference, MathHelper.clamp(lvl, Short.MIN_VALUE, Short.MAX_VALUE)))); } }); diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java index 2d8edf10..6dca780a 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java @@ -22,30 +22,28 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.SwordItem; -import net.minecraft.item.ToolItem; -import net.minecraft.item.ToolMaterial; +import net.minecraft.item.consume.UseAction; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; -import net.minecraft.util.UseAction; import net.minecraft.world.World; import net.raphimc.vialegacy.api.LegacyProtocolVersion; import org.spongepowered.asm.mixin.Mixin; @Mixin(SwordItem.class) -public abstract class MixinSwordItem extends ToolItem { +public abstract class MixinSwordItem extends Item { - public MixinSwordItem(ToolMaterial material, Settings settings) { - super(material, settings); + public MixinSwordItem(Settings settings) { + super(settings); } @Override - public TypedActionResult use(World world, PlayerEntity user, Hand hand) { + public ActionResult use(World world, PlayerEntity user, Hand hand) { if (ProtocolTranslator.getTargetVersion().betweenInclusive(LegacyProtocolVersion.b1_8tob1_8_1, ProtocolVersion.v1_8)) { - ItemStack itemStack = user.getStackInHand(hand); user.setCurrentHand(hand); - return TypedActionResult.success(itemStack); + return ActionResult.SUCCESS; } else { return super.use(world, user, hand); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java index 6cc121fc..4d1b98db 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java @@ -57,7 +57,6 @@ import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.screen.slot.SlotActionType; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -74,6 +73,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.List; +import java.util.Objects; @SuppressWarnings("DataFlowIssue") @Mixin(ClientPlayerInteractionManager.class) @@ -114,7 +114,7 @@ public abstract class MixinClientPlayerInteractionManager implements IClientPlay @Inject(method = "interactItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;syncSelectedSlot()V", shift = At.Shift.AFTER)) private void sendPlayerPosPacket(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { if (ProtocolTranslator.getTargetVersion().betweenInclusive(ProtocolVersion.v1_17, ProtocolVersion.v1_20_5)) { - this.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(player.getX(), player.getY(), player.getZ(), player.getYaw(), player.getPitch(), player.isOnGround())); + this.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(player.getX(), player.getY(), player.getZ(), player.getYaw(), player.getPitch(), player.isOnGround(), player.horizontalCollision)); } } @@ -230,21 +230,26 @@ public abstract class MixinClientPlayerInteractionManager implements IClientPlay } } - @Redirect(method = "method_41929", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;use(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/TypedActionResult;")) - private TypedActionResult eitherSuccessOrPass(ItemStack instance, World world, PlayerEntity user, Hand hand, @Local ItemStack itemStack) { + @Redirect(method = "method_41929", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;use(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;")) + private ActionResult eitherSuccessOrPass(ItemStack instance, World world, PlayerEntity user, Hand hand, @Local ItemStack itemStack) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) { final int count = instance.getCount(); - final TypedActionResult action = instance.use(world, user, hand); - final ItemStack output = action.getValue(); + final ActionResult actionResult = instance.use(world, user, hand); + final ItemStack output; + if (actionResult instanceof ActionResult.Success success) { + output = Objects.requireNonNullElseGet(success.getNewHandStack(), () -> user.getStackInHand(hand)); + } else { + output = user.getStackInHand(hand); + } // In <= 1.8, ActionResult weren't a thing and interactItem simply returned either true or false // depending on if the input and output item are equal or not final boolean accepted = !output.isEmpty() && (output != itemStack || output.getCount() != count); - if (action.getResult().isAccepted() == accepted) { - return action; + if (actionResult.isAccepted() == accepted) { + return actionResult; } else { - return accepted ? TypedActionResult.success(output) : TypedActionResult.pass(output); + return accepted ? ActionResult.SUCCESS.withNewHandStack(output) : ActionResult.PASS; } } else { return instance.use(world, user, hand); diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinAbstractSignEditScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinAbstractSignEditScreen.java index 6452af00..4e7f1af0 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinAbstractSignEditScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinAbstractSignEditScreen.java @@ -35,7 +35,7 @@ public abstract class MixinAbstractSignEditScreen { @Shadow @Final - private SignBlockEntity blockEntity; + protected SignBlockEntity blockEntity; @Inject(method = "canEdit", at = @At("HEAD"), cancellable = true) private void dontCloseTooFarAwaySigns(CallbackInfoReturnable cir) { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinCraftingScreenHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinCraftingScreenHandler.java index 29aa7ade..14292efb 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinCraftingScreenHandler.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinCraftingScreenHandler.java @@ -23,32 +23,24 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.fixes.data.recipe.Recipes1_11_2; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.inventory.Inventory; -import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.ItemStack; -import net.minecraft.recipe.CraftingRecipe; -import net.minecraft.recipe.input.CraftingRecipeInput; -import net.minecraft.screen.AbstractRecipeScreenHandler; +import net.minecraft.screen.AbstractCraftingScreenHandler; import net.minecraft.screen.CraftingScreenHandler; import net.minecraft.screen.ScreenHandlerType; -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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(CraftingScreenHandler.class) -public abstract class MixinCraftingScreenHandler extends AbstractRecipeScreenHandler { +public abstract class MixinCraftingScreenHandler extends AbstractCraftingScreenHandler { - @Shadow - @Final - private RecipeInputInventory input; - - public MixinCraftingScreenHandler(ScreenHandlerType screenHandlerType, int i) { - super(screenHandlerType, i); + public MixinCraftingScreenHandler(ScreenHandlerType type, int syncId, int width, int height) { + super(type, syncId, width, height); } + @Redirect(method = "quickMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/screen/CraftingScreenHandler;insertItem(Lnet/minecraft/item/ItemStack;IIZ)Z", ordinal = 1)) private boolean noShiftClickMoveIntoCraftingTable(CraftingScreenHandler instance, ItemStack itemStack, int startIndex, int endIndex, boolean fromLast) { return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_14_4) && this.insertItem(itemStack, startIndex, endIndex, fromLast); @@ -57,7 +49,7 @@ public abstract class MixinCraftingScreenHandler extends AbstractRecipeScreenHan @Inject(method = "onContentChanged", at = @At("HEAD")) private void clientSideCrafting(Inventory inventory, CallbackInfo ci) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_11_1)) { - Recipes1_11_2.setCraftingResultSlot(syncId, this, input); + Recipes1_11_2.setCraftingResultSlot(syncId, this, this.craftingInventory); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinPlayerScreenHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinPlayerScreenHandler.java index 648e6b5d..df82af0b 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinPlayerScreenHandler.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinPlayerScreenHandler.java @@ -23,16 +23,11 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.fixes.data.recipe.Recipes1_11_2; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.inventory.Inventory; -import net.minecraft.inventory.RecipeInputInventory; -import net.minecraft.recipe.CraftingRecipe; -import net.minecraft.recipe.input.CraftingRecipeInput; -import net.minecraft.screen.AbstractRecipeScreenHandler; +import net.minecraft.screen.AbstractCraftingScreenHandler; import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.screen.slot.Slot; -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.Redirect; @@ -40,20 +35,16 @@ import org.spongepowered.asm.mixin.injection.Slice; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(PlayerScreenHandler.class) -public abstract class MixinPlayerScreenHandler extends AbstractRecipeScreenHandler { +public abstract class MixinPlayerScreenHandler extends AbstractCraftingScreenHandler { - @Shadow - @Final - private RecipeInputInventory craftingInput; - - public MixinPlayerScreenHandler(ScreenHandlerType screenHandlerType, int i) { - super(screenHandlerType, i); + public MixinPlayerScreenHandler(ScreenHandlerType type, int syncId, int width, int height) { + super(type, syncId, width, height); } @Inject(method = "onContentChanged", at = @At("HEAD")) private void clientSideCrafting(Inventory inventory, CallbackInfo ci) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_11_1)) { - Recipes1_11_2.setCraftingResultSlot(syncId, this, craftingInput); + Recipes1_11_2.setCraftingResultSlot(syncId, this, this.craftingInventory); } } diff --git a/src/main/resources/viafabricplus.accesswidener b/src/main/resources/viafabricplus.accesswidener index 304fb50b..320f8a8e 100644 --- a/src/main/resources/viafabricplus.accesswidener +++ b/src/main/resources/viafabricplus.accesswidener @@ -9,8 +9,7 @@ accessible field net/minecraft/client/font/FontStorage$GlyphPair MISSING Lnet/mi accessible field net/minecraft/network/ClientConnection packetSizeLogger Lnet/minecraft/network/handler/PacketSizeLogger; accessible field net/minecraft/entity/boss/dragon/EnderDragonEntity body Lnet/minecraft/entity/boss/dragon/EnderDragonPart; accessible field net/minecraft/entity/passive/AbstractHorseEntity lastAngryAnimationProgress F -accessible field net/minecraft/entity/vehicle/BoatEntity yawVelocity F -accessible field net/minecraft/client/font/FontStorage glyphRendererCache Lnet/minecraft/client/font/GlyphContainer; +accessible field net/minecraft/entity/vehicle/AbstractBoatEntity yawVelocity F accessible field net/minecraft/client/font/FontStorage glyphCache Lnet/minecraft/client/font/GlyphContainer; accessible field net/minecraft/entity/EntityType dimensions Lnet/minecraft/entity/EntityDimensions; accessible field net/minecraft/block/AbstractBlock velocityMultiplier F @@ -23,7 +22,7 @@ accessible field net/minecraft/client/resource/language/TranslationStorage trans accessible method net/minecraft/screen/GenericContainerScreenHandler (Lnet/minecraft/screen/ScreenHandlerType;ILnet/minecraft/entity/player/PlayerInventory;I)V accessible method net/minecraft/client/font/FontStorage$GlyphPair (Lnet/minecraft/client/font/Glyph;Lnet/minecraft/client/font/Glyph;)V accessible method net/minecraft/entity/passive/CamelEntity getPassengerAttachmentY (ZFLnet/minecraft/entity/EntityDimensions;F)D -accessible method net/minecraft/entity/vehicle/BoatEntity getMaxPassengers ()I +accessible method net/minecraft/entity/vehicle/AbstractBoatEntity getMaxPassengers ()I accessible method net/minecraft/client/gui/screen/multiplayer/ConnectScreen setStatus (Lnet/minecraft/text/Text;)V accessible method net/minecraft/item/BlockItem getPlacementState (Lnet/minecraft/item/ItemPlacementContext;)Lnet/minecraft/block/BlockState; diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index bf476e25..861a8f32 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -98,13 +98,13 @@ "fixes.minecraft.block.MixinSnowBlock", "fixes.minecraft.block.MixinSoulSandBlock", "fixes.minecraft.block.MixinWallBlock", + "fixes.minecraft.entity.MixinAbstractBoatEntity", "fixes.minecraft.entity.MixinAbstractClientPlayerEntity", "fixes.minecraft.entity.MixinAbstractHorseEntity", "fixes.minecraft.entity.MixinAnimalEntity", "fixes.minecraft.entity.MixinArmadilloEntity", "fixes.minecraft.entity.MixinAxolotlEntity", "fixes.minecraft.entity.MixinBipedEntityModel", - "fixes.minecraft.entity.MixinBoatEntity", "fixes.minecraft.entity.MixinCamelEntity", "fixes.minecraft.entity.MixinCatEntity", "fixes.minecraft.entity.MixinClientPlayerEntity", @@ -134,6 +134,7 @@ "fixes.minecraft.item.MixinEquipment", "fixes.minecraft.item.MixinFireChargeItem", "fixes.minecraft.item.MixinFireworkRocketItem", + "fixes.minecraft.item.MixinFishingRodItem", "fixes.minecraft.item.MixinHeldItemRenderer", "fixes.minecraft.item.MixinItemCooldownManager", "fixes.minecraft.item.MixinItemGroup_EntriesImpl", @@ -187,6 +188,7 @@ "fixes.viaversion.MixinBlockItemPacketRewriter1_20_5", "fixes.viaversion.MixinCommandBlockProvider", "fixes.viaversion.MixinCommonBoss", + "fixes.viaversion.MixinEntityPacketRewriter1_12", "fixes.viaversion.MixinEntityPacketRewriter1_15", "fixes.viaversion.MixinEntityPacketRewriter1_17", "fixes.viaversion.MixinEntityPacketRewriter1_19_4", @@ -203,7 +205,6 @@ "fixes.viaversion.MixinParticleIdMappings1_13", "fixes.viaversion.MixinParticleMappings", "fixes.viaversion.MixinProtocol1_10To1_11", - "fixes.viaversion.MixinEntityPacketRewriter1_12", "fixes.viaversion.MixinProtocol1_20_3To1_20_5", "fixes.viaversion.MixinProtocol1_20To1_20_2", "fixes.viaversion.MixinTagType", @@ -213,8 +214,7 @@ "fixes.viaversion.MixinWorldPacketRewriter1_19", "viabedrock.MixinJoinPackets", "vialegacy.MixinExtensionProtocolMetadataStorage", - "vialegacy.MixinViaLegacyConfig", - "fixes.minecraft.item.MixinFishingRodItem" + "vialegacy.MixinViaLegacyConfig" ], "injectors": { "defaultRequire": 1