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 64608ef commit 980b003
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
- Fixed cheese not being edible.
- Fixed etrionic blast furnace layer not being cutout.
- Fixed etrionic blast furnace skipping cooking progress when items are taken out and put back in.
- Fixed side interactions putting items in wrong slot and not working for blocks like furnaces (#423)
- Fixed side interactions putting items in wrong slot and not working for blocks like furnaces (#423)
- You can no longer get kicked for flying in a rocket or jet suit.
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.SlotAccessor",
"common.entities.CreeperMixin",
Expand Down

0 comments on commit 980b003

Please sign in to comment.