Skip to content

Commit

Permalink
Fix kicked for flying in rocket
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexNijjar committed Jan 16, 2024
1 parent f67145b commit ecbcf1a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package earth.terrarium.adastra.mixins.common;

import earth.terrarium.adastra.common.entities.vehicles.Vehicle;
import earth.terrarium.adastra.common.items.armor.JetSuitItem;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
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;

@Mixin(ServerGamePacketListenerImpl.class)
public abstract class ServerGamePacketListenerImplMixin {

@Shadow
private int aboveGroundTickCount;
@Shadow
private int aboveGroundVehicleTickCount;

@Shadow
public ServerPlayer player;

@Inject(method = "tick", at = @At("HEAD"))
public void adastra$tick(CallbackInfo ci) {
if (player.tickCount % 50 == 0) {
// Prevent the player from being kicked for flying a jet suit.
if (!player.onGround() && JetSuitItem.hasFullSet(player)) {
aboveGroundTickCount = 0;
}

// Prevent the player from being kicked for flying in a rocket.
if (player.getVehicle() instanceof Vehicle) {
aboveGroundVehicleTickCount = 0;
}
}
}
}
1 change: 1 addition & 0 deletions common/src/main/resources/adastra-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"common.LivingEntityMixin",
"common.MobMixin",
"common.PlayerMixin",
"common.ServerGamePacketListenerImplMixin",
"common.ServerLevelMixin",
"common.SkullBlockEntityInvoker",
"common.SlotAccessor",
Expand Down

0 comments on commit ecbcf1a

Please sign in to comment.