pala M-cmd-util: /craft table portable + /spawn delai 3s (wiki commandes)

This commit is contained in:
Anaïs Saraiva
2026-10-19 02:41:23 +02:00
parent 6e0bed343b
commit e3b4500bd6
3 changed files with 76 additions and 6 deletions
+4
View File
@@ -530,6 +530,10 @@ avant M4 (TODO:crafts-machines).
assets/pala/items/*.json exigees en 26.3 par ClientItemInfoLoader — 162 generees, une par
models/item). VERIFIE en jeu : minerai texturé en main, epee orange complete, 0 damier
(visfix1/visfix2). Lecon : models/item seuls ne suffisent plus ; le missing est silencieux.
- M-cmd-util LIVRE 2026-10-19 ~02:45 : /craft (table portable via CraftingMenu+SimpleMenuProvider,
APIs verifiees javap) + /spawn (tp spawn overworld, delai wiki 3 s via END_SERVER_TICK, file
UUID). Refacto teleport() vers teleportPlayer(). VERIFIE : build SUCCESSFUL, boot Done,
0 erreur. UNVERIFIED en jeu (pas de joueur).
- Client/mod : boucle visuelle OPERATIONNELLE 2026-10-19 (Xvfb :99 + runClient SDL x11 +
captures Java Robot + pilotage xdotool + vision_analyze) : menu, Select World, monde New World
(creatif, cheats), /give, pose de bloc, inventaire, F3+T. Screens : scratch vis*.png.
@@ -24,12 +24,17 @@ import fr.surviepote.pala.core.PalaPermissions;
import fr.surviepote.pala.core.PalaStorage;
// Commandes Pala : /end /overworld (permission niveau 4, legacy), /nether (gate metier
// mineur niv.3, M0), /pala reload|info|rank (admin), /jobs (metiers). Voir CDC §3.8.
// mineur niv.3, M0), /pala reload|info|rank (admin), /jobs (metiers), /craft (table de
// craft portable, wiki commandes), /spawn (tp spawn overworld, delai 3 s sans grade, wiki).
// Voir CDC §3.8.
// Origine : CommandEnd/Nether/Overworld + procedures *CommandExecuted qui
// teleportaient le joueur au spawn de la dimension visee. Ici via
// TeleportTransition (API 26.x), sans le Teleporter custom du legacy.
public final class PalaCommands {
// M-cmd-util : /spawn differe (delai wiki 3 s = 60 ticks). UUID -> tick d'execution.
private static final java.util.Map<java.util.UUID, Long> SPAWN_QUEUE = new java.util.HashMap<>();
private PalaCommands() {
}
@@ -69,6 +74,12 @@ public final class PalaCommands {
.then(joueurArg)));
dispatcher.register(Commands.literal("jobs")
.executes(command -> jobs(command.getSource())));
dispatcher.register(Commands.literal("craft")
.executes(command -> craft(command.getSource())));
dispatcher.register(Commands.literal("spawn")
.executes(command -> spawn(command.getSource())));
net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents.END_SERVER_TICK
.register(PalaCommands::tickSpawnQueue);
});
}
@@ -204,14 +215,69 @@ public final class PalaCommands {
} else {
spawn = target.getRespawnData().pos();
}
Vec3 pos = new Vec3(spawn.getX() + 0.5, spawn.getY() + 1.0, spawn.getZ() + 0.5);
player.teleport(new TeleportTransition(target, pos, Vec3.ZERO, player.getYRot(), player.getXRot(),
TeleportTransition.DO_NOTHING));
target.playSound(null, pos.x(), pos.y(), pos.z(), SoundEvents.ENDERMAN_TELEPORT,
SoundSource.NEUTRAL, 1.0F, 1.0F);
teleportPlayer(player, target, spawn);
return Command.SINGLE_SUCCESS;
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
return 0;
}
}
private static void teleportPlayer(ServerPlayer player, ServerLevel target, BlockPos spawn) {
Vec3 pos = new Vec3(spawn.getX() + 0.5, spawn.getY() + 1.0, spawn.getZ() + 0.5);
player.teleport(new TeleportTransition(target, pos, Vec3.ZERO, player.getYRot(), player.getXRot(),
TeleportTransition.DO_NOTHING));
target.playSound(null, pos.x(), pos.y(), pos.z(), SoundEvents.ENDERMAN_TELEPORT,
SoundSource.NEUTRAL, 1.0F, 1.0F);
}
// /craft : table de craft portable (wiki commandes).
private static int craft(CommandSourceStack source) {
try {
ServerPlayer player = source.getPlayerOrException();
player.openMenu(new net.minecraft.world.SimpleMenuProvider(
(syncId, inventory, p) -> new net.minecraft.world.inventory.CraftingMenu(syncId,
inventory),
Component.translatable("container.crafting")));
return Command.SINGLE_SUCCESS;
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
return 0;
}
}
// /spawn : tp au spawn overworld avec delai wiki 3 s (60 ticks). Pas d'annulation sur
// mouvement cote wiki (teleportation simple apres delai).
private static int spawn(CommandSourceStack source) {
try {
ServerPlayer player = source.getPlayerOrException();
MinecraftServer server = source.getServer();
SPAWN_QUEUE.put(player.getUUID(), (long) server.getTickCount() + 60L);
player.sendSystemMessage(
Component.literal("§6[Pala] §7Teleportation dans 3 secondes..."));
return Command.SINGLE_SUCCESS;
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
return 0;
}
}
private static void tickSpawnQueue(MinecraftServer server) {
if (SPAWN_QUEUE.isEmpty()) {
return;
}
int now = server.getTickCount();
java.util.Iterator<java.util.Map.Entry<java.util.UUID, Long>> it =
SPAWN_QUEUE.entrySet().iterator();
while (it.hasNext()) {
java.util.Map.Entry<java.util.UUID, Long> entry = it.next();
if (now < entry.getValue()) {
continue;
}
it.remove();
ServerPlayer player = server.getPlayerList().getPlayer(entry.getKey());
if (player == null) {
continue;
}
ServerLevel overworld = server.overworld();
teleportPlayer(player, overworld, overworld.getRespawnData().pos());
}
}
}
Binary file not shown.