diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8e1acbedf..c47daea75 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,6 +14,7 @@ Things you should also avoid include: * unused or half finished util functions (for obvious reasons) * half finished or obviously broken features (à la "bob will fix it, i'm sure of it", please don't do that) * updating the changelog (you're guaranteed to cause a merge conflict with that) +* any use of `I18n`, use `I18nUtil` instead ## Test your code diff --git a/changelog b/changelog index d354db2a9..45c3f8101 100644 --- a/changelog +++ b/changelog @@ -24,4 +24,6 @@ * Fixed strand caster fluid gauges going out of bounds * Fixed arc welder and soldering station not changing buffer size based on upgrade, preventing use of higher overdrive tiers * Fixed non-standard template folder recipes not using the correct icon -* Fixed jetpack flight time not resetting when equipped like armor, causing kicks on servers that don't have flying cheats allowed \ No newline at end of file +* Fixed jetpack flight time not resetting when equipped like armor, causing kicks on servers that don't have flying cheats allowed +* Fixed missing energy damage category localization +* Fixed server crash caused by tool abilities \ No newline at end of file diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index e857521bb..b3e81b36b 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -1008,7 +1008,8 @@ public class ModBlocks { public static Block machine_soldering_station; public static Block machine_arc_furnace; - public static Block machine_chemplant; + @Deprecated public static Block machine_chemplant; + public static Block machine_chemical_plant; public static Block machine_chemfac; public static Block machine_mixer; @@ -2230,6 +2231,7 @@ public class ModBlocks { machine_arc_welder = new MachineArcWelder(Material.iron).setBlockName("machine_arc_welder").setHardness(5.0F).setResistance(30.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel"); machine_soldering_station = new MachineSolderingStation(Material.iron).setBlockName("machine_soldering_station").setHardness(5.0F).setResistance(30.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel"); machine_chemplant = new MachineChemplant(Material.iron).setBlockName("machine_chemplant").setHardness(5.0F).setResistance(30.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel"); + machine_chemical_plant = new MachineChemicalPlant(Material.iron).setBlockName("machine_chemical_plant").setHardness(5.0F).setResistance(30.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel"); machine_chemfac = new MachineChemfac(Material.iron).setBlockName("machine_chemfac").setHardness(5.0F).setResistance(30.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel"); machine_mixer = new MachineMixer(Material.iron).setBlockName("machine_mixer").setHardness(5.0F).setResistance(30.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel"); machine_fluidtank = new MachineFluidTank(Material.iron).setBlockName("machine_fluidtank").setHardness(5.0F).setResistance(20.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_fluidtank"); @@ -3272,7 +3274,8 @@ public class ModBlocks { GameRegistry.registerBlock(machine_assembler, machine_assembler.getUnlocalizedName()); GameRegistry.registerBlock(machine_assemfac, machine_assemfac.getUnlocalizedName()); GameRegistry.registerBlock(machine_chemplant, machine_chemplant.getUnlocalizedName()); - GameRegistry.registerBlock(machine_chemfac, machine_chemfac.getUnlocalizedName()); + register(machine_chemical_plant); + register(machine_chemfac); register(machine_arc_welder); register(machine_soldering_station); register(machine_arc_furnace); diff --git a/src/main/java/com/hbm/blocks/machine/MachineChemicalPlant.java b/src/main/java/com/hbm/blocks/machine/MachineChemicalPlant.java new file mode 100644 index 000000000..58fd028c6 --- /dev/null +++ b/src/main/java/com/hbm/blocks/machine/MachineChemicalPlant.java @@ -0,0 +1,22 @@ +package com.hbm.blocks.machine; + +import com.hbm.blocks.BlockDummyable; + +import net.minecraft.block.material.Material; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class MachineChemicalPlant extends BlockDummyable { + + public MachineChemicalPlant(Material mat) { + super(mat); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return null; + } + + @Override public int[] getDimensions() { return new int[] {2, 0, 1, 1, 1, 1}; } + @Override public int getOffset() { return 1; } +} diff --git a/src/main/java/com/hbm/blocks/machine/MachineChemplant.java b/src/main/java/com/hbm/blocks/machine/MachineChemplant.java index cfe87c0b5..fdf17898f 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineChemplant.java +++ b/src/main/java/com/hbm/blocks/machine/MachineChemplant.java @@ -11,6 +11,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +@Deprecated public class MachineChemplant extends BlockDummyable { public MachineChemplant(Material p_i45386_1_) { diff --git a/src/main/java/com/hbm/handler/ability/IBaseAbility.java b/src/main/java/com/hbm/handler/ability/IBaseAbility.java index 3ba941022..8918a2511 100644 --- a/src/main/java/com/hbm/handler/ability/IBaseAbility.java +++ b/src/main/java/com/hbm/handler/ability/IBaseAbility.java @@ -1,6 +1,6 @@ package com.hbm.handler.ability; -import net.minecraft.client.resources.I18n; +import com.hbm.util.i18n.I18nUtil; public interface IBaseAbility extends Comparable { public String getName(); @@ -11,7 +11,7 @@ public interface IBaseAbility extends Comparable { // Note: only usable client-side. Server-side, use ChatComponentTranslation manually instead public default String getFullName(int level) { - return I18n.format(getName()) + getExtension(level); + return I18nUtil.format(getName()) + getExtension(level); } public default boolean isAllowed() { diff --git a/src/main/java/com/hbm/inventory/recipes/loader/GenericRecipes.java b/src/main/java/com/hbm/inventory/recipes/loader/GenericRecipes.java new file mode 100644 index 000000000..5ddbcecbc --- /dev/null +++ b/src/main/java/com/hbm/inventory/recipes/loader/GenericRecipes.java @@ -0,0 +1,121 @@ +package com.hbm.inventory.recipes.loader; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Random; + +import com.google.gson.JsonElement; +import com.google.gson.stream.JsonWriter; +import com.hbm.inventory.FluidStack; +import com.hbm.inventory.RecipesCommon.AStack; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandom; + +/** + * Fully genericized recipes. + * Features: + * * Fluid in and output + * * AStack intput + * * Chance-based outputs, for selecting items and for selecting items are produced in the first place + * * Duration + * * Tags for identification + * + * @author hbm + */ +public abstract class GenericRecipes extends SerializableRecipe { + + public static final Random RNG = new Random(); + + public List recipeOrderedList = new ArrayList(); + public HashMap recipeNameMap = new HashMap(); + + public abstract int inputItemLimit(); + public abstract int inputFluidLimit(); + public abstract int outputItemLimit(); + public abstract int outputFluidLimit(); + + @Override + public Object getRecipeObject() { + return this.recipeOrderedList; + } + + @Override + public void deleteRecipes() { + this.recipeOrderedList.clear(); + this.recipeNameMap.clear(); + } + + public void register(GenericRecipe recipe) { + this.recipeOrderedList.add(recipe); + this.recipeNameMap.put(recipe.name, recipe); + } + + @Override + public void readRecipe(JsonElement recipe) { + + } + + @Override + public void writeRecipe(Object recipe, JsonWriter writer) throws IOException { + + } + + /////////////// + /// CLASSES /// + /////////////// + + public static class GenericRecipe { + + public String name; + public AStack[] inputItem; + public FluidStack[] inputFluid; + public IOutput[] outputItem; + public FluidStack[] outputFluid; + public int duration; + + public GenericRecipe(String name, int duration) { + this.name = name; + this.duration = duration; + } + } + + public static interface IOutput { + public boolean possibleMultiOutput(); + public ItemStack collapse(); + } + + /** A chance output, produces either an ItemStack or null */ + public static class ChanceOutput extends WeightedRandom.Item implements IOutput { + + public ItemStack stack; + public float chance; + + public ChanceOutput(ItemStack stack) { this(stack, 1F, 1); } + public ChanceOutput(ItemStack stack, int weight) { this(stack, 1F, weight); } + public ChanceOutput(ItemStack stack, float chance, int weight) { + super(weight); + this.stack = stack; + this.chance = chance; + } + + @Override + public ItemStack collapse() { + if(this.chance >= 1F) return this.stack; + return RNG.nextFloat() <= chance ? this.stack : null; + } + + @Override public boolean possibleMultiOutput() { return false; } + } + + /** Multiple choice chance output, produces a ChanceOutput chosen randomly by weight */ + public static class ChanceOutputMulti implements IOutput { + + public List pool = new ArrayList(); + + @Override public ItemStack collapse() { return ((ChanceOutput) WeightedRandom.getRandomItem(RNG, pool)).collapse(); } + @Override public boolean possibleMultiOutput() { return pool.size() > 1; } + } +} diff --git a/src/main/resources/assets/hbm/lang/de_DE.lang b/src/main/resources/assets/hbm/lang/de_DE.lang index 9b657d0d5..984ab6040 100644 --- a/src/main/resources/assets/hbm/lang/de_DE.lang +++ b/src/main/resources/assets/hbm/lang/de_DE.lang @@ -489,6 +489,7 @@ crucible.tcalloy=Herstellung - Technetiumstahl damage.inset=Resistenz wenn in Set getragen: damage.item=Resistenz wenn getragen: +damage.category.EN=Energie damage.category.EXPL=Explosion damage.category.FIRE=Feuer damage.category.PROJ=Projektil diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index 8b3529fe0..df2d909a3 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -905,6 +905,7 @@ crucible.tcalloy=Technetium Steel Production damage.inset=Resistances when worn in set: damage.item=Resistances when worn: +damage.category.EN=Energy damage.category.EXPL=Explosion damage.category.FIRE=Fire damage.category.PROJ=Projectile