Random cleanups to users of Level.OVERWORLD and reduce minecraft_server usage (#1697)
- Use `overworld()` instead of `getLevel(Level.OVERWORLD)` when convenient - Remove now unnecessary `// OW` comments, from when it had no mappings - Make spawn chunk size and light batches not depend on global server instance - Merge all spawn chunk size logic into SpawnChunks instead of methods in the validator - Remove unneeded `withWorld(OVERWORLD)` with just-created server `CommandSource`s - Use enhanced for in light batch application
This commit is contained in:
1 parent
17c2d601d2
commit
8cd60db5e4
6 files changed
+30
-46
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package carpet.utils;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -13,7 +12,6 @@ import net.minecraft.network.chat.TextColor;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -162,7 +160,7 @@ public class Messenger
|
||||
}
|
||||
public static Component tp(String desc, int x, int y, int z)
|
||||
{
|
||||
return getCoordsTextComponent(desc, (float)x, (float)y, (float)z, true);
|
||||
return getCoordsTextComponent(desc, x, y, z, true);
|
||||
}
|
||||
|
||||
/// to be continued
|
||||
@@ -233,7 +231,7 @@ public class Messenger
|
||||
public static void m(CommandSourceStack source, Object ... fields)
|
||||
{
|
||||
if (source != null)
|
||||
source.sendSuccess(Messenger.c(fields),source.getServer() != null && source.getServer().getLevel(Level.OVERWORLD) != null); //OW
|
||||
source.sendSuccess(Messenger.c(fields), source.getServer() != null && source.getServer().overworld() != null);
|
||||
}
|
||||
public static void m(Player player, Object ... fields)
|
||||
{
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
package carpet.utils;
|
||||
|
||||
import carpet.fakes.ChunkTicketManagerInterface;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.DistanceManager;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
|
||||
public class SpawnChunks
|
||||
{
|
||||
public static void changeSpawnChunks(ServerChunkCache chunkManager, ChunkPos pos, int size)
|
||||
public static void changeSpawnSize(ServerLevel overworld, int size)
|
||||
{
|
||||
DistanceManager ticketManager = chunkManager.chunkMap.getDistanceManager();
|
||||
((ChunkTicketManagerInterface)ticketManager).changeSpawnChunks(pos, size);
|
||||
ChunkPos centerChunk = new ChunkPos(new BlockPos(
|
||||
overworld.getLevelData().getXSpawn(),
|
||||
overworld.getLevelData().getYSpawn(),
|
||||
overworld.getLevelData().getZSpawn()
|
||||
));
|
||||
DistanceManager ticketManager = overworld.getChunkSource().chunkMap.getDistanceManager();
|
||||
((ChunkTicketManagerInterface)ticketManager).changeSpawnChunks(centerChunk, size);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user