From 2a5ab51b85b20ccaaff400f225cf653ba77b96f7 Mon Sep 17 00:00:00 2001 From: BlueWeabo Date: Mon, 26 Aug 2024 20:39:28 +0300 Subject: merge sources and edit mcmod.info --- .../java/pers/gwyog/gtneioreplugin/Config.java | 22 + .../pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java | 95 ++++ .../gwyog/gtneioreplugin/plugin/IMCForNEI.java | 64 +++ .../gtneioreplugin/plugin/NEIPluginConfig.java | 35 ++ .../gwyog/gtneioreplugin/plugin/PluginBase.java | 54 ++ .../plugin/block/BlockDimensionDisplay.java | 47 ++ .../gtneioreplugin/plugin/block/ModBlocks.java | 27 + .../plugin/gregtech5/PluginGT5Base.java | 64 +++ .../plugin/gregtech5/PluginGT5SmallOreStat.java | 203 +++++++ .../gregtech5/PluginGT5UndergroundFluid.java | 165 ++++++ .../plugin/gregtech5/PluginGT5VeinStat.java | 202 +++++++ .../plugin/item/ItemDimensionDisplay.java | 55 ++ .../renderer/ItemDimensionDisplayRenderer.java | 78 +++ .../pers/gwyog/gtneioreplugin/util/CSVMaker.java | 229 ++++++++ .../gwyog/gtneioreplugin/util/DimensionHelper.java | 159 ++++++ .../gwyog/gtneioreplugin/util/GT5CFGHelper.java | 199 +++++++ .../gtneioreplugin/util/GT5OreLayerHelper.java | 139 +++++ .../gtneioreplugin/util/GT5OreSmallHelper.java | 195 +++++++ .../util/GT5UndergroundFluidHelper.java | 146 +++++ .../gwyog/gtneioreplugin/util/OreVeinLayer.java | 18 + .../pers/gwyog/gtneioreplugin/util/Oremix.java | 600 +++++++++++++++++++++ .../gtneioreplugin/util/StringPaddingHack.java | 131 +++++ .../gwyog/gtneioreplugin/util/Veinrenamer.java | 23 + .../pers/gwyog/gtneioreplugin/util/XtoBool.java | 33 ++ 24 files changed, 2983 insertions(+) create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/Config.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/IMCForNEI.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/block/BlockDimensionDisplay.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/block/ModBlocks.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5UndergroundFluid.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/item/ItemDimensionDisplay.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/renderer/ItemDimensionDisplayRenderer.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreLayerHelper.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/GT5OreSmallHelper.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/GT5UndergroundFluidHelper.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/OreVeinLayer.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/Oremix.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/Veinrenamer.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/XtoBool.java (limited to 'src/main/java') diff --git a/src/main/java/pers/gwyog/gtneioreplugin/Config.java b/src/main/java/pers/gwyog/gtneioreplugin/Config.java new file mode 100644 index 0000000000..8501ebabb1 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/Config.java @@ -0,0 +1,22 @@ +package pers.gwyog.gtneioreplugin; + +import java.io.File; + +import net.minecraftforge.common.config.Configuration; + +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public class Config { + + public final Configuration tConfig; + + public Config(FMLPreInitializationEvent preinit, String cfgname) { + File tFile = new File(preinit.getModConfigurationDirectory(), cfgname); + tConfig = new Configuration(tFile); + tConfig.load(); + } + + public void save() { + if (tConfig.hasChanged()) tConfig.save(); + } +} diff --git a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java new file mode 100644 index 0000000000..f16fa148e0 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java @@ -0,0 +1,95 @@ +package pers.gwyog.gtneioreplugin; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +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 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 { + + public static final String MODID = "gtneioreplugin"; + public static final String NAME = "GT NEI Ore Plugin GT:NH Mod"; + public static final String VERSION = Tags.VERSION; + public static final Logger LOG = LogManager.getLogger(NAME); + public static boolean csv = false; + public static String CSVname; + public static String CSVnameSmall; + public static int maxTooltipLines = 11; + 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) { + Config c = new Config(event, MODID + ".cfg"); + csv = c.tConfig.getBoolean( + "print csv", + "ALL", + false, + "print csv, you need apache commons collections to be injected in the minecraft jar."); + CSVname = c.tConfig.getString( + "CSV_name", + "ALL", + event.getModConfigurationDirectory() + "/GTNH-Oresheet.csv", + "rename the oresheet here, it will appear in /config"); + CSVnameSmall = c.tConfig.getString( + "CSV_name_for_Small_Ore_Sheet", + "ALL", + event.getModConfigurationDirectory() + "/GTNH-Small-Ores-Sheet.csv", + "rename the oresheet here, it will appear in /config"); + maxTooltipLines = c.tConfig.getInt( + "MaxToolTipLines", + "ALL", + 11, + 1, + Integer.MAX_VALUE, + "Maximum number of lines the dimension names tooltip can have before it wraps around."); + + c.save(); + } + + @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 (csv) { + 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 new file mode 100644 index 0000000000..2c69b68a4a --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/IMCForNEI.java @@ -0,0 +1,64 @@ +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 new file mode 100644 index 0000000000..6996cba220 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java @@ -0,0 +1,35 @@ +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 new file mode 100644 index 0000000000..5509341696 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java @@ -0,0 +1,54 @@ +package pers.gwyog.gtneioreplugin.plugin; + +import java.awt.*; + +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 new file mode 100644 index 0000000000..7d3b1eb5bc --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/block/BlockDimensionDisplay.java @@ -0,0 +1,47 @@ +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 new file mode 100644 index 0000000000..db953c7112 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/block/ModBlocks.java @@ -0,0 +1,27 @@ +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 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 new file mode 100644 index 0000000000..646e6d2bc7 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java @@ -0,0 +1,64 @@ +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 new file mode 100644 index 0000000000..76bd66d280 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java @@ -0,0 +1,203 @@ +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 getStoneDusts(int maximumIndex) { + List 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 = DimensionHelper.parseDimNames(GT5OreSmallHelper.bufferedDims.get(oreSmall)); + 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 positionedDropStackList; + private final List dimensionDisplayItems = new ArrayList<>(); + + public CachedOreSmallRecipe(String oreGenName, List stackList, List materialDustStackList, + List dropStackList) { + this.oreGenName = oreGenName; + this.positionedStackOreSmall = new PositionedStack(stackList, 2, 0); + this.positionedStackMaterialDust = new PositionedStack( + materialDustStackList, + 43, + 79 + getRestrictBiomeOffset()); + List 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 getIngredients() { + return dimensionDisplayItems; + } + + @Override + public PositionedStack getResult() { + return null; + } + + @Override + public List getOtherStacks() { + List 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 new file mode 100644 index 0000000000..8f7754bbde --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5UndergroundFluid.java @@ -0,0 +1,165 @@ +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> 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 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> 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 dimensionDisplayItems = new ArrayList<>(); + private final List chances = new ArrayList<>(); + private final List maxAmounts = new ArrayList<>(); + private final List minAmounts = new ArrayList<>(); + + private CachedUndergroundFluidRecipe(Fluid fluid, List 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 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 new file mode 100644 index 0000000000..98f168c2a7 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java @@ -0,0 +1,202 @@ +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 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 = DimensionHelper.parseDimNames(GT5OreLayerHelper.bufferedDims.get(oreLayer)); + 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 dimensionDisplayItems = new ArrayList<>(); + + public CachedVeinStatRecipe(String veinName, List stackListPrimary, + List stackListSecondary, List stackListBetween, + List 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 getIngredients() { + return dimensionDisplayItems; + } + + @Override + public PositionedStack getResult() { + return null; + } + + @Override + public List getOtherStacks() { + List 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 new file mode 100644 index 0000000000..b8e9301f3b --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/item/ItemDimensionDisplay.java @@ -0,0 +1,55 @@ +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 new file mode 100644 index 0000000000..0c670a6d3d --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/renderer/ItemDimensionDisplayRenderer.java @@ -0,0 +1,78 @@ +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 new file mode 100644 index 0000000000..1a56044219 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/CSVMaker.java @@ -0,0 +1,229 @@ +package pers.gwyog.gtneioreplugin.util; + +import java.io.BufferedWriter; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import com.opencsv.CSVWriter; +import com.opencsv.bean.ColumnPositionMappingStrategy; +import com.opencsv.bean.StatefulBeanToCsv; +import com.opencsv.bean.StatefulBeanToCsvBuilder; + +import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; +import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat; +import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.OreLayerWrapper; + +public class CSVMaker implements Runnable { + + public CSVMaker() {} + + public static List Combsort(List list) { + try { + List list2 = new ArrayList<>(list.size()); + list2.addAll(list); + + int step = list2.size(); + boolean swapped; + do { + swapped = false; + if (step > 1) { + step = (int) (step / 1.3); + } + for (int i = 0; i < list2.size() - step; i++) { + if (list2.get(i).getOreName().substring(0, 3) + .compareTo((list2.get(i + step).getOreName().substring(0, 3))) > 0) { + Oremix tmp = list2.get(i); + list2.set(i, list2.get(i + step)); + list2.set(i + step, tmp); + swapped = true; + } + } + } while (swapped || step > 1); + return list2; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public void runSmallOres() { + try { + Iterator> it = GT5OreSmallHelper.mapOreSmallWrapper + .entrySet().iterator(); + List OreVeins = new ArrayList<>(); + while (it.hasNext()) { + Oremix oremix = new Oremix(); + + Map.Entry pair = it.next(); + String Dims = GT5OreSmallHelper.bufferedDims.get(pair.getValue()); + GT5OreSmallHelper.OreSmallWrapper oreLayer = pair.getValue(); + oremix.setOreName(oreLayer.oreGenName.split("\\.")[2]); + oremix.setHeight(oreLayer.worldGenHeightRange); + oremix.setDensity(oreLayer.amountPerChunk); + oremix.an = Dims.contains("An"); + oremix.as = Dims.contains("As"); + oremix.bc = Dims.contains("BC"); + oremix.be = Dims.contains("BE"); + oremix.bf = Dims.contains("BF"); + oremix.ca = Dims.contains("Ca"); + oremix.cb = Dims.contains("CA"); + oremix.ce = Dims.contains("Ce"); + oremix.dd = Dims.contains("DD"); + oremix.de = Dims.contains("De"); + oremix.ea = Dims.contains("EA"); + oremix.en = Dims.contains("En"); + oremix.eu = Dims.contains("Eu"); + oremix.ga = Dims.contains("Ga"); + oremix.ha = Dims.contains("Ha"); + oremix.ho = Dims.contains("Ho"); + oremix.io = Dims.contains("Io"); + oremix.kb = Dims.contains("KB"); + oremix.make = Dims.contains("MM"); + oremix.ma = Dims.contains("Ma"); + oremix.mb = Dims.contains("MB"); + oremix.me = Dims.contains("Me"); + oremix.mh = Dims.contains("Mh"); + oremix.mi = Dims.contains("Mi"); + oremix.mo = Dims.contains("Mo"); + oremix.np = Dims.contains("Np"); + oremix.ob = Dims.contains("Ob"); + oremix.ph = Dims.contains("Ph"); + oremix.pl = Dims.contains("Pl"); + oremix.pr = Dims.contains("Pr"); + oremix.se = Dims.contains("Se"); + oremix.tcetie = Dims.contains("TE"); + oremix.tf = Dims.contains("TF"); + oremix.ti = Dims.contains("Ti"); + oremix.tr = Dims.contains("Tr"); + oremix.vb = Dims.contains("VB"); + oremix.ve = Dims.contains("Ve"); + oremix.setOverworld(Dims.contains("Ow")); + oremix.setNether(Dims.contains("Ne")); + oremix.setEnd(Dims.contains("EN")); + OreVeins.add(oremix); + + System.out.println(pair.getKey() + " = " + pair.getValue()); + it.remove(); // avoids a ConcurrentModificationException + } + BufferedWriter one = Files.newBufferedWriter(Paths.get(GTNEIOrePlugin.CSVnameSmall)); + ColumnPositionMappingStrategy strat = new ColumnPositionMappingStrategy<>(); + strat.setType(Oremix.class); + String[] columns = "ORENAME,mix,DENSITY,overworld,nether,end,ea,tf,mo,ma,ph,de,as,ce,eu,ga,ca,io,ve,me,en,ti,mi,ob,pr,tr,pl,kb,ha,make,dd,cb,vb,bc,be,bf,tcetie,an,ho,np,mh,mb,se" + .split("\\,"); + strat.setColumnMapping(columns); + StatefulBeanToCsv beanToCsv = new StatefulBeanToCsvBuilder(one) + .withQuotechar(CSVWriter.NO_QUOTE_CHARACTER).withMappingStrategy(strat).build(); + List towrite = Combsort(OreVeins); + one.write( + "Ore Name,Primary,Secondary,Inbetween,Around,ID,Tier,Height,Density,Size,Weight,Overworld,Nether,End,End Asteroids,Twilight Forest,Moon,Mars,Phobos,Deimos,Asteroids,Ceres,Europa,Ganymede,Callisto,Io,Venus,Mercury,Enceladus,Titan,Miranda,Oberon,Proteus,Triton,Pluto,Kuiper Belt,Haumea,Makemake,Deep Dark,Centauri Bb,Vega B,Barnard C,Barnard E,Barnard F,T Ceti E,Anubis,Horus,Neper,Maahes,Mehen Belt,Seth"); + one.newLine(); + beanToCsv.write(towrite); + one.flush(); + one.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void run() { + runVeins(); + runSmallOres(); + } + + public void runVeins() { + try { + Iterator> it = GT5OreLayerHelper.mapOreLayerWrapper.entrySet() + .iterator(); + List OreVeins = new ArrayList<>(); + while (it.hasNext()) { + Oremix oremix = new Oremix(); + + Map.Entry pair = it.next(); + String Dims = GT5OreLayerHelper.bufferedDims.get(pair.getValue()); + OreLayerWrapper oreLayer = pair.getValue(); + oremix.setOreName(oreLayer.veinName.split("\\.")[2]); + oremix.setPrimary(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[0])); + oremix.setSecondary(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[1])); + oremix.setInbetween(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[2])); + oremix.setAround(PluginGT5VeinStat.getGTOreLocalizedName(oreLayer.Meta[3])); + oremix.setSize(oreLayer.size); + oremix.setHeight(oreLayer.worldGenHeightRange); + oremix.setDensity(oreLayer.density); + oremix.setWeight(oreLayer.randomWeight); + oremix.setMix( + Integer.toString(oreLayer.Meta[0]) + "|" + + Integer.toString(oreLayer.Meta[1]) + + "|" + + Integer.toString(oreLayer.Meta[2]) + + "|" + + Integer.toString(oreLayer.Meta[3])); + oremix.an = Dims.contains("An"); + oremix.as = Dims.contains("As"); + oremix.bc = Dims.contains("BC"); + oremix.be = Dims.contains("BE"); + oremix.bf = Dims.contains("BF"); + oremix.ca = Dims.contains("Ca"); + oremix.cb = Dims.contains("CA"); + oremix.ce = Dims.contains("Ce"); + oremix.dd = Dims.contains("DD"); + oremix.de = Dims.contains("De"); + oremix.ea = Dims.contains("EA"); + oremix.en = Dims.contains("En"); + oremix.eu = Dims.contains("Eu"); + oremix.ga = Dims.contains("Ga"); + oremix.ha = Dims.contains("Ha"); + oremix.ho = Dims.contains("Ho"); + oremix.io = Dims.contains("Io"); + oremix.kb = Dims.contains("KB"); + oremix.make = Dims.contains("MM"); + oremix.ma = Dims.contains("Ma"); + oremix.mb = Dims.contains("MB"); + oremix.me = Dims.contains("Me"); + oremix.mh = Dims.contains("Mh"); + oremix.mi = Dims.contains("Mi"); + oremix.mo = Dims.contains("Mo"); + oremix.np = Dims.contains("Np"); + oremix.ob = Dims.contains("Ob"); + oremix.ph = Dims.contains("Ph"); + oremix.pl = Dims.contains("Pl"); + oremix.pr = Dims.contains("Pr"); + oremix.se = Dims.contains("Se"); + oremix.tcetie = Dims.contains("TE"); + oremix.tf = Dims.contains("TF"); + oremix.ti = Dims.contains("Ti"); + oremix.tr = Dims.contains("Tr"); + oremix.vb = Dims.contains("VB"); + oremix.ve = Dims.contains("Ve"); + oremix.setOverworld(Dims.contains("Ow")); + oremix.setNether(Dims.contains("Ne")); + oremix.setEnd(Dims.contains("EN")); + OreVeins.add(oremix); + + System.out.println(pair.getKey() + " = " + pair.getValue()); + it.remove(); // avoids a ConcurrentModificationException + } + BufferedWriter one = Files.newBufferedWriter(Paths.get(GTNEIOrePlugin.CSVname)); + ColumnPositionMappingStrategy strat = new ColumnPositionMappingStrategy<>(); + strat.setType(Oremix.class); + String[] columns = "ORENAME,PRIMARY,SECONDARY,INBETWEEN,AROUND,mix,TIER,HEIGHT,DENSITY,SIZE,WEIGHT,overworld,nether,end,ea,tf,mo,ma,ph,de,as,ce,eu,ga,ca,io,ve,me,en,ti,mi,ob,pr,tr,pl,kb,ha,make,dd,cb,vb,bc,be,bf,tcetie,an,ho,np,mh,mb,se" + .split("\\,"); + strat.setColumnMapping(columns); + StatefulBeanToCsv beanToCsv = new StatefulBeanToCsvBuilder(one) + .withQuotechar(CSVWriter.NO_QUOTE_CHARACTER).withMappingStrategy(strat).build(); + List towrite = Combsort(OreVeins); + one.write( + "Ore Name,Primary,Secondary,Inbetween,Around,ID,Tier,Height,Density,Size,Weight,Overworld,Nether,End,End Asteroids,Twilight Forest,Moon,Mars,Phobos,Deimos,Asteroids,Ceres,Europa,Ganymede,Callisto,Io,Venus,Mercury,Enceladus,Titan,Miranda,Oberon,Proteus,Triton,Pluto,Kuiper Belt,Haumea,Makemake,Deep Dark,Centauri Bb,Vega B,Barnard C,Barnard E,Barnard F,T Ceti E,Anubis,Horus,Neper,Maahes,Mehen Belt,Seth"); + one.newLine(); + beanToCsv.write(towrite); + 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 new file mode 100644 index 0000000000..b82cb63f58 --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java @@ -0,0 +1,159 @@ +package pers.gwyog.gtneioreplugin.util; + +import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.maxTooltipLines; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import net.minecraft.util.StatCollector; + +public class DimensionHelper { + + public static final String[] DimName = { + // Non GC dimensions in progression order instead of alphabetical + "Overworld", "Nether", "Twilight", "TheEnd", "Vanilla_EndAsteroids", "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(