net.minecraft.util.StatCollector Java Examples

The following examples show how to use net.minecraft.util.StatCollector. 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: GuiAutoChisel.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
	super.drawGuiContainerForegroundLayer(mouseX, mouseY);

	int x = (this.width - this.xSize) / 2;
	int y = (this.height - this.ySize) / 2;

	for (Slot slot : (List<Slot>) inventorySlots.inventorySlots) {
		if (!slot.getHasStack() && mouseInside(slot, mouseX - x, mouseY - y)) {
			if (slot.slotNumber < autochisel.getSizeInventory()) {
				String tt = autochisel.getSlotTooltipUnloc(slot.slotNumber);
				if (!Strings.isNullOrEmpty(tt)) {
					this.func_146283_a(Lists.newArrayList(StatCollector.translateToLocal(tt)), mouseX - x, mouseY - y);
				}
			}
		}
	}
	RenderHelper.enableGUIStandardItemLighting();
}
 
Example #2
Source File: GT_TileEntity_VoidMiner_Base.java    From bartworks with MIT License 6 votes vote down vote up
@Override
public String[] getDescription() {
    String casingName = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(this.getCasingBlockItem().get(1L)));
    return new String[]{"Controller Block for the Void Miner "+ GT_Values.VN[this.getMinTier()],
            "Size(WxHxD): 3x7x3",
            "Controller (Front middle at bottom)",
            "3x1x3 Base of " + casingName,
            "1x3x1 " + casingName + " pillar (Center of base)",
            "1x3x1 " + this.getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)",
            "1x Output Bus (One of base casings)",
            "Optional: 0+ Input Hatch (One of base casings)",
            "1x Maintenance Hatch (One of base casings)",
            "1x " + GT_Values.VN[this.getMinTier()] + "+ Energy Hatch (Any bottom layer casing)",
            "Consumes " + GT_Values.V[this.getMinTier()] + "EU/t",
            "Can be supplied with 2L/s of Neon(x4), Krypton(x8), Xenon(x16) or Oganesson(x64)",
            "for higher outputs.",
            "Will output "+(2*TIER_MULTIPLIER)+" Ores per Second depending on the Dimension it is build in",
            StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"
    };
}
 
Example #3
Source File: GT_TileEntity_MegaBlastFurnace.java    From bartworks with MIT License 6 votes vote down vote up
public String[] getInfoData() {
    int mPollutionReduction = 0;

    for (GT_MetaTileEntity_Hatch_Muffler e : this.mMufflerHatches)
        if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(e))
            mPollutionReduction = Math.max(e.calculatePollutionReduction(this.mPollution), mPollutionReduction);

    long storedEnergy = 0L;
    long maxEnergy = 0L;

    if (LoaderReference.tectech) {
        long[] info = getCurrentInfoData();
        storedEnergy = info[0];
        maxEnergy = info[1];
    }

    for (GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) {
        if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
            storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU();
            maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity();
        }
    }

    return new String[]{StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + EnumChatFormatting.GREEN + this.mProgresstime / 20 + EnumChatFormatting.RESET + " s / " + EnumChatFormatting.YELLOW + this.mMaxProgresstime / 20 + EnumChatFormatting.RESET + " s", StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + EnumChatFormatting.GREEN + storedEnergy + EnumChatFormatting.RESET + " EU / " + EnumChatFormatting.YELLOW + maxEnergy + EnumChatFormatting.RESET + " EU", StatCollector.translateToLocal("GT5U.multiblock.usage") + ": " + EnumChatFormatting.RED + -this.lEUt + EnumChatFormatting.RESET + " EU/t", StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " + EnumChatFormatting.YELLOW + this.getMaxInputVoltage() + EnumChatFormatting.RESET + " EU/t(*2A) " + StatCollector.translateToLocal("GT5U.machines.tier") + ": " + EnumChatFormatting.YELLOW + GT_Values.VN[GT_Utility.getTier(this.getMaxInputVoltage())] + EnumChatFormatting.RESET, StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " + EnumChatFormatting.RED + (this.getIdealStatus() - this.getRepairStatus()) + EnumChatFormatting.RESET + " " + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + EnumChatFormatting.YELLOW + (float) this.mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %"};
}
 
