Compare commits
2 Commits
6ff2142538
...
cbea81f9ce
Author | SHA1 | Date |
---|---|---|
Ryan Fox | cbea81f9ce | |
Ryan Fox | 037342e553 |
|
@ -0,0 +1,32 @@
|
|||
package party._2a03.mc.mixin;
|
||||
|
||||
import net.minecraft.entity.player.PlayerAbilities;
|
||||
import net.minecraft.world.GameMode;
|
||||
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;
|
||||
import party._2a03.mc.util.Config;
|
||||
|
||||
@Mixin(GameMode.class)
|
||||
public class MixinGameMode {
|
||||
private boolean flying;
|
||||
|
||||
@Inject(method = "setAbilities", at = @At("HEAD"))
|
||||
public void checkFlight(PlayerAbilities abilities, CallbackInfo ci) {
|
||||
this.flying = abilities.flying;
|
||||
}
|
||||
|
||||
@Inject(method = "setAbilities", at = @At("TAIL"))
|
||||
public void restoreFlight(PlayerAbilities abilities, CallbackInfo ci) {
|
||||
if (!Config.getBool("persistentFlight"))
|
||||
return;
|
||||
if (abilities.flying)
|
||||
return;
|
||||
if (this.flying) {
|
||||
abilities.allowFlying = true;
|
||||
abilities.flying = true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package party._2a03.mc.mixin;
|
|||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.GameMode;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
@ -29,4 +30,12 @@ public abstract class MixinServerPlayerEntity extends PlayerEntity {
|
|||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "setGameMode", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;sendAbilitiesUpdate()V"))
|
||||
public void disableFlightIfSafe(GameMode gameMode, CallbackInfo ci) {
|
||||
if (gameMode != GameMode.CREATIVE && gameMode != GameMode.SPECTATOR) {
|
||||
this.abilities.allowFlying = false;
|
||||
this.abilities.flying = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ public class Config {
|
|||
json = new JSONObject();
|
||||
}
|
||||
|
||||
setDefault("persistentFlight", true);
|
||||
setDefault("disableTntExplosions", false);
|
||||
setDefault("disableRespawnAnchorExplosions", false);
|
||||
setDefault("iphubApiKey", "");
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"package": "party._2a03.mc.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"server": [
|
||||
"MixinGameMode",
|
||||
"MixinGameModeCommand",
|
||||
"MixinRespawnAnchorBlock",
|
||||
"MixinServerPlayerEntity",
|
||||
|
|
Loading…
Reference in New Issue