Fix cat interaction in <= 1.20.4

This commit is contained in:
FlorianMichael 2024-08-07 16:11:16 +02:00
parent 59fe914604
commit a0700247b6
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 61 additions and 2 deletions

View File

@ -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

View File

@ -0,0 +1,56 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> 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 <http://www.gnu.org/licenses/>.
*/
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<? extends TameableEntity> entityType, World world) {
super(entityType, world);
}
@Inject(method = "interactMob", at = @At("HEAD"), cancellable = true)
private void interactMob1_20_4(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> 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);
}
}
}
}

View File

@ -209,7 +209,8 @@
"fixes.viaversion.MixinWorldPacketRewriter1_19",
"viabedrock.MixinJoinPackets",
"vialegacy.MixinExtensionProtocolMetadataStorage",
"vialegacy.MixinViaLegacyConfig"
"vialegacy.MixinViaLegacyConfig",
"fixes.minecraft.entity.MixinCatEntity"
],
"injectors": {
"defaultRequire": 1