Remove internal phase comments and format code

Strip all Phase references, TODO/FUTURE roadmap notes, and internal
planning comments from the codebase. Run Prettier for consistent
formatting across all Java files.
This commit is contained in:
NotEvil
2026-04-12 01:24:49 +02:00
parent 73d70e212d
commit a71093ba9c
482 changed files with 8500 additions and 5155 deletions

View File

@@ -9,5 +9,5 @@ public enum NpcCommandType {
CANCEL_COMMAND,
SELECT_JOB,
CYCLE_FOLLOW_DISTANCE,
TOGGLE_AUTO_REST
TOGGLE_AUTO_REST,
}

View File

@@ -17,7 +17,6 @@ import com.tiedup.remake.personality.PersonalityState;
import com.tiedup.remake.v2.BodyRegionV2;
import java.util.UUID;
import java.util.function.Supplier;
import org.jetbrains.annotations.Nullable;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
@@ -25,6 +24,7 @@ import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.network.NetworkEvent;
import org.jetbrains.annotations.Nullable;
/**
* Unified C2S packet for all NPC command wand actions.
@@ -39,35 +39,82 @@ public class PacketNpcCommand {
private final NpcCommandType type;
// Optional fields depending on type
private final String commandName; // GIVE_COMMAND, SELECT_JOB
private final String commandName; // GIVE_COMMAND, SELECT_JOB
@Nullable
private final BlockPos targetPos; // GIVE_COMMAND only
private final boolean refreshScreen; // CYCLE_FOLLOW_DISTANCE, TOGGLE_AUTO_REST
private final BlockPos targetPos; // GIVE_COMMAND only
private final boolean refreshScreen; // CYCLE_FOLLOW_DISTANCE, TOGGLE_AUTO_REST
// --- Constructors for each command type ---
public static PacketNpcCommand giveCommand(UUID entityUUID, NpcCommand command, @Nullable BlockPos targetPos) {
return new PacketNpcCommand(entityUUID, NpcCommandType.GIVE_COMMAND, command.name(), targetPos, false);
public static PacketNpcCommand giveCommand(
UUID entityUUID,
NpcCommand command,
@Nullable BlockPos targetPos
) {
return new PacketNpcCommand(
entityUUID,
NpcCommandType.GIVE_COMMAND,
command.name(),
targetPos,
false
);
}
public static PacketNpcCommand cancelCommand(UUID entityUUID) {
return new PacketNpcCommand(entityUUID, NpcCommandType.CANCEL_COMMAND, "", null, false);
return new PacketNpcCommand(
entityUUID,
NpcCommandType.CANCEL_COMMAND,
"",
null,
false
);
}
public static PacketNpcCommand selectJob(UUID entityUUID, NpcCommand job) {
return new PacketNpcCommand(entityUUID, NpcCommandType.SELECT_JOB, job.name(), null, false);
return new PacketNpcCommand(
entityUUID,
NpcCommandType.SELECT_JOB,
job.name(),
null,
false
);
}
public static PacketNpcCommand cycleFollowDistance(UUID entityUUID, boolean refreshScreen) {
return new PacketNpcCommand(entityUUID, NpcCommandType.CYCLE_FOLLOW_DISTANCE, "", null, refreshScreen);
public static PacketNpcCommand cycleFollowDistance(
UUID entityUUID,
boolean refreshScreen
) {
return new PacketNpcCommand(
entityUUID,
NpcCommandType.CYCLE_FOLLOW_DISTANCE,
"",
null,
refreshScreen
);
}
public static PacketNpcCommand toggleAutoRest(UUID entityUUID, boolean refreshScreen) {
return new PacketNpcCommand(entityUUID, NpcCommandType.TOGGLE_AUTO_REST, "", null, refreshScreen);
public static PacketNpcCommand toggleAutoRest(
UUID entityUUID,
boolean refreshScreen
) {
return new PacketNpcCommand(
entityUUID,
NpcCommandType.TOGGLE_AUTO_REST,
"",
null,
refreshScreen
);
}
private PacketNpcCommand(UUID entityUUID, NpcCommandType type, String commandName,
@Nullable BlockPos targetPos, boolean refreshScreen) {
private PacketNpcCommand(
UUID entityUUID,
NpcCommandType type,
String commandName,
@Nullable BlockPos targetPos,
boolean refreshScreen
) {
this.entityUUID = entityUUID;
this.type = type;
this.commandName = commandName;
@@ -89,8 +136,11 @@ public class PacketNpcCommand {
}
}
case SELECT_JOB -> buf.writeUtf(commandName);
case CYCLE_FOLLOW_DISTANCE, TOGGLE_AUTO_REST -> buf.writeBoolean(refreshScreen);
case CANCEL_COMMAND -> {} // no extra data
case CYCLE_FOLLOW_DISTANCE, TOGGLE_AUTO_REST -> buf.writeBoolean(
refreshScreen
);
case CANCEL_COMMAND -> {
} // no extra data
}
}
@@ -109,19 +159,23 @@ public class PacketNpcCommand {
}
}
case SELECT_JOB -> cmd = buf.readUtf(32);
case CYCLE_FOLLOW_DISTANCE, TOGGLE_AUTO_REST -> refresh = buf.readBoolean();
case CANCEL_COMMAND -> {}
case CYCLE_FOLLOW_DISTANCE, TOGGLE_AUTO_REST -> refresh =
buf.readBoolean();
case CANCEL_COMMAND -> {
}
}
return new PacketNpcCommand(uuid, type, cmd, pos, refresh);
}
public void handle(Supplier<NetworkEvent.Context> ctx) {
ctx.get().enqueueWork(() -> {
ServerPlayer sender = ctx.get().getSender();
if (sender == null) return;
handleServer(sender);
});
ctx
.get()
.enqueueWork(() -> {
ServerPlayer sender = ctx.get().getSender();
if (sender == null) return;
handleServer(sender);
});
ctx.get().setPacketHandled(true);
}
@@ -130,17 +184,25 @@ public class PacketNpcCommand {
private void handleServer(ServerPlayer sender) {
if (!PacketRateLimiter.allowPacket(sender, "action")) return;
Entity entity = ((net.minecraft.server.level.ServerLevel) sender.level()).getEntity(entityUUID);
Entity entity = (
(net.minecraft.server.level.ServerLevel) sender.level()
).getEntity(entityUUID);
if (!(entity instanceof EntityDamsel damsel)) {
TiedUpMod.LOGGER.warn("[PacketNpcCommand:{}] Entity {} not found or not a Damsel",
type, entityUUID);
TiedUpMod.LOGGER.warn(
"[PacketNpcCommand:{}] Entity {} not found or not a Damsel",
type,
entityUUID
);
return;
}
double distance = sender.distanceTo(damsel);
if (distance > MAX_COMMAND_RANGE) {
SystemMessageManager.sendToPlayer(sender,
SystemMessageManager.MessageCategory.ERROR, "Target is too far away!");
SystemMessageManager.sendToPlayer(
sender,
SystemMessageManager.MessageCategory.ERROR,
"Target is too far away!"
);
return;
}
@@ -148,7 +210,10 @@ public class PacketNpcCommand {
case GIVE_COMMAND -> handleGiveCommand(sender, damsel);
case CANCEL_COMMAND -> handleCancelCommand(sender, damsel);
case SELECT_JOB -> handleSelectJob(sender, damsel);
case CYCLE_FOLLOW_DISTANCE -> handleCycleFollowDistance(sender, damsel);
case CYCLE_FOLLOW_DISTANCE -> handleCycleFollowDistance(
sender,
damsel
);
case TOGGLE_AUTO_REST -> handleToggleAutoRest(sender, damsel);
}
}
@@ -156,19 +221,32 @@ public class PacketNpcCommand {
private void handleGiveCommand(ServerPlayer sender, EntityDamsel damsel) {
NpcCommand command = NpcCommand.fromString(commandName);
if (command == NpcCommand.NONE && !"NONE".equals(commandName)) {
TiedUpMod.LOGGER.warn("[PacketNpcCommand:GIVE] Unknown command: {}", commandName);
TiedUpMod.LOGGER.warn(
"[PacketNpcCommand:GIVE] Unknown command: {}",
commandName
);
return;
}
boolean success = damsel.giveCommand(sender, command, targetPos);
String npcName = damsel.getNpcName();
if (success) {
EntityDialogueManager.talkTo(damsel, sender, DialogueCategory.COMMAND_ACCEPT);
SystemMessageManager.sendToPlayer(sender,
SystemMessageManager.MessageCategory.INFO,
npcName + " accepted command: " + command.name());
TiedUpMod.LOGGER.debug("[PacketNpcCommand:GIVE] {} gave command {} to {}",
sender.getName().getString(), command.name(), npcName);
EntityDialogueManager.talkTo(
damsel,
sender,
DialogueCategory.COMMAND_ACCEPT
);
SystemMessageManager.sendToPlayer(
sender,
SystemMessageManager.MessageCategory.INFO,
npcName + " accepted command: " + command.name()
);
TiedUpMod.LOGGER.debug(
"[PacketNpcCommand:GIVE] {} gave command {} to {}",
sender.getName().getString(),
command.name(),
npcName
);
}
}
@@ -177,16 +255,25 @@ public class PacketNpcCommand {
damsel.cancelCommand();
String npcName = damsel.getNpcName();
SystemMessageManager.sendToPlayer(sender,
SystemMessageManager.MessageCategory.INFO, npcName + "'s command cancelled.");
TiedUpMod.LOGGER.debug("[PacketNpcCommand:CANCEL] {} cancelled command for {}",
sender.getName().getString(), npcName);
SystemMessageManager.sendToPlayer(
sender,
SystemMessageManager.MessageCategory.INFO,
npcName + "'s command cancelled."
);
TiedUpMod.LOGGER.debug(
"[PacketNpcCommand:CANCEL] {} cancelled command for {}",
sender.getName().getString(),
npcName
);
}
private void handleSelectJob(ServerPlayer sender, EntityDamsel damsel) {
NpcCommand job = NpcCommand.fromString(commandName);
if (!job.isWorkCommand()) {
TiedUpMod.LOGGER.warn("[PacketNpcCommand:JOB] {} is not a work command", commandName);
TiedUpMod.LOGGER.warn(
"[PacketNpcCommand:JOB] {} is not a work command",
commandName
);
return;
}
@@ -195,7 +282,9 @@ public class PacketNpcCommand {
String npcName = damsel.getNpcName();
if (state.willObeyCommand(sender, job)) {
ItemStack mainHand = sender.getItemInHand(InteractionHand.MAIN_HAND);
ItemStack mainHand = sender.getItemInHand(
InteractionHand.MAIN_HAND
);
ItemStack offHand = sender.getItemInHand(InteractionHand.OFF_HAND);
ItemStack wand = null;
@@ -207,17 +296,32 @@ public class PacketNpcCommand {
if (wand != null) {
ItemCommandWand.enterSelectionMode(wand, damsel.getUUID(), job);
EntityDialogueManager.talkTo(damsel, sender, DialogueCategory.COMMAND_ACCEPT);
SystemMessageManager.sendToPlayer(sender,
SystemMessageManager.MessageCategory.INFO,
npcName + " is ready to " + job.name() + ". Click a chest to set work zone!");
TiedUpMod.LOGGER.debug("[PacketNpcCommand:JOB] {} accepted job {} - wand in selection mode",
npcName, job.name());
EntityDialogueManager.talkTo(
damsel,
sender,
DialogueCategory.COMMAND_ACCEPT
);
SystemMessageManager.sendToPlayer(
sender,
SystemMessageManager.MessageCategory.INFO,
npcName +
" is ready to " +
job.name() +
". Click a chest to set work zone!"
);
TiedUpMod.LOGGER.debug(
"[PacketNpcCommand:JOB] {} accepted job {} - wand in selection mode",
npcName,
job.name()
);
}
}
}
private void handleCycleFollowDistance(ServerPlayer sender, EntityDamsel damsel) {
private void handleCycleFollowDistance(
ServerPlayer sender,
EntityDamsel damsel
) {
if (!validateCollarOwnership(sender, damsel)) return;
PersonalityState state = damsel.getPersonalityState();
@@ -231,26 +335,39 @@ public class PacketNpcCommand {
};
state.setFollowDistance(next);
TiedUpMod.LOGGER.debug("[PacketNpcCommand:FOLLOW] {} changed {} follow distance to {}",
sender.getName().getString(), damsel.getNpcName(), next.name());
TiedUpMod.LOGGER.debug(
"[PacketNpcCommand:FOLLOW] {} changed {} follow distance to {}",
sender.getName().getString(),
damsel.getNpcName(),
next.name()
);
if (refreshScreen) {
sendRefreshedScreen(sender, damsel, state);
}
}
private void handleToggleAutoRest(ServerPlayer sender, EntityDamsel damsel) {
private void handleToggleAutoRest(
ServerPlayer sender,
EntityDamsel damsel
) {
if (!validateCollarOwnership(sender, damsel)) return;
PersonalityState state = damsel.getPersonalityState();
if (state == null) return;
boolean newState = state.toggleAutoRest();
TiedUpMod.LOGGER.debug("[PacketNpcCommand:REST] {} toggled {} auto-rest to {}",
sender.getName().getString(), damsel.getNpcName(), newState ? "ON" : "OFF");
SystemMessageManager.sendToPlayer(sender,
SystemMessageManager.MessageCategory.INFO,
"Auto-Rest: " + (newState ? "ON" : "OFF"));
TiedUpMod.LOGGER.debug(
"[PacketNpcCommand:REST] {} toggled {} auto-rest to {}",
sender.getName().getString(),
damsel.getNpcName(),
newState ? "ON" : "OFF"
);
SystemMessageManager.sendToPlayer(
sender,
SystemMessageManager.MessageCategory.INFO,
"Auto-Rest: " + (newState ? "ON" : "OFF")
);
if (refreshScreen) {
sendRefreshedScreen(sender, damsel, state);
@@ -259,11 +376,16 @@ public class PacketNpcCommand {
// --- Shared helpers ---
private boolean validateCollarOwnership(ServerPlayer sender, EntityDamsel damsel) {
private boolean validateCollarOwnership(
ServerPlayer sender,
EntityDamsel damsel
) {
if (!damsel.hasCollar()) {
SystemMessageManager.sendToPlayer(sender,
SystemMessageManager.MessageCategory.ERROR,
damsel.getNpcName() + " is not wearing a collar!");
SystemMessageManager.sendToPlayer(
sender,
SystemMessageManager.MessageCategory.ERROR,
damsel.getNpcName() + " is not wearing a collar!"
);
return false;
}
@@ -273,17 +395,22 @@ public class PacketNpcCommand {
}
if (!collarItem.getOwners(collar).contains(sender.getUUID())) {
SystemMessageManager.sendToPlayer(sender,
SystemMessageManager.MessageCategory.ERROR,
"You don't own " + damsel.getNpcName() + "'s collar!");
SystemMessageManager.sendToPlayer(
sender,
SystemMessageManager.MessageCategory.ERROR,
"You don't own " + damsel.getNpcName() + "'s collar!"
);
return false;
}
return true;
}
private static void sendRefreshedScreen(ServerPlayer sender, EntityDamsel damsel,
PersonalityState state) {
private static void sendRefreshedScreen(
ServerPlayer sender,
EntityDamsel damsel,
PersonalityState state
) {
NpcNeeds needs = state.getNeeds();
String homeType = state.getHomeType().name();
@@ -300,13 +427,24 @@ public class PacketNpcCommand {
}
ModNetwork.sendToPlayer(
new PacketOpenCommandWandScreen(
damsel.getUUID(), damsel.getNpcName(),
state.getPersonality().name(), activeCmd.name(),
needs.getHunger(), needs.getRest(), state.getMood(),
state.getFollowDistance().name(), homeType,
state.isAutoRestEnabled(), "", "",
activeJobLevelName, activeJobXp, activeJobXpMax),
sender);
new PacketOpenCommandWandScreen(
damsel.getUUID(),
damsel.getNpcName(),
state.getPersonality().name(),
activeCmd.name(),
needs.getHunger(),
needs.getRest(),
state.getMood(),
state.getFollowDistance().name(),
homeType,
state.isAutoRestEnabled(),
"",
"",
activeJobLevelName,
activeJobXp,
activeJobXpMax
),
sender
);
}
}

View File

@@ -1,9 +1,9 @@
package com.tiedup.remake.network.personality;
import com.tiedup.remake.core.TiedUpMod;
import com.tiedup.remake.v2.BodyRegionV2;
import com.tiedup.remake.entities.EntityDamsel;
import com.tiedup.remake.network.PacketRateLimiter;
import com.tiedup.remake.v2.BodyRegionV2;
import java.util.function.Supplier;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;

View File

@@ -14,7 +14,6 @@ import net.minecraftforge.network.NetworkEvent;
* Packet sent from server to client to alert an owner that someone
* is trying to free their slave.
*
* Phase 11: Multiplayer protection system
*/
public class PacketSlaveBeingFreed {