Utils ported
This commit is contained in:
@@ -74,15 +74,15 @@ public class ServerHelper extends CommonHelper {
|
||||
@Override
|
||||
public void sendToAllNearExcept(final PlayerEntity p, final double x, final double y, final double z,
|
||||
final double dist, final World w, final BasePacket packet) {
|
||||
if (Platform.isClient()) {
|
||||
if (w.isClient()) {
|
||||
return;
|
||||
}
|
||||
for (final PlayerEntity o : this.getPlayers()) {
|
||||
final ServerPlayerEntity entityplayermp = (ServerPlayerEntity) o;
|
||||
if (entityplayermp != p && entityplayermp.world == w) {
|
||||
final double dX = x - entityplayermp.getPosX();
|
||||
final double dY = y - entityplayermp.getPosY();
|
||||
final double dZ = z - entityplayermp.getPosZ();
|
||||
final double dX = x - entityplayermp.getX();
|
||||
final double dY = y - entityplayermp.getY();
|
||||
final double dZ = z - entityplayermp.getZ();
|
||||
if (dX * dX + dY * dY + dZ * dZ < dist * dist) {
|
||||
NetworkHandler.instance().sendTo(packet, entityplayermp);
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class ServerHelper extends CommonHelper {
|
||||
protected CableRenderMode renderModeForPlayer(final PlayerEntity player) {
|
||||
if (player != null) {
|
||||
for (int x = 0; x < PlayerInventory.getHotbarSize(); x++) {
|
||||
final ItemStack is = player.inventory.getStackInSlot(x);
|
||||
final ItemStack is = player.inventory.getStack(x);
|
||||
|
||||
if (!is.isEmpty() && is.getItem() instanceof NetworkToolItem) {
|
||||
final CompoundTag c = is.getTag();
|
||||
|
||||
@@ -33,11 +33,11 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.HoverEvent;
|
||||
import net.minecraft.world.chunk.ChunkStatus;
|
||||
@@ -84,7 +84,7 @@ public class TestMeteoritesCommand implements ISubCommand {
|
||||
BlockPos centerBlock;
|
||||
if (player != null) {
|
||||
world = player.getServerWorld();
|
||||
centerBlock = new BlockPos(player.getPosX(), 0, player.getPosZ());
|
||||
centerBlock = new BlockPos(player.getX(), 0, player.getPosZ());
|
||||
} else {
|
||||
world = srv.getWorld(DimensionType.OVERWORLD);
|
||||
centerBlock = world.getSpawnPoint();
|
||||
@@ -173,7 +173,7 @@ public class TestMeteoritesCommand implements ISubCommand {
|
||||
// Add a tooltip
|
||||
Text tooltip = new LiteralText(settings.toString() + "\nBiome: ")
|
||||
.append(world.getBiome(pos).getName());
|
||||
msg.applyTextStyle(style -> style.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, tooltip)));
|
||||
msg.formatted(style -> style.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, tooltip)));
|
||||
|
||||
sender.sendFeedback(msg, true);
|
||||
}
|
||||
@@ -191,8 +191,8 @@ public class TestMeteoritesCommand implements ISubCommand {
|
||||
String displayText = String.format(Locale.ROOT, "pos=%d,%d,%d", tpPos.getX(), tpPos.getY(), tpPos.getZ());
|
||||
String tpCommand = String.format(Locale.ROOT, "/tp @s %d %d %d", tpPos.getX(), tpPos.getY(), tpPos.getZ());
|
||||
|
||||
return new LiteralText(displayText).applyTextStyle(TextFormatting.UNDERLINE)
|
||||
.applyTextStyle(style -> style.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, tpCommand)));
|
||||
return new LiteralText(displayText).formatted(Formatting.UNDERLINE)
|
||||
.formatted(style -> style.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, tpCommand)));
|
||||
}
|
||||
|
||||
private static MeteoriteStructurePiece getMeteoritePieceFromChunk(IChunk chunk) {
|
||||
|
||||
@@ -66,7 +66,7 @@ public class TestOreGenCommand implements ISubCommand {
|
||||
try {
|
||||
ServerPlayerEntity player = sender.asPlayer();
|
||||
world = player.getServerWorld();
|
||||
center = new BlockPos(player.getPosX(), 0, player.getPosZ());
|
||||
center = new BlockPos(player.getX(), 0, player.getPosZ());
|
||||
} catch (CommandSyntaxException e) {
|
||||
world = srv.getWorld(DimensionType.OVERWORLD);
|
||||
center = world.getSpawnPoint();
|
||||
|
||||
Reference in New Issue
Block a user