Example #4
Source File: PacketTCNotificationText.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public IMessage onMessage(PacketTCNotificationText message, MessageContext ctx) {
    if(message.text == null) return null;
    String translated = StatCollector.translateToLocal(message.text);
    ResourceLocation image = null;
    int color = message.color;
    Aspect a = Aspect.getAspect(message.additionalInfo);
    if(a != null) {
        image = a.getImage();
        color = a.getColor();
    }
    if(message.text.equals("gadomancy.aura.research.unlock")) {
        if(a != null) {
            translated = EnumChatFormatting.GREEN + String.format(translated, a.getName());
        } else {
            translated = EnumChatFormatting.GREEN + String.format(translated, message.additionalInfo);
        }
    }
    color &= 0xFFFFFF;
    PlayerNotifications.addNotification(translated, image, color);
    return null;
}
 
Example #5
Source File: EventHandlerGolem.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(ItemTooltipEvent event) {
    if(event.itemStack != null) {
        if(event.itemStack.getItem() instanceof ItemGolemPlacer
                || event.itemStack.getItem() instanceof ItemAdditionalGolemPlacer) {
            if(RegisteredGolemStuff.upgradeRunicShield.hasUpgrade(event.itemStack)) {
                event.toolTip.add("\u00a76" + StatCollector.translateToLocal("item.runic.charge") + " +" + RegisteredGolemStuff.upgradeRunicShield.getChargeLimit(event.itemStack));
            }

            AdditionalGolemCore core = GadomancyApi.getAdditionalGolemCore(event.itemStack);
            if(core != null) {
                String searchStr = StatCollector.translateToLocal("item.ItemGolemCore.name");
                for(int i = 0; i < event.toolTip.size(); i++) {
                    String line = event.toolTip.get(i);
                    if(line.contains(searchStr)) {
                        int index = line.indexOf('\u00a7', searchStr.length()) + 2;
                        event.toolTip.remove(i);
                        event.toolTip.add(i, line.substring(0, index) + StatCollector.translateToLocal(core.getUnlocalizedName()));
                        break;
                    }
                }
            }
        }
    }
}
 
Example #6
Source File: ComponentResistance.java    From Artifacts with MIT License 6 votes vote down vote up
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, String trigger, boolean advTooltip) {
	if(trigger == "passively.") {
		par3List.add(EnumChatFormatting.AQUA + StatCollector.translateToLocal("effect.Damage Resistance"));
	}
	else {
		int time = 0;
		if(trigger == "when inflicting damage.") {
			time = 5;
		}
		else if(trigger == "when used.") {
			time = 30;
		}
		par3List.add(EnumChatFormatting.AQUA + StatCollector.translateToLocal("effect.Damage Resistance"));
		par3List.add("  " + EnumChatFormatting.AQUA + StatCollector.translateToLocal("tool."+trigger) + " (" + time + " "  + StatCollector.translateToLocal("time.seconds") + ")");
	}
}
 
Example #7
Source File: GuiSolderingStation.java    From ExtraCells1 with MIT License 6 votes vote down vote up
@Override
public void drawScreen(int x, int y, float f)
{
	drawDefaultBackground();
	int posX = (this.width - xSize) / 2;
	int posY = (this.height - ySize) / 2;

	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	Minecraft.getMinecraft().renderEngine.bindTexture(guiTexture);

	drawTexturedModalRect(posX, posY, 0, 0, xSize, ySize);

	if (rightItem)
	{
		textfield_size.drawTextBox();
		textfield_types.drawTextBox();
	} else
	{
		this.fontRenderer.drawSplitString(StatCollector.translateToLocal("tooltip.solderingwarning.tutorial"), posX + 3, posY + 25, 170, 0x000064);
	}
	super.drawScreen(x, y, f);
}
 
