I18n implementation for missiles and sattelites

This commit is contained in:
Bufka2011 2025-08-23 17:51:01 -06:00
parent fa6b4faeee
commit 60b9e1fb18
4 changed files with 252 additions and 222 deletions

View File

@ -4,6 +4,7 @@ import java.util.List;
import com.hbm.items.ISatChip; import com.hbm.items.ISatChip;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.util.i18n.I18nUtil;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -14,36 +15,36 @@ public class ItemSatChip extends Item implements ISatChip {
@Override @Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool)
{ {
list.add("Satellite frequency: " + getFreq(itemstack)); list.add(I18nUtil.resolveKey("satchip.frequency") + ": " + getFreq(itemstack));
if(this == ModItems.sat_foeq) if(this == ModItems.sat_foeq)
list.add("Gives you an achievement. That's it."); list.add(I18nUtil.resolveKey("satchip.foeq"));
if(this == ModItems.sat_gerald) { if(this == ModItems.sat_gerald) {
list.add("Single use."); list.add(I18nUtil.resolveKey("satchip.gerald.line1"));
list.add("Requires orbital module."); list.add(I18nUtil.resolveKey("satchip.gerald.line2"));
list.add("Melter of CPUs, bane of every server owner."); list.add(I18nUtil.resolveKey("satchip.gerald.line3"));
} }
if(this == ModItems.sat_laser) if(this == ModItems.sat_laser)
list.add("Allows to summon lasers with a 15 second cooldown."); list.add(I18nUtil.resolveKey("satchip.laser"));
if(this == ModItems.sat_mapper) if(this == ModItems.sat_mapper)
list.add("Displays currently loaded chunks."); list.add(I18nUtil.resolveKey("satchip.mapper"));
if(this == ModItems.sat_miner) if(this == ModItems.sat_miner)
list.add("Will deliver ore powders to a cargo landing pad."); list.add(I18nUtil.resolveKey("satchip.miner"));
if(this == ModItems.sat_lunar_miner) if(this == ModItems.sat_lunar_miner)
list.add("Mines moon turf to deliver it to a cargo landing pad."); list.add(I18nUtil.resolveKey("satchip.lunar_miner"));
if(this == ModItems.sat_radar) if(this == ModItems.sat_radar)
list.add("Shows a map of active entities."); list.add(I18nUtil.resolveKey("satchip.radar"));
if(this == ModItems.sat_resonator) if(this == ModItems.sat_resonator)
list.add("Allows for teleportation with no cooldown."); list.add(I18nUtil.resolveKey("satchip.resonator"));
if(this == ModItems.sat_scanner) if(this == ModItems.sat_scanner)
list.add("Creates a topdown map of underground ores."); list.add(I18nUtil.resolveKey("satchip.scanner"));
} }
} }

View File

