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

@@ -19,11 +19,13 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
@@ -33,8 +35,6 @@ import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.entity.IEntityAdditionalSpawnData;
@@ -59,25 +59,36 @@ import org.jetbrains.annotations.Nullable;
* Forge to include the {@code IEntityAdditionalSpawnData} buffer in the spawn
* packet. Without this override, the entity would be invisible on clients.</p>
*/
public class EntityFurniture extends Entity
implements ISeatProvider, IEntityAdditionalSpawnData {
public class EntityFurniture
extends Entity
implements ISeatProvider, IEntityAdditionalSpawnData
{
// ========== SynchedEntityData Accessors ==========
/** The furniture definition ID (ResourceLocation string form). */
private static final EntityDataAccessor<String> FURNITURE_ID =
SynchedEntityData.defineId(EntityFurniture.class, EntityDataSerializers.STRING);
SynchedEntityData.defineId(
EntityFurniture.class,
EntityDataSerializers.STRING
);
/**
* Bitmask of locked seats. Bit N corresponds to seat index N
* in {@link FurnitureDefinition#seats()}. Max 8 seats per furniture.
*/
private static final EntityDataAccessor<Byte> SEAT_LOCK_BITS =
SynchedEntityData.defineId(EntityFurniture.class, EntityDataSerializers.BYTE);
SynchedEntityData.defineId(
EntityFurniture.class,
EntityDataSerializers.BYTE
);
/** Current animation state (idle, occupied, locking, struggle). */
private static final EntityDataAccessor<Byte> ANIM_STATE =
SynchedEntityData.defineId(EntityFurniture.class, EntityDataSerializers.BYTE);
SynchedEntityData.defineId(
EntityFurniture.class,
EntityDataSerializers.BYTE
);
// ========== Animation State Constants ==========
@@ -166,7 +177,10 @@ public class EntityFurniture extends Entity
public EntityDimensions getDimensions(Pose pose) {
FurnitureDefinition def = getDefinition();
if (def != null) {
return EntityDimensions.fixed(def.hitboxWidth(), def.hitboxHeight());
return EntityDimensions.fixed(
def.hitboxWidth(),
def.hitboxHeight()
);
}
return EntityDimensions.fixed(1.0f, 1.0f);
}
@@ -228,7 +242,9 @@ public class EntityFurniture extends Entity
if (locked) {
writeFurnitureReconnectionTag(serverPlayer, seatId);
} else {
serverPlayer.getPersistentData().remove("tiedup_locked_furniture");
serverPlayer
.getPersistentData()
.remove("tiedup_locked_furniture");
}
}
}
@@ -258,7 +274,10 @@ public class EntityFurniture extends Entity
* @param player the server player locked in this furniture
* @param seatId the seat ID the player is locked in
*/
private void writeFurnitureReconnectionTag(ServerPlayer player, String seatId) {
private void writeFurnitureReconnectionTag(
ServerPlayer player,
String seatId
) {
CompoundTag tag = new CompoundTag();
BlockPos pos = this.blockPosition();
tag.putInt("x", pos.getX());
@@ -311,13 +330,21 @@ public class EntityFurniture extends Entity
* by spacing seats evenly along the furniture's local right axis.</p>
*/
@Override
protected void positionRider(Entity passenger, Entity.MoveFunction moveFunction) {
protected void positionRider(
Entity passenger,
Entity.MoveFunction moveFunction
) {
if (!this.hasPassenger(passenger)) return;
SeatDefinition seat = getSeatForPassenger(passenger);
if (seat == null) {
// Fallback: center of entity at base height
moveFunction.accept(passenger, this.getX(), this.getY(), this.getZ());
moveFunction.accept(
passenger,
this.getX(),
this.getY(),
this.getZ()
);
return;
}
@@ -326,10 +353,13 @@ public class EntityFurniture extends Entity
if (this.level().isClientSide) {
FurnitureDefinition def = getDefinition();
if (def != null) {
double[] pos = com.tiedup.remake.v2.furniture.client.FurnitureSeatPositionHelper
.getSeatWorldPosition(
def, seat.id(),
this.getX(), this.getY(), this.getZ(),
double[] pos =
com.tiedup.remake.v2.furniture.client.FurnitureSeatPositionHelper.getSeatWorldPosition(
def,
seat.id(),
this.getX(),
this.getY(),
this.getZ(),
this.getYRot()
);
if (pos != null) {
@@ -349,7 +379,8 @@ public class EntityFurniture extends Entity
float yawRad = (float) Math.toRadians(this.getYRot());
double rightX = -Math.sin(yawRad + Math.PI / 2.0);
double rightZ = Math.cos(yawRad + Math.PI / 2.0);
double offset = seatCount == 1 ? 0.0 : (seatIdx - (seatCount - 1) / 2.0);
double offset =
seatCount == 1 ? 0.0 : (seatIdx - (seatCount - 1) / 2.0);
moveFunction.accept(
passenger,
@@ -464,7 +495,10 @@ public class EntityFurniture extends Entity
* @return the best matching seat, or null if no occupied lockable seats exist
*/
@Nullable
private SeatDefinition findNearestOccupiedLockableSeat(Player player, FurnitureDefinition def) {
private SeatDefinition findNearestOccupiedLockableSeat(
Player player,
FurnitureDefinition def
) {
Vec3 playerPos = player.getEyePosition();
Vec3 lookDir = player.getLookAngle();
float yawRad = (float) Math.toRadians(this.getYRot());
@@ -482,7 +516,9 @@ public class EntityFurniture extends Entity
SeatDefinition seat = seats.get(i);
// Only consider occupied, lockable seats
if (!seat.lockable() || !seatAssignments.containsValue(seat.id())) continue;
if (
!seat.lockable() || !seatAssignments.containsValue(seat.id())
) continue;
double offset = seatCount == 1 ? 0.0 : (i - (seatCount - 1) / 2.0);
Vec3 seatWorldPos = new Vec3(
@@ -533,9 +569,20 @@ public class EntityFurniture extends Entity
if (passenger instanceof ServerPlayer sp) {
FurnitureDefinition def = getDefinition();
if (def != null && def.feedback().deniedSound() != null) {
sp.level().playSound(null, sp.getX(), sp.getY(), sp.getZ(),
SoundEvent.createVariableRangeEvent(def.feedback().deniedSound()),
SoundSource.PLAYERS, 0.5f, 1.0f);
sp
.level()
.playSound(
null,
sp.getX(),
sp.getY(),
sp.getZ(),
SoundEvent.createVariableRangeEvent(
def.feedback().deniedSound()
),
SoundSource.PLAYERS,
0.5f,
1.0f
);
}
}
@@ -546,7 +593,11 @@ public class EntityFurniture extends Entity
String lockedSeatId = seat.id();
Entity self = this;
this.getServer().execute(() -> {
if (passenger.isAlive() && self.isAlive() && !self.isRemoved()) {
if (
passenger.isAlive() &&
self.isAlive() &&
!self.isRemoved()
) {
passenger.startRiding(self, true);
// Re-assign the specific seat (not just first available)
assignSeat(passenger, lockedSeatId);
@@ -575,7 +626,9 @@ public class EntityFurniture extends Entity
if (!this.level().isClientSide) {
this.entityData.set(ANIM_STATE, STATE_EXITING);
this.transitionTicksLeft = 20;
this.transitionTargetState = this.getPassengers().isEmpty() ? STATE_IDLE : STATE_OCCUPIED;
this.transitionTargetState = this.getPassengers().isEmpty()
? STATE_IDLE
: STATE_OCCUPIED;
}
// Client-side: immediately stop the furniture pose animation on the dismounting player.
@@ -583,8 +636,9 @@ public class EntityFurniture extends Entity
// The safety tick in AnimationTickHandler also catches this after a 3-tick grace period,
// but stopping immediately avoids a visible animation glitch during dismount.
if (this.level().isClientSide && passenger instanceof Player) {
com.tiedup.remake.client.animation.BondageAnimationManager
.stopFurniture((Player) passenger);
com.tiedup.remake.client.animation.BondageAnimationManager.stopFurniture(
(Player) passenger
);
}
}
@@ -598,7 +652,9 @@ public class EntityFurniture extends Entity
// Don't clobber active transitions — let the tick timer handle the reset
if (this.transitionTicksLeft > 0) return;
byte state = this.getPassengers().isEmpty() ? STATE_IDLE : STATE_OCCUPIED;
byte state = this.getPassengers().isEmpty()
? STATE_IDLE
: STATE_OCCUPIED;
this.entityData.set(ANIM_STATE, state);
}
@@ -628,11 +684,16 @@ public class EntityFurniture extends Entity
// Priority 1: Force-mount a leashed captive onto an available seat.
// The interacting player must be a captor with at least one leashed captive,
// and the captive must wear a collar owned by this player (or player is OP).
if (player instanceof ServerPlayer serverPlayer
&& this.getPassengers().size() < def.seats().size()) {
PlayerBindState ownerState = PlayerBindState.getInstance(serverPlayer);
if (
player instanceof ServerPlayer serverPlayer &&
this.getPassengers().size() < def.seats().size()
) {
PlayerBindState ownerState = PlayerBindState.getInstance(
serverPlayer
);
if (ownerState != null) {
PlayerCaptorManager captorManager = ownerState.getCaptorManager();
PlayerCaptorManager captorManager =
ownerState.getCaptorManager();
if (captorManager != null && captorManager.hasCaptives()) {
for (IBondageState captive : captorManager.getCaptives()) {
LivingEntity captiveEntity = captive.asLivingEntity();
@@ -647,11 +708,18 @@ public class EntityFurniture extends Entity
// Verify collar ownership
if (!captive.hasCollar()) continue;
ItemStack collarStack = captive.getEquipment(BodyRegionV2.NECK);
if (collarStack.isEmpty()
|| !(collarStack.getItem() instanceof ItemCollar collar)) continue;
if (!collar.isOwner(collarStack, serverPlayer)
&& !serverPlayer.hasPermissions(2)) continue;
ItemStack collarStack = captive.getEquipment(
BodyRegionV2.NECK
);
if (
collarStack.isEmpty() ||
!(collarStack.getItem() instanceof
ItemCollar collar)
) continue;
if (
!collar.isOwner(collarStack, serverPlayer) &&
!serverPlayer.hasPermissions(2)
) continue;
// Detach leash only (drop the lead, keep tied-up status)
captive.free(false);
@@ -662,10 +730,18 @@ public class EntityFurniture extends Entity
// Play mount sound
FurnitureFeedback feedback = def.feedback();
if (feedback.mountSound() != null) {
this.level().playSound(null,
this.getX(), this.getY(), this.getZ(),
SoundEvent.createVariableRangeEvent(feedback.mountSound()),
SoundSource.BLOCKS, 1.0f, 1.0f);
this.level().playSound(
null,
this.getX(),
this.getY(),
this.getZ(),
SoundEvent.createVariableRangeEvent(
feedback.mountSound()
),
SoundSource.BLOCKS,
1.0f,
1.0f
);
}
// Broadcast updated state to tracking clients
@@ -688,7 +764,10 @@ public class EntityFurniture extends Entity
// Use look direction to pick the nearest occupied, lockable seat.
ItemStack heldItem = player.getItemInHand(hand);
if (isKeyItem(heldItem) && !this.getPassengers().isEmpty()) {
SeatDefinition targetSeat = findNearestOccupiedLockableSeat(player, def);
SeatDefinition targetSeat = findNearestOccupiedLockableSeat(
player,
def
);
if (targetSeat != null) {
boolean wasLocked = isSeatLocked(targetSeat.id());
setSeatLocked(targetSeat.id(), !wasLocked);
@@ -699,15 +778,24 @@ public class EntityFurniture extends Entity
? feedback.unlockSound()
: feedback.lockSound();
if (soundRL != null) {
this.level().playSound(null, this.getX(), this.getY(), this.getZ(),
this.level().playSound(
null,
this.getX(),
this.getY(),
this.getZ(),
SoundEvent.createVariableRangeEvent(soundRL),
SoundSource.BLOCKS, 1.0f, 1.0f);
SoundSource.BLOCKS,
1.0f,
1.0f
);
}
// Set lock/unlock animation with transition timer
boolean nowLocked = !wasLocked;
this.entityData.set(ANIM_STATE,
nowLocked ? STATE_LOCKING : STATE_UNLOCKING);
this.entityData.set(
ANIM_STATE,
nowLocked ? STATE_LOCKING : STATE_UNLOCKING
);
this.transitionTicksLeft = 20;
this.transitionTargetState = STATE_OCCUPIED;
@@ -723,7 +811,10 @@ public class EntityFurniture extends Entity
}
// Priority 3: Empty hand + available seat -> self mount
if (heldItem.isEmpty() && this.getPassengers().size() < def.seats().size()) {
if (
heldItem.isEmpty() &&
this.getPassengers().size() < def.seats().size()
) {
player.startRiding(this);
return InteractionResult.CONSUME;
}
@@ -731,9 +822,16 @@ public class EntityFurniture extends Entity
// No valid action — play denied sound if configured
FurnitureFeedback feedback = def.feedback();
if (feedback != null && feedback.deniedSound() != null) {
this.level().playSound(null, this.getX(), this.getY(), this.getZ(),
this.level().playSound(
null,
this.getX(),
this.getY(),
this.getZ(),
SoundEvent.createVariableRangeEvent(feedback.deniedSound()),
SoundSource.BLOCKS, 0.5f, 1.0f);
SoundSource.BLOCKS,
0.5f,
1.0f
);
}
return InteractionResult.PASS;
@@ -775,10 +873,22 @@ public class EntityFurniture extends Entity
// Creative mode bypasses this check (handled above with instant discard).
if (!this.getPassengers().isEmpty()) {
FurnitureDefinition occupiedDef = getDefinition();
if (occupiedDef != null && occupiedDef.feedback().deniedSound() != null) {
this.level().playSound(null, this.getX(), this.getY(), this.getZ(),
SoundEvent.createVariableRangeEvent(occupiedDef.feedback().deniedSound()),
SoundSource.BLOCKS, 0.5f, 1.0f);
if (
occupiedDef != null &&
occupiedDef.feedback().deniedSound() != null
) {
this.level().playSound(
null,
this.getX(),
this.getY(),
this.getZ(),
SoundEvent.createVariableRangeEvent(
occupiedDef.feedback().deniedSound()
),
SoundSource.BLOCKS,
0.5f,
1.0f
);
}
return true; // Consume the attack but accumulate no damage
}
@@ -790,7 +900,9 @@ public class EntityFurniture extends Entity
if (this.currentDamage >= resistance) {
this.ejectPassengers();
if (def != null && def.dropOnBreak()) {
ItemStack dropStack = FurniturePlacerItem.createStack(def.id());
ItemStack dropStack = FurniturePlacerItem.createStack(
def.id()
);
if (!dropStack.isEmpty()) {
this.spawnAtLocation(dropStack);
}
@@ -850,9 +962,9 @@ public class EntityFurniture extends Entity
passengerUuids.add(passenger.getUUID());
}
boolean removed = seatAssignments.keySet().removeIf(
uuid -> !passengerUuids.contains(uuid)
);
boolean removed = seatAssignments
.keySet()
.removeIf(uuid -> !passengerUuids.contains(uuid));
if (removed) {
TiedUpMod.LOGGER.debug(
@@ -888,7 +1000,8 @@ public class EntityFurniture extends Entity
@Override
protected void readAdditionalSaveData(CompoundTag tag) {
if (tag.contains(FurnitureRegistry.NBT_FURNITURE_ID, 8)) { // 8 = TAG_String
if (tag.contains(FurnitureRegistry.NBT_FURNITURE_ID, 8)) {
// 8 = TAG_String
setFurnitureId(tag.getString(FurnitureRegistry.NBT_FURNITURE_ID));
}
if (tag.contains("facing")) {
@@ -909,7 +1022,8 @@ public class EntityFurniture extends Entity
// Restore seat assignments
seatAssignments.clear();
if (tag.contains("seat_assignments", 10)) { // 10 = TAG_Compound
if (tag.contains("seat_assignments", 10)) {
// 10 = TAG_Compound
CompoundTag assignments = tag.getCompound("seat_assignments");
for (String key : assignments.getAllKeys()) {
try {