mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-25 12:25:22 +01:00
Handle leash/mob interaction changes in <= 1.20.6
This commit is contained in:
parent
d2b765c60d
commit
5c61aab8fc
@ -41,7 +41,6 @@ import java.util.concurrent.CompletableFuture;
|
||||
* - Particle handling has slightly changed
|
||||
*
|
||||
* TODO | Port 1.21
|
||||
* - ClientPlayerEntity#tickMovement nether portal logic has new screen conditions and changed
|
||||
* - HangingEntity/ItemFrame/Painting bounding box calculation changed
|
||||
*
|
||||
* TODO | General
|
||||
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.mob.MobEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
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(MobEntity.class)
|
||||
public abstract class MixinMobEntity {
|
||||
|
||||
@Shadow protected abstract ActionResult interactWithItem(PlayerEntity player, Hand hand);
|
||||
|
||||
@Shadow protected abstract ActionResult interactMob(PlayerEntity player, Hand hand);
|
||||
|
||||
@Redirect(method = "interact", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/mob/MobEntity;interactWithItem(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;"))
|
||||
private ActionResult cancelItemInteractions(MobEntity instance, PlayerEntity player, Hand hand) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_5)) {
|
||||
return ActionResult.FAIL;
|
||||
} else {
|
||||
return interactWithItem(player, hand);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "interact", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/mob/MobEntity;interactMob(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;"))
|
||||
private ActionResult moveItemInteractionsAfterLeashing(MobEntity instance, PlayerEntity player, Hand hand) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_5)) {
|
||||
final ActionResult result = interactWithItem(player, hand);
|
||||
if (result.isAccepted()) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return interactMob(player, hand);
|
||||
}
|
||||
|
||||
}
|
@ -206,7 +206,8 @@
|
||||
"viabedrock.MixinJoinPackets",
|
||||
"vialegacy.MixinExtensionProtocolMetadataStorage",
|
||||
"vialegacy.MixinViaLegacyConfig",
|
||||
"fixes.minecraft.item.MixinKnowledgeBookItem"
|
||||
"fixes.minecraft.item.MixinKnowledgeBookItem",
|
||||
"fixes.minecraft.entity.MixinMobEntity"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
Loading…
Reference in New Issue
Block a user