rebrand server name
This commit is contained in:
4 files changed
+17
-5
No files matched your search
@@ -1,10 +1,15 @@
|
||||
package io.ib67.sfcraft.mixin.server;
|
||||
|
||||
import io.ib67.sfcraft.module.randomevt.longnight.LongNightEvent;
|
||||
import io.ib67.sfcraft.util.Helper;
|
||||
import io.ib67.sfcraft.util.SFConsts;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class MinecraftServerMixin {
|
||||
@@ -15,4 +20,10 @@ public class MinecraftServerMixin {
|
||||
}
|
||||
return constant;
|
||||
}
|
||||
|
||||
@Inject(method = "getServerModName", at = @At("TAIL"), cancellable = true, remap = false)
|
||||
private void rebrandServerModName(CallbackInfoReturnable<String> cir) {
|
||||
cir.setReturnValue("§bsfcraft " + SFConsts.VERSION + "§r");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,10 +42,10 @@ public class BackModule extends ServerModule {
|
||||
var nearby = wld.getClosestPlayer(_pos.getX(), _pos.getY(), _pos.getZ(), 20, true);
|
||||
if (nearby != null) {
|
||||
_pos = nearby.getBlockPos();
|
||||
Helper.teleportSafely(player, wld, _pos.getX(), _pos.getY(), _pos.getZ());
|
||||
Helper.teleportSafely(player, wld, _pos.getX(), _pos.getY(), _pos.getZ(),0,0);
|
||||
} else {
|
||||
if (SFConsts.UNLIMITED_COMMAND_BACK.hasPermission(player)) {
|
||||
Helper.teleportSafely(player, wld, _pos.getX(), _pos.getY(), _pos.getZ());
|
||||
Helper.teleportSafely(player, wld, _pos.getX(), _pos.getY(), _pos.getZ(),0,0);
|
||||
return 0;
|
||||
}
|
||||
player.sendMessage(Text.of("周围没有玩家。").copy().withColor(Colors.RED));
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Helper {
|
||||
return nearby != null;
|
||||
}
|
||||
|
||||
public static boolean teleportSafely(ServerPlayerEntity player, ServerWorld world, int x, int y, int z) {
|
||||
public static boolean teleportSafely(ServerPlayerEntity player, ServerWorld world, int x, int y, int z, float yaw, float pitch) {
|
||||
var pos = new BlockPos(x, y, z);
|
||||
var stand = world.getBlockState(pos);
|
||||
if (!stand.isAir() && !stand.isSolidBlock(world, pos)) {
|
||||
@@ -55,7 +55,6 @@ public class Helper {
|
||||
var deltaY = 0.0;
|
||||
var deltaX = 0.5;
|
||||
var deltaZ = 0.5;
|
||||
var fluid = stand.getFluidState().getFluid();
|
||||
if (!stand.isAir()) {
|
||||
deltaY = stand.getCollisionShape(world, pos).getMax(Direction.Axis.Y);
|
||||
deltaY = Double.isFinite(deltaY) ? deltaY + 0.1 : 0;
|
||||
@@ -64,7 +63,7 @@ public class Helper {
|
||||
deltaZ = stand.getCollisionShape(world, pos).getMax(Direction.Axis.X);
|
||||
deltaZ = Double.isFinite(deltaZ) ? deltaZ / 2 : 0.5;
|
||||
}
|
||||
player.teleport(world, x + deltaX, y + deltaY, z + deltaZ, 0, 0);
|
||||
player.teleport(world, x + deltaX, y + deltaY, z + deltaZ, yaw, pitch);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,10 +2,12 @@ package io.ib67.sfcraft.util;
|
||||
|
||||
import io.ib67.sfcraft.util.Permission;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
@UtilityClass
|
||||
public class SFConsts {
|
||||
public static final String VERSION = FabricLoader.getInstance().getModContainer("sfcraft").get().getMetadata().getVersion().getFriendlyString();
|
||||
public static final String SPECIAL_SUDO = "sfcraft.special.state.sudo";
|
||||
public static final Permission<PlayerEntity> USE_AT = ofSFCPermission("chat.at", true);
|
||||
public static final Permission<PlayerEntity> USE_BROADCAST_LOCATION = ofSFCPermission("chat.xyz", true);
|
||||
|
||||
Reference in new issue
Block a user