net.minecraft.util.ChatComponentTranslation Java Examples

The following examples show how to use net.minecraft.util.ChatComponentTranslation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NEIServerUtils.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public static void givePlayerItem(EntityPlayerMP player, ItemStack stack, boolean infinite, boolean doGive) {
    if (stack.getItem() == null) {
        player.addChatComponentMessage(setColour(new ChatComponentTranslation("nei.chat.give.noitem"), EnumChatFormatting.WHITE));
        return;
    }

    int given = stack.stackSize;
    if(doGive) {
        if (infinite)
            player.inventory.addItemStackToInventory(stack);
        else
            given -= InventoryUtils.insertItem(player.inventory, stack, false);
    }

    sendNotice(player, new ChatComponentTranslation("commands.give.success", stack.getChatComponent(), infinite ? "\u221E" : Integer.toString(given), player.getCommandSenderName()), "notify-item");
    player.openContainer.detectAndSendChanges();
}
 
Example #2
Source File: config.java    From wailanbt with MIT License 6 votes vote down vote up
@SuppressWarnings("ResultOfMethodCallIgnored")
public static void init(File dir, EntityPlayer player) {
    configDir = new File(dir, Reference.MOD_ID);
    if (!configDir.exists()) {
        try {
            configDir.mkdir();
                File defaultFile = new File(configDir, "default.json");
                defaultFile.createNewFile();
                LogHelper.info("Empty config created");
            player.addChatMessage(new ChatComponentTranslation("wailanbt.info.CreateEmptyConfig"));

        } catch (Exception e) {
            LogHelper.info("Create config file failed");
            player.addChatMessage(new ChatComponentTranslation("wailanbt.info.FailCreateEmptyConfig"));
            e.printStackTrace();
        }
    }
    loadConfig(player);
}
 
Example #3
Source File: RenderItemPneumaticHelmet.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
public void render(){
    if(helmetModel == null) {
        helmetModel = AdvancedModelLoader.loadModel(Models.PNEUMATIC_HELMET);
        eyesModel = AdvancedModelLoader.loadModel(Models.PNEUMATIC_HELMET_EYES);
        faceModel = AdvancedModelLoader.loadModel(Models.PNEUMATIC_HELMET_FACE);
        if(!Config.useHelmetModel) {
            PneumaticCraft.proxy.getPlayer().addChatComponentMessage(new ChatComponentTranslation("message.date.ironman"));
        }
    }

    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glColor4d(1, 0.2, 0.2, 1);
    helmetModel.renderAll();
    GL11.glColor4d(1, 1, 0.7, 1);
    faceModel.renderAll();
    GL11.glColor4d(1, 1, 1, 1);
    GL11.glDisable(GL11.GL_CULL_FACE);
    eyesModel.renderAll();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
}
 
Example #4
Source File: PacketAmadronTradeAdd.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void handleServerSide(PacketAmadronTradeAdd message, EntityPlayer player){
    AmadronOfferCustom offer = message.getOffer();
    offer.updatePlayerId();
    if(AmadronOfferManager.getInstance().hasOffer(offer.copy().invert())) {
        player.addChatMessage(new ChatComponentTranslation("message.amadron.duplicateReversedOffer"));
    } else if(AmadronOfferManager.getInstance().addStaticOffer(offer)) {
        if(AmadronOfferSettings.notifyOfTradeAddition) NetworkHandler.sendToAll(message);
        try {
            AmadronOfferStaticConfig.INSTANCE.writeToFile();
        } catch(IOException e) {
            e.printStackTrace();
        }
    } else {
        player.addChatMessage(new ChatComponentTranslation("message.amadron.duplicateOffer"));
    }
}
 
Example #5
Source File: NEICPH.java    From NotEnoughItems with MIT License 6 votes vote down vote up
private void handleSMPCheck(int serverprotocol, String worldName, World world) {
    if (serverprotocol > NEIActions.protocol) {
        NEIClientUtils.printChatMessage(new ChatComponentTranslation("nei.chat.mismatch.client"));
    } else if (serverprotocol < NEIActions.protocol) {
        NEIClientUtils.printChatMessage(new ChatComponentTranslation("nei.chat.mismatch.server"));
    } else {
        try {
            ClientHandler.instance().loadWorld(world);
            NEIClientConfig.setHasSMPCounterPart(true);
            NEIClientConfig.loadWorld(getSaveName(worldName));
            sendRequestLoginInfo();
        } catch (Exception e) {
            NEIClientConfig.logger.error("Error handling SMP Check", e);
        }
    }
}
 
