From a41cb4998f083b2fa6681c0fd63a6c95429cd70a Mon Sep 17 00:00:00 2001 From: Calclavia Date: Thu, 27 Feb 2014 20:57:56 +0800 Subject: [PATCH] Fixed fluid names with other mods --- .../electrical/generator/TileGenerator.java | 29 ++++++++++--------- .../electrical/wire/PartConductor.java | 4 +-- .../core/resource/ResourceGenerator.java | 16 ++++++++-- .../resource/fluid/ItemOreResourceBucket.java | 18 ++---------- .../languages/en_US.properties | 4 +-- 5 files changed, 36 insertions(+), 35 deletions(-) diff --git a/electrical/src/main/java/resonantinduction/electrical/generator/TileGenerator.java b/electrical/src/main/java/resonantinduction/electrical/generator/TileGenerator.java index 385b7aff..1c347bee 100644 --- a/electrical/src/main/java/resonantinduction/electrical/generator/TileGenerator.java +++ b/electrical/src/main/java/resonantinduction/electrical/generator/TileGenerator.java @@ -92,25 +92,28 @@ public class TileGenerator extends TileElectrical implements IRotatable { long torqueRatio = (long) ((gearRatio + 1) / 4d * (extract)); - final float maxAngularVelocity = extract / (float) torqueRatio; + if (torqueRatio > 0) + { + final float maxAngularVelocity = extract / (float) torqueRatio; - final long maxTorque = (long) (((double) extract) / maxAngularVelocity); + final long maxTorque = (long) (((double) extract) / maxAngularVelocity); - float setAngularVelocity = maxAngularVelocity; - long setTorque = maxTorque; + float setAngularVelocity = maxAngularVelocity; + long setTorque = maxTorque; - long currentTorque = Math.abs(mech.getTorque()); + long currentTorque = Math.abs(mech.getTorque()); - if (currentTorque != 0) - setTorque = Math.min(setTorque, maxTorque) * (mech.getTorque() / currentTorque); + if (currentTorque != 0) + setTorque = Math.min(setTorque, maxTorque) * (mech.getTorque() / currentTorque); - float currentVelo = Math.abs(mech.getAngularVelocity()); - if (currentVelo != 0) - setAngularVelocity = Math.min(+setAngularVelocity, maxAngularVelocity) * (mech.getAngularVelocity() / currentVelo); + float currentVelo = Math.abs(mech.getAngularVelocity()); + if (currentVelo != 0) + setAngularVelocity = Math.min(+setAngularVelocity, maxAngularVelocity) * (mech.getAngularVelocity() / currentVelo); - mech.setTorque(setTorque); - mech.setAngularVelocity(setAngularVelocity); - energy.extractEnergy((long) Math.abs(setTorque * setAngularVelocity), true); + mech.setTorque(setTorque); + mech.setAngularVelocity(setAngularVelocity); + energy.extractEnergy((long) Math.abs(setTorque * setAngularVelocity), true); + } } } } diff --git a/electrical/src/main/java/resonantinduction/electrical/wire/PartConductor.java b/electrical/src/main/java/resonantinduction/electrical/wire/PartConductor.java index 5dcaa71b..35f741d5 100644 --- a/electrical/src/main/java/resonantinduction/electrical/wire/PartConductor.java +++ b/electrical/src/main/java/resonantinduction/electrical/wire/PartConductor.java @@ -181,13 +181,13 @@ public abstract class PartConductor extends PartAdvanced implements IConductor public void save(NBTTagCompound nbt) { super.save(nbt); - nbt.setLong("savedBuffer", this.getNetwork().getBufferOf(this)); + nbt.setLong("savedBuffer", getNetwork().getBufferOf(this)); } @Override public void load(NBTTagCompound nbt) { super.load(nbt); - this.getNetwork().setBufferFor(this, nbt.getLong("savedBuffer")); + getNetwork().setBufferFor(this, nbt.getLong("savedBuffer")); } } diff --git a/src/main/java/resonantinduction/core/resource/ResourceGenerator.java b/src/main/java/resonantinduction/core/resource/ResourceGenerator.java index 7937ab3f..cce8fd75 100644 --- a/src/main/java/resonantinduction/core/resource/ResourceGenerator.java +++ b/src/main/java/resonantinduction/core/resource/ResourceGenerator.java @@ -45,6 +45,7 @@ import calclavia.lib.utility.nbt.SaveManager; import com.google.common.collect.HashBiMap; import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -120,6 +121,15 @@ public class ResourceGenerator implements IVirtualObject { // Caps version of the name String nameCaps = LanguageUtility.capitalizeFirst(materialName); + String localizedName = materialName; + + List list = OreDictionary.getOres("ingot" + materialName.substring(0, 1).toUpperCase() + materialName.substring(1)); + + if (list.size() > 0) + { + ItemStack type = list.get(0); + localizedName = type.getDisplayName().replace(LanguageUtility.getLocal("misc.resonantinduction.ingot"), "").replaceAll("^ ", "").replaceAll(" $", ""); + } /** Generate molten fluids */ FluidColored fluidMolten = new FluidColored(materialNameToMolten(materialName)); @@ -127,6 +137,7 @@ public class ResourceGenerator implements IVirtualObject fluidMolten.setViscosity(5000); fluidMolten.setTemperature(273 + 1538); FluidRegistry.registerFluid(fluidMolten); + LanguageRegistry.instance().addStringLocalization(fluidMolten.getUnlocalizedName(), "Molten " + localizedName); BlockFluidMaterial blockFluidMaterial = new BlockFluidMaterial(fluidMolten); GameRegistry.registerBlock(blockFluidMaterial, "molten" + nameCaps); ResonantInduction.blockMoltenFluid.put(getID(materialName), blockFluidMaterial); @@ -136,6 +147,7 @@ public class ResourceGenerator implements IVirtualObject FluidColored fluidMixture = new FluidColored(materialNameToMixture(materialName)); FluidRegistry.registerFluid(fluidMixture); BlockFluidMixture blockFluidMixture = new BlockFluidMixture(fluidMixture); + LanguageRegistry.instance().addStringLocalization(fluidMixture.getUnlocalizedName(), localizedName + " Mixture"); GameRegistry.registerBlock(blockFluidMixture, "mixture" + nameCaps); ResonantInduction.blockMixtureFluids.put(getID(materialName), blockFluidMixture); FluidContainerRegistry.registerFluidContainer(fluidMixture, ResonantInduction.itemBucketMixture.getStackFromMaterial(materialName)); @@ -326,10 +338,10 @@ public class ResourceGenerator implements IVirtualObject { return materials.inverse().get(id); } - + public static String getName(ItemStack itemStack) { - return LanguageUtility.decapitalizeFirst(OreDictionary.getOreName(OreDictionary.getOreID(itemStack)).replace("dust", "").replace("ore", "").replace("ingot", "")); + return LanguageUtility.decapitalizeFirst(OreDictionary.getOreName(OreDictionary.getOreID(itemStack)).replace("dust", "").replace("ore", "").replace("ingot", "")); } public static int getColor(String name) diff --git a/src/main/java/resonantinduction/core/resource/fluid/ItemOreResourceBucket.java b/src/main/java/resonantinduction/core/resource/fluid/ItemOreResourceBucket.java index c2d7eb4a..abf76244 100644 --- a/src/main/java/resonantinduction/core/resource/fluid/ItemOreResourceBucket.java +++ b/src/main/java/resonantinduction/core/resource/fluid/ItemOreResourceBucket.java @@ -49,22 +49,8 @@ public class ItemOreResourceBucket extends Item { if (getMaterialFromStack(is) != null) { - String dustName = getMaterialFromStack(is); - - if (dustName != null) - { - List list = OreDictionary.getOres("ingot" + dustName.substring(0, 1).toUpperCase() + dustName.substring(1)); - - if (list.size() > 0) - { - ItemStack type = list.get(0); - - String name = type.getDisplayName().replace(LanguageUtility.getLocal("misc.resonantinduction.ingot"), "").replaceAll("^ ", "").replaceAll(" $", ""); - return (LanguageUtility.getLocal(this.getUnlocalizedName() + ".name")).replace("%v", name).replace(" ", " "); - } - } - - return (FluidRegistry.getFluid(isMolten ? ResourceGenerator.materialNameToMolten(getMaterialFromStack(is)) : ResourceGenerator.materialNameToMixture(getMaterialFromStack(is))).getLocalizedName() + " Bucket"); + String fluidName = FluidRegistry.getFluid(isMolten ? ResourceGenerator.materialNameToMolten(getMaterialFromStack(is)) : ResourceGenerator.materialNameToMixture(getMaterialFromStack(is))).getLocalizedName(); + return (LanguageUtility.getLocal(this.getUnlocalizedName() + ".name")).replace("%v", fluidName).replace(" ", " "); } return null; } diff --git a/src/main/resources/assets/resonantinduction/languages/en_US.properties b/src/main/resources/assets/resonantinduction/languages/en_US.properties index 2b4a0ed8..22809940 100644 --- a/src/main/resources/assets/resonantinduction/languages/en_US.properties +++ b/src/main/resources/assets/resonantinduction/languages/en_US.properties @@ -22,8 +22,8 @@ item.resonantinduction\:oreDust.name=%v Dust item.resonantinduction\:oreDust.tooltip=Shift-right click on a cauldron to refine. item.resonantinduction\:oreRefinedDust.name=%v Refined Dust item.resonantinduction\:oreRubble.name=%v Rubble -item.resonantinduction\:bucketMixture.name=%v Mixture Bucket -item.resonantinduction\:bucketMolten.name=Molten %v Bucket +item.resonantinduction\:bucketMixture.name=%v Bucket +item.resonantinduction\:bucketMolten.name=%v Bucket ### Archaic Module ## machineMaterials