Search in sources :

Example 1 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project SecurityCraft by Geforce132.

the class BlockCageTrap method onEntityCollidedWithBlock.

public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) {
    if (par1World.isRemote) {
        return;
    } else {
        if (par5Entity instanceof EntityPlayer && !deactivated) {
            par1World.setBlock(par2, par3, par4, mod_SecurityCraft.deactivatedCageTrap);
            par1World.scheduleBlockUpdate(par2, par3, par4, mod_SecurityCraft.unbreakableIronBars, 1200);
            par1World.setBlock(par2, par3 + 4, par4, mod_SecurityCraft.unbreakableIronBars);
            par1World.scheduleBlockUpdate(par2, par3 + 4, par4, mod_SecurityCraft.unbreakableIronBars, 1200);
            par1World.setBlock(par2 + 1, par3 + 4, par4, mod_SecurityCraft.unbreakableIronBars);
            par1World.scheduleBlockUpdate(par2 + 1, par3 + 4, par4, mod_SecurityCraft.unbreakableIronBars, 1200);
            par1World.setBlock(par2 - 1, par3 + 4, par4, mod_SecurityCraft.unbreakableIronBars);
            par1World.scheduleBlockUpdate(par2 - 1, par3 + 4, par4, mod_SecurityCraft.unbreakableIronBars, 1200);
            par1World.setBlock(par2, par3 + 4, par4 + 1, mod_SecurityCraft.unbreakableIronBars);
            par1World.scheduleBlockUpdate(par2, par3 + 4, par4 + 1, mod_SecurityCraft.unbreakableIronBars, 1200);
            par1World.setBlock(par2, par3 + 4, par4 - 1, mod_SecurityCraft.unbreakableIronBars);
            par1World.scheduleBlockUpdate(par2, par3 + 4, par4 - 1, mod_SecurityCraft.unbreakableIronBars, 1200);
            HelpfulMethods.setBlockInBox(par1World, par2, par3, par4, mod_SecurityCraft.unbreakableIronBars);
            par1World.playSoundAtEntity(par5Entity, "random.anvil_use", 3.0F, 1.0F);
            // ChatMessageComponent.createFromText(((EntityPlayer) par5Entity).getCommandSenderName() + " was captured in a trap at" + HelpfulMethods.getFormattedCoordinates(par2, par3, par4))
            MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentTranslation(((EntityPlayer) par5Entity).getCommandSenderName() + " was captured in a trap at" + HelpfulMethods.getFormattedCoordinates(par2, par3, par4)));
        }
    }
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 2 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project SecurityCraft by Geforce132.

the class SCIRCBot method sendMessageToPlayer.

private void sendMessageToPlayer(String par1String, EntityPlayer par2EntityPlayer) {
    ChatComponentTranslation component = new ChatComponentTranslation(par1String, new Object[0]);
    par2EntityPlayer.addChatComponentMessage(component);
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation)

Example 3 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.

the class Connector method onItemUseFirst.