Example #8
Source File: ItemBanner.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "unchecked", "rawtypes" })
public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) {
	NBTTagCompound nbttagcompound = getSubTag(stack, "BlockEntityTag", false);

	if (nbttagcompound != null && nbttagcompound.hasKey("Patterns")) {
		NBTTagList nbttaglist = nbttagcompound.getTagList("Patterns", 10);

		for (int i = 0; i < nbttaglist.tagCount() && i < 6; i++) {
			NBTTagCompound nbt = nbttaglist.getCompoundTagAt(i);
			EnumColour colour = EnumColour.fromDamage(nbt.getInteger("Color"));
			EnumBannerPattern pattern = EnumBannerPattern.getPatternByID(nbt.getString("Pattern"));

			if (pattern != null)
				tooltip.add(StatCollector.translateToLocal("item.banner." + pattern.getPatternName() + "." + colour.getMojangName()));
		}
	}
}
 
Example #9
Source File: LingeringPotion.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@Override
public String getItemStackDisplayName(ItemStack stack) {
	if (stack.getItemDamage() == 0)
		return StatCollector.translateToLocal("item.emptyPotion.name").trim();
	else {
		String s = StatCollector.translateToLocal("potion.prefix.lingering").trim() + " ";

		List<PotionEffect> list = getEffects(stack);
		String s1;

		if (list != null && !list.isEmpty()) {
			s1 = list.get(0).getEffectName();
			s1 = s1 + ".postfix";
			return s + StatCollector.translateToLocal(s1).trim();
		} else {
			s1 = PotionHelper.func_77905_c(stack.getItemDamage());
			return StatCollector.translateToLocal(s1).trim() + " " + super.getItemStackDisplayName(stack);
		}
	}
}
 
Example #10
Source File: ComponentResurrect.java    From Artifacts with MIT License 6 votes vote down vote up
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, String trigger, boolean advTooltip) {
	NBTTagCompound data = par1ItemStack.getTagCompound();
	int c = data.getInteger("resCooldown_armor");
	if(c < 1) {
		par3List.add(StatCollector.translateToLocal("effect.Restores health") + " " + StatCollector.translateToLocal("tool."+trigger));
		par3List.add("   (5 " + StatCollector.translateToLocal("time.minute") + " " + StatCollector.translateToLocal("time.cooldown") + ")");
	}
	else {
		String m = "";
		if(c >= 1200) {
			m = ((c+30)/1200) + " "+StatCollector.translateToLocal("time.minutes");
		}
		else {
			m = (c/20) + " "+StatCollector.translateToLocal("time.seconds");
		}
		par3List.add(StatCollector.translateToLocal("effect.Restores health") + " " + StatCollector.translateToLocal("tool."+trigger));
		par3List.add("   (" + StatCollector.translateToLocal("time.on") + " " + StatCollector.translateToLocal("time.cooldown") + ": " + m + ")");
	}
}
 
Example #11
Source File: SJStringHelper.java    From SimplyJetpacks with MIT License 5 votes vote down vote up
public static String localize(String unlocalized, boolean prefix, Object... args) {
    String toLocalize = (prefix ? SimplyJetpacks.PREFIX : "") + unlocalized;
    if (args != null && args.length > 0) {
        return StatCollector.translateToLocalFormatted(toLocalize, args);
    } else {
        return StatCollector.translateToLocal(toLocalize);
    }
}
 
Example #12
Source File: GuiEnderItemStorage.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
    fontRendererObj.drawString(name, 8, 6, 0x404040);
    fontRendererObj.drawString(StatCollector.translateToLocal(playerInv.getInventoryName()), 8, ySize - 94, 0x404040);
    ContainerEnderItemStorage ces = (ContainerEnderItemStorage)inventorySlots;
    if(!ces.chestInv.owner.equals("global"))
        fontRendererObj.drawString(ces.chestInv.owner, 170-fontRendererObj.getStringWidth(ces.chestInv.owner), 6, 0x404040);
}
 
