Search in sources :

Example 1 with ItemLootTableComponentTag

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

the class PacketSaveLootTableHandler method processServer.

@Override
public void processServer(PacketSaveLootTable 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.getComponent(), saveDir.isActive(), saveDir.getLevel());
    if (RCCommands.informSaveResult((message.getComponent() != 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 ItemLootTableComponentTag)
            ItemLootTableComponentTag.setComponentKey(heldItem, id);
        player.openContainer.detectAndSendChanges();
    }
}
Also used : ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) SaveDirectoryData(ivorius.reccomplex.utils.SaveDirectoryData) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemLootTableComponentTag(ivorius.reccomplex.item.ItemLootTableComponentTag) ItemStack(net.minecraft.item.ItemStack) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer)

Aggregations

ResourceDirectory (ivorius.reccomplex.files.loading.ResourceDirectory)1 ItemLootTableComponentTag (ivorius.reccomplex.item.ItemLootTableComponentTag)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