diff --git a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java
index 15ca96f4..cc5eb0cd 100644
--- a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java
+++ b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java
@@ -53,9 +53,6 @@ import java.io.File;
* - Fix MixinAbstractDonkeyEntity
* - Boats are probably broken. Check entity height offset fix
* - 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
* - Fix third party implementations properly
*/
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinConnectScreen_1.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinConnectScreen_1.java
new file mode 100644
index 00000000..44a1fd49
--- /dev/null
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinConnectScreen_1.java
@@ -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 .
+ */
+
+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);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/input/MixinCamera.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinCamera.java
similarity index 99%
rename from src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/input/MixinCamera.java
rename to src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinCamera.java
index 858b2e9b..048335b4 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/input/MixinCamera.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinCamera.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-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 net.minecraft.client.render.Camera;
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinClientPlayerInteractionManager.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinClientPlayerInteractionManager.java
index 0aa1fb3e..4a715bbc 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinClientPlayerInteractionManager.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinClientPlayerInteractionManager.java
@@ -83,10 +83,17 @@ public abstract class MixinClientPlayerInteractionManager {
@Unique
private List viaFabricPlus$oldItems;
- @Inject(method = "breakBlock", at = @At("TAIL"))
- private void resetBlockBreaking(BlockPos pos, CallbackInfoReturnable cir) {
- if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_3)) {
- this.currentBreakingPos = new BlockPos(this.currentBreakingPos.getX(), -1, this.currentBreakingPos.getZ());
+ @Inject(method = "getBlockBreakingProgress", at = @At("HEAD"), cancellable = true)
+ private void changeCalculation(CallbackInfoReturnable cir) {
+ if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
+ 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);
}
- @Inject(method = "interactItem", at = @At("HEAD"))
- private void trackLastUsedItem(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) {
- ViaFabricPlusHandItemProvider.lastUsedItem = player.getStackInHand(hand).copy();
- }
-
- @Inject(method = "interactBlock", at = @At("HEAD"))
- private void trackLastUsedBlock(ClientPlayerEntity player, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable cir) {
- ViaFabricPlusHandItemProvider.lastUsedItem = player.getStackInHand(hand).copy();
+ @Inject(method = "breakBlock", at = @At("TAIL"))
+ private void resetBlockBreaking(BlockPos pos, CallbackInfoReturnable cir) {
+ if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_3)) {
+ this.currentBreakingPos = new BlockPos(this.currentBreakingPos.getX(), -1, this.currentBreakingPos.getZ());
+ }
}
@Unique
@@ -183,18 +187,14 @@ public abstract class MixinClientPlayerInteractionManager {
return interactBlockInternal(player, hand, hitResult);
}
- @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());
- }
+ @Inject(method = "interactItem", at = @At("HEAD"))
+ private void trackLastUsedItem(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) {
+ ViaFabricPlusHandItemProvider.lastUsedItem = player.getStackInHand(hand).copy();
}
- @Inject(method = "getBlockBreakingProgress", at = @At("HEAD"), cancellable = true)
- private void changeCalculation(CallbackInfoReturnable cir) {
- if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
- cir.setReturnValue((int)(this.currentBreakingProgress * 10.0F) - 1);
- }
+ @Inject(method = "interactBlock", at = @At("HEAD"))
+ private void trackLastUsedBlock(ClientPlayerEntity player, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable cir) {
+ ViaFabricPlusHandItemProvider.lastUsedItem = player.getStackInHand(hand).copy();
}
}
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/input/MixinKeyboardInput.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinKeyboardInput.java
similarity index 99%
rename from src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/input/MixinKeyboardInput.java
rename to src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinKeyboardInput.java
index 8d5877bf..fdc0c82f 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/input/MixinKeyboardInput.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinKeyboardInput.java
@@ -17,7 +17,7 @@
* along with this program. If not, see .
*/
-package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.input;
+package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.MinecraftClient;
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinMinecraftClient.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinMinecraftClient.java
index b3943579..e77c251e 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinMinecraftClient.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinMinecraftClient.java
@@ -60,48 +60,6 @@ public abstract class MixinMinecraftClient {
@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
private final ConcurrentLinkedDeque 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;
+ }
+
}
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractBlock_AbstractBlockState.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractBlock_AbstractBlockState.java
index 7faa9cc9..b09ef6b9 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractBlock_AbstractBlockState.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractBlock_AbstractBlockState.java
@@ -59,9 +59,13 @@ public abstract class MixinAbstractBlock_AbstractBlockState {
@Inject(method = "getHardness", at = @At("RETURN"), cancellable = true)
private void changeHardness(BlockView world, BlockPos pos, CallbackInfoReturnable cir) {
final Block block = this.getBlock();
- if (block.equals(Blocks.OBSIDIAN)) {
- if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
- cir.setReturnValue(10.0F);
+ 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);
+ }
+ } 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) {
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)) {
cir.setReturnValue(0F);
}
- } 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.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);
+ } else if (block.equals(Blocks.OBSIDIAN)) {
+ if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
+ cir.setReturnValue(10.0F);
}
}
}
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinBedBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinBedBlock.java
index a5f55e78..98b4eca7 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinBedBlock.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinBedBlock.java
@@ -42,13 +42,6 @@ public abstract class MixinBedBlock {
@Unique
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)
private void changeOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable cir) {
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();
+ }
+ }
+
}
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java
index 34621b88..624483e9 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java
@@ -73,6 +73,58 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Final
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"))
private double changeMagnitude(double n) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) {
@@ -82,6 +134,87 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
return MathHelper.square(n);
}
+ @Inject(method = "startRiding", at = @At("RETURN"))
+ private void setRotationsWhenInBoat(Entity entity, boolean force, CallbackInfoReturnable 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 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))
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
@@ -107,137 +240,6 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
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 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 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))
private void modifyPositionPacket(ClientPlayNetworkHandler instance, Packet> packet) throws Exception {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_5_2)) {
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java
index 74773f3e..3be38056 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java
@@ -74,12 +74,50 @@ public abstract class MixinEntity implements IEntity {
@Unique
private boolean viaFabricPlus$isInLoadedChunkAndShouldTick;
- @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;
+ @Inject(method = "getRidingOffset", at = @At("HEAD"), cancellable = true)
+ private void getRidingOffset1_20_1(Entity vehicle, CallbackInfoReturnable cir) {
+ if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
+ 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 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)
@@ -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)
private void revertCalculation(float pitch, float yaw, CallbackInfoReturnable cir) {
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 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 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
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*/;
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java
index 384898f0..e3fd46ed 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java
@@ -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.protocolhack.ProtocolHack;
+import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.TrapdoorBlock;
import net.minecraft.entity.*;
@@ -72,17 +73,62 @@ public abstract class MixinLivingEntity extends Entity {
super(type, world);
}
- @Inject(method = "", at = @At("RETURN"))
- private void modify1_7StepHeight(EntityType extends LivingEntity> type, World world, CallbackInfo ci) {
- if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
- this.setStepHeight(0.5F);
+ @Inject(method = "getRidingOffset", at = @At("HEAD"), cancellable = true)
+ private void getRidingOffset1_20_1(Entity vehicle, CallbackInfoReturnable cir) {
+ if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1)) {
+ cir.setReturnValue((float) EntityHeightOffsetsPre1_20_2.getHeightOffset(this));
}
}
- @Inject(method = "getPreferredEquipmentSlot", at = @At("HEAD"), cancellable = true)
- private static void removeShieldSlotPreference(ItemStack stack, CallbackInfoReturnable cir) {
- if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_9_3tor1_9_4) && stack.isOf(Items.SHIELD)) {
- cir.setReturnValue(EquipmentSlot.MAINHAND);
+ @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);
+ }
+
+ @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 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;
}
- @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)
private boolean modifyMovingDown(boolean movingDown) {
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 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))
private double modifyVelocityZero(final double constant) {
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))
- private float modifySwimFriction(float constant) {
- if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
- return this.getBaseMovementSpeedMultiplier();
+ @Inject(method = "", at = @At("RETURN"))
+ private void modify1_7StepHeight(EntityType extends LivingEntity> type, World world, CallbackInfo ci) {
+ if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
+ this.setStepHeight(0.5F);
}
- return constant;
}
@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 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)
private void allowGappedLadderClimb(CallbackInfoReturnable cir) {
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 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);
- }
-
}
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLockableContainerBlockEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLockableContainerBlockEntity.java
index c9679777..05c65509 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLockableContainerBlockEntity.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLockableContainerBlockEntity.java
@@ -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.WrapOperation;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
+import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
import net.minecraft.block.entity.LockableContainerBlockEntity;
import net.minecraft.text.MutableText;
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;"))
private MutableText allowInvalidJson(String json, Operation operation) {
- if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
+ if (DebugSettings.global().skipContainersWithCustomDisplayNames.isEnabled()) {
try {
return operation.call(json);
} catch (Exception e) { // In case the json is invalid for the modern client, we just return the raw json
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java
index f62c481f..f416a5c5 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java
@@ -72,6 +72,58 @@ public abstract class MixinPlayerEntity extends LivingEntity {
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 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)
private void onUpdatePose(CallbackInfo ci) {
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)
private void removeAttackCooldown(CallbackInfoReturnable ci) {
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 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
- * @reason ProtocolHack block break speed changes
+ * @author Mojang, RK_01
+ * @reason Block break speed calculation changes
*/
@Overwrite
public float getBlockBreakingSpeed(BlockState block) {
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java
index cdb17661..36fe6b35 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java
@@ -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 .
+ */
+
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java
index 29d6e90e..bbe06293 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java
@@ -53,13 +53,6 @@ public abstract class MixinAxeItem extends MiningToolItem {
super(attackDamage, attackSpeed, material, effectiveBlocks, settings);
}
- @Inject(method = "useOnBlock", at = @At("HEAD"), cancellable = true)
- private void disableUse(ItemUsageContext context, CallbackInfoReturnable cir) {
- if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
- cir.setReturnValue(ActionResult.PASS);
- }
- }
-
@Override
public boolean isSuitableFor(BlockState state) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
@@ -69,6 +62,13 @@ public abstract class MixinAxeItem extends MiningToolItem {
return super.isSuitableFor(state);
}
+ @Inject(method = "useOnBlock", at = @At("HEAD"), cancellable = true)
+ private void disableUse(ItemUsageContext context, CallbackInfoReturnable cir) {
+ if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
+ cir.setReturnValue(ActionResult.PASS);
+ }
+ }
+
@Override
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBowItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBowItem.java
index 418bb5c0..b145601d 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBowItem.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBowItem.java
@@ -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 .
+ */
+
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHoeItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHoeItem.java
index beb337a2..06ab2dd1 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHoeItem.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHoeItem.java
@@ -39,7 +39,7 @@ import java.util.Set;
public abstract class MixinHoeItem extends MiningToolItem {
@Unique
- private static final Set viaFabricPlus$EFFECTIVE_BLOCKS_1165 = ImmutableSet.of(
+ private static final Set viaFabricPlus$effective_blocks_r1_16_5 = ImmutableSet.of(
Blocks.NETHER_WART_BLOCK,
Blocks.WARPED_WART_BLOCK,
Blocks.HAY_BLOCK,
@@ -74,7 +74,7 @@ public abstract class MixinHoeItem extends MiningToolItem {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
return 1.0F;
} 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 {
return super.getMiningSpeedMultiplier(stack, state);
}
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemGroup_EntriesImpl.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemGroup_EntriesImpl.java
index 93f519c0..d632eb17 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemGroup_EntriesImpl.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemGroup_EntriesImpl.java
@@ -19,7 +19,6 @@
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 net.minecraft.client.MinecraftClient;
import net.minecraft.item.Item;
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemPlacementContext.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemPlacementContext.java
index cf5703b3..2317f28a 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemPlacementContext.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemPlacementContext.java
@@ -44,7 +44,7 @@ public abstract class MixinItemPlacementContext extends ItemUsageContext {
}
@Inject(method = "getPlayerLookDirection", at = @At("HEAD"), cancellable = true)
- private void get112LookDirection(CallbackInfoReturnable cir) {
+ private void getLookDirection1_12_2(CallbackInfoReturnable cir) {
final ItemPlacementContext self = (ItemPlacementContext) (Object) this;
final PlayerEntity player = self.getPlayer();
@@ -71,7 +71,7 @@ public abstract class MixinItemPlacementContext extends ItemUsageContext {
}
@Inject(method = "canPlace", at = @At("RETURN"), cancellable = true)
- private void anvilOverride(CallbackInfoReturnable cir) {
+ private void canPlace1_12_2(CallbackInfoReturnable cir) {
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));
}
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinPickaxeItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinPickaxeItem.java
index 529f50cc..2f3e1b0e 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinPickaxeItem.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinPickaxeItem.java
@@ -41,16 +41,16 @@ import java.util.Set;
public abstract class MixinPickaxeItem extends MiningToolItem {
@Unique
- private static final Set _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 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
- private static final Set _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 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
- private static final Set _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 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
- private static final Set _r1_16_5_EFFECTIVE_MATERIALS = ImmutableSet.of(Material1_19_4.METAL, Material1_19_4.REPAIR_STATION, Material1_19_4.STONE);
+ private static final Set 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 effectiveBlocks, Settings 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)) {
return miningLevel >= MiningLevels.STONE;
} 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
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
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)) {
- 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)) {
- 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);
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShearsItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShearsItem.java
index ccd3dba3..18a65b93 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShearsItem.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShearsItem.java
@@ -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 .
+ */
+
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
@@ -20,13 +39,6 @@ public abstract class MixinShearsItem extends Item {
super(settings);
}
- @Inject(method = "isSuitableFor", at = @At("HEAD"), cancellable = true)
- private void changeEffectiveBlocks(BlockState state, CallbackInfoReturnable cir) {
- if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
- cir.setReturnValue(state.isOf(Blocks.COBWEB));
- }
- }
-
@Inject(method = "getMiningSpeedMultiplier", at = @At("HEAD"), cancellable = true)
private void changeMiningSpeed(ItemStack stack, BlockState state, CallbackInfoReturnable cir) {
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 cir) {
+ if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
+ cir.setReturnValue(state.isOf(Blocks.COBWEB));
+ }
+ }
+
}
diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShovelItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShovelItem.java
index eb473b88..e90024a5 100644
--- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShovelItem.java
+++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShovelItem.java
@@ -40,21 +40,15 @@ import java.util.Set;
public abstract class MixinShovelItem extends MiningToolItem {
@Unique
- private static final Set _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 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
- private static final Set _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 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 effectiveBlocks, Item.Settings 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