diff options
author | NotAPenguin <michiel.vandeginste@gmail.com> | 2024-09-02 23:17:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-02 23:17:17 +0200 |
commit | 1b820de08a05070909a267e17f033fcf58ac8710 (patch) | |
tree | 02831a025986a06b20f87e5bcc69d1e0c639a342 /src/main/java/pers | |
parent | afd3fd92b6a6ab9ab0d0dc3214e6bc8ff7a86c9b (diff) | |
download | GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.gz GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.bz2 GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.zip |
The Great Renaming (#3014)
* move kekztech to a single root dir
* move detrav to a single root dir
* move gtnh-lanthanides to a single root dir
* move tectech and delete some gross reflection in gt++
* remove more reflection inside gt5u
* delete more reflection in gt++
* fix imports
* move bartworks and bwcrossmod
* fix proxies
* move galactigreg and ggfab
* move gtneioreplugin
* try to fix gt++ bee loader
* apply the rename rules to BW
* apply rename rules to bwcrossmod
* apply rename rules to detrav scanner mod
* apply rename rules to galacticgreg
* apply rename rules to ggfab
* apply rename rules to goodgenerator
* apply rename rules to gtnh-lanthanides
* apply rename rules to gt++
* apply rename rules to kekztech
* apply rename rules to kubatech
* apply rename rules to tectech
* apply rename rules to gt
apply the rename rules to gt
* fix tt import
* fix mui hopefully
* fix coremod except intergalactic
* rename assline recipe class
* fix a class name i stumbled on
* rename StructureUtility to GTStructureUtility to prevent conflict with structurelib
* temporary rename of GTTooltipDataCache to old name
* fix gt client/server proxy names
Diffstat (limited to 'src/main/java/pers')
22 files changed, 0 insertions, 2420 deletions
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/Config.java b/src/main/java/pers/gwyog/gtneioreplugin/Config.java deleted file mode 100644 index ceced6a78e..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/Config.java +++ /dev/null @@ -1,28 +0,0 @@ -package pers.gwyog.gtneioreplugin; - -@com.gtnewhorizon.gtnhlib.config.Config( - modid = GTNEIOrePlugin.MODID, - category = "general", - filename = GTNEIOrePlugin.MODID) -public class Config { - - @com.gtnewhorizon.gtnhlib.config.Config.Comment("if true, generate both csv files.") - @com.gtnewhorizon.gtnhlib.config.Config.DefaultBoolean(false) - @com.gtnewhorizon.gtnhlib.config.Config.RequiresMcRestart - public static boolean printCsv; - - @com.gtnewhorizon.gtnhlib.config.Config.Comment("the name of the file you want for the ore sheet, it'll appear at the root of your instance.") - @com.gtnewhorizon.gtnhlib.config.Config.DefaultString("GTNH-Oresheet.csv") - @com.gtnewhorizon.gtnhlib.config.Config.RequiresMcRestart - public static String CSVName; - - @com.gtnewhorizon.gtnhlib.config.Config.Comment("the name of the file you want for the small ore sheet, it'll appear at the root of your instance.") - @com.gtnewhorizon.gtnhlib.config.Config.DefaultString("GTNH-Small-Ores-Sheet.csv") - @com.gtnewhorizon.gtnhlib.config.Config.RequiresMcRestart - public static String CSVnameSmall; - - @com.gtnewhorizon.gtnhlib.config.Config.Comment("Maximum number of lines the dimension names tooltip can have before it wraps around.") - @com.gtnewhorizon.gtnhlib.config.Config.DefaultInt(11) - @com.gtnewhorizon.gtnhlib.config.Config.RequiresMcRestart - public static int maxTooltipLines; -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java deleted file mode 100644 index 7ae7b0bc1c..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java +++ /dev/null @@ -1,84 +0,0 @@ -package pers.gwyog.gtneioreplugin; - -import java.io.File; - -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.gtnewhorizon.gtnhlib.config.ConfigException; -import com.gtnewhorizon.gtnhlib.config.ConfigurationManager; - -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLLoadCompleteEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import gregtech.GT_Version; -import pers.gwyog.gtneioreplugin.plugin.IMCForNEI; -import pers.gwyog.gtneioreplugin.plugin.block.ModBlocks; -import pers.gwyog.gtneioreplugin.util.CSVMaker; -import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; -import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper; -import pers.gwyog.gtneioreplugin.util.GT5UndergroundFluidHelper; - -@Mod( - modid = GTNEIOrePlugin.MODID, - name = GTNEIOrePlugin.NAME, - version = GTNEIOrePlugin.VERSION, - dependencies = "required-after:gregtech;required-after:NotEnoughItems") -public class GTNEIOrePlugin { - - static { - try { - ConfigurationManager.registerConfig(Config.class); - } catch (ConfigException e) { - throw new RuntimeException(e); - } - } - - public static final String MODID = "gtneioreplugin"; - public static final String NAME = "GT NEI Ore Plugin GT:NH Mod"; - public static final String VERSION = GT_Version.VERSION; - public static final Logger LOG = LogManager.getLogger(NAME); - public static File instanceDir; - public static final CreativeTabs creativeTab = new CreativeTabs(MODID) { - - @Override - public Item getTabIconItem() { - return GameRegistry.makeItemStack("gregtech:gt.blockores", 386, 1, null) - .getItem(); - } - }; - - @Mod.Instance(MODID) - public static GTNEIOrePlugin instance; - - @EventHandler - public void preinit(FMLPreInitializationEvent event) { - instanceDir = event.getModConfigurationDirectory() - .getParentFile(); - } - - @EventHandler - public void init(FMLInitializationEvent event) { - ModBlocks.init(); - IMCForNEI.IMCSender(); - } - - @EventHandler - public void onLoadComplete(FMLLoadCompleteEvent event) { - GT5OreLayerHelper.init(); - GT5OreSmallHelper.init(); - GT5UndergroundFluidHelper.init(); - if (event.getSide() == Side.CLIENT) { - if (Config.printCsv) { - new CSVMaker().run(); - } - } - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/IMCForNEI.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/IMCForNEI.java deleted file mode 100644 index bf59fa292c..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/IMCForNEI.java +++ /dev/null @@ -1,64 +0,0 @@ -package pers.gwyog.gtneioreplugin.plugin; - -import net.minecraft.nbt.NBTTagCompound; - -import cpw.mods.fml.common.event.FMLInterModComms; -import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; - -public class IMCForNEI { - - public static void IMCSender() { - // Though these 2 are already registered in NEI jar, we need to re-register - // because new DimensionDisplayItems made tabs a bit taller. - sendHandler("pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat", "gregtech:gt.blockores:386"); - - sendHandler("pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5SmallOreStat", "gregtech:gt.blockores:85"); - - sendHandler( - "pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5UndergroundFluid", - "gregtech:gt.metaitem.01:32619"); - sendCatalyst( - "pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5UndergroundFluid", - "gregtech:gt.blockmachines:1157"); - sendCatalyst( - "pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5UndergroundFluid", - "gregtech:gt.blockmachines:141"); - sendCatalyst( - "pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5UndergroundFluid", - "gregtech:gt.blockmachines:142"); - sendCatalyst( - "pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5UndergroundFluid", - "gregtech:gt.blockmachines:149"); - sendCatalyst( - "pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5UndergroundFluid", - "gregtech:gt.blockmachines:148"); - } - - private static void sendHandler(String name, String itemStack) { - NBTTagCompound aNBT = new NBTTagCompound(); - aNBT.setString("handler", name); - aNBT.setString("modName", GTNEIOrePlugin.NAME); - aNBT.setString("modId", GTNEIOrePlugin.MODID); - aNBT.setBoolean("modRequired", true); - aNBT.setString("itemName", itemStack); - aNBT.setInteger("handlerHeight", 160); - aNBT.setInteger("handlerWidth", 166); - aNBT.setInteger("maxRecipesPerPage", 2); - aNBT.setInteger("yShift", 0); - FMLInterModComms.sendMessage("NotEnoughItems", "registerHandlerInfo", aNBT); - } - - @SuppressWarnings("SameParameterValue") - private static void sendCatalyst(String name, String itemStack, int priority) { - NBTTagCompound aNBT = new NBTTagCompound(); - aNBT.setString("handlerID", name); - aNBT.setString("itemName", itemStack); - aNBT.setInteger("priority", priority); - FMLInterModComms.sendMessage("NotEnoughItems", "registerCatalystInfo", aNBT); - } - - @SuppressWarnings("SameParameterValue") - private static void sendCatalyst(String name, String itemStack) { - sendCatalyst(name, itemStack, 0); - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java deleted file mode 100644 index 6996cba220..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java +++ /dev/null @@ -1,35 +0,0 @@ -package pers.gwyog.gtneioreplugin.plugin; - -import codechicken.nei.api.API; -import codechicken.nei.api.IConfigureNEI; -import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; -import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5SmallOreStat; -import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5UndergroundFluid; -import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat; - -@SuppressWarnings("unused") -public class NEIPluginConfig implements IConfigureNEI { - - @Override - public String getName() { - return "GregTech Ore Plugin"; - } - - @Override - public String getVersion() { - return GTNEIOrePlugin.VERSION; - } - - @Override - public void loadConfig() { - PluginGT5VeinStat pluginVeinStat = new PluginGT5VeinStat(); - PluginGT5SmallOreStat pluginSmallOreStat = new PluginGT5SmallOreStat(); - PluginGT5UndergroundFluid pluginGT5UndergroundFluid = new PluginGT5UndergroundFluid(); - API.registerRecipeHandler(pluginVeinStat); - API.registerUsageHandler(pluginVeinStat); - API.registerRecipeHandler(pluginSmallOreStat); - API.registerUsageHandler(pluginSmallOreStat); - API.registerRecipeHandler(pluginGT5UndergroundFluid); - API.registerUsageHandler(pluginGT5UndergroundFluid); - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java deleted file mode 100644 index 0db39c8e28..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java +++ /dev/null @@ -1,52 +0,0 @@ -package pers.gwyog.gtneioreplugin.plugin; - -import java.awt.Rectangle; - -import net.minecraft.client.resources.I18n; -import net.minecraft.util.EnumChatFormatting; - -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.recipe.TemplateRecipeHandler; - -public abstract class PluginBase extends TemplateRecipeHandler { - - @Override - public int recipiesPerPage() { - return 1; - } - - @Override - public String getRecipeName() { - return null; - } - - @Override - public String getGuiTexture() { - return "gtneioreplugin:textures/gui/nei/guiBase.png"; - } - - @Override - public void loadTransferRects() { - int stringLength = GuiDraw.getStringWidth(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll")); - transferRects.add( - new RecipeTransferRect(new Rectangle(getGuiWidth() - stringLength - 3, 5, stringLength, 9), getOutputId())); - } - - public abstract String getOutputId(); - - public int getGuiWidth() { - return 166; - } - - /** - * Draw the "see all recipes" transfer label - */ - protected void drawSeeAllRecipesLabel() { - GuiDraw.drawStringR( - EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), - getGuiWidth() - 3, - 5, - 0x404040, - false); - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/block/BlockDimensionDisplay.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/block/BlockDimensionDisplay.java deleted file mode 100644 index 7d3b1eb5bc..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/block/BlockDimensionDisplay.java +++ /dev/null @@ -1,47 +0,0 @@ -package pers.gwyog.gtneioreplugin.plugin.block; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; -import net.minecraft.util.MathHelper; - -import pers.gwyog.gtneioreplugin.plugin.renderer.ItemDimensionDisplayRenderer; - -public class BlockDimensionDisplay extends Block { - - private final String dimension; - - @SuppressWarnings("unused") - public long getDimensionRocketTier() { - return this.dimensionRocketTier; - } - - private final long dimensionRocketTier; - private final IIcon[] icons = new IIcon[6]; - - public BlockDimensionDisplay(String dimension) { - super(Material.rock); - this.dimension = dimension; - this.dimensionRocketTier = ItemDimensionDisplayRenderer.getPrefix(dimension); - } - - @Override - public IIcon getIcon(int side, int meta) { - return this.icons[MathHelper.clamp_int(side, 0, 5)]; - } - - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - this.icons[0] = iconRegister.registerIcon("gtneioreplugin:" + dimension + "_bottom"); - this.icons[1] = iconRegister.registerIcon("gtneioreplugin:" + dimension + "_top"); - this.icons[2] = iconRegister.registerIcon("gtneioreplugin:" + dimension + "_back"); - this.icons[3] = iconRegister.registerIcon("gtneioreplugin:" + dimension + "_front"); - this.icons[4] = iconRegister.registerIcon("gtneioreplugin:" + dimension + "_left"); - this.icons[5] = iconRegister.registerIcon("gtneioreplugin:" + dimension + "_right"); - } - - public String getDimension() { - return this.dimension; - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/block/ModBlocks.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/block/ModBlocks.java deleted file mode 100644 index db953c7112..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/block/ModBlocks.java +++ /dev/null @@ -1,27 +0,0 @@ -package pers.gwyog.gtneioreplugin.plugin.block; - -import java.util.HashMap; -import java.util.Map; - -import net.minecraft.block.Block; - -import cpw.mods.fml.common.registry.GameRegistry; -import pers.gwyog.gtneioreplugin.plugin.item.ItemDimensionDisplay; -import pers.gwyog.gtneioreplugin.util.DimensionHelper; - -public class ModBlocks { - - public static final Map<String, Block> blocks = new HashMap<>(); - - public static void init() { - for (String dimension : DimensionHelper.DimNameDisplayed) { - Block block = new BlockDimensionDisplay(dimension); - GameRegistry.registerBlock(block, ItemDimensionDisplay.class, "blockDimensionDisplay_" + dimension); - blocks.put(dimension, block); - } - } - - public static Block getBlock(String dimension) { - return blocks.get(dimension); - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java deleted file mode 100644 index 895a23ddb1..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java +++ /dev/null @@ -1,65 +0,0 @@ -package pers.gwyog.gtneioreplugin.plugin.gregtech5; - -import net.minecraft.client.resources.I18n; - -import codechicken.lib.gui.GuiDraw; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.util.GT_LanguageManager; -import pers.gwyog.gtneioreplugin.plugin.PluginBase; - -public abstract class PluginGT5Base extends PluginBase { - - protected static String getLocalizedNameForItem(Materials aMaterial, String aFormat) { - return String.format( - aFormat.replace("%s", "%temp") - .replace("%material", "%s"), - aMaterial.mLocalizedName) - .replace("%temp", "%s"); - } - - protected static String getLocalizedNameForItem(String aFormat, int aMaterialID) { - if (aMaterialID >= 0 && aMaterialID < 1000) { - Materials aMaterial = GregTech_API.sGeneratedMaterials[aMaterialID]; - if (aMaterial != null) { - return getLocalizedNameForItem(aMaterial, aFormat); - } - } - return aFormat; - } - - public static String getGTOreLocalizedName(short index) { - - if (!getLocalizedNameForItem(GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(index)), index % 1000) - .contains("Awakened")) - return getLocalizedNameForItem( - GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(index)), - index % 1000); - else return "Aw. Draconium Ore"; - } - - protected static String getGTOreUnlocalizedName(short index) { - return "gt.blockores." + index + ".name"; - } - - static void drawLine(String lineKey, String value, int x, int y) { - GuiDraw.drawString(I18n.format(lineKey) + ": " + value, x, y, 0x404040, false); - } - - protected int getMaximumMaterialIndex(short meta, boolean smallOre) { - int offset = smallOre ? 16000 : 0; - if (!getGTOreLocalizedName((short) (meta + offset + 5000)) - .equals(getGTOreUnlocalizedName((short) (meta + offset + 5000)))) return 7; - else if (!getGTOreLocalizedName((short) (meta + offset + 5000)) - .equals(getGTOreUnlocalizedName((short) (meta + offset + 5000)))) return 6; - else return 5; - } - - /** - * Draw the dimension header and the dimension names over up to 3 lines - * - */ - protected void drawDimNames() { - GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": ", 2, 100, 0x404040, false); - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java deleted file mode 100644 index 7e42f912a7..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java +++ /dev/null @@ -1,208 +0,0 @@ -package pers.gwyog.gtneioreplugin.plugin.gregtech5; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; - -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; - -import codechicken.nei.PositionedStack; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.util.GT_OreDictUnificator; -import pers.gwyog.gtneioreplugin.plugin.item.ItemDimensionDisplay; -import pers.gwyog.gtneioreplugin.util.DimensionHelper; -import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper; -import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper.OreSmallWrapper; - -public class PluginGT5SmallOreStat extends PluginGT5Base { - - private static final int SMALL_ORE_BASE_META = 16000; - - @Override - public void drawExtras(int recipe) { - OreSmallWrapper oreSmall = getSmallOre(recipe); - - drawSmallOreName(oreSmall); - drawSmallOreInfo(oreSmall); - - drawDimNames(); - - drawSeeAllRecipesLabel(); - } - - private void drawSmallOreName(OreSmallWrapper oreSmall) { - String oreName = getGTOreLocalizedName((short) (oreSmall.oreMeta + SMALL_ORE_BASE_META)); - drawLine("gtnop.gui.nei.oreName", oreName, 2, 18); - } - - private void drawSmallOreInfo(OreSmallWrapper oreSmall) { - drawLine("gtnop.gui.nei.genHeight", oreSmall.worldGenHeightRange, 2, 31); - drawLine("gtnop.gui.nei.amount", String.valueOf(oreSmall.amountPerChunk), 2, 44); - drawLine("gtnop.gui.nei.chanceDrops", "", 2, 83 + getRestrictBiomeOffset()); - drawLine("gtnop.gui.nei.worldNames", "", 2, 100); - } - - private OreSmallWrapper getSmallOre(int recipe) { - CachedOreSmallRecipe crecipe = (CachedOreSmallRecipe) this.arecipes.get(recipe); - return GT5OreSmallHelper.mapOreSmallWrapper.get(crecipe.oreGenName); - } - - public int getRestrictBiomeOffset() { - return GT5OreSmallHelper.restrictBiomeSupport ? 0 : -13; - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals(getOutputId())) - for (ItemStack stack : GT5OreSmallHelper.oreSmallList) loadCraftingRecipes(stack); - else super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack stack) { - if (stack.getUnlocalizedName() - .startsWith("gt.blockores")) { - short oreMeta = (short) (stack.getItemDamage() % 1000); - loadSmallOre(oreMeta, getMaximumMaterialIndex(oreMeta, true)); - } else if (GT5OreSmallHelper.mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { - short oreMeta = GT5OreSmallHelper.mapOreDropUnlocalizedNameToOreMeta.get(stack.getUnlocalizedName()); - loadSmallOre(oreMeta, 7); - } else super.loadCraftingRecipes(stack); - } - - @Override - public void loadUsageRecipes(ItemStack stack) { - String dimension = ItemDimensionDisplay.getDimension(stack); - if (dimension == null) { - return; - } - - for (OreSmallWrapper oreVein : GT5OreSmallHelper.mapOreSmallWrapper.values()) { - if (Arrays.asList(getDimNameArrayFromVeinName(oreVein.oreGenName)) - .contains(dimension)) { - addSmallOre(oreVein, 7); - } - } - } - - private void loadSmallOre(short oreMeta, int maximumIndex) { - OreSmallWrapper smallOre = getSmallOre(oreMeta); - if (smallOre != null) { - addSmallOre(smallOre, maximumIndex); - } - } - - private OreSmallWrapper getSmallOre(short oreMeta) { - for (OreSmallWrapper oreSmallWorldGen : GT5OreSmallHelper.mapOreSmallWrapper.values()) { - if (oreSmallWorldGen.oreMeta == oreMeta) { - return oreSmallWorldGen; - } - } - return null; - } - - private void addSmallOre(OreSmallWrapper smallOre, int maximumIndex) { - this.arecipes.add( - new CachedOreSmallRecipe( - smallOre.oreGenName, - smallOre.getMaterialDrops(maximumIndex), - getStoneDusts(maximumIndex), - GT5OreSmallHelper.mapOreMetaToOreDrops.get(smallOre.oreMeta))); - } - - private List<ItemStack> getStoneDusts(int maximumIndex) { - List<ItemStack> materialDustStackList = new ArrayList<>(); - for (int i = 0; i < maximumIndex; i++) materialDustStackList - .add(GT_OreDictUnificator.get(OrePrefixes.dust, GT5OreSmallHelper.getDroppedDusts()[i], 1L)); - return materialDustStackList; - } - - @Override - public String getOutputId() { - return "GTOrePluginOreSmall"; - } - - @Override - public String getRecipeName() { - return I18n.format("gtnop.gui.smallOreStat.name"); - } - - private String[] getDimNameArrayFromVeinName(String veinName) { - OreSmallWrapper oreSmall = GT5OreSmallHelper.mapOreSmallWrapper.get(veinName); - String[] dims = GT5OreSmallHelper.bufferedDims.get(oreSmall) - .keySet() - .toArray(new String[0]); - Arrays.sort( - dims, - Comparator.comparingInt( - s -> Arrays.asList(DimensionHelper.DimNameDisplayed) - .indexOf(s))); - return dims; - } - - public class CachedOreSmallRecipe extends CachedRecipe { - - public final String oreGenName; - public final PositionedStack positionedStackOreSmall; - public final PositionedStack positionedStackMaterialDust; - public final List<PositionedStack> positionedDropStackList; - private final List<PositionedStack> dimensionDisplayItems = new ArrayList<>(); - - public CachedOreSmallRecipe(String oreGenName, List<ItemStack> stackList, List<ItemStack> materialDustStackList, - List<ItemStack> dropStackList) { - this.oreGenName = oreGenName; - this.positionedStackOreSmall = new PositionedStack(stackList, 2, 0); - this.positionedStackMaterialDust = new PositionedStack( - materialDustStackList, - 43, - 79 + getRestrictBiomeOffset()); - List<PositionedStack> positionedDropStackList = new ArrayList<>(); - int i = 1; - for (ItemStack stackDrop : dropStackList) positionedDropStackList.add( - new PositionedStack(stackDrop, 43 + 20 * (i % 4), 79 + 16 * ((i++) / 4) + getRestrictBiomeOffset())); - this.positionedDropStackList = positionedDropStackList; - setDimensionDisplayItems(); - } - - private void setDimensionDisplayItems() { - int x = 2; - int y = 110; - int count = 0; - int itemsPerLine = 9; - int itemSize = 18; - for (String dim : getDimNameArrayFromVeinName(this.oreGenName)) { - ItemStack item = ItemDimensionDisplay.getItem(dim); - if (item != null) { - int xPos = x + itemSize * (count % itemsPerLine); - int yPos = y + itemSize * (count / itemsPerLine); - dimensionDisplayItems.add(new PositionedStack(item, xPos, yPos, false)); - count++; - } - } - } - - @Override - public List<PositionedStack> getIngredients() { - return dimensionDisplayItems; - } - - @Override - public PositionedStack getResult() { - return null; - } - - @Override - public List<PositionedStack> getOtherStacks() { - List<PositionedStack> outputs = new ArrayList<>(); - positionedStackOreSmall.setPermutationToRender((cycleticks / 20) % positionedStackOreSmall.items.length); - positionedStackMaterialDust - .setPermutationToRender((cycleticks / 20) % positionedStackMaterialDust.items.length); - outputs.add(positionedStackOreSmall); - outputs.add(positionedStackMaterialDust); - outputs.addAll(positionedDropStackList); - return outputs; - } - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5UndergroundFluid.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5UndergroundFluid.java deleted file mode 100644 index 5530f5b145..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5UndergroundFluid.java +++ /dev/null @@ -1,168 +0,0 @@ -package pers.gwyog.gtneioreplugin.plugin.gregtech5; - -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.PositionedStack; -import gregtech.api.util.GT_Utility; -import pers.gwyog.gtneioreplugin.plugin.PluginBase; -import pers.gwyog.gtneioreplugin.plugin.item.ItemDimensionDisplay; -import pers.gwyog.gtneioreplugin.util.GT5UndergroundFluidHelper; -import pers.gwyog.gtneioreplugin.util.GT5UndergroundFluidHelper.UndergroundFluidWrapper; - -public class PluginGT5UndergroundFluid extends PluginBase { - - private static final int lineSpace = 20; - private static final int xDimensionDisplay = 30; - private static final int halfItemLength = 16 / 2; - private static final DecimalFormat format = new DecimalFormat("0.#"); - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals(getOutputId())) { - for (Map.Entry<String, List<UndergroundFluidWrapper>> entry : GT5UndergroundFluidHelper.getAllEntries() - .entrySet()) { - Fluid fluid = FluidRegistry.getFluid(entry.getKey()); - if (fluid != null) { - this.arecipes.add(new CachedUndergroundFluidRecipe(fluid, entry.getValue())); - } - } - } else { - super.loadCraftingRecipes(outputId, results); - } - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - Fluid fluid = null; - FluidStack containerFluid = GT_Utility.getFluidForFilledItem(result, true); - if (containerFluid != null) { - fluid = containerFluid.getFluid(); - } - if (fluid == null) { - FluidStack displayFluid = GT_Utility.getFluidFromDisplayStack(result); - if (displayFluid != null) { - fluid = displayFluid.getFluid(); - } - } - if (fluid == null) return; - - List<UndergroundFluidWrapper> wrappers = GT5UndergroundFluidHelper.getEntry(fluid.getName()); - if (wrappers != null) { - this.arecipes.add(new CachedUndergroundFluidRecipe(fluid, wrappers)); - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - String dimension = ItemDimensionDisplay.getDimension(ingredient); - if (dimension != null) { - for (Map.Entry<String, List<UndergroundFluidWrapper>> entry : GT5UndergroundFluidHelper.getAllEntries() - .entrySet()) { - boolean found = false; - for (UndergroundFluidWrapper wrapper : entry.getValue()) { - if (wrapper.dimension.equals(dimension)) { - found = true; - break; - } - } - if (found) { - Fluid fluid = FluidRegistry.getFluid(entry.getKey()); - if (fluid != null) { - this.arecipes.add(new CachedUndergroundFluidRecipe(fluid, entry.getValue())); - } - } - } - } - } - - @Override - public void drawExtras(int recipeIndex) { - drawSeeAllRecipesLabel(); - - int xChance = 85; - int xAmount = 140; - int yHeader = 30; - int black = 0x404040; - - GuiDraw.drawStringC(I18n.format("gtnop.gui.nei.dimension") + ":", xDimensionDisplay, yHeader, black, false); - GuiDraw.drawStringC(I18n.format("gtnop.gui.nei.chance") + ":", xChance, yHeader, black, false); - GuiDraw.drawStringC(I18n.format("gtnop.gui.nei.fluidAmount") + ":", xAmount, yHeader, black, false); - - int y = 50; - CachedUndergroundFluidRecipe recipe = (CachedUndergroundFluidRecipe) this.arecipes.get(recipeIndex); - for (int i = 0; i < recipe.dimensionDisplayItems.size(); i++) { - GuiDraw.drawStringC(format.format((double) recipe.chances.get(i) / 100) + "%", xChance, y, black, false); - GuiDraw.drawStringC( - recipe.minAmounts.get(i) - .toString() + "-" - + recipe.maxAmounts.get(i) - .toString(), - xAmount, - y, - black, - false); - y += lineSpace; - } - } - - @Override - public String getOutputId() { - return "GTOrePluginUndergroundFluid"; - } - - @Override - public String getRecipeName() { - return I18n.format("gtnop.gui.undergroundFluid.name"); - } - - private class CachedUndergroundFluidRecipe extends CachedRecipe { - - private final PositionedStack targetFluidDisplay; - private final List<PositionedStack> dimensionDisplayItems = new ArrayList<>(); - private final List<Integer> chances = new ArrayList<>(); - private final List<Integer> maxAmounts = new ArrayList<>(); - private final List<Integer> minAmounts = new ArrayList<>(); - - private CachedUndergroundFluidRecipe(Fluid fluid, List<UndergroundFluidWrapper> wrappers) { - targetFluidDisplay = new PositionedStack( - GT_Utility.getFluidDisplayStack(fluid), - getGuiWidth() / 2 - halfItemLength, - 3); - int y = 50 - halfItemLength; - for (UndergroundFluidWrapper wrapper : wrappers) { - ItemStack dimensionDisplay = ItemDimensionDisplay.getItem(wrapper.dimension); - if (dimensionDisplay != null) { - dimensionDisplayItems.add( - new PositionedStack( - dimensionDisplay, - xDimensionDisplay - halfItemLength, - y + GuiDraw.fontRenderer.FONT_HEIGHT / 2)); - y += lineSpace; - chances.add(wrapper.chance); - maxAmounts.add(wrapper.maxAmount); - minAmounts.add(wrapper.minAmount); - } - } - } - - @Override - public PositionedStack getResult() { - return targetFluidDisplay; - } - - @Override - public List<PositionedStack> getIngredients() { - return dimensionDisplayItems; - } - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java deleted file mode 100644 index 81aff90ba9..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java +++ /dev/null @@ -1,209 +0,0 @@ -package pers.gwyog.gtneioreplugin.plugin.gregtech5; - -import static pers.gwyog.gtneioreplugin.util.OreVeinLayer.*; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Comparator; -import java.util.List; - -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; - -import codechicken.nei.PositionedStack; -import cpw.mods.fml.common.Loader; -import pers.gwyog.gtneioreplugin.plugin.item.ItemDimensionDisplay; -import pers.gwyog.gtneioreplugin.util.DimensionHelper; -import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; -import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.OreLayerWrapper; - -public class PluginGT5VeinStat extends PluginGT5Base { - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals(getOutputId())) { - for (OreLayerWrapper oreVein : getAllVeins()) { - addVeinWithLayers(oreVein, 7); - } - } else super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack stack) { - if (stack.getUnlocalizedName() - .startsWith("gt.blockores")) { - loadMatchingVeins((short) (stack.getItemDamage() % 1000)); - } else super.loadCraftingRecipes(stack); - } - - private void loadMatchingVeins(short oreId) { - for (OreLayerWrapper oreVein : getAllVeins()) { - if (oreVein.containsOre(oreId)) { - addVeinWithLayers(oreVein, getMaximumMaterialIndex(oreId, false)); - } - } - } - - @Override - public void loadUsageRecipes(ItemStack stack) { - String dimension = ItemDimensionDisplay.getDimension(stack); - if (dimension == null) { - return; - } - - for (OreLayerWrapper oreVein : getAllVeins()) { - if (Arrays.asList(getDimNameArrayFromVeinName(oreVein.veinName)) - .contains(dimension)) { - addVeinWithLayers(oreVein, getMaximumMaterialIndex((short) (stack.getItemDamage() % 1000), false)); - } - } - } - - private void addVeinWithLayers(OreLayerWrapper oreVein, int maximumMaterialIndex) { - this.arecipes.add( - new CachedVeinStatRecipe( - oreVein.veinName, - oreVein.getVeinLayerOre(maximumMaterialIndex, VEIN_PRIMARY), - oreVein.getVeinLayerOre(maximumMaterialIndex, VEIN_SECONDARY), - oreVein.getVeinLayerOre(maximumMaterialIndex, VEIN_BETWEEN), - oreVein.getVeinLayerOre(maximumMaterialIndex, VEIN_SPORADIC))); - } - - private Collection<OreLayerWrapper> getAllVeins() { - return GT5OreLayerHelper.mapOreLayerWrapper.values(); - } - - @Override - public void drawExtras(int recipe) { - OreLayerWrapper oreLayer = getOreLayer(recipe); - - drawVeinName(oreLayer); - drawVeinLayerNames(oreLayer); - drawVeinInfo(oreLayer); - - drawDimNames(); - - drawSeeAllRecipesLabel(); - } - - private OreLayerWrapper getOreLayer(int recipe) { - CachedVeinStatRecipe crecipe = (CachedVeinStatRecipe) this.arecipes.get(recipe); - return GT5OreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName); - } - - private static void drawVeinName(OreLayerWrapper oreLayer) { - if (Loader.isModLoaded("visualprospecting")) { - drawVeinNameLine(I18n.format(oreLayer.veinName) + " "); - } else { - String veinName = getGTOreLocalizedName(oreLayer.Meta[VEIN_PRIMARY]); - if (veinName.contains("Ore")) drawVeinNameLine(veinName.split("Ore")[0]); - else if (veinName.contains("Sand")) drawVeinNameLine(veinName.split("Sand")[0]); - else drawVeinNameLine(veinName + " "); - } - } - - private static void drawVeinNameLine(String veinName) { - drawLine("gtnop.gui.nei.veinName", veinName + I18n.format("gtnop.gui" + ".nei.vein"), 2, 20); - } - - private static void drawVeinLayerNames(OreLayerWrapper oreLayer) { - drawVeinLayerNameLine(oreLayer, VEIN_PRIMARY, 50); - drawVeinLayerNameLine(oreLayer, VEIN_SECONDARY, 60); - drawVeinLayerNameLine(oreLayer, VEIN_BETWEEN, 70); - drawVeinLayerNameLine(oreLayer, VEIN_SPORADIC, 80); - } - - private static void drawVeinLayerNameLine(OreLayerWrapper oreLayer, int veinLayer, int height) { - drawLine(getOreVeinLayerName(veinLayer), getGTOreLocalizedName(oreLayer.Meta[veinLayer]), 2, height); - } - - private static void drawVeinInfo(OreLayerWrapper oreLayer) { - drawLine("gtnop.gui.nei.genHeight", oreLayer.worldGenHeightRange, 2, 90); - drawLine("gtnop.gui.nei.weightedChance", Integer.toString(oreLayer.randomWeight), 100, 90); - } - - @Override - public String getOutputId() { - return "GTOrePluginVein"; - } - - @Override - public String getRecipeName() { - return I18n.format("gtnop.gui.veinStat.name"); - } - - private String[] getDimNameArrayFromVeinName(String veinName) { - OreLayerWrapper oreLayer = GT5OreLayerHelper.mapOreLayerWrapper.get(veinName); - String[] dims = (GT5OreLayerHelper.bufferedDims.get(oreLayer) - .keySet() - .toArray(new String[0])); - Arrays.sort( - dims, - Comparator.comparingInt( - s -> Arrays.asList(DimensionHelper.DimNameDisplayed) - .indexOf(s))); - return dims; - } - - public class CachedVeinStatRecipe extends CachedRecipe { - - public final String veinName; - public final PositionedStack positionedStackPrimary; - public final PositionedStack positionedStackSecondary; - public final PositionedStack positionedStackBetween; - public final PositionedStack positionedStackSporadic; - private final List<PositionedStack> dimensionDisplayItems = new ArrayList<>(); - - public CachedVeinStatRecipe(String veinName, List<ItemStack> stackListPrimary, - List<ItemStack> stackListSecondary, List<ItemStack> stackListBetween, List<ItemStack> stackListSporadic) { - this.veinName = veinName; - positionedStackPrimary = new PositionedStack(stackListPrimary, 2, 0); - positionedStackSecondary = new PositionedStack(stackListSecondary, 22, 0); - positionedStackBetween = new PositionedStack(stackListBetween, 42, 0); - positionedStackSporadic = new PositionedStack(stackListSporadic, 62, 0); - setDimensionDisplayItems(); - } - - private void setDimensionDisplayItems() { - int x = 2; - int y = 110; - int count = 0; - int itemsPerLine = 9; - int itemSize = 18; - for (String dim : getDimNameArrayFromVeinName(this.veinName)) { - ItemStack item = ItemDimensionDisplay.getItem(dim); - if (item != null) { - int xPos = x + itemSize * (count % itemsPerLine); - int yPos = y + itemSize * (count / itemsPerLine); - dimensionDisplayItems.add(new PositionedStack(item, xPos, yPos, false)); - count++; - } - } - } - - @Override - public List<PositionedStack> getIngredients() { - return dimensionDisplayItems; - } - - @Override - public PositionedStack getResult() { - return null; - } - - @Override - public List<PositionedStack> getOtherStacks() { - List<PositionedStack> outputs = new ArrayList<>(); - positionedStackPrimary.setPermutationToRender((cycleticks / 20) % positionedStackPrimary.items.length); - positionedStackSecondary.setPermutationToRender((cycleticks / 20) % positionedStackPrimary.items.length); - positionedStackBetween.setPermutationToRender((cycleticks / 20) % positionedStackPrimary.items.length); - positionedStackSporadic.setPermutationToRender((cycleticks / 20) % positionedStackPrimary.items.length); - outputs.add(positionedStackPrimary); - outputs.add(positionedStackSecondary); - outputs.add(positionedStackBetween); - outputs.add(positionedStackSporadic); - return outputs; - } - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/item/ItemDimensionDisplay.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/item/ItemDimensionDisplay.java deleted file mode 100644 index 01a0b4bebb..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/item/ItemDimensionDisplay.java +++ /dev/null @@ -1,57 +0,0 @@ -package pers.gwyog.gtneioreplugin.plugin.item; - -import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.LOG; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraftforge.client.MinecraftForgeClient; - -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; -import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; -import pers.gwyog.gtneioreplugin.plugin.block.BlockDimensionDisplay; -import pers.gwyog.gtneioreplugin.plugin.block.ModBlocks; -import pers.gwyog.gtneioreplugin.plugin.renderer.ItemDimensionDisplayRenderer; -import pers.gwyog.gtneioreplugin.util.DimensionHelper; - -public class ItemDimensionDisplay extends ItemBlock { - - public ItemDimensionDisplay(Block block) { - super(block); - setCreativeTab(GTNEIOrePlugin.creativeTab); - - if (FMLCommonHandler.instance() - .getEffectiveSide() == Side.CLIENT) { - MinecraftForgeClient.registerItemRenderer(this, new ItemDimensionDisplayRenderer()); - } - } - - public static ItemStack getItem(String dimension) { - Block block = ModBlocks.getBlock(dimension); - if (block != null) { - return new ItemStack(block); - } - if (dimension != null) { - LOG.warn("Unknown dimension queried for ItemDimensionDisplay: " + dimension); - } - return null; - } - - public static String getDimension(ItemStack stack) { - if (stack.getItem() instanceof ItemDimensionDisplay) { - return ((BlockDimensionDisplay) Block.getBlockFromItem(stack.getItem())).getDimension(); - } - return null; - } - - @Override - public String getItemStackDisplayName(ItemStack stack) { - String dimension = getDimension(stack); - if (dimension != null) { - return DimensionHelper.convertCondensedStringToToolTip(dimension) - .get(0); - } - return super.getItemStackDisplayName(stack); - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/renderer/ItemDimensionDisplayRenderer.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/renderer/ItemDimensionDisplayRenderer.java deleted file mode 100644 index 12c62c9830..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/renderer/ItemDimensionDisplayRenderer.java +++ /dev/null @@ -1,78 +0,0 @@ -package pers.gwyog.gtneioreplugin.plugin.renderer; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.item.ItemStack; -import net.minecraftforge.client.IItemRenderer; - -import org.lwjgl.opengl.GL11; - -import pers.gwyog.gtneioreplugin.plugin.item.ItemDimensionDisplay; - -public class ItemDimensionDisplayRenderer implements IItemRenderer { - - private final RenderItem renderItem = new RenderItem(); - - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) { - return type == ItemRenderType.INVENTORY; - } - - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return false; - } - - // Renders the actual text on top of planet items. - @Override - public void renderItem(ItemRenderType type, ItemStack stack, Object... data) { - String dimension = ItemDimensionDisplay.getDimension(stack); - if (dimension == null) { - return; - } - - renderItem.renderItemIntoGUI( - Minecraft.getMinecraft().fontRenderer, - Minecraft.getMinecraft().renderEngine, - stack, - 0, - 0, - false); - - FontRenderer fontRender = Minecraft.getMinecraft().fontRenderer; - float smallTextScale = 3F / 4F; - - GL11.glPushMatrix(); - GL11.glTranslatef(0, 0, 300); - GL11.glScalef(smallTextScale, smallTextScale, 1.0f); - - long prefix = getPrefix(dimension); - String tooltipPrefix = prefix != -1 ? "T" + prefix : "INVALID. Please, report this to the GTNH team"; - - fontRender - .drawString(tooltipPrefix, 0, (int) (16 / smallTextScale) - fontRender.FONT_HEIGHT + 1, 0xFFFFFF, true); - - GL11.glPopMatrix(); - - GL11.glDisable(GL11.GL_ALPHA_TEST); - } - - // See DimensionHelper.DimNameDisplayed for real names of these. - public static long getPrefix(String dimName) { - return switch (dimName) { - case "Ow", "Ne", "TF", "ED", "VA", "EA" -> 0L; - case "Mo" -> 1L; - case "De", "Ma", "Ph" -> 2L; - case "As", "Ca", "Ce", "Eu", "Ga", "Rb" -> 3L; - case "Io", "Me", "Ve" -> 4L; - case "En", "Mi", "Ob", "Ti", "Ra" -> 5L; - case "Pr", "Tr" -> 6L; - case "Ha", "KB", "MM", "Pl" -> 7L; - case "BC", "BE", "BF", "CB", "TE", "VB" -> 8L; - case "An", "Ho", "Np", "Mh", "MB", "Se" -> 9L; - case "DD" -> 10L; - default -> -1L; - }; - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java b/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java deleted file mode 100644 index 61fdff46a2..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java +++ /dev/null @@ -1,121 +0,0 @@ -package pers.gwyog.gtneioreplugin.util; - -import static pers.gwyog.gtneioreplugin.Config.CSVName; -import static pers.gwyog.gtneioreplugin.Config.CSVnameSmall; -import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.instanceDir; - -import java.io.BufferedWriter; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat; -import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.OreLayerWrapper; - -// todo: yeet any opencsv usage. -public class CSVMaker implements Runnable { - - public void runSmallOres() { - try { - Iterator<Map.Entry<String, GT5OreSmallHelper.OreSmallWrapper>> it = GT5OreSmallHelper.mapOreSmallWrapper - .entrySet() - .iterator(); - List<SmallOre> SmallOreVeins = new ArrayList<>(); - while (it.hasNext()) { - SmallOre oremix = new SmallOre(); - - Map.Entry<String, GT5OreSmallHelper.OreSmallWrapper> pair = it.next(); - GT5OreSmallHelper.OreSmallWrapper oreLayer = pair.getValue(); - - Map<String, Boolean> Dims = GT5OreSmallHelper.bufferedDims.get(oreLayer); - - oremix.setOreName(oreLayer.oreGenName); - oremix.setOreMeta(oreLayer.oreMeta); - oremix.setHeight(oreLayer.worldGenHeightRange); - oremix.setAmount(oreLayer.amountPerChunk); - oremix.setDims(Dims); - - SmallOreVeins.add(oremix); - - it.remove(); // avoids a ConcurrentModificationException - } - - BufferedWriter one = Files.newBufferedWriter( - instanceDir.toPath() - .resolve(CSVnameSmall)); - Collections.sort(SmallOreVeins); - - // header first - one.write(SmallOre.getCsvHeader()); - one.newLine(); - for (SmallOre ore : SmallOreVeins) { - one.write(ore.getCsvEntry()); - one.newLine(); - } - one.flush(); - one.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public void run() { - runVeins(); - runSmallOres(); - } - - public void runVeins() { - try { - Iterator<Map.Entry<String, OreLayerWrapper>> it = GT5OreLayerHelper.mapOreLayerWrapper.entrySet() - .iterator(); - List<Oremix> OreVeins = new ArrayList<>(); - while (it.hasNext()) { - Oremix oremix = new Oremix(); - - Map.Entry<String, OreLayerWrapper> pair = it.next(); - Map<String, Boolean> Dims = GT5OreLayerHelper.bufferedDims.get(pair.getValue()); - OreLayerWrapper oreLayer = pair.getValue(); - oremix.setOreMixName(oreLayer.veinName); - oremix.setPrimary(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[0])); - oremix.setSecondary(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[1])); - oremix.setInbetween(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[2])); - oremix.setSporadic(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[3])); - oremix.setSize(oreLayer.size); - oremix.setHeight(oreLayer.worldGenHeightRange); - oremix.setDensity(oreLayer.density); - oremix.setWeight(oreLayer.randomWeight); - oremix.setOreMixIDs( - Integer.toString(oreLayer.Meta[0]) + "|" - + Integer.toString(oreLayer.Meta[1]) - + "|" - + Integer.toString(oreLayer.Meta[2]) - + "|" - + Integer.toString(oreLayer.Meta[3])); - oremix.setDims(Dims); - OreVeins.add(oremix); - - it.remove(); // avoids a ConcurrentModificationException - } - BufferedWriter one = Files.newBufferedWriter( - instanceDir.toPath() - .resolve(CSVName)); - Collections.sort(OreVeins); - - // header first - one.write(Oremix.getCsvHeader()); - one.newLine(); - for (Oremix ore : OreVeins) { - one.write(ore.getCsvEntry()); - one.newLine(); - } - one.flush(); - one.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java deleted file mode 100644 index db7201323b..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java +++ /dev/null @@ -1,351 +0,0 @@ -package pers.gwyog.gtneioreplugin.util; - -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.ANUBIS; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.ASTEROIDS; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.BARNARDC; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.BARNARDE; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.BARNARDF; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.CALLISTO; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.CENTAURIA; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.CERES; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.DEEPDARK; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.DEIMOS; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.ENCELADUS; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.ENDASTEROIDS; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.EUROPA; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.GANYMEDE; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.HAUMEA; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.HORUS; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.IO; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.KUIPERBELT; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.MAAHES; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.MAKEMAKE; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.MARS; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.MEHENBELT; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.MERCURY; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.MIRANDA; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.MOON; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.NEPER; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.OBERON; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.PHOBOS; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.PLUTO; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.PROTEUS; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.ROSS128B; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.ROSS128BA; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.SETH; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.TCETIE; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.TITAN; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.TRITON; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.VEGAB; -import static bloodasp.galacticgreg.api.enums.DimensionDef.DimNames.VENUS; -import static pers.gwyog.gtneioreplugin.Config.maxTooltipLines; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.minecraft.util.StatCollector; - -import gregtech.common.OreMixBuilder; - -public class DimensionHelper { - - public static final String[] DimName = { - // Non GC dimensions in progression order instead of alphabetical - "Overworld", "Nether", "Twilight", "TheEnd", "EndAsteroid", - // T1 - "GalacticraftCore_Moon", - // T2 - "GalaxySpace_Deimos", "GalacticraftMars_Mars", "GalaxySpace_Phobos", - // T3 - "GalacticraftMars_Asteroids", "GalaxySpace_Callisto", "GalaxySpace_Ceres", "GalaxySpace_Europa", - "GalaxySpace_Ganymede", "Ross128b", - // T4 - "GalaxySpace_Io", "GalaxySpace_Mercury", "GalaxySpace_Venus", - // T5 - "GalaxySpace_Enceladus", "GalaxySpace_Miranda", "GalaxySpace_Oberon", "GalaxySpace_Titan", "Ross128ba", - // T6 - "GalaxySpace_Proteus", "GalaxySpace_Triton", - // T7 - "GalaxySpace_Haumea", "GalaxySpace_Kuiperbelt", "GalaxySpace_MakeMake", "GalaxySpace_Pluto", - // T8 - "GalaxySpace_BarnardC", "GalaxySpace_BarnardE", "GalaxySpace_BarnardF", "GalaxySpace_CentauriA", - "GalaxySpace_TcetiE", "GalaxySpace_VegaB", - // T9 - "GalacticraftAmunRa_Anubis", "GalacticraftAmunRa_Horus", "GalacticraftAmunRa_Maahes", - "GalacticraftAmunRa_MehenBelt", "GalacticraftAmunRa_Neper", "GalacticraftAmunRa_Seth", - // T10 - "Underdark", }; - - public static final String[] DimNameTrimmed = Arrays.stream(DimName) - .map( - n -> n.replaceAll("GalacticraftCore_", "") - .replaceAll("GalacticraftMars_", "") - .replaceAll("GalaxySpace_", "") - .replaceAll("GalacticraftAmunRa_", "")) - .toArray(String[]::new); - - public static final String[] DimNameDisplayed = { // first 2 letters if one word else 1 letter of every word, except - // capital letter in - // name, then 1rst + capital Moon = Mo, BarnardC = BC, EndAsteroid = EA - // Non GC dimensions in progression order instead of alphabetical - "Ow", // Overworld - "Ne", // Nether - "TF", // Twilight - "ED", // TheEnd because En = Encalus - "EA", // EndAsteroid - // T1 - "Mo", // GalacticraftCore_Moon - // T2 - "De", // GalaxySpace_Deimos - "Ma", // GalacticraftMars_Mars - "Ph", // GalaxySpace_Phobos - // T3 - "As", // GalacticraftMars_Asteroids - "Ca", // GalaxySpace_Callisto - "Ce", // GalaxySpace_Ceres - "Eu", // GalaxySpace_Europa - "Ga", // GalaxySpace_Ganymede - "Rb", // Ross128b - // T4 - "Io", // GalaxySpace_Io - "Me", // GalaxySpace_Mercury - "Ve", // GalaxySpace_Venus - // T5 - "En", // GalaxySpace_Enceladus - "Mi", // GalaxySpace_Miranda - "Ob", // GalaxySpace_Oberon - "Ti", // GalaxySpace_Titan - "Ra", // Ross128ba - // T6 - "Pr", // GalaxySpace_Proteus - "Tr", // GalaxySpace_Triton - // T7 - "Ha", // GalaxySpace_Haumea - "KB", // GalaxySpace_Kuiperbelt - "MM", // GalaxySpace_MakeMake - "Pl", // GalaxySpace_Pluto - // T8 - "BC", // GalaxySpace_BarnardC - "BE", // GalaxySpace_BarnardE - "BF", // GalaxySpace_BarnardF - "CB", // GalaxySpace_CentauriA is actually α Centauri Bb - "TE", // GalaxySpace_TcetiE - "VB", // GalaxySpace_VegaB - // T9 - "An", // GalacticraftAmunRa_Anubis - "Ho", // GalacticraftAmunRa_Horus - "Mh", // GalacticraftAmunRa_Maahes - "MB", // GalacticraftAmunRa_MehenBelt - "Np", // GalacticraftAmunRa_Neper - "Se", // GalacticraftAmunRa_Seth - // T10 - "DD", // Underdark - }; - - private static final HashMap<String, List<String>> tooltipBuffer = new HashMap<>(); - - private static List<String> computeString(String line) { - String[] dims = parseDimNames(line); - for (int j = 0; j < dims.length; j++) { - String s = dims[j]; - for (int i = 0; i < DimNameDisplayed.length; i++) { - if (s.equals(DimNameDisplayed[i])) { - String k = DimNameTrimmed[i]; - s = StatCollector.translateToLocal("gtnop.world." + k); - s = switch (k) { - case "Moon" -> "T1: " + s; - case "Deimos", "Mars", "Phobos" -> "T2: " + s; - case "Asteroids", "Callisto", "Ceres", "Europa", "Ganymede", "Ross128b" -> "T3: " + s; - case "Io", "Mercury", "Venus" -> "T4: " + s; - case "Enceladus", "Miranda", "Oberon", "Titan", "Ross128ba" -> "T5: " + s; - case "Proteus", "Triton" -> "T6: " + s; - case "Haumea", "Kuiperbelt", "MakeMake", "Pluto" -> "T7: " + s; - case "BarnardC", "BarnardE", "BarnardF", "CentauriA", "TcetiE", "VegaB" -> "T8: " + s; - case "Anubis", "Horus", "Maahes", "MehenBelt", "Neper", "Seth" -> "T9: " + s; - case "Underdark" -> "T10: " + s; - default -> s; - }; - - dims[j] = s; - } - } - } - - if (dims.length > maxTooltipLines) { - dims = StringPaddingHack.stringsToSpacedColumns( - dims, - dims.length / maxTooltipLines + (dims.length % maxTooltipLines == 0 ? 0 : 1), - 2); - } - - return Arrays.asList(dims); - } - - public static String[] parseDimNames(String line) { - String[] dims = line.split(","); - for (int j = 0; j < dims.length; j++) { - String s = dims[j]; - s = s.replaceAll(",", ""); - s = s.trim(); - dims[j] = s; - } - return dims; - } - - public static Map<String, Boolean> getDims(GT5OreLayerHelper.OreLayerWrapper oreLayer) { - Map<String, Boolean> enabledDims = new HashMap<>(); - Map<String, Boolean> origNames = oreLayer.allowedDimWithOrigNames; - - for (String dimName : origNames.keySet()) { - String abbr = getDimAbbreviatedName(dimName); - if (!origNames.getOrDefault(dimName, false)) { - continue; - } - enabledDims.put(abbr, true); - } - return enabledDims; - } - - public static Map<String, Boolean> getDims(GT5OreSmallHelper.OreSmallWrapper ore) { - Map<String, Boolean> enabledDims = new HashMap<>(); - Map<String, Boolean> origNames = ore.allowedDimWithOrigNames; - - for (String dimName : origNames.keySet()) { - String abbr = getDimAbbreviatedName(dimName); - if (!origNames.getOrDefault(dimName, false)) { - continue; - } - enabledDims.put(abbr, true); - } - return enabledDims; - } - - public static String getDimAbbreviatedName(String dimName) { - String abbreviatedName; - switch (dimName) { - case (OreMixBuilder.OW) -> abbreviatedName = "Ow"; // Overworld - case OreMixBuilder.NETHER -> abbreviatedName = "Ne"; // Nether - case OreMixBuilder.TWILIGHT_FOREST -> abbreviatedName = "TF"; // Twilight - case OreMixBuilder.THE_END -> abbreviatedName = "ED"; // TheEnd because En = Encalus - case ENDASTEROIDS -> abbreviatedName = "EA"; // EndAsteroid - // T1 - case MOON -> abbreviatedName = "Mo"; // GalacticraftCore_Moon - // T2 - case DEIMOS -> abbreviatedName = "De"; // GalaxySpace_Deimos - case MARS -> abbreviatedName = "Ma"; // GalacticraftMars_Mars - case PHOBOS -> abbreviatedName = "Ph"; // GalaxySpace_Phobos - // T3 - case ASTEROIDS -> abbreviatedName = "As"; // GalacticraftMars_Asteroids - case CALLISTO -> abbreviatedName = "Ca"; // GalaxySpace_Callisto - case CERES -> abbreviatedName = "Ce"; // GalaxySpace_Ceres - case EUROPA -> abbreviatedName = "Eu"; // GalaxySpace_Europa - case GANYMEDE -> abbreviatedName = "Ga"; // GalaxySpace_Ganymede - case ROSS128B -> abbreviatedName = "Rb"; // Ross128b - // T4 - case IO -> abbreviatedName = "Io"; // GalaxySpace_Io - case MERCURY -> abbreviatedName = "Me"; // GalaxySpace_Mercury - case VENUS -> abbreviatedName = "Ve"; // GalaxySpace_Venus - // T5 - case ENCELADUS -> abbreviatedName = "En"; // GalaxySpace_Enceladus - case MIRANDA -> abbreviatedName = "Mi"; // GalaxySpace_Miranda - case OBERON -> abbreviatedName = "Ob"; // GalaxySpace_Oberon - case TITAN -> abbreviatedName = "Ti"; // GalaxySpace_Titan - case ROSS128BA -> abbreviatedName = "Ra"; // Ross128ba - // T6 - case PROTEUS -> abbreviatedName = "Pr"; // GalaxySpace_Proteus - case TRITON -> abbreviatedName = "Tr"; // GalaxySpace_Triton - // T7 - case HAUMEA -> abbreviatedName = "Ha"; // GalaxySpace_Haumea - case KUIPERBELT -> abbreviatedName = "KB"; // GalaxySpace_Kuiperbelt - case MAKEMAKE -> abbreviatedName = "MM"; // GalaxySpace_MakeMake - case PLUTO -> abbreviatedName = "Pl"; // GalaxySpace_Pluto - // T8 - case BARNARDC -> abbreviatedName = "BC"; // GalaxySpace_BarnardC - case BARNARDE -> abbreviatedName = "BE"; // GalaxySpace_BarnardE - case BARNARDF -> abbreviatedName = "BF"; // GalaxySpace_BarnardF - case CENTAURIA -> abbreviatedName = "CB"; // GalaxySpace_CentauriA is actually α Centauri Bb - case TCETIE -> abbreviatedName = "TE"; // GalaxySpace_TcetiE - case VEGAB -> abbreviatedName = "VB"; // GalaxySpace_VegaB - // T9 - case ANUBIS -> abbreviatedName = "An"; // GalacticraftAmunRa_Anubis - case HORUS -> abbreviatedName = "Ho"; // GalacticraftAmunRa_Horus - case MAAHES -> abbreviatedName = "Mh"; // GalacticraftAmunRa_Maahes - case MEHENBELT -> abbreviatedName = "MB"; // GalacticraftAmunRa_MehenBelt - case NEPER -> abbreviatedName = "Np"; // GalacticraftAmunRa_Neper - case SETH -> abbreviatedName = "Se"; // GalacticraftAmunRa_Seth - // T10 - case DEEPDARK -> abbreviatedName = "DD"; // Underdark - default -> { - throw new IllegalStateException("String: " + dimName + " has no abbredged name!"); - } - } - return abbreviatedName; - } - - public static String getFullName(String dimName) { - - return switch (dimName) { - case "Ow" -> (OreMixBuilder.OW); // Overworld - case "Ne" -> OreMixBuilder.NETHER; // Nether - case "TF" -> OreMixBuilder.TWILIGHT_FOREST; // Twilight - case "ED" -> OreMixBuilder.THE_END; // TheEnd because En = Encalus - case "EA" -> ENDASTEROIDS; // EndAsteroid - // T1 - case "Mo" -> MOON; // GalacticraftCore_Moon - // T2 - case "De" -> DEIMOS; // GalaxySpace_Deimos - case "Ma" -> MARS; // GalacticraftMars_Mars - case "Ph" -> PHOBOS; // GalaxySpace_Phobos - // T3 - case "As" -> ASTEROIDS; // GalacticraftMars_Asteroids - case "Ca" -> CALLISTO; // GalaxySpace_Callisto - case "Ce" -> CERES; // GalaxySpace_Ceres - case "Eu" -> EUROPA; // GalaxySpace_Europa - case "Ga" -> GANYMEDE; // GalaxySpace_Ganymede - case "Rb" -> ROSS128B; // Ross128b - // T4 - case "Io" -> IO; // GalaxySpace_Io - case "Me" -> MERCURY; // GalaxySpace_Mercury - case "Ve" -> VENUS; // GalaxySpace_Venus - // T5 - case "En" -> ENCELADUS; // GalaxySpace_Enceladus - case "Mi" -> MIRANDA; // GalaxySpace_Miranda - case "Ob" -> OBERON; // GalaxySpace_Oberon - case "Ti" -> TITAN; // GalaxySpace_Titan - case "Ra" -> ROSS128BA; // Ross128ba - // T6 - case "Pr" -> PROTEUS; // GalaxySpace_Proteus - case "Tr" -> TRITON; // GalaxySpace_Triton - // T7 - case "Ha" -> HAUMEA; // GalaxySpace_Haumea - case "KB" -> KUIPERBELT; // GalaxySpace_Kuiperbelt - case "MM" -> MAKEMAKE; // GalaxySpace_MakeMake - case "Pl" -> PLUTO; // GalaxySpace_Pluto - // T8 - case "BC" -> BARNARDC; // GalaxySpace_BarnardC - case "BE" -> BARNARDE; // GalaxySpace_BarnardE - case "BF" -> BARNARDF; // GalaxySpace_BarnardF - case "CB" -> CENTAURIA; // GalaxySpace_CentauriA is actually α Centauri Bb - case "TE" -> TCETIE; // GalaxySpace_TcetiE - case "VB" -> VEGAB; // GalaxySpace_VegaB - // T9 - case "An" -> ANUBIS; // GalacticraftAmunRa_Anubis - case "Ho" -> HORUS; // GalacticraftAmunRa_Horus - case "Mh" -> MAAHES; // GalacticraftAmunRa_Maahes - case "MB" -> MEHENBELT; // GalacticraftAmunRa_MehenBelt - case "Np" -> NEPER; // GalacticraftAmunRa_Neper - case "Se" -> SETH; // GalacticraftAmunRa_Seth - // T10 - case "DD" -> DEEPDARK; // Underdark - default -> { - throw new IllegalStateException("String: " + dimName + " has no abbredged name!"); - } - }; - } - - public static List<String> convertCondensedStringToToolTip(String line) { - return tooltipBuffer.computeIfAbsent(line, (String tmp) -> computeString(line)); - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java deleted file mode 100644 index 246ace7fda..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java +++ /dev/null @@ -1,125 +0,0 @@ -package pers.gwyog.gtneioreplugin.util; - -import static pers.gwyog.gtneioreplugin.util.DimensionHelper.getDims; -import static pers.gwyog.gtneioreplugin.util.OreVeinLayer.*; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.minecraft.item.ItemStack; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OreMixes; -import gregtech.common.OreMixBuilder; - -public class GT5OreLayerHelper { - - public static class NormalOreDimensionWrapper { - - public final ArrayList<OreLayerWrapper> internalDimOreList = new ArrayList<>(); - public final HashMap<OreLayerWrapper, Double> oreVeinToProbabilityInDimension = new HashMap<>(); - - // Calculate all weights of ore veins once dimension is initialised. - private void calculateWeights() { - int totalWeight = 0; - for (OreLayerWrapper oreVein : internalDimOreList) { - totalWeight += oreVein.randomWeight; - } - for (OreLayerWrapper oreVein : internalDimOreList) { - oreVeinToProbabilityInDimension.put(oreVein, ((double) oreVein.randomWeight) / ((double) totalWeight)); - } - } - } - - private static final int DIMENSION_COUNT = 33; - public static final Integer[] weightPerWorld = new Integer[DIMENSION_COUNT]; - public static final Integer[] DimIDs = new Integer[DIMENSION_COUNT]; - public static final HashMap<String, OreLayerWrapper> mapOreLayerWrapper = new HashMap<>(); - public static final HashMap<OreLayerWrapper, Map<String, Boolean>> bufferedDims = new HashMap<>(); - public static final HashMap<String, NormalOreDimensionWrapper> dimToOreWrapper = new HashMap<>(); - - public static void init() { - Arrays.fill(weightPerWorld, 0); - Arrays.fill(DimIDs, 0); - for (OreMixes mix : OreMixes.values()) - mapOreLayerWrapper.put(mix.oreMixBuilder.oreMixName, new OreLayerWrapper(mix.oreMixBuilder)); - for (OreLayerWrapper layer : mapOreLayerWrapper.values()) { - bufferedDims.put(layer, getDims(layer)); - } - - // --- Handling of dimToOreWrapper --- - - // Get dims as "Ow,Ne,Ma" etc. - bufferedDims.forEach((veinInfo, dims) -> { - - for (String dim : dims.keySet()) { - NormalOreDimensionWrapper dimensionOres = dimToOreWrapper - .getOrDefault(dim, new NormalOreDimensionWrapper()); - dimensionOres.internalDimOreList.add(veinInfo); - dimToOreWrapper.put(dim, dimensionOres); - } - - // Calculate probabilities for each dim. - for (String dim : dimToOreWrapper.keySet()) { - dimToOreWrapper.get(dim) - .calculateWeights(); - } - }); - // --- End of handling for dimToOreWrapper --- - } - - public static class OreLayerWrapper { - - public final String veinName, worldGenHeightRange; - public final short[] Meta = new short[4]; - public final short randomWeight, size, density; - public final Map<String, Boolean> allowedDimWithOrigNames; - - public final Materials mPrimaryVeinMaterial; - public final Materials mSecondaryMaterial; - public final Materials mBetweenMaterial; - public final Materials mSporadicMaterial; - - public OreLayerWrapper(OreMixBuilder mix) { - this.veinName = mix.oreMixName; - this.Meta[0] = (short) mix.primary.mMetaItemSubID; - this.Meta[1] = (short) mix.secondary.mMetaItemSubID; - this.Meta[2] = (short) mix.between.mMetaItemSubID; - this.Meta[3] = (short) mix.sporadic.mMetaItemSubID; - - this.mPrimaryVeinMaterial = mix.primary; - this.mSecondaryMaterial = mix.secondary; - this.mBetweenMaterial = mix.between; - this.mSporadicMaterial = mix.sporadic; - - this.size = (short) mix.size; - this.density = (short) mix.density; - this.worldGenHeightRange = mix.minY + "-" + mix.maxY; - this.randomWeight = (short) mix.weight; - - this.allowedDimWithOrigNames = mix.dimsEnabled; - } - - public List<ItemStack> getVeinLayerOre(int maximumMaterialIndex, int veinLayer) { - List<ItemStack> stackList = new ArrayList<>(); - for (int i = 0; i < maximumMaterialIndex; i++) { - stackList.add(getLayerOre(veinLayer, i)); - } - return stackList; - } - - public ItemStack getLayerOre(int veinLayer, int materialIndex) { - return new ItemStack(GregTech_API.sBlockOres1, 1, Meta[veinLayer] + materialIndex * 1000); - } - - public boolean containsOre(short materialIndex) { - return Meta[VEIN_PRIMARY] == materialIndex || Meta[VEIN_SECONDARY] == materialIndex - || Meta[VEIN_BETWEEN] == materialIndex - || Meta[VEIN_SPORADIC] == materialIndex; - } - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java deleted file mode 100644 index bed47193b9..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java +++ /dev/null @@ -1,200 +0,0 @@ -package pers.gwyog.gtneioreplugin.util; - -import static pers.gwyog.gtneioreplugin.util.DimensionHelper.getDims; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.minecraft.item.ItemStack; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.SmallOres; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.world.GT_Worldgen; -import gregtech.common.GT_Worldgen_GT_Ore_SmallPieces; -import gregtech.common.SmallOreBuilder; - -public class GT5OreSmallHelper { - - private static final int SMALL_ORE_BASE_META = 16000; - public static boolean restrictBiomeSupport = false; - public static final List<ItemStack> oreSmallList = new ArrayList<>(); - public static final HashMap<String, OreSmallWrapper> mapOreSmallWrapper = new HashMap<>(); - public static final HashMap<String, Short> mapOreDropUnlocalizedNameToOreMeta = new HashMap<>(); - public static final HashMap<Short, List<ItemStack>> mapOreMetaToOreDrops = new HashMap<>(); - public static final HashMap<OreSmallWrapper, Map<String, Boolean>> bufferedDims = new HashMap<>(); - public static final HashMap<String, SmallOreDimensionWrapper> dimToSmallOreWrapper = new HashMap<>(); - - public static class SmallOreDimensionWrapper { - - public final ArrayList<OreSmallWrapper> internalDimOreList = new ArrayList<>(); - public final HashMap<OreSmallWrapper, Double> oreVeinToProbabilityInDimension = new HashMap<>(); - - // Calculate all weights of ore veins once dimension is initialised. - private void calculateWeights() { - int totalWeight = 0; - for (OreSmallWrapper oreVein : internalDimOreList) { - totalWeight += oreVein.amountPerChunk; - } - for (OreSmallWrapper oreVein : internalDimOreList) { - oreVeinToProbabilityInDimension - .put(oreVein, ((double) oreVein.amountPerChunk) / ((double) totalWeight)); - } - } - } - - public static void init() { - checkExtraSupport(); - ItemStack stack; - Materials material; - short meta; - Map<String, SmallOreBuilder> smallOreDefMap = new HashMap<>(); - - for (SmallOres ore : SmallOres.values()) { - smallOreDefMap.put(ore.smallOreBuilder.smallOreName, ore.smallOreBuilder); - } - - for (GT_Worldgen worldGen : GregTech_API.sWorldgenList) { - if (!worldGen.mWorldGenName.startsWith("ore.small.") - || !(worldGen instanceof GT_Worldgen_GT_Ore_SmallPieces)) { - continue; - } - - GT_Worldgen_GT_Ore_SmallPieces worldGenSmallPieces = (GT_Worldgen_GT_Ore_SmallPieces) worldGen; - meta = worldGenSmallPieces.mMeta; - if (meta < 0) break; - material = GregTech_API.sGeneratedMaterials[meta]; - mapOreSmallWrapper.put( - worldGen.mWorldGenName, - new OreSmallWrapper(smallOreDefMap.get(worldGenSmallPieces.mWorldGenName))); - if (mapOreMetaToOreDrops.containsKey(meta)) { - continue; - } - - List<ItemStack> stackList = new ArrayList<>(); - stack = GT_OreDictUnificator - .get(OrePrefixes.gemExquisite, material, GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { - mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); - stackList.add(stack); - } - stack = GT_OreDictUnificator - .get(OrePrefixes.gemFlawless, material, GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { - mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); - stackList.add(stack); - } - stack = GT_OreDictUnificator.get(OrePrefixes.gem, material, 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { - mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); - stackList.add(stack); - } - stack = GT_OreDictUnificator - .get(OrePrefixes.gemFlawed, material, GT_OreDictUnificator.get(OrePrefixes.crushed, material, 1L), 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { - mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); - stackList.add(stack); - } - stack = GT_OreDictUnificator.get(OrePrefixes.crushed, material, 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { - mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); - stackList.add(stack); - } - stack = GT_OreDictUnificator.get( - OrePrefixes.gemChipped, - material, - GT_OreDictUnificator.get(OrePrefixes.dustImpure, material, 1L), - 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { - mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); - stackList.add(stack); - } - stack = GT_OreDictUnificator.get(OrePrefixes.dustImpure, material, 1L); - if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.containsKey(stack.getUnlocalizedName())) { - mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta); - stackList.add(stack); - } - oreSmallList.add(new ItemStack(GregTech_API.sBlockOres1, 1, meta + SMALL_ORE_BASE_META)); - mapOreMetaToOreDrops.put(meta, stackList); - - } - for (OreSmallWrapper oreSmallWrapper : mapOreSmallWrapper.values()) { - bufferedDims.put(oreSmallWrapper, getDims(oreSmallWrapper)); - } - - // --- Handling of dimToOreWrapper --- - - // Get dims as "Ow,Ne,Ma" etc. - bufferedDims.forEach((veinInfo, dims) -> { - for (String dim : dims.keySet()) { - SmallOreDimensionWrapper dimensionSmallOres = dimToSmallOreWrapper - .getOrDefault(dim, new SmallOreDimensionWrapper()); - dimensionSmallOres.internalDimOreList.add(veinInfo); - dimToSmallOreWrapper.put(dim, dimensionSmallOres); - } - - // Calculate probabilities for each dim. - for (String dim : dimToSmallOreWrapper.keySet()) { - dimToSmallOreWrapper.get(dim) - .calculateWeights(); - } - }); - // --- End of handling for dimToOreWrapper --- - } - - private static void checkExtraSupport() { - Class<?> clazzGTOreSmall = null; - try { - clazzGTOreSmall = Class.forName("gregtech.common" + ".GT_Worldgen_GT_Ore_SmallPieces"); - } catch (ClassNotFoundException ignored) {} - if (clazzGTOreSmall != null) { - try { - clazzGTOreSmall.getField("mRestrictBiome"); - restrictBiomeSupport = true; - } catch (Exception ignored) {} - } - } - - public static Materials[] getDroppedDusts() { - return new Materials[] { Materials.Stone, Materials.Netherrack, Materials.Endstone, Materials.GraniteBlack, - Materials.GraniteRed, Materials.Marble, Materials.Basalt, Materials.Stone }; - } - - public static class OreSmallWrapper { - - public final String oreGenName; - public final short oreMeta; - public final String worldGenHeightRange; - public final short amountPerChunk; - - public final Map<String, Boolean> allowedDimWithOrigNames; - - @SuppressWarnings("unused") - public Materials getOreMaterial() { - return oreMaterial; - } - - private final Materials oreMaterial; - - public OreSmallWrapper(SmallOreBuilder ore) { - this.oreGenName = ore.smallOreName; - this.oreMeta = (short) ore.ore.mMetaItemSubID; - this.worldGenHeightRange = ore.minY + "-" + ore.maxY; - this.amountPerChunk = (short) ore.amount; - this.oreMaterial = ore.ore; - - this.allowedDimWithOrigNames = ore.dimsEnabled; - } - - public List<ItemStack> getMaterialDrops(int maximumIndex) { - List<ItemStack> stackList = new ArrayList<>(); - for (int i = 0; i < maximumIndex; i++) - stackList.add(new ItemStack(GregTech_API.sBlockOres1, 1, oreMeta + SMALL_ORE_BASE_META + i * 1000)); - return stackList; - } - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5UndergroundFluidHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5UndergroundFluidHelper.java deleted file mode 100644 index d08709d775..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5UndergroundFluidHelper.java +++ /dev/null @@ -1,149 +0,0 @@ -package pers.gwyog.gtneioreplugin.util; - -import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.LOG; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; - -import com.google.common.collect.BiMap; - -import gregtech.GT_Mod; -import gregtech.api.objects.GT_UO_Dimension; -import gregtech.api.objects.GT_UO_DimensionList; -import gregtech.api.objects.GT_UO_Fluid; - -public class GT5UndergroundFluidHelper { - - /** - * Need to store fluid name instead of fluid because fluid instance might be different between gas and liquid - */ - private static final Map<String, List<UndergroundFluidWrapper>> fluidMap = new HashMap<>(); - - @SuppressWarnings("unchecked") - public static void init() { - try { - Field fieldDimensionList = GT_UO_DimensionList.class.getDeclaredField("fDimensionList"); - fieldDimensionList.setAccessible(true); - BiMap<String, GT_UO_Dimension> dimensionList = (BiMap<String, GT_UO_Dimension>) fieldDimensionList - .get(GT_Mod.gregtechproxy.mUndergroundOil); - for (Map.Entry<String, GT_UO_Dimension> dimensionEntry : dimensionList.entrySet()) { - String rawDimension = dimensionEntry.getKey(); - String dimension; - try { - dimension = getDimensionFromID(Integer.parseInt(rawDimension)); - } catch (NumberFormatException ignored) { - dimension = getDimensionForEdgeCase(rawDimension); - if (dimension == null) { - for (int i = 0; i < DimensionHelper.DimNameTrimmed.length; i++) { - if (DimensionHelper.DimNameTrimmed[i].equalsIgnoreCase(rawDimension)) { - dimension = DimensionHelper.DimNameDisplayed[i]; - break; - } - } - } - } - if (dimension == null) { - LOG.warn("Unknown dimension found in GT5 config: " + rawDimension); - continue; - } - - Field fieldFluids = GT_UO_Dimension.class.getDeclaredField("fFluids"); - fieldFluids.setAccessible(true); - BiMap<String, GT_UO_Fluid> fluids = (BiMap<String, GT_UO_Fluid>) fieldFluids - .get(dimensionEntry.getValue()); - - int maxChance = 0; - for (Map.Entry<String, GT_UO_Fluid> fluidEntry : fluids.entrySet()) { - maxChance += fluidEntry.getValue().Chance; - } - - for (Map.Entry<String, GT_UO_Fluid> fluidEntry : fluids.entrySet()) { - Fluid fluid = FluidRegistry.getFluid(fluidEntry.getKey()); - if (fluid != null) { - UndergroundFluidWrapper wrapper = new UndergroundFluidWrapper( - dimension, - fluidEntry.getValue().Chance * 10000 / maxChance, - fluidEntry.getValue().MaxAmount, - fluidEntry.getValue().MinAmount); - if (fluidMap.containsKey(fluid.getName())) { - fluidMap.get(fluid.getName()) - .add(wrapper); - } else { - fluidMap.put(fluid.getName(), new ArrayList<>(Collections.singletonList(wrapper))); - } - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - - for (List<UndergroundFluidWrapper> wrappers : fluidMap.values()) { - wrappers.sort( - Comparator.comparingInt( - w -> Arrays.asList(DimensionHelper.DimNameDisplayed) - .indexOf(w.dimension))); - } - } - - public static List<UndergroundFluidWrapper> getEntry(String fluidName) { - return fluidMap.get(fluidName); - } - - public static Map<String, List<UndergroundFluidWrapper>> getAllEntries() { - return fluidMap; - } - - @SuppressWarnings("SwitchStatementWithTooFewBranches") - private static String getDimensionFromID(int id) { - return switch (id) { - case 0 -> "Ow"; - default -> null; - }; - } - - private static String getDimensionForEdgeCase(String rawDimension) { - return switch (rawDimension) { - case "aCentauriBb" -> "CB"; - case "BarnardaC" -> "BC"; - case "BarnardaE" -> "BE"; - case "BarnardaF" -> "BF"; - case "TCetiE" -> "TE"; - default -> { - LOG.warn("Unknown dimension name while parsing: " + rawDimension); - yield null; - } - }; - } - - public static class UndergroundFluidWrapper { - - /** - * Using {@link DimensionHelper#DimNameDisplayed} - */ - public final String dimension; - /** - * Chance of this fluid field being generated. 10000 means 100% of the dimension - */ - public final int chance; - - public final int maxAmount; - public final int minAmount; - - public UndergroundFluidWrapper(String dimension, int chance, int maxAmount, int minAmount) { - this.dimension = dimension; - this.chance = chance; - this.maxAmount = maxAmount; - this.minAmount = minAmount; - } - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/OreVeinLayer.java b/src/main/java/pers/gwyog/gtneioreplugin/util/OreVeinLayer.java deleted file mode 100644 index 3aaba2d1e4..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/OreVeinLayer.java +++ /dev/null @@ -1,18 +0,0 @@ -package pers.gwyog.gtneioreplugin.util; - -public class OreVeinLayer { - - public static final int VEIN_PRIMARY = 0; - public static final int VEIN_SECONDARY = 1; - public static final int VEIN_BETWEEN = 2; - public static final int VEIN_SPORADIC = 3; - - private static final String[] LAYER_NAMES = { "gtnop.gui.nei.primaryOre", "gtnop.gui.nei.secondaryOre", - "gtnop.gui.nei.betweenOre", "gtnop.gui" + ".nei.sporadicOre" }; - - public static String getOreVeinLayerName(int layerId) { - return LAYER_NAMES[layerId]; - } - - private OreVeinLayer() {} -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java b/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java deleted file mode 100644 index aba9497dbe..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java +++ /dev/null @@ -1,121 +0,0 @@ -package pers.gwyog.gtneioreplugin.util; - -import static pers.gwyog.gtneioreplugin.util.DimensionHelper.DimNameDisplayed; - -import java.util.Map; - -public class Oremix implements Comparable<Oremix> { - - private String oreMixName; - - private String primary = ""; - - private String secondary = ""; - - private String inbetween = ""; - - private String sporadic = ""; - - private String oreMixIDs = ""; - - private String height = ""; - - private int density; - - private int size; - - private int weight; - - private static final int sizeData = 10; // hors dims - - private Map<String, Boolean> dimensions; - - public void setDims(Map<String, Boolean> dims) { - this.dimensions = dims; - } - - public String getOreMixName() { - return this.oreMixName; - } - - public void setOreMixName(String s) { - this.oreMixName = s; - } - - public void setPrimary(String s) { - this.primary = s; - } - - public void setSecondary(String s) { - this.secondary = s; - } - - public void setInbetween(String s) { - this.inbetween = s; - } - - public void setSporadic(String s) { - this.sporadic = s; - } - - public void setOreMixIDs(String s) { - this.oreMixIDs = s; - } - - public void setHeight(String s) { - this.height = s; - } - - public void setDensity(int i) { - this.density = i; - } - - public void setSize(int i) { - this.size = i; - } - - public void setWeight(int i) { - this.weight = i; - } - - @Override - public int compareTo(Oremix ore) { - return ore.oreMixName.compareTo(ore.oreMixName); - } - - public static String getCsvHeader() { - String[] headers = new String[sizeData + DimNameDisplayed.length]; - headers[0] = "Ore Mix Name"; - headers[1] = "Primary Ore"; - headers[2] = "Secondary Ore"; - headers[3] = "InBetween Ore"; - headers[4] = "Sporadic Ore"; - headers[5] = "Ore Meta IDs"; - headers[6] = "Height"; - headers[7] = "Density"; - headers[8] = "Size"; - headers[9] = "Weight"; - for (int i = 0; i < DimNameDisplayed.length; i++) { - headers[sizeData + i] = DimensionHelper.getFullName(DimNameDisplayed[i]); - } - return String.join(",", headers); - } - - public String getCsvEntry() { - String[] values = new String[sizeData + DimNameDisplayed.length]; - values[0] = oreMixName; - values[1] = primary; - values[2] = secondary; - values[3] = inbetween; - values[4] = sporadic; - values[5] = oreMixIDs; - values[6] = height; - values[7] = Integer.toString(density); - values[8] = Integer.toString(size); - values[9] = Integer.toString(weight); - for (int i = 0; i < DimNameDisplayed.length; i++) { - values[sizeData + i] = Boolean.toString(dimensions.getOrDefault(DimNameDisplayed[i], false)); - } - return String.join(",", values); - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/SmallOre.java b/src/main/java/pers/gwyog/gtneioreplugin/util/SmallOre.java deleted file mode 100644 index 75a691ad1c..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/SmallOre.java +++ /dev/null @@ -1,82 +0,0 @@ -package pers.gwyog.gtneioreplugin.util; - -import static pers.gwyog.gtneioreplugin.util.DimensionHelper.DimNameDisplayed; - -import java.util.Map; - -@SuppressWarnings("unused") -public class SmallOre implements Comparable<SmallOre> { - - private String oreName; - private int oreMeta; - private int amount; - private String height = ""; - private static final int sizeData = 4; // hors dims - - private Map<String, Boolean> dimensions; - - public void setDims(Map<String, Boolean> dims) { - this.dimensions = dims; - } - - public String getOreName() { - return this.oreName; - } - - public void setOreName(String s) { - this.oreName = s; - } - - public int getOreMeta() { - return this.oreMeta; - } - - public void setOreMeta(int meta) { - this.oreMeta = meta; - } - - public String getHeight() { - return this.height; - } - - public void setHeight(String s) { - this.height = s; - } - - public void setAmount(int i) { - this.amount = i; - } - - public int getAmount() { - return this.amount; - } - - public static String getCsvHeader() { - String[] headers = new String[sizeData + DimNameDisplayed.length]; - headers[0] = "Ore Name"; - headers[1] = "Block Meta"; - headers[2] = "Height"; - headers[3] = "Amount Per Chunk"; - for (int i = 0; i < DimNameDisplayed.length; i++) { - headers[sizeData + i] = DimensionHelper.getFullName(DimNameDisplayed[i]); - } - return String.join(",", headers); - } - - public String getCsvEntry() { - String[] values = new String[sizeData + DimNameDisplayed.length]; - values[0] = oreName; - values[1] = Integer.toString(oreMeta); - values[2] = getHeight(); - values[3] = Integer.toString(amount); - for (int i = 0; i < DimNameDisplayed.length; i++) { - values[sizeData + i] = Boolean.toString(dimensions.getOrDefault(DimNameDisplayed[i], false)); - } - return String.join(",", values); - } - - @Override - public int compareTo(SmallOre other) { - return oreName.compareTo(other.oreName); - } -} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java b/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java deleted file mode 100644 index 3f6d3fa387..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java +++ /dev/null @@ -1,131 +0,0 @@ -package pers.gwyog.gtneioreplugin.util; - -import java.util.Arrays; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; - -import com.google.common.base.Strings; - -public class StringPaddingHack { - - private static final int SPACE_WIDTH = 4; - private static final int BOLD_SPACE_WIDTH = 5; - - /** - * Given a list of strings, arrange them into the requested number of columns with the specified spacing. Up to 3 - * additional spaces might be added between columns because this function relies on quirky font behaviors. - * - * @param strings List of strings to wrap into columns - * @param numColumns Number of columns, minimum of 1 - * @param minColumnSpacing Minimum amount of extra spaces between columns. - * @return strings wrapped into columns - */ - public static String[] stringsToSpacedColumns(String[] strings, int numColumns, int minColumnSpacing) { - if (numColumns < 1) { - throw new IllegalArgumentException( - String.format("Argument numColumns must be 1 or higher, got value %d", numColumns)); - } - if (numColumns > 1) { - int sliceSize = strings.length / numColumns; - int remainder = strings.length % numColumns; - String[][] columns = new String[numColumns][]; - int totalExtra = 0; - - // Arrange all strings into their proper columns so that the list of strings wraps through all columns - for (int i = 0; i < numColumns; i++) { - int extra = 0; - if (remainder > 0) { - remainder--; - extra = 1; - } - columns[i] = Arrays - .copyOfRange(strings, (sliceSize * i) + totalExtra, (sliceSize * (i + 1) + totalExtra + extra)); - - totalExtra += extra; - } - - // Add extra padding to all but the last columns to align the text - for (int i = 0; i < numColumns - 1; i++) { - columns[i] = padStrings(columns[i], minColumnSpacing); - } - - // Concatenate all columns into the final result - strings = columns[0]; - for (int i = 0; i < sliceSize; i++) { - for (int j = 1; j < numColumns; j++) { - strings[i] += columns[j][i]; - } - } - } - - return strings; - } - - /** - * Pads strings with spaces so that they are of equal length and adds to that the number of spaces specified and up - * to 3 if minExtraSpaces is below 3. Added spaces might be bold. - * <p> - * Relies on the quirk of bold space characters being 1 pixel wider than regular space characters in the default - * font renderer. - * - * @param strings List of strings - * @param minExtraSpaces The minimum number of extra spaces to add - * @return Array of strings padded with spaces to an equal length - */ - public static String[] padStrings(String[] strings, int minExtraSpaces) { - int[] widths = getStringWidths(strings); - int maxUnPaddedStrLength = 0; - int numSpacesAddedToLongestString = 0; - int maxPaddedStrLength = 0; - - // Making string width a multiple of 4 by adding bold spaces of width 5 - for (int i = 0; i < strings.length; i++) { - int mod = widths[i] % SPACE_WIDTH; - int numBoldSpacesToAdd = (SPACE_WIDTH - mod) % SPACE_WIDTH; - - // Keep track of the number of spaces added to the longest string - if (widths[i] > maxUnPaddedStrLength) { - numSpacesAddedToLongestString = numBoldSpacesToAdd; - maxUnPaddedStrLength = widths[i]; - } - - strings[i] += "§l" + Strings.repeat(" ", numBoldSpacesToAdd) + "§r"; - widths[i] += numBoldSpacesToAdd * BOLD_SPACE_WIDTH; - - // Keep track of the current widest string we currently have - if (widths[i] > maxPaddedStrLength) { - maxPaddedStrLength = widths[i]; - } - } - - // Make sure we pad at least up to the desired number of spaces from the longest string - if (numSpacesAddedToLongestString < minExtraSpaces) { - maxPaddedStrLength += (minExtraSpaces - numSpacesAddedToLongestString) * SPACE_WIDTH; - } - - // Add required spaces to equalize length of all strings to at least the target width - for (int i = 0; i < strings.length; i++) { - int numSpacesToAdd = (maxPaddedStrLength - widths[i]) / SPACE_WIDTH; - strings[i] += Strings.repeat(" ", numSpacesToAdd); - widths[i] += numSpacesToAdd * SPACE_WIDTH; - } - - return strings; - } - - /** - * Returns an array of font widths for the given array of strings - * - * @param strList Array of strings - * @return Array of font widths - */ - protected static int[] getStringWidths(String[] strList) { - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - int[] widths = new int[strList.length]; - for (int i = 0; i < strList.length; ++i) { - widths[i] = font.getStringWidth(strList[i]); - } - return widths; - } -} |