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