Skip to content

Commit

Permalink
Added Rule: mountingFlyingTooLongFix back for 1.18 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
FxMorin committed Mar 1, 2022
1 parent e94202e commit 038a711
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/carpetfixes/CFSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ public class CFSettings {
)
public static boolean endVoidRingsFix = false;

//by FX - PR0CESS
@Rule(
desc = "Fixes getting kicked for flying too long when jumping and riding an entity",
extra = "Fixes [MC-98727](https://bugs.mojang.com/browse/MC-98727)",
category = {BUGFIX,RECOMMENDED,VANILLA},
condition = VersionConditions.LT_22w03a.class
)
public static boolean mountingFlyingTooLongFix = false;

//by FX - PR0CESS
@Rule(
desc = "Fixes fall damage being delayed by sleeping, fall damage will be removed instead",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package carpetfixes.mixins.playerFixes;

import carpetfixes.CFSettings;
import carpetfixes.settings.ModIds;
import carpetfixes.settings.VersionPredicates;
import me.fallenbreath.conditionalmixin.api.annotation.Condition;
import me.fallenbreath.conditionalmixin.api.annotation.Restriction;
import net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
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.CallbackInfo;

@Restriction(require = @Condition(value = ModIds.MINECRAFT, versionPredicates = VersionPredicates.LT_22w03a))
@Mixin(ServerPlayNetworkHandler.class)
public class ServerPlayNetworkHandler_vehicleFloatingMixin {

/**
* Players can get kicked for flying by mounting an entity after jumping, this is
* because the server does not realize that players mounting an entity means they
* are no longer jumping. So this fix is as simple as telling the server
* that if they are riding an entity, they should not be considered floating.
*/


@Shadow
private boolean floating;

@Shadow
public ServerPlayerEntity player;


@Inject(
method = "onVehicleMove(Lnet/minecraft/network/packet/c2s/play/VehicleMoveC2SPacket;)V",
at = @At("RETURN")
)
public void IfVehicleMovedPlayerNotFlying(VehicleMoveC2SPacket packet, CallbackInfo ci) {
if (CFSettings.mountingFlyingTooLongFix && this.player.hasVehicle() && this.player.getVehicle() != this.player)
this.floating = false;
}
}
1 change: 1 addition & 0 deletions src/main/resources/carpet-fixes.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
"playerFixes.LivingEntity_sleepingKillsMixin",
"playerFixes.PlayerManager_endPortalEffectsMixin",
"playerFixes.ServerPlayerEntity_endPortalEffectsMixin",
"playerFixes.ServerPlayNetworkHandler_vehicleFloatingMixin",
"redstoneFixes.AbstractRedstoneGateBlock_repeaterPriorityMixin",
"redstoneFixes.PistonBlock_doubleRetractionMixin",
"redstoneFixes.World_ComparatorNotUpdatingMixin",
Expand Down

0 comments on commit 038a711

Please sign in to comment.