Fixing isLocalInstanceAuthoritative and getKnownMovement for EntityPlayerMPFakes (#2176)
Fixes: - At least some spear attacks - Mace attacks (not verified myself) - Fall damage (#2198) Possibly needs further checking that isLocalInstanceAuthoritative doesn't break other things, but I don't have the time right now. Co-authored-by: altrisi <altrisi.trillosierra@gmail.com>
This commit is contained in:
1 parent
1618df9e8f
commit
bf55408ff5
4 files changed
+36
-6
No files matched your search
@@ -38,7 +38,8 @@ public abstract class EntityMixin implements EntityInterface
|
||||
@Inject(method = "isLocalInstanceAuthoritative", at = @At("HEAD"), cancellable = true)
|
||||
private void isFakePlayer(CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if (getControllingPassenger() instanceof EntityPlayerMPFake) cir.setReturnValue(!level.isClientSide());
|
||||
// getControllingPassenger() does not return the EntityPlayerMPFake if there are no passengers involved with it
|
||||
if ((Object) this instanceof EntityPlayerMPFake || getControllingPassenger() instanceof EntityPlayerMPFake) cir.setReturnValue(!level.isClientSide());
|
||||
}
|
||||
|
||||
@Shadow
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Debug;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import carpet.patches.EntityPlayerMPFake;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
@Mixin(ServerPlayer.class)
|
||||
@Debug(export = true)
|
||||
public abstract class ServerPlayer_fakeLastMovementMixin extends Player {
|
||||
public ServerPlayer_fakeLastMovementMixin(Level level, GameProfile gameProfile) {
|
||||
super(level, gameProfile);
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(
|
||||
method = {"getKnownMovement", "getKnownSpeed"}, // both because ServerPlayer overrides both to the same "movement" field
|
||||
at = @At(value = "FIELD", target = "lastKnownClientMovement", opcode = Opcodes.GETFIELD),
|
||||
require = 2
|
||||
)
|
||||
private Vec3 bypassClientMovementInfo(Vec3 original) {
|
||||
return ((Player)this) instanceof EntityPlayerMPFake ? super.getKnownMovement() : original;
|
||||
}
|
||||
}
|
||||
@@ -267,11 +267,6 @@ public class EntityPlayerMPFake extends ServerPlayer
|
||||
return CarpetSettings.allowListingFakePlayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkFallDamage(double y, boolean onGround, BlockState state, BlockPos pos) {
|
||||
doCheckFallDamage(0.0, y, 0.0, onGround);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerPlayer teleport(TeleportTransition serverLevel)
|
||||
{
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
"MobMixin",
|
||||
"Villager_aiMixin",
|
||||
"Player_fakePlayersMixin",
|
||||
"ServerPlayer_fakeLastMovementMixin",
|
||||
"TickRateManager_fakePlayersMixin",
|
||||
"ServerGamePacketListenerImpl_coreMixin",
|
||||
"MinecraftServer_scarpetMixin",
|
||||
|
||||
Reference in new issue
Block a user