Example #13
Source File: MCLanguageManager.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String translate(String key) {
	String value = super.translate(key);
	if (value.equals(key))
		value = StatCollector.translateToLocal(key);
	return value;
}
 
Example #14
Source File: ItemFocusBasic.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void addInformation(ItemStack stack,EntityPlayer player, List list, boolean par4) {
	AspectList al = this.getVisCost(stack);
	if (al!=null && al.size()>0) {
		list.add(StatCollector.translateToLocal(isVisCostPerTick(stack)?"item.Focus.cost2":"item.Focus.cost1"));
		for (Aspect aspect:al.getAspectsSorted()) {
			DecimalFormat myFormatter = new DecimalFormat("#####.##");
			String amount = myFormatter.format(al.getAmount(aspect)/100f);
			list.add(" \u00A7"+aspect.getChatcolor()+aspect.getName()+"\u00A7r x "+ amount);				
		}
	}
	addFocusInformation(stack,player,list,par4);
}
 
Example #15
Source File: TT_MetaTileEntity_Pipe_Energy_LowPower.java    From bartworks with MIT License 5 votes vote down vote up
@Override
public String[] getDescription() {
    return new String[]{
            "Primitive Laser Cable intended for Low Power Applications",
            "Does not auto-connect",
            "Does not turn or bend",
            ChatColorHelper.WHITE + "Must be " + ChatColorHelper.YELLOW + "c" + ChatColorHelper.RED + "o" + ChatColorHelper.BLUE + "l" + ChatColorHelper.DARKPURPLE + "o" + ChatColorHelper.GOLD + "r" + ChatColorHelper.DARKRED + "e" + ChatColorHelper.DARKGREEN + "d" + ChatColorHelper.WHITE + " in order to work",
            StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"
    };
}
 
Example #16
Source File: ItemWirelessRemote.java    From WirelessRedstone with MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public String getItemStackDisplayName(ItemStack itemstack) {
    return RedstoneEtherAddons.localizeWirelessItem(
            StatCollector.translateToLocal("wrcbe_addons.remote.short"),
            itemstack.getItemDamage());
}
 
Example #17
Source File: ItemMobCrystal.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Override
public String getItemStackDisplayName(ItemStack stack) {
    if (stack.hasTagCompound()) {
        NBTTagCompound nbttagcompound = stack.getTagCompound();
        if(nbttagcompound.hasKey("mob")) {
            String string = nbttagcompound.getString("mob");

            if (string != null)
                return ("" + StatCollector.translateToLocal("item.MobCrystal.name").replace("%s", StatCollector.translateToLocal("entity." + string + ".name"))).trim();
        }
    }

    return ("" + StatCollector.translateToLocal("item.MobCrystalEmpty.name")).trim();
}
 
Example #18
Source File: EventHandlerPneumaticCraft.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onPlayerClick(PlayerInteractEvent event){
    Block interactedBlock = event.world.getBlock(event.x, event.y, event.z);
    if(!event.entityPlayer.capabilities.isCreativeMode || !event.entityPlayer.canCommandSenderUseCommand(2, "securityStation")) {
        if(event.action != PlayerInteractEvent.Action.RIGHT_CLICK_AIR && event.world != null && !event.world.isRemote) {
            if(interactedBlock != Blockss.securityStation || event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) {
                ItemStack heldItem = event.entityPlayer.getCurrentEquippedItem();
                boolean tryingToPlaceSecurityStation = heldItem != null && heldItem.getItem() instanceof ItemBlock && ((ItemBlock)heldItem.getItem()).field_150939_a == Blockss.securityStation;
                int blockingStations = PneumaticCraftUtils.getProtectingSecurityStations(event.entity.worldObj, event.x, event.y, event.z, event.entityPlayer, true, tryingToPlaceSecurityStation);
                if(blockingStations > 0) {
                    event.setCanceled(true);
                    event.entityPlayer.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted(tryingToPlaceSecurityStation ? "message.securityStation.stationPlacementPrevented" : "message.securityStation.accessPrevented", blockingStations)));
                }
            }
        }
    }

    /**
     * Due to some weird quirk that causes Block#onBlockActivated not getting called on the server when the player is sneaking, this is a workaround.
     */
    if(!event.isCanceled() && event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK && !event.world.isRemote) {
        if(event.entityPlayer.isSneaking() && (interactedBlock == Blockss.elevatorCaller || interactedBlock == Blockss.chargingStation)) {
            event.setCanceled(interactedBlock.onBlockActivated(event.world, event.x, event.y, event.z, event.entityPlayer, event.face, 0, 0, 0));
        } else if(event.entityPlayer.getCurrentEquippedItem() != null && ModInteractionUtilImplementation.getInstance().isModdedWrench(event.entityPlayer.getCurrentEquippedItem().getItem())) {
            if(interactedBlock instanceof IPneumaticWrenchable) {
                ((IPneumaticWrenchable)interactedBlock).rotateBlock(event.world, event.entityPlayer, event.x, event.y, event.z, ForgeDirection.getOrientation(event.face));
            }
        }
    }

    if(!event.isCanceled() && interactedBlock == Blocks.cobblestone) {
        AchievementHandler.checkFor9x9(event.entityPlayer, event.x, event.y, event.z);
    }
}
 
