-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef763be
commit f87774a
Showing
14 changed files
with
273 additions
and
93 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
.../com/viaversion/viafabricplus/injection/mixin/features/interaction/MixinPlayerEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus | ||
* Copyright (C) 2021-2025 the original authors | ||
* - FlorianMichael/EnZaXD <florian.michael07@gmail.com> | ||
* - RK_01/RaphiMC | ||
* Copyright (C) 2023-2025 ViaVersion 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 com.viaversion.viafabricplus.injection.mixin.features.interaction; | ||
|
||
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; | ||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; | ||
import net.minecraft.entity.player.PlayerAbilities; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(PlayerEntity.class) | ||
public abstract class MixinPlayerEntity { | ||
|
||
@Shadow | ||
@Final | ||
private PlayerAbilities abilities; | ||
|
||
@Inject(method = "canConsume", at = @At("HEAD"), cancellable = true) | ||
private void preventEatingFoodInCreative(boolean ignoreHunger, CallbackInfoReturnable<Boolean> cir) { | ||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4) && this.abilities.invulnerable) { | ||
cir.setReturnValue(false); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ public abstract class MixinEntity { | |
|
||
@Shadow | ||
private Vec3d pos; | ||
|
||
@Shadow | ||
private World world; | ||
|
||
|
44 changes: 44 additions & 0 deletions
44
...on/viafabricplus/injection/mixin/features/movement/constants/MixinClientPlayerEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus | ||
* Copyright (C) 2021-2025 the original authors | ||
* - FlorianMichael/EnZaXD <florian.michael07@gmail.com> | ||
* - RK_01/RaphiMC | ||
* Copyright (C) 2023-2025 ViaVersion 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 com.viaversion.viafabricplus.injection.mixin.features.movement.constants; | ||
|
||
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; | ||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; | ||
import net.minecraft.client.network.ClientPlayerEntity; | ||
import net.minecraft.util.math.MathHelper; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(value = ClientPlayerEntity.class, priority = 2000) | ||
public abstract class MixinClientPlayerEntity { | ||
|
||
@Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;square(D)D")) | ||
private double changeMagnitude(double n) { | ||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_18)) { | ||
return 9.0E-4D; | ||
} else { | ||
return MathHelper.square(n); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...om/viaversion/viafabricplus/injection/mixin/features/movement/jump/MixinLivingEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus | ||
* Copyright (C) 2021-2025 the original authors | ||
* - FlorianMichael/EnZaXD <florian.michael07@gmail.com> | ||
* - RK_01/RaphiMC | ||
* Copyright (C) 2023-2025 ViaVersion 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 com.viaversion.viafabricplus.injection.mixin.features.movement.jump; | ||
|
||
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; | ||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.raphimc.vialegacy.api.LegacyProtocolVersion; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(LivingEntity.class) | ||
public abstract class MixinLivingEntity { | ||
|
||
@Shadow | ||
protected boolean jumping; | ||
|
||
@Shadow | ||
private int jumpingCooldown; | ||
|
||
@Redirect(method = "applyMovementInput", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/LivingEntity;jumping:Z")) | ||
private boolean disableJumpOnLadder(LivingEntity self) { | ||
return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_13_2) && jumping; | ||
} | ||
|
||
@Inject(method = "tickMovement", at = @At("HEAD")) | ||
private void removeJumpDelay(CallbackInfo ci) { | ||
if (ProtocolTranslator.getTargetVersion().olderThan(LegacyProtocolVersion.r1_0_0tor1_0_1)) { | ||
this.jumpingCooldown = 0; | ||
} | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...version/viafabricplus/injection/mixin/features/movement/limitation/MixinPlayerEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus | ||
* Copyright (C) 2021-2025 the original authors | ||
* - FlorianMichael/EnZaXD <florian.michael07@gmail.com> | ||
* - RK_01/RaphiMC | ||
* Copyright (C) 2023-2025 ViaVersion 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 com.viaversion.viafabricplus.injection.mixin.features.movement.limitation; | ||
|
||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; | ||
import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; | ||
import net.minecraft.entity.*; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.*; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(PlayerEntity.class) | ||
public abstract class MixinPlayerEntity extends LivingEntity { | ||
|
||
protected MixinPlayerEntity(EntityType<? extends LivingEntity> entityType, World world) { | ||
super(entityType, world); | ||
} | ||
|
||
@Inject(method = "isClimbing", at = @At("HEAD"), cancellable = true) | ||
private void allowClimbingWhileFlying(CallbackInfoReturnable<Boolean> cir) { | ||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21_2)) { | ||
cir.setReturnValue(super.isClimbing()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.