Search in sources :

Example 1 with SyncMaterialData

use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class OpenSynthesis method process.

@Override
public void process(EntityPlayer player, Side side) {
    PacketDispatcher.sendTo(new SyncMunnyData(player.getCapability(ModCapabilities.MUNNY, null)), (EntityPlayerMP) player);
    PacketDispatcher.sendTo(new SyncRecipeData(player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null)), (EntityPlayerMP) player);
    PacketDispatcher.sendTo(new SyncFreeDevRecipeData(player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null)), (EntityPlayerMP) player);
    PacketDispatcher.sendTo(new SyncMaterialData(player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null)), (EntityPlayerMP) player);
}
Also used : SyncRecipeData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncRecipeData) SyncFreeDevRecipeData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncFreeDevRecipeData) SyncMunnyData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMunnyData) SyncMaterialData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData)

Example 2 with SyncMaterialData

use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class CreateFromSynthesisRecipe method process.

@Override
public void process(EntityPlayer player, Side side) {
    boolean freeDev = false;
    if (FreeDevRecipeRegistry.isFreeDevRecipeRegistered(name)) {
        freeDev = true;
    }
    if (!freeDev) {
        if (RecipeRegistry.get(name).getResult().getItem() instanceof ItemKeychain)
            player.inventory.addItemStackToInventory(RecipeRegistry.get(name).getResult());
        Recipe r = RecipeRegistry.get(name);
        SynthesisMaterialCapability.ISynthesisMaterial MATS = player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null);
        Iterator it = r.getRequirements().entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<Material, Integer> pair = (Map.Entry<Material, Integer>) it.next();
            MATS.removeMaterial(pair.getKey(), pair.getValue());
        }
    } else {
        player.inventory.addItemStackToInventory(FreeDevRecipeRegistry.get(name).getResult());
        Recipe r = FreeDevRecipeRegistry.get(name);
        SynthesisMaterialCapability.ISynthesisMaterial MATS = player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null);
        Iterator it = r.getRequirements().entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<Material, Integer> pair = (Map.Entry<Material, Integer>) it.next();
            MATS.removeMaterial(pair.getKey(), pair.getValue());
        }
    }
    PacketDispatcher.sendTo(new SyncMaterialData(player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null)), (EntityPlayerMP) player);
}
Also used : SynthesisMaterialCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability) ItemKeychain(uk.co.wehavecookies56.kk.common.item.base.ItemKeychain) Recipe(uk.co.wehavecookies56.kk.api.recipes.Recipe) Iterator(java.util.Iterator) Material(uk.co.wehavecookies56.kk.api.materials.Material) Map(java.util.Map) SyncMaterialData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData)

Example 3 with SyncMaterialData

use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class DepositMaterialsFromBag method removeMaterial.

public void removeMaterial(IItemHandler bag, EntityPlayer player, int i) {
    for (int j = 0; j < bag.getSlots(); j++) {
        ItemStack bagItem = bag.getStackInSlot(j);
        if (!ItemStack.areItemStacksEqual(bagItem, ItemStack.EMPTY)) {
            if (bagItem.hasTagCompound()) {
                String s = bagItem.getTagCompound().getString("material");
                if (MaterialRegistry.isMaterialRegistered(s)) {
                    player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).addMaterial(MaterialRegistry.get(s), bag.getStackInSlot(j).getCount());
                }
                bag.extractItem(j, bag.getStackInSlot(j).getCount(), false);
            }
        } else if (MaterialRegistry.isMaterialRegistered(player.inventory.mainInventory.get(i).getItem().getUnlocalizedName())) {
            player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).addMaterial(MaterialRegistry.get(player.inventory.mainInventory.get(i).getItem().getUnlocalizedName()), player.inventory.mainInventory.get(i).getCount());
            player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
        }
        PacketDispatcher.sendTo(new SyncMaterialData(player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null)), (EntityPlayerMP) player);
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) SyncMaterialData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData)

Example 4 with SyncMaterialData

use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class OpenMaterials method process.