Example #19
Source File: WailaDataProvider.java    From ExtraCells1 with MIT License 5 votes vote down vote up
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
{
	List<String> list = currenttip;
	Class clazz = accessor.getClass();
	TileEntity tileEntity = accessor.getTileEntity();
	if (tileEntity instanceof TileEntityMonitorStorageFluid)
	{
		TileEntityMonitorStorageFluid fluidMonitor = (TileEntityMonitorStorageFluid) tileEntity;
		Fluid fluid = fluidMonitor.getFluid();
		String fluidName = fluid != null ? fluid.getLocalizedName() : "-";
		long fluidAmount = fluid != null ? fluidMonitor.getAmount() : 0;

		String amountToText = Long.toString(fluidAmount) + "mB";
		if (Extracells.shortenedBuckets)
		{
			if (fluidAmount > 1000000000L)
				amountToText = Long.toString(fluidAmount / 1000000000L) + "MegaB";
			else if (fluidAmount > 1000000L)
				amountToText = Long.toString(fluidAmount / 1000000L) + "KiloB";
			else if (fluidAmount > 9999L)
			{
				amountToText = Long.toString(fluidAmount / 1000L) + "B";
			}
		}

		list.add(StatCollector.translateToLocal("tooltip.fluid") + ": " + fluidName);
		list.add(StatCollector.translateToLocal("tooltip.amount") + ": " + amountToText);
	}
	return list;
}
 
Example #20
Source File: GT_TileEntity_CircuitAssemblyLine.java    From bartworks with MIT License 5 votes vote down vote up
@Override
public String[] getDescription() {
    return new String[]{
            "Circuit Assembly Line", "Size(WxHxD): (2-7)x3x3, variable length",
            "Bottom: Steel Machine Casing(or 1x Maintenance or Input Hatch),",
            "ULV Input Bus (Last ULV Output Bus), Steel Machine Casing",
            "Middle: EV+ Tier Glass, Assembling Line Casing, EV+ Tier Glass",
            "Top: Grate Machine Casing (or Controller or 1x Energy Hatch)",
            "Up to 7 repeating slices, last is Output Bus",
            "Imprint this machine with a Circuit Imprint,",
            "by putting the imprint in the controller.",
            "Every Circuit Assembly Line can only be imprinted ONCE.",
            StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"
    };
}
 
