diff --git a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java index c7676f91..8307d167 100644 --- a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java +++ b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java @@ -35,10 +35,12 @@ import java.util.concurrent.CompletableFuture; /* * TODO | Port 1.20.6 * - ClientPlayerInteractionManager#interactBlockInternal added new condition - * - MouseHandling changed (not sure if relevant) * - Command arguments (Probably not everything worth, but least them with nbt) * - Entity attachment calculation got changed completely * - Particle handling has slightly changed + * - BookViewScreen/BookEditScreen networking handling + * - SetEquipment packet now only accepts living entities + * - Wolf interaction * * TODO | General * - Make recipe fixes dynamic instead of a data dump in java classes diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCatEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCatEntity.java new file mode 100644 index 00000000..23e38aca --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinCatEntity.java @@ -0,0 +1,56 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus + * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC + * Copyright (C) 2023-2024 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 com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.passive.CatEntity; +import net.minecraft.entity.passive.TameableEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.world.World; +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(CatEntity.class) +public abstract class MixinCatEntity extends TameableEntity { + + protected MixinCatEntity(EntityType entityType, World world) { + super(entityType, world); + } + + @Inject(method = "interactMob", at = @At("HEAD"), cancellable = true) + private void interactMob1_20_4(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_3)) { + final ItemStack itemStack = player.getStackInHand(hand); + if (this.isTamed() && this.isOwner(player)) { + cir.setReturnValue(ActionResult.SUCCESS); + } else { + cir.setReturnValue(!this.isBreedingItem(itemStack) || !(this.getHealth() < this.getMaxHealth()) && this.isTamed() ? ActionResult.PASS : ActionResult.SUCCESS); + } + } + } + +} diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index a304cf8e..adec1276 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -209,7 +209,8 @@ "fixes.viaversion.MixinWorldPacketRewriter1_19", "viabedrock.MixinJoinPackets", "vialegacy.MixinExtensionProtocolMetadataStorage", - "vialegacy.MixinViaLegacyConfig" + "vialegacy.MixinViaLegacyConfig", + "fixes.minecraft.entity.MixinCatEntity" ], "injectors": { "defaultRequire": 1