Skip to content

Commit

Permalink
Start to add tooltip translations
Browse files Browse the repository at this point in the history
  • Loading branch information
HyCraftHD committed Jan 6, 2020
1 parent e6dd05e commit 57f7879
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 15 deletions.
Expand Up @@ -5,6 +5,8 @@
import static info.u_team.useful_railroads.init.UsefulRailroadsItems.*;

import info.u_team.u_team_core.data.*;
import net.minecraft.block.Block;
import net.minecraft.item.Item;

public class UsefulRailroadsLanguagesProvider extends CommonLanguagesProvider {

Expand Down Expand Up @@ -58,6 +60,9 @@ public void addTranslations() {
add(trackBuilderContainerKey + ".mode.5x5", "5x5 air tunnel");
add(trackBuilderContainerKey + ".mode.tunnel", "Tunnel with blocks & light");

add("usefulrailroads.tooltip.right_click", "RIGHT CLICK");
add("usefulrailroads.tooltip.shift_right_click", "SHIFT + RIGHT CLICK");

// German

add("de_de", GROUP, "Nützliche Eisenbahn Erweiterungen");
Expand Down Expand Up @@ -95,6 +100,25 @@ public void addTranslations() {
add("de_de", trackBuilderContainerKey + ".mode.3x3", "3x3 Lufttunnel");
add("de_de", trackBuilderContainerKey + ".mode.5x5", "5x5 Lufttunnel");
add("de_de", trackBuilderContainerKey + ".mode.tunnel", "Tunnel mit Blöcken & Licht");

add("de_de", "usefulrailroads.tooltip.right_click", "RECHTS KLICK");
add("de_de", "usefulrailroads.tooltip.shift_right_click", "UMSCHALTTASTE + RECHTS KLICK");
}

protected void addTooltip(Block key, int line, String value) {
addTooltip(key.asItem(), line, value);
}

protected void addTooltip(String locale, Block key, int line, String value) {
addTooltip(locale, key.asItem(), line, value);
}

protected void addTooltip(Item key, int line, String value) {
add(key.getTranslationKey() + ".tooltip." + line, value);
}

protected void addTooltip(String locale, Item key, int line, String value) {
add(key.getTranslationKey() + ".tooltip" + line, value);
}

}
@@ -1,7 +1,6 @@
package info.u_team.useful_railroads.item;

import java.util.Random;

import info.u_team.u_team_core.util.MathUtil;
import info.u_team.useful_railroads.block.TeleportRailBlock;
import info.u_team.useful_railroads.util.Location;
import net.minecraft.entity.effect.LightningBoltEntity;
Expand Down Expand Up @@ -45,7 +44,7 @@ public boolean onEntityItemUpdate(ItemStack stack, ItemEntity itemEntity) {
if (world.isRemote) { // Do client particles
if (world.rand.nextInt(10) == 0) {
for (int i = 0; i < 5; i++) {
world.addParticle(ParticleTypes.ENCHANT, true, itemEntity.posX, itemEntity.posY + 0.5, itemEntity.posZ, getRandomNumberInRange(world.rand, -0.2, 0.2), getRandomNumberInRange(world.rand, 0.1, 1.5), getRandomNumberInRange(world.rand, -0.2, 0.2));
world.addParticle(ParticleTypes.ENCHANT, true, itemEntity.posX, itemEntity.posY + 0.5, itemEntity.posZ, MathUtil.getRandomNumberInRange(world.rand, -0.2, 0.2), MathUtil.getRandomNumberInRange(world.rand, 0.1, 1.5), MathUtil.getRandomNumberInRange(world.rand, -0.2, 0.2));
}
}
} else { // Do server stuff
Expand Down Expand Up @@ -84,16 +83,4 @@ public boolean onEntityItemUpdate(ItemStack stack, ItemEntity itemEntity) {
}
return false;
}

/**
* Just a helper method. Might be in uteamcore soon again TODO
*
* @param random
* @param min
* @param max
* @return
*/
public static double getRandomNumberInRange(Random random, double min, double max) {
return random.nextDouble() * (max - min) + min;
}
}
@@ -1,16 +1,20 @@
package info.u_team.useful_railroads.item;

import java.util.List;

import info.u_team.u_team_core.item.UItem;
import info.u_team.useful_railroads.container.TrackBuilderContainer;
import info.u_team.useful_railroads.init.UsefulRailroadsItemGroups;
import info.u_team.useful_railroads.inventory.TrackBuilderInventoryWrapper;
import info.u_team.useful_railroads.util.TrackBuilderManager;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.*;
import net.minecraft.inventory.container.*;
import net.minecraft.item.*;
import net.minecraft.util.*;
import net.minecraft.util.text.*;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.*;
import net.minecraftforge.fml.network.NetworkHooks;

public class TrackBuilderItem extends UItem {
Expand Down Expand Up @@ -73,4 +77,11 @@ public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStac
public boolean isDoubleTrack() {
return doubleTrack;
}

@OnlyIn(Dist.CLIENT)
@Override
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
tooltip.add(new TranslationTextComponent("", new TranslationTextComponent("usefulrailroads.tooltip.right_click")));
}

}

0 comments on commit 57f7879

Please sign in to comment.