});
icon.bindIcon(new ReadOnlyBinding<TextureRegion>() {
@Override
public TextureRegion get() {
if (getTargetItem().exists()) {
ItemComponent itemComp = getTargetItem().getComponent(ItemComponent.class);
if (itemComp != null && itemComp.icon != null) {
return itemComp.icon;
}
BlockItemComponent blockItemComp = getTargetItem().getComponent(BlockItemComponent.class);
if (blockItemComp == null || blockItemComp.blockFamily == null) {
return Assets.getTextureRegion("engine:items.questionMark");
}
}
return null;
}
});
icon.bindMesh(new ReadOnlyBinding<Mesh>() {
@Override
public Mesh get() {
BlockItemComponent blockItemComp = getTargetItem().getComponent(BlockItemComponent.class);
if (blockItemComp != null && blockItemComp.blockFamily != null) {
return blockItemComp.blockFamily.getArchetypeBlock().getMesh();
}
return null;
}
});
icon.setMeshTexture(Assets.getTexture("engine:terrain"));
icon.bindQuantity(new ReadOnlyBinding<Integer>() {
@Override
public Integer get() {
ItemComponent itemComp = getTargetItem().getComponent(ItemComponent.class);
if (itemComp != null) {
return UnsignedBytes.toInt(itemComp.stackCount);
}
return 1;
}