This commit is contained in:
luk
2026-02-04 03:12:15 +00:00
parent 49a80ebf77
commit ea0b747baf

View File

@@ -128,7 +128,7 @@ public class InteractionManager implements Component<EntityStore> {
assert this.commandBuffer != null;
Player playerComponent = this.commandBuffer.getComponent(ref, Player.getComponentType());
return playerComponent != null ? playerComponent.isWaitingForClientReady() : false;
return playerComponent != null && playerComponent.isWaitingForClientReady();
}
@Deprecated(forRemoval = true)
@@ -1250,33 +1250,35 @@ public class InteractionManager implements Component<EntityStore> {
this.tryRunHeldInteraction(ref, commandBuffer, type, (short) -1);
}
public void tryRunHeldInteraction(
@Nonnull Ref<EntityStore> ref, @Nonnull CommandBuffer<EntityStore> commandBuffer, @Nonnull InteractionType type, short equipSlot
) {
public void tryRunHeldInteraction(@Nonnull Ref<EntityStore> ref, @Nonnull CommandBuffer<EntityStore> commandBuffer, @Nonnull InteractionType type, short equipSlot) {
Inventory inventory = this.entity.getInventory();
ItemStack itemStack;
itemStack = switch (type) {
case Held -> inventory.getItemInHand();
case HeldOffhand -> inventory.getUtilityItem();
case Equipped -> {
switch (type) {
case Held:
itemStack = inventory.getItemInHand();
break;
case HeldOffhand:
itemStack = inventory.getUtilityItem();
break;
case Equipped:
if (equipSlot == -1) {
throw new IllegalArgumentException();
}
yield inventory.getArmor().getItemStack(equipSlot);
}
default -> throw new IllegalArgumentException();
};
itemStack = inventory.getArmor().getItemStack(equipSlot);
break;
default:
throw new IllegalArgumentException();
}
if (itemStack != null && !itemStack.isEmpty()) {
String rootId = itemStack.getItem().getInteractions().get(type);
if (rootId == null) {
return;
}
RootInteraction root = RootInteraction.getAssetMap().getAsset(rootId);
if (root != null && this.canRun(type, equipSlot, root)) {
InteractionContext context = InteractionContext.forInteraction(this, ref, type, equipSlot, commandBuffer);
this.startChain(ref, commandBuffer, type, context, root);
String rootId = (String) itemStack.getItem().getInteractions().get(type);
if (rootId != null) {
RootInteraction root = (RootInteraction) RootInteraction.getAssetMap().getAsset(rootId);
if (root != null && this.canRun(type, equipSlot, root)) {
InteractionContext context = InteractionContext.forInteraction(this, ref, type, equipSlot, commandBuffer);
this.startChain(ref, commandBuffer, type, context, root);
}
}
}
}