@ -6,6 +6,7 @@ import com.hbm.handler.MissileStruct;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.weapon.ItemCustomMissilePart.FuelType; import com.hbm.items.weapon.ItemCustomMissilePart.FuelType;
import com.hbm.items.weapon.ItemCustomMissilePart.WarheadType; import com.hbm.items.weapon.ItemCustomMissilePart.WarheadType;
import com.hbm.util.i18n.I18nUtil;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -15,35 +16,35 @@ import net.minecraft.util.EnumChatFormatting;
public class ItemCustomMissile extends Item { public class ItemCustomMissile extends Item {
public static ItemStack buildMissile(Item chip, Item warhead, Item fuselage, Item stability, Item thruster) { public static ItemStack buildMissile(Item chip, Item warhead, Item fuselage, Item stability, Item thruster) {
if(stability == null) { if(stability == null) {
return buildMissile(new ItemStack(chip), new ItemStack(warhead), new ItemStack(fuselage), null, new ItemStack(thruster)); return buildMissile(new ItemStack(chip), new ItemStack(warhead), new ItemStack(fuselage), null, new ItemStack(thruster));
} else { } else {
return buildMissile(new ItemStack(chip), new ItemStack(warhead), new ItemStack(fuselage), new ItemStack(stability), new ItemStack(thruster)); return buildMissile(new ItemStack(chip), new ItemStack(warhead), new ItemStack(fuselage), new ItemStack(stability), new ItemStack(thruster));
} }
} }
public static ItemStack buildMissile(ItemStack chip, ItemStack warhead, ItemStack fuselage, ItemStack stability, ItemStack thruster) { public static ItemStack buildMissile(ItemStack chip, ItemStack warhead, ItemStack fuselage, ItemStack stability, ItemStack thruster) {
ItemStack missile = new ItemStack(ModItems.missile_custom); ItemStack missile = new ItemStack(ModItems.missile_custom);
writeToNBT(missile, "chip", Item.getIdFromItem(chip.getItem())); writeToNBT(missile, "chip", Item.getIdFromItem(chip.getItem()));
writeToNBT(missile, "warhead", Item.getIdFromItem(warhead.getItem())); writeToNBT(missile, "warhead", Item.getIdFromItem(warhead.getItem()));
writeToNBT(missile, "fuselage", Item.getIdFromItem(fuselage.getItem())); writeToNBT(missile, "fuselage", Item.getIdFromItem(fuselage.getItem()));
writeToNBT(missile, "thruster", Item.getIdFromItem(thruster.getItem())); writeToNBT(missile, "thruster", Item.getIdFromItem(thruster.getItem()));
if(stability != null) if(stability != null)
writeToNBT(missile, "stability", Item.getIdFromItem(stability.getItem())); writeToNBT(missile, "stability", Item.getIdFromItem(stability.getItem()));
return missile; return missile;
} }
private static void writeToNBT(ItemStack stack, String key, int value) { private static void writeToNBT(ItemStack stack, String key, int value) {
if(!stack.hasTagCompound()) if(!stack.hasTagCompound())
stack.stackTagCompound = new NBTTagCompound(); stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setInteger(key, value); stack.stackTagCompound.setInteger(key, value);
} }
public static int readFromNBT(ItemStack stack, String key) { public static int readFromNBT(ItemStack stack, String key) {
if(!stack.hasTagCompound()) if(!stack.hasTagCompound())
stack.stackTagCompound = new NBTTagCompound(); stack.stackTagCompound = new NBTTagCompound();
@ -52,53 +53,63 @@ public class ItemCustomMissile extends Item {
@Override @Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
if(!stack.hasTagCompound()) if(!stack.hasTagCompound())
return; return;
try { try {
ItemCustomMissilePart chip = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "chip")); ItemCustomMissilePart chip = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "chip"));
ItemCustomMissilePart warhead = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "warhead")); ItemCustomMissilePart warhead = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "warhead"));
ItemCustomMissilePart fuselage = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "fuselage")); ItemCustomMissilePart fuselage = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "fuselage"));
ItemCustomMissilePart stability = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "stability")); ItemCustomMissilePart stability = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "stability"));
ItemCustomMissilePart thruster = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "thruster")); ItemCustomMissilePart thruster = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "thruster"));
list.add(EnumChatFormatting.BOLD + "Warhead: " + EnumChatFormatting.GRAY + warhead.getWarhead((WarheadType)warhead.attributes[0])); // warhead name
list.add(EnumChatFormatting.BOLD + "Strength: " + EnumChatFormatting.GRAY + (Float)warhead.attributes[1]); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("gui.missile.warhead") + ": " + EnumChatFormatting.GRAY + warhead.getWarhead((WarheadType)warhead.attributes[0]));
list.add(EnumChatFormatting.BOLD + "Fuel Type: " + EnumChatFormatting.GRAY + fuselage.getFuel((FuelType)fuselage.attributes[0]));
list.add(EnumChatFormatting.BOLD + "Fuel amount: " + EnumChatFormatting.GRAY + (Float)fuselage.attributes[1] + "l"); // strength
list.add(EnumChatFormatting.BOLD + "Chip inaccuracy: " + EnumChatFormatting.GRAY + (Float)chip.attributes[0] * 100 + "%"); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("gui.missile.strength") + ": " + EnumChatFormatting.GRAY + (Float)warhead.attributes[1]);
// fuel type & amount
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("gui.missile.fuelType") + ": " + EnumChatFormatting.GRAY + fuselage.getFuel((FuelType)fuselage.attributes[0]));
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("gui.missile.fuelAmount") + ": " + EnumChatFormatting.GRAY + (Float)fuselage.attributes[1] + "l");
// chip inaccuracy
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("gui.missile.chipInaccuracy") + ": " + EnumChatFormatting.GRAY + (Float)chip.attributes[0] * 100 + "%");
// fin inaccuracy
if(stability != null) if(stability != null)
list.add(EnumChatFormatting.BOLD + "Fin inaccuracy: " + EnumChatFormatting.GRAY + (Float)stability.attributes[0] * 100 + "%"); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("gui.missile.finInaccuracy") + ": " + EnumChatFormatting.GRAY + (Float)stability.attributes[0] * 100 + "%");
else else
list.add(EnumChatFormatting.BOLD + "Fin inaccuracy: " + EnumChatFormatting.GRAY + "100%"); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("gui.missile.finInaccuracy") + ": " + EnumChatFormatting.GRAY + "100%");
list.add(EnumChatFormatting.BOLD + "Size: " + EnumChatFormatting.GRAY + fuselage.getSize(fuselage.top) + "/" + fuselage.getSize(fuselage.bottom)); // size
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("gui.missile.size") + ": " + EnumChatFormatting.GRAY + fuselage.getSize(fuselage.top) + "/" + fuselage.getSize(fuselage.bottom));
// health
float health = warhead.health + fuselage.health + thruster.health; float health = warhead.health + fuselage.health + thruster.health;
if(stability != null) if(stability != null)
health += stability.health; health += stability.health;
list.add(EnumChatFormatting.BOLD + "Health: " + EnumChatFormatting.GRAY + health + "HP"); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("gui.missile.health") + ": " + EnumChatFormatting.GRAY + health + "HP");
} catch(Exception ex) { } catch(Exception ex) {
list.add(EnumChatFormatting.RED + "### I AM ERROR ###"); list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("error.generic"));
} }
} }
public static MissileStruct getStruct(ItemStack stack) { public static MissileStruct getStruct(ItemStack stack) {
if(stack == null || !(stack.getItem() instanceof ItemCustomMissile)) if(stack == null || !(stack.getItem() instanceof ItemCustomMissile))
return null; return null;
ItemCustomMissilePart warhead = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "warhead")); ItemCustomMissilePart warhead = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "warhead"));
ItemCustomMissilePart fuselage = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "fuselage")); ItemCustomMissilePart fuselage = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "fuselage"));
ItemCustomMissilePart stability = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "stability")); ItemCustomMissilePart stability = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "stability"));
ItemCustomMissilePart thruster = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "thruster")); ItemCustomMissilePart thruster = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "thruster"));
MissileStruct missile = new MissileStruct(warhead, fuselage, stability, thruster); MissileStruct missile = new MissileStruct(warhead, fuselage, stability, thruster);
return missile; return missile;
} }
} }

