Search in sources :

Example 1 with SpongeGuiId

use of org.spongepowered.common.data.type.SpongeGuiId in project SpongeCommon by SpongePowered.

the class CustomInventory method getGuiID.

@Override
public String getGuiID() {
    String key = AbstractInventoryProperty.getDefaultKey(GuiIdProperty.class).toString();
    InventoryProperty<?, ?> property = this.properties.get(key);
    if (property instanceof GuiIdProperty) {
        if (property.getValue() instanceof SpongeGuiId) {
            // Handle Vanilla EntityHorse GuiId
            return ((SpongeGuiId) property.getValue()).getInternalId();
        }
        return ((GuiIdProperty) property).getValue().getId();
    }
    GuiId guiId = this.archetype.getProperty(GuiIdProperty.class, key).map(GuiIdProperty::getValue).orElse(GuiIds.CHEST);
    if (guiId instanceof SpongeGuiId) {
        // Handle Vanilla EntityHorse GuiId
        return ((SpongeGuiId) guiId).getInternalId();
    }
    return guiId.getId();
}
Also used : GuiIdProperty(org.spongepowered.api.item.inventory.property.GuiIdProperty) SpongeGuiId(org.spongepowered.common.data.type.SpongeGuiId) SpongeGuiId(org.spongepowered.common.data.type.SpongeGuiId) GuiId(org.spongepowered.api.item.inventory.property.GuiId)

Aggregations

GuiId (org.spongepowered.api.item.inventory.property.GuiId)1 GuiIdProperty (org.spongepowered.api.item.inventory.property.GuiIdProperty)1 SpongeGuiId (org.spongepowered.common.data.type.SpongeGuiId)1