@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    Block block = world.getBlock(x, y, z);
    if (block == null)
        return false;
    if (!world.isRemote) {
        if (player.isSneaking()) {
            UUID uuid = player.getUniqueID();
            TileEntity tileEntity = world.getTileEntity(x, y, z);
            if (tileEntity instanceof TileEntityTransceiver) {
                TileEntityTransceiver railSender = (TileEntityTransceiver) tileEntity;
                if (tmpRails.containsKey(uuid)) {
                    tmpRails.remove(uuid);
                    if (player instanceof EntityPlayerMP)
                        player.addChatComponentMessage(new ChatComponentTranslation("info.signal.abort"));
                } else {
                    tmpRails.put(uuid, railSender);
                    if (player instanceof EntityPlayerMP)
                        player.addChatComponentMessage(new ChatComponentTranslation("info.signal.begin"));
                }
                return true;
            } else if (tileEntity instanceof TileEntityReceiver) {
                TileEntityReceiver railReceiver = (TileEntityReceiver) tileEntity;
                if (tmpRails.containsKey(uuid)) {
                    if (railReceiver.getSender() != tmpRails.get(uuid)) {
                        if (tmpRails.get(uuid).getTransceiver() == null) {
                            if (player instanceof EntityPlayerMP)
                                player.addChatComponentMessage(new ChatComponentTranslation("info.signal.error"));
                        } else {
                            railReceiver.setSender(tmpRails.get(uuid));
                            if (player instanceof EntityPlayerMP)
                                player.addChatComponentMessage(new ChatComponentTranslation("info.signal.connected"));
                            updateTileEntity(tmpRails.get(uuid));
                            updateTileEntity(railReceiver);
                        }
                        tmpRails.remove(uuid);
                    } else {
                        if (railReceiver.getSender() == tmpRails.get(uuid)) {
                            railReceiver.setSender(null);
                            if (player instanceof EntityPlayerMP)
                                player.addChatComponentMessage(new ChatComponentTranslation("info.signal.disconnected"));
                            updateTileEntity(tmpRails.get(uuid));
                            updateTileEntity(railReceiver);
                            tmpRails.remove(uuid);
                        }
                    }
                } else {
                    if (player instanceof EntityPlayerMP)
                        player.addChatComponentMessage(new ChatComponentTranslation("info.signal.error"));
                }
                return true;
            }
        } else {
            UUID uuid = player.getUniqueID();
            TileEntity tileEntity = world.getTileEntity(x, y, z);
            if (tileEntity instanceof TileEntityMultiSender) {
                TileEntityMultiSender sender = (TileEntityMultiSender) tileEntity;
                if (senderRails.containsKey(uuid)) {
                    if (senderRails.get(uuid) instanceof TileEntityMultiSender) {
                        if (senderRails.get(uuid) == sender) {
                            if (player instanceof EntityPlayerMP)
                                player.addChatComponentMessage(new ChatComponentTranslation("info.signal.abort"));
                        } else {
                            if (player instanceof EntityPlayerMP)
                                player.addChatComponentMessage(new ChatComponentTranslation("info.signal.error"));
                        }
                    } else {
                        if (sender.getTransceiver() == senderRails.get(uuid)) {
                            sender.getTransceiver().setTransceiver(null);
                            sender.setTransceiver(null);
                            if (player instanceof EntityPlayerMP)
                                player.addChatComponentMessage(new ChatComponentTranslation("info.signal.disconnected"));
                            updateTileEntity(senderRails.get(uuid));
                            updateTileEntity(sender);
                        } else {
                            sender.setTransceiver(senderRails.get(uuid));
                            sender.getTransceiver().setTransceiver(sender);
                            if (player instanceof EntityPlayerMP)
                                player.addChatComponentMessage(new ChatComponentTranslation("info.signal.connected"));
                            updateTileEntity(senderRails.get(uuid));
                            updateTileEntity(sender);
                        }
                    }
                    senderRails.remove(uuid);
                } else {
                    if (receiverRails.containsKey(uuid)) {
                        // Here is actuator to transceiver, 1 to 1
                        if (receiverRails.get(uuid) instanceof TileEntityActuator) {
                            TileEntityActuator actuator = (TileEntityActuator) receiverRails.get(uuid);
                            if (actuator.getTarget() != sender) {
                                actuator.setTarget(sender);
                                if (player instanceof EntityPlayerMP)
                                    player.addChatComponentMessage(new ChatComponentTranslation("info.signal.connected"));
                                updateTileEntity(actuator);
                                updateTileEntity(sender);
                            } else {
                                actuator.setTarget(null);
                                if (player instanceof EntityPlayerMP)
                                    player.addChatComponentMessage(new ChatComponentTranslation("info.signal.disconnected"));
                                updateTileEntity(actuator);
                                updateTileEntity(sender);
                            }
                        } else {
                            if (player instanceof EntityPlayerMP)
                                player.addChatComponentMessage(new ChatComponentTranslation("info.signal.error"));
                        }
                        receiverRails.remove(uuid);
                    } else {
                        senderRails.put(uuid, sender);
                        if (player instanceof EntityPlayerMP)
                            player.addChatComponentMessage(new ChatComponentTranslation("info.signal.begin"));
                    }
                }
                return true;
            } else if (tileEntity instanceof TileEntityTransceiver) {
                TileEntityTransceiver transceiver = (TileEntityTransceiver) tileEntity;
                if (senderRails.containsKey(uuid)) {
                    if (senderRails.get(uuid) instanceof TileEntityMultiSender) {
                        if (transceiver.getTransceiver() == senderRails.get(uuid)) {
                            transceiver.getTransceiver().setTransceiver(null);
                            transceiver.setTransceiver(null);
                            if (player instanceof EntityPlayerMP)
                                player.addChatComponentMessage(new ChatComponentTranslation("info.signal.disconnected"));
                            updateTileEntity(senderRails.get(uuid));
                            updateTileEntity(transceiver);
                        } else {
                            if (player instanceof EntityPlayerMP)
                                player.addChatComponentMessage(new ChatComponentTranslation("info.signal.error"));
                        }
                    } else {
                        // Here is blocking rail, link with 1n4148 instead of this item, it may be dangerous
                        if (player instanceof EntityPlayerMP)
                            player.addChatComponentMessage(new ChatComponentTranslation("info.signal.abort"));
                    }
                    senderRails.remove(uuid);
                } else {
                    senderRails.put(uuid, transceiver);
                    if (player instanceof EntityPlayerMP)
                        player.addChatComponentMessage(new ChatComponentTranslation("info.signal.begin"));
                }
                return true;
            } else if (tileEntity instanceof TileEntityReceiver) {
                TileEntityReceiver receiver = (TileEntityReceiver) tileEntity;
                if (senderRails.containsKey(uuid)) {
                    if (receiver.getSender() != senderRails.get(uuid)) {
                        receiver.setSender(senderRails.get(uuid));
                        if (senderRails.get(uuid) instanceof TileEntityMultiSender) {
                            ((TileEntityMultiSender) senderRails.get(uuid)).incTarget();
                        }
                        if (player instanceof EntityPlayerMP)
                            player.addChatComponentMessage(new ChatComponentTranslation("info.signal.connected"));
                        updateTileEntity(senderRails.get(uuid));
                        updateTileEntity(receiver);
                    } else {
                        receiver.setSender(null);
                        if (senderRails.get(uuid) instanceof TileEntityMultiSender) {
                            ((TileEntityMultiSender) senderRails.get(uuid)).decTarget();
                        }
                        if (player instanceof EntityPlayerMP)
                            player.addChatComponentMessage(new ChatComponentTranslation("info.signal.disconnected"));
                        updateTileEntity(senderRails.get(uuid));
                        updateTileEntity(receiver);
                    }
                    senderRails.remove(uuid);
                } else {
                    if (receiverRails.containsKey(uuid)) {
                        if (receiverRails.get(uuid) instanceof TileEntityActuator) {
                            TileEntityActuator actuator = (TileEntityActuator) receiverRails.get(uuid);
                            if (actuator == receiver) {
                                if (player instanceof EntityPlayerMP)
                                    player.addChatComponentMessage(new ChatComponentTranslation("info.signal.abort"));
                            } else if (actuator.getTarget() != receiver) {
                                actuator.setTarget(receiver);
                                if (player instanceof EntityPlayerMP)
                                    player.addChatComponentMessage(new ChatComponentTranslation("info.signal.connected"));
                                updateTileEntity(actuator);
                                updateTileEntity(receiver);
                            } else {
                                actuator.setTarget(null);
                                if (player instanceof EntityPlayerMP)
                                    player.addChatComponentMessage(new ChatComponentTranslation("info.signal.disconnected"));
                                updateTileEntity(actuator);
                                updateTileEntity(receiver);
                            }
                        } else if (receiver instanceof TileEntityActuator) {
                            if (((TileEntityActuator) receiver).getTarget() != receiverRails.get(uuid)) {
                                ((TileEntityActuator) receiver).setTarget(receiverRails.get(uuid));
                                if (player instanceof EntityPlayerMP)
                                    player.addChatComponentMessage(new ChatComponentTranslation("info.signal.connected"));
                                updateTileEntity(receiverRails.get(uuid));
                                updateTileEntity(receiver);
                            } else {
                                ((TileEntityActuator) receiver).setTarget(null);
                                if (player instanceof EntityPlayerMP)
                                    player.addChatComponentMessage(new ChatComponentTranslation("info.signal.disconnected"));
                                updateTileEntity(receiverRails.get(uuid));
                                updateTileEntity(receiver);
                            }
                        }
                        receiverRails.remove(uuid);
                    } else {
                        if (receiver instanceof TileEntityPassiveReceiver) {
                            if (player instanceof EntityPlayerMP)
                                player.addChatComponentMessage(new ChatComponentTranslation("info.signal.error"));
                        } else {
                            receiverRails.put(uuid, receiver);
                            if (player instanceof EntityPlayerMP)
                                player.addChatComponentMessage(new ChatComponentTranslation("info.signal.begin"));
                        }
                    }
                }
                return true;
            } else {
                onConnectorUseLast(player, uuid, tileEntity);
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityActuator(club.nsdn.nyasamatelecom.api.tileentity.TileEntityActuator) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) Block(net.minecraft.block.Block) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TileEntityReceiver(club.nsdn.nyasamatelecom.api.tileentity.TileEntityReceiver) UUID(java.util.UUID) TileEntityTransceiver(club.nsdn.nyasamatelecom.api.tileentity.TileEntityTransceiver)

Example 4 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.

the class DevEditor method onItemUseFirst.

@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    UUID uuid = player.getUniqueID();
    if (!world.isRemote) {
        if (tileEntity == null) {
            if (sender.containsKey(uuid))
                sender.remove(uuid);
            if (target.containsKey(uuid))
                target.remove(uuid);
            player.addChatComponentMessage(new ChatComponentTranslation("info.editor.clear"));
            return true;
        }
        if (player.isSneaking()) {
            if (!target.containsKey(uuid)) {
                if (tileEntity instanceof TileEntityActuator) {
                    target.put(uuid, ((TileEntityActuator) tileEntity).getTarget());
                    player.addChatComponentMessage(new ChatComponentTranslation("info.editor.copy.target"));
                } else {
                    player.addChatComponentMessage(new ChatComponentTranslation("info.editor.error"));
                }
            } else {
                if (tileEntity instanceof TileEntityActuator) {
                    ((TileEntityActuator) tileEntity).setTarget(target.get(uuid));
                    world.markBlockForUpdate(x, y, z);
                    player.addChatComponentMessage(new ChatComponentTranslation("info.editor.paste.target"));
                } else {
                    player.addChatComponentMessage(new ChatComponentTranslation("info.editor.error"));
                }
            }
        } else {
            if (!sender.containsKey(uuid)) {
                if (tileEntity instanceof TileEntityReceiver) {
                    sender.put(uuid, ((TileEntityReceiver) tileEntity).getSender());
                    player.addChatComponentMessage(new ChatComponentTranslation("info.editor.copy.sender"));
                } else {
                    player.addChatComponentMessage(new ChatComponentTranslation("info.editor.error"));
                }
            } else {
                if (tileEntity instanceof TileEntityReceiver) {
                    ((TileEntityReceiver) tileEntity).setSender(sender.get(uuid));
                    world.markBlockForUpdate(x, y, z);
                    player.addChatComponentMessage(new ChatComponentTranslation("info.editor.paste.sender"));
                } else {
                    player.addChatComponentMessage(new ChatComponentTranslation("info.editor.error"));
                }
            }
        }
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityActuator(club.nsdn.nyasamatelecom.api.tileentity.TileEntityActuator) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) TileEntityReceiver(club.nsdn.nyasamatelecom.api.tileentity.TileEntityReceiver) UUID(java.util.UUID)

Example 5 with ChatComponentTranslation

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

the class GuiWorker method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    switch(button.id) {
        case 1:
            this.player.addChatMessage(new ChatComponentTranslation("gui.worker.woodcut.go"));
            member.defaultHeldItem = new ItemStack(Items.iron_axe, 1);
            this.member.worktype = 1;
            this.member.follow = true;
            this.mc.displayGuiScreen(null);
            break;
        case 2:
            this.player.addChatMessage(new ChatComponentTranslation("gui.worker.mine.go"));
            member.defaultHeldItem = new ItemStack(Items.iron_pickaxe, 1);
            this.member.worktype = 2;
            this.member.follow = true;
            this.mc.displayGuiScreen(null);
            break;
        case 3:
            this.mc.displayGuiScreen(null);
            break;
    }
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ItemStack(net.minecraft.item.ItemStack)

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