Search in sources :

Example 6 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project Tale-of-Kingdoms by Ivasik78.

the class GuiFoodKeeper method actionPerformed.

@Override
public void actionPerformed(GuiButton button) {
    switch(button.id) {
        case 1:
            if (this.freeBread) {
                this.mc.displayGuiScreen(null);
                NetworkHandler.INSTANCE.sendToServer(new SPacketAdd(new ItemStack(Items.bread), 1, "gui.farmer.take"));
                this.freeBread = false;
            } else if (!this.world.isRemote) {
                this.player.addChatMessage(new ChatComponentTranslation("gui.farmer.have"));
            }
            break;
        case 2:
            this.mc.displayGuiScreen(null);
            break;
    }
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ItemStack(net.minecraft.item.ItemStack) SPacketAdd(kingdoms.server.handlers.packets.server.SPacketAdd)

Example 7 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project Tale-of-Kingdoms by Ivasik78.

the class GuiLumber method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    switch(button.id) {
        case 1:
            if (ResourcesHandler.INSTANCE.getWoodPool() >= 64) {
                this.world.spawnEntityInWorld(new EntityItem(this.world, this.player.posX, this.player.posY, this.player.posZ, new ItemStack(Item.getItemFromBlock(Blocks.log), 64)));
                this.goldchecker = false;
                ResourcesHandler.INSTANCE.decreaseWoodPool(64);
            } else {
                this.player.addChatMessage(new ChatComponentTranslation("gui.foreman.notResources"));
            }
            break;
        case 2:
            if (playerProvider.getGoldTotal() >= 1500) {
                if (WorkersHandler.INSTANCE.getLumberMembers() < 12) {
                    WorkersHandler.INSTANCE.addLumberMember((byte) 1);
                    playerProvider.decreaseGold(1500);
                    this.player.addChatMessage(new ChatComponentTranslation("gui.foreman.boughtWorker"));
                } else {
                    this.player.addChatMessage(new ChatComponentTranslation("gui.foreman.limitWorkers"));
                }
            } else {
                this.goldchecker = true;
            }
            break;
        case 3:
            this.mc.displayGuiScreen(null);
            break;
    }
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 8 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project Tale-of-Kingdoms by Ivasik78.

the class GuiMageHall method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    switch(button.id) {
        case 1:
            ItemStack var9 = this.player.inventory.getCurrentItem();
            if (500 <= playerProvider.getGoldTotal() && var9 != null) {
                final Random random = new Random();
                int[] ai = new int[3];
                int k;
                for (k = 0; k < 3; ++k) {
                    ai[k] = EnchantmentHelper.calcItemStackEnchantability(random, k, 30, var9);
                }
                k = random.nextInt(3);
                List list1 = EnchantmentHelper.buildEnchantmentList(random, var9, ai[k]);
                if (list1 != null) {
                    for (Object aList1 : list1) {
                        EnchantmentData enchantmentdata = (EnchantmentData) aList1;
                        var9.addEnchantment(enchantmentdata.enchantmentobj, enchantmentdata.enchantmentLevel);
                    }
                    playerProvider.decreaseGold(500);
                    this.player.addChatMessage(new ChatComponentTranslation("gui.mage.enchanted", var9.getDisplayName()));
                } else if (!this.world.isRemote) {
                    this.player.addChatMessage(new ChatComponentTranslation("gui.mage.dontEnchant"));
                }
            } else {
                this.goldchecker = true;
            }
            break;
        case 2:
            if (2000 <= playerProvider.getGoldTotal()) {
                // NetworkHandler.INSTANCE.sendToServer(new SPacketSpawnEntity("DefendMage"));
                playerProvider.decreaseGold(2000);
            } else {
                this.goldchecker = true;
            }
            break;
        case 3:
            this.mc.displayGuiScreen(null);
            this.goldchecker = false;
            break;
    }
}
Also used : Random(java.util.Random) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) EnchantmentData(net.minecraft.enchantment.EnchantmentData)

Example 9 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project Tale-of-Kingdoms by Ivasik78.

the class EntityQuarry method interact.

@Override
public boolean interact(EntityPlayer player) {
    if (this.canInteractWith(player)) {
        if (!this.worldObj.isRemote) {
            this.heal(100.0F);
            player.addChatMessage(new ChatComponentTranslation("npc.foreman.dialog"));
        }
        player.openGui(TaleOfKingdoms.instance, GUI_QUARRY, worldObj, 0, 0, 0);
    }
    return true;
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation)

Example 10 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project Tale-of-Kingdoms by Ivasik78.

the class EntitySantaClaus method onDeath.

@Override
public void onDeath(DamageSource damageSource) {
    if (!worldObj.isRemote) {
        if (damageSource.getSourceOfDamage() instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) damageSource.getEntity();
            player.addChatMessage(new ChatComponentTranslation("npc.santa.badKid.dialog"));
            player.dropItem(Items.coal, worldObj.rand.nextInt(32));
            PlayerProvider.get(player).badKid = true;
            IntStream.range(1, rand.nextInt(5)).mapToObj(i -> new EntitySnowman(worldObj)).forEach(golem -> {
                golem.setLocationAndAngles(this.posX, this.posY, this.posZ, 0.0F, 0.0F);
                golem.setAttackTarget(player);
                worldObj.spawnEntityInWorld(golem);
            });
        }
    }
}
Also used : IntStream(java.util.stream.IntStream) Entity(net.minecraft.entity.Entity) Blocks(net.minecraft.init.Blocks) MathHelper(net.minecraft.util.MathHelper) PlayerProvider(kingdoms.server.PlayerProvider) Items(net.minecraft.init.Items) Item(net.minecraft.item.Item) World(net.minecraft.world.World) Date(java.util.Date) EntityNPC(kingdoms.api.entities.EntityNPC) DamageSource(net.minecraft.util.DamageSource) TileEntityChest(net.minecraft.tileentity.TileEntityChest) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) List(java.util.List) Calendar(java.util.Calendar) Material(net.minecraft.block.material.Material) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntitySnowman(net.minecraft.entity.monster.EntitySnowman) TileEntity(net.minecraft.tileentity.TileEntity) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) EntitySnowman(net.minecraft.entity.monster.EntitySnowman) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)77 ItemStack (net.minecraft.item.ItemStack)19 EntityPlayer (net.minecraft.entity.player.EntityPlayer)13 TileEntity (net.minecraft.tileentity.TileEntity)13 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)11 ArrayList (java.util.ArrayList)5 Block (net.minecraft.block.Block)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 World (net.minecraft.world.World)4 Item1N4148 (club.nsdn.nyasamarailway.item.tool.Item1N4148)3 ItemNTP32Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit)3 ItemNTP8Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit)3 TrainPacket (club.nsdn.nyasamarailway.network.TrainPacket)3 TileEntityActuator (club.nsdn.nyasamatelecom.api.tileentity.TileEntityActuator)3 EntityItem (net.minecraft.entity.item.EntityItem)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 TileEntityRailSniffer (club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailSniffer)2 TileEntityReceiver (club.nsdn.nyasamatelecom.api.tileentity.TileEntityReceiver)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 Side (cpw.mods.fml.relauncher.Side)2