View File

@ -8,6 +8,7 @@ import com.hbm.entity.missile.EntityMissileCustom;
import com.hbm.items.special.ItemLootCrate; import com.hbm.items.special.ItemLootCrate;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import com.hbm.util.i18n.I18nUtil;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -15,7 +16,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
public class ItemCustomMissilePart extends Item { public class ItemCustomMissilePart extends Item {
public PartType type; public PartType type;
public PartSize top; public PartSize top;
public PartSize bottom; public PartSize bottom;
@ -24,37 +25,37 @@ public class ItemCustomMissilePart extends Item {
private String title; private String title;
private String author; private String author;
private String witty; private String witty;
public ItemCustomMissilePart() { public ItemCustomMissilePart() {
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.setCreativeTab(MainRegistry.missileTab); this.setCreativeTab(MainRegistry.missileTab);
} }
public static HashMap<Integer, ItemCustomMissilePart> parts = new HashMap(); public static HashMap<Integer, ItemCustomMissilePart> parts = new HashMap();
/** /**
* == Chips == * == Chips ==
* [0]: inaccuracy * [0]: inaccuracy
* *
* == Warheads == * == Warheads ==
* [0]: type * [0]: type
* [1]: strength/radius/cluster count * [1]: strength/radius/cluster count
* [2]: weight * [2]: weight
* *
* == Fuselages == * == Fuselages ==
* [0]: type * [0]: type
* [1]: tank size * [1]: tank size
* *
* == Stability == * == Stability ==
* [0]: inaccuracy mod * [0]: inaccuracy mod
* *
* == Thrusters === * == Thrusters ===
* [0]: type * [0]: type
* [1]: consumption * [1]: consumption
* [2]: lift strength * [2]: lift strength
*/ */
public Object[] attributes; public Object[] attributes;
public enum PartType { public enum PartType {
CHIP, CHIP,
WARHEAD, WARHEAD,
@ -62,9 +63,9 @@ public class ItemCustomMissilePart extends Item {
FINS, FINS,
THRUSTER THRUSTER
} }
public enum PartSize { public enum PartSize {
//for chips //for chips
ANY, ANY,
//for missile tips and thrusters //for missile tips and thrusters
@ -74,9 +75,9 @@ public class ItemCustomMissilePart extends Item {
SIZE_15, SIZE_15,
SIZE_20 SIZE_20
} }
public enum WarheadType { public enum WarheadType {
HE, HE,
INC, INC,
BUSTER, BUSTER,
@ -89,8 +90,8 @@ public class ItemCustomMissilePart extends Item {
TAINT, TAINT,
CLOUD, CLOUD,
TURBINE, TURBINE,
//shit solution but it works. this allows traits to be attached to these empty dummy types, allowing for custom warheads //dummy/custom types
CUSTOM0, CUSTOM1, CUSTOM2, CUSTOM3, CUSTOM4, CUSTOM5, CUSTOM6, CUSTOM7, CUSTOM8, CUSTOM9; CUSTOM0, CUSTOM1, CUSTOM2, CUSTOM3, CUSTOM4, CUSTOM5, CUSTOM6, CUSTOM7, CUSTOM8, CUSTOM9;
/** Overrides that type's impact effect. Only runs serverside */ /** Overrides that type's impact effect. Only runs serverside */
@ -100,44 +101,50 @@ public class ItemCustomMissilePart extends Item {
/** Override for the warhead's name in the missile description */ /** Override for the warhead's name in the missile description */
public String labelCustom = null; public String labelCustom = null;
} }
public enum FuelType { public enum FuelType {
KEROSENE, KEROSENE,
SOLID, SOLID,
HYDROGEN, HYDROGEN,
XENON, XENON,
BALEFIRE BALEFIRE
} }
public enum Rarity { public enum Rarity {
COMMON(EnumChatFormatting.GRAY + "Common"), COMMON("part.rarity.common", EnumChatFormatting.GRAY),
UNCOMMON(EnumChatFormatting.YELLOW + "Uncommon"), UNCOMMON("part.rarity.uncommon", EnumChatFormatting.YELLOW),
RARE(EnumChatFormatting.AQUA + "Rare"), RARE("part.rarity.rare", EnumChatFormatting.AQUA),
EPIC(EnumChatFormatting.LIGHT_PURPLE + "Epic"), EPIC("part.rarity.epic", EnumChatFormatting.LIGHT_PURPLE),
LEGENDARY(EnumChatFormatting.DARK_GREEN + "Legendary"), LEGENDARY("part.rarity.legendary", EnumChatFormatting.DARK_GREEN),
SEWS_CLOTHES_AND_SUCKS_HORSE_COCK(EnumChatFormatting.DARK_AQUA + "Strange"); SEWS_CLOTHES_AND_SUCKS_HORSE_COCK("part.rarity.strange", EnumChatFormatting.DARK_AQUA);
String name; private final String key;
private final EnumChatFormatting color;
Rarity(String name) {
this.name = name; Rarity(String key, EnumChatFormatting color) {
this.key = key;
this.color = color;
}
public String getDisplay() {
return color + I18nUtil.resolveKey(key);
} }
} }
public ItemCustomMissilePart makeChip(float inaccuracy) { public ItemCustomMissilePart makeChip(float inaccuracy) {
this.type = PartType.CHIP; this.type = PartType.CHIP;
this.top = PartSize.ANY; this.top = PartSize.ANY;
this.bottom = PartSize.ANY; this.bottom = PartSize.ANY;
this.attributes = new Object[] { inaccuracy }; this.attributes = new Object[] { inaccuracy };
parts.put(this.hashCode(), this); parts.put(this.hashCode(), this);
return this; return this;
} }
public ItemCustomMissilePart makeWarhead(WarheadType type, float punch, float weight, PartSize size) { public ItemCustomMissilePart makeWarhead(WarheadType type, float punch, float weight, PartSize size) {
this.type = PartType.WARHEAD; this.type = PartType.WARHEAD;
@ -145,12 +152,12 @@ public class ItemCustomMissilePart extends Item {
this.bottom = size; this.bottom = size;
this.attributes = new Object[] { type, punch, weight }; this.attributes = new Object[] { type, punch, weight };
setTextureName(RefStrings.MODID + ":mp_warhead"); setTextureName(RefStrings.MODID + ":mp_warhead");
parts.put(this.hashCode(), this); parts.put(this.hashCode(), this);
return this; return this;
} }
public ItemCustomMissilePart makeFuselage(FuelType type, float fuel, PartSize top, PartSize bottom) { public ItemCustomMissilePart makeFuselage(FuelType type, float fuel, PartSize top, PartSize bottom) {
this.type = PartType.FUSELAGE; this.type = PartType.FUSELAGE;
@ -158,12 +165,12 @@ public class ItemCustomMissilePart extends Item {
this.bottom = bottom; this.bottom = bottom;
attributes = new Object[] { type, fuel }; attributes = new Object[] { type, fuel };
setTextureName(RefStrings.MODID + ":mp_fuselage"); setTextureName(RefStrings.MODID + ":mp_fuselage");
parts.put(this.hashCode(), this); parts.put(this.hashCode(), this);
return this; return this;
} }
public ItemCustomMissilePart makeStability(float inaccuracy, PartSize size) { public ItemCustomMissilePart makeStability(float inaccuracy, PartSize size) {
this.type = PartType.FINS; this.type = PartType.FINS;
@ -171,12 +178,12 @@ public class ItemCustomMissilePart extends Item {
this.bottom = size; this.bottom = size;
this.attributes = new Object[] { inaccuracy }; this.attributes = new Object[] { inaccuracy };
setTextureName(RefStrings.MODID + ":mp_stability"); setTextureName(RefStrings.MODID + ":mp_stability");
parts.put(this.hashCode(), this); parts.put(this.hashCode(), this);
return this; return this;
} }
public ItemCustomMissilePart makeThruster(FuelType type, float consumption, float lift, PartSize size) { public ItemCustomMissilePart makeThruster(FuelType type, float consumption, float lift, PartSize size) {
this.type = PartType.THRUSTER; this.type = PartType.THRUSTER;
@ -184,9 +191,9 @@ public class ItemCustomMissilePart extends Item {
this.bottom = PartSize.NONE; this.bottom = PartSize.NONE;
this.attributes = new Object[] { type, consumption, lift }; this.attributes = new Object[] { type, consumption, lift };
setTextureName(RefStrings.MODID + ":mp_thruster"); setTextureName(RefStrings.MODID + ":mp_thruster");
parts.put(this.hashCode(), this); parts.put(this.hashCode(), this);
return this; return this;
} }
@ -196,122 +203,122 @@ public class ItemCustomMissilePart extends Item {
if(title != null) if(title != null)
list.add(EnumChatFormatting.DARK_PURPLE + "\"" + title + "\""); list.add(EnumChatFormatting.DARK_PURPLE + "\"" + title + "\"");
try { try {
switch(type) { switch(type) {
case CHIP: case CHIP:
list.add(EnumChatFormatting.BOLD + "Inaccuracy: " + EnumChatFormatting.GRAY + (Float)attributes[0] * 100 + "%"); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.inaccuracy") + ": " + EnumChatFormatting.GRAY + (Float)attributes[0] * 100 + "%");
break; break;
case WARHEAD: case WARHEAD:
list.add(EnumChatFormatting.BOLD + "Size: " + EnumChatFormatting.GRAY + getSize(bottom)); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.size") + ": " + EnumChatFormatting.GRAY + getSize(bottom));
list.add(EnumChatFormatting.BOLD + "Type: " + EnumChatFormatting.GRAY + getWarhead((WarheadType)attributes[0])); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.type") + ": " + EnumChatFormatting.GRAY + getWarhead((WarheadType)attributes[0]));
list.add(EnumChatFormatting.BOLD + "Strength: " + EnumChatFormatting.GRAY + (Float)attributes[1]); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.strength") + ": " + EnumChatFormatting.GRAY + (Float)attributes[1]);
list.add(EnumChatFormatting.BOLD + "Weight: " + EnumChatFormatting.GRAY + (Float)attributes[2] + "t"); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.weight") + ": " + EnumChatFormatting.GRAY + (Float)attributes[2] + "t");
break; break;
case FUSELAGE: case FUSELAGE:
list.add(EnumChatFormatting.BOLD + "Top size: " + EnumChatFormatting.GRAY + getSize(top)); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.topSize") + ": " + EnumChatFormatting.GRAY + getSize(top));
list.add(EnumChatFormatting.BOLD + "Bottom size: " + EnumChatFormatting.GRAY + getSize(bottom)); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.bottomSize") + ": " + EnumChatFormatting.GRAY + getSize(bottom));
list.add(EnumChatFormatting.BOLD + "Fuel type: " + EnumChatFormatting.GRAY + getFuel((FuelType)attributes[0])); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.fuelType") + ": " + EnumChatFormatting.GRAY + getFuel((FuelType)attributes[0]));
list.add(EnumChatFormatting.BOLD + "Fuel amount: " + EnumChatFormatting.GRAY + (Float)attributes[1] + "l"); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.fuelAmount") + ": " + EnumChatFormatting.GRAY + (Float)attributes[1] + "l");
break; break;
case FINS: case FINS:
list.add(EnumChatFormatting.BOLD + "Size: " + EnumChatFormatting.GRAY + getSize(top)); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.size") + ": " + EnumChatFormatting.GRAY + getSize(top));
list.add(EnumChatFormatting.BOLD + "Inaccuracy: " + EnumChatFormatting.GRAY + (Float)attributes[0] * 100 + "%"); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.inaccuracy") + ": " + EnumChatFormatting.GRAY + (Float)attributes[0] * 100 + "%");
break; break;
case THRUSTER: case THRUSTER:
list.add(EnumChatFormatting.BOLD + "Size: " + EnumChatFormatting.GRAY + getSize(top)); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.size") + ": " + EnumChatFormatting.GRAY + getSize(top));
list.add(EnumChatFormatting.BOLD + "Fuel type: " + EnumChatFormatting.GRAY + getFuel((FuelType)attributes[0])); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.fuelType") + ": " + EnumChatFormatting.GRAY + getFuel((FuelType)attributes[0]));
list.add(EnumChatFormatting.BOLD + "Fuel consumption: " + EnumChatFormatting.GRAY + (Float)attributes[1] + "l/tick"); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.fuelConsumption") + ": " + EnumChatFormatting.GRAY + (Float)attributes[1] + "l/tick");
list.add(EnumChatFormatting.BOLD + "Max. payload: " + EnumChatFormatting.GRAY + (Float)attributes[2] + "t"); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.maxPayload") + ": " + EnumChatFormatting.GRAY + (Float)attributes[2] + "t");
break; break;
} }
} catch(Exception ex) { } catch(Exception ex) {
list.add("### I AM ERROR ###"); list.add(I18nUtil.resolveKey("error.generic"));
} }
if(type != PartType.CHIP) if(type != PartType.CHIP)
list.add(EnumChatFormatting.BOLD + "Health: " + EnumChatFormatting.GRAY + health + "HP"); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.health") + ": " + EnumChatFormatting.GRAY + health + "HP");
if(this.rarity != null) if(this.rarity != null)
list.add(EnumChatFormatting.BOLD + "Rarity: " + EnumChatFormatting.GRAY + this.rarity.name); list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.rarity") + ": " + EnumChatFormatting.GRAY + this.rarity.getDisplay());
if(author != null) if(author != null)
list.add(EnumChatFormatting.WHITE + " by " + author); list.add(EnumChatFormatting.WHITE + " " + I18nUtil.resolveKey("part.by") + " " + author);
if(witty != null) if(witty != null)
list.add(EnumChatFormatting.GOLD + " " + EnumChatFormatting.ITALIC + "\"" + witty + "\""); list.add(EnumChatFormatting.GOLD + " " + EnumChatFormatting.ITALIC + "\"" + witty + "\"");
} }
public String getSize(PartSize size) { public String getSize(PartSize size) {
switch(size) { switch(size) {
case ANY: case ANY:
return "Any"; return I18nUtil.resolveKey("part.size.any");
case SIZE_10: case SIZE_10:
return "1.0m"; return "1.0m";
case SIZE_15: case SIZE_15:
return "1.5m"; return "1.5m";
case SIZE_20: case SIZE_20:
return "2.0m"; return "2.0m";
default: default:
return "None"; return I18nUtil.resolveKey("part.size.none");
} }
} }
public String getWarhead(WarheadType type) { public String getWarhead(WarheadType type) {
if(type.labelCustom != null) return type.labelCustom; if(type.labelCustom != null) return type.labelCustom;
switch(type) { switch(type) {
case HE: case HE:
return EnumChatFormatting.YELLOW + "HE"; return EnumChatFormatting.YELLOW + I18nUtil.resolveKey("warhead.he");
case INC: case INC:
return EnumChatFormatting.GOLD + "Incendiary"; return EnumChatFormatting.GOLD + I18nUtil.resolveKey("warhead.incendiary");
case CLUSTER: case CLUSTER:
return EnumChatFormatting.GRAY + "Cluster"; return EnumChatFormatting.GRAY + I18nUtil.resolveKey("warhead.cluster");
case BUSTER: case BUSTER:
return EnumChatFormatting.WHITE + "Bunker Buster"; return EnumChatFormatting.WHITE + I18nUtil.resolveKey("warhead.bunker_buster");
case NUCLEAR: case NUCLEAR:
return EnumChatFormatting.DARK_GREEN + "Nuclear"; return EnumChatFormatting.DARK_GREEN + I18nUtil.resolveKey("warhead.nuclear");
case TX: case TX:
return EnumChatFormatting.DARK_PURPLE + "Thermonuclear (TX)"; return EnumChatFormatting.DARK_PURPLE + I18nUtil.resolveKey("warhead.thermonuclear");
case N2: case N2:
return EnumChatFormatting.RED + ""; return EnumChatFormatting.RED + I18nUtil.resolveKey("warhead.n2");
case BALEFIRE: case BALEFIRE:
return EnumChatFormatting.GREEN + "BF"; return EnumChatFormatting.GREEN + I18nUtil.resolveKey("warhead.balefire");
case SCHRAB: case SCHRAB:
return EnumChatFormatting.AQUA + "Schrabidium"; return EnumChatFormatting.AQUA + I18nUtil.resolveKey("warhead.schrabidium");
case TAINT: case TAINT:
return EnumChatFormatting.DARK_PURPLE + "Taint"; return EnumChatFormatting.DARK_PURPLE + I18nUtil.resolveKey("warhead.taint");
case CLOUD: case CLOUD:
return EnumChatFormatting.LIGHT_PURPLE + "Cloud"; return EnumChatFormatting.LIGHT_PURPLE + I18nUtil.resolveKey("warhead.cloud");
case TURBINE: case TURBINE:
return (System.currentTimeMillis() % 1000 < 500 ? EnumChatFormatting.RED : EnumChatFormatting.LIGHT_PURPLE) + "Turbine"; return (System.currentTimeMillis() % 1000 < 500 ? EnumChatFormatting.RED : EnumChatFormatting.LIGHT_PURPLE) + I18nUtil.resolveKey("warhead.turbine");
default: default:
return EnumChatFormatting.BOLD + "N/A"; return EnumChatFormatting.BOLD + I18nUtil.resolveKey("general.na");
} }
} }
public String getFuel(FuelType type) { public String getFuel(FuelType type) {
switch(type) { switch(type) {
case KEROSENE: case KEROSENE:
return EnumChatFormatting.LIGHT_PURPLE + "Kerosene / Peroxide"; return EnumChatFormatting.LIGHT_PURPLE + I18nUtil.resolveKey("missile.fuel.kerosene_peroxide"); // reuse missile fuel keys
case SOLID: case SOLID:
return EnumChatFormatting.GOLD + "Solid Fuel"; return EnumChatFormatting.GOLD + I18nUtil.resolveKey("missile.fuel.solid");
case HYDROGEN: case HYDROGEN:
return EnumChatFormatting.DARK_AQUA + "Hydrogen / Oxygen"; return EnumChatFormatting.DARK_AQUA + I18nUtil.resolveKey("missile.fuel.ethanol_peroxide"); // closest match
case XENON: case XENON:
return EnumChatFormatting.DARK_PURPLE + "Xenon Gas"; return EnumChatFormatting.DARK_PURPLE + I18nUtil.resolveKey("fuel.xenon");
case BALEFIRE: case BALEFIRE:
return EnumChatFormatting.GREEN + "BF Rocket Fuel / Peroxide"; return EnumChatFormatting.GREEN + I18nUtil.resolveKey("fuel.balefire");
default: default:
return EnumChatFormatting.BOLD + "N/A"; return EnumChatFormatting.BOLD + I18nUtil.resolveKey("general.na");
} }
} }
//am i retarded? //am i retarded?
/* yes */ /* yes */
public ItemCustomMissilePart copy() { public ItemCustomMissilePart copy() {
ItemCustomMissilePart part = new ItemCustomMissilePart(); ItemCustomMissilePart part = new ItemCustomMissilePart();
part.type = this.type; part.type = this.type;
part.top = this.top; part.top = this.top;
@ -320,33 +327,33 @@ public class ItemCustomMissilePart extends Item {
part.attributes = this.attributes; part.attributes = this.attributes;
part.health = this.health; part.health = this.health;
part.setTextureName(this.iconString); part.setTextureName(this.iconString);
return part; return part;
} }
public ItemCustomMissilePart setAuthor(String author) { public ItemCustomMissilePart setAuthor(String author) {
this.author = author; this.author = author;
return this; return this;
} }
public ItemCustomMissilePart setTitle(String title) { public ItemCustomMissilePart setTitle(String title) {
this.title = title; this.title = title;
return this; return this;
} }
public ItemCustomMissilePart setWittyText(String witty) { public ItemCustomMissilePart setWittyText(String witty) {
this.witty = witty; this.witty = witty;
return this; return this;
} }
public ItemCustomMissilePart setHealth(float health) { public ItemCustomMissilePart setHealth(float health) {
this.health = health; this.health = health;
return this; return this;
} }
public ItemCustomMissilePart setRarity(Rarity rarity) { public ItemCustomMissilePart setRarity(Rarity rarity) {
this.rarity = rarity; this.rarity = rarity;
if(this.type == PartType.FUSELAGE) { if(this.type == PartType.FUSELAGE) {
if(this.top == PartSize.SIZE_10) if(this.top == PartSize.SIZE_10)
ItemLootCrate.list10.add(this); ItemLootCrate.list10.add(this);

View File

@ -3,53 +3,57 @@ package com.hbm.items.weapon;
import java.util.List; import java.util.List;
import com.hbm.items.ItemCustomLore; import com.hbm.items.ItemCustomLore;
import com.hbm.util.i18n.I18nUtil;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
public class ItemMissile extends ItemCustomLore { public class ItemMissile extends ItemCustomLore {
public final MissileFormFactor formFactor; public final MissileFormFactor formFactor;
public final MissileTier tier; public final MissileTier tier;
public final MissileFuel fuel; public final MissileFuel fuel;
public int fuelCap; public int fuelCap;
public boolean launchable = true; public boolean launchable = true;
public ItemMissile(MissileFormFactor form, MissileTier tier) { public ItemMissile(MissileFormFactor form, MissileTier tier) {
this(form, tier, form.defaultFuel); this(form, tier, form.defaultFuel);
} }
public ItemMissile(MissileFormFactor form, MissileTier tier, MissileFuel fuel) { public ItemMissile(MissileFormFactor form, MissileTier tier, MissileFuel fuel) {
this.formFactor = form; this.formFactor = form;
this.tier = tier; this.tier = tier;
this.fuel = fuel; this.fuel = fuel;
this.setFuelCap(this.fuel.defaultCap); this.setFuelCap(this.fuel.defaultCap);
} }
public ItemMissile notLaunchable() { public ItemMissile notLaunchable() {
this.launchable = false; this.launchable = false;
return this; return this;
} }
public ItemMissile setFuelCap(int fuelCap) { public ItemMissile setFuelCap(int fuelCap) {
this.fuelCap = fuelCap; this.fuelCap = fuelCap;
return this; return this;
} }
@Override @Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) { public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) {
list.add(EnumChatFormatting.ITALIC + this.tier.display); // Tier localized: missile.tier.tier0, missile.tier.tier1, ...
String tierKey = "missile.tier." + this.tier.name().toLowerCase();
list.add(EnumChatFormatting.ITALIC + I18nUtil.resolveKey(tierKey));
if(!this.launchable) { if(!this.launchable) {
list.add(EnumChatFormatting.RED + "Not launchable!"); list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("gui.missile.notLaunchable"));
} else { } else {
list.add("Fuel: " + this.fuel.display); // Fuel localized & colored via enum helper
if(this.fuelCap > 0) list.add("Fuel capacity: " + this.fuelCap + "mB"); list.add(I18nUtil.resolveKey("gui.missile.fuel") + ": " + this.fuel.getDisplay());
if(this.fuelCap > 0) list.add(I18nUtil.resolveKey("gui.missile.fuelCapacity") + ": " + this.fuelCap + "mB");
super.addInformation(itemstack, player, list, bool); super.addInformation(itemstack, player, list, bool);
} }
} }
public enum MissileFormFactor { public enum MissileFormFactor {
ABM(MissileFuel.SOLID), ABM(MissileFuel.SOLID),
MICRO(MissileFuel.SOLID), MICRO(MissileFuel.SOLID),
@ -58,41 +62,48 @@ public class ItemMissile extends ItemCustomLore {
HUGE(MissileFuel.KEROSENE_LOXY), HUGE(MissileFuel.KEROSENE_LOXY),
ATLAS(MissileFuel.JETFUEL_LOXY), ATLAS(MissileFuel.JETFUEL_LOXY),
OTHER(MissileFuel.KEROSENE_PEROXIDE); OTHER(MissileFuel.KEROSENE_PEROXIDE);
protected MissileFuel defaultFuel; protected MissileFuel defaultFuel;
private MissileFormFactor(MissileFuel defaultFuel) { private MissileFormFactor(MissileFuel defaultFuel) {
this.defaultFuel = defaultFuel; this.defaultFuel = defaultFuel;
} }
} }
public enum MissileTier { public enum MissileTier {
TIER0("Tier 0"), TIER0("Tier 0"),
TIER1("Tier 1"), TIER1("Tier 1"),
TIER2("Tier 2"), TIER2("Tier 2"),
TIER3("Tier 3"), TIER3("Tier 3"),
TIER4("Tier 4"); TIER4("Tier 4");
public String display; public String display;
private MissileTier(String display) { private MissileTier(String display) {
this.display = display; this.display = display;
} }
} }
public enum MissileFuel { public enum MissileFuel {
SOLID(EnumChatFormatting.GOLD + "Solid Fuel (pre-fueled)", 0), SOLID("missile.fuel.solid" + " (pre-fueled)", EnumChatFormatting.GOLD, 0),
ETHANOL_PEROXIDE(EnumChatFormatting.AQUA + "Ethanol / Hydrogen Peroxide", 4_000), ETHANOL_PEROXIDE("missile.fuel.ethanol_peroxide", EnumChatFormatting.AQUA, 4_000),
KEROSENE_PEROXIDE(EnumChatFormatting.BLUE + "Kerosene / Hydrogen Peroxide", 8_000), KEROSENE_PEROXIDE("missile.fuel.kerosene_peroxide", EnumChatFormatting.BLUE, 8_000),
KEROSENE_LOXY(EnumChatFormatting.LIGHT_PURPLE + "Kerosene / Liquid Oxygen", 12_000), KEROSENE_LOXY("missile.fuel.kerosene_loxy", EnumChatFormatting.LIGHT_PURPLE, 12_000),
JETFUEL_LOXY(EnumChatFormatting.RED + "Jet Fuel / Liquid Oxygen", 16_000); JETFUEL_LOXY("missile.fuel.jetfuel_loxy", EnumChatFormatting.RED, 16_000);
public String display; private final String key;
public int defaultCap; public final EnumChatFormatting color;
public final int defaultCap;
private MissileFuel(String display, int defaultCap) {
this.display = display; private MissileFuel(String key, EnumChatFormatting color, int defaultCap) {
this.key = key;
this.color = color;
this.defaultCap = defaultCap; this.defaultCap = defaultCap;
} }
/** Returns a color localized string for display */
public String getDisplay() {
return color + I18nUtil.resolveKey(this.key);
}
} }
} }