mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-26 12:35:54 +01:00
Sort injection methods in fixes package by version
Added new debug settings
This commit is contained in:
parent
a2a2a56e46
commit
a19c7085e9
@ -53,9 +53,6 @@ import java.io.File;
|
|||||||
* - Fix MixinAbstractDonkeyEntity
|
* - Fix MixinAbstractDonkeyEntity
|
||||||
* - Boats are probably broken. Check entity height offset fix
|
* - Boats are probably broken. Check entity height offset fix
|
||||||
* - Check TO DO in MixinEntity
|
* - Check TO DO in MixinEntity
|
||||||
* - Sort injection methods in fixes package by version
|
|
||||||
* - Add setting for revertOnlyPlayerCramming
|
|
||||||
* - Add setting for MixinLockableContainerBlockEntity
|
|
||||||
* - Diff ItemRegistryDiff from projects and add missing items
|
* - Diff ItemRegistryDiff from projects and add missing items
|
||||||
* - Fix third party implementations properly
|
* - Fix third party implementations properly
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||||
|
|
||||||
|
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||||
|
import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
|
||||||
|
import de.florianmichael.viafabricplus.settings.impl.AuthenticationSettings;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.network.ClientConnection;
|
||||||
|
import net.minecraft.network.packet.Packet;
|
||||||
|
import net.minecraft.network.packet.c2s.login.LoginHelloC2SPacket;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(targets = "net.minecraft.client.gui.screen.ConnectScreen$1")
|
||||||
|
public abstract class MixinConnectScreen_1 {
|
||||||
|
|
||||||
|
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;send(Lnet/minecraft/network/packet/Packet;)V"))
|
||||||
|
private void spoofUserName(ClientConnection instance, Packet<?> packet) {
|
||||||
|
if (AuthenticationSettings.global().setSessionNameToClassiCubeNameInServerList.getValue() && ViaFabricPlusClassicMPPassProvider.classiCubeMPPass != null) {
|
||||||
|
final var account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount();
|
||||||
|
if (account != null) {
|
||||||
|
instance.send(new LoginHelloC2SPacket(account.username(), MinecraftClient.getInstance().getSession().getUuidOrNull()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
instance.send(packet);
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.input;
|
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||||
|
|
||||||
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||||
import net.minecraft.client.render.Camera;
|
import net.minecraft.client.render.Camera;
|
@ -83,10 +83,17 @@ public abstract class MixinClientPlayerInteractionManager {
|
|||||||
@Unique
|
@Unique
|
||||||
private List<ItemStack> viaFabricPlus$oldItems;
|
private List<ItemStack> viaFabricPlus$oldItems;
|
||||||
|
|
||||||
@Inject(method = "breakBlock", at = @At("TAIL"))
|
@Inject(method = "getBlockBreakingProgress", at = @At("HEAD"), cancellable = true)
|
||||||
private void resetBlockBreaking(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
private void changeCalculation(CallbackInfoReturnable<Integer> cir) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_3)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
||||||
this.currentBreakingPos = new BlockPos(this.currentBreakingPos.getX(), -1, this.currentBreakingPos.getZ());
|
cir.setReturnValue((int)(this.currentBreakingProgress * 10.0F) - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "sendSequencedPacket", at = @At("HEAD"))
|
||||||
|
private void handleBlockAcknowledgements(ClientWorld world, SequencedPacketCreator packetCreator, CallbackInfo ci) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_14_4, VersionEnum.r1_18_2) && packetCreator instanceof PlayerActionC2SPacket playerActionC2SPacket) {
|
||||||
|
ClientPlayerInteractionManager1_18_2.trackBlockAction(playerActionC2SPacket.getAction(), playerActionC2SPacket.getPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,14 +158,11 @@ public abstract class MixinClientPlayerInteractionManager {
|
|||||||
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_17);
|
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_17);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "interactItem", at = @At("HEAD"))
|
@Inject(method = "breakBlock", at = @At("TAIL"))
|
||||||
private void trackLastUsedItem(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
|
private void resetBlockBreaking(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
||||||
ViaFabricPlusHandItemProvider.lastUsedItem = player.getStackInHand(hand).copy();
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_3)) {
|
||||||
}
|
this.currentBreakingPos = new BlockPos(this.currentBreakingPos.getX(), -1, this.currentBreakingPos.getZ());
|
||||||
|
}
|
||||||
@Inject(method = "interactBlock", at = @At("HEAD"))
|
|
||||||
private void trackLastUsedBlock(ClientPlayerEntity player, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) {
|
|
||||||
ViaFabricPlusHandItemProvider.lastUsedItem = player.getStackInHand(hand).copy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
@ -183,18 +187,14 @@ public abstract class MixinClientPlayerInteractionManager {
|
|||||||
return interactBlockInternal(player, hand, hitResult);
|
return interactBlockInternal(player, hand, hitResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "sendSequencedPacket", at = @At("HEAD"))
|
@Inject(method = "interactItem", at = @At("HEAD"))
|
||||||
private void handleBlockAcknowledgements(ClientWorld world, SequencedPacketCreator packetCreator, CallbackInfo ci) {
|
private void trackLastUsedItem(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
|
||||||
if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_14_4, VersionEnum.r1_18_2) && packetCreator instanceof PlayerActionC2SPacket playerActionC2SPacket) {
|
ViaFabricPlusHandItemProvider.lastUsedItem = player.getStackInHand(hand).copy();
|
||||||
ClientPlayerInteractionManager1_18_2.trackBlockAction(playerActionC2SPacket.getAction(), playerActionC2SPacket.getPos());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "getBlockBreakingProgress", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "interactBlock", at = @At("HEAD"))
|
||||||
private void changeCalculation(CallbackInfoReturnable<Integer> cir) {
|
private void trackLastUsedBlock(ClientPlayerEntity player, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
ViaFabricPlusHandItemProvider.lastUsedItem = player.getStackInHand(hand).copy();
|
||||||
cir.setReturnValue((int)(this.currentBreakingProgress * 10.0F) - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.input;
|
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||||
|
|
||||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
@ -60,48 +60,6 @@ public abstract class MixinMinecraftClient {
|
|||||||
|
|
||||||
@Shadow @Nullable public abstract ClientPlayNetworkHandler getNetworkHandler();
|
@Shadow @Nullable public abstract ClientPlayNetworkHandler getNetworkHandler();
|
||||||
|
|
||||||
@WrapWithCondition(method = "doItemUse",
|
|
||||||
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;interactItem(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;")),
|
|
||||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;resetEquipProgress(Lnet/minecraft/util/Hand;)V", ordinal = 0))
|
|
||||||
private boolean removeEquipProgressReset(HeldItemRenderer instance, Hand hand) {
|
|
||||||
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_8) || !(player.getStackInHand(hand).getItem() instanceof SwordItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "doItemUse",
|
|
||||||
slice = @Slice(to = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;interactEntity(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/entity/Entity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;")),
|
|
||||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ActionResult;isAccepted()Z", ordinal = 0))
|
|
||||||
private boolean preventGenericInteract(ActionResult instance) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance.isAccepted();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ModifyExpressionValue(method = "handleBlockBreaking", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z"))
|
|
||||||
private boolean allowBlockBreakAndItemUsageAtTheSameTime(boolean original) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return original;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;attackCooldown:I", ordinal = 1))
|
|
||||||
private int unwrapOperation(MinecraftClient instance) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return attackCooldown;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;handleInputEvents()V", shift = At.Shift.BEFORE))
|
|
||||||
private void updateCooldown(CallbackInfo ci) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
|
||||||
if (this.attackCooldown > 0) {
|
|
||||||
--this.attackCooldown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private final ConcurrentLinkedDeque<Runnable> viaFabricPlus$mouseInteractions = new ConcurrentLinkedDeque<>();
|
private final ConcurrentLinkedDeque<Runnable> viaFabricPlus$mouseInteractions = new ConcurrentLinkedDeque<>();
|
||||||
@ -143,4 +101,48 @@ public abstract class MixinMinecraftClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@WrapWithCondition(method = "doItemUse",
|
||||||
|
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;interactItem(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;")),
|
||||||
|
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;resetEquipProgress(Lnet/minecraft/util/Hand;)V", ordinal = 0))
|
||||||
|
private boolean removeEquipProgressReset(HeldItemRenderer instance, Hand hand) {
|
||||||
|
return ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_8) || !(player.getStackInHand(hand).getItem() instanceof SwordItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Redirect(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;attackCooldown:I", ordinal = 1))
|
||||||
|
private int dontIncrementCooldown(MinecraftClient instance) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return attackCooldown;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;handleInputEvents()V", shift = At.Shift.BEFORE))
|
||||||
|
private void postIncrementCooldown(CallbackInfo ci) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||||
|
if (this.attackCooldown > 0) {
|
||||||
|
--this.attackCooldown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "doItemUse",
|
||||||
|
slice = @Slice(to = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;interactEntity(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/entity/Entity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;")),
|
||||||
|
at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ActionResult;isAccepted()Z", ordinal = 0))
|
||||||
|
private boolean preventGenericInteract(ActionResult instance) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance.isAccepted();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModifyExpressionValue(method = "handleBlockBreaking", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z"))
|
||||||
|
private boolean allowBlockBreakAndItemUsageAtTheSameTime(boolean original) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,9 +59,13 @@ public abstract class MixinAbstractBlock_AbstractBlockState {
|
|||||||
@Inject(method = "getHardness", at = @At("RETURN"), cancellable = true)
|
@Inject(method = "getHardness", at = @At("RETURN"), cancellable = true)
|
||||||
private void changeHardness(BlockView world, BlockPos pos, CallbackInfoReturnable<Float> cir) {
|
private void changeHardness(BlockView world, BlockPos pos, CallbackInfoReturnable<Float> cir) {
|
||||||
final Block block = this.getBlock();
|
final Block block = this.getBlock();
|
||||||
if (block.equals(Blocks.OBSIDIAN)) {
|
if (block.equals(Blocks.END_STONE_BRICKS) || block.equals(Blocks.END_STONE_BRICK_SLAB) || block.equals(Blocks.END_STONE_BRICK_STAIRS) || block.equals(Blocks.END_STONE_BRICK_WALL)) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||||
cir.setReturnValue(10.0F);
|
cir.setReturnValue(0.8F);
|
||||||
|
}
|
||||||
|
} else if (block.equals(Blocks.PISTON) || block.equals(Blocks.STICKY_PISTON) || block.equals(Blocks.PISTON_HEAD)) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||||
|
cir.setReturnValue(0.5F);
|
||||||
}
|
}
|
||||||
} else if (block instanceof InfestedBlock) {
|
} else if (block instanceof InfestedBlock) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||||
@ -69,13 +73,9 @@ public abstract class MixinAbstractBlock_AbstractBlockState {
|
|||||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||||
cir.setReturnValue(0F);
|
cir.setReturnValue(0F);
|
||||||
}
|
}
|
||||||
} else if (block.equals(Blocks.PISTON) || block.equals(Blocks.STICKY_PISTON) || block.equals(Blocks.PISTON_HEAD)) {
|
} else if (block.equals(Blocks.OBSIDIAN)) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||||
cir.setReturnValue(0.5F);
|
cir.setReturnValue(10.0F);
|
||||||
}
|
|
||||||
} else if (block.equals(Blocks.END_STONE_BRICKS) || block.equals(Blocks.END_STONE_BRICK_SLAB) || block.equals(Blocks.END_STONE_BRICK_STAIRS) || block.equals(Blocks.END_STONE_BRICK_WALL)) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
|
||||||
cir.setReturnValue(0.8F);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,13 +42,6 @@ public abstract class MixinBedBlock {
|
|||||||
@Unique
|
@Unique
|
||||||
private static final VoxelShape viaFabricPlus$shape_r1_13_2 = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D);
|
private static final VoxelShape viaFabricPlus$shape_r1_13_2 = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D);
|
||||||
|
|
||||||
@Inject(method = "bounceEntity", at = @At("HEAD"), cancellable = true)
|
|
||||||
private void cancelEntityBounce(Entity entity, CallbackInfo ci) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_11_1to1_11_2)) {
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
|
||||||
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||||
@ -56,4 +49,11 @@ public abstract class MixinBedBlock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "bounceEntity", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void cancelEntityBounce(Entity entity, CallbackInfo ci) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_11_1to1_11_2)) {
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,58 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
|
|||||||
@Final
|
@Final
|
||||||
public ClientPlayNetworkHandler networkHandler;
|
public ClientPlayNetworkHandler networkHandler;
|
||||||
|
|
||||||
|
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z", ordinal = 0))
|
||||||
|
private boolean removeVehicleRequirement(ClientPlayerEntity instance) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance.hasVehicle();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendSprintingPacket()V"))
|
||||||
|
private void removeSprintingPacket(ClientPlayerEntity instance) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_19_3)) {
|
||||||
|
sendSprintingPacket();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "autoJump", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;inverseSqrt(F)F"))
|
||||||
|
private float useFastInverse(float x) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
|
||||||
|
// fast inverse sqrt
|
||||||
|
x = Float.intBitsToFloat(1597463007 - (Float.floatToIntBits(x) >> 1));
|
||||||
|
return x * (1.5F - (0.5F * x) * x * x);
|
||||||
|
}
|
||||||
|
return MathHelper.inverseSqrt(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z"))
|
||||||
|
private boolean removeVehicleCheck(ClientPlayerEntity instance) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return instance.hasVehicle();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isFallFlying()Z"))
|
||||||
|
private boolean removeFallFlyingCheck(ClientPlayerEntity instance) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return instance.isFallFlying();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "canSprint", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z"))
|
||||||
|
private boolean dontAllowSprintingAsPassenger(ClientPlayerEntity instance) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return instance.hasVehicle();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;square(D)D"))
|
@Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;square(D)D"))
|
||||||
private double changeMagnitude(double n) {
|
private double changeMagnitude(double n) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) {
|
||||||
@ -82,6 +134,87 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
|
|||||||
return MathHelper.square(n);
|
return MathHelper.square(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "startRiding", at = @At("RETURN"))
|
||||||
|
private void setRotationsWhenInBoat(Entity entity, boolean force, CallbackInfoReturnable<Boolean> cir) {
|
||||||
|
if (cir.getReturnValueZ() && entity instanceof BoatEntity && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) {
|
||||||
|
this.prevYaw = entity.getYaw();
|
||||||
|
this.setYaw(entity.getYaw());
|
||||||
|
this.setHeadYaw(entity.getYaw());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isClimbing()Z"))
|
||||||
|
private boolean allowElytraWhenClimbing(ClientPlayerEntity instance) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_1)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return instance.isClimbing();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z", ordinal = 3))
|
||||||
|
private boolean allowElytraInVehicle(ClientPlayerEntity instance) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return instance.hasVehicle();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModifyVariable(method = "tickMovement", at = @At(value = "LOAD", ordinal = 4), ordinal = 4)
|
||||||
|
private boolean removeBl8Boolean(boolean value) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "tickMovement()V",
|
||||||
|
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isCamera()Z")),
|
||||||
|
at = @At(value = "FIELD", target = "Lnet/minecraft/client/input/Input;sneaking:Z", ordinal = 0))
|
||||||
|
private void injectTickMovement(CallbackInfo ci) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||||
|
if (this.input.sneaking) {
|
||||||
|
this.input.movementSideways = (float) ((double) this.input.movementSideways / 0.3D);
|
||||||
|
this.input.movementForward = (float) ((double) this.input.movementForward / 0.3D);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "isWalking", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void easierUnderwaterSprinting(CallbackInfoReturnable<Boolean> cir) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_1)) {
|
||||||
|
cir.setReturnValue(((ClientPlayerEntity) (Object) this).input.movementForward >= 0.8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "tickMovement()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;hasForwardMovement()Z", ordinal = 0))
|
||||||
|
private boolean disableSprintSneak(Input input) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_1)) {
|
||||||
|
return input.movementForward >= 0.8F;
|
||||||
|
}
|
||||||
|
|
||||||
|
return input.hasForwardMovement();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "tickMovement",
|
||||||
|
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isWalking()Z")),
|
||||||
|
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSwimming()Z", ordinal = 0))
|
||||||
|
private boolean redirectIsSneakingWhileSwimming(ClientPlayerEntity instance) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_1)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return instance.isSwimming();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isTouchingWater()Z"))
|
||||||
|
private boolean redirectTickMovement(ClientPlayerEntity self) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||||
|
return false; // Disable all water related movement
|
||||||
|
}
|
||||||
|
|
||||||
|
return self.isTouchingWater();
|
||||||
|
}
|
||||||
|
|
||||||
@Redirect(method = "sendMovementPackets", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerEntity;ticksSinceLastPositionPacketSent:I", ordinal = 0))
|
@Redirect(method = "sendMovementPackets", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerEntity;ticksSinceLastPositionPacketSent:I", ordinal = 0))
|
||||||
private int revertLastPositionPacketSentIncrementor(ClientPlayerEntity instance) {
|
private int revertLastPositionPacketSentIncrementor(ClientPlayerEntity instance) {
|
||||||
// Mixin calls the redirector and sets the original field to the return value of the redirector + 1, therefore the -1 results, so we truncate the + 1 again and the field does not change
|
// Mixin calls the redirector and sets the original field to the return value of the redirector + 1, therefore the -1 results, so we truncate the + 1 again and the field does not change
|
||||||
@ -107,137 +240,6 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
|
|||||||
return lastOnGround;
|
return lastOnGround;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "tickMovement()V",
|
|
||||||
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isCamera()Z")),
|
|
||||||
at = @At(value = "FIELD", target = "Lnet/minecraft/client/input/Input;sneaking:Z", ordinal = 0))
|
|
||||||
private void injectTickMovement(CallbackInfo ci) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
|
||||||
if (this.input.sneaking) {
|
|
||||||
this.input.movementSideways = (float) ((double) this.input.movementSideways / 0.3D);
|
|
||||||
this.input.movementForward = (float) ((double) this.input.movementForward / 0.3D);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "tickMovement",
|
|
||||||
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isWalking()Z")),
|
|
||||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSwimming()Z", ordinal = 0))
|
|
||||||
private boolean redirectIsSneakingWhileSwimming(ClientPlayerEntity instance) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_1)) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return instance.isSwimming();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "isWalking", at = @At("HEAD"), cancellable = true)
|
|
||||||
private void easierUnderwaterSprinting(CallbackInfoReturnable<Boolean> cir) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_1)) {
|
|
||||||
cir.setReturnValue(((ClientPlayerEntity) (Object) this).input.movementForward >= 0.8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "tickMovement()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;hasForwardMovement()Z", ordinal = 0))
|
|
||||||
private boolean disableSprintSneak(Input input) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_1)) {
|
|
||||||
return input.movementForward >= 0.8F;
|
|
||||||
}
|
|
||||||
|
|
||||||
return input.hasForwardMovement();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isTouchingWater()Z"))
|
|
||||||
private boolean redirectTickMovement(ClientPlayerEntity self) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
|
||||||
return false; // Disable all water related movement
|
|
||||||
}
|
|
||||||
|
|
||||||
return self.isTouchingWater();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendSprintingPacket()V"))
|
|
||||||
private void removeSprintingPacket(ClientPlayerEntity instance) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_19_3)) {
|
|
||||||
sendSprintingPacket();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "autoJump", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;inverseSqrt(F)F"))
|
|
||||||
private float useFastInverse(float x) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
|
|
||||||
// fast inverse sqrt
|
|
||||||
x = Float.intBitsToFloat(1597463007 - (Float.floatToIntBits(x) >> 1));
|
|
||||||
return x * (1.5F - (0.5F * x) * x * x);
|
|
||||||
}
|
|
||||||
return MathHelper.inverseSqrt(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z", ordinal = 0))
|
|
||||||
private boolean removeVehicleRequirement(ClientPlayerEntity instance) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance.hasVehicle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isClimbing()Z"))
|
|
||||||
private boolean allowElytraWhenClimbing(ClientPlayerEntity instance) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_1)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return instance.isClimbing();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z", ordinal = 3))
|
|
||||||
private boolean allowElytraInVehicle(ClientPlayerEntity instance) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return instance.hasVehicle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ModifyVariable(method = "tickMovement", at = @At(value = "LOAD", ordinal = 4), ordinal = 4)
|
|
||||||
private boolean removeBl8Boolean(boolean value) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z"))
|
|
||||||
private boolean removeVehicleCheck(ClientPlayerEntity instance) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return instance.hasVehicle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isFallFlying()Z"))
|
|
||||||
private boolean removeFallFlyingCheck(ClientPlayerEntity instance) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return instance.isFallFlying();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "canSprint", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z"))
|
|
||||||
private boolean dontAllowSprintingAsPassenger(ClientPlayerEntity instance) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return instance.hasVehicle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "startRiding", at = @At("RETURN"))
|
|
||||||
private void setRotationsWhenInBoat(Entity entity, boolean force, CallbackInfoReturnable<Boolean> cir) {
|
|
||||||
if (cir.getReturnValueZ() && entity instanceof BoatEntity && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) {
|
|
||||||
this.prevYaw = entity.getYaw();
|
|
||||||
this.setYaw(entity.getYaw());
|
|
||||||
this.setHeadYaw(entity.getYaw());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "tick", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z")), at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V", ordinal = 0))
|
@Redirect(method = "tick", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z")), at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V", ordinal = 0))
|
||||||
private void modifyPositionPacket(ClientPlayNetworkHandler instance, Packet<?> packet) throws Exception {
|
private void modifyPositionPacket(ClientPlayNetworkHandler instance, Packet<?> packet) throws Exception {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_5_2)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_5_2)) {
|
||||||
|
@ -74,12 +74,50 @@ public abstract class MixinEntity implements IEntity {
|
|||||||
@Unique
|
@Unique
|
||||||
private boolean viaFabricPlus$isInLoadedChunkAndShouldTick;
|
private boolean viaFabricPlus$isInLoadedChunkAndShouldTick;
|
||||||
|
|
||||||
@ModifyConstant(method = "movementInputToVelocity", constant = @Constant(doubleValue = 1E-7))
|
@Inject(method = "getRidingOffset", at = @At("HEAD"), cancellable = true)
|
||||||
private static double fixVelocityEpsilon(double epsilon) {
|
private void getRidingOffset1_20_1(Entity vehicle, CallbackInfoReturnable<Float> cir) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
||||||
return 1E-4;
|
cir.setReturnValue((float) EntityHeightOffsetsPre1_20_2.getHeightOffset((Entity) (Object) this));
|
||||||
}
|
}
|
||||||
return epsilon;
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "getPassengerRidingPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPassengerAttachmentPos(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/EntityDimensions;F)Lorg/joml/Vector3f;"))
|
||||||
|
private Vector3f getPassengerRidingPos1_20_1(Entity instance, Entity passenger, EntityDimensions dimensions, float scaleFactor) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
||||||
|
return EntityHeightOffsetsPre1_20_2.getMountedHeightOffset(instance, passenger);
|
||||||
|
}
|
||||||
|
|
||||||
|
return getPassengerAttachmentPos(passenger, dimensions, scaleFactor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "getPosWithYOffset", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void modifyPosWithYOffset(float offset, CallbackInfoReturnable<BlockPos> cir) {
|
||||||
|
final VersionEnum target = ProtocolHack.getTargetVersion();
|
||||||
|
if (target.isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
||||||
|
int i = MathHelper.floor(this.pos.x);
|
||||||
|
int j = MathHelper.floor(this.pos.y - (double) (target.isOlderThanOrEqualTo(VersionEnum.r1_18_2) && offset == 1.0E-5F ? 0.2F : offset));
|
||||||
|
int k = MathHelper.floor(this.pos.z);
|
||||||
|
BlockPos blockPos = new BlockPos(i, j, k);
|
||||||
|
if (this.world.getBlockState(blockPos).isAir()) {
|
||||||
|
BlockPos downPos = blockPos.down();
|
||||||
|
BlockState blockState = this.world.getBlockState(downPos);
|
||||||
|
if (blockState.isIn(BlockTags.FENCES) || blockState.isIn(BlockTags.WALLS) || blockState.getBlock() instanceof FenceGateBlock) {
|
||||||
|
cir.setReturnValue(downPos);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cir.setReturnValue(blockPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModifyConstant(method = "checkBlockCollision", constant = @Constant(doubleValue = 1.0E-7))
|
||||||
|
private double fixBlockCollisionMargin(double constant) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
||||||
|
return 1E-3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return constant;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "getVelocityAffectingPos", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "getVelocityAffectingPos", at = @At("HEAD"), cancellable = true)
|
||||||
@ -91,6 +129,19 @@ public abstract class MixinEntity implements IEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Redirect(method = {"setYaw", "setPitch"}, at = @At(value = "INVOKE", target = "Ljava/lang/Float;isFinite(F)Z"))
|
||||||
|
private boolean allowInfiniteValues(float f) {
|
||||||
|
return Float.isFinite(f) || ((Object) this instanceof ClientPlayerEntity && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModifyConstant(method = "movementInputToVelocity", constant = @Constant(doubleValue = 1E-7))
|
||||||
|
private static double fixVelocityEpsilon(double epsilon) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||||
|
return 1E-4;
|
||||||
|
}
|
||||||
|
return epsilon;
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "getRotationVector(FF)Lnet/minecraft/util/math/Vec3d;", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "getRotationVector(FF)Lnet/minecraft/util/math/Vec3d;", at = @At("HEAD"), cancellable = true)
|
||||||
private void revertCalculation(float pitch, float yaw, CallbackInfoReturnable<Vec3d> cir) {
|
private void revertCalculation(float pitch, float yaw, CallbackInfoReturnable<Vec3d> cir) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||||
@ -164,57 +215,6 @@ public abstract class MixinEntity implements IEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = {"setYaw", "setPitch"}, at = @At(value = "INVOKE", target = "Ljava/lang/Float;isFinite(F)Z"))
|
|
||||||
private boolean allowInfiniteValues(float f) {
|
|
||||||
return Float.isFinite(f) || ((Object) this instanceof ClientPlayerEntity && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ModifyConstant(method = "checkBlockCollision", constant = @Constant(doubleValue = 1.0E-7))
|
|
||||||
private double fixBlockCollisionMargin(double constant) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
|
||||||
return 1E-3;
|
|
||||||
}
|
|
||||||
|
|
||||||
return constant;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "getPosWithYOffset", at = @At("HEAD"), cancellable = true)
|
|
||||||
private void modifyPosWithYOffset(float offset, CallbackInfoReturnable<BlockPos> cir) {
|
|
||||||
final VersionEnum target = ProtocolHack.getTargetVersion();
|
|
||||||
if (target.isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
|
|
||||||
int i = MathHelper.floor(this.pos.x);
|
|
||||||
int j = MathHelper.floor(this.pos.y - (double) (target.isOlderThanOrEqualTo(VersionEnum.r1_18_2) && offset == 1.0E-5F ? 0.2F : offset));
|
|
||||||
int k = MathHelper.floor(this.pos.z);
|
|
||||||
BlockPos blockPos = new BlockPos(i, j, k);
|
|
||||||
if (this.world.getBlockState(blockPos).isAir()) {
|
|
||||||
BlockPos downPos = blockPos.down();
|
|
||||||
BlockState blockState = this.world.getBlockState(downPos);
|
|
||||||
if (blockState.isIn(BlockTags.FENCES) || blockState.isIn(BlockTags.WALLS) || blockState.getBlock() instanceof FenceGateBlock) {
|
|
||||||
cir.setReturnValue(downPos);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cir.setReturnValue(blockPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "getRidingOffset", at = @At("HEAD"), cancellable = true)
|
|
||||||
private void getRidingOffset1_20_1(Entity vehicle, CallbackInfoReturnable<Float> cir) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
|
||||||
cir.setReturnValue((float) EntityHeightOffsetsPre1_20_2.getHeightOffset((Entity) (Object) this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "getPassengerRidingPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPassengerAttachmentPos(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/EntityDimensions;F)Lorg/joml/Vector3f;"))
|
|
||||||
private Vector3f getPassengerRidingPos1_20_1(Entity instance, Entity passenger, EntityDimensions dimensions, float scaleFactor) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
|
||||||
return EntityHeightOffsetsPre1_20_2.getMountedHeightOffset(instance, passenger);
|
|
||||||
}
|
|
||||||
|
|
||||||
return getPassengerAttachmentPos(passenger, dimensions, scaleFactor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean viaFabricPlus$isInLoadedChunkAndShouldTick() {
|
public boolean viaFabricPlus$isInLoadedChunkAndShouldTick() {
|
||||||
return this.viaFabricPlus$isInLoadedChunkAndShouldTick || !ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_9, VersionEnum.r1_16_4tor1_16_5) /* || TODO: Add setting to force this*/;
|
return this.viaFabricPlus$isInLoadedChunkAndShouldTick || !ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_9, VersionEnum.r1_16_4tor1_16_5) /* || TODO: Add setting to force this*/;
|
||||||
|
@ -21,6 +21,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
|||||||
|
|
||||||
import de.florianmichael.viafabricplus.fixes.EntityHeightOffsetsPre1_20_2;
|
import de.florianmichael.viafabricplus.fixes.EntityHeightOffsetsPre1_20_2;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||||
|
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.TrapdoorBlock;
|
import net.minecraft.block.TrapdoorBlock;
|
||||||
import net.minecraft.entity.*;
|
import net.minecraft.entity.*;
|
||||||
@ -72,17 +73,62 @@ public abstract class MixinLivingEntity extends Entity {
|
|||||||
super(type, world);
|
super(type, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "<init>", at = @At("RETURN"))
|
@Inject(method = "getRidingOffset", at = @At("HEAD"), cancellable = true)
|
||||||
private void modify1_7StepHeight(EntityType<? extends LivingEntity> type, World world, CallbackInfo ci) {
|
private void getRidingOffset1_20_1(Entity vehicle, CallbackInfoReturnable<Float> cir) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
||||||
this.setStepHeight(0.5F);
|
cir.setReturnValue((float) EntityHeightOffsetsPre1_20_2.getHeightOffset(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "getPreferredEquipmentSlot", at = @At("HEAD"), cancellable = true)
|
@Redirect(method = "getPassengerRidingPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getPassengerAttachmentPos(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/EntityDimensions;F)Lorg/joml/Vector3f;"))
|
||||||
private static void removeShieldSlotPreference(ItemStack stack, CallbackInfoReturnable<EquipmentSlot> cir) {
|
private Vector3f getPassengerRidingPos1_20_1(LivingEntity instance, Entity entity, EntityDimensions entityDimensions, float v) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4) && stack.isOf(Items.SHIELD)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
||||||
cir.setReturnValue(EquipmentSlot.MAINHAND);
|
return EntityHeightOffsetsPre1_20_2.getMountedHeightOffset(instance, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
return getPassengerAttachmentPos(entity, entityDimensions, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isLogicalSideForUpdatingMovement()Z"))
|
||||||
|
private boolean allowPlayerToBeMovedByEntityPackets(LivingEntity instance) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3) || ProtocolHack.getTargetVersion().equals(VersionEnum.bedrockLatest)) {
|
||||||
|
return instance.getControllingPassenger() instanceof PlayerEntity player ? player.isMainPlayer() : !instance.getWorld().isClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance.isLogicalSideForUpdatingMovement();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "tickCramming", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isClient()Z"))
|
||||||
|
private boolean revertOnlyPlayerCramming(World instance) {
|
||||||
|
if (DebugSettings.global().alwaysTickOnlyPlayer.isEnabled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return instance.isClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Ljava/lang/Math;cos(D)D", remap = false))
|
||||||
|
private double fixCosTable(double a) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) {
|
||||||
|
return MathHelper.cos((float) a);
|
||||||
|
}
|
||||||
|
return Math.cos(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getFluidHeight(Lnet/minecraft/registry/tag/TagKey;)D"))
|
||||||
|
private double fixLavaMovement(LivingEntity instance, TagKey<Fluid> tagKey) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||||
|
return Double.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance.getFluidHeight(tagKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isChunkLoaded(Lnet/minecraft/util/math/BlockPos;)Z"))
|
||||||
|
private boolean modify1_13LoadedCheck(World instance, BlockPos blockPos) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||||
|
return this.getWorld().isChunkLoaded(blockPos) && instance.getChunkManager().isChunkLoaded(blockPos.getX() >> 4, blockPos.getZ() >> 4);
|
||||||
|
} else {
|
||||||
|
return this.getWorld().isChunkLoaded(blockPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,15 +152,6 @@ public abstract class MixinLivingEntity extends Entity {
|
|||||||
return instance.horizontalCollision;
|
return instance.horizontalCollision;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isLogicalSideForUpdatingMovement()Z"))
|
|
||||||
private boolean allowPlayerToBeMovedByEntityPackets(LivingEntity instance) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3) || ProtocolHack.getTargetVersion().equals(VersionEnum.bedrockLatest)) {
|
|
||||||
return instance.getControllingPassenger() instanceof PlayerEntity player ? player.isMainPlayer() : !instance.getWorld().isClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance.isLogicalSideForUpdatingMovement();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ModifyVariable(method = "applyFluidMovingSpeed", ordinal = 0, at = @At("HEAD"), argsOnly = true)
|
@ModifyVariable(method = "applyFluidMovingSpeed", ordinal = 0, at = @At("HEAD"), argsOnly = true)
|
||||||
private boolean modifyMovingDown(boolean movingDown) {
|
private boolean modifyMovingDown(boolean movingDown) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||||
@ -158,6 +195,21 @@ public abstract class MixinLivingEntity extends Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ModifyConstant(method = "travel", constant = @Constant(floatValue = 0.9F))
|
||||||
|
private float modifySwimFriction(float constant) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||||
|
return this.getBaseMovementSpeedMultiplier();
|
||||||
|
}
|
||||||
|
return constant;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "getPreferredEquipmentSlot", at = @At("HEAD"), cancellable = true)
|
||||||
|
private static void removeShieldSlotPreference(ItemStack stack, CallbackInfoReturnable<EquipmentSlot> cir) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4) && stack.isOf(Items.SHIELD)) {
|
||||||
|
cir.setReturnValue(EquipmentSlot.MAINHAND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ModifyConstant(method = "tickMovement", constant = @Constant(doubleValue = 0.003D))
|
@ModifyConstant(method = "tickMovement", constant = @Constant(doubleValue = 0.003D))
|
||||||
private double modifyVelocityZero(final double constant) {
|
private double modifyVelocityZero(final double constant) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||||
@ -173,12 +225,11 @@ public abstract class MixinLivingEntity extends Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyConstant(method = "travel", constant = @Constant(floatValue = 0.9F))
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
private float modifySwimFriction(float constant) {
|
private void modify1_7StepHeight(EntityType<? extends LivingEntity> type, World world, CallbackInfo ci) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
|
||||||
return this.getBaseMovementSpeedMultiplier();
|
this.setStepHeight(0.5F);
|
||||||
}
|
}
|
||||||
return constant;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "tickMovement", at = @At("HEAD"))
|
@Inject(method = "tickMovement", at = @At("HEAD"))
|
||||||
@ -188,40 +239,6 @@ public abstract class MixinLivingEntity extends Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Ljava/lang/Math;cos(D)D", remap = false))
|
|
||||||
private double fixCosTable(double a) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) {
|
|
||||||
return MathHelper.cos((float) a);
|
|
||||||
}
|
|
||||||
return Math.cos(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getFluidHeight(Lnet/minecraft/registry/tag/TagKey;)D"))
|
|
||||||
private double fixLavaMovement(LivingEntity instance, TagKey<Fluid> tagKey) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
|
||||||
return Double.MAX_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance.getFluidHeight(tagKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isChunkLoaded(Lnet/minecraft/util/math/BlockPos;)Z"))
|
|
||||||
private boolean modify1_13LoadedCheck(World instance, BlockPos blockPos) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
|
||||||
return this.getWorld().isChunkLoaded(blockPos) && instance.getChunkManager().isChunkLoaded(blockPos.getX() >> 4, blockPos.getZ() >> 4);
|
|
||||||
} else {
|
|
||||||
return this.getWorld().isChunkLoaded(blockPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "tickCramming", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isClient()Z"))
|
|
||||||
private boolean revertOnlyPlayerCramming(World instance) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return instance.isClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "isClimbing", at = @At("RETURN"), cancellable = true)
|
@Inject(method = "isClimbing", at = @At("RETURN"), cancellable = true)
|
||||||
private void allowGappedLadderClimb(CallbackInfoReturnable<Boolean> cir) {
|
private void allowGappedLadderClimb(CallbackInfoReturnable<Boolean> cir) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.b1_5tob1_5_2) && !cir.getReturnValueZ() && !this.isSpectator()) {
|
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.b1_5tob1_5_2) && !cir.getReturnValueZ() && !this.isSpectator()) {
|
||||||
@ -237,20 +254,4 @@ public abstract class MixinLivingEntity extends Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "getRidingOffset", at = @At("HEAD"), cancellable = true)
|
|
||||||
private void getRidingOffset1_20_1(Entity vehicle, CallbackInfoReturnable<Float> cir) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
|
||||||
cir.setReturnValue((float) EntityHeightOffsetsPre1_20_2.getHeightOffset(this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "getPassengerRidingPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getPassengerAttachmentPos(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/EntityDimensions;F)Lorg/joml/Vector3f;"))
|
|
||||||
private Vector3f getPassengerRidingPos1_20_1(LivingEntity instance, Entity entity, EntityDimensions entityDimensions, float v) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
|
|
||||||
return EntityHeightOffsetsPre1_20_2.getMountedHeightOffset(instance, entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
return getPassengerAttachmentPos(entity, entityDimensions, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity;
|
|||||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||||
|
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
|
||||||
import net.minecraft.block.entity.LockableContainerBlockEntity;
|
import net.minecraft.block.entity.LockableContainerBlockEntity;
|
||||||
import net.minecraft.text.MutableText;
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
@ -46,7 +47,7 @@ public abstract class MixinLockableContainerBlockEntity {
|
|||||||
|
|
||||||
@WrapOperation(method = "readNbt", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Text$Serializer;fromJson(Ljava/lang/String;)Lnet/minecraft/text/MutableText;"))
|
@WrapOperation(method = "readNbt", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Text$Serializer;fromJson(Ljava/lang/String;)Lnet/minecraft/text/MutableText;"))
|
||||||
private MutableText allowInvalidJson(String json, Operation<MutableText> operation) {
|
private MutableText allowInvalidJson(String json, Operation<MutableText> operation) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
if (DebugSettings.global().skipContainersWithCustomDisplayNames.isEnabled()) {
|
||||||
try {
|
try {
|
||||||
return operation.call(json);
|
return operation.call(json);
|
||||||
} catch (Exception e) { // In case the json is invalid for the modern client, we just return the raw json
|
} catch (Exception e) { // In case the json is invalid for the modern client, we just return the raw json
|
||||||
|
@ -72,6 +72,58 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
|||||||
super(entityType, world);
|
super(entityType, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "getOffGroundSpeed", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isSprinting()Z"))
|
||||||
|
private boolean useLastSprintingState(PlayerEntity instance) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
|
||||||
|
return viaFabricPlus$isSprinting;
|
||||||
|
}
|
||||||
|
return instance.isSprinting();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Redirect(method = "dropItem(Lnet/minecraft/item/ItemStack;ZZ)Lnet/minecraft/entity/ItemEntity;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
|
||||||
|
private void dontSwingHand(PlayerEntity instance, Hand hand) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) return;
|
||||||
|
|
||||||
|
instance.swingHand(hand);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "checkFallFlying", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;hasStatusEffect(Lnet/minecraft/entity/effect/StatusEffect;)Z"))
|
||||||
|
private boolean allowElytraWhenLevitating(PlayerEntity instance, StatusEffect statusEffect) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return instance.hasStatusEffect(statusEffect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "checkFallFlying", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void replaceFallFlyingCondition(CallbackInfoReturnable<Boolean> cir) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
||||||
|
if (!this.isOnGround() && this.getVelocity().y < 0D && !this.isFallFlying()) {
|
||||||
|
final ItemStack itemStack = this.getEquippedStack(EquipmentSlot.CHEST);
|
||||||
|
if (itemStack.isOf(Items.ELYTRA) && ElytraItem.isUsable(itemStack)) {
|
||||||
|
cir.setReturnValue(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cir.setReturnValue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModifyConstant(method = "getActiveEyeHeight", constant = @Constant(floatValue = 1.27f))
|
||||||
|
private float modifySneakEyeHeight(float prevEyeHeight) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_13_2)) {
|
||||||
|
return prevEyeHeight;
|
||||||
|
} else {
|
||||||
|
return 1.54f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "updatePose", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "updatePose", at = @At("HEAD"), cancellable = true)
|
||||||
private void onUpdatePose(CallbackInfo ci) {
|
private void onUpdatePose(CallbackInfo ci) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
|
||||||
@ -105,6 +157,14 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "adjustMovementForSneaking", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getStepHeight()F"))
|
||||||
|
private float modifyStepHeight1_10(PlayerEntity instance) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10)) {
|
||||||
|
return 1.0F;
|
||||||
|
}
|
||||||
|
return instance.getStepHeight();
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "getAttackCooldownProgress", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "getAttackCooldownProgress", at = @At("HEAD"), cancellable = true)
|
||||||
private void removeAttackCooldown(CallbackInfoReturnable<Float> ci) {
|
private void removeAttackCooldown(CallbackInfoReturnable<Float> ci) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||||
@ -119,68 +179,9 @@ public abstract class MixinPlayerEntity extends LivingEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyConstant(method = "getActiveEyeHeight", constant = @Constant(floatValue = 1.27f))
|
|
||||||
private float modifySneakEyeHeight(float prevEyeHeight) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isNewerThan(VersionEnum.r1_13_2)) {
|
|
||||||
return prevEyeHeight;
|
|
||||||
} else {
|
|
||||||
return 1.54f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "dropItem(Lnet/minecraft/item/ItemStack;ZZ)Lnet/minecraft/entity/ItemEntity;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
|
|
||||||
private void dontSwingHand(PlayerEntity instance, Hand hand) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) return;
|
|
||||||
|
|
||||||
instance.swingHand(hand);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "getOffGroundSpeed", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isSprinting()Z"))
|
|
||||||
private boolean useLastSprintingState(PlayerEntity instance) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
|
|
||||||
return viaFabricPlus$isSprinting;
|
|
||||||
}
|
|
||||||
return instance.isSprinting();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "checkFallFlying", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;hasStatusEffect(Lnet/minecraft/entity/effect/StatusEffect;)Z"))
|
|
||||||
private boolean allowElytraWhenLevitating(PlayerEntity instance, StatusEffect statusEffect) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return instance.hasStatusEffect(statusEffect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "checkFallFlying", at = @At("HEAD"), cancellable = true)
|
|
||||||
private void replaceFallFlyingCondition(CallbackInfoReturnable<Boolean> cir) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
|
|
||||||
if (!this.isOnGround() && this.getVelocity().y < 0D && !this.isFallFlying()) {
|
|
||||||
final ItemStack itemStack = this.getEquippedStack(EquipmentSlot.CHEST);
|
|
||||||
if (itemStack.isOf(Items.ELYTRA) && ElytraItem.isUsable(itemStack)) {
|
|
||||||
cir.setReturnValue(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cir.setReturnValue(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "adjustMovementForSneaking", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getStepHeight()F"))
|
|
||||||
private float modifyStepHeight1_10(PlayerEntity instance) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_10)) {
|
|
||||||
return 1.0F;
|
|
||||||
}
|
|
||||||
return instance.getStepHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author RK_01
|
* @author Mojang, RK_01
|
||||||
* @reason ProtocolHack block break speed changes
|
* @reason Block break speed calculation changes
|
||||||
*/
|
*/
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public float getBlockBreakingSpeed(BlockState block) {
|
public float getBlockBreakingSpeed(BlockState block) {
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
||||||
|
|
||||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||||
|
@ -53,13 +53,6 @@ public abstract class MixinAxeItem extends MiningToolItem {
|
|||||||
super(attackDamage, attackSpeed, material, effectiveBlocks, settings);
|
super(attackDamage, attackSpeed, material, effectiveBlocks, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "useOnBlock", at = @At("HEAD"), cancellable = true)
|
|
||||||
private void disableUse(ItemUsageContext context, CallbackInfoReturnable<ActionResult> cir) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
|
||||||
cir.setReturnValue(ActionResult.PASS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSuitableFor(BlockState state) {
|
public boolean isSuitableFor(BlockState state) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||||
@ -69,6 +62,13 @@ public abstract class MixinAxeItem extends MiningToolItem {
|
|||||||
return super.isSuitableFor(state);
|
return super.isSuitableFor(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "useOnBlock", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void disableUse(ItemUsageContext context, CallbackInfoReturnable<ActionResult> cir) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||||
|
cir.setReturnValue(ActionResult.PASS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
||||||
|
|
||||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Set;
|
|||||||
public abstract class MixinHoeItem extends MiningToolItem {
|
public abstract class MixinHoeItem extends MiningToolItem {
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private static final Set<Block> viaFabricPlus$EFFECTIVE_BLOCKS_1165 = ImmutableSet.of(
|
private static final Set<Block> viaFabricPlus$effective_blocks_r1_16_5 = ImmutableSet.of(
|
||||||
Blocks.NETHER_WART_BLOCK,
|
Blocks.NETHER_WART_BLOCK,
|
||||||
Blocks.WARPED_WART_BLOCK,
|
Blocks.WARPED_WART_BLOCK,
|
||||||
Blocks.HAY_BLOCK,
|
Blocks.HAY_BLOCK,
|
||||||
@ -74,7 +74,7 @@ public abstract class MixinHoeItem extends MiningToolItem {
|
|||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||||
return 1.0F;
|
return 1.0F;
|
||||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||||
return viaFabricPlus$EFFECTIVE_BLOCKS_1165.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
return viaFabricPlus$effective_blocks_r1_16_5.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
||||||
} else {
|
} else {
|
||||||
return super.getMiningSpeedMultiplier(stack, state);
|
return super.getMiningSpeedMultiplier(stack, state);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
||||||
|
|
||||||
import de.florianmichael.viafabricplus.fixes.diff.ItemRegistryDiffPre1_20_2;
|
|
||||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
@ -44,7 +44,7 @@ public abstract class MixinItemPlacementContext extends ItemUsageContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "getPlayerLookDirection", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "getPlayerLookDirection", at = @At("HEAD"), cancellable = true)
|
||||||
private void get112LookDirection(CallbackInfoReturnable<Direction> cir) {
|
private void getLookDirection1_12_2(CallbackInfoReturnable<Direction> cir) {
|
||||||
final ItemPlacementContext self = (ItemPlacementContext) (Object) this;
|
final ItemPlacementContext self = (ItemPlacementContext) (Object) this;
|
||||||
final PlayerEntity player = self.getPlayer();
|
final PlayerEntity player = self.getPlayer();
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ public abstract class MixinItemPlacementContext extends ItemUsageContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "canPlace", at = @At("RETURN"), cancellable = true)
|
@Inject(method = "canPlace", at = @At("RETURN"), cancellable = true)
|
||||||
private void anvilOverride(CallbackInfoReturnable<Boolean> cir) {
|
private void canPlace1_12_2(CallbackInfoReturnable<Boolean> cir) {
|
||||||
if (!cir.getReturnValueZ() && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
if (!cir.getReturnValueZ() && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
|
||||||
cir.setReturnValue(Material1_19_4.getMaterial(this.getWorld().getBlockState(this.getBlockPos())).equals(Material1_19_4.DECORATION) && Block.getBlockFromItem(this.getStack().getItem()).equals(Blocks.ANVIL));
|
cir.setReturnValue(Material1_19_4.getMaterial(this.getWorld().getBlockState(this.getBlockPos())).equals(Material1_19_4.DECORATION) && Block.getBlockFromItem(this.getStack().getItem()).equals(Blocks.ANVIL));
|
||||||
}
|
}
|
||||||
|
@ -41,16 +41,16 @@ import java.util.Set;
|
|||||||
public abstract class MixinPickaxeItem extends MiningToolItem {
|
public abstract class MixinPickaxeItem extends MiningToolItem {
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private static final Set<Block> _b1_8_1_EFFECTIVE_BLOCKS = ImmutableSet.of(Blocks.COBBLESTONE, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.STONE, Blocks.SANDSTONE, Blocks.MOSSY_COBBLESTONE, Blocks.IRON_ORE, Blocks.IRON_BLOCK, Blocks.COAL_ORE, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.DIAMOND_ORE, Blocks.DIAMOND_BLOCK, Blocks.ICE, Blocks.NETHERRACK, Blocks.LAPIS_ORE, Blocks.LAPIS_BLOCK);
|
private static final Set<Block> viaFabricPlus$effective_blocks_b1_8_1 = ImmutableSet.of(Blocks.COBBLESTONE, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.STONE, Blocks.SANDSTONE, Blocks.MOSSY_COBBLESTONE, Blocks.IRON_ORE, Blocks.IRON_BLOCK, Blocks.COAL_ORE, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.DIAMOND_ORE, Blocks.DIAMOND_BLOCK, Blocks.ICE, Blocks.NETHERRACK, Blocks.LAPIS_ORE, Blocks.LAPIS_BLOCK);
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private static final Set<Block> _r1_15_2_EFFECTIVE_BLOCKS = ImmutableSet.of(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.POWERED_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.BLUE_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.GRANITE, Blocks.POLISHED_GRANITE, Blocks.DIORITE, Blocks.POLISHED_DIORITE, Blocks.ANDESITE, Blocks.POLISHED_ANDESITE, Blocks.STONE_SLAB, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.NETHER_BRICK_SLAB, Blocks.QUARTZ_SLAB, Blocks.RED_SANDSTONE_SLAB, Blocks.PURPUR_SLAB, Blocks.SMOOTH_QUARTZ, Blocks.SMOOTH_RED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.SMOOTH_STONE, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE, Blocks.POLISHED_GRANITE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB, Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.POLISHED_DIORITE_SLAB, Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.END_STONE_BRICK_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB, Blocks.SMOOTH_QUARTZ_SLAB, Blocks.GRANITE_SLAB, Blocks.ANDESITE_SLAB, Blocks.RED_NETHER_BRICK_SLAB, Blocks.POLISHED_ANDESITE_SLAB, Blocks.DIORITE_SLAB, Blocks.SHULKER_BOX, Blocks.BLACK_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, Blocks.CYAN_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.GREEN_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.LIGHT_GRAY_SHULKER_BOX, Blocks.LIME_SHULKER_BOX, Blocks.MAGENTA_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.WHITE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX);
|
private static final Set<Block> viaFabricPlus$effective_blocks_r1_15_2 = ImmutableSet.of(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.POWERED_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.BLUE_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.GRANITE, Blocks.POLISHED_GRANITE, Blocks.DIORITE, Blocks.POLISHED_DIORITE, Blocks.ANDESITE, Blocks.POLISHED_ANDESITE, Blocks.STONE_SLAB, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.NETHER_BRICK_SLAB, Blocks.QUARTZ_SLAB, Blocks.RED_SANDSTONE_SLAB, Blocks.PURPUR_SLAB, Blocks.SMOOTH_QUARTZ, Blocks.SMOOTH_RED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.SMOOTH_STONE, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE, Blocks.POLISHED_GRANITE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB, Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.POLISHED_DIORITE_SLAB, Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.END_STONE_BRICK_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB, Blocks.SMOOTH_QUARTZ_SLAB, Blocks.GRANITE_SLAB, Blocks.ANDESITE_SLAB, Blocks.RED_NETHER_BRICK_SLAB, Blocks.POLISHED_ANDESITE_SLAB, Blocks.DIORITE_SLAB, Blocks.SHULKER_BOX, Blocks.BLACK_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, Blocks.CYAN_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.GREEN_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.LIGHT_GRAY_SHULKER_BOX, Blocks.LIME_SHULKER_BOX, Blocks.MAGENTA_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.WHITE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX);
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private static final Set<Block> _r1_16_5_EFFECTIVE_BLOCKS = ImmutableSet.of(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.POWERED_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.NETHER_GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.BLUE_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.GRANITE, Blocks.POLISHED_GRANITE, Blocks.DIORITE, Blocks.POLISHED_DIORITE, Blocks.ANDESITE, Blocks.POLISHED_ANDESITE, Blocks.STONE_SLAB, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.NETHER_BRICK_SLAB, Blocks.QUARTZ_SLAB, Blocks.RED_SANDSTONE_SLAB, Blocks.PURPUR_SLAB, Blocks.SMOOTH_QUARTZ, Blocks.SMOOTH_RED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.SMOOTH_STONE, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE, Blocks.POLISHED_GRANITE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB, Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.POLISHED_DIORITE_SLAB, Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.END_STONE_BRICK_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB, Blocks.SMOOTH_QUARTZ_SLAB, Blocks.GRANITE_SLAB, Blocks.ANDESITE_SLAB, Blocks.RED_NETHER_BRICK_SLAB, Blocks.POLISHED_ANDESITE_SLAB, Blocks.DIORITE_SLAB, Blocks.SHULKER_BOX, Blocks.BLACK_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, Blocks.CYAN_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.GREEN_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.LIGHT_GRAY_SHULKER_BOX, Blocks.LIME_SHULKER_BOX, Blocks.MAGENTA_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.WHITE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX, Blocks.PISTON, Blocks.STICKY_PISTON, Blocks.PISTON_HEAD);
|
private static final Set<Block> viaFabricPlus$effective_blocks_r1_16_5 = ImmutableSet.of(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.POWERED_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.NETHER_GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.BLUE_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.GRANITE, Blocks.POLISHED_GRANITE, Blocks.DIORITE, Blocks.POLISHED_DIORITE, Blocks.ANDESITE, Blocks.POLISHED_ANDESITE, Blocks.STONE_SLAB, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.NETHER_BRICK_SLAB, Blocks.QUARTZ_SLAB, Blocks.RED_SANDSTONE_SLAB, Blocks.PURPUR_SLAB, Blocks.SMOOTH_QUARTZ, Blocks.SMOOTH_RED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.SMOOTH_STONE, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE, Blocks.POLISHED_GRANITE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB, Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.POLISHED_DIORITE_SLAB, Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.END_STONE_BRICK_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB, Blocks.SMOOTH_QUARTZ_SLAB, Blocks.GRANITE_SLAB, Blocks.ANDESITE_SLAB, Blocks.RED_NETHER_BRICK_SLAB, Blocks.POLISHED_ANDESITE_SLAB, Blocks.DIORITE_SLAB, Blocks.SHULKER_BOX, Blocks.BLACK_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, Blocks.CYAN_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.GREEN_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.LIGHT_GRAY_SHULKER_BOX, Blocks.LIME_SHULKER_BOX, Blocks.MAGENTA_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.WHITE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX, Blocks.PISTON, Blocks.STICKY_PISTON, Blocks.PISTON_HEAD);
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private static final Set<Material1_19_4> _r1_16_5_EFFECTIVE_MATERIALS = ImmutableSet.of(Material1_19_4.METAL, Material1_19_4.REPAIR_STATION, Material1_19_4.STONE);
|
private static final Set<Material1_19_4> viaFabricPlus$effective_materials_r1_16_5 = ImmutableSet.of(Material1_19_4.METAL, Material1_19_4.REPAIR_STATION, Material1_19_4.STONE);
|
||||||
|
|
||||||
protected MixinPickaxeItem(float attackDamage, float attackSpeed, ToolMaterial material, TagKey<Block> effectiveBlocks, Settings settings) {
|
protected MixinPickaxeItem(float attackDamage, float attackSpeed, ToolMaterial material, TagKey<Block> effectiveBlocks, Settings settings) {
|
||||||
super(attackDamage, attackSpeed, material, effectiveBlocks, settings);
|
super(attackDamage, attackSpeed, material, effectiveBlocks, settings);
|
||||||
@ -67,7 +67,7 @@ public abstract class MixinPickaxeItem extends MiningToolItem {
|
|||||||
} else if (state.isOf(Blocks.IRON_BLOCK) || state.isOf(Blocks.IRON_ORE) || state.isOf(Blocks.LAPIS_BLOCK) || state.isOf(Blocks.LAPIS_ORE)) {
|
} else if (state.isOf(Blocks.IRON_BLOCK) || state.isOf(Blocks.IRON_ORE) || state.isOf(Blocks.LAPIS_BLOCK) || state.isOf(Blocks.LAPIS_ORE)) {
|
||||||
return miningLevel >= MiningLevels.STONE;
|
return miningLevel >= MiningLevels.STONE;
|
||||||
} else {
|
} else {
|
||||||
return _r1_16_5_EFFECTIVE_MATERIALS.contains(Material1_19_4.getMaterial(state)) || state.isOf(Blocks.NETHER_GOLD_ORE);
|
return viaFabricPlus$effective_materials_r1_16_5.contains(Material1_19_4.getMaterial(state)) || state.isOf(Blocks.NETHER_GOLD_ORE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,11 +77,11 @@ public abstract class MixinPickaxeItem extends MiningToolItem {
|
|||||||
@Override
|
@Override
|
||||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||||
return _b1_8_1_EFFECTIVE_BLOCKS.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
return viaFabricPlus$effective_blocks_b1_8_1.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
||||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
|
||||||
return _r1_16_5_EFFECTIVE_MATERIALS.contains(Material1_19_4.getMaterial(state)) ? this.miningSpeed : _r1_15_2_EFFECTIVE_BLOCKS.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
return viaFabricPlus$effective_materials_r1_16_5.contains(Material1_19_4.getMaterial(state)) ? this.miningSpeed : viaFabricPlus$effective_blocks_r1_15_2.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
||||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||||
return _r1_16_5_EFFECTIVE_MATERIALS.contains(Material1_19_4.getMaterial(state)) ? this.miningSpeed : _r1_16_5_EFFECTIVE_BLOCKS.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
return viaFabricPlus$effective_materials_r1_16_5.contains(Material1_19_4.getMaterial(state)) ? this.miningSpeed : viaFabricPlus$effective_blocks_r1_16_5.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getMiningSpeedMultiplier(stack, state);
|
return super.getMiningSpeedMultiplier(stack, state);
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
||||||
|
|
||||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||||
@ -20,13 +39,6 @@ public abstract class MixinShearsItem extends Item {
|
|||||||
super(settings);
|
super(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "isSuitableFor", at = @At("HEAD"), cancellable = true)
|
|
||||||
private void changeEffectiveBlocks(BlockState state, CallbackInfoReturnable<Boolean> cir) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
|
||||||
cir.setReturnValue(state.isOf(Blocks.COBWEB));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "getMiningSpeedMultiplier", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "getMiningSpeedMultiplier", at = @At("HEAD"), cancellable = true)
|
||||||
private void changeMiningSpeed(ItemStack stack, BlockState state, CallbackInfoReturnable<Float> cir) {
|
private void changeMiningSpeed(ItemStack stack, BlockState state, CallbackInfoReturnable<Float> cir) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||||
@ -38,4 +50,11 @@ public abstract class MixinShearsItem extends Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "isSuitableFor", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void changeEffectiveBlocks(BlockState state, CallbackInfoReturnable<Boolean> cir) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||||
|
cir.setReturnValue(state.isOf(Blocks.COBWEB));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,21 +40,15 @@ import java.util.Set;
|
|||||||
public abstract class MixinShovelItem extends MiningToolItem {
|
public abstract class MixinShovelItem extends MiningToolItem {
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private static final Set<Block> _b1_8_1_EFFECTIVE_BLOCKS = ImmutableSet.of(Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.SAND, Blocks.GRAVEL, Blocks.SNOW, Blocks.SNOW_BLOCK, Blocks.CLAY, Blocks.FARMLAND);
|
private static final Set<Block> viaFabricPlus$effective_blocks_b1_8_1 = ImmutableSet.of(Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.SAND, Blocks.GRAVEL, Blocks.SNOW, Blocks.SNOW_BLOCK, Blocks.CLAY, Blocks.FARMLAND);
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private static final Set<Block> _r1_16_5_EFFECTIVE_BLOCKS = ImmutableSet.of(Blocks.CLAY, Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL, Blocks.FARMLAND, Blocks.GRASS_BLOCK, Blocks.GRAVEL, Blocks.MYCELIUM, Blocks.SAND, Blocks.RED_SAND, Blocks.SNOW_BLOCK, Blocks.SNOW, Blocks.SOUL_SAND, Blocks.DIRT_PATH, Blocks.WHITE_CONCRETE_POWDER, Blocks.ORANGE_CONCRETE_POWDER, Blocks.MAGENTA_CONCRETE_POWDER, Blocks.LIGHT_BLUE_CONCRETE_POWDER, Blocks.YELLOW_CONCRETE_POWDER, Blocks.LIME_CONCRETE_POWDER, Blocks.PINK_CONCRETE_POWDER, Blocks.GRAY_CONCRETE_POWDER, Blocks.LIGHT_GRAY_CONCRETE_POWDER, Blocks.CYAN_CONCRETE_POWDER, Blocks.PURPLE_CONCRETE_POWDER, Blocks.BLUE_CONCRETE_POWDER, Blocks.BROWN_CONCRETE_POWDER, Blocks.GREEN_CONCRETE_POWDER, Blocks.RED_CONCRETE_POWDER, Blocks.BLACK_CONCRETE_POWDER, Blocks.SOUL_SOIL);
|
private static final Set<Block> viaFabricPlus$effective_blocks_r1_16_5 = ImmutableSet.of(Blocks.CLAY, Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL, Blocks.FARMLAND, Blocks.GRASS_BLOCK, Blocks.GRAVEL, Blocks.MYCELIUM, Blocks.SAND, Blocks.RED_SAND, Blocks.SNOW_BLOCK, Blocks.SNOW, Blocks.SOUL_SAND, Blocks.DIRT_PATH, Blocks.WHITE_CONCRETE_POWDER, Blocks.ORANGE_CONCRETE_POWDER, Blocks.MAGENTA_CONCRETE_POWDER, Blocks.LIGHT_BLUE_CONCRETE_POWDER, Blocks.YELLOW_CONCRETE_POWDER, Blocks.LIME_CONCRETE_POWDER, Blocks.PINK_CONCRETE_POWDER, Blocks.GRAY_CONCRETE_POWDER, Blocks.LIGHT_GRAY_CONCRETE_POWDER, Blocks.CYAN_CONCRETE_POWDER, Blocks.PURPLE_CONCRETE_POWDER, Blocks.BLUE_CONCRETE_POWDER, Blocks.BROWN_CONCRETE_POWDER, Blocks.GREEN_CONCRETE_POWDER, Blocks.RED_CONCRETE_POWDER, Blocks.BLACK_CONCRETE_POWDER, Blocks.SOUL_SOIL);
|
||||||
|
|
||||||
protected MixinShovelItem(float attackDamage, float attackSpeed, ToolMaterial material, TagKey<Block> effectiveBlocks, Item.Settings settings) {
|
protected MixinShovelItem(float attackDamage, float attackSpeed, ToolMaterial material, TagKey<Block> effectiveBlocks, Item.Settings settings) {
|
||||||
super(attackDamage, attackSpeed, material, effectiveBlocks, settings);
|
super(attackDamage, attackSpeed, material, effectiveBlocks, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "useOnBlock", slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/item/ShovelItem;PATH_STATES:Ljava/util/Map;")), at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 0, remap = false))
|
|
||||||
private Object disablePathAction(Map<Object, Object> instance, Object grassBlock) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) return null;
|
|
||||||
return instance.get(grassBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSuitableFor(BlockState state) {
|
public boolean isSuitableFor(BlockState state) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||||
@ -63,12 +57,18 @@ public abstract class MixinShovelItem extends MiningToolItem {
|
|||||||
return super.isSuitableFor(state);
|
return super.isSuitableFor(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "useOnBlock", slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/item/ShovelItem;PATH_STATES:Ljava/util/Map;")), at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 0, remap = false))
|
||||||
|
private Object disablePathAction(Map<Object, Object> instance, Object grassBlock) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) return null;
|
||||||
|
return instance.get(grassBlock);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
|
||||||
return _b1_8_1_EFFECTIVE_BLOCKS.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
return viaFabricPlus$effective_blocks_b1_8_1.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
||||||
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
|
||||||
return _r1_16_5_EFFECTIVE_BLOCKS.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
return viaFabricPlus$effective_blocks_r1_16_5.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getMiningSpeedMultiplier(stack, state);
|
return super.getMiningSpeedMultiplier(stack, state);
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.packet;
|
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.network;
|
||||||
|
|
||||||
import de.florianmichael.viafabricplus.fixes.ClientsideFixes;
|
import de.florianmichael.viafabricplus.fixes.ClientsideFixes;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
@ -51,6 +51,16 @@ public abstract class MixinClientCommonNetworkHandler {
|
|||||||
|
|
||||||
@Shadow public abstract void sendPacket(Packet<?> packet);
|
@Shadow public abstract void sendPacket(Packet<?> packet);
|
||||||
|
|
||||||
|
@Redirect(method = "onKeepAlive", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientCommonNetworkHandler;send(Lnet/minecraft/network/packet/Packet;Ljava/util/function/BooleanSupplier;Ljava/time/Duration;)V"))
|
||||||
|
private void forceSendKeepAlive(ClientCommonNetworkHandler instance, Packet<? extends ServerPacketListener> packet, BooleanSupplier sendCondition, Duration expiry) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
|
||||||
|
sendPacket(packet);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
send(packet, sendCondition, expiry);
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "onPing", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkThreadUtils;forceMainThread(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;Lnet/minecraft/util/thread/ThreadExecutor;)V", shift = At.Shift.AFTER), cancellable = true)
|
@Inject(method = "onPing", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkThreadUtils;forceMainThread(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;Lnet/minecraft/util/thread/ThreadExecutor;)V", shift = At.Shift.AFTER), cancellable = true)
|
||||||
private void onPing(CommonPingS2CPacket packet, CallbackInfo ci) {
|
private void onPing(CommonPingS2CPacket packet, CallbackInfo ci) {
|
||||||
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_17)) {
|
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_17)) {
|
||||||
@ -68,16 +78,6 @@ public abstract class MixinClientCommonNetworkHandler {
|
|||||||
if (handler == null) ci.cancel();
|
if (handler == null) ci.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "onKeepAlive", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientCommonNetworkHandler;send(Lnet/minecraft/network/packet/Packet;Ljava/util/function/BooleanSupplier;Ljava/time/Duration;)V"))
|
|
||||||
private void forceSendKeepAlive(ClientCommonNetworkHandler instance, Packet<? extends ServerPacketListener> packet, BooleanSupplier sendCondition, Duration expiry) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_3)) {
|
|
||||||
sendPacket(packet);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
send(packet, sendCondition, expiry);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "onCustomPayload(Lnet/minecraft/network/packet/s2c/common/CustomPayloadS2CPacket;)V", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "onCustomPayload(Lnet/minecraft/network/packet/s2c/common/CustomPayloadS2CPacket;)V", at = @At("HEAD"), cancellable = true)
|
||||||
private void handleSyncTask(CustomPayloadS2CPacket packet, CallbackInfo ci) {
|
private void handleSyncTask(CustomPayloadS2CPacket packet, CallbackInfo ci) {
|
||||||
if (packet.payload().id().toString().equals(ClientsideFixes.PACKET_SYNC_IDENTIFIER) && packet.payload() instanceof PacketByteBufPayload payload) {
|
if (packet.payload().id().toString().equals(ClientsideFixes.PACKET_SYNC_IDENTIFIER) && packet.payload() instanceof PacketByteBufPayload payload) {
|
||||||
|
@ -66,11 +66,23 @@ public abstract class MixinClientPlayNetworkHandler {
|
|||||||
@Shadow
|
@Shadow
|
||||||
public abstract void onSimulationDistance(SimulationDistanceS2CPacket packet);
|
public abstract void onSimulationDistance(SimulationDistanceS2CPacket packet);
|
||||||
|
|
||||||
@Shadow
|
|
||||||
private ClientWorld world;
|
|
||||||
|
|
||||||
@Shadow public abstract ClientConnection getConnection();
|
@Shadow public abstract ClientConnection getConnection();
|
||||||
|
|
||||||
|
@WrapWithCondition(method = "onChatMessage", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
|
||||||
|
private boolean removeError(Logger instance, String s, Object o) {
|
||||||
|
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_20_2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WrapWithCondition(method = "setPublicSession", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
|
||||||
|
private boolean removeInvalidSignatureWarning(Logger instance, String s, Object o) {
|
||||||
|
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_19_4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@WrapWithCondition(method = "onPlayerList", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
|
||||||
|
private boolean removeWarning(Logger instance, String s, Object o) {
|
||||||
|
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_19_3);
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "<init>", at = @At("RETURN"))
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
private void fixPlayerListOrdering(MinecraftClient client, ClientConnection clientConnection, ClientConnectionState clientConnectionState, CallbackInfo ci) {
|
private void fixPlayerListOrdering(MinecraftClient client, ClientConnection clientConnection, ClientConnectionState clientConnectionState, CallbackInfo ci) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
|
||||||
@ -78,20 +90,9 @@ public abstract class MixinClientPlayNetworkHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "onChunkLoadDistance", at = @At("RETURN"))
|
@Redirect(method = "onServerMetadata", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/ServerMetadataS2CPacket;isSecureChatEnforced()Z"))
|
||||||
private void emulateSimulationDistance(ChunkLoadDistanceS2CPacket packet, CallbackInfo ci) {
|
private boolean removeSecureChatWarning(ServerMetadataS2CPacket instance) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_17_1)) {
|
return instance.isSecureChatEnforced() || VisualSettings.global().disableSecureChatWarning.isEnabled();
|
||||||
this.onSimulationDistance(new SimulationDistanceS2CPacket(packet.getDistance()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = {"onGameJoin", "onPlayerRespawn"}, at = @At("TAIL"))
|
|
||||||
private void injectOnOnGameJoinOrRespawn(CallbackInfo ci) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
|
||||||
ClientPlayerEntity player = MinecraftClient.getInstance().player;
|
|
||||||
assert player != null;
|
|
||||||
onEntityStatus(new EntityStatusS2CPacket(player, (byte) 28));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@WrapWithCondition(method = "onPlayerSpawnPosition", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/DownloadingTerrainScreen;setReady()V"))
|
@WrapWithCondition(method = "onPlayerSpawnPosition", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/DownloadingTerrainScreen;setReady()V"))
|
||||||
@ -114,19 +115,11 @@ public abstract class MixinClientPlayNetworkHandler {
|
|||||||
return constant;
|
return constant;
|
||||||
}
|
}
|
||||||
|
|
||||||
@WrapWithCondition(method = "onPlayerList", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
|
@Inject(method = "onChunkLoadDistance", at = @At("RETURN"))
|
||||||
private boolean removeWarning(Logger instance, String s, Object o) {
|
private void emulateSimulationDistance(ChunkLoadDistanceS2CPacket packet, CallbackInfo ci) {
|
||||||
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_19_3);
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_17_1)) {
|
||||||
}
|
this.onSimulationDistance(new SimulationDistanceS2CPacket(packet.getDistance()));
|
||||||
|
}
|
||||||
@WrapWithCondition(method = "onChatMessage", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
|
|
||||||
private boolean removeError(Logger instance, String s, Object o) {
|
|
||||||
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_20_2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "onServerMetadata", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/ServerMetadataS2CPacket;isSecureChatEnforced()Z"))
|
|
||||||
private boolean removeSecureChatWarning(ServerMetadataS2CPacket instance) {
|
|
||||||
return instance.isSecureChatEnforced() || VisualSettings.global().disableSecureChatWarning.isEnabled();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "onSynchronizeRecipes", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/SynchronizeRecipesS2CPacket;getRecipes()Ljava/util/List;"))
|
@Redirect(method = "onSynchronizeRecipes", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/SynchronizeRecipesS2CPacket;getRecipes()Ljava/util/List;"))
|
||||||
@ -146,9 +139,13 @@ public abstract class MixinClientPlayNetworkHandler {
|
|||||||
return instance.getRecipes();
|
return instance.getRecipes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@WrapWithCondition(method = "setPublicSession", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
|
@Inject(method = {"onGameJoin", "onPlayerRespawn"}, at = @At("TAIL"))
|
||||||
private boolean removeInvalidSignatureWarning(Logger instance, String s, Object o) {
|
private void injectOnOnGameJoinOrRespawn(CallbackInfo ci) {
|
||||||
return ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_19_4);
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||||
|
ClientPlayerEntity player = MinecraftClient.getInstance().player;
|
||||||
|
assert player != null;
|
||||||
|
onEntityStatus(new EntityStatusS2CPacket(player, (byte) 28));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.packet;
|
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.network;
|
||||||
|
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.packet;
|
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.network;
|
||||||
|
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
@ -81,19 +81,6 @@ public abstract class MixinConnectScreen_1 {
|
|||||||
return instance.getPort();
|
return instance.getPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;send(Lnet/minecraft/network/packet/Packet;)V"))
|
|
||||||
private void spoofUserName(ClientConnection instance, Packet<?> packet) {
|
|
||||||
if (AuthenticationSettings.global().setSessionNameToClassiCubeNameInServerList.getValue() && ViaFabricPlusClassicMPPassProvider.classiCubeMPPass != null) {
|
|
||||||
final var account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount();
|
|
||||||
if (account != null) {
|
|
||||||
instance.send(new LoginHelloC2SPacket(account.username(), MinecraftClient.getInstance().getSession().getUuidOrNull()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
instance.send(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;send(Lnet/minecraft/network/packet/Packet;)V", shift = At.Shift.BEFORE))
|
@Inject(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;send(Lnet/minecraft/network/packet/Packet;)V", shift = At.Shift.BEFORE))
|
||||||
private void setupConnectionSessions(CallbackInfo ci) {
|
private void setupConnectionSessions(CallbackInfo ci) {
|
||||||
final ClientConnection connection = field_2416.connection;
|
final ClientConnection connection = field_2416.connection;
|
||||||
|
@ -60,13 +60,6 @@ public abstract class MixinGameModeSelectionScreen extends Screen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "init", at = @At("HEAD"))
|
|
||||||
private void disableInClassic(CallbackInfo ci) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) { // survival mode was added in a1.0.15
|
|
||||||
this.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "init", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;VALUES:[Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;"))
|
@Redirect(method = "init", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;VALUES:[Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;"))
|
||||||
private GameModeSelectionScreen.GameModeSelection[] removeNewerGameModes() {
|
private GameModeSelectionScreen.GameModeSelection[] removeNewerGameModes() {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
|
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
|
||||||
@ -76,4 +69,11 @@ public abstract class MixinGameModeSelectionScreen extends Screen {
|
|||||||
return GameModeSelectionScreen.GameModeSelection.values();
|
return GameModeSelectionScreen.GameModeSelection.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "init", at = @At("HEAD"))
|
||||||
|
private void disableInClassic(CallbackInfo ci) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) { // survival mode was added in a1.0.15
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,19 +40,6 @@ public abstract class MixinGameModeSelectionScreen_GameModeSelection {
|
|||||||
|
|
||||||
@Shadow @Final public static GameModeSelectionScreen.GameModeSelection CREATIVE;
|
@Shadow @Final public static GameModeSelectionScreen.GameModeSelection CREATIVE;
|
||||||
|
|
||||||
@Inject(method = "getCommand", at = @At("HEAD"), cancellable = true)
|
|
||||||
private void oldCommand(CallbackInfoReturnable<String> cir) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_2_4tor1_2_5)) {
|
|
||||||
cir.setReturnValue(
|
|
||||||
"gamemode " + MinecraftClient.getInstance().getSession().getUsername() + ' ' + switch (((Enum<?>)(Object)this).ordinal()) {
|
|
||||||
case 0, 3 -> 1;
|
|
||||||
case 1, 2 -> 0;
|
|
||||||
default -> throw new AssertionError();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "next", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "next", at = @At("HEAD"), cancellable = true)
|
||||||
private void unwrapGameModes(CallbackInfoReturnable<Optional<GameModeSelectionScreen.GameModeSelection>> cir) {
|
private void unwrapGameModes(CallbackInfoReturnable<Optional<GameModeSelectionScreen.GameModeSelection>> cir) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
|
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
|
||||||
@ -70,4 +57,17 @@ public abstract class MixinGameModeSelectionScreen_GameModeSelection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "getCommand", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void oldCommand(CallbackInfoReturnable<String> cir) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_2_4tor1_2_5)) {
|
||||||
|
cir.setReturnValue(
|
||||||
|
"gamemode " + MinecraftClient.getInstance().getSession().getUsername() + ' ' + switch (((Enum<?>)(Object)this).ordinal()) {
|
||||||
|
case 0, 3 -> 1;
|
||||||
|
case 1, 2 -> 0;
|
||||||
|
default -> throw new AssertionError();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,13 @@ public abstract class MixinPlayerScreenHandler extends AbstractRecipeScreenHandl
|
|||||||
super(screenHandlerType, i);
|
super(screenHandlerType, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "onContentChanged", at = @At("HEAD"))
|
||||||
|
public void updateResultSlot(Inventory inventory, CallbackInfo ci) {
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_11_1to1_11_2)) {
|
||||||
|
RecipesPre1_12.setCraftingResultSlot(syncId, this, craftingInput);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Redirect(method = "<init>",
|
@Redirect(method = "<init>",
|
||||||
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/screen/PlayerScreenHandler$2;<init>(Lnet/minecraft/screen/PlayerScreenHandler;Lnet/minecraft/inventory/Inventory;IIILnet/minecraft/entity/player/PlayerEntity;)V")),
|
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/screen/PlayerScreenHandler$2;<init>(Lnet/minecraft/screen/PlayerScreenHandler;Lnet/minecraft/inventory/Inventory;IIILnet/minecraft/entity/player/PlayerEntity;)V")),
|
||||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/screen/PlayerScreenHandler;addSlot(Lnet/minecraft/screen/slot/Slot;)Lnet/minecraft/screen/slot/Slot;", ordinal = 0))
|
at = @At(value = "INVOKE", target = "Lnet/minecraft/screen/PlayerScreenHandler;addSlot(Lnet/minecraft/screen/slot/Slot;)Lnet/minecraft/screen/slot/Slot;", ordinal = 0))
|
||||||
@ -64,10 +71,4 @@ public abstract class MixinPlayerScreenHandler extends AbstractRecipeScreenHandl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "onContentChanged", at = @At("HEAD"))
|
|
||||||
public void updateResultSlot(Inventory inventory, CallbackInfo ci) {
|
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_11_1to1_11_2)) {
|
|
||||||
RecipesPre1_12.setCraftingResultSlot(syncId, this, craftingInput);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,9 @@ import net.raphimc.vialoader.util.VersionRange;
|
|||||||
public class DebugSettings extends SettingGroup {
|
public class DebugSettings extends SettingGroup {
|
||||||
private static final DebugSettings instance = new DebugSettings();
|
private static final DebugSettings instance = new DebugSettings();
|
||||||
|
|
||||||
|
// 1.19.1/2 -> 1.19
|
||||||
|
public final VersionedBooleanSetting alwaysTickOnlyPlayer = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.always_tick_only_player"), VersionRange.andOlder(VersionEnum.r1_19_1tor1_19_2));
|
||||||
|
|
||||||
// 1.19 -> 1.18.2
|
// 1.19 -> 1.18.2
|
||||||
public final VersionedBooleanSetting disableSequencing = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.disable_sequencing"), VersionRange.andOlder(VersionEnum.r1_18_2));
|
public final VersionedBooleanSetting disableSequencing = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.disable_sequencing"), VersionRange.andOlder(VersionEnum.r1_18_2));
|
||||||
|
|
||||||
@ -37,6 +40,7 @@ public class DebugSettings extends SettingGroup {
|
|||||||
// 1.13 -> 1.12.2
|
// 1.13 -> 1.12.2
|
||||||
public final VersionedBooleanSetting executeInputsInSync = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.execute_inputs_in_sync"), VersionRange.andOlder(VersionEnum.r1_12_2));
|
public final VersionedBooleanSetting executeInputsInSync = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.execute_inputs_in_sync"), VersionRange.andOlder(VersionEnum.r1_12_2));
|
||||||
public final VersionedBooleanSetting sneakInstant = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.sneak_instant"), VersionRange.of(VersionEnum.r1_8, VersionEnum.r1_12_2));
|
public final VersionedBooleanSetting sneakInstant = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.sneak_instant"), VersionRange.of(VersionEnum.r1_8, VersionEnum.r1_12_2));
|
||||||
|
public final VersionedBooleanSetting skipContainersWithCustomDisplayNames = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.skip_containers_with_custom_display_names"), VersionRange.andOlder(VersionEnum.r1_12_2));
|
||||||
|
|
||||||
// 1.12 -> 1.11.1-1.11.2
|
// 1.12 -> 1.11.1-1.11.2
|
||||||
public final VersionedBooleanSetting sendOpenInventoryPacket = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.send_open_inventory_packet"), VersionRange.andOlder(VersionEnum.r1_11_1to1_11_2));
|
public final VersionedBooleanSetting sendOpenInventoryPacket = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.send_open_inventory_packet"), VersionRange.andOlder(VersionEnum.r1_11_1to1_11_2));
|
||||||
|
@ -55,6 +55,8 @@
|
|||||||
"debug_settings.viafabricplus.replace_sneaking": "Replace sneaking",
|
"debug_settings.viafabricplus.replace_sneaking": "Replace sneaking",
|
||||||
"debug_settings.viafabricplus.long_sneaking": "Long sneaking",
|
"debug_settings.viafabricplus.long_sneaking": "Long sneaking",
|
||||||
"debug_settings.viafabricplus.legacy_mining_speeds": "Legacy mining speeds",
|
"debug_settings.viafabricplus.legacy_mining_speeds": "Legacy mining speeds",
|
||||||
|
"debug_settings.viafabricplus.skip_containers_with_custom_display_names": "Skip containers with custom display names",
|
||||||
|
"debug_settings.viafabricplus.always_tick_only_player": "Always tick only player",
|
||||||
|
|
||||||
"authentication_settings.viafabricplus.use_beta_craft_authentication": "Use BetaCraft authentication",
|
"authentication_settings.viafabricplus.use_beta_craft_authentication": "Use BetaCraft authentication",
|
||||||
"authentication_settings.viafabricplus.verify_session_for_online_mode": "Verify session for online mode servers",
|
"authentication_settings.viafabricplus.verify_session_for_online_mode": "Verify session for online mode servers",
|
||||||
|
@ -27,8 +27,10 @@
|
|||||||
"compat.jsonwebtoken.MixinDefaultJwtParserBuilder",
|
"compat.jsonwebtoken.MixinDefaultJwtParserBuilder",
|
||||||
"fixes.authlib.MixinKeyPairResponse",
|
"fixes.authlib.MixinKeyPairResponse",
|
||||||
"fixes.authlib.MixinYggdrasilUserApiService",
|
"fixes.authlib.MixinYggdrasilUserApiService",
|
||||||
|
"fixes.minecraft.MixinCamera",
|
||||||
"fixes.minecraft.MixinClientPlayerInteractionManager",
|
"fixes.minecraft.MixinClientPlayerInteractionManager",
|
||||||
"fixes.minecraft.MixinFontStorage",
|
"fixes.minecraft.MixinFontStorage",
|
||||||
|
"fixes.minecraft.MixinKeyboardInput",
|
||||||
"fixes.minecraft.MixinMinecraftClient",
|
"fixes.minecraft.MixinMinecraftClient",
|
||||||
"fixes.minecraft.MixinPendingUpdateManager",
|
"fixes.minecraft.MixinPendingUpdateManager",
|
||||||
"fixes.minecraft.MixinPlayerListEntry",
|
"fixes.minecraft.MixinPlayerListEntry",
|
||||||
@ -87,8 +89,6 @@
|
|||||||
"fixes.minecraft.entity.MixinPlayerEntityRenderer",
|
"fixes.minecraft.entity.MixinPlayerEntityRenderer",
|
||||||
"fixes.minecraft.entity.MixinSquidEntity",
|
"fixes.minecraft.entity.MixinSquidEntity",
|
||||||
"fixes.minecraft.entity.MixinWolfEntity",
|
"fixes.minecraft.entity.MixinWolfEntity",
|
||||||
"fixes.minecraft.input.MixinCamera",
|
|
||||||
"fixes.minecraft.input.MixinKeyboardInput",
|
|
||||||
"fixes.minecraft.item.MixinAxeItem",
|
"fixes.minecraft.item.MixinAxeItem",
|
||||||
"fixes.minecraft.item.MixinBlockItem",
|
"fixes.minecraft.item.MixinBlockItem",
|
||||||
"fixes.minecraft.item.MixinDrawContext",
|
"fixes.minecraft.item.MixinDrawContext",
|
||||||
@ -107,11 +107,11 @@
|
|||||||
"fixes.minecraft.item.MixinPickaxeItem",
|
"fixes.minecraft.item.MixinPickaxeItem",
|
||||||
"fixes.minecraft.item.MixinShovelItem",
|
"fixes.minecraft.item.MixinShovelItem",
|
||||||
"fixes.minecraft.item.MixinSwordItem",
|
"fixes.minecraft.item.MixinSwordItem",
|
||||||
|
"fixes.minecraft.network.MixinChatMessageC2SPacket",
|
||||||
"fixes.minecraft.network.MixinClientCommonNetworkHandler",
|
"fixes.minecraft.network.MixinClientCommonNetworkHandler",
|
||||||
"fixes.minecraft.network.MixinClientPlayNetworkHandler",
|
"fixes.minecraft.network.MixinClientPlayNetworkHandler",
|
||||||
"fixes.minecraft.packet.MixinChatMessageC2SPacket",
|
"fixes.minecraft.network.MixinPacketByteBuf",
|
||||||
"fixes.minecraft.packet.MixinPacketByteBuf",
|
"fixes.minecraft.network.MixinUpdatePlayerAbilitiesC2SPacket",
|
||||||
"fixes.minecraft.packet.MixinUpdatePlayerAbilitiesC2SPacket",
|
|
||||||
"fixes.minecraft.screen.MixinAbstractSignEditScreen",
|
"fixes.minecraft.screen.MixinAbstractSignEditScreen",
|
||||||
"fixes.minecraft.screen.MixinAnvilScreen",
|
"fixes.minecraft.screen.MixinAnvilScreen",
|
||||||
"fixes.minecraft.screen.MixinChatScreen",
|
"fixes.minecraft.screen.MixinChatScreen",
|
||||||
@ -168,6 +168,7 @@
|
|||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"base.integration.MixinConnectScreen_1",
|
||||||
"fixes.minecraft.entity.MixinBoatEntity",
|
"fixes.minecraft.entity.MixinBoatEntity",
|
||||||
"fixes.minecraft.entity.MixinSkeletonHorseEntity",
|
"fixes.minecraft.entity.MixinSkeletonHorseEntity",
|
||||||
"fixes.minecraft.item.MixinArmorItem",
|
"fixes.minecraft.item.MixinArmorItem",
|
||||||
|
Loading…
Reference in New Issue
Block a user