Search in sources :

Example 1 with EntityHired

use of kingdoms.server.entities.EntityHired in project Tale-of-Kingdoms by Ivasik78.

the class GuiHunter method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    switch(button.id) {
        case 1:
            this.player.addChatMessage(!HunterHandler.INSTANCE.getHunter() ? new ChatComponentTranslation("gui.guildMaster.killMobs") : new ChatComponentTranslation("gui.guildMaster.discarded"));
            this.player.addChatMessage(new ChatComponentTranslation("gui.guildMaster.await"));
            this.initGui();
            break;
        case 2:
            if (1500 <= playerProvider.getGoldTotal()) {
                EntityLiving entityLiving = (EntityLiving) UltimateHelper.INSTANCE.getEntity("Hired", world);
                entityLiving.setLocationAndAngles(this.player.posX, this.player.posY, this.player.posZ, 0.0F, 0.0F);
                this.world.spawnEntityInWorld(entityLiving);
                playerProvider.decreaseGold(1500);
            } else {
                this.goldchecker = true;
            }
            break;
        case 3:
            this.mc.displayGuiScreen(null);
            this.goldchecker = false;
            break;
        case 4:
            InventoryPlayer inventoryPlayer = this.player.inventory;
            boolean entity = false;
            if (inventoryPlayer.hasItem(Item.getItemFromBlock(Blocks.log))) {
                for (ItemStack stack : inventoryPlayer.mainInventory) {
                    if (stack != null && stack.getItem() == Item.getItemFromBlock(Blocks.log)) {
                        if (stack.stackSize == stack.getMaxStackSize() && !entity) {
                            inventoryPlayer.setItemStack(null);
                            entity = true;
                        }
                    }
                }
            }
            if (!entity) {
                if (!this.world.isRemote) {
                    this.player.addChatMessage(new ChatComponentTranslation("gui.guildMaster.needMore"));
                }
            } else if (!this.world.isRemote) {
                this.player.addChatMessage(new ChatComponentTranslation("gui.guildMaster.fixed"));
            }
            break;
        case 5:
            IntStream.range(0, this.world.loadedEntityList.size()).mapToObj(var7 -> (Entity) this.world.loadedEntityList.get(var7)).filter(entity1 -> entity1 instanceof EntityHired).map(entity1 -> (EntityHired) entity1).forEach(var9 -> {
                var9.setDead();
                playerProvider.addGold(1000);
            });
            break;
    }
}
Also used : IntStream(java.util.stream.IntStream) Entity(net.minecraft.entity.Entity) Side(cpw.mods.fml.relauncher.Side) SideOnly(cpw.mods.fml.relauncher.SideOnly) Blocks(net.minecraft.init.Blocks) GuiPriceBar(kingdoms.api.gui.GuiPriceBar) GuiButton(net.minecraft.client.gui.GuiButton) Item(net.minecraft.item.Item) World(net.minecraft.world.World) HunterHandler(kingdoms.server.handlers.resources.HunterHandler) InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) I18n(net.minecraft.client.resources.I18n) ItemStack(net.minecraft.item.ItemStack) GuiScreenToK(kingdoms.api.gui.GuiScreenToK) EntityLiving(net.minecraft.entity.EntityLiving) EntityPlayer(net.minecraft.entity.player.EntityPlayer) UltimateHelper(kingdoms.server.handlers.UltimateHelper) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) EntityHired(kingdoms.server.entities.EntityHired) InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) Entity(net.minecraft.entity.Entity) EntityLiving(net.minecraft.entity.EntityLiving) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) EntityHired(kingdoms.server.entities.EntityHired) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Side (cpw.mods.fml.relauncher.Side)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 IntStream (java.util.stream.IntStream)1 GuiPriceBar (kingdoms.api.gui.GuiPriceBar)1 GuiScreenToK (kingdoms.api.gui.GuiScreenToK)1 EntityHired (kingdoms.server.entities.EntityHired)1 UltimateHelper (kingdoms.server.handlers.UltimateHelper)1 HunterHandler (kingdoms.server.handlers.resources.HunterHandler)1 GuiButton (net.minecraft.client.gui.GuiButton)1 I18n (net.minecraft.client.resources.I18n)1 Entity (net.minecraft.entity.Entity)1 EntityLiving (net.minecraft.entity.EntityLiving)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)1 Blocks (net.minecraft.init.Blocks)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)1 World (net.minecraft.world.World)1