diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinDecoratedPotBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinDecoratedPotBlock.java new file mode 100644 index 000000000..b6c7a4c4f --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinDecoratedPotBlock.java @@ -0,0 +1,47 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus + * Copyright (C) 2021-2023 FlorianMichael/EnZaXD + * Copyright (C) 2023 RK_01/RaphiMC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block; + +import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; +import net.minecraft.block.BlockState; +import net.minecraft.block.DecoratedPotBlock; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.raphimc.vialoader.util.VersionEnum; +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(DecoratedPotBlock.class) +public abstract class MixinDecoratedPotBlock { + + @Inject(method = "onUse", at = @At("HEAD"), cancellable = true) + public void alwaysPass(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20_2)) { + cir.setReturnValue(ActionResult.PASS); + } + } + +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAbstractHorseEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAbstractHorseEntity.java new file mode 100644 index 000000000..3c82ed566 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAbstractHorseEntity.java @@ -0,0 +1,45 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus + * Copyright (C) 2021-2023 FlorianMichael/EnZaXD + * Copyright (C) 2023 RK_01/RaphiMC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; + +import de.florianmichael.viafabricplus.protocolhack.ProtocolHack; +import net.minecraft.entity.passive.AbstractHorseEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.raphimc.vialoader.util.VersionEnum; +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.Redirect; + +@Mixin(AbstractHorseEntity.class) +public abstract class MixinAbstractHorseEntity { + + @Shadow protected abstract boolean receiveFood(PlayerEntity player, ItemStack item); + + @Redirect(method = "interactHorse", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/AbstractHorseEntity;receiveFood(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/item/ItemStack;)Z")) + public boolean dontRemoveItemOnClientside(AbstractHorseEntity instance, PlayerEntity player, ItemStack item) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20_2)) { + return false; + } + return receiveFood(player, item); + } + +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java index a8be59842..e4553986b 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java @@ -72,6 +72,14 @@ protected MixinPlayerEntity(EntityType entityType, World super(entityType, world); } + @Redirect(method = "getMaxRelativeHeadRotation", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isBlocking()Z")) + public boolean dontModifyHeadRotationWhenBlocking(PlayerEntity instance) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20_2)) { + return false; + } + return instance.isBlocking(); + } + @Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;setMovementSpeed(F)V")) private void storeSprintingState(CallbackInfo ci) { viaFabricPlus$isSprinting = this.isSprinting(); diff --git a/src/main/java/de/florianmichael/viafabricplus/protocolhack/netty/ViaFabricPlusViaDecoder.java b/src/main/java/de/florianmichael/viafabricplus/protocolhack/netty/ViaFabricPlusViaDecoder.java index f3312906d..7986b7700 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocolhack/netty/ViaFabricPlusViaDecoder.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocolhack/netty/ViaFabricPlusViaDecoder.java @@ -46,7 +46,6 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception if (mode == 1) { ChatUtil.sendPrefixedMessage(Text.literal("An error occurred while translating a packet! See more details in the logs!").formatted(Formatting.RED)); } - return; } throw t; diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index a6060e65d..c0677110d 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -195,7 +195,9 @@ "viaversion.MixinAbstractFenceConnectionHandler", "viaversion.MixinConfig", "viaversion.MixinGlassConnectionHandler", - "viaversion.MixinProtocolVersion" + "viaversion.MixinProtocolVersion", + "fixes.minecraft.block.MixinDecoratedPotBlock", + "fixes.minecraft.entity.MixinAbstractHorseEntity" ], "injectors": { "defaultRequire": 1