Example #21
Source File: ItemLogisticsFrame.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public static void addTooltip(ItemStack stack, EntityPlayer player, List<String> curInfo, boolean sneaking){

        if(stack.getTagCompound() != null) {
            if(stack.getTagCompound().getBoolean("invisible")) curInfo.add(I18n.format("gui.logisticFrame.invisible"));
            if(stack.getTagCompound().hasKey("filters") && stack.getTagCompound().getTagList("filters", 10).tagCount() > 0 || stack.getTagCompound().hasKey("fluidFilters") && stack.getTagCompound().getTagList("fluidFilters", 10).tagCount() > 0) {
                String key = SemiBlockManager.getKeyForSemiBlock(SemiBlockManager.getSemiBlockForItem(stack.getItem()));
                if(sneaking) {
                    curInfo.add(StatCollector.translateToLocal(String.format("gui.%s.filters", key)));
                    SemiBlockRequester requester = new SemiBlockRequester();
                    requester.onPlaced(player, stack);
                    ItemStack[] stacks = new ItemStack[requester.getFilters().getSizeInventory()];
                    for(int i = 0; i < stacks.length; i++) {
                        stacks[i] = requester.getFilters().getStackInSlot(i);
                    }
                    PneumaticCraftUtils.sortCombineItemStacksAndToString(curInfo, stacks);
                    for(int i = 0; i < 9; i++) {
                        FluidStack fluid = requester.getTankFilter(i).getFluid();
                        if(fluid != null) {
                            curInfo.add("-" + fluid.amount / 1000 + "B " + fluid.getLocalizedName());
                        }
                    }
                } else {
                    curInfo.add(StatCollector.translateToLocal(String.format("gui.%s.hasFilters", key)));
                }
            }
        }
    }
 
Example #22
Source File: DarkResearchItem.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public String getText() {
    if (Config.tagResearch) {
        if (inter == null)
            return "[FM] " + StatCollector.translateToLocal("forbidden.research_text." + key);
        else
            return "[FM] " + inter + " " + StatCollector.translateToLocal("forbidden.research_text." + key);
    } else
        return StatCollector.translateToLocal("forbidden.research_text." + key);
}
 
Example #23
Source File: ItemSubCollar.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
@Override
public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity)
{
    if (entity.worldObj.isRemote)
    {
        return false;
    }
    if (entity instanceof EntityPlayer)
    {
        EntityPlayer sub = (EntityPlayer)entity;
        IInventory baubles = BaublesApi.getBaubles(sub);
        if(baubles.getStackInSlot(0) == null) {
            if(!itemstack.hasTagCompound()){
                NBTTagCompound tag = new NBTTagCompound();
                itemstack.setTagCompound(tag);
            }
            itemstack.stackTagCompound.setString("owner", player.getDisplayName());
            baubles.setInventorySlotContents(0, itemstack.copy());
            itemstack.stackSize = 0;
            sub.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.collar.placescollar").replace("%s", player.getDisplayName())));
            player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.collar.youplacecollar").replace("%s", sub.getDisplayName())));
            return true;
        }
        else
            player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.collar.alreadywearing").replace("%s", sub.getDisplayName())));
    }
    return false;
}
 
Example #24
Source File: ComponentMusicPlayer.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, String trigger, boolean advTooltip) {
	String play = StatCollector.translateToLocal("effect.Play");
	if(play.equals("{Play}"))
		play = "" + EnumChatFormatting.GREEN + ((char) 0x266A) + EnumChatFormatting.LIGHT_PURPLE + ((char) 0x266B) + EnumChatFormatting.GOLD + ((char) 0x266A);
	
	//Get the localized record description
	String recordDescription = "Unknown";
	ItemRecord record = ItemRecord.getRecord("records."+itemStack.getTagCompound().getString("record"));
	if(record != null) { //If the record was from a mod that is no longer loaded, the description will stay "Unknown"
		recordDescription = record.getRecordNameLocal();
	}
	
	list.add(StatCollector.translateToLocal("effect.Plays the record") + " " + recordDescription + " " + StatCollector.translateToLocal("tool." + trigger) + " " + (itemStack.getTagCompound().getBoolean("playing") ? play : ""));
}
 
Example #25
Source File: ItemDivineOrb.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
    list.add(StatCollector.translateToLocal("tooltip.divineorb"));

    if (!(stack.stackTagCompound == null)) {
        list.add(StatCollector.translateToLocal("tooltip.currentowner") + " " + stack.stackTagCompound.getString("ownerName"));
    }

}
 