@Override
public void process(EntityPlayer player, Side side) {
    for (int i = 0; i < 36; i++) {
        if (!ItemStack.areItemStacksEqual(player.inventory.mainInventory.get(i), ItemStack.EMPTY)) {
            if (player.inventory.mainInventory.get(i).getItem() instanceof ItemSynthesisMaterial) {
                if (player.inventory.mainInventory.get(i).hasTagCompound()) {
                    String s = player.inventory.mainInventory.get(i).getTagCompound().getString("material");
                    if (MaterialRegistry.isMaterialRegistered(s)) {
                        player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).addMaterial(MaterialRegistry.get(s), player.inventory.mainInventory.get(i).getCount());
                    }
                    player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
                }
            } else if (MaterialRegistry.isMaterialRegistered(player.inventory.mainInventory.get(i).getItem().getUnlocalizedName().toString())) {
                player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).addMaterial(MaterialRegistry.get(player.inventory.mainInventory.get(i).getItem().getUnlocalizedName()), player.inventory.mainInventory.get(i).getCount());
                player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
            }
            PacketDispatcher.sendTo(new SyncMaterialData(player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null)), (EntityPlayerMP) player);
        }
    }
/*for (int i = 0; i < 36; i++)
            if (player.inventory.mainInventory[i] != null) if (player.inventory.mainInventory[i].getItem() instanceof ItemSynthesisMaterial) {
                if (player.inventory.mainInventory[i].hasTagCompound()) {
                    String s = player.inventory.mainInventory[i].getTagCompound().getString("material");
                    if (MaterialRegistry.isMaterialRegistered(s)) player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).addMaterial(MaterialRegistry.get(s), player.inventory.mainInventory[i].stackSize);
                    player.inventory.setInventorySlotContents(i, null);
                }

            } else if (MaterialRegistry.isMaterialRegistered(player.inventory.mainInventory[i].getItem().getUnlocalizedName().toString())) {
                player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).addMaterial(MaterialRegistry.get(player.inventory.mainInventory[i].getItem().getUnlocalizedName()), player.inventory.mainInventory[i].stackSize);
                player.inventory.setInventorySlotContents(i, null);
            }
        PacketDispatcher.sendTo(new SyncMaterialData(player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null)), (EntityPlayerMP) player);
        */
}
Also used : ItemSynthesisMaterial(uk.co.wehavecookies56.kk.common.item.base.ItemSynthesisMaterial) SyncMaterialData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData)

Example 5 with SyncMaterialData

use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class BlockSynthesisTable method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, ModSounds.kupo, SoundCategory.BLOCKS, 0.5F, 1.0F);
    if (world.isRemote)
        PacketDispatcher.sendToServer(new OpenSynthesis());
    player.openGui(KingdomKeys.instance, GuiIDs.GUI_SYNTHESISTABLE, world, pos.getX(), pos.getY(), pos.getZ());
    if (!world.isRemote) {
        PacketDispatcher.sendTo(new SyncRecipeData(player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null)), (EntityPlayerMP) player);
        PacketDispatcher.sendTo(new SyncFreeDevRecipeData(player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null)), (EntityPlayerMP) player);
        PacketDispatcher.sendTo(new SyncMaterialData(player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null)), (EntityPlayerMP) player);
    }
    return true;
}
Also used : SyncRecipeData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncRecipeData) SyncFreeDevRecipeData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncFreeDevRecipeData) OpenSynthesis(uk.co.wehavecookies56.kk.common.network.packet.server.OpenSynthesis) SyncMaterialData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData)

Aggregations

SyncMaterialData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData)6 ItemStack (net.minecraft.item.ItemStack)2 SyncFreeDevRecipeData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncFreeDevRecipeData)2 SyncRecipeData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncRecipeData)2 Iterator (java.util.Iterator)1 Map (java.util.Map)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 Material (uk.co.wehavecookies56.kk.api.materials.Material)1 Recipe (uk.co.wehavecookies56.kk.api.recipes.Recipe)1 SynthesisMaterialCapability (uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability)1 ItemKeychain (uk.co.wehavecookies56.kk.common.item.base.ItemKeychain)1 ItemSynthesisMaterial (uk.co.wehavecookies56.kk.common.item.base.ItemSynthesisMaterial)1 SyncMunnyData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncMunnyData)1 OpenSynthesis (uk.co.wehavecookies56.kk.common.network.packet.server.OpenSynthesis)1