This commit is contained in:
gnembon committed 2025-05-07 19:33:48 +02:00
1 parent 6bed85ef8c
commit a1e4496cff
14 files changed
+38 -38

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
# check https://fabricmc.net/develop/ # check https://fabricmc.net/develop/
minecraft_version=25w18a minecraft_version=25w19a
loader_version=0.16.10 loader_version=0.16.10
jsr305_version=3.0.2 jsr305_version=3.0.2
fabric_version=0.119.5+1.21.5 fabric_version=0.119.5+1.21.5
@@ -229,7 +229,7 @@ public class PlayerCommand
{ {
if (cantReMove(context)) return 0; if (cantReMove(context)) return 0;
ServerPlayer player = getPlayer(context); ServerPlayer player = getPlayer(context);
player.kill(player.serverLevel()); player.kill(player.level());
return 1; return 1;
} }
@@ -342,7 +342,7 @@ public class PlayerCommand
return 0; return 0;
} }
EntityPlayerMPFake.createShadow(player.server, player); EntityPlayerMPFake.createShadow(player.getServer(), player);
return 1; return 1;
} }
} }
@@ -310,7 +310,7 @@ public class EntityPlayerActionPack
case BLOCK: case BLOCK:
{ {
player.resetLastActionTime(); player.resetLastActionTime();
ServerLevel world = player.serverLevel(); ServerLevel world = player.level();
BlockHitResult blockHit = (BlockHitResult) hit; BlockHitResult blockHit = (BlockHitResult) hit;
BlockPos pos = blockHit.getBlockPos(); BlockPos pos = blockHit.getBlockPos();
Direction side = blockHit.getDirection(); Direction side = blockHit.getDirection();
@@ -9,7 +9,7 @@ public class ParticleDisplay
public static void drawParticleLine(ServerPlayer player, Vec3 from, Vec3 to, ParticleOptions mainParticle, ParticleOptions accentParticle, int count, double spread) public static void drawParticleLine(ServerPlayer player, Vec3 from, Vec3 to, ParticleOptions mainParticle, ParticleOptions accentParticle, int count, double spread)
{ {
if (accentParticle != null) player.serverLevel().sendParticles( if (accentParticle != null) player.level().sendParticles(
player, player,
accentParticle, accentParticle,
true, true, true, true,
@@ -24,7 +24,7 @@ public class ParticleDisplay
delta.lengthSqr() < lineLengthSq; delta.lengthSqr() < lineLengthSq;
delta = delta.add(incvec.scale(player.level().random.nextFloat()))) delta = delta.add(incvec.scale(player.level().random.nextFloat())))
{ {
player.serverLevel().sendParticles( player.level().sendParticles(
player, player,
mainParticle, mainParticle,
true, true, true, true,
@@ -257,7 +257,7 @@ public class ServerGamePacketListenerImpl_scarpetEventsMixin
{ {
if (PLAYER_CHOOSES_RECIPE.isNeeded()) if (PLAYER_CHOOSES_RECIPE.isNeeded())
{ {
RecipeManager.ServerDisplayInfo displayInfo = player.server.getRecipeManager().getRecipeFromDisplay(packet.recipe()); RecipeManager.ServerDisplayInfo displayInfo = player.getServer().getRecipeManager().getRecipeFromDisplay(packet.recipe());
if (displayInfo == null) { if (displayInfo == null) {
return; return;
} }
@@ -26,7 +26,7 @@ public class ServerGamePacketListenerimpl_connectionMixin
// We should force onto the main thread here // We should force onto the main thread here
// ServerNetworkHandler.handleData can possibly mutate data that isn't // ServerNetworkHandler.handleData can possibly mutate data that isn't
// thread safe, and also allows for client commands to be executed // thread safe, and also allows for client commands to be executed
PacketUtils.ensureRunningOnSameThread(serverboundCustomPayloadPacket, (ServerGamePacketListener) this, player.serverLevel()); PacketUtils.ensureRunningOnSameThread(serverboundCustomPayloadPacket, (ServerGamePacketListener) this, player.level());
ServerNetworkHandler.onClientData(player, cpp.data()); ServerNetworkHandler.onClientData(player, cpp.data());
ci.cancel(); ci.cancel();
} }
@@ -61,7 +61,7 @@ public class ServerNetworkHandler
{ {
CarpetSettings.LOG.warn("Player " + playerEntity.getName().getString() + " joined with another carpet version: " + version); CarpetSettings.LOG.warn("Player " + playerEntity.getName().getString() + " joined with another carpet version: " + version);
} }
DataBuilder data = DataBuilder.create(playerEntity.server); // tickrate related settings are sent on world change DataBuilder data = DataBuilder.create(playerEntity.getServer()); // tickrate related settings are sent on world change
CarpetServer.forEachManager(sm -> sm.getCarpetRules().forEach(data::withRule)); CarpetServer.forEachManager(sm -> sm.getCarpetRules().forEach(data::withRule));
playerEntity.connection.send(data.build()); playerEntity.connection.send(data.build());
} }
@@ -110,7 +110,7 @@ public class ServerNetworkHandler
{ {
result.put("output", outputResult); result.put("output", outputResult);
} }
player.connection.send(DataBuilder.create(player.server).withCustomNbt("clientCommand", result).build()); player.connection.send(DataBuilder.create(player.getServer()).withCustomNbt("clientCommand", result).build());
// run command plug to command output, // run command plug to command output,
} }
@@ -137,7 +137,7 @@ public class ServerNetworkHandler
} }
for (ServerPlayer player : remoteCarpetPlayers.keySet()) for (ServerPlayer player : remoteCarpetPlayers.keySet())
{ {
player.connection.send(DataBuilder.create(player.server).withRule(rule).build()); player.connection.send(DataBuilder.create(player.getServer()).withRule(rule).build());
} }
} }
@@ -149,7 +149,7 @@ public class ServerNetworkHandler
} }
for (ServerPlayer player : validCarpetPlayers) for (ServerPlayer player : validCarpetPlayers)
{ {
player.connection.send(DataBuilder.create(player.server).withCustomNbt(command, data).build()); player.connection.send(DataBuilder.create(player.getServer()).withCustomNbt(command, data).build());
} }
} }
@@ -157,7 +157,7 @@ public class ServerNetworkHandler
{ {
if (isValidCarpetPlayer(player)) if (isValidCarpetPlayer(player))
{ {
player.connection.send(DataBuilder.create(player.server).withCustomNbt(command, data).build()); player.connection.send(DataBuilder.create(player.getServer()).withCustomNbt(command, data).build());
} }
} }
@@ -117,7 +117,7 @@ public class EntityPlayerMPFake extends ServerPlayer
{ {
player.getServer().getPlayerList().remove(player); player.getServer().getPlayerList().remove(player);
player.connection.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login")); player.connection.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login"));
ServerLevel worldIn = player.serverLevel();//.getWorld(player.dimension); ServerLevel worldIn = player.level();//.getWorld(player.dimension);
GameProfile gameprofile = player.getGameProfile(); GameProfile gameprofile = player.getGameProfile();
EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, player.clientInformation(), true); EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, player.clientInformation(), true);
playerShadow.setChatSession(player.getChatSession()); playerShadow.setChatSession(player.getChatSession());
@@ -174,7 +174,7 @@ public class EntityPlayerMPFake extends ServerPlayer
if (reason.getContents() instanceof TranslatableContents text && text.getKey().equals("multiplayer.disconnect.duplicate_login")) { if (reason.getContents() instanceof TranslatableContents text && text.getKey().equals("multiplayer.disconnect.duplicate_login")) {
this.connection.onDisconnect(new DisconnectionDetails(reason)); this.connection.onDisconnect(new DisconnectionDetails(reason));
} else { } else {
this.server.schedule(new TickTask(this.server.getTickCount(), () -> { this.getServer().schedule(new TickTask(this.getServer().getTickCount(), () -> {
this.connection.onDisconnect(new DisconnectionDetails(reason)); this.connection.onDisconnect(new DisconnectionDetails(reason));
})); }));
} }
@@ -186,7 +186,7 @@ public class EntityPlayerMPFake extends ServerPlayer
if (this.getServer().getTickCount() % 10 == 0) if (this.getServer().getTickCount() % 10 == 0)
{ {
this.connection.resetPosition(); this.connection.resetPosition();
this.serverLevel().getChunkSource().move(this); this.level().getChunkSource().move(this);
} }
try try
{ {
@@ -37,9 +37,9 @@ public class NetHandlerPlayServerFake extends ServerGamePacketListenerImpl
public void teleport(PositionMoveRotation positionMoveRotation, Set<Relative> set) public void teleport(PositionMoveRotation positionMoveRotation, Set<Relative> set)
{ {
super.teleport(positionMoveRotation, set); super.teleport(positionMoveRotation, set);
if (player.serverLevel().getPlayerByUUID(player.getUUID()) != null) { if (player.level().getPlayerByUUID(player.getUUID()) != null) {
resetPosition(); resetPosition();
player.serverLevel().getChunkSource().move(player); player.level().getChunkSource().move(player);
} }
} }
@@ -604,7 +604,7 @@ public class CarpetEventServer
return handler.call(() -> return handler.call(() ->
Arrays.asList( Arrays.asList(
new EntityValue(player), new EntityValue(player),
new BlockValue(null, player.serverLevel(), blockpos), new BlockValue(null, player.level(), blockpos),
StringValue.of(facing.getName()) StringValue.of(facing.getName())
), player::createCommandSourceStack); ), player::createCommandSourceStack);
} }
@@ -624,7 +624,7 @@ public class CarpetEventServer
new EntityValue(player), new EntityValue(player),
ValueConversions.of(itemstack, player.level().registryAccess()), ValueConversions.of(itemstack, player.level().registryAccess()),
StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"), StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"),
new BlockValue(null, player.serverLevel(), blockpos), new BlockValue(null, player.level(), blockpos),
StringValue.of(enumfacing.getName()), StringValue.of(enumfacing.getName()),
ListValue.of( ListValue.of(
new NumericValue(vec3d.x), new NumericValue(vec3d.x),
@@ -648,7 +648,7 @@ public class CarpetEventServer
return Arrays.asList( return Arrays.asList(
new EntityValue(player), new EntityValue(player),
StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"), StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"),
new BlockValue(null, player.serverLevel(), blockpos), new BlockValue(null, player.level(), blockpos),
StringValue.of(enumfacing.getName()), StringValue.of(enumfacing.getName()),
ListValue.of( ListValue.of(
new NumericValue(vec3d.x), new NumericValue(vec3d.x),
@@ -669,7 +669,7 @@ public class CarpetEventServer
new EntityValue(player), new EntityValue(player),
ValueConversions.of(itemstack, player.level().registryAccess()), ValueConversions.of(itemstack, player.level().registryAccess()),
StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"), StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"),
new BlockValue(null, player.serverLevel(), pos) new BlockValue(null, player.level(), pos)
), player::createCommandSourceStack); ), player::createCommandSourceStack);
} }
}; };
@@ -682,7 +682,7 @@ public class CarpetEventServer
new EntityValue(player), new EntityValue(player),
ValueConversions.of(itemstack, player.level().registryAccess()), ValueConversions.of(itemstack, player.level().registryAccess()),
StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"), StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"),
new BlockValue(null, player.serverLevel(), pos) new BlockValue(null, player.level(), pos)
), player::createCommandSourceStack); ), player::createCommandSourceStack);
return false; return false;
} }
@@ -693,7 +693,7 @@ public class CarpetEventServer
public boolean onBlockBroken(ServerPlayer player, BlockPos pos, BlockState previousBS) public boolean onBlockBroken(ServerPlayer player, BlockPos pos, BlockState previousBS)
{ {
return handler.call( return handler.call(
() -> Arrays.asList(new EntityValue(player), new BlockValue(previousBS, player.serverLevel(), pos)), () -> Arrays.asList(new EntityValue(player), new BlockValue(previousBS, player.level(), pos)),
player::createCommandSourceStack player::createCommandSourceStack
); );
} }
@@ -1336,7 +1336,7 @@ public class CarpetEventServer
valArgs.add(EntityValue.of(player)); valArgs.add(EntityValue.of(player));
for (Object o : args) for (Object o : args)
{ {
valArgs.add(ValueConversions.guess(player.serverLevel(), o)); valArgs.add(ValueConversions.guess(player.level(), o));
} }
return valArgs; return valArgs;
}, player::createCommandSourceStack }, player::createCommandSourceStack
@@ -777,7 +777,7 @@ public class ShapeDispatcher
} }
Vec3 v = relativiseRender(p.level(), this.pos, 0); Vec3 v = relativiseRender(p.level(), this.pos, 0);
p.serverLevel().sendParticles(p, particle, true, true, v.x, v.y, v.z, 1, 0.0, 0.0, 0.0, 0.0); p.level().sendParticles(p, particle, true, true, v.x, v.y, v.z, 1, 0.0, 0.0, 0.0, 0.0);
}; };
} }
@@ -1072,7 +1072,7 @@ public class ShapeDispatcher
ParticleOptions locparticledata = new DustParticleOptions(ARGB.colorFromFloat(1.0f, fr, fg, fb), 1); ParticleOptions locparticledata = new DustParticleOptions(ARGB.colorFromFloat(1.0f, fr, fg, fb), 1);
for (Vec3 v : getAlterPoint(p)) for (Vec3 v : getAlterPoint(p))
{ {
p.serverLevel().sendParticles(p, locparticledata, true, true, p.level().sendParticles(p, locparticledata, true, true,
v.x, v.y, v.z, 1, v.x, v.y, v.z, 1,
0.0, 0.0, 0.0, 0.0); 0.0, 0.0, 0.0, 0.0);
} }
@@ -1282,7 +1282,7 @@ public class ShapeDispatcher
{ {
int partno = Math.min(1000, 20 * subdivisions); int partno = Math.min(1000, 20 * subdivisions);
RandomSource rand = p.level().getRandom(); RandomSource rand = p.level().getRandom();
ServerLevel world = p.serverLevel(); ServerLevel world = p.level();
ParticleOptions particle = replacementParticle(world.registryAccess()); ParticleOptions particle = replacementParticle(world.registryAccess());
Vec3 ccenter = relativiseRender(world, center, 0); Vec3 ccenter = relativiseRender(world, center, 0);
@@ -1379,7 +1379,7 @@ public class ShapeDispatcher
{ {
int partno = (int) Math.min(1000, Math.sqrt(20 * subdivisions * (1 + height))); int partno = (int) Math.min(1000, Math.sqrt(20 * subdivisions * (1 + height)));
RandomSource rand = p.level().getRandom(); RandomSource rand = p.level().getRandom();
ServerLevel world = p.serverLevel(); ServerLevel world = p.level();
ParticleOptions particle = replacementParticle(world.registryAccess()); ParticleOptions particle = replacementParticle(world.registryAccess());
Vec3 ccenter = relativiseRender(world, center, 0); Vec3 ccenter = relativiseRender(world, center, 0);
@@ -2185,7 +2185,7 @@ public class ShapeDispatcher
int parts = 0; int parts = 0;
for (ServerPlayer player : playerList) for (ServerPlayer player : playerList)
{ {
ServerLevel world = player.serverLevel(); ServerLevel world = player.level();
world.sendParticles(player, particle, true, true, world.sendParticles(player, particle, true, true,
(towards.x) / 2 + from.x, (towards.y) / 2 + from.y, (towards.z) / 2 + from.z, particles / 3, (towards.x) / 2 + from.x, (towards.y) / 2 + from.y, (towards.z) / 2 + from.z, particles / 3,
towards.x / 6, towards.y / 6, towards.z / 6, 0.0); towards.x / 6, towards.y / 6, towards.z / 6, 0.0);
@@ -2202,7 +2202,7 @@ public class ShapeDispatcher
int dev = 2 * divider; int dev = 2 * divider;
for (ServerPlayer player : playerList) for (ServerPlayer player : playerList)
{ {
ServerLevel world = player.serverLevel(); ServerLevel world = player.level();
world.sendParticles(player, particle, true, true, world.sendParticles(player, particle, true, true,
(towards.x) / center + from.x, (towards.y) / center + from.y, (towards.z) / center + from.z, particles / divider, (towards.x) / center + from.x, (towards.y) / center + from.y, (towards.z) / center + from.z, particles / divider,
towards.x / dev, towards.y / dev, towards.z / dev, 0.0); towards.x / dev, towards.y / dev, towards.z / dev, 0.0);
@@ -2234,7 +2234,7 @@ public class ShapeDispatcher
Vec3 at = from.add(towards.scale(rand.nextDouble())); Vec3 at = from.add(towards.scale(rand.nextDouble()));
for (ServerPlayer player : players) for (ServerPlayer player : players)
{ {
player.serverLevel().sendParticles(player, particle, true, true, player.level().sendParticles(player, particle, true, true,
at.x, at.y, at.z, 1, at.x, at.y, at.z, 1,
0.0, 0.0, 0.0, 0.0); 0.0, 0.0, 0.0, 0.0);
pcount++; pcount++;
@@ -2255,7 +2255,7 @@ public class ShapeDispatcher
{ {
for (ServerPlayer player : players) for (ServerPlayer player : players)
{ {
player.serverLevel().sendParticles(player, particle, true, true, player.level().sendParticles(player, particle, true, true,
delta.x + from.x, delta.y + from.y, delta.z + from.z, 1, delta.x + from.x, delta.y + from.y, delta.z + from.z, 1,
0.0, 0.0, 0.0, 0.0); 0.0, 0.0, 0.0, 0.0);
pcount++; pcount++;
@@ -70,12 +70,12 @@ public class SnoopyCommandSource extends CommandSourceStack
{ {
super(player.commandSource(), player.position(), player.getRotationVector(), super(player.commandSource(), player.position(), player.getRotationVector(),
player.level() instanceof final ServerLevel serverLevel ? serverLevel : null, player.level() instanceof final ServerLevel serverLevel ? serverLevel : null,
player.server.getProfilePermissions(player.getGameProfile()), player.getName().getString(), player.getDisplayName(), player.getServer().getProfilePermissions(player.getGameProfile()), player.getName().getString(), player.getDisplayName(),
player.level().getServer(), player); player.level().getServer(), player);
this.output = player.commandSource(); this.output = player.commandSource();
this.position = player.position(); this.position = player.position();
this.world = player.level() instanceof final ServerLevel serverLevel ? serverLevel : null; this.world = player.level() instanceof final ServerLevel serverLevel ? serverLevel : null;
this.level = player.server.getProfilePermissions(player.getGameProfile()); this.level = player.getServer().getProfilePermissions(player.getGameProfile());
this.simpleName = player.getName().getString(); this.simpleName = player.getName().getString();
this.name = player.getDisplayName(); this.name = player.getDisplayName();
this.server = player.level().getServer(); this.server = player.level().getServer();
@@ -86,7 +86,7 @@ public class SnoopyCommandSource extends CommandSourceStack
this.error = error; this.error = error;
this.chatOutput = output; this.chatOutput = output;
this.signingContext = CommandSigningContext.ANONYMOUS; this.signingContext = CommandSigningContext.ANONYMOUS;
this.taskChainer = TaskChainer.immediate(player.server); this.taskChainer = TaskChainer.immediate(player.getServer());
} }
private SnoopyCommandSource(CommandSource output, Vec3 pos, Vec2 rot, ServerLevel world, int level, String simpleName, Component name, MinecraftServer server, @Nullable Entity entity, CommandResultCallback consumer, EntityAnchorArgument.Anchor entityAnchor, CommandSigningContext context, TaskChainer chainer, private SnoopyCommandSource(CommandSource output, Vec3 pos, Vec2 rot, ServerLevel world, int level, String simpleName, Component name, MinecraftServer server, @Nullable Entity entity, CommandResultCallback consumer, EntityAnchorArgument.Anchor entityAnchor, CommandSigningContext context, TaskChainer chainer,
@@ -714,7 +714,7 @@ public class EntityValue extends Value
{ {
return Value.NULL; return Value.NULL;
} }
return new BlockValue(null, sp.serverLevel(), pos); return new BlockValue(null, sp.level(), pos);
} }
return Value.NULL; return Value.NULL;
}); });
@@ -200,7 +200,7 @@ public class ScreenValue extends Value
this.screenHandler = null; this.screenHandler = null;
return false; return false;
} }
int runPermissionLevel = Vanilla.MinecraftServer_getRunPermissionLevel(player.server); int runPermissionLevel = Vanilla.MinecraftServer_getRunPermissionLevel(player.getServer());
CommandSourceStack source = player.createCommandSourceStack().withPermission(runPermissionLevel); CommandSourceStack source = player.createCommandSourceStack().withPermission(runPermissionLevel);
CarpetScriptHost executingHost = appHost.retrieveForExecution(source, player); CarpetScriptHost executingHost = appHost.retrieveForExecution(source, player);
try try