Search in sources :

Example 1 with ItemInventoryGenComponentTag

use of ivorius.reccomplex.item.ItemInventoryGenComponentTag in project RecurrentComplex by Ivorforce.

the class PacketSaveInvGenComponentHandler method processServer.

@Override
public void processServer(PacketSaveInvGenComponent message, MessageContext ctx, WorldServer server) {
    NetHandlerPlayServer playServer = ctx.getServerHandler();
    EntityPlayerMP player = playServer.player;
    if (RecurrentComplex.checkPerms(player))
        return;
    SaveDirectoryData.Result saveDirectoryDataResult = message.getSaveDirectoryDataResult();
    String id = message.getKey();
    ResourceDirectory saveDir = saveDirectoryDataResult.directory;
    ResourceDirectory delDir = saveDir.opposite();
    GenericItemCollectionRegistry.INSTANCE.register(id, "", message.getInventoryGenerator(), saveDir.isActive(), saveDir.getLevel());
    if (RCCommands.informSaveResult((message.getInventoryGenerator() != null && id != null) && RecurrentComplex.saver.trySave(saveDir.toPath(), RCFileSaver.INVENTORY_GENERATION_COMPONENT, id), player, saveDir, RCFileSaver.INVENTORY_GENERATION_COMPONENT, id)) {
        if (saveDirectoryDataResult.deleteOther)
            RCCommands.informDeleteResult(RecurrentComplex.saver.tryDeleteWithID(delDir.toPath(), RCFileSaver.INVENTORY_GENERATION_COMPONENT, id), player, RCFileSaver.INVENTORY_GENERATION_COMPONENT, id, delDir);
        ItemStack heldItem = playServer.player.getHeldItem(EnumHand.MAIN_HAND);
        if (heldItem != null && heldItem.getItem() instanceof ItemInventoryGenComponentTag)
            ItemInventoryGenComponentTag.setComponentKey(heldItem, id);
        player.openContainer.detectAndSendChanges();
    }
}
Also used : ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) SaveDirectoryData(ivorius.reccomplex.utils.SaveDirectoryData) ItemInventoryGenComponentTag(ivorius.reccomplex.item.ItemInventoryGenComponentTag) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer)

Aggregations

ResourceDirectory (ivorius.reccomplex.files.loading.ResourceDirectory)1 ItemInventoryGenComponentTag (ivorius.reccomplex.item.ItemInventoryGenComponentTag)1 SaveDirectoryData (ivorius.reccomplex.utils.SaveDirectoryData)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 ItemStack (net.minecraft.item.ItemStack)1 NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)1