mappings
This commit is contained in:
1 parent
787eb3e41d
commit
9a4e15da48
28 files changed
+176
-149
No files matched your search
+1
-1
@@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
# check these on https://fabricmc.net/use
|
# check these on https://fabricmc.net/use
|
||||||
# or better: https://modmuss50.me/fabric.html
|
# or better: https://modmuss50.me/fabric.html
|
||||||
minecraft_version=1.17.1-pre1
|
minecraft_version=1.17.1-pre1
|
||||||
yarn_mappings=1.17.1-pre1+build.9
|
yarn_mappings=1.17.1-pre1+build.19
|
||||||
loader_version=0.11.6
|
loader_version=0.11.6
|
||||||
fabric_version=0.36.0+1.17
|
fabric_version=0.36.0+1.17
|
||||||
|
|
||||||
|
|||||||
@@ -636,7 +636,7 @@ public class CarpetSettings
|
|||||||
Messenger.m(source, "r view distance has to be between 0 and 32");
|
Messenger.m(source, "r view distance has to be between 0 and 32");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
MinecraftServer server = source.getMinecraftServer();
|
MinecraftServer server = source.getServer();
|
||||||
|
|
||||||
if (server.isDedicated())
|
if (server.isDedicated())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class CounterCommand
|
|||||||
HopperCounter counter = HopperCounter.getCounter(color);
|
HopperCounter counter = HopperCounter.getCounter(color);
|
||||||
if (counter == null) throw new CommandException(Messenger.s("Unknown wool color: "+color));
|
if (counter == null) throw new CommandException(Messenger.s("Unknown wool color: "+color));
|
||||||
|
|
||||||
for (BaseText message: counter.format(source.getMinecraftServer(), realtime, false))
|
for (BaseText message: counter.format(source.getServer(), realtime, false))
|
||||||
{
|
{
|
||||||
source.sendFeedback(message, false);
|
source.sendFeedback(message, false);
|
||||||
}
|
}
|
||||||
@@ -72,14 +72,14 @@ public class CounterCommand
|
|||||||
{
|
{
|
||||||
if (color == null)
|
if (color == null)
|
||||||
{
|
{
|
||||||
HopperCounter.resetAll(source.getMinecraftServer(), false);
|
HopperCounter.resetAll(source.getServer(), false);
|
||||||
Messenger.m(source, "w Restarted all counters");
|
Messenger.m(source, "w Restarted all counters");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HopperCounter counter = HopperCounter.getCounter(color);
|
HopperCounter counter = HopperCounter.getCounter(color);
|
||||||
if (counter == null) throw new CommandException(Messenger.s("Unknown wool color"));
|
if (counter == null) throw new CommandException(Messenger.s("Unknown wool color"));
|
||||||
counter.reset(source.getMinecraftServer());
|
counter.reset(source.getServer());
|
||||||
Messenger.m(source, "w Restarted "+color+" counter");
|
Messenger.m(source, "w Restarted "+color+" counter");
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@@ -92,7 +92,7 @@ public class CounterCommand
|
|||||||
*/
|
*/
|
||||||
private static int listAllCounters(ServerCommandSource source, boolean realtime)
|
private static int listAllCounters(ServerCommandSource source, boolean realtime)
|
||||||
{
|
{
|
||||||
for (BaseText message: HopperCounter.formatAll(source.getMinecraftServer(), realtime))
|
for (BaseText message: HopperCounter.formatAll(source.getServer(), realtime))
|
||||||
{
|
{
|
||||||
source.sendFeedback(message, false);
|
source.sendFeedback(message, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ public class LogCommand
|
|||||||
}
|
}
|
||||||
private static int unsubFromAll(ServerCommandSource source, String player_name)
|
private static int unsubFromAll(ServerCommandSource source, String player_name)
|
||||||
{
|
{
|
||||||
PlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(player_name);
|
PlayerEntity player = source.getServer().getPlayerManager().getPlayer(player_name);
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
Messenger.m(source, "r No player specified");
|
Messenger.m(source, "r No player specified");
|
||||||
@@ -148,7 +148,7 @@ public class LogCommand
|
|||||||
}
|
}
|
||||||
private static int unsubFromLogger(ServerCommandSource source, String player_name, String logname)
|
private static int unsubFromLogger(ServerCommandSource source, String player_name, String logname)
|
||||||
{
|
{
|
||||||
PlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(player_name);
|
PlayerEntity player = source.getServer().getPlayerManager().getPlayer(player_name);
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
Messenger.m(source, "r No player specified");
|
Messenger.m(source, "r No player specified");
|
||||||
@@ -166,7 +166,7 @@ public class LogCommand
|
|||||||
|
|
||||||
private static int toggleSubscription(ServerCommandSource source, String player_name, String logName)
|
private static int toggleSubscription(ServerCommandSource source, String player_name, String logName)
|
||||||
{
|
{
|
||||||
PlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(player_name);
|
PlayerEntity player = source.getServer().getPlayerManager().getPlayer(player_name);
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
Messenger.m(source, "r No player specified");
|
Messenger.m(source, "r No player specified");
|
||||||
@@ -190,7 +190,7 @@ public class LogCommand
|
|||||||
}
|
}
|
||||||
private static int subscribePlayer(ServerCommandSource source, String player_name, String logname, String option)
|
private static int subscribePlayer(ServerCommandSource source, String player_name, String logname, String option)
|
||||||
{
|
{
|
||||||
PlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(player_name);
|
PlayerEntity player = source.getServer().getPlayerManager().getPlayer(player_name);
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
Messenger.m(source, "r No player specified");
|
Messenger.m(source, "r No player specified");
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ public class PlayerCommand
|
|||||||
private static ServerPlayerEntity getPlayer(CommandContext<ServerCommandSource> context)
|
private static ServerPlayerEntity getPlayer(CommandContext<ServerCommandSource> context)
|
||||||
{
|
{
|
||||||
String playerName = StringArgumentType.getString(context, "player");
|
String playerName = StringArgumentType.getString(context, "player");
|
||||||
MinecraftServer server = context.getSource().getMinecraftServer();
|
MinecraftServer server = context.getSource().getServer();
|
||||||
return server.getPlayerManager().getPlayer(playerName);
|
return server.getPlayerManager().getPlayer(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ public class PlayerCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context.getSource().getMinecraftServer().getPlayerManager().isOperator(sendingPlayer.getGameProfile()))
|
if (!context.getSource().getServer().getPlayerManager().isOperator(sendingPlayer.getGameProfile()))
|
||||||
{
|
{
|
||||||
if (sendingPlayer != player && !(player instanceof EntityPlayerMPFake))
|
if (sendingPlayer != player && !(player instanceof EntityPlayerMPFake))
|
||||||
{
|
{
|
||||||
@@ -181,7 +181,7 @@ public class PlayerCommand
|
|||||||
private static boolean cantSpawn(CommandContext<ServerCommandSource> context)
|
private static boolean cantSpawn(CommandContext<ServerCommandSource> context)
|
||||||
{
|
{
|
||||||
String playerName = StringArgumentType.getString(context, "player");
|
String playerName = StringArgumentType.getString(context, "player");
|
||||||
MinecraftServer server = context.getSource().getMinecraftServer();
|
MinecraftServer server = context.getSource().getServer();
|
||||||
PlayerManager manager = server.getPlayerManager();
|
PlayerManager manager = server.getPlayerManager();
|
||||||
PlayerEntity player = manager.getPlayer(playerName);
|
PlayerEntity player = manager.getPlayer(playerName);
|
||||||
if (player != null)
|
if (player != null)
|
||||||
@@ -274,13 +274,13 @@ public class PlayerCommand
|
|||||||
}
|
}
|
||||||
catch (CommandSyntaxException ignored) {}
|
catch (CommandSyntaxException ignored) {}
|
||||||
String playerName = StringArgumentType.getString(context, "player");
|
String playerName = StringArgumentType.getString(context, "player");
|
||||||
if (playerName.length()>maxPlayerLength(source.getMinecraftServer()))
|
if (playerName.length()>maxPlayerLength(source.getServer()))
|
||||||
{
|
{
|
||||||
Messenger.m(context.getSource(), "rb Player name: "+playerName+" is too long");
|
Messenger.m(context.getSource(), "rb Player name: "+playerName+" is too long");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MinecraftServer server = source.getMinecraftServer();
|
MinecraftServer server = source.getServer();
|
||||||
if (!World.isValid(new BlockPos(pos.x, pos.y, pos.z)))
|
if (!World.isValid(new BlockPos(pos.x, pos.y, pos.z)))
|
||||||
{
|
{
|
||||||
Messenger.m(context.getSource(), "rb Player "+playerName+" cannot be placed outside of the world");
|
Messenger.m(context.getSource(), "rb Player "+playerName+" cannot be placed outside of the world");
|
||||||
|
|||||||
@@ -146,8 +146,8 @@ public class SpawnCommand
|
|||||||
Math.max(a.getY(), b.getY()),
|
Math.max(a.getY(), b.getY()),
|
||||||
Math.max(a.getZ(), b.getZ()) );
|
Math.max(a.getZ(), b.getZ()) );
|
||||||
}
|
}
|
||||||
SpawnReporter.reset_spawn_stats(source.getMinecraftServer(), false);
|
SpawnReporter.reset_spawn_stats(source.getServer(), false);
|
||||||
SpawnReporter.track_spawns = (long) source.getMinecraftServer().getTicks();
|
SpawnReporter.track_spawns = (long) source.getServer().getTicks();
|
||||||
SpawnReporter.lower_spawning_limit = lsl;
|
SpawnReporter.lower_spawning_limit = lsl;
|
||||||
SpawnReporter.upper_spawning_limit = usl;
|
SpawnReporter.upper_spawning_limit = usl;
|
||||||
Messenger.m(source, "gi Spawning tracking started.");
|
Messenger.m(source, "gi Spawning tracking started.");
|
||||||
@@ -157,7 +157,7 @@ public class SpawnCommand
|
|||||||
private static int stopTracking(ServerCommandSource source)
|
private static int stopTracking(ServerCommandSource source)
|
||||||
{
|
{
|
||||||
Messenger.send(source, SpawnReporter.tracking_report(source.getWorld()));
|
Messenger.send(source, SpawnReporter.tracking_report(source.getWorld()));
|
||||||
SpawnReporter.reset_spawn_stats(source.getMinecraftServer(),false);
|
SpawnReporter.reset_spawn_stats(source.getServer(),false);
|
||||||
SpawnReporter.track_spawns = 0L;
|
SpawnReporter.track_spawns = 0L;
|
||||||
SpawnReporter.lower_spawning_limit = null;
|
SpawnReporter.lower_spawning_limit = null;
|
||||||
SpawnReporter.upper_spawning_limit = null;
|
SpawnReporter.upper_spawning_limit = null;
|
||||||
@@ -175,19 +175,19 @@ public class SpawnCommand
|
|||||||
private static int runTest(ServerCommandSource source, int ticks, String counter)
|
private static int runTest(ServerCommandSource source, int ticks, String counter)
|
||||||
{
|
{
|
||||||
//stop tracking
|
//stop tracking
|
||||||
SpawnReporter.reset_spawn_stats(source.getMinecraftServer(),false);
|
SpawnReporter.reset_spawn_stats(source.getServer(),false);
|
||||||
//start tracking
|
//start tracking
|
||||||
SpawnReporter.track_spawns = (long) source.getMinecraftServer().getTicks();
|
SpawnReporter.track_spawns = (long) source.getServer().getTicks();
|
||||||
//counter reset
|
//counter reset
|
||||||
if (counter == null)
|
if (counter == null)
|
||||||
{
|
{
|
||||||
HopperCounter.resetAll(source.getMinecraftServer(), false);
|
HopperCounter.resetAll(source.getServer(), false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HopperCounter hCounter = HopperCounter.getCounter(counter);
|
HopperCounter hCounter = HopperCounter.getCounter(counter);
|
||||||
if (hCounter != null)
|
if (hCounter != null)
|
||||||
hCounter.reset(source.getMinecraftServer());
|
hCounter.reset(source.getServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ public class BlockRotator
|
|||||||
{
|
{
|
||||||
Direction sourceFace = source.getBlockState().get(DispenserBlock.FACING);
|
Direction sourceFace = source.getBlockState().get(DispenserBlock.FACING);
|
||||||
World world = source.getWorld();
|
World world = source.getWorld();
|
||||||
BlockPos blockpos = source.getBlockPos().offset(sourceFace); // offset
|
BlockPos blockpos = source.getPos().offset(sourceFace); // offset
|
||||||
BlockState iblockstate = world.getBlockState(blockpos);
|
BlockState iblockstate = world.getBlockState(blockpos);
|
||||||
Block block = iblockstate.getBlock();
|
Block block = iblockstate.getBlock();
|
||||||
|
|
||||||
@@ -274,7 +274,7 @@ public class BlockRotator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Send block update to the block that just have been rotated.
|
// Send block update to the block that just have been rotated.
|
||||||
world.updateNeighbor(blockpos, block, source.getBlockPos());
|
world.updateNeighbor(blockpos, block, source.getPos());
|
||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ public class EntityPlayerActionPack
|
|||||||
boolean execute(ServerPlayerEntity player, Action action)
|
boolean execute(ServerPlayerEntity player, Action action)
|
||||||
{
|
{
|
||||||
player.updateLastActionTime();
|
player.updateLastActionTime();
|
||||||
player.method_37413(false); // dropSelectedItem
|
player.dropSelectedItem(false); // dropSelectedItem
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -497,7 +497,7 @@ public class EntityPlayerActionPack
|
|||||||
boolean execute(ServerPlayerEntity player, Action action)
|
boolean execute(ServerPlayerEntity player, Action action)
|
||||||
{
|
{
|
||||||
player.updateLastActionTime();
|
player.updateLastActionTime();
|
||||||
player.method_37413(true); // dropSelectedItem
|
player.dropSelectedItem(true); // dropSelectedItem
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ public class TickSpeed
|
|||||||
time_warp_start_time = 0;
|
time_warp_start_time = 0;
|
||||||
if (tick_warp_callback != null)
|
if (tick_warp_callback != null)
|
||||||
{
|
{
|
||||||
CommandManager icommandmanager = tick_warp_sender.getMinecraftServer().getCommandManager();
|
CommandManager icommandmanager = tick_warp_sender.getServer().getCommandManager();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
icommandmanager.execute(tick_warp_sender, tick_warp_callback);
|
icommandmanager.execute(tick_warp_sender, tick_warp_callback);
|
||||||
|
|||||||
@@ -46,24 +46,23 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
|||||||
|
|
||||||
@Shadow private long nextTickTimestamp;
|
@Shadow private long nextTickTimestamp;
|
||||||
|
|
||||||
@Shadow protected abstract void method_16208();
|
|
||||||
|
|
||||||
@Shadow private volatile boolean loading;
|
@Shadow private volatile boolean loading;
|
||||||
|
|
||||||
//@Shadow protected abstract void startMonitor(TickDurationMonitor monitor);
|
|
||||||
|
|
||||||
@Shadow protected abstract void startMonitor();
|
|
||||||
|
|
||||||
@Shadow private long lastTimeReference;
|
@Shadow private long lastTimeReference;
|
||||||
|
|
||||||
@Shadow private boolean waitingForNextTick;
|
@Shadow private boolean waitingForNextTick;
|
||||||
|
|
||||||
@Shadow public abstract Iterable<ServerWorld> getWorlds();
|
@Shadow public abstract Iterable<ServerWorld> getWorlds();
|
||||||
|
|
||||||
@Shadow protected abstract void endMonitor();
|
|
||||||
|
|
||||||
@Shadow private boolean profilerEnabled;
|
|
||||||
@Shadow private int ticks;
|
@Shadow private int ticks;
|
||||||
|
|
||||||
|
@Shadow protected abstract void runTasksTillTickEnd();
|
||||||
|
|
||||||
|
@Shadow protected abstract void startTickMetrics();
|
||||||
|
|
||||||
|
@Shadow protected abstract void endTickMetrics();
|
||||||
|
|
||||||
|
@Shadow private boolean needsDebugSetup;
|
||||||
CarpetProfiler.ProfilerToken currentSection;
|
CarpetProfiler.ProfilerToken currentSection;
|
||||||
|
|
||||||
private float carpetMsptAccum = 0.0f;
|
private float carpetMsptAccum = 0.0f;
|
||||||
@@ -125,15 +124,15 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
|||||||
this.lastTimeReference = this.timeReference;
|
this.lastTimeReference = this.timeReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.profilerEnabled) {
|
if (this.needsDebugSetup) {
|
||||||
this.profilerEnabled = false;
|
this.needsDebugSetup = false;
|
||||||
this.profilerTimings = Pair.of(Util.getMeasuringTimeNano(), ticks);
|
this.profilerTimings = Pair.of(Util.getMeasuringTimeNano(), ticks);
|
||||||
//this.field_33978 = new MinecraftServer.class_6414(Util.getMeasuringTimeNano(), this.ticks);
|
//this.field_33978 = new MinecraftServer.class_6414(Util.getMeasuringTimeNano(), this.ticks);
|
||||||
}
|
}
|
||||||
this.timeReference += msThisTick;//50L;
|
this.timeReference += msThisTick;//50L;
|
||||||
//TickDurationMonitor tickDurationMonitor = TickDurationMonitor.create("Server");
|
//TickDurationMonitor tickDurationMonitor = TickDurationMonitor.create("Server");
|
||||||
//this.startMonitor(tickDurationMonitor);
|
//this.startMonitor(tickDurationMonitor);
|
||||||
this.startMonitor();
|
this.startTickMetrics();
|
||||||
this.profiler.push("tick");
|
this.profiler.push("tick");
|
||||||
this.tick(TickSpeed.time_warp_start_time != 0 ? ()->true : this::shouldKeepTicking);
|
this.tick(TickSpeed.time_warp_start_time != 0 ? ()->true : this::shouldKeepTicking);
|
||||||
this.profiler.swap("nextTickWait");
|
this.profiler.swap("nextTickWait");
|
||||||
@@ -144,9 +143,9 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
|||||||
this.waitingForNextTick = true;
|
this.waitingForNextTick = true;
|
||||||
this.nextTickTimestamp = Math.max(Util.getMeasuringTimeMs() + /*50L*/ msThisTick, this.timeReference);
|
this.nextTickTimestamp = Math.max(Util.getMeasuringTimeMs() + /*50L*/ msThisTick, this.timeReference);
|
||||||
// run all tasks (this will not do a lot when warping), but that's fine since we already run them
|
// run all tasks (this will not do a lot when warping), but that's fine since we already run them
|
||||||
this.method_16208();
|
this.runTasksTillTickEnd();
|
||||||
this.profiler.pop();
|
this.profiler.pop();
|
||||||
this.endMonitor();
|
this.endTickMetrics();
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +157,7 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
|||||||
@Inject(method = "isDebugRunning", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "isDebugRunning", at = @At("HEAD"), cancellable = true)
|
||||||
public void isCMDebugRunning(CallbackInfoReturnable<Boolean> cir)
|
public void isCMDebugRunning(CallbackInfoReturnable<Boolean> cir)
|
||||||
{
|
{
|
||||||
cir.setReturnValue(profilerEnabled || profilerTimings != null);
|
cir.setReturnValue(needsDebugSetup || profilerTimings != null);
|
||||||
}
|
}
|
||||||
@Inject(method = "stopDebug", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "stopDebug", at = @At("HEAD"), cancellable = true)
|
||||||
public void stopCMDebug(CallbackInfoReturnable<ProfileResult> cir)
|
public void stopCMDebug(CallbackInfoReturnable<ProfileResult> cir)
|
||||||
@@ -232,12 +231,12 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
|||||||
CarpetProfiler.end_current_section(currentSection);
|
CarpetProfiler.end_current_section(currentSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "method_16208", at = @At("HEAD"))
|
@Inject(method = "runTasksTillTickEnd", at = @At("HEAD"))
|
||||||
private void startAsync(CallbackInfo ci)
|
private void startAsync(CallbackInfo ci)
|
||||||
{
|
{
|
||||||
currentSection = CarpetProfiler.start_section(null, "Async Tasks", CarpetProfiler.TYPE.GENERAL);
|
currentSection = CarpetProfiler.start_section(null, "Async Tasks", CarpetProfiler.TYPE.GENERAL);
|
||||||
}
|
}
|
||||||
@Inject(method = "method_16208", at = @At(
|
@Inject(method = "runTasksTillTickEnd", at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/server/MinecraftServer;runTasks(Ljava/util/function/BooleanSupplier;)V",
|
target = "Lnet/minecraft/server/MinecraftServer;runTasks(Ljava/util/function/BooleanSupplier;)V",
|
||||||
shift = At.Shift.BEFORE
|
shift = At.Shift.BEFORE
|
||||||
|
|||||||
@@ -18,6 +18,6 @@ public class ReloadCommand_reloadAppsMixin {
|
|||||||
private static void onReload(CommandContext<ServerCommandSource> context, CallbackInfoReturnable<Integer> cir)
|
private static void onReload(CommandContext<ServerCommandSource> context, CallbackInfoReturnable<Integer> cir)
|
||||||
{
|
{
|
||||||
// can't fetch here the reference to the server
|
// can't fetch here the reference to the server
|
||||||
CarpetServer.onReload(context.getSource().getMinecraftServer());
|
CarpetServer.onReload(context.getSource().getServer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package carpet.mixins;
|
||||||
|
|
||||||
|
import carpet.fakes.SimpleEntityLookupInterface;
|
||||||
|
import net.minecraft.util.math.ChunkPos;
|
||||||
|
import net.minecraft.world.entity.EntityLike;
|
||||||
|
import net.minecraft.world.entity.EntityTrackingSection;
|
||||||
|
import net.minecraft.world.entity.SectionedEntityCache;
|
||||||
|
import net.minecraft.world.entity.SimpleEntityLookup;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Mixin(SimpleEntityLookup.class)
|
||||||
|
public class SimpleEntityLookup_scarpetMixin<T extends EntityLike> implements SimpleEntityLookupInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
@Shadow @Final private SectionedEntityCache<T> cache;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<T> getChunkEntities(ChunkPos chpos) {
|
||||||
|
return this.cache.getTrackingSections(chpos.toLong()).flatMap(EntityTrackingSection::stream).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
+8
-8
@@ -78,7 +78,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
|||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
@Final
|
@Final
|
||||||
private ServerLightingProvider serverLightingProvider;
|
private ServerLightingProvider lightingProvider;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
@Final
|
@Final
|
||||||
@@ -289,12 +289,12 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
|||||||
this.currentChunkHolders.get(pos.toLong()).getChunkAt(ChunkStatus.EMPTY, (ThreadedAnvilChunkStorage) (Object) this);
|
this.currentChunkHolders.get(pos.toLong()).getChunkAt(ChunkStatus.EMPTY, (ThreadedAnvilChunkStorage) (Object) this);
|
||||||
final Chunk chunk = this.getCurrentChunk(pos);
|
final Chunk chunk = this.getCurrentChunk(pos);
|
||||||
if (!(chunk.getStatus().isAtLeast(ChunkStatus.LIGHT.getPrevious()))) return;
|
if (!(chunk.getStatus().isAtLeast(ChunkStatus.LIGHT.getPrevious()))) return;
|
||||||
((ServerLightingProviderInterface) this.serverLightingProvider).removeLightData(chunk);
|
((ServerLightingProviderInterface) this.lightingProvider).removeLightData(chunk);
|
||||||
this.addRelightTicket(pos);
|
this.addRelightTicket(pos);
|
||||||
final CompletableFuture<?> lightFuture = this.getRegion (pos, 1, (pos_) -> ChunkStatus.LIGHT)
|
final CompletableFuture<?> lightFuture = this.getRegion (pos, 1, (pos_) -> ChunkStatus.LIGHT)
|
||||||
.thenCompose(
|
.thenCompose(
|
||||||
either -> either.map(
|
either -> either.map(
|
||||||
list -> ((ServerLightingProviderInterface) this.serverLightingProvider).relight(chunk),
|
list -> ((ServerLightingProviderInterface) this.lightingProvider).relight(chunk),
|
||||||
unloaded -> {
|
unloaded -> {
|
||||||
this.releaseRelightTicket(pos);
|
this.releaseRelightTicket(pos);
|
||||||
return CompletableFuture.completedFuture(null);
|
return CompletableFuture.completedFuture(null);
|
||||||
@@ -374,8 +374,8 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
|||||||
if (this.loadedChunks.remove(pos.toLong()) && chunk instanceof WorldChunk)
|
if (this.loadedChunks.remove(pos.toLong()) && chunk instanceof WorldChunk)
|
||||||
this.world.unloadEntities((WorldChunk) chunk); // block entities only
|
this.world.unloadEntities((WorldChunk) chunk); // block entities only
|
||||||
|
|
||||||
((ServerLightingProviderInterface) this.serverLightingProvider).invokeUpdateChunkStatus(pos);
|
((ServerLightingProviderInterface) this.lightingProvider).invokeUpdateChunkStatus(pos);
|
||||||
((ServerLightingProviderInterface) this.serverLightingProvider).removeLightData(chunk);
|
((ServerLightingProviderInterface) this.lightingProvider).removeLightData(chunk);
|
||||||
|
|
||||||
this.worldGenerationProgressListener.setChunkStatus(pos, null);
|
this.worldGenerationProgressListener.setChunkStatus(pos, null);
|
||||||
}
|
}
|
||||||
@@ -388,7 +388,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
|||||||
final long pos = cPos.toLong();
|
final long pos = cPos.toLong();
|
||||||
|
|
||||||
final ChunkHolder oldHolder = this.currentChunkHolders.remove(pos);
|
final ChunkHolder oldHolder = this.currentChunkHolders.remove(pos);
|
||||||
final ChunkHolder newHolder = new ChunkHolder(cPos, oldHolder.getLevel(), world, this.serverLightingProvider, this.chunkTaskPrioritySystem, (ChunkHolder.PlayersWatchingChunkProvider) this);
|
final ChunkHolder newHolder = new ChunkHolder(cPos, oldHolder.getLevel(), world, this.lightingProvider, this.chunkTaskPrioritySystem, (ChunkHolder.PlayersWatchingChunkProvider) this);
|
||||||
((ChunkHolderInterface) newHolder).setDefaultProtoChunk(cPos, this.mainThreadExecutor, world);
|
((ChunkHolderInterface) newHolder).setDefaultProtoChunk(cPos, this.mainThreadExecutor, world);
|
||||||
this.currentChunkHolders.put(pos, newHolder);
|
this.currentChunkHolders.put(pos, newHolder);
|
||||||
|
|
||||||
@@ -401,7 +401,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
|||||||
// Remove light for affected neighbors
|
// Remove light for affected neighbors
|
||||||
|
|
||||||
for (final Chunk chunk : affectedNeighbors)
|
for (final Chunk chunk : affectedNeighbors)
|
||||||
((ServerLightingProviderInterface) this.serverLightingProvider).removeLightData(chunk);
|
((ServerLightingProviderInterface) this.lightingProvider).removeLightData(chunk);
|
||||||
|
|
||||||
// Schedule relighting of neighbors
|
// Schedule relighting of neighbors
|
||||||
|
|
||||||
@@ -418,7 +418,7 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
|
|||||||
|
|
||||||
lightFutures.add(this.getRegion (pos, 1, (pos_) -> ChunkStatus.LIGHT).thenCompose(
|
lightFutures.add(this.getRegion (pos, 1, (pos_) -> ChunkStatus.LIGHT).thenCompose(
|
||||||
either -> either.map(
|
either -> either.map(
|
||||||
list -> ((ServerLightingProviderInterface) this.serverLightingProvider).relight(chunk),
|
list -> ((ServerLightingProviderInterface) this.lightingProvider).relight(chunk),
|
||||||
unloaded -> {
|
unloaded -> {
|
||||||
this.releaseRelightTicket(pos);
|
this.releaseRelightTicket(pos);
|
||||||
return CompletableFuture.completedFuture(null);
|
return CompletableFuture.completedFuture(null);
|
||||||
|
|||||||
@@ -642,7 +642,7 @@ public class CarpetScriptHost extends ScriptHost
|
|||||||
{
|
{
|
||||||
if (optionalTarget == null)
|
if (optionalTarget == null)
|
||||||
{
|
{
|
||||||
for (ServerPlayerEntity player : source.getMinecraftServer().getPlayerManager().getPlayerList())
|
for (ServerPlayerEntity player : source.getServer().getPlayerManager().getPlayerList())
|
||||||
{
|
{
|
||||||
CarpetScriptHost host = (CarpetScriptHost) retrieveForExecution(player.getEntityName());
|
CarpetScriptHost host = (CarpetScriptHost) retrieveForExecution(player.getEntityName());
|
||||||
targets.add(host);
|
targets.add(host);
|
||||||
@@ -651,7 +651,7 @@ public class CarpetScriptHost extends ScriptHost
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerPlayerEntity player = source.getMinecraftServer().getPlayerManager().getPlayer(optionalTarget);
|
ServerPlayerEntity player = source.getServer().getPlayerManager().getPlayer(optionalTarget);
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
CarpetScriptHost host = (CarpetScriptHost) retrieveForExecution(player.getEntityName());
|
CarpetScriptHost host = (CarpetScriptHost) retrieveForExecution(player.getEntityName());
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ public class CarpetScriptServer
|
|||||||
ServerPlayerEntity target = null;
|
ServerPlayerEntity target = null;
|
||||||
if (optionalTarget != null)
|
if (optionalTarget != null)
|
||||||
{
|
{
|
||||||
target = sender.getMinecraftServer().getPlayerManager().getPlayer(optionalTarget);
|
target = sender.getServer().getPlayerManager().getPlayer(optionalTarget);
|
||||||
if (target == null) return false;
|
if (target == null) return false;
|
||||||
}
|
}
|
||||||
int successes = signal(sender, target, hostname, udf, argv, true );
|
int successes = signal(sender, target, hostname, udf, argv, true );
|
||||||
@@ -436,8 +436,8 @@ public class CarpetScriptServer
|
|||||||
{
|
{
|
||||||
// getPlayer will always return nonnull cause retrieve for execution only returns hosts for existing players.
|
// getPlayer will always return nonnull cause retrieve for execution only returns hosts for existing players.
|
||||||
ServerCommandSource executingSource = host.perUser
|
ServerCommandSource executingSource = host.perUser
|
||||||
? source.getMinecraftServer().getPlayerManager().getPlayer(host.user).getCommandSource()
|
? source.getServer().getPlayerManager().getPlayer(host.user).getCommandSource()
|
||||||
: source.getMinecraftServer().getCommandSource();
|
: source.getServer().getCommandSource();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
host.callUDF(BlockPos.ORIGIN, source.withLevel(CarpetSettings.runPermissionLevel), udf, argv);
|
host.callUDF(BlockPos.ORIGIN, source.withLevel(CarpetSettings.runPermissionLevel), udf, argv);
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ public class Auxiliary {
|
|||||||
{
|
{
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
if (lv.size() == 0) return ListValue.wrap(Registry.PARTICLE_TYPE.getIds().stream().map(ValueConversions::of));
|
if (lv.size() == 0) return ListValue.wrap(Registry.PARTICLE_TYPE.getIds().stream().map(ValueConversions::of));
|
||||||
MinecraftServer ms = cc.s.getMinecraftServer();
|
MinecraftServer ms = cc.s.getServer();
|
||||||
ServerWorld world = cc.s.getWorld();
|
ServerWorld world = cc.s.getWorld();
|
||||||
Vector3Argument locator = Vector3Argument.findIn(lv, 1);
|
Vector3Argument locator = Vector3Argument.findIn(lv, 1);
|
||||||
String particleName = lv.get(0).getString();
|
String particleName = lv.get(0).getString();
|
||||||
@@ -270,7 +270,7 @@ public class Auxiliary {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player = cc.s.getMinecraftServer().getPlayerManager().getPlayer(playerValue.getString());
|
player = cc.s.getServer().getPlayerManager().getPlayer(playerValue.getString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -310,7 +310,7 @@ public class Auxiliary {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player = cc.s.getMinecraftServer().getPlayerManager().getPlayer(playerValue.getString());
|
player = cc.s.getServer().getPlayerManager().getPlayer(playerValue.getString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -485,7 +485,7 @@ public class Auxiliary {
|
|||||||
{
|
{
|
||||||
if (lv.size() == 0 || lv.size() > 2) throw new InternalExpressionException("'print' takes one or two arguments");
|
if (lv.size() == 0 || lv.size() > 2) throw new InternalExpressionException("'print' takes one or two arguments");
|
||||||
ServerCommandSource s = ((CarpetContext)c).s;
|
ServerCommandSource s = ((CarpetContext)c).s;
|
||||||
MinecraftServer server = s.getMinecraftServer();
|
MinecraftServer server = s.getServer();
|
||||||
Value res = lv.get(0);
|
Value res = lv.get(0);
|
||||||
List<ServerPlayerEntity> targets = null;
|
List<ServerPlayerEntity> targets = null;
|
||||||
if (lv.size() == 2)
|
if (lv.size() == 2)
|
||||||
@@ -516,7 +516,7 @@ public class Auxiliary {
|
|||||||
if (lv.size() < 2) throw new InternalExpressionException("'display_title' needs at least a target, type and message, and optionally times");
|
if (lv.size() < 2) throw new InternalExpressionException("'display_title' needs at least a target, type and message, and optionally times");
|
||||||
Value pVal = lv.get(0);
|
Value pVal = lv.get(0);
|
||||||
if (!(pVal instanceof ListValue)) pVal = ListValue.of(pVal);
|
if (!(pVal instanceof ListValue)) pVal = ListValue.of(pVal);
|
||||||
MinecraftServer server = ((CarpetContext)c).s.getMinecraftServer();
|
MinecraftServer server = ((CarpetContext)c).s.getServer();
|
||||||
Stream<ServerPlayerEntity> targets = ((ListValue) pVal).getItems().stream().map(v ->
|
Stream<ServerPlayerEntity> targets = ((ListValue) pVal).getItems().stream().map(v ->
|
||||||
{
|
{
|
||||||
ServerPlayerEntity player = EntityValue.getPlayerByValue(server, v);
|
ServerPlayerEntity player = EntityValue.getPlayerByValue(server, v);
|
||||||
@@ -590,7 +590,7 @@ public class Auxiliary {
|
|||||||
map.put(target.getEntityName(), (BaseText) title);
|
map.put(target.getEntityName(), (BaseText) title);
|
||||||
total.getAndIncrement();
|
total.getAndIncrement();
|
||||||
});
|
});
|
||||||
HUDController.update_hud(((CarpetContext)c).s.getMinecraftServer(), targetList);
|
HUDController.update_hud(((CarpetContext)c).s.getServer(), targetList);
|
||||||
return NumericValue.of(total.get());
|
return NumericValue.of(total.get());
|
||||||
}
|
}
|
||||||
TitleFadeS2CPacket timesPacket; // TimesPacket
|
TitleFadeS2CPacket timesPacket; // TimesPacket
|
||||||
@@ -630,7 +630,7 @@ public class Auxiliary {
|
|||||||
{
|
{
|
||||||
Text[] error = {null};
|
Text[] error = {null};
|
||||||
List<Text> output = new ArrayList<>();
|
List<Text> output = new ArrayList<>();
|
||||||
Value retval = new NumericValue(s.getMinecraftServer().getCommandManager().execute(
|
Value retval = new NumericValue(s.getServer().getCommandManager().execute(
|
||||||
new SnoopyCommandSource(s, error, output),
|
new SnoopyCommandSource(s, error, output),
|
||||||
lv.get(0).getString())
|
lv.get(0).getString())
|
||||||
);
|
);
|
||||||
@@ -649,15 +649,15 @@ public class Auxiliary {
|
|||||||
expression.addContextFunction("save", 0, (c, t, lv) ->
|
expression.addContextFunction("save", 0, (c, t, lv) ->
|
||||||
{
|
{
|
||||||
ServerCommandSource s = ((CarpetContext)c).s;
|
ServerCommandSource s = ((CarpetContext)c).s;
|
||||||
s.getMinecraftServer().getPlayerManager().saveAllPlayerData();
|
s.getServer().getPlayerManager().saveAllPlayerData();
|
||||||
s.getMinecraftServer().save(true,true,true);
|
s.getServer().save(true,true,true);
|
||||||
s.getWorld().getChunkManager().tick(() -> true);
|
s.getWorld().getChunkManager().tick(() -> true);
|
||||||
CarpetScriptServer.LOG.warn("Saved chunks");
|
CarpetScriptServer.LOG.warn("Saved chunks");
|
||||||
return Value.TRUE;
|
return Value.TRUE;
|
||||||
});
|
});
|
||||||
|
|
||||||
expression.addContextFunction("tick_time", 0, (c, t, lv) ->
|
expression.addContextFunction("tick_time", 0, (c, t, lv) ->
|
||||||
new NumericValue(((CarpetContext) c).s.getMinecraftServer().getTicks()));
|
new NumericValue(((CarpetContext) c).s.getServer().getTicks()));
|
||||||
|
|
||||||
expression.addContextFunction("world_time", 0, (c, t, lv) ->
|
expression.addContextFunction("world_time", 0, (c, t, lv) ->
|
||||||
new NumericValue(((CarpetContext) c).s.getWorld().getTime()));
|
new NumericValue(((CarpetContext) c).s.getWorld().getTime()));
|
||||||
@@ -678,9 +678,9 @@ public class Auxiliary {
|
|||||||
{
|
{
|
||||||
//assuming we are in the tick world section
|
//assuming we are in the tick world section
|
||||||
// might be off one tick when run in the off tasks or asynchronously.
|
// might be off one tick when run in the off tasks or asynchronously.
|
||||||
int currentReportedTick = ((CarpetContext) c).s.getMinecraftServer().getTicks()-1;
|
int currentReportedTick = ((CarpetContext) c).s.getServer().getTicks()-1;
|
||||||
List<Value> ticks = new ArrayList<>(100);
|
List<Value> ticks = new ArrayList<>(100);
|
||||||
final long[] tickArray = ((CarpetContext) c).s.getMinecraftServer().lastTickLengths;
|
final long[] tickArray = ((CarpetContext) c).s.getServer().lastTickLengths;
|
||||||
for (int i=currentReportedTick+100; i > currentReportedTick; i--)
|
for (int i=currentReportedTick+100; i > currentReportedTick; i--)
|
||||||
{
|
{
|
||||||
ticks.add(new NumericValue(((double)tickArray[i % 100])/1000000.0));
|
ticks.add(new NumericValue(((double)tickArray[i % 100])/1000000.0));
|
||||||
@@ -692,12 +692,12 @@ public class Auxiliary {
|
|||||||
expression.addContextFunction("game_tick", -1, (c, t, lv) -> {
|
expression.addContextFunction("game_tick", -1, (c, t, lv) -> {
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
ServerCommandSource s = cc.s;
|
ServerCommandSource s = cc.s;
|
||||||
if (!s.getMinecraftServer().isOnThread()) throw new InternalExpressionException("Unable to run ticks from threads");
|
if (!s.getServer().isOnThread()) throw new InternalExpressionException("Unable to run ticks from threads");
|
||||||
if (CarpetServer.scriptServer.tickDepth > 16) throw new InternalExpressionException("'game_tick' function caused other 'game_tick' functions to run. You should not allow that.");
|
if (CarpetServer.scriptServer.tickDepth > 16) throw new InternalExpressionException("'game_tick' function caused other 'game_tick' functions to run. You should not allow that.");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CarpetServer.scriptServer.tickDepth ++;
|
CarpetServer.scriptServer.tickDepth ++;
|
||||||
((MinecraftServerInterface) s.getMinecraftServer()).forceTick(() -> System.nanoTime() - CarpetServer.scriptServer.tickStart < 50000000L);
|
((MinecraftServerInterface) s.getServer()).forceTick(() -> System.nanoTime() - CarpetServer.scriptServer.tickStart < 50000000L);
|
||||||
if (lv.size() > 0)
|
if (lv.size() > 0)
|
||||||
{
|
{
|
||||||
long ms_total = NumericValue.asNumber(lv.get(0)).getLong();
|
long ms_total = NumericValue.asNumber(lv.get(0)).getLong();
|
||||||
@@ -747,13 +747,13 @@ public class Auxiliary {
|
|||||||
ValueConversions.of( ((CarpetContext)c).s.getWorld()));
|
ValueConversions.of( ((CarpetContext)c).s.getWorld()));
|
||||||
|
|
||||||
expression.addContextFunction("view_distance", 0, (c, t, lv) ->
|
expression.addContextFunction("view_distance", 0, (c, t, lv) ->
|
||||||
new NumericValue(((CarpetContext)c).s.getMinecraftServer().getPlayerManager().getViewDistance()));
|
new NumericValue(((CarpetContext)c).s.getServer().getPlayerManager().getViewDistance()));
|
||||||
|
|
||||||
// lazy due to passthrough and context changing ability
|
// lazy due to passthrough and context changing ability
|
||||||
expression.addLazyFunction("in_dimension", 2, (c, t, lv) -> {
|
expression.addLazyFunction("in_dimension", 2, (c, t, lv) -> {
|
||||||
ServerCommandSource outerSource = ((CarpetContext)c).s;
|
ServerCommandSource outerSource = ((CarpetContext)c).s;
|
||||||
Value dimensionValue = lv.get(0).evalValue(c);
|
Value dimensionValue = lv.get(0).evalValue(c);
|
||||||
World world = ValueConversions.dimFromValue(dimensionValue, outerSource.getMinecraftServer());
|
World world = ValueConversions.dimFromValue(dimensionValue, outerSource.getServer());
|
||||||
if (world == outerSource.getWorld()) return lv.get(1);
|
if (world == outerSource.getWorld()) return lv.get(1);
|
||||||
ServerCommandSource innerSource = outerSource.withWorld((ServerWorld)world);
|
ServerCommandSource innerSource = outerSource.withWorld((ServerWorld)world);
|
||||||
Context newCtx = c.recreate();
|
Context newCtx = c.recreate();
|
||||||
@@ -791,7 +791,7 @@ public class Auxiliary {
|
|||||||
throw new InternalExpressionException("'plop' needs extra argument indicating what to plop");
|
throw new InternalExpressionException("'plop' needs extra argument indicating what to plop");
|
||||||
String what = lv.get(locator.offset).getString();
|
String what = lv.get(locator.offset).getString();
|
||||||
Value [] result = new Value[]{Value.NULL};
|
Value [] result = new Value[]{Value.NULL};
|
||||||
((CarpetContext)c).s.getMinecraftServer().submitAndJoin( () ->
|
((CarpetContext)c).s.getServer().submitAndJoin( () ->
|
||||||
{
|
{
|
||||||
Boolean res = FeatureGenerator.plop(what, ((CarpetContext) c).s.getWorld(), locator.block.getPos());
|
Boolean res = FeatureGenerator.plop(what, ((CarpetContext) c).s.getWorld(), locator.block.getPos());
|
||||||
|
|
||||||
@@ -969,7 +969,7 @@ public class Auxiliary {
|
|||||||
expression.addContextFunction("statistic", 3, (c, t, lv) ->
|
expression.addContextFunction("statistic", 3, (c, t, lv) ->
|
||||||
{
|
{
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
ServerPlayerEntity player = EntityValue.getPlayerByValue(cc.s.getMinecraftServer(), lv.get(0));
|
ServerPlayerEntity player = EntityValue.getPlayerByValue(cc.s.getServer(), lv.get(0));
|
||||||
if (player == null) return Value.NULL;
|
if (player == null) return Value.NULL;
|
||||||
Identifier category;
|
Identifier category;
|
||||||
Identifier statName;
|
Identifier statName;
|
||||||
@@ -1030,7 +1030,7 @@ public class Auxiliary {
|
|||||||
expression.addContextFunction("nbt_storage", -1, (c, t, lv) -> {
|
expression.addContextFunction("nbt_storage", -1, (c, t, lv) -> {
|
||||||
if (lv.size() > 2) throw new InternalExpressionException("'nbt_storage' requires 0, 1 or 2 arguments.");
|
if (lv.size() > 2) throw new InternalExpressionException("'nbt_storage' requires 0, 1 or 2 arguments.");
|
||||||
CarpetContext cc = (CarpetContext) c;
|
CarpetContext cc = (CarpetContext) c;
|
||||||
DataCommandStorage storage = cc.s.getMinecraftServer().getDataCommandStorage();
|
DataCommandStorage storage = cc.s.getServer().getDataCommandStorage();
|
||||||
if (lv.size() == 0)
|
if (lv.size() == 0)
|
||||||
return ListValue.wrap(storage.getIds().map(i -> new StringValue(nameFromRegistryId(i))).collect(Collectors.toList()));
|
return ListValue.wrap(storage.getIds().map(i -> new StringValue(nameFromRegistryId(i))).collect(Collectors.toList()));
|
||||||
String key = lv.get(0).getString();
|
String key = lv.get(0).getString();
|
||||||
@@ -1049,7 +1049,7 @@ public class Auxiliary {
|
|||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
String origName = lv.get(0).getString();
|
String origName = lv.get(0).getString();
|
||||||
String name = InputValidator.validateSimpleString(origName, true);
|
String name = InputValidator.validateSimpleString(origName, true);
|
||||||
MinecraftServer server = cc.s.getMinecraftServer();
|
MinecraftServer server = cc.s.getServer();
|
||||||
for (String dpName : server.getDataPackManager().getNames())
|
for (String dpName : server.getDataPackManager().getNames())
|
||||||
{
|
{
|
||||||
if (dpName.equalsIgnoreCase("file/"+name+".zip") ||
|
if (dpName.equalsIgnoreCase("file/"+name+".zip") ||
|
||||||
@@ -1114,7 +1114,7 @@ public class Auxiliary {
|
|||||||
expression.addContextFunction("enable_hidden_dimensions", 0, (c, t, lv) -> {
|
expression.addContextFunction("enable_hidden_dimensions", 0, (c, t, lv) -> {
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
// from minecraft.server.Main.main
|
// from minecraft.server.Main.main
|
||||||
MinecraftServer server = cc.s.getMinecraftServer();
|
MinecraftServer server = cc.s.getServer();
|
||||||
LevelStorage.Session session = ((MinecraftServerInterface)server).getCMSession();
|
LevelStorage.Session session = ((MinecraftServerInterface)server).getCMSession();
|
||||||
DataPackSettings dataPackSettings = session.getDataPackSettings();
|
DataPackSettings dataPackSettings = session.getDataPackSettings();
|
||||||
ResourcePackManager resourcePackManager = server.getDataPackManager();
|
ResourcePackManager resourcePackManager = server.getDataPackManager();
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class Entities {
|
|||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
if (cc.host.user != null)
|
if (cc.host.user != null)
|
||||||
{
|
{
|
||||||
ServerPlayerEntity player = cc.s.getMinecraftServer().getPlayerManager().getPlayer(cc.host.user);
|
ServerPlayerEntity player = cc.s.getServer().getPlayerManager().getPlayer(cc.host.user);
|
||||||
return EntityValue.of(player);
|
return EntityValue.of(player);
|
||||||
}
|
}
|
||||||
Entity callingEntity = cc.s.getEntity();
|
Entity callingEntity = cc.s.getEntity();
|
||||||
@@ -62,7 +62,7 @@ public class Entities {
|
|||||||
if ("all".equalsIgnoreCase(playerName))
|
if ("all".equalsIgnoreCase(playerName))
|
||||||
{
|
{
|
||||||
retval = ListValue.wrap(
|
retval = ListValue.wrap(
|
||||||
((CarpetContext)c).s.getMinecraftServer().getPlayerManager().getPlayerList().
|
((CarpetContext)c).s.getServer().getPlayerManager().getPlayerList().
|
||||||
stream().map(EntityValue::new).collect(Collectors.toList()));
|
stream().map(EntityValue::new).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
else if ("*".equalsIgnoreCase(playerName))
|
else if ("*".equalsIgnoreCase(playerName))
|
||||||
@@ -97,7 +97,7 @@ public class Entities {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerPlayerEntity player = ((CarpetContext) c).s.getMinecraftServer().getPlayerManager().getPlayer(playerName);
|
ServerPlayerEntity player = ((CarpetContext) c).s.getServer().getPlayerManager().getPlayer(playerName);
|
||||||
if (player != null)
|
if (player != null)
|
||||||
retval = new EntityValue(player);
|
retval = new EntityValue(player);
|
||||||
}
|
}
|
||||||
@@ -167,7 +167,7 @@ public class Entities {
|
|||||||
{
|
{
|
||||||
String who = lv.get(0).getString();
|
String who = lv.get(0).getString();
|
||||||
ServerCommandSource source = ((CarpetContext)c).s;
|
ServerCommandSource source = ((CarpetContext)c).s;
|
||||||
EntityValue.EntityClassDescriptor eDesc = EntityValue.getEntityDescriptor(who, source.getMinecraftServer());
|
EntityValue.EntityClassDescriptor eDesc = EntityValue.getEntityDescriptor(who, source.getServer());
|
||||||
List<? extends Entity> entityList = source.getWorld().getEntitiesByType(eDesc.directType, eDesc.filteringPredicate);
|
List<? extends Entity> entityList = source.getWorld().getEntitiesByType(eDesc.directType, eDesc.filteringPredicate);
|
||||||
return ListValue.wrap(entityList.stream().map(EntityValue::new).collect(Collectors.toList()));
|
return ListValue.wrap(entityList.stream().map(EntityValue::new).collect(Collectors.toList()));
|
||||||
});
|
});
|
||||||
@@ -195,7 +195,7 @@ public class Entities {
|
|||||||
throw new InternalExpressionException("Range of 'entity_area' cannot come from a block argument");
|
throw new InternalExpressionException("Range of 'entity_area' cannot come from a block argument");
|
||||||
Vec3d range = rangeLocator.vec;
|
Vec3d range = rangeLocator.vec;
|
||||||
Box area = centerBox.expand(range.x, range.y, range.z);
|
Box area = centerBox.expand(range.x, range.y, range.z);
|
||||||
EntityValue.EntityClassDescriptor eDesc = EntityValue.getEntityDescriptor(who, cc.s.getMinecraftServer());
|
EntityValue.EntityClassDescriptor eDesc = EntityValue.getEntityDescriptor(who, cc.s.getServer());
|
||||||
List<? extends Entity> entityList = cc.s.getWorld().getEntitiesByType(eDesc.directType, area,eDesc.filteringPredicate);
|
List<? extends Entity> entityList = cc.s.getWorld().getEntitiesByType(eDesc.directType, area,eDesc.filteringPredicate);
|
||||||
return ListValue.wrap(entityList.stream().map(EntityValue::new).collect(Collectors.toList()));
|
return ListValue.wrap(entityList.stream().map(EntityValue::new).collect(Collectors.toList()));
|
||||||
});
|
});
|
||||||
@@ -257,7 +257,7 @@ public class Entities {
|
|||||||
{
|
{
|
||||||
if (lv.size() > 1) throw new InternalExpressionException("'entity_types' requires one or no arguments");
|
if (lv.size() > 1) throw new InternalExpressionException("'entity_types' requires one or no arguments");
|
||||||
String desc = (lv.size() == 1)?lv.get(0).getString():"*";
|
String desc = (lv.size() == 1)?lv.get(0).getString():"*";
|
||||||
return EntityValue.getEntityDescriptor(desc, ((CarpetContext) c).s.getMinecraftServer()).listValue;
|
return EntityValue.getEntityDescriptor(desc, ((CarpetContext) c).s.getServer()).listValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
expression.addContextFunction("entity_load_handler", -1, (c, t, lv) ->
|
expression.addContextFunction("entity_load_handler", -1, (c, t, lv) ->
|
||||||
@@ -269,7 +269,7 @@ public class Entities {
|
|||||||
? ((ListValue) entityValue).getItems().stream().map(Value::getString).collect(Collectors.toList())
|
? ((ListValue) entityValue).getItems().stream().map(Value::getString).collect(Collectors.toList())
|
||||||
: Collections.singletonList(entityValue.getString());
|
: Collections.singletonList(entityValue.getString());
|
||||||
Set<EntityType<? extends Entity>> types = new HashSet<>();
|
Set<EntityType<? extends Entity>> types = new HashSet<>();
|
||||||
descriptors.forEach(s -> types.addAll(EntityValue.getEntityDescriptor(s, ((CarpetContext) c).s.getMinecraftServer()).typeList));
|
descriptors.forEach(s -> types.addAll(EntityValue.getEntityDescriptor(s, ((CarpetContext) c).s.getServer()).typeList));
|
||||||
FunctionArgument funArg = FunctionArgument.findIn(c, expression.module, lv, 1, true, false);
|
FunctionArgument funArg = FunctionArgument.findIn(c, expression.module, lv, 1, true, false);
|
||||||
CarpetEventServer events = ((CarpetScriptHost)c.host).getScriptServer().events;
|
CarpetEventServer events = ((CarpetScriptHost)c.host).getScriptServer().events;
|
||||||
if (funArg.function == null)
|
if (funArg.function == null)
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class Inventories {
|
|||||||
if (lv.size() == 0)
|
if (lv.size() == 0)
|
||||||
return ListValue.wrap(Registry.ITEM.getIds().stream().map(ValueConversions::of).collect(Collectors.toList()));
|
return ListValue.wrap(Registry.ITEM.getIds().stream().map(ValueConversions::of).collect(Collectors.toList()));
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
TagManager tagManager = cc.s.getMinecraftServer().getTagManager();
|
TagManager tagManager = cc.s.getServer().getTagManager();
|
||||||
String tag = lv.get(0).getString();
|
String tag = lv.get(0).getString();
|
||||||
net.minecraft.tag.Tag<Item> itemTag = tagManager.getOrCreateTagGroup(Registry.ITEM_KEY).getTag(new Identifier(tag));
|
net.minecraft.tag.Tag<Item> itemTag = tagManager.getOrCreateTagGroup(Registry.ITEM_KEY).getTag(new Identifier(tag));
|
||||||
if (itemTag == null) return Value.NULL;
|
if (itemTag == null) return Value.NULL;
|
||||||
@@ -75,7 +75,7 @@ public class Inventories {
|
|||||||
expression.addContextFunction("item_tags", -1, (c, t, lv) ->
|
expression.addContextFunction("item_tags", -1, (c, t, lv) ->
|
||||||
{
|
{
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
TagManager tagManager = cc.s.getMinecraftServer().getTagManager();
|
TagManager tagManager = cc.s.getServer().getTagManager();
|
||||||
if (lv.size() == 0)
|
if (lv.size() == 0)
|
||||||
return ListValue.wrap(tagManager.getOrCreateTagGroup(Registry.ITEM_KEY).getTagIds().stream().map(ValueConversions::of).collect(Collectors.toList()));
|
return ListValue.wrap(tagManager.getOrCreateTagGroup(Registry.ITEM_KEY).getTagIds().stream().map(ValueConversions::of).collect(Collectors.toList()));
|
||||||
Item item = NBTSerializableValue.parseItem(lv.get(0).getString()).getItem();
|
Item item = NBTSerializableValue.parseItem(lv.get(0).getString()).getItem();
|
||||||
@@ -106,7 +106,7 @@ public class Inventories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<Recipe<?>> recipes;
|
List<Recipe<?>> recipes;
|
||||||
recipes = ((RecipeManagerInterface) cc.s.getMinecraftServer().getRecipeManager()).getAllMatching(type, new Identifier(recipeName));
|
recipes = ((RecipeManagerInterface) cc.s.getServer().getRecipeManager()).getAllMatching(type, new Identifier(recipeName));
|
||||||
if (recipes.isEmpty())
|
if (recipes.isEmpty())
|
||||||
return Value.NULL;
|
return Value.NULL;
|
||||||
List<Value> recipesOutput = new ArrayList<>();
|
List<Value> recipesOutput = new ArrayList<>();
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class Scoreboards {
|
|||||||
expression.addContextFunction("scoreboard", -1, (c, t, lv) ->
|
expression.addContextFunction("scoreboard", -1, (c, t, lv) ->
|
||||||
{
|
{
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
Scoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard();
|
Scoreboard scoreboard = cc.s.getServer().getScoreboard();
|
||||||
if (lv.size()==0)
|
if (lv.size()==0)
|
||||||
return ListValue.wrap(scoreboard.getObjectiveNames().stream().map(StringValue::new).collect(Collectors.toList()));
|
return ListValue.wrap(scoreboard.getObjectiveNames().stream().map(StringValue::new).collect(Collectors.toList()));
|
||||||
String objectiveName = lv.get(0).getString();
|
String objectiveName = lv.get(0).getString();
|
||||||
@@ -102,7 +102,7 @@ public class Scoreboards {
|
|||||||
{
|
{
|
||||||
if (lv.size()==0) throw new InternalExpressionException("'scoreboard_remove' requires at least one parameter");
|
if (lv.size()==0) throw new InternalExpressionException("'scoreboard_remove' requires at least one parameter");
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
Scoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard();
|
Scoreboard scoreboard = cc.s.getServer().getScoreboard();
|
||||||
String objectiveName = lv.get(0).getString();
|
String objectiveName = lv.get(0).getString();
|
||||||
ScoreboardObjective objective = scoreboard.getObjective(objectiveName);
|
ScoreboardObjective objective = scoreboard.getObjective(objectiveName);
|
||||||
if (objective == null) return Value.FALSE;
|
if (objective == null) return Value.FALSE;
|
||||||
@@ -125,7 +125,7 @@ public class Scoreboards {
|
|||||||
expression.addContextFunction("scoreboard_add", -1, (c, t, lv)->
|
expression.addContextFunction("scoreboard_add", -1, (c, t, lv)->
|
||||||
{
|
{
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
Scoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard();
|
Scoreboard scoreboard = cc.s.getServer().getScoreboard();
|
||||||
if (lv.size() == 0 || lv.size()>2) throw new InternalExpressionException("'scoreboard_add' should have one or two parameters");
|
if (lv.size() == 0 || lv.size()>2) throw new InternalExpressionException("'scoreboard_add' should have one or two parameters");
|
||||||
String objectiveName = lv.get(0).getString();
|
String objectiveName = lv.get(0).getString();
|
||||||
ScoreboardCriterion criterion;
|
ScoreboardCriterion criterion;
|
||||||
@@ -163,7 +163,7 @@ public class Scoreboards {
|
|||||||
{
|
{
|
||||||
if(lv.size() < 2) throw new InternalExpressionException("'scoreboard_property' requires at least two parameters");
|
if(lv.size() < 2) throw new InternalExpressionException("'scoreboard_property' requires at least two parameters");
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
Scoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard();
|
Scoreboard scoreboard = cc.s.getServer().getScoreboard();
|
||||||
ScoreboardObjective objective = scoreboard.getObjective(lv.get(0).getString());
|
ScoreboardObjective objective = scoreboard.getObjective(lv.get(0).getString());
|
||||||
if(objective == null) return Value.NULL;
|
if(objective == null) return Value.NULL;
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ public class Scoreboards {
|
|||||||
expression.addContextFunction("scoreboard_display", 2, (c, t, lv) ->
|
expression.addContextFunction("scoreboard_display", 2, (c, t, lv) ->
|
||||||
{
|
{
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
Scoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard();
|
Scoreboard scoreboard = cc.s.getServer().getScoreboard();
|
||||||
String location = lv.get(0).getString();
|
String location = lv.get(0).getString();
|
||||||
int slot = Scoreboard.getDisplaySlotId(location);
|
int slot = Scoreboard.getDisplaySlotId(location);
|
||||||
if (slot < 0) throw new InternalExpressionException("Invalid objective slot: "+location);
|
if (slot < 0) throw new InternalExpressionException("Invalid objective slot: "+location);
|
||||||
@@ -249,7 +249,7 @@ public class Scoreboards {
|
|||||||
{
|
{
|
||||||
if(lv.size() > 1) throw new InternalExpressionException("'team_list' requires zero or one parameters");
|
if(lv.size() > 1) throw new InternalExpressionException("'team_list' requires zero or one parameters");
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
ServerScoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard();
|
ServerScoreboard scoreboard = cc.s.getServer().getScoreboard();
|
||||||
if(lv.size() == 0)
|
if(lv.size() == 0)
|
||||||
return ListValue.wrap(scoreboard.getTeamNames().stream().map(StringValue::of).collect(Collectors.toList()));
|
return ListValue.wrap(scoreboard.getTeamNames().stream().map(StringValue::of).collect(Collectors.toList()));
|
||||||
if (lv.size() != 1) return Value.NULL;
|
if (lv.size() != 1) return Value.NULL;
|
||||||
@@ -264,7 +264,7 @@ public class Scoreboards {
|
|||||||
if(!(lv.size() < 3 && lv.size() > 0)) throw new InternalExpressionException("'team_add' requires one or two parameters");
|
if(!(lv.size() < 3 && lv.size() > 0)) throw new InternalExpressionException("'team_add' requires one or two parameters");
|
||||||
|
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
ServerScoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard();
|
ServerScoreboard scoreboard = cc.s.getServer().getScoreboard();
|
||||||
String teamName = lv.get(0).getString();
|
String teamName = lv.get(0).getString();
|
||||||
|
|
||||||
if(lv.size() == 1)
|
if(lv.size() == 1)
|
||||||
@@ -287,7 +287,7 @@ public class Scoreboards {
|
|||||||
expression.addContextFunction("team_remove", 1, (c, t, lv) ->
|
expression.addContextFunction("team_remove", 1, (c, t, lv) ->
|
||||||
{
|
{
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
ServerScoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard();
|
ServerScoreboard scoreboard = cc.s.getServer().getScoreboard();
|
||||||
Value teamVal = lv.get(0);
|
Value teamVal = lv.get(0);
|
||||||
String team = teamVal.getString();
|
String team = teamVal.getString();
|
||||||
if(scoreboard.getTeam(team) == null) return Value.NULL;
|
if(scoreboard.getTeam(team) == null) return Value.NULL;
|
||||||
@@ -299,7 +299,7 @@ public class Scoreboards {
|
|||||||
expression.addContextFunction("team_leave", 1, (c, t, lv) ->
|
expression.addContextFunction("team_leave", 1, (c, t, lv) ->
|
||||||
{
|
{
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
ServerScoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard();
|
ServerScoreboard scoreboard = cc.s.getServer().getScoreboard();
|
||||||
Value playerVal = lv.get(0);
|
Value playerVal = lv.get(0);
|
||||||
String player = EntityValue.getPlayerNameByValue(playerVal);
|
String player = EntityValue.getPlayerNameByValue(playerVal);
|
||||||
if(player == null) return Value.NULL;
|
if(player == null) return Value.NULL;
|
||||||
@@ -309,7 +309,7 @@ public class Scoreboards {
|
|||||||
expression.addContextFunction("team_property", -1, (c, t, lv) ->
|
expression.addContextFunction("team_property", -1, (c, t, lv) ->
|
||||||
{
|
{
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
ServerScoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard();
|
ServerScoreboard scoreboard = cc.s.getServer().getScoreboard();
|
||||||
|
|
||||||
if(lv.size() < 2 || lv.size() > 3) throw new InternalExpressionException("'team_property' requires two or three arguments");
|
if(lv.size() < 2 || lv.size() > 3) throw new InternalExpressionException("'team_property' requires two or three arguments");
|
||||||
|
|
||||||
@@ -400,7 +400,7 @@ public class Scoreboards {
|
|||||||
|
|
||||||
expression.addContextFunction("bossbar", -1, (c, t, lv) ->
|
expression.addContextFunction("bossbar", -1, (c, t, lv) ->
|
||||||
{
|
{
|
||||||
BossBarManager bossBarManager = ((CarpetContext)c).s.getMinecraftServer().getBossBarManager();
|
BossBarManager bossBarManager = ((CarpetContext)c).s.getServer().getBossBarManager();
|
||||||
if(lv.size() > 3) throw new InternalExpressionException("'bossbar' accepts max three arguments");
|
if(lv.size() > 3) throw new InternalExpressionException("'bossbar' accepts max three arguments");
|
||||||
|
|
||||||
if(lv.size() == 0) return ListValue.wrap(bossBarManager.getAll().stream().map(CommandBossBar::getId).map(Identifier::toString).map(StringValue::of).collect(Collectors.toList()));
|
if(lv.size() == 0) return ListValue.wrap(bossBarManager.getAll().stream().map(CommandBossBar::getId).map(Identifier::toString).map(StringValue::of).collect(Collectors.toList()));
|
||||||
@@ -457,13 +457,13 @@ public class Scoreboards {
|
|||||||
|
|
||||||
if(propertyValue instanceof ListValue) {
|
if(propertyValue instanceof ListValue) {
|
||||||
((ListValue) propertyValue).getItems().forEach((v)->{
|
((ListValue) propertyValue).getItems().forEach((v)->{
|
||||||
ServerPlayerEntity player = EntityValue.getPlayerByValue(((CarpetContext)c).s.getMinecraftServer(),propertyValue);
|
ServerPlayerEntity player = EntityValue.getPlayerByValue(((CarpetContext)c).s.getServer(),propertyValue);
|
||||||
if(player != null) bossBar.addPlayer(player);
|
if(player != null) bossBar.addPlayer(player);
|
||||||
});
|
});
|
||||||
return Value.TRUE;
|
return Value.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerPlayerEntity player = EntityValue.getPlayerByValue(((CarpetContext) c).s.getMinecraftServer(), propertyValue);
|
ServerPlayerEntity player = EntityValue.getPlayerByValue(((CarpetContext) c).s.getServer(), propertyValue);
|
||||||
if(player != null) {
|
if(player != null) {
|
||||||
bossBar.addPlayer(player);
|
bossBar.addPlayer(player);
|
||||||
return Value.TRUE;
|
return Value.TRUE;
|
||||||
@@ -475,14 +475,14 @@ public class Scoreboards {
|
|||||||
{
|
{
|
||||||
bossBar.clearPlayers();
|
bossBar.clearPlayers();
|
||||||
((ListValue) propertyValue).getItems().forEach((v) -> {
|
((ListValue) propertyValue).getItems().forEach((v) -> {
|
||||||
ServerPlayerEntity p = EntityValue.getPlayerByValue(((CarpetContext) c).s.getMinecraftServer(), v);
|
ServerPlayerEntity p = EntityValue.getPlayerByValue(((CarpetContext) c).s.getServer(), v);
|
||||||
if (p != null) bossBar.addPlayer(p);
|
if (p != null) bossBar.addPlayer(p);
|
||||||
});
|
});
|
||||||
return Value.TRUE;
|
return Value.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ServerPlayerEntity p = EntityValue.getPlayerByValue(((CarpetContext) c).s.getMinecraftServer(), propertyValue);
|
ServerPlayerEntity p = EntityValue.getPlayerByValue(((CarpetContext) c).s.getServer(), propertyValue);
|
||||||
bossBar.clearPlayers();
|
bossBar.clearPlayers();
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
bossBar.addPlayer(p);
|
bossBar.addPlayer(p);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class Threading
|
|||||||
{
|
{
|
||||||
//"overidden" native call to cancel if on main thread
|
//"overidden" native call to cancel if on main thread
|
||||||
expression.addContextFunction("task_join", 1, (c, t, lv) -> {
|
expression.addContextFunction("task_join", 1, (c, t, lv) -> {
|
||||||
if (((CarpetContext)c).s.getMinecraftServer().isOnThread())
|
if (((CarpetContext)c).s.getServer().isOnThread())
|
||||||
throw new InternalExpressionException("'task_join' cannot be called from main thread to avoid deadlocks");
|
throw new InternalExpressionException("'task_join' cannot be called from main thread to avoid deadlocks");
|
||||||
Value v = lv.get(0);
|
Value v = lv.get(0);
|
||||||
if (!(v instanceof ThreadValue))
|
if (!(v instanceof ThreadValue))
|
||||||
@@ -27,13 +27,13 @@ public class Threading
|
|||||||
// has to be lazy due to deferred execution of the expression
|
// has to be lazy due to deferred execution of the expression
|
||||||
expression.addLazyFunctionWithDelegation("task_dock", 1, false,true, (c, t, expr, tok, lv) -> {
|
expression.addLazyFunctionWithDelegation("task_dock", 1, false,true, (c, t, expr, tok, lv) -> {
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
MinecraftServer server = cc.s.getMinecraftServer();
|
MinecraftServer server = cc.s.getServer();
|
||||||
if (server.isOnThread()) return lv.get(0); // pass through for on thread tasks
|
if (server.isOnThread()) return lv.get(0); // pass through for on thread tasks
|
||||||
Value[] result = new Value[]{Value.NULL};
|
Value[] result = new Value[]{Value.NULL};
|
||||||
RuntimeException[] internal = new RuntimeException[]{null};
|
RuntimeException[] internal = new RuntimeException[]{null};
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
((CarpetContext) c).s.getMinecraftServer().submitAndJoin(() ->
|
((CarpetContext) c).s.getServer().submitAndJoin(() ->
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -692,7 +692,7 @@ public class WorldAccess {
|
|||||||
boolean previous = CarpetSettings.impendingFillSkipUpdates.get();
|
boolean previous = CarpetSettings.impendingFillSkipUpdates.get();
|
||||||
if (previous) return lv.get(0);
|
if (previous) return lv.get(0);
|
||||||
Value [] result = new Value[]{Value.NULL};
|
Value [] result = new Value[]{Value.NULL};
|
||||||
((CarpetContext)c).s.getMinecraftServer().submitAndJoin( () ->
|
((CarpetContext)c).s.getServer().submitAndJoin( () ->
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -781,7 +781,7 @@ public class WorldAccess {
|
|||||||
BlockState finalSourceBlockState = sourceBlockState;
|
BlockState finalSourceBlockState = sourceBlockState;
|
||||||
BlockPos targetPos = targetLocator.block.getPos();
|
BlockPos targetPos = targetLocator.block.getPos();
|
||||||
Boolean[] result = new Boolean[]{true};
|
Boolean[] result = new Boolean[]{true};
|
||||||
cc.s.getMinecraftServer().submitAndJoin( () ->
|
cc.s.getServer().submitAndJoin( () ->
|
||||||
{
|
{
|
||||||
Clearable.clear(world.getBlockEntity(targetPos));
|
Clearable.clear(world.getBlockEntity(targetPos));
|
||||||
boolean success = world.setBlockState(targetPos, finalSourceBlockState, 2);
|
boolean success = world.setBlockState(targetPos, finalSourceBlockState, 2);
|
||||||
@@ -1135,7 +1135,7 @@ public class WorldAccess {
|
|||||||
if (lv.size() == 0)
|
if (lv.size() == 0)
|
||||||
return ListValue.wrap(Registry.BLOCK.getIds().stream().map(ValueConversions::of).collect(Collectors.toList()));
|
return ListValue.wrap(Registry.BLOCK.getIds().stream().map(ValueConversions::of).collect(Collectors.toList()));
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
TagManager tagManager = cc.s.getMinecraftServer().getTagManager();
|
TagManager tagManager = cc.s.getServer().getTagManager();
|
||||||
String tag = lv.get(0).getString();
|
String tag = lv.get(0).getString();
|
||||||
net.minecraft.tag.Tag<Block> blockTag = tagManager.getOrCreateTagGroup(Registry.BLOCK_KEY).getTag(new Identifier(tag));
|
net.minecraft.tag.Tag<Block> blockTag = tagManager.getOrCreateTagGroup(Registry.BLOCK_KEY).getTag(new Identifier(tag));
|
||||||
if (blockTag == null) return Value.NULL;
|
if (blockTag == null) return Value.NULL;
|
||||||
@@ -1145,7 +1145,7 @@ public class WorldAccess {
|
|||||||
expression.addContextFunction("block_tags", -1, (c, t, lv) ->
|
expression.addContextFunction("block_tags", -1, (c, t, lv) ->
|
||||||
{
|
{
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
TagManager tagManager = cc.s.getMinecraftServer().getTagManager();
|
TagManager tagManager = cc.s.getServer().getTagManager();
|
||||||
if (lv.size() == 0)
|
if (lv.size() == 0)
|
||||||
return ListValue.wrap(tagManager.getOrCreateTagGroup(Registry.BLOCK_KEY).getTagIds().stream().map(ValueConversions::of).collect(Collectors.toList()));
|
return ListValue.wrap(tagManager.getOrCreateTagGroup(Registry.BLOCK_KEY).getTagIds().stream().map(ValueConversions::of).collect(Collectors.toList()));
|
||||||
BlockArgument blockLocator = BlockArgument.findIn(cc, lv, 0, true);
|
BlockArgument blockLocator = BlockArgument.findIn(cc, lv, 0, true);
|
||||||
@@ -1182,7 +1182,7 @@ public class WorldAccess {
|
|||||||
// in locatebiome
|
// in locatebiome
|
||||||
if (locator.offset == lv.size())
|
if (locator.offset == lv.size())
|
||||||
{
|
{
|
||||||
Identifier biomeId = cc.s.getMinecraftServer().getRegistryManager().get(Registry.BIOME_KEY).getId(biome);
|
Identifier biomeId = cc.s.getServer().getRegistryManager().get(Registry.BIOME_KEY).getId(biome);
|
||||||
return new StringValue(NBTSerializableValue.nameFromRegistryId(biomeId));
|
return new StringValue(NBTSerializableValue.nameFromRegistryId(biomeId));
|
||||||
}
|
}
|
||||||
String biomeFeature = lv.get(locator.offset).getString();
|
String biomeFeature = lv.get(locator.offset).getString();
|
||||||
@@ -1199,7 +1199,7 @@ public class WorldAccess {
|
|||||||
throw new InternalExpressionException("'set_biome' needs a biome name as an argument");
|
throw new InternalExpressionException("'set_biome' needs a biome name as an argument");
|
||||||
String biomeName = lv.get(locator.offset+0).getString();
|
String biomeName = lv.get(locator.offset+0).getString();
|
||||||
// from locatebiome command code
|
// from locatebiome command code
|
||||||
Biome biome = cc.s.getMinecraftServer().getRegistryManager().get(Registry.BIOME_KEY).getOrEmpty(new Identifier(biomeName))
|
Biome biome = cc.s.getServer().getRegistryManager().get(Registry.BIOME_KEY).getOrEmpty(new Identifier(biomeName))
|
||||||
.orElseThrow(() -> new ThrowStatement(biomeName, Throwables.UNKNOWN_BIOME));
|
.orElseThrow(() -> new ThrowStatement(biomeName, Throwables.UNKNOWN_BIOME));
|
||||||
boolean doImmediateUpdate = true;
|
boolean doImmediateUpdate = true;
|
||||||
if (lv.size() > locator.offset+1)
|
if (lv.size() > locator.offset+1)
|
||||||
@@ -1218,7 +1218,7 @@ public class WorldAccess {
|
|||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
BlockPos pos = BlockArgument.findIn(cc, lv, 0).block.getPos();
|
BlockPos pos = BlockArgument.findIn(cc, lv, 0).block.getPos();
|
||||||
ServerWorld world = cc.s.getWorld();
|
ServerWorld world = cc.s.getWorld();
|
||||||
cc.s.getMinecraftServer().submitAndJoin( () -> WorldTools.forceChunkUpdate(pos, world));
|
cc.s.getServer().submitAndJoin( () -> WorldTools.forceChunkUpdate(pos, world));
|
||||||
return Value.TRUE;
|
return Value.TRUE;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1345,7 +1345,7 @@ public class WorldAccess {
|
|||||||
// good 'ol pointer
|
// good 'ol pointer
|
||||||
Value[] result = new Value[]{Value.NULL};
|
Value[] result = new Value[]{Value.NULL};
|
||||||
// technically a world modification. Even if we could let it slide, we will still park it
|
// technically a world modification. Even if we could let it slide, we will still park it
|
||||||
((CarpetContext) c).s.getMinecraftServer().submitAndJoin(() ->
|
((CarpetContext) c).s.getServer().submitAndJoin(() ->
|
||||||
{
|
{
|
||||||
Map<StructureFeature<?>, StructureStart<?>> structures = world.getChunk(pos).getStructureStarts();
|
Map<StructureFeature<?>, StructureStart<?>> structures = world.getChunk(pos).getStructureStarts();
|
||||||
if (lv.size() == locator.offset + 1)
|
if (lv.size() == locator.offset + 1)
|
||||||
@@ -1407,7 +1407,7 @@ public class WorldAccess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean success = WorldTools.createWorld(cc.s.getMinecraftServer(), worldKey, seed);
|
boolean success = WorldTools.createWorld(cc.s.getServer(), worldKey, seed);
|
||||||
if (!success) return Value.FALSE;
|
if (!success) return Value.FALSE;
|
||||||
CarpetServer.settingsManager.notifyPlayersCommandsChanged();
|
CarpetServer.settingsManager.notifyPlayersCommandsChanged();
|
||||||
return Value.TRUE;
|
return Value.TRUE;
|
||||||
@@ -1466,7 +1466,7 @@ public class WorldAccess {
|
|||||||
|
|
||||||
Value [] result = new Value[]{Value.NULL};
|
Value [] result = new Value[]{Value.NULL};
|
||||||
|
|
||||||
((CarpetContext)c).s.getMinecraftServer().submitAndJoin( () ->
|
((CarpetContext)c).s.getServer().submitAndJoin( () ->
|
||||||
{
|
{
|
||||||
Map<String, Integer> report = ((ThreadedAnvilChunkStorageInterface) world.getChunkManager().threadedAnvilChunkStorage).regenerateChunkRegion(requestedChunks);
|
Map<String, Integer> report = ((ThreadedAnvilChunkStorageInterface) world.getChunkManager().threadedAnvilChunkStorage).regenerateChunkRegion(requestedChunks);
|
||||||
/*for (ChunkPos chpos: requestedChunks) // needed in 1.16 only
|
/*for (ChunkPos chpos: requestedChunks) // needed in 1.16 only
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ public abstract class CommandArgument
|
|||||||
false
|
false
|
||||||
),
|
),
|
||||||
new VanillaUnconfigurableArgument( "blockpredicate", BlockPredicateArgumentType::blockPredicate,
|
new VanillaUnconfigurableArgument( "blockpredicate", BlockPredicateArgumentType::blockPredicate,
|
||||||
(c, p) -> ValueConversions.ofBlockPredicate(c.getSource().getMinecraftServer().getTagManager(), BlockPredicateArgumentType.getBlockPredicate(c, p)), false
|
(c, p) -> ValueConversions.ofBlockPredicate(c.getSource().getServer().getTagManager(), BlockPredicateArgumentType.getBlockPredicate(c, p)), false
|
||||||
),
|
),
|
||||||
new VanillaUnconfigurableArgument("teamcolor", ColorArgumentType::color,
|
new VanillaUnconfigurableArgument("teamcolor", ColorArgumentType::color,
|
||||||
(c, p) -> {
|
(c, p) -> {
|
||||||
@@ -199,13 +199,13 @@ public abstract class CommandArgument
|
|||||||
(c, p) -> ValueConversions.of( IdentifierArgumentType.getRecipeArgument(c, p).getId()), SuggestionProviders.ALL_RECIPES
|
(c, p) -> ValueConversions.of( IdentifierArgumentType.getRecipeArgument(c, p).getId()), SuggestionProviders.ALL_RECIPES
|
||||||
),
|
),
|
||||||
new VanillaUnconfigurableArgument("advancement", IdentifierArgumentType::identifier,
|
new VanillaUnconfigurableArgument("advancement", IdentifierArgumentType::identifier,
|
||||||
(c, p) -> ValueConversions.of( IdentifierArgumentType.getAdvancementArgument(c, p).getId()), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getMinecraftServer().getAdvancementLoader().getAdvancements().stream().map(Advancement::getId), builder)
|
(c, p) -> ValueConversions.of( IdentifierArgumentType.getAdvancementArgument(c, p).getId()), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getServer().getAdvancementLoader().getAdvancements().stream().map(Advancement::getId), builder)
|
||||||
),
|
),
|
||||||
new VanillaUnconfigurableArgument("lootcondition", IdentifierArgumentType::identifier,
|
new VanillaUnconfigurableArgument("lootcondition", IdentifierArgumentType::identifier,
|
||||||
(c, p) -> ValueConversions.of( Registry.LOOT_CONDITION_TYPE.getId(IdentifierArgumentType.getPredicateArgument(c, p).getType())), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getMinecraftServer().getPredicateManager().getIds(), builder)
|
(c, p) -> ValueConversions.of( Registry.LOOT_CONDITION_TYPE.getId(IdentifierArgumentType.getPredicateArgument(c, p).getType())), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getServer().getPredicateManager().getIds(), builder)
|
||||||
),
|
),
|
||||||
new VanillaUnconfigurableArgument("loottable", IdentifierArgumentType::identifier,
|
new VanillaUnconfigurableArgument("loottable", IdentifierArgumentType::identifier,
|
||||||
(c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getMinecraftServer().getLootManager().getTableIds(), builder)
|
(c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getServer().getLootManager().getTableIds(), builder)
|
||||||
),
|
),
|
||||||
new VanillaUnconfigurableArgument("attribute", IdentifierArgumentType::identifier,
|
new VanillaUnconfigurableArgument("attribute", IdentifierArgumentType::identifier,
|
||||||
(c, p) -> ValueConversions.of( Registry.ATTRIBUTE.getId(IdentifierArgumentType.getAttributeArgument(c, p))), (ctx, builder) -> CommandSource.suggestIdentifiers(Registry.ATTRIBUTE.getIds(), builder)
|
(c, p) -> ValueConversions.of( Registry.ATTRIBUTE.getId(IdentifierArgumentType.getAttributeArgument(c, p))), (ctx, builder) -> CommandSource.suggestIdentifiers(Registry.ATTRIBUTE.getIds(), builder)
|
||||||
@@ -220,7 +220,7 @@ public abstract class CommandArgument
|
|||||||
(c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), SuggestionProviders.AVAILABLE_SOUNDS
|
(c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), SuggestionProviders.AVAILABLE_SOUNDS
|
||||||
),
|
),
|
||||||
new VanillaUnconfigurableArgument("storekey", IdentifierArgumentType::identifier,
|
new VanillaUnconfigurableArgument("storekey", IdentifierArgumentType::identifier,
|
||||||
(c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getMinecraftServer().getDataCommandStorage().getIds(), builder)
|
(c, p) -> ValueConversions.of( IdentifierArgumentType.getIdentifier(c, p)), (ctx, builder) -> CommandSource.suggestIdentifiers(ctx.getSource().getServer().getDataCommandStorage().getIds(), builder)
|
||||||
),
|
),
|
||||||
|
|
||||||
// default
|
// default
|
||||||
|
|||||||
@@ -283,14 +283,14 @@ public class AppStoreManager
|
|||||||
public static boolean saveScriptToFile(ServerCommandSource source, String path, String appFileName, String code, boolean globalSavePath){
|
public static boolean saveScriptToFile(ServerCommandSource source, String path, String appFileName, String code, boolean globalSavePath){
|
||||||
String scriptPath;
|
String scriptPath;
|
||||||
String location;
|
String location;
|
||||||
if(globalSavePath && !source.getMinecraftServer().isDedicated())
|
if(globalSavePath && !source.getServer().isDedicated())
|
||||||
{ //cos config folder only is in clients
|
{ //cos config folder only is in clients
|
||||||
scriptPath = FabricLoader.getInstance().getConfigDir().resolve("carpet/scripts/appstore").toAbsolutePath()+"/"+path;
|
scriptPath = FabricLoader.getInstance().getConfigDir().resolve("carpet/scripts/appstore").toAbsolutePath()+"/"+path;
|
||||||
location = "global script config folder";
|
location = "global script config folder";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
scriptPath = source.getMinecraftServer().getSavePath(WorldSavePath.ROOT).resolve("scripts").toAbsolutePath()+"/"+appFileName;
|
scriptPath = source.getServer().getSavePath(WorldSavePath.ROOT).resolve("scripts").toAbsolutePath()+"/"+appFileName;
|
||||||
location = "world scripts folder";
|
location = "world scripts folder";
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class SnoopyCommandSource extends ServerCommandSource
|
|||||||
public SnoopyCommandSource(ServerCommandSource original, Text[] error, List<Text> chatOutput)
|
public SnoopyCommandSource(ServerCommandSource original, Text[] error, List<Text> chatOutput)
|
||||||
{
|
{
|
||||||
super(CommandOutput.DUMMY, original.getPosition(), original.getRotation(), original.getWorld(), CarpetSettings.runPermissionLevel,
|
super(CommandOutput.DUMMY, original.getPosition(), original.getRotation(), original.getWorld(), CarpetSettings.runPermissionLevel,
|
||||||
original.getName(), original.getDisplayName(), original.getMinecraftServer(), original.getEntity(), false,
|
original.getName(), original.getDisplayName(), original.getServer(), original.getEntity(), false,
|
||||||
(ctx, succ, res) -> { }, EntityAnchorArgumentType.EntityAnchor.FEET);
|
(ctx, succ, res) -> { }, EntityAnchorArgumentType.EntityAnchor.FEET);
|
||||||
this.output = CommandOutput.DUMMY;
|
this.output = CommandOutput.DUMMY;
|
||||||
this.position = original.getPosition();
|
this.position = original.getPosition();
|
||||||
@@ -48,7 +48,7 @@ public class SnoopyCommandSource extends ServerCommandSource
|
|||||||
this.level = CarpetSettings.runPermissionLevel;
|
this.level = CarpetSettings.runPermissionLevel;
|
||||||
this.simpleName = original.getName();
|
this.simpleName = original.getName();
|
||||||
this.name = original.getDisplayName();
|
this.name = original.getDisplayName();
|
||||||
this.server = original.getMinecraftServer();
|
this.server = original.getServer();
|
||||||
this.entity = original.getEntity();
|
this.entity = original.getEntity();
|
||||||
this.resultConsumer = (ctx, succ, res) -> { };
|
this.resultConsumer = (ctx, succ, res) -> { };
|
||||||
this.entityAnchor = original.getEntityAnchor();
|
this.entityAnchor = original.getEntityAnchor();
|
||||||
|
|||||||
@@ -42,31 +42,31 @@ public class SystemInfo {
|
|||||||
put("app_scope", c -> StringValue.of((c.host).isPerUser()?"player":"global"));
|
put("app_scope", c -> StringValue.of((c.host).isPerUser()?"player":"global"));
|
||||||
put("app_players", c -> ListValue.wrap(c.host.getUserList().stream().map(StringValue::new).collect(Collectors.toList())));
|
put("app_players", c -> ListValue.wrap(c.host.getUserList().stream().map(StringValue::new).collect(Collectors.toList())));
|
||||||
|
|
||||||
put("world_name", c -> new StringValue(c.s.getMinecraftServer().getSaveProperties().getLevelName()));
|
put("world_name", c -> new StringValue(c.s.getServer().getSaveProperties().getLevelName()));
|
||||||
put("world_seed", c -> new NumericValue(c.s.getWorld().getSeed()));
|
put("world_seed", c -> new NumericValue(c.s.getWorld().getSeed()));
|
||||||
put("server_motd", c -> StringValue.of(c.s.getMinecraftServer().getServerMotd()));
|
put("server_motd", c -> StringValue.of(c.s.getServer().getServerMotd()));
|
||||||
put("world_path", c -> StringValue.of(c.s.getMinecraftServer().getSavePath(WorldSavePath.ROOT).toString()));
|
put("world_path", c -> StringValue.of(c.s.getServer().getSavePath(WorldSavePath.ROOT).toString()));
|
||||||
put("world_folder", c -> {
|
put("world_folder", c -> {
|
||||||
Path serverPath = c.s.getMinecraftServer().getSavePath(WorldSavePath.ROOT);
|
Path serverPath = c.s.getServer().getSavePath(WorldSavePath.ROOT);
|
||||||
int nodeCount = serverPath.getNameCount();
|
int nodeCount = serverPath.getNameCount();
|
||||||
if (nodeCount < 2) return Value.NULL;
|
if (nodeCount < 2) return Value.NULL;
|
||||||
String tlf = serverPath.getName(nodeCount-2).toString();
|
String tlf = serverPath.getName(nodeCount-2).toString();
|
||||||
return StringValue.of(tlf);
|
return StringValue.of(tlf);
|
||||||
});
|
});
|
||||||
put("world_dimensions", c -> ListValue.wrap(c.s.getMinecraftServer().getWorldRegistryKeys().stream().map(k -> ValueConversions.of(k.getValue())).collect(Collectors.toList())));
|
put("world_dimensions", c -> ListValue.wrap(c.s.getServer().getWorldRegistryKeys().stream().map(k -> ValueConversions.of(k.getValue())).collect(Collectors.toList())));
|
||||||
put("world_spawn_point", c -> {
|
put("world_spawn_point", c -> {
|
||||||
WorldProperties prop = c.s.getMinecraftServer().getOverworld().getLevelProperties();
|
WorldProperties prop = c.s.getServer().getOverworld().getLevelProperties();
|
||||||
return ListValue.of(NumericValue.of(prop.getSpawnX()), NumericValue.of(prop.getSpawnY()), NumericValue.of(prop.getSpawnZ()));
|
return ListValue.of(NumericValue.of(prop.getSpawnX()), NumericValue.of(prop.getSpawnY()), NumericValue.of(prop.getSpawnZ()));
|
||||||
});
|
});
|
||||||
|
|
||||||
put("game_difficulty", c -> StringValue.of(c.s.getMinecraftServer().getSaveProperties().getDifficulty().getName()));
|
put("game_difficulty", c -> StringValue.of(c.s.getServer().getSaveProperties().getDifficulty().getName()));
|
||||||
put("game_hardcore", c -> BooleanValue.of(c.s.getMinecraftServer().getSaveProperties().isHardcore()));
|
put("game_hardcore", c -> BooleanValue.of(c.s.getServer().getSaveProperties().isHardcore()));
|
||||||
put("game_storage_format", c -> StringValue.of(c.s.getMinecraftServer().getSaveProperties().getFormatName(c.s.getMinecraftServer().getSaveProperties().getVersion())));
|
put("game_storage_format", c -> StringValue.of(c.s.getServer().getSaveProperties().getFormatName(c.s.getServer().getSaveProperties().getVersion())));
|
||||||
put("game_default_gamemode", c -> StringValue.of(c.s.getMinecraftServer().getDefaultGameMode().getName()));
|
put("game_default_gamemode", c -> StringValue.of(c.s.getServer().getDefaultGameMode().getName()));
|
||||||
put("game_max_players", c -> new NumericValue(c.s.getMinecraftServer().getMaxPlayerCount()));
|
put("game_max_players", c -> new NumericValue(c.s.getServer().getMaxPlayerCount()));
|
||||||
put("game_view_distance", c -> new NumericValue(c.s.getMinecraftServer().getPlayerManager().getViewDistance()));
|
put("game_view_distance", c -> new NumericValue(c.s.getServer().getPlayerManager().getViewDistance()));
|
||||||
put("game_mod_name", c -> StringValue.of(c.s.getMinecraftServer().getServerModName()));
|
put("game_mod_name", c -> StringValue.of(c.s.getServer().getServerModName()));
|
||||||
put("game_version", c -> StringValue.of(c.s.getMinecraftServer().getVersion()));
|
put("game_version", c -> StringValue.of(c.s.getServer().getVersion()));
|
||||||
put("game_target", c -> StringValue.of(SharedConstants.getGameVersion().getReleaseTarget()));
|
put("game_target", c -> StringValue.of(SharedConstants.getGameVersion().getReleaseTarget()));
|
||||||
put("game_protocol", c -> NumericValue.of(SharedConstants.getProtocolVersion()));
|
put("game_protocol", c -> NumericValue.of(SharedConstants.getProtocolVersion()));
|
||||||
put("game_major_target", c -> {
|
put("game_major_target", c -> {
|
||||||
@@ -81,11 +81,11 @@ public class SystemInfo {
|
|||||||
put("game_data_version", c->NumericValue.of(SharedConstants.getGameVersion().getWorldVersion()));
|
put("game_data_version", c->NumericValue.of(SharedConstants.getGameVersion().getWorldVersion()));
|
||||||
put("game_pack_version", c->NumericValue.of(SharedConstants.getGameVersion().getPackVersion()));
|
put("game_pack_version", c->NumericValue.of(SharedConstants.getGameVersion().getPackVersion()));
|
||||||
|
|
||||||
put("server_ip", c -> StringValue.of(c.s.getMinecraftServer().getServerIp()));
|
put("server_ip", c -> StringValue.of(c.s.getServer().getServerIp()));
|
||||||
put("server_whitelisted", c -> BooleanValue.of(c.s.getMinecraftServer().isEnforceWhitelist()));
|
put("server_whitelisted", c -> BooleanValue.of(c.s.getServer().isEnforceWhitelist()));
|
||||||
put("server_whitelist", c -> {
|
put("server_whitelist", c -> {
|
||||||
MapValue whitelist = new MapValue(Collections.emptyList());
|
MapValue whitelist = new MapValue(Collections.emptyList());
|
||||||
for (String s: c.s.getMinecraftServer().getPlayerManager().getWhitelistedNames())
|
for (String s: c.s.getServer().getPlayerManager().getWhitelistedNames())
|
||||||
{
|
{
|
||||||
whitelist.append(StringValue.of(s));
|
whitelist.append(StringValue.of(s));
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ public class SystemInfo {
|
|||||||
});
|
});
|
||||||
put("server_banned_players", c -> {
|
put("server_banned_players", c -> {
|
||||||
MapValue whitelist = new MapValue(Collections.emptyList());
|
MapValue whitelist = new MapValue(Collections.emptyList());
|
||||||
for (String s: c.s.getMinecraftServer().getPlayerManager().getUserBanList().getNames())
|
for (String s: c.s.getServer().getPlayerManager().getUserBanList().getNames())
|
||||||
{
|
{
|
||||||
whitelist.append(StringValue.of(s));
|
whitelist.append(StringValue.of(s));
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ public class SystemInfo {
|
|||||||
});
|
});
|
||||||
put("server_banned_ips", c -> {
|
put("server_banned_ips", c -> {
|
||||||
MapValue whitelist = new MapValue(Collections.emptyList());
|
MapValue whitelist = new MapValue(Collections.emptyList());
|
||||||
for (String s: c.s.getMinecraftServer().getPlayerManager().getIpBanList().getNames())
|
for (String s: c.s.getServer().getPlayerManager().getIpBanList().getNames())
|
||||||
{
|
{
|
||||||
whitelist.append(StringValue.of(s));
|
whitelist.append(StringValue.of(s));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
|||||||
if (strVal.equals("enderchest"))
|
if (strVal.equals("enderchest"))
|
||||||
{
|
{
|
||||||
Value v2 = params.get(1 + offset);
|
Value v2 = params.get(1 + offset);
|
||||||
ServerPlayerEntity player = EntityValue.getPlayerByValue(c.s.getMinecraftServer(), v2);
|
ServerPlayerEntity player = EntityValue.getPlayerByValue(c.s.getServer(), v2);
|
||||||
if (player == null) throw new InternalExpressionException("enderchest inventory requires player argument");
|
if (player == null) throw new InternalExpressionException("enderchest inventory requires player argument");
|
||||||
return new InventoryLocator(player, player.getBlockPos(), player.getEnderChestInventory(), offset + 2, true);
|
return new InventoryLocator(player, player.getBlockPos(), player.getEnderChestInventory(), offset + 2, true);
|
||||||
}
|
}
|
||||||
@@ -221,7 +221,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
|||||||
}
|
}
|
||||||
boolean isEnder = strVal.startsWith("enderchest_");
|
boolean isEnder = strVal.startsWith("enderchest_");
|
||||||
if (isEnder) strVal = strVal.substring(11); // len("enderchest_")
|
if (isEnder) strVal = strVal.substring(11); // len("enderchest_")
|
||||||
ServerPlayerEntity player = c.s.getMinecraftServer().getPlayerManager().getPlayer(strVal);
|
ServerPlayerEntity player = c.s.getServer().getPlayerManager().getPlayer(strVal);
|
||||||
if (player == null) throw new InternalExpressionException("String description of an inventory should either denote a player or player's enderchest");
|
if (player == null) throw new InternalExpressionException("String description of an inventory should either denote a player or player's enderchest");
|
||||||
return new InventoryLocator(
|
return new InventoryLocator(
|
||||||
player,
|
player,
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class CarpetProfiler
|
|||||||
{
|
{
|
||||||
SECTION_STATS.put(section, 0L);
|
SECTION_STATS.put(section, 0L);
|
||||||
}
|
}
|
||||||
for (RegistryKey<World> level : source.getMinecraftServer().getWorldRegistryKeys())
|
for (RegistryKey<World> level : source.getServer().getWorldRegistryKeys())
|
||||||
{
|
{
|
||||||
for (String section : SECTIONS)
|
for (String section : SECTIONS)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ public class Messenger
|
|||||||
public static void m(ServerCommandSource source, Object ... fields)
|
public static void m(ServerCommandSource source, Object ... fields)
|
||||||
{
|
{
|
||||||
if (source != null)
|
if (source != null)
|
||||||
source.sendFeedback(Messenger.c(fields),source.getMinecraftServer() != null && source.getMinecraftServer().getWorld(World.OVERWORLD) != null); //OW
|
source.sendFeedback(Messenger.c(fields),source.getServer() != null && source.getServer().getWorld(World.OVERWORLD) != null); //OW
|
||||||
}
|
}
|
||||||
public static void m(PlayerEntity player, Object ... fields)
|
public static void m(PlayerEntity player, Object ... fields)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user