Example #26
Source File: BW_SimpleWindMeter.java    From bartworks with MIT License 5 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) {
    if (entityPlayer.worldObj.isRemote || world == null || WorldData.get(world) == null || WorldData.get(world).windSim == null)
        return itemStack;

    float windStrength = (float) WorldData.get(world).windSim.getWindAt(entityPlayer.posY);
    String windS = windStrength < 1f ? StatCollector.translateToLocal("tooltip.windmeter.2.name") : windStrength < 10f ? StatCollector.translateToLocal("tooltip.windmeter.3.name") : windStrength < 20f ? StatCollector.translateToLocal("tooltip.windmeter.4.name") : windStrength < 30f ? StatCollector.translateToLocal("tooltip.windmeter.5.name") : windStrength < 50f ? StatCollector.translateToLocal("tooltip.windmeter.6.name") : StatCollector.translateToLocal("tooltip.windmeter.7.name");
    entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip.windmeter.8.name") + " " + windS + "."));
    itemStack.damageItem(1, entityPlayer);
    return itemStack;
}
 
Example #27
Source File: BW_ItemBlocks.java    From bartworks with MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) {
    if (this.field_150939_a instanceof BW_GlasBlocks)
        aList.add(StatCollector.translateToLocal("tooltip.glas.0.name") + " " + BW_ColorUtil.getColorForTier(BW_Util.getTierFromGlasMeta(aStack.getItemDamage())) + GT_Values.VN[BW_Util.getTierFromGlasMeta(aStack.getItemDamage())]);
    if (this.field_150939_a instanceof ITileAddsInformation) {
        aList.addAll(Arrays.asList(((ITileAddsInformation) this.field_150939_a).getInfoData()));
    }
    aList.add(this.mNoMobsToolTip);
    if (!(this.field_150939_a instanceof ITileEntityProvider))
        aList.add(this.mNoTileEntityToolTip);

    aList.add(StatCollector.translateToLocal("tooltip.bw.0.name") + ChatColorHelper.DARKGREEN + " BartWorks");
}
 
Example #28
Source File: ItemSecureStoragePhysicalDecrypted.java    From ExtraCells1 with MIT License 5 votes vote down vote up
@ForgeSubscribe
@Override
public ItemStack onItemRightClick(ItemStack i, World w, EntityPlayer p)
{
	if (p.isSneaking())
	{
		ItemStack itemStackDecrypted = p.inventory.getCurrentItem();
		ItemStack itemStackEncrypted = new ItemStack(ItemEnum.STORAGEPHYSICALENCRYPTED.getItemInstance(), 1);
		if (!itemStackEncrypted.hasTagCompound())
		{
			itemStackEncrypted.setTagCompound(new NBTTagCompound());
		}

		if (!itemStackDecrypted.hasTagCompound())
		{
			itemStackDecrypted.setTagCompound(new NBTTagCompound());
		}

		NBTTagCompound tagDecrypted = itemStackDecrypted.getTagCompound();

		// copy over content
		itemStackEncrypted.setTagCompound(tagDecrypted);

		// set owner
		itemStackEncrypted.getTagCompound().setString("owner", p.username);

		p.inventory.setInventorySlotContents(p.inventory.currentItem, itemStackEncrypted);
		if (!w.isRemote)
		{
			p.addChatMessage(StatCollector.translateToLocal("tooltip.storageencrypted"));
		}
	}
	return i;
}
 
Example #29
Source File: ResearchPage.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * returns a localized text of the text field (if one exists). Returns the text field itself otherwise.
 * @return
 */
public String getTranslatedText() {
	String ret="";
	if (text != null) {
		ret = StatCollector.translateToLocal(text);
		if (ret.isEmpty()) ret = text;
	}
	return ret;
}
 
Example #30
Source File: ItemGlasses.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "unchecked", "rawtypes" })
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
	Long guid = extractGuid(itemStack);
	if (guid != null) list.add(StatCollector.translateToLocalFormatted("openperipheral.misc.key", TerminalUtils.formatTerminalId(guid)));
}