mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
I18n implementation for missiles and sattelites
This commit is contained in:
parent
fa6b4faeee
commit
60b9e1fb18
@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import com.hbm.items.ISatChip;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.util.i18n.I18nUtil;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@ -14,36 +15,36 @@ public class ItemSatChip extends Item implements ISatChip {
|
||||
@Override
|
||||
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)
|
||||
list.add("Gives you an achievement. That's it.");
|
||||
|
||||
list.add(I18nUtil.resolveKey("satchip.foeq"));
|
||||
|
||||
if(this == ModItems.sat_gerald) {
|
||||
list.add("Single use.");
|
||||
list.add("Requires orbital module.");
|
||||
list.add("Melter of CPUs, bane of every server owner.");
|
||||
list.add(I18nUtil.resolveKey("satchip.gerald.line1"));
|
||||
list.add(I18nUtil.resolveKey("satchip.gerald.line2"));
|
||||
list.add(I18nUtil.resolveKey("satchip.gerald.line3"));
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
list.add("Displays currently loaded chunks.");
|
||||
|
||||
list.add(I18nUtil.resolveKey("satchip.mapper"));
|
||||
|
||||
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)
|
||||
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)
|
||||
list.add("Shows a map of active entities.");
|
||||
|
||||
list.add(I18nUtil.resolveKey("satchip.radar"));
|
||||
|
||||
if(this == ModItems.sat_resonator)
|
||||
list.add("Allows for teleportation with no cooldown.");
|
||||
|
||||
list.add(I18nUtil.resolveKey("satchip.resonator"));
|
||||
|
||||
if(this == ModItems.sat_scanner)
|
||||
list.add("Creates a topdown map of underground ores.");
|
||||
list.add(I18nUtil.resolveKey("satchip.scanner"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import com.hbm.handler.MissileStruct;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.weapon.ItemCustomMissilePart.FuelType;
|
||||
import com.hbm.items.weapon.ItemCustomMissilePart.WarheadType;
|
||||
import com.hbm.util.i18n.I18nUtil;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -15,35 +16,35 @@ import net.minecraft.util.EnumChatFormatting;
|
||||
public class ItemCustomMissile extends Item {
|
||||
|
||||
public static ItemStack buildMissile(Item chip, Item warhead, Item fuselage, Item stability, Item thruster) {
|
||||
|
||||
|
||||
if(stability == null) {
|
||||
return buildMissile(new ItemStack(chip), new ItemStack(warhead), new ItemStack(fuselage), null, new ItemStack(thruster));
|
||||
} else {
|
||||
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) {
|
||||
|
||||
|
||||
ItemStack missile = new ItemStack(ModItems.missile_custom);
|
||||
|
||||
writeToNBT(missile, "chip", Item.getIdFromItem(chip.getItem()));
|
||||
writeToNBT(missile, "warhead", Item.getIdFromItem(warhead.getItem()));
|
||||
writeToNBT(missile, "fuselage", Item.getIdFromItem(fuselage.getItem()));
|
||||
writeToNBT(missile, "thruster", Item.getIdFromItem(thruster.getItem()));
|
||||
|
||||
|
||||
if(stability != null)
|
||||
writeToNBT(missile, "stability", Item.getIdFromItem(stability.getItem()));
|
||||
|
||||
|
||||
return missile;
|
||||
}
|
||||
|
||||
|
||||
private static void writeToNBT(ItemStack stack, String key, int value) {
|
||||
if(!stack.hasTagCompound())
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
stack.stackTagCompound.setInteger(key, value);
|
||||
}
|
||||
|
||||
|
||||
public static int readFromNBT(ItemStack stack, String key) {
|
||||
if(!stack.hasTagCompound())
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
@ -52,53 +53,63 @@ public class ItemCustomMissile extends Item {
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
|
||||
|
||||
|
||||
if(!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
|
||||
try {
|
||||
ItemCustomMissilePart chip = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "chip"));
|
||||
ItemCustomMissilePart warhead = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "warhead"));
|
||||
ItemCustomMissilePart fuselage = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "fuselage"));
|
||||
ItemCustomMissilePart stability = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "stability"));
|
||||
ItemCustomMissilePart thruster = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "thruster"));
|
||||
|
||||
list.add(EnumChatFormatting.BOLD + "Warhead: " + EnumChatFormatting.GRAY + warhead.getWarhead((WarheadType)warhead.attributes[0]));
|
||||
list.add(EnumChatFormatting.BOLD + "Strength: " + EnumChatFormatting.GRAY + (Float)warhead.attributes[1]);
|
||||
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");
|
||||
list.add(EnumChatFormatting.BOLD + "Chip inaccuracy: " + EnumChatFormatting.GRAY + (Float)chip.attributes[0] * 100 + "%");
|
||||
|
||||
|
||||
// warhead name
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("gui.missile.warhead") + ": " + EnumChatFormatting.GRAY + warhead.getWarhead((WarheadType)warhead.attributes[0]));
|
||||
|
||||
// strength
|
||||
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)
|
||||
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
|
||||
list.add(EnumChatFormatting.BOLD + "Fin inaccuracy: " + EnumChatFormatting.GRAY + "100%");
|
||||
|
||||
list.add(EnumChatFormatting.BOLD + "Size: " + EnumChatFormatting.GRAY + fuselage.getSize(fuselage.top) + "/" + fuselage.getSize(fuselage.bottom));
|
||||
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("gui.missile.finInaccuracy") + ": " + EnumChatFormatting.GRAY + "100%");
|
||||
|
||||
// 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;
|
||||
if(stability != null)
|
||||
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) {
|
||||
list.add(EnumChatFormatting.RED + "### I AM ERROR ###");
|
||||
list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("error.generic"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static MissileStruct getStruct(ItemStack stack) {
|
||||
|
||||
|
||||
if(stack == null || !(stack.getItem() instanceof ItemCustomMissile))
|
||||
return null;
|
||||
|
||||
|
||||
ItemCustomMissilePart warhead = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "warhead"));
|
||||
ItemCustomMissilePart fuselage = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "fuselage"));
|
||||
ItemCustomMissilePart stability = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "stability"));
|
||||
ItemCustomMissilePart thruster = (ItemCustomMissilePart) Item.getItemById(readFromNBT(stack, "thruster"));
|
||||
|
||||
|
||||
MissileStruct missile = new MissileStruct(warhead, fuselage, stability, thruster);
|
||||
|
||||
|
||||
return missile;
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import com.hbm.entity.missile.EntityMissileCustom;
|
||||
import com.hbm.items.special.ItemLootCrate;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.util.i18n.I18nUtil;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@ -15,7 +16,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public class ItemCustomMissilePart extends Item {
|
||||
|
||||
|
||||
public PartType type;
|
||||
public PartSize top;
|
||||
public PartSize bottom;
|
||||
@ -24,37 +25,37 @@ public class ItemCustomMissilePart extends Item {
|
||||
private String title;
|
||||
private String author;
|
||||
private String witty;
|
||||
|
||||
|
||||
public ItemCustomMissilePart() {
|
||||
this.setMaxStackSize(1);
|
||||
this.setCreativeTab(MainRegistry.missileTab);
|
||||
}
|
||||
|
||||
|
||||
public static HashMap<Integer, ItemCustomMissilePart> parts = new HashMap();
|
||||
|
||||
|
||||
/**
|
||||
* == Chips ==
|
||||
* [0]: inaccuracy
|
||||
*
|
||||
*
|
||||
* == Warheads ==
|
||||
* [0]: type
|
||||
* [1]: strength/radius/cluster count
|
||||
* [2]: weight
|
||||
*
|
||||
*
|
||||
* == Fuselages ==
|
||||
* [0]: type
|
||||
* [1]: tank size
|
||||
*
|
||||
*
|
||||
* == Stability ==
|
||||
* [0]: inaccuracy mod
|
||||
*
|
||||
*
|
||||
* == Thrusters ===
|
||||
* [0]: type
|
||||
* [1]: consumption
|
||||
* [2]: lift strength
|
||||
*/
|
||||
public Object[] attributes;
|
||||
|
||||
|
||||
public enum PartType {
|
||||
CHIP,
|
||||
WARHEAD,
|
||||
@ -62,9 +63,9 @@ public class ItemCustomMissilePart extends Item {
|
||||
FINS,
|
||||
THRUSTER
|
||||
}
|
||||
|
||||
|
||||
public enum PartSize {
|
||||
|
||||
|
||||
//for chips
|
||||
ANY,
|
||||
//for missile tips and thrusters
|
||||
@ -74,9 +75,9 @@ public class ItemCustomMissilePart extends Item {
|
||||
SIZE_15,
|
||||
SIZE_20
|
||||
}
|
||||
|
||||
|
||||
public enum WarheadType {
|
||||
|
||||
|
||||
HE,
|
||||
INC,
|
||||
BUSTER,
|
||||
@ -89,8 +90,8 @@ public class ItemCustomMissilePart extends Item {
|
||||
TAINT,
|
||||
CLOUD,
|
||||
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;
|
||||
|
||||
/** 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 */
|
||||
public String labelCustom = null;
|
||||
}
|
||||
|
||||
|
||||
public enum FuelType {
|
||||
|
||||
|
||||
KEROSENE,
|
||||
SOLID,
|
||||
HYDROGEN,
|
||||
XENON,
|
||||
BALEFIRE
|
||||
}
|
||||
|
||||
|
||||
public enum Rarity {
|
||||
|
||||
COMMON(EnumChatFormatting.GRAY + "Common"),
|
||||
UNCOMMON(EnumChatFormatting.YELLOW + "Uncommon"),
|
||||
RARE(EnumChatFormatting.AQUA + "Rare"),
|
||||
EPIC(EnumChatFormatting.LIGHT_PURPLE + "Epic"),
|
||||
LEGENDARY(EnumChatFormatting.DARK_GREEN + "Legendary"),
|
||||
SEWS_CLOTHES_AND_SUCKS_HORSE_COCK(EnumChatFormatting.DARK_AQUA + "Strange");
|
||||
|
||||
String name;
|
||||
|
||||
Rarity(String name) {
|
||||
this.name = name;
|
||||
|
||||
COMMON("part.rarity.common", EnumChatFormatting.GRAY),
|
||||
UNCOMMON("part.rarity.uncommon", EnumChatFormatting.YELLOW),
|
||||
RARE("part.rarity.rare", EnumChatFormatting.AQUA),
|
||||
EPIC("part.rarity.epic", EnumChatFormatting.LIGHT_PURPLE),
|
||||
LEGENDARY("part.rarity.legendary", EnumChatFormatting.DARK_GREEN),
|
||||
SEWS_CLOTHES_AND_SUCKS_HORSE_COCK("part.rarity.strange", EnumChatFormatting.DARK_AQUA);
|
||||
|
||||
private final String key;
|
||||
private final EnumChatFormatting color;
|
||||
|
||||
Rarity(String key, EnumChatFormatting color) {
|
||||
this.key = key;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getDisplay() {
|
||||
return color + I18nUtil.resolveKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ItemCustomMissilePart makeChip(float inaccuracy) {
|
||||
|
||||
|
||||
this.type = PartType.CHIP;
|
||||
this.top = PartSize.ANY;
|
||||
this.bottom = PartSize.ANY;
|
||||
this.attributes = new Object[] { inaccuracy };
|
||||
|
||||
|
||||
parts.put(this.hashCode(), this);
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ItemCustomMissilePart makeWarhead(WarheadType type, float punch, float weight, PartSize size) {
|
||||
|
||||
this.type = PartType.WARHEAD;
|
||||
@ -145,12 +152,12 @@ public class ItemCustomMissilePart extends Item {
|
||||
this.bottom = size;
|
||||
this.attributes = new Object[] { type, punch, weight };
|
||||
setTextureName(RefStrings.MODID + ":mp_warhead");
|
||||
|
||||
|
||||
parts.put(this.hashCode(), this);
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ItemCustomMissilePart makeFuselage(FuelType type, float fuel, PartSize top, PartSize bottom) {
|
||||
|
||||
this.type = PartType.FUSELAGE;
|
||||
@ -158,12 +165,12 @@ public class ItemCustomMissilePart extends Item {
|
||||
this.bottom = bottom;
|
||||
attributes = new Object[] { type, fuel };
|
||||
setTextureName(RefStrings.MODID + ":mp_fuselage");
|
||||
|
||||
|
||||
parts.put(this.hashCode(), this);
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ItemCustomMissilePart makeStability(float inaccuracy, PartSize size) {
|
||||
|
||||
this.type = PartType.FINS;
|
||||
@ -171,12 +178,12 @@ public class ItemCustomMissilePart extends Item {
|
||||
this.bottom = size;
|
||||
this.attributes = new Object[] { inaccuracy };
|
||||
setTextureName(RefStrings.MODID + ":mp_stability");
|
||||
|
||||
|
||||
parts.put(this.hashCode(), this);
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ItemCustomMissilePart makeThruster(FuelType type, float consumption, float lift, PartSize size) {
|
||||
|
||||
this.type = PartType.THRUSTER;
|
||||
@ -184,9 +191,9 @@ public class ItemCustomMissilePart extends Item {
|
||||
this.bottom = PartSize.NONE;
|
||||
this.attributes = new Object[] { type, consumption, lift };
|
||||
setTextureName(RefStrings.MODID + ":mp_thruster");
|
||||
|
||||
|
||||
parts.put(this.hashCode(), this);
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -196,122 +203,122 @@ public class ItemCustomMissilePart extends Item {
|
||||
|
||||
if(title != null)
|
||||
list.add(EnumChatFormatting.DARK_PURPLE + "\"" + title + "\"");
|
||||
|
||||
|
||||
try {
|
||||
switch(type) {
|
||||
case CHIP:
|
||||
list.add(EnumChatFormatting.BOLD + "Inaccuracy: " + EnumChatFormatting.GRAY + (Float)attributes[0] * 100 + "%");
|
||||
break;
|
||||
case WARHEAD:
|
||||
list.add(EnumChatFormatting.BOLD + "Size: " + EnumChatFormatting.GRAY + getSize(bottom));
|
||||
list.add(EnumChatFormatting.BOLD + "Type: " + EnumChatFormatting.GRAY + getWarhead((WarheadType)attributes[0]));
|
||||
list.add(EnumChatFormatting.BOLD + "Strength: " + EnumChatFormatting.GRAY + (Float)attributes[1]);
|
||||
list.add(EnumChatFormatting.BOLD + "Weight: " + EnumChatFormatting.GRAY + (Float)attributes[2] + "t");
|
||||
break;
|
||||
case FUSELAGE:
|
||||
list.add(EnumChatFormatting.BOLD + "Top size: " + EnumChatFormatting.GRAY + getSize(top));
|
||||
list.add(EnumChatFormatting.BOLD + "Bottom size: " + EnumChatFormatting.GRAY + getSize(bottom));
|
||||
list.add(EnumChatFormatting.BOLD + "Fuel type: " + EnumChatFormatting.GRAY + getFuel((FuelType)attributes[0]));
|
||||
list.add(EnumChatFormatting.BOLD + "Fuel amount: " + EnumChatFormatting.GRAY + (Float)attributes[1] + "l");
|
||||
break;
|
||||
case FINS:
|
||||
list.add(EnumChatFormatting.BOLD + "Size: " + EnumChatFormatting.GRAY + getSize(top));
|
||||
list.add(EnumChatFormatting.BOLD + "Inaccuracy: " + EnumChatFormatting.GRAY + (Float)attributes[0] * 100 + "%");
|
||||
break;
|
||||
case THRUSTER:
|
||||
list.add(EnumChatFormatting.BOLD + "Size: " + EnumChatFormatting.GRAY + getSize(top));
|
||||
list.add(EnumChatFormatting.BOLD + "Fuel type: " + EnumChatFormatting.GRAY + getFuel((FuelType)attributes[0]));
|
||||
list.add(EnumChatFormatting.BOLD + "Fuel consumption: " + EnumChatFormatting.GRAY + (Float)attributes[1] + "l/tick");
|
||||
list.add(EnumChatFormatting.BOLD + "Max. payload: " + EnumChatFormatting.GRAY + (Float)attributes[2] + "t");
|
||||
break;
|
||||
case CHIP:
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.inaccuracy") + ": " + EnumChatFormatting.GRAY + (Float)attributes[0] * 100 + "%");
|
||||
break;
|
||||
case WARHEAD:
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.size") + ": " + EnumChatFormatting.GRAY + getSize(bottom));
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.type") + ": " + EnumChatFormatting.GRAY + getWarhead((WarheadType)attributes[0]));
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.strength") + ": " + EnumChatFormatting.GRAY + (Float)attributes[1]);
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.weight") + ": " + EnumChatFormatting.GRAY + (Float)attributes[2] + "t");
|
||||
break;
|
||||
case FUSELAGE:
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.topSize") + ": " + EnumChatFormatting.GRAY + getSize(top));
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.bottomSize") + ": " + EnumChatFormatting.GRAY + getSize(bottom));
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.fuelType") + ": " + EnumChatFormatting.GRAY + getFuel((FuelType)attributes[0]));
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.fuelAmount") + ": " + EnumChatFormatting.GRAY + (Float)attributes[1] + "l");
|
||||
break;
|
||||
case FINS:
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.size") + ": " + EnumChatFormatting.GRAY + getSize(top));
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.inaccuracy") + ": " + EnumChatFormatting.GRAY + (Float)attributes[0] * 100 + "%");
|
||||
break;
|
||||
case THRUSTER:
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.size") + ": " + EnumChatFormatting.GRAY + getSize(top));
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.fuelType") + ": " + EnumChatFormatting.GRAY + getFuel((FuelType)attributes[0]));
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.fuelConsumption") + ": " + EnumChatFormatting.GRAY + (Float)attributes[1] + "l/tick");
|
||||
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("part.maxPayload") + ": " + EnumChatFormatting.GRAY + (Float)attributes[2] + "t");
|
||||
break;
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
list.add("### I AM ERROR ###");
|
||||
list.add(I18nUtil.resolveKey("error.generic"));
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
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)
|
||||
list.add(EnumChatFormatting.WHITE + " by " + author);
|
||||
list.add(EnumChatFormatting.WHITE + " " + I18nUtil.resolveKey("part.by") + " " + author);
|
||||
if(witty != null)
|
||||
list.add(EnumChatFormatting.GOLD + " " + EnumChatFormatting.ITALIC + "\"" + witty + "\"");
|
||||
}
|
||||
|
||||
|
||||
public String getSize(PartSize size) {
|
||||
|
||||
|
||||
switch(size) {
|
||||
case ANY:
|
||||
return "Any";
|
||||
case SIZE_10:
|
||||
return "1.0m";
|
||||
case SIZE_15:
|
||||
return "1.5m";
|
||||
case SIZE_20:
|
||||
return "2.0m";
|
||||
default:
|
||||
return "None";
|
||||
case ANY:
|
||||
return I18nUtil.resolveKey("part.size.any");
|
||||
case SIZE_10:
|
||||
return "1.0m";
|
||||
case SIZE_15:
|
||||
return "1.5m";
|
||||
case SIZE_20:
|
||||
return "2.0m";
|
||||
default:
|
||||
return I18nUtil.resolveKey("part.size.none");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getWarhead(WarheadType type) {
|
||||
|
||||
|
||||
if(type.labelCustom != null) return type.labelCustom;
|
||||
|
||||
|
||||
switch(type) {
|
||||
case HE:
|
||||
return EnumChatFormatting.YELLOW + "HE";
|
||||
case INC:
|
||||
return EnumChatFormatting.GOLD + "Incendiary";
|
||||
case CLUSTER:
|
||||
return EnumChatFormatting.GRAY + "Cluster";
|
||||
case BUSTER:
|
||||
return EnumChatFormatting.WHITE + "Bunker Buster";
|
||||
case NUCLEAR:
|
||||
return EnumChatFormatting.DARK_GREEN + "Nuclear";
|
||||
case TX:
|
||||
return EnumChatFormatting.DARK_PURPLE + "Thermonuclear (TX)";
|
||||
case N2:
|
||||
return EnumChatFormatting.RED + "N²";
|
||||
case BALEFIRE:
|
||||
return EnumChatFormatting.GREEN + "BF";
|
||||
case SCHRAB:
|
||||
return EnumChatFormatting.AQUA + "Schrabidium";
|
||||
case TAINT:
|
||||
return EnumChatFormatting.DARK_PURPLE + "Taint";
|
||||
case CLOUD:
|
||||
return EnumChatFormatting.LIGHT_PURPLE + "Cloud";
|
||||
case TURBINE:
|
||||
return (System.currentTimeMillis() % 1000 < 500 ? EnumChatFormatting.RED : EnumChatFormatting.LIGHT_PURPLE) + "Turbine";
|
||||
default:
|
||||
return EnumChatFormatting.BOLD + "N/A";
|
||||
case HE:
|
||||
return EnumChatFormatting.YELLOW + I18nUtil.resolveKey("warhead.he");
|
||||
case INC:
|
||||
return EnumChatFormatting.GOLD + I18nUtil.resolveKey("warhead.incendiary");
|
||||
case CLUSTER:
|
||||
return EnumChatFormatting.GRAY + I18nUtil.resolveKey("warhead.cluster");
|
||||
case BUSTER:
|
||||
return EnumChatFormatting.WHITE + I18nUtil.resolveKey("warhead.bunker_buster");
|
||||
case NUCLEAR:
|
||||
return EnumChatFormatting.DARK_GREEN + I18nUtil.resolveKey("warhead.nuclear");
|
||||
case TX:
|
||||
return EnumChatFormatting.DARK_PURPLE + I18nUtil.resolveKey("warhead.thermonuclear");
|
||||
case N2:
|
||||
return EnumChatFormatting.RED + I18nUtil.resolveKey("warhead.n2");
|
||||
case BALEFIRE:
|
||||
return EnumChatFormatting.GREEN + I18nUtil.resolveKey("warhead.balefire");
|
||||
case SCHRAB:
|
||||
return EnumChatFormatting.AQUA + I18nUtil.resolveKey("warhead.schrabidium");
|
||||
case TAINT:
|
||||
return EnumChatFormatting.DARK_PURPLE + I18nUtil.resolveKey("warhead.taint");
|
||||
case CLOUD:
|
||||
return EnumChatFormatting.LIGHT_PURPLE + I18nUtil.resolveKey("warhead.cloud");
|
||||
case TURBINE:
|
||||
return (System.currentTimeMillis() % 1000 < 500 ? EnumChatFormatting.RED : EnumChatFormatting.LIGHT_PURPLE) + I18nUtil.resolveKey("warhead.turbine");
|
||||
default:
|
||||
return EnumChatFormatting.BOLD + I18nUtil.resolveKey("general.na");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getFuel(FuelType type) {
|
||||
|
||||
|
||||
switch(type) {
|
||||
case KEROSENE:
|
||||
return EnumChatFormatting.LIGHT_PURPLE + "Kerosene / Peroxide";
|
||||
case SOLID:
|
||||
return EnumChatFormatting.GOLD + "Solid Fuel";
|
||||
case HYDROGEN:
|
||||
return EnumChatFormatting.DARK_AQUA + "Hydrogen / Oxygen";
|
||||
case XENON:
|
||||
return EnumChatFormatting.DARK_PURPLE + "Xenon Gas";
|
||||
case BALEFIRE:
|
||||
return EnumChatFormatting.GREEN + "BF Rocket Fuel / Peroxide";
|
||||
default:
|
||||
return EnumChatFormatting.BOLD + "N/A";
|
||||
case KEROSENE:
|
||||
return EnumChatFormatting.LIGHT_PURPLE + I18nUtil.resolveKey("missile.fuel.kerosene_peroxide"); // reuse missile fuel keys
|
||||
case SOLID:
|
||||
return EnumChatFormatting.GOLD + I18nUtil.resolveKey("missile.fuel.solid");
|
||||
case HYDROGEN:
|
||||
return EnumChatFormatting.DARK_AQUA + I18nUtil.resolveKey("missile.fuel.ethanol_peroxide"); // closest match
|
||||
case XENON:
|
||||
return EnumChatFormatting.DARK_PURPLE + I18nUtil.resolveKey("fuel.xenon");
|
||||
case BALEFIRE:
|
||||
return EnumChatFormatting.GREEN + I18nUtil.resolveKey("fuel.balefire");
|
||||
default:
|
||||
return EnumChatFormatting.BOLD + I18nUtil.resolveKey("general.na");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//am i retarded?
|
||||
/* yes */
|
||||
public ItemCustomMissilePart copy() {
|
||||
|
||||
|
||||
ItemCustomMissilePart part = new ItemCustomMissilePart();
|
||||
part.type = this.type;
|
||||
part.top = this.top;
|
||||
@ -320,33 +327,33 @@ public class ItemCustomMissilePart extends Item {
|
||||
part.attributes = this.attributes;
|
||||
part.health = this.health;
|
||||
part.setTextureName(this.iconString);
|
||||
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
|
||||
public ItemCustomMissilePart setAuthor(String author) {
|
||||
this.author = author;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ItemCustomMissilePart setTitle(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ItemCustomMissilePart setWittyText(String witty) {
|
||||
this.witty = witty;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ItemCustomMissilePart setHealth(float health) {
|
||||
this.health = health;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ItemCustomMissilePart setRarity(Rarity rarity) {
|
||||
this.rarity = rarity;
|
||||
|
||||
|
||||
if(this.type == PartType.FUSELAGE) {
|
||||
if(this.top == PartSize.SIZE_10)
|
||||
ItemLootCrate.list10.add(this);
|
||||
|
||||
@ -3,53 +3,57 @@ package com.hbm.items.weapon;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.items.ItemCustomLore;
|
||||
import com.hbm.util.i18n.I18nUtil;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public class ItemMissile extends ItemCustomLore {
|
||||
|
||||
|
||||
public final MissileFormFactor formFactor;
|
||||
public final MissileTier tier;
|
||||
public final MissileFuel fuel;
|
||||
public int fuelCap;
|
||||
public boolean launchable = true;
|
||||
|
||||
|
||||
public ItemMissile(MissileFormFactor form, MissileTier tier) {
|
||||
this(form, tier, form.defaultFuel);
|
||||
}
|
||||
|
||||
|
||||
public ItemMissile(MissileFormFactor form, MissileTier tier, MissileFuel fuel) {
|
||||
this.formFactor = form;
|
||||
this.tier = tier;
|
||||
this.fuel = fuel;
|
||||
this.setFuelCap(this.fuel.defaultCap);
|
||||
}
|
||||
|
||||
|
||||
public ItemMissile notLaunchable() {
|
||||
this.launchable = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ItemMissile setFuelCap(int fuelCap) {
|
||||
this.fuelCap = fuelCap;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
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) {
|
||||
list.add(EnumChatFormatting.RED + "Not launchable!");
|
||||
list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("gui.missile.notLaunchable"));
|
||||
} else {
|
||||
list.add("Fuel: " + this.fuel.display);
|
||||
if(this.fuelCap > 0) list.add("Fuel capacity: " + this.fuelCap + "mB");
|
||||
// Fuel localized & colored via enum helper
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum MissileFormFactor {
|
||||
ABM(MissileFuel.SOLID),
|
||||
MICRO(MissileFuel.SOLID),
|
||||
@ -58,41 +62,48 @@ public class ItemMissile extends ItemCustomLore {
|
||||
HUGE(MissileFuel.KEROSENE_LOXY),
|
||||
ATLAS(MissileFuel.JETFUEL_LOXY),
|
||||
OTHER(MissileFuel.KEROSENE_PEROXIDE);
|
||||
|
||||
|
||||
protected MissileFuel defaultFuel;
|
||||
|
||||
|
||||
private MissileFormFactor(MissileFuel defaultFuel) {
|
||||
this.defaultFuel = defaultFuel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum MissileTier {
|
||||
TIER0("Tier 0"),
|
||||
TIER1("Tier 1"),
|
||||
TIER2("Tier 2"),
|
||||
TIER3("Tier 3"),
|
||||
TIER4("Tier 4");
|
||||
|
||||
|
||||
public String display;
|
||||
|
||||
|
||||
private MissileTier(String display) {
|
||||
this.display = display;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum MissileFuel {
|
||||
SOLID(EnumChatFormatting.GOLD + "Solid Fuel (pre-fueled)", 0),
|
||||
ETHANOL_PEROXIDE(EnumChatFormatting.AQUA + "Ethanol / Hydrogen Peroxide", 4_000),
|
||||
KEROSENE_PEROXIDE(EnumChatFormatting.BLUE + "Kerosene / Hydrogen Peroxide", 8_000),
|
||||
KEROSENE_LOXY(EnumChatFormatting.LIGHT_PURPLE + "Kerosene / Liquid Oxygen", 12_000),
|
||||
JETFUEL_LOXY(EnumChatFormatting.RED + "Jet Fuel / Liquid Oxygen", 16_000);
|
||||
|
||||
public String display;
|
||||
public int defaultCap;
|
||||
|
||||
private MissileFuel(String display, int defaultCap) {
|
||||
this.display = display;
|
||||
SOLID("missile.fuel.solid" + " (pre-fueled)", EnumChatFormatting.GOLD, 0),
|
||||
ETHANOL_PEROXIDE("missile.fuel.ethanol_peroxide", EnumChatFormatting.AQUA, 4_000),
|
||||
KEROSENE_PEROXIDE("missile.fuel.kerosene_peroxide", EnumChatFormatting.BLUE, 8_000),
|
||||
KEROSENE_LOXY("missile.fuel.kerosene_loxy", EnumChatFormatting.LIGHT_PURPLE, 12_000),
|
||||
JETFUEL_LOXY("missile.fuel.jetfuel_loxy", EnumChatFormatting.RED, 16_000);
|
||||
|
||||
private final String key;
|
||||
public final EnumChatFormatting color;
|
||||
public final int defaultCap;
|
||||
|
||||
private MissileFuel(String key, EnumChatFormatting color, int defaultCap) {
|
||||
this.key = key;
|
||||
this.color = color;
|
||||
this.defaultCap = defaultCap;
|
||||
}
|
||||
|
||||
/** Returns a color localized string for display */
|
||||
public String getDisplay() {
|
||||
return color + I18nUtil.resolveKey(this.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user