Search in sources :

Example 1 with Component

use of ivorius.reccomplex.world.storage.loot.GenericItemCollection.Component in project RecurrentComplex by Ivorforce.

the class RCGuiHandler method openComponentGui.

protected static void openComponentGui(EntityPlayer player, String key, Component component, SaveDirectoryData saveDirectoryData, int guiID) {
    if (key == null)
        key = "New Generator";
    if (component == null)
        component = Component.createDefaultComponent();
    if (saveDirectoryData == null) {
        SimpleLeveledRegistry<Component>.Status<Component> status = GenericItemCollectionRegistry.INSTANCE.status(key);
        saveDirectoryData = SaveDirectoryData.defaultData(key, status != null && status.isActive(), RecurrentComplex.loader.tryFindIDs(ResourceDirectory.ACTIVE.toPath(), RCFileSuffix.INVENTORY_GENERATION_COMPONENT), RecurrentComplex.loader.tryFindIDs(ResourceDirectory.INACTIVE.toPath(), RCFileSuffix.INVENTORY_GENERATION_COMPONENT));
    }
    ByteBuf buf = Unpooled.buffer();
    ByteBufUtils.writeUTF8String(buf, key);
    ItemCollectionSaveHandler.INSTANCE.write(buf, component);
    saveDirectoryData.writeTo(buf);
    IvGuiRegistry.INSTANCE.openGui(player, RecurrentComplex.MOD_ID, guiID, buf);
}
Also used : Component(ivorius.reccomplex.world.storage.loot.GenericItemCollection.Component) ByteBuf(io.netty.buffer.ByteBuf) SimpleLeveledRegistry(ivorius.reccomplex.files.SimpleLeveledRegistry)

Example 2 with Component

use of ivorius.reccomplex.world.storage.loot.GenericItemCollection.Component in project RecurrentComplex by Ivorforce.

the class ItemInventoryGenComponentTag method addInformation.

@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean advancedInformation) {
    super.addInformation(stack, player, list, advancedInformation);
    Component component = component(stack);
    if (component != null) {
        list.add(component.inventoryGeneratorID);
        list.add(GenericItemCollectionRegistry.INSTANCE.hasActive(componentKey(stack)) ? IvTranslations.format("inventoryGen.active", TextFormatting.GREEN, TextFormatting.RESET) : IvTranslations.format("inventoryGen.inactive", TextFormatting.RED, TextFormatting.RESET));
    } else
        list.add(IvTranslations.get("inventoryGen.create"));
}
Also used : Component(ivorius.reccomplex.world.storage.loot.GenericItemCollection.Component)

Example 3 with Component

use of ivorius.reccomplex.world.storage.loot.GenericItemCollection.Component in project RecurrentComplex by Ivorforce.

the class RCGuiHandler method getClientGuiElement.

@Override
public Object getClientGuiElement(int id, EntityPlayer player, ByteBuf data) {
    if (id == editInventoryGen || id == editInventoryGenItems) {
        String key = ByteBufUtils.readUTF8String(data);
        Component component = ItemCollectionSaveHandler.INSTANCE.read(data);
        SaveDirectoryData saveDirectoryData = SaveDirectoryData.readFrom(data);
        if (component != null) {
            if (id == editInventoryGen)
                return new GuiEditInventoryGen(player, component, key, saveDirectoryData);
            else
                return new GuiEditInventoryGenItems(player, component, key, saveDirectoryData);
        }
    }
    return null;
}
Also used : GuiEditInventoryGen(ivorius.reccomplex.gui.inventorygen.GuiEditInventoryGen) SaveDirectoryData(ivorius.reccomplex.utils.SaveDirectoryData) GuiEditInventoryGenItems(ivorius.reccomplex.gui.inventorygen.GuiEditInventoryGenItems) Component(ivorius.reccomplex.world.storage.loot.GenericItemCollection.Component)

Aggregations

Component (ivorius.reccomplex.world.storage.loot.GenericItemCollection.Component)3 ByteBuf (io.netty.buffer.ByteBuf)1 SimpleLeveledRegistry (ivorius.reccomplex.files.SimpleLeveledRegistry)1 GuiEditInventoryGen (ivorius.reccomplex.gui.inventorygen.GuiEditInventoryGen)1 GuiEditInventoryGenItems (ivorius.reccomplex.gui.inventorygen.GuiEditInventoryGenItems)1 SaveDirectoryData (ivorius.reccomplex.utils.SaveDirectoryData)1