Example #6
Source File: NEIServerUtils.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public static void setGamemode(EntityPlayerMP player, int mode) {
    if (mode < 0 || mode >= NEIActions.gameModes.length ||
            NEIActions.nameActionMap.containsKey(NEIActions.gameModes[mode]) &&
                    !NEIServerConfig.canPlayerPerformAction(player.getCommandSenderName(), NEIActions.gameModes[mode]))
        return;

    //creative+
    NEIServerConfig.forPlayer(player.getCommandSenderName()).enableAction("creative+", mode == 2);
    if(mode == 2 && !(player.openContainer instanceof ContainerCreativeInv))//open the container immediately for the client
        NEISPH.processCreativeInv(player, true);

    //change it on the server
    player.theItemInWorldManager.setGameType(getGameType(mode));

    //tell the client to change it
    new PacketCustom(NEISPH.channel, 14).writeByte(mode).sendToPlayer(player);
    player.addChatMessage(new ChatComponentTranslation("nei.chat.gamemode." + mode));
}
 
Example #7
Source File: ItemAmadronTablet.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onItemUse(ItemStack tablet, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10){

    TileEntity te = world.getTileEntity(x, y, z);
    if(te instanceof IFluidHandler) {
        if(!world.isRemote) {
            setLiquidProvidingLocation(tablet, x, y, z, world.provider.dimensionId);
            player.addChatComponentMessage(new ChatComponentTranslation("message.amadronTable.setLiquidProvidingLocation", x, y, z, world.provider.dimensionId, world.provider.getDimensionName()));
        }
    } else if(te instanceof IInventory) {
        if(!world.isRemote) {
            setItemProvidingLocation(tablet, x, y, z, world.provider.dimensionId);
            player.addChatComponentMessage(new ChatComponentTranslation("message.amadronTable.setItemProvidingLocation", x, y, z, world.provider.dimensionId, world.provider.getDimensionName()));
        }
    } else {
        return false;
    }
    return true;

}
 
Example #8
Source File: BlockChunkLoader.java    From ChickenChunks with MIT License 6 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
    int meta = world.getBlockMetadata(x, y, z);
    if (meta != 0 || player.isSneaking())
        return false;

    if (!world.isRemote) {
        TileChunkLoader tile = (TileChunkLoader) world.getTileEntity(x, y, z);
        if (tile.owner == null || tile.owner.equals(player.getCommandSenderName()) ||
                ChunkLoaderManager.opInteract() && ServerUtils.isPlayerOP(player.getCommandSenderName())) {
            PacketCustom packet = new PacketCustom(ChunkLoaderSPH.channel, 12);
            packet.writeCoord(x, y, z);
            packet.sendToPlayer(player);
        } else
            player.addChatMessage(new ChatComponentTranslation("chickenchunks.accessdenied"));
    }
    return true;
}
 
Example #9
Source File: ItemBlockRemoteJar.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if(!world.isRemote) {
        if(player.isSneaking()) {
            NBTTagCompound compound = NBTHelper.getData(stack);
            if(compound.hasKey("networkId")) {
                compound.removeTag("networkId");

                if(compound.hasNoTags()) {
                    stack.setTagCompound(null);
                }

                player.addChatComponentMessage(new ChatComponentTranslation("gadomancy.info.RemoteJar.clear"));
            }
        }
    }

    return super.onItemRightClick(stack, world, player);
}
 
Example #10
Source File: ItemManometer.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean itemInteractionForEntity(ItemStack iStack, EntityPlayer player, EntityLivingBase entity){
    if(!player.worldObj.isRemote) {
        if(entity instanceof IManoMeasurable) {
            if(((IPressurizable)iStack.getItem()).getPressure(iStack) > 0F) {
                List<String> curInfo = new ArrayList<String>();
                ((IManoMeasurable)entity).printManometerMessage(player, curInfo);
                if(curInfo.size() > 0) {
                    ((IPressurizable)iStack.getItem()).addAir(iStack, -30);
                    for(String s : curInfo) {
                        player.addChatComponentMessage(new ChatComponentTranslation(s));
                    }
                    return true;
                }
            } else {
                player.addChatComponentMessage(new ChatComponentTranslation(EnumChatFormatting.RED + "The Manometer doesn't have any charge!"));
            }
        }
    }
    return false;
}
 
Example #11
Source File: BlockSecurityStation.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
    if(player.isSneaking()) return false;
    else {
        if(!world.isRemote) {
            TileEntitySecurityStation te = (TileEntitySecurityStation)world.getTileEntity(x, y, z);
            if(te != null) {
                if(te.isPlayerOnWhiteList(player)) {
                    player.openGui(PneumaticCraft.instance, EnumGuiId.SECURITY_STATION_INVENTORY.ordinal(), world, x, y, z);
                } else if(!te.hasValidNetwork()) {
                    player.addChatComponentMessage(new ChatComponentTranslation(EnumChatFormatting.GREEN + "This Security Station is out of order: Its network hasn't been properly configured."));
                } else if(te.hasPlayerHacked(player)) {
                    player.addChatComponentMessage(new ChatComponentTranslation(EnumChatFormatting.GREEN + "You've already hacked this Security Station!"));
                } else if(getPlayerHackLevel(player) < te.getSecurityLevel()) {
                    player.addChatComponentMessage(new ChatComponentTranslation(EnumChatFormatting.RED + "You can't access or hack this Security Station. To hack it you need at least a Pneumatic Helmet upgraded with " + te.getSecurityLevel() + " Security upgrade(s)."));
                } else {
                    player.openGui(PneumaticCraft.instance, EnumGuiId.HACKING.ordinal(), world, x, y, z);
                }
            }
        }
        return true;
    }
}
 
Example #12
Source File: TileEntitySecurityStation.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void handleGUIButtonPress(int buttonID, EntityPlayer player){
    if(buttonID == 0) {
        redstoneMode++;
        if(redstoneMode > 2) redstoneMode = 0;
        updateNeighbours();
    } else if(buttonID == 2) {
        rebootStation();
    } else if(buttonID == 3) {
        if(!hasValidNetwork()) {
            player.addChatComponentMessage(new ChatComponentTranslation(EnumChatFormatting.GREEN + "This Security Station is out of order: Its network hasn't been properly configured."));
        } else {
            player.openGui(PneumaticCraft.instance, EnumGuiId.HACKING.ordinal(), worldObj, xCoord, yCoord, zCoord);
        }
    } else if(buttonID > 3 && buttonID - 4 < sharedUsers.size()) {
        sharedUsers.remove(buttonID - 4);
    }
    sendDescriptionPacket();
}
 
Example #13
Source File: ItemRemote.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private boolean isAllowedToEdit(EntityPlayer player, ItemStack remote){
    NBTTagCompound tag = remote.getTagCompound();
    if(tag != null) {
        if(tag.hasKey("securityX")) {
            int x = tag.getInteger("securityX");
            int y = tag.getInteger("securityY");
            int z = tag.getInteger("securityZ");
            int dimensionId = tag.getInteger("securityDimension");
            WorldServer world = null;
            for(WorldServer w : MinecraftServer.getServer().worldServers) {
                if(w.provider.dimensionId == dimensionId) {
                    world = w;
                    break;
                }
            }
            if(world != null) {
                TileEntity te = world.getTileEntity(x, y, z);
                if(te instanceof TileEntitySecurityStation) {
                    boolean canAccess = ((TileEntitySecurityStation)te).doesAllowPlayer(player);
                    if(!canAccess) {
                        player.addChatComponentMessage(new ChatComponentTranslation("gui.remote.noEditRights", x, y, z));
                    }
                    return canAccess;
                }
            }
        }
    }
    return true;
}
 
Example #14
Source File: ItemSeismicSensor.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10){
    if(!world.isRemote) {
        int testingY = y;
        while(testingY > 0) {
            testingY--;
            if(world.getBlock(x, testingY, z) == FluidRegistry.getFluid(Fluids.oil.getName()).getBlock()) {
                Set<ChunkPosition> oilPositions = new HashSet<ChunkPosition>();
                Stack<ChunkPosition> pendingPositions = new Stack<ChunkPosition>();
                pendingPositions.add(new ChunkPosition(x, testingY, z));
                while(!pendingPositions.empty()) {
                    ChunkPosition checkingPos = pendingPositions.pop();
                    for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                        ChunkPosition newPos = new ChunkPosition(checkingPos.chunkPosX + d.offsetX, checkingPos.chunkPosY + d.offsetY, checkingPos.chunkPosZ + d.offsetZ);
                        if(world.getBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ) == Fluids.oil.getBlock() && world.getBlockMetadata(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ) == 0 && oilPositions.add(newPos)) {
                            pendingPositions.add(newPos);
                        }
                    }
                }
                player.addChatComponentMessage(new ChatComponentTranslation("message.seismicSensor.foundOilDetails", EnumChatFormatting.GREEN.toString() + (y - testingY), EnumChatFormatting.GREEN.toString() + oilPositions.size() / 10 * 10));
                return true;
            }
        }
        player.addChatComponentMessage(new ChatComponentTranslation("message.seismicSensor.noOilFound"));
    }
    return true; // we don't want to use the item.

}
 
Example #15
Source File: ItemGPSTool.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onItemUse(ItemStack IStack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10){
    setGPSLocation(IStack, x, y, z);
    if(!world.isRemote) player.addChatComponentMessage(new ChatComponentTranslation(EnumChatFormatting.GREEN + "[GPS Tool] Set Coordinates to " + x + ", " + y + ", " + z + "."));
    return true; // we don't want to use the item.

}
 
Example #16
Source File: CommandName.java    From wailanbt with MIT License 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] array) {
    EntityPlayer player = (EntityPlayer) sender;
    ItemStack holdItem = player.getHeldItem();
    if (holdItem == null) {
        player.addChatComponentMessage(new ChatComponentTranslation("wailanbt.info.NotHolding"));
        return;
    }
    player.addChatComponentMessage(new ChatComponentText(Item.itemRegistry.getNameForObject(holdItem.getItem())));
}
 
Example #17
Source File: DamageSourcePneumaticCraft.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the message to be displayed on player death.
 */
@Override
public IChatComponent func_151519_b(EntityLivingBase par1EntityLivingBase){
    String messageMeta = "";
    int messageNumber = par1EntityLivingBase.getRNG().nextInt(deathMessages) + 1;
    messageMeta = messageNumber + "";

    EntityLivingBase entitylivingbase1 = par1EntityLivingBase.func_94060_bK();
    String s = "death.attack." + damageType + messageMeta;
    String s1 = s + ".player";
    return entitylivingbase1 != null && StatCollector.canTranslate(s1) ? new ChatComponentTranslation(s1, new Object[]{par1EntityLivingBase.func_145748_c_(), entitylivingbase1.func_145748_c_()}) : new ChatComponentTranslation(s, new Object[]{par1EntityLivingBase.func_145748_c_()});
}
 
Example #18
Source File: ContainerAmadron.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean canInteractWith(EntityPlayer player){
    if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Itemss.amadronTablet) {
        IPressurizable pressurizable = (IPressurizable)Itemss.amadronTablet;
        pressurizable.addAir(player.getCurrentEquippedItem(), -1);
        if(pressurizable.getPressure(player.getCurrentEquippedItem()) > 0) return true;
        else {
            player.addChatMessage(new ChatComponentTranslation("gui.tab.problems.notEnoughPressure"));
        }
    }
    return false;
}
 
Example #19
Source File: CommandSetGlobalVariable.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args){
    if(args.length != 4) throw new WrongUsageException("command.deliverAmazon.args");
    String varName = args[0].startsWith("#") ? args[0].substring(1) : args[0];
    ChunkPosition newPos = new ChunkPosition(parseInt(sender, args[1]), parseInt(sender, args[2]), parseInt(sender, args[3]));
    GlobalVariableManager.getInstance().set(varName, newPos);
    sender.addChatMessage(new ChatComponentTranslation("command.setGlobalVariable.output", varName, newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ));
}
 
Example #20
Source File: EntityDrone.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onDeath(DamageSource par1DamageSource){
    for(int i = 0; i < inventory.getSizeInventory(); i++) {
        if(inventory.getStackInSlot(i) != null) {
            entityDropItem(inventory.getStackInSlot(i), 0);
            inventory.setInventorySlotContents(i, null);
        }
    }
    if(naturallySpawned) {

    } else {
        ItemStack drone = getDroppedStack();
        if(hasCustomNameTag()) drone.setStackDisplayName(getCustomNameTag());

        entityDropItem(drone, 0);

        if(!worldObj.isRemote) {
            EntityPlayer owner = getOwner();
            if(owner != null) {
                int x = (int)Math.floor(posX);
                int y = (int)Math.floor(posY);
                int z = (int)Math.floor(posZ);
                if(hasCustomNameTag()) {
                    owner.addChatComponentMessage(new ChatComponentTranslation("death.drone.named", getCustomNameTag(), x, y, z));
                } else {
                    owner.addChatComponentMessage(new ChatComponentTranslation("death.drone", x, y, z));
                }
            }
        }
    }
    if(!worldObj.isRemote) ((FakePlayerItemInWorldManager)getFakePlayer().theItemInWorldManager).cancelDigging();
    super.onDeath(par1DamageSource);
}
 
Example #21
Source File: GuiHelmetMainOptions.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void keyTyped(char ch, int key){
    if(changingKeybinding) {
        changingKeybinding = false;
        updateKeybindingButtonText();

        KeyHandler.getInstance().keybindOpenOptions.setKeyCode(key);
        KeyBinding.resetKeyBindingArrayAndHash();
        FMLClientHandler.instance().getClient().thePlayer.addChatComponentMessage(new ChatComponentTranslation(EnumChatFormatting.GREEN + "Bound the opening of this menu to the '" + Keyboard.getKeyName(key) + "' key."));
    }
}
 
Example #22
Source File: NetworkConnectionPlayerHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onSlotHack(int slot, boolean nuked){
    if(!nuked && gui instanceof GuiSecurityStationHacking) {
        ((GuiSecurityStationHacking)gui).onSlotHack(slot);
    }
    if(station.getStackInSlot(slot) != null && (station.getStackInSlot(slot).getItemDamage() == ItemNetworkComponents.NETWORK_REGISTRY || station.getStackInSlot(slot).getItemDamage() == ItemNetworkComponents.DIAGNOSTIC_SUBROUTINE)) {
        hackedSuccessfully = true;
        EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;
        NetworkHandler.sendToServer(new PacketSecurityStationAddHacker(station, player.getCommandSenderName()));
        FMLClientHandler.instance().getClient().thePlayer.closeScreen();
        player.addChatComponentMessage(new ChatComponentTranslation(EnumChatFormatting.GREEN + "Hacking successful! This Security Station now doesn't protect the area any longer!"));
        if(gui instanceof GuiSecurityStationHacking) ((GuiSecurityStationHacking)gui).removeUpdatesOnConnectionHandlers();
    }
}
 
Example #23
Source File: NetworkConnectionAIHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSlotHack(int slot, boolean nuked){
    if(!simulating && station.getStackInSlot(slot) != null && station.getStackInSlot(slot).getItemDamage() == ItemNetworkComponents.NETWORK_IO_PORT) {
        FMLClientHandler.instance().getClient().thePlayer.closeScreen();
        FMLClientHandler.instance().getClient().thePlayer.addChatComponentMessage(new ChatComponentTranslation(EnumChatFormatting.RED + "Hacking unsuccessful! The Diagnostic Subroutine traced to your location!"));
        if(gui instanceof GuiSecurityStationHacking) ((GuiSecurityStationHacking)gui).removeUpdatesOnConnectionHandlers();
    }
}
 
Example #24
Source File: ItemKeyboard.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
	if (world.isRemote) {
		final Optional<Long> terminalGuid = TerminalIdAccess.instance.getIdFrom(player);
		if (terminalGuid.isPresent()) {
			FMLCommonHandler.instance().showGuiScreen(new GuiCapture(terminalGuid.get()));
		} else {
			player.addChatMessage(new ChatComponentTranslation("openperipheral.misc.no_glasses"));
		}
	}

	return stack;
}
 
Example #25
Source File: CommandEntity.java    From wailanbt with MIT License 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] array) {
    EntityPlayer player = (EntityPlayer) sender;
    Minecraft minecraft = Minecraft.getMinecraft();
    MovingObjectPosition objectMouseOver = minecraft.objectMouseOver;
    if (objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY){
        Class pointEntityClass  = objectMouseOver.entityHit.getClass();
        if (EntityList.classToStringMapping.containsKey(pointEntityClass)){
         player.addChatComponentMessage(new ChatComponentText(EntityList.getEntityString(objectMouseOver.entityHit)));
        }
    }else{
        player.addChatComponentMessage(new ChatComponentTranslation("wailanbt.info.NotPointing"));
    }
}
 
Example #26
Source File: CommandItemName.java    From OmniOcular with Apache License 2.0 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] array) {
    EntityPlayer player = (EntityPlayer) sender;
    ItemStack holdItem = player.getHeldItem();
    if (holdItem == null) {
        player.addChatComponentMessage(new ChatComponentTranslation("omniocular.info.NotHolding"));
        return;
    }
    player.addChatComponentMessage(new ChatComponentText(Item.itemRegistry.getNameForObject(holdItem.getItem())));
}
 
Example #27
Source File: CommandEntityName.java    From OmniOcular with Apache License 2.0 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] array) {
    EntityPlayer player = (EntityPlayer) sender;
    Minecraft minecraft = Minecraft.getMinecraft();
    MovingObjectPosition objectMouseOver = minecraft.objectMouseOver;
    if (objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
        Class pointEntityClass = objectMouseOver.entityHit.getClass();
        if (EntityList.classToStringMapping.containsKey(pointEntityClass)) {
            player.addChatComponentMessage(new ChatComponentText(EntityList.getEntityString(objectMouseOver.entityHit)));
        }
    } else {
        player.addChatComponentMessage(new ChatComponentTranslation("omniocular.info.NotPointing"));
    }
}
 
Example #28
Source File: GuiItemIconDumper.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private void exportItems() throws IOException {
    BufferedImage img = screenshot();
    int rows = img.getHeight() / boxSize;
    int cols = img.getWidth() / boxSize;
    int fit = rows*cols;
    for(int i = 0; parseIndex < ItemPanel.items.size() && i < fit; parseIndex++, i++) {
        int x = i%cols * boxSize;
        int y = i/cols * boxSize;
        exportImage(dir, img.getSubimage(x+borderSize, y+borderSize, iconSize, iconSize), ItemPanel.items.get(parseIndex));
    }

    if(parseIndex >= ItemPanel.items.size())
        returnScreen(new ChatComponentTranslation(opt.fullName()+".icon.dumped", "dumps/itempanel_icons"));
}
 
Example #29
Source File: GuiItemIconDumper.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
protected void keyTyped(char c, int keycode) throws IOException {
    if (keycode == Keyboard.KEY_ESCAPE || keycode == Keyboard.KEY_BACK) {
        returnScreen(new ChatComponentTranslation(opt.fullName()+".icon.cancelled"));
        return;
    }
    super.keyTyped(c, keycode);
}
 
Example #30
Source File: BlockInfusionClaw.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
    if(!world.isRemote) {
        TileInfusionClaw tile = (TileInfusionClaw) world.getTileEntity(x, y, z);
        if(tile.hasOwner()) {
            player.openGui(Gadomancy.instance, 1, world, x, y, z);
        } else if(tile.setOwner(player)) {
            player.addChatComponentMessage(new ChatComponentTranslation("gadomancy.info.InfusionClaw.owner"));
        }
    }
    return true;
}