diff --git a/build.gradle b/build.gradle index b9fc153..3ccb50b 100644 --- a/build.gradle +++ b/build.gradle @@ -46,11 +46,11 @@ repositories { dependencies { compile files('libs/') - deobfCompile "mezz.jei:jei_1.12:4.7.1.69:api" - runtime "mezz.jei:jei_1.12:4.7.1.69" + deobfCompile "mezz.jei:jei_1.12:4.7.1.+:api" + runtime "mezz.jei:jei_1.12:4.7.1.+" deobfCompile "mcp.mobius.waila:Hwyla:1.8.19-B33_1.12:api" runtime "mcp.mobius.waila:Hwyla:1.8.19-B33_1.12" - compile "cofh:RedstoneFlux:1.12-2.0.0.+:deobf" + compile "cofh:RedstoneFlux:1.12-2.+:deobf" } processResources diff --git a/gradle.properties b/gradle.properties index acf226e..348798c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,6 +2,6 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx4G mc_version=1.12 -forge_version=14.21.1.2406 -mod_version=2.2 -mappings_version=snapshot_20170710 +forge_version=14.21.1.2428 +mod_version=2.3 +mappings_version=snapshot_20170731 diff --git a/src/main/java/me/jacky1356400/exchangers/Config.java b/src/main/java/me/jacky1356400/exchangers/Config.java index 717c6d8..c68c9f2 100644 --- a/src/main/java/me/jacky1356400/exchangers/Config.java +++ b/src/main/java/me/jacky1356400/exchangers/Config.java @@ -5,198 +5,198 @@ public class Config { - //Categories - private static final String CATEGORY_MODULES = "modules"; - private static final String CATEGORY_TWEAKS_VANILLA = "vanilla tweaks"; - private static final String CATEGORY_TWEAKS_EIO = "ender io tweaks"; - private static final String CATEGORY_TWEAKS_TE = "thermal expansion tweaks"; - private static final String CATEGORY_TWEAKS_MEKANISM = "mekanism tweaks"; - private static final String CATEGORY_RECIPES = "recipe tweaks"; - - //Modules - public static boolean vanillaModule; - public static boolean enderIOModule; - public static boolean thermalExpansionModule; - public static boolean mekanismModule; - public static boolean specialModule; - - //Recipes - public static boolean vanillaProgressiveRecipes; - public static boolean enderIOProgressiveRecipes; - public static boolean thermalExpansionProgressiveRecipes; - public static boolean mekanismProgressiveRecipes; - - //Vanilla - public static int woodMaxDmg; - public static int stoneMaxDmg; - public static int goldMaxDmg; - public static int ironMaxDmg; - public static int diaMaxDmg; - public static int emeMaxDmg; - public static int obsMaxDmg; - - //Ender IO - public static int conductiveMaxEnergy; - public static int conductivePerBlockUse; - public static int pulsatingMaxEnergy; - public static int pulsatingPerBlockUse; - public static int electricalSteelMaxEnergy; - public static int electricalSteelPerBlockUse; - public static int energeticMaxEnergy; - public static int energeticPerBlockUse; - public static int darkSteelMaxEnergy; - public static int darkSteelPerBlockUse; - public static int vibrantMaxEnergy; - public static int vibrantPerBlockUse; - - //Thermal Expansion - public static int leadstoneMaxEnergy; - public static int leadstonePerBlockUse; - public static int hardenedMaxEnergy; - public static int hardenedPerBlockUse; - public static int reinforcedMaxEnergy; - public static int reinforcedPerBlockUse; - public static int signalumMaxEnergy; - public static int signalumPerBlockUse; - public static int resonantMaxEnergy; - public static int resonantPerBlockUse; - - //Mekanism - public static int basicMaxEnergy; - public static int basicPerBlockUse; - public static int advancedMaxEnergy; - public static int advancedPerBlockUse; - public static int eliteMaxEnergy; - public static int elitePerBlockUse; - public static int ultimateMaxEnergy; - public static int ultimatePerBlockUse; - - public static void readConfig() { - Configuration cfg = CommonProxy.config; - try { - cfg.load(); - initConfig(cfg); - } catch (Exception e) { - Exchangers.logger.error("ERROR LOADING CONFIG", e); - } finally { - if (cfg.hasChanged()) { - cfg.save(); - } - } - } - - private static void initConfig(Configuration cfg) { - - //Modules - vanillaModule = cfg.getBoolean("Vanilla Module", CATEGORY_MODULES, true, - "If true, enables recipes for vanilla-based exchangers."); - enderIOModule = cfg.getBoolean("Ender IO Module", CATEGORY_MODULES, false, - "[Not implemented!] If true, enables recipes for Ender IO-based exchangers (Requires Ender IO to be installed)."); - thermalExpansionModule = cfg.getBoolean("Thermal Expansion Module", CATEGORY_MODULES, true, - "If true, enables recipes for Thermal Expansion-based exchangers (Requires Thermal Expansion to be installed)."); - mekanismModule = cfg.getBoolean("Mekanism Module", CATEGORY_MODULES, false, - "[Not implemented!] If true, enables recipes for Mekanism-based exchangers (Requires Mekanism to be installed)."); - specialModule = cfg.getBoolean("Special Module", CATEGORY_MODULES, true, - "If true, enables recipes for special exchangers (e.g. Tuberous Exchanger)."); - - //Recipes - cfg.addCustomCategoryComment(CATEGORY_RECIPES, - "Progressive recipes - requires the previous tier to craft the next tier exchanger, which means more expensive."); - vanillaProgressiveRecipes = cfg.getBoolean("Vanilla Progressive Recipes", CATEGORY_RECIPES, true, - "If true, enables progressive recipes for vanilla-based exchangers."); - enderIOProgressiveRecipes = cfg.getBoolean("Ender IO Progressive Recipes", CATEGORY_RECIPES, true, - "[Not implemented!] If true, enables progressive recipes for Ender IO-based exchangers."); - thermalExpansionProgressiveRecipes = cfg.getBoolean("Thermal Expansion Progressive Recipes", CATEGORY_RECIPES, - true, "If true, enables progressive recipes for Thermal Expansion-based exchangers."); - mekanismProgressiveRecipes = cfg.getBoolean("Mekanism Progressive Recipes", CATEGORY_RECIPES, true, - "[Not implemented!] If true, enables progressive recipes for Mekanism-based exchangers."); - - //Vanilla Tweaks - cfg.addCustomCategoryComment(CATEGORY_TWEAKS_VANILLA, "Vanilla Exchanger Tweaks"); - woodMaxDmg = cfg.getInt("Wooden Exchanger Max Durability", CATEGORY_TWEAKS_VANILLA, 256, 1, 2147483647, - "Set the durability for Wooden Exchanger"); - stoneMaxDmg = cfg.getInt("Stone Exchanger Max Durability", CATEGORY_TWEAKS_VANILLA, 384, 1, 2147483647, - "Set the durability for Stone Exchanger"); - goldMaxDmg = cfg.getInt("Golden Exchanger Max Durability", CATEGORY_TWEAKS_VANILLA, 512, 1, 2147483647, - "Set the durability for Golden Exchanger"); - ironMaxDmg = cfg.getInt("Iron Exchanger Max Durability", CATEGORY_TWEAKS_VANILLA, 1024, 1, 2147483647, - "Set the durability for Iron Exchanger"); - diaMaxDmg = cfg.getInt("Diamond Exchanger Max Durability", CATEGORY_TWEAKS_VANILLA, 4096, 1, 2147483647, - "Set the durability for Diamond Exchanger"); - emeMaxDmg = cfg.getInt("Emerald Exchanger Max Durability", CATEGORY_TWEAKS_VANILLA, 8192, 1, 2147483647, - "Set the durability for Emerald Exchanger"); - obsMaxDmg = cfg.getInt("Obsidian Exchanger Max Durability", CATEGORY_TWEAKS_VANILLA, 16384, 1, 2147483647, - "Set the durability for Obsidian Exchanger"); - - //Ender IO Tweaks - cfg.addCustomCategoryComment(CATEGORY_TWEAKS_EIO, "[Not implemented!] Ender IO Exchanger Tweaks"); - conductiveMaxEnergy = cfg.getInt("Conductive Iron Exchanger Capacity", CATEGORY_TWEAKS_EIO, 80000, - 1000, 100000000, "Set the RF capacity for Conductive Iron Exchanger"); - conductivePerBlockUse = cfg.getInt("Conductive Iron Exchanger Power Consumption", - CATEGORY_TWEAKS_EIO, 10, 1, 250, "Set the Rf consumption per block for Conductive Iron Exchanger"); - pulsatingMaxEnergy = cfg.getInt("Pulsating Iron Exchanger Capacity", CATEGORY_TWEAKS_EIO, 400000, 1000, - 100000000, "Set the RF capacity for Pulsating Iron Exchanger"); - pulsatingPerBlockUse = cfg.getInt("Pulsating Iron Exchanger Power Consumption", CATEGORY_TWEAKS_EIO, - 50, 1, 500, "Set the RF consumption per block for Pulsating Iron Exchanger"); - electricalSteelMaxEnergy = cfg.getInt("Electrical Steel Exchanger Capacity", CATEGORY_TWEAKS_EIO, 800000, - 1000, 100000000, "Set the RF capacity for Electrical Steel Exchanger"); - electricalSteelPerBlockUse = cfg.getInt("Electrical Steel Exchanger Power Consumption", - CATEGORY_TWEAKS_EIO, 100, 1, 1000, "Set the RF consumption per block for Electrical Steel Exchanger"); - energeticMaxEnergy = cfg.getInt("Energetic Exchanger Capacity", CATEGORY_TWEAKS_EIO, 5000000, 1000, - 100000000, "Set the RF capacity for Energetic Exchanger"); - energeticPerBlockUse = cfg.getInt("Energetic Exchanger Power Consumption", CATEGORY_TWEAKS_EIO, 250, 1, - 2500, "Set the RF consumption per block for Energetic Exchanger"); - darkSteelMaxEnergy = cfg.getInt("Dark Steel Exchanger Capacity", CATEGORY_TWEAKS_EIO, 10000000, 1000, - 100000000, "Set the RF capacity for Dark Steel Exchanger"); - darkSteelPerBlockUse = cfg.getInt("Dark Steel Exchanger Power Consumption", CATEGORY_TWEAKS_EIO, 500, 1, - 5000, "Set the RF consumption per block for Dark Steel Exchanger"); - vibrantMaxEnergy = cfg.getInt("Vibrant Exchanger Capacity", CATEGORY_TWEAKS_EIO, 20000000, 1000, 100000000, - "Set the RF capacity for Vibrant Exchanger"); - vibrantPerBlockUse = cfg.getInt("Vibrant Exchanger Power Consumption", CATEGORY_TWEAKS_EIO, 1000, 1, - 10000, "Set the RF consumption per block for Vibrant Exchanger"); - - //Thermal Expansion Tweaks - cfg.addCustomCategoryComment(CATEGORY_TWEAKS_TE, "Thermal Expansion Exchanger Tweaks"); - leadstoneMaxEnergy = cfg.getInt("Leadstone Exchanger Capacity", CATEGORY_TWEAKS_TE, 80000, 1000, 100000000, - "Set the RF capacity for Leadstone Exchanger"); - leadstonePerBlockUse = cfg.getInt("Leadstone Exchanger Power Consumption", CATEGORY_TWEAKS_TE, 10, 1, - 250, "Set the RF consumption per block for Leadstone Exchanger"); - hardenedMaxEnergy = cfg.getInt("Hardened Exchanger Capacity", CATEGORY_TWEAKS_TE, 500000, 1000, 100000000, - "Set the RF capacity for Hardened Exchanger"); - hardenedPerBlockUse = cfg.getInt("Hardened Exchanger Power Consumption", CATEGORY_TWEAKS_TE, 50, 1, 500, - "Set the RF consumption per block for Hardened Exchanger"); - reinforcedMaxEnergy = cfg.getInt("Reinforced Exchanger Capacity", CATEGORY_TWEAKS_TE, 1000000, 1000, - 100000000, "Set the RF capacity for Reinforced Exchanger"); - reinforcedPerBlockUse = cfg.getInt("Reinforced Exchanger Power Consumption", CATEGORY_TWEAKS_TE, 100, 1, - 1000, "Set the RF consumption per block for Reinforced Exchanger"); - signalumMaxEnergy = cfg.getInt("Signalum Exchanger Capacity", CATEGORY_TWEAKS_TE, 10000000, 1000, - 100000000, "Set the RF capacity for Signalum Exchanger"); - signalumPerBlockUse = cfg.getInt("Signalum Exchanger Power Consumption", CATEGORY_TWEAKS_TE, 500, 1, - 5000, "Set the RF consumption per block for Signalum Exchanger"); - resonantMaxEnergy = cfg.getInt("Resonant Exchanger Capacity", CATEGORY_TWEAKS_TE, 20000000, 1000, - 100000000, "Set the RF capacity for Resonant Exchanger"); - resonantPerBlockUse = cfg.getInt("Resonant Exchanger Power Consumption", CATEGORY_TWEAKS_TE, 1000, 1, - 10000, "Set the RF consumption per block for Resonant Exchanger"); - - //Mekanism Tweaks - cfg.addCustomCategoryComment(CATEGORY_TWEAKS_MEKANISM, "[Not implemented!] Mekanism Exchanger Tweaks"); - basicMaxEnergy = cfg.getInt("Basic Exchanger Capacity", CATEGORY_TWEAKS_MEKANISM, 100000, 1000, 100000000, - "Set the RF capacity for Basic Exchanger"); - basicPerBlockUse = cfg.getInt("Basic Exchanger Power Consumption", CATEGORY_TWEAKS_MEKANISM, 50, 1, 500, - "Set the RF consumption per block for Basic Exchanger"); - advancedMaxEnergy = cfg.getInt("Advanced Exchanger Capacity", CATEGORY_TWEAKS_MEKANISM, 800000, 1000, - 100000000, "Set the RF capacity for Advanced Exchanger"); - advancedPerBlockUse = cfg.getInt("Advanced Exchanger Power Consumption", CATEGORY_TWEAKS_MEKANISM, 100, - 1, 1000, "Set the RF consumption per block for Advanced Exchanger"); - eliteMaxEnergy = cfg.getInt("Elite Exchanger Capacity", CATEGORY_TWEAKS_MEKANISM, 5000000, 1000, 100000000, - "Set the RF capacity for Elite Exchanger"); - elitePerBlockUse = cfg.getInt("Elite Exchanger Power Consumption", CATEGORY_TWEAKS_MEKANISM, 250, 1, - 2500, "Set the RF consumption per block for Elite Exchanger"); - ultimateMaxEnergy = cfg.getInt("Ultimate Exchanger Capacity", CATEGORY_TWEAKS_MEKANISM, 10000000, 1000, - 100000000, "Set the RF capacity for Ultimate Exchanger"); - ultimatePerBlockUse = cfg.getInt("Ultimate Exchanger Power Consumption", CATEGORY_TWEAKS_MEKANISM, 500, - 1, 5000, "Set the RF consumption per block for Ultimate Exchanger"); - - } + //Categories + private static final String CATEGORY_MODULES = "modules"; + private static final String CATEGORY_TWEAKS_VANILLA = "vanilla tweaks"; + private static final String CATEGORY_TWEAKS_EIO = "ender io tweaks"; + private static final String CATEGORY_TWEAKS_TE = "thermal expansion tweaks"; + private static final String CATEGORY_TWEAKS_MEKANISM = "mekanism tweaks"; + private static final String CATEGORY_RECIPES = "recipe tweaks"; + + //Modules + public static boolean vanillaModule; + public static boolean enderIOModule; + public static boolean thermalExpansionModule; + public static boolean mekanismModule; + public static boolean specialModule; + + //Recipes + public static boolean vanillaProgressiveRecipes; + public static boolean enderIOProgressiveRecipes; + public static boolean thermalExpansionProgressiveRecipes; + public static boolean mekanismProgressiveRecipes; + + //Vanilla + public static int woodMaxDmg; + public static int stoneMaxDmg; + public static int goldMaxDmg; + public static int ironMaxDmg; + public static int diaMaxDmg; + public static int emeMaxDmg; + public static int obsMaxDmg; + + //Ender IO + public static int conductiveMaxEnergy; + public static int conductivePerBlockUse; + public static int pulsatingMaxEnergy; + public static int pulsatingPerBlockUse; + public static int electricalSteelMaxEnergy; + public static int electricalSteelPerBlockUse; + public static int energeticMaxEnergy; + public static int energeticPerBlockUse; + public static int darkSteelMaxEnergy; + public static int darkSteelPerBlockUse; + public static int vibrantMaxEnergy; + public static int vibrantPerBlockUse; + + //Thermal Expansion + public static int leadstoneMaxEnergy; + public static int leadstonePerBlockUse; + public static int hardenedMaxEnergy; + public static int hardenedPerBlockUse; + public static int reinforcedMaxEnergy; + public static int reinforcedPerBlockUse; + public static int signalumMaxEnergy; + public static int signalumPerBlockUse; + public static int resonantMaxEnergy; + public static int resonantPerBlockUse; + + //Mekanism + public static int basicMaxEnergy; + public static int basicPerBlockUse; + public static int advancedMaxEnergy; + public static int advancedPerBlockUse; + public static int eliteMaxEnergy; + public static int elitePerBlockUse; + public static int ultimateMaxEnergy; + public static int ultimatePerBlockUse; + + public static void readConfig() { + Configuration cfg = CommonProxy.config; + try { + cfg.load(); + initConfig(cfg); + } catch (Exception e) { + Exchangers.logger.error("ERROR LOADING CONFIG", e); + } finally { + if (cfg.hasChanged()) { + cfg.save(); + } + } + } + + private static void initConfig(Configuration cfg) { + + //Modules + vanillaModule = cfg.getBoolean("Vanilla Module", CATEGORY_MODULES, true, + "If true, enables recipes for vanilla-based exchangers."); + enderIOModule = cfg.getBoolean("Ender IO Module", CATEGORY_MODULES, false, + "If true, enables recipes for Ender IO-based exchangers (Requires Ender IO to be installed)."); + thermalExpansionModule = cfg.getBoolean("Thermal Expansion Module", CATEGORY_MODULES, true, + "If true, enables recipes for Thermal Expansion-based exchangers (Requires Thermal Expansion to be installed)."); + mekanismModule = cfg.getBoolean("Mekanism Module", CATEGORY_MODULES, true, + "If true, enables recipes for Mekanism-based exchangers (Requires Mekanism to be installed)."); + specialModule = cfg.getBoolean("Special Module", CATEGORY_MODULES, true, + "If true, enables recipes for special exchangers (e.g. Tuberous Exchanger)."); + + //Recipes + cfg.addCustomCategoryComment(CATEGORY_RECIPES, + "Progressive recipes - requires the previous tier to craft the next tier exchanger, which means more expensive."); + vanillaProgressiveRecipes = cfg.getBoolean("Vanilla Progressive Recipes", CATEGORY_RECIPES, true, + "If true, enables progressive recipes for vanilla-based exchangers."); + enderIOProgressiveRecipes = cfg.getBoolean("Ender IO Progressive Recipes", CATEGORY_RECIPES, true, + "If true, enables progressive recipes for Ender IO-based exchangers."); + thermalExpansionProgressiveRecipes = cfg.getBoolean("Thermal Expansion Progressive Recipes", CATEGORY_RECIPES, + true, "If true, enables progressive recipes for Thermal Expansion-based exchangers."); + mekanismProgressiveRecipes = cfg.getBoolean("Mekanism Progressive Recipes", CATEGORY_RECIPES, true, + "If true, enables progressive recipes for Mekanism-based exchangers."); + + //Vanilla Tweaks + cfg.addCustomCategoryComment(CATEGORY_TWEAKS_VANILLA, "Vanilla Exchanger Tweaks"); + woodMaxDmg = cfg.getInt("Wooden Exchanger Max Durability", CATEGORY_TWEAKS_VANILLA, 256, 1, 2147483647, + "Set the durability for Wooden Exchanger"); + stoneMaxDmg = cfg.getInt("Stone Exchanger Max Durability", CATEGORY_TWEAKS_VANILLA, 384, 1, 2147483647, + "Set the durability for Stone Exchanger"); + goldMaxDmg = cfg.getInt("Golden Exchanger Max Durability", CATEGORY_TWEAKS_VANILLA, 512, 1, 2147483647, + "Set the durability for Golden Exchanger"); + ironMaxDmg = cfg.getInt("Iron Exchanger Max Durability", CATEGORY_TWEAKS_VANILLA, 1024, 1, 2147483647, + "Set the durability for Iron Exchanger"); + diaMaxDmg = cfg.getInt("Diamond Exchanger Max Durability", CATEGORY_TWEAKS_VANILLA, 4096, 1, 2147483647, + "Set the durability for Diamond Exchanger"); + emeMaxDmg = cfg.getInt("Emerald Exchanger Max Durability", CATEGORY_TWEAKS_VANILLA, 8192, 1, 2147483647, + "Set the durability for Emerald Exchanger"); + obsMaxDmg = cfg.getInt("Obsidian Exchanger Max Durability", CATEGORY_TWEAKS_VANILLA, 16384, 1, 2147483647, + "Set the durability for Obsidian Exchanger"); + + //Ender IO Tweaks + cfg.addCustomCategoryComment(CATEGORY_TWEAKS_EIO, "[Not implemented!] Ender IO Exchanger Tweaks"); + conductiveMaxEnergy = cfg.getInt("Conductive Iron Exchanger Capacity", CATEGORY_TWEAKS_EIO, 80000, + 1000, 100000000, "Set the RF capacity for Conductive Iron Exchanger"); + conductivePerBlockUse = cfg.getInt("Conductive Iron Exchanger Power Consumption", + CATEGORY_TWEAKS_EIO, 10, 1, 250, "Set the Rf consumption per block for Conductive Iron Exchanger"); + pulsatingMaxEnergy = cfg.getInt("Pulsating Iron Exchanger Capacity", CATEGORY_TWEAKS_EIO, 400000, 1000, + 100000000, "Set the RF capacity for Pulsating Iron Exchanger"); + pulsatingPerBlockUse = cfg.getInt("Pulsating Iron Exchanger Power Consumption", CATEGORY_TWEAKS_EIO, + 50, 1, 500, "Set the RF consumption per block for Pulsating Iron Exchanger"); + electricalSteelMaxEnergy = cfg.getInt("Electrical Steel Exchanger Capacity", CATEGORY_TWEAKS_EIO, 800000, + 1000, 100000000, "Set the RF capacity for Electrical Steel Exchanger"); + electricalSteelPerBlockUse = cfg.getInt("Electrical Steel Exchanger Power Consumption", + CATEGORY_TWEAKS_EIO, 100, 1, 1000, "Set the RF consumption per block for Electrical Steel Exchanger"); + energeticMaxEnergy = cfg.getInt("Energetic Exchanger Capacity", CATEGORY_TWEAKS_EIO, 5000000, 1000, + 100000000, "Set the RF capacity for Energetic Exchanger"); + energeticPerBlockUse = cfg.getInt("Energetic Exchanger Power Consumption", CATEGORY_TWEAKS_EIO, 250, 1, + 2500, "Set the RF consumption per block for Energetic Exchanger"); + darkSteelMaxEnergy = cfg.getInt("Dark Steel Exchanger Capacity", CATEGORY_TWEAKS_EIO, 10000000, 1000, + 100000000, "Set the RF capacity for Dark Steel Exchanger"); + darkSteelPerBlockUse = cfg.getInt("Dark Steel Exchanger Power Consumption", CATEGORY_TWEAKS_EIO, 500, 1, + 5000, "Set the RF consumption per block for Dark Steel Exchanger"); + vibrantMaxEnergy = cfg.getInt("Vibrant Exchanger Capacity", CATEGORY_TWEAKS_EIO, 20000000, 1000, 100000000, + "Set the RF capacity for Vibrant Exchanger"); + vibrantPerBlockUse = cfg.getInt("Vibrant Exchanger Power Consumption", CATEGORY_TWEAKS_EIO, 1000, 1, + 10000, "Set the RF consumption per block for Vibrant Exchanger"); + + //Thermal Expansion Tweaks + cfg.addCustomCategoryComment(CATEGORY_TWEAKS_TE, "Thermal Expansion Exchanger Tweaks"); + leadstoneMaxEnergy = cfg.getInt("Leadstone Exchanger Capacity", CATEGORY_TWEAKS_TE, 80000, 1000, 100000000, + "Set the RF capacity for Leadstone Exchanger"); + leadstonePerBlockUse = cfg.getInt("Leadstone Exchanger Power Consumption", CATEGORY_TWEAKS_TE, 10, 1, + 250, "Set the RF consumption per block for Leadstone Exchanger"); + hardenedMaxEnergy = cfg.getInt("Hardened Exchanger Capacity", CATEGORY_TWEAKS_TE, 500000, 1000, 100000000, + "Set the RF capacity for Hardened Exchanger"); + hardenedPerBlockUse = cfg.getInt("Hardened Exchanger Power Consumption", CATEGORY_TWEAKS_TE, 50, 1, 500, + "Set the RF consumption per block for Hardened Exchanger"); + reinforcedMaxEnergy = cfg.getInt("Reinforced Exchanger Capacity", CATEGORY_TWEAKS_TE, 1000000, 1000, + 100000000, "Set the RF capacity for Reinforced Exchanger"); + reinforcedPerBlockUse = cfg.getInt("Reinforced Exchanger Power Consumption", CATEGORY_TWEAKS_TE, 100, 1, + 1000, "Set the RF consumption per block for Reinforced Exchanger"); + signalumMaxEnergy = cfg.getInt("Signalum Exchanger Capacity", CATEGORY_TWEAKS_TE, 10000000, 1000, + 100000000, "Set the RF capacity for Signalum Exchanger"); + signalumPerBlockUse = cfg.getInt("Signalum Exchanger Power Consumption", CATEGORY_TWEAKS_TE, 500, 1, + 5000, "Set the RF consumption per block for Signalum Exchanger"); + resonantMaxEnergy = cfg.getInt("Resonant Exchanger Capacity", CATEGORY_TWEAKS_TE, 20000000, 1000, + 100000000, "Set the RF capacity for Resonant Exchanger"); + resonantPerBlockUse = cfg.getInt("Resonant Exchanger Power Consumption", CATEGORY_TWEAKS_TE, 1000, 1, + 10000, "Set the RF consumption per block for Resonant Exchanger"); + + //Mekanism Tweaks + cfg.addCustomCategoryComment(CATEGORY_TWEAKS_MEKANISM, "[Not implemented!] Mekanism Exchanger Tweaks"); + basicMaxEnergy = cfg.getInt("Basic Exchanger Capacity", CATEGORY_TWEAKS_MEKANISM, 100000, 1000, 100000000, + "Set the RF capacity for Basic Exchanger"); + basicPerBlockUse = cfg.getInt("Basic Exchanger Power Consumption", CATEGORY_TWEAKS_MEKANISM, 50, 1, 500, + "Set the RF consumption per block for Basic Exchanger"); + advancedMaxEnergy = cfg.getInt("Advanced Exchanger Capacity", CATEGORY_TWEAKS_MEKANISM, 800000, 1000, + 100000000, "Set the RF capacity for Advanced Exchanger"); + advancedPerBlockUse = cfg.getInt("Advanced Exchanger Power Consumption", CATEGORY_TWEAKS_MEKANISM, 100, + 1, 1000, "Set the RF consumption per block for Advanced Exchanger"); + eliteMaxEnergy = cfg.getInt("Elite Exchanger Capacity", CATEGORY_TWEAKS_MEKANISM, 5000000, 1000, 100000000, + "Set the RF capacity for Elite Exchanger"); + elitePerBlockUse = cfg.getInt("Elite Exchanger Power Consumption", CATEGORY_TWEAKS_MEKANISM, 250, 1, + 2500, "Set the RF consumption per block for Elite Exchanger"); + ultimateMaxEnergy = cfg.getInt("Ultimate Exchanger Capacity", CATEGORY_TWEAKS_MEKANISM, 10000000, 1000, + 100000000, "Set the RF capacity for Ultimate Exchanger"); + ultimatePerBlockUse = cfg.getInt("Ultimate Exchanger Power Consumption", CATEGORY_TWEAKS_MEKANISM, 500, + 1, 5000, "Set the RF consumption per block for Ultimate Exchanger"); + + } } diff --git a/src/main/java/me/jacky1356400/exchangers/Exchangers.java b/src/main/java/me/jacky1356400/exchangers/Exchangers.java index 9ec6075..e552089 100644 --- a/src/main/java/me/jacky1356400/exchangers/Exchangers.java +++ b/src/main/java/me/jacky1356400/exchangers/Exchangers.java @@ -13,26 +13,26 @@ @Mod(modid = Data.MODID, version = Data.VERSION, name = Data.MODNAME, dependencies = Exchangers.DEPENDS, useMetadata = true) public class Exchangers { - public static final String DEPENDS = "required-after:redstoneflux;after:enderio;after:thermalfoundation;after:thermalexpansion;after:mekanism;"; + public static final String DEPENDS = "required-after:redstoneflux;after:enderio;after:thermalfoundation;after:thermalexpansion;after:mekanism;"; - public static Logger logger = LogManager.getLogger("Exchangers"); + public static Logger logger = LogManager.getLogger("Exchangers"); - @SidedProxy(serverSide = "me.jacky1356400.exchangers.proxy.CommonProxy", clientSide = "me.jacky1356400.exchangers.proxy.ClientProxy") - public static CommonProxy proxy; + @SidedProxy(serverSide = "me.jacky1356400.exchangers.proxy.CommonProxy", clientSide = "me.jacky1356400.exchangers.proxy.ClientProxy") + public static CommonProxy proxy; - @Mod.EventHandler - public void preInit(FMLPreInitializationEvent e) { - proxy.preInit(e); - } + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent e) { + proxy.preInit(e); + } - @Mod.EventHandler - public void init(FMLInitializationEvent e) { - proxy.init(e); - } + @Mod.EventHandler + public void init(FMLInitializationEvent e) { + proxy.init(e); + } - @Mod.EventHandler - public void postInit(FMLPostInitializationEvent e) { - proxy.postInit(e); - } + @Mod.EventHandler + public void postInit(FMLPostInitializationEvent e) { + proxy.postInit(e); + } } diff --git a/src/main/java/me/jacky1356400/exchangers/client/Keys.java b/src/main/java/me/jacky1356400/exchangers/client/Keys.java index 75bdfd4..d21d9df 100644 --- a/src/main/java/me/jacky1356400/exchangers/client/Keys.java +++ b/src/main/java/me/jacky1356400/exchangers/client/Keys.java @@ -9,11 +9,11 @@ @SideOnly(Side.CLIENT) public class Keys { - public static KeyBinding modeKey; + public static KeyBinding modeKey; - public static void init() { - modeKey = new KeyBinding("key.exchangermode", Keyboard.KEY_COMMA, "key.categories.exchangers"); - ClientRegistry.registerKeyBinding(modeKey); - } + public static void init() { + modeKey = new KeyBinding("key.exchangermode", Keyboard.KEY_COMMA, "key.categories.exchangers"); + ClientRegistry.registerKeyBinding(modeKey); + } } diff --git a/src/main/java/me/jacky1356400/exchangers/handler/ExchangerHandler.java b/src/main/java/me/jacky1356400/exchangers/handler/ExchangerHandler.java index b9ec8fd..42e2e60 100644 --- a/src/main/java/me/jacky1356400/exchangers/handler/ExchangerHandler.java +++ b/src/main/java/me/jacky1356400/exchangers/handler/ExchangerHandler.java @@ -1,380 +1,359 @@ package me.jacky1356400.exchangers.handler; import me.jacky1356400.exchangers.client.Keys; -import me.jacky1356400.exchangers.helper.DirectionHelper; import me.jacky1356400.exchangers.helper.StringHelper; import me.jacky1356400.exchangers.item.ItemExchanger; import me.jacky1356400.exchangers.item.ItemPoweredExchanger; -import me.jacky1356400.exchangers.util.Data; -import me.jacky1356400.exchangers.util.Tier; -import net.minecraft.block.*; +import me.jacky1356400.exchangers.util.StackUtil; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; +import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.*; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; -import net.minecraftforge.common.IPlantable; -import net.minecraftforge.fluids.BlockFluidBase; - -import java.util.*; - -import static me.jacky1356400.exchangers.handler.WorldEventHandler.queueExchanges; - -public abstract class ExchangerHandler extends Item { - - public static final int MODE_1X1 = 0; - public static final int MODE_3X3 = 1; - public static final int MODE_5X5 = 2; - public static final int MODE_7X7 = 3; - public static final int MODE_9X9 = 4; - public static final int MODE_11X11 = 5; - public static final int MODE_13X13 = 6; - public static final int MODE_15X15 = 7; - public static final int MODE_17X17 = 8; - public static final int MODE_19X19 = 9; - public static final int MODE_21X21 = 10; - public static final int MODE_23X23 = 11; - public static final int MODE_25X25 = 12; - - public static final String[] modeSwitchList = new String[] { "1x1", "3x3", "5x5", "7x7", "9x9", "11x11", "13x13", - "15x15", "17x17", "19x19", "21x21", "23x23", "25x25" }; - - public static void setDefaultTagCompound(ItemStack stack) { - stack.setTagCompound(new NBTTagCompound()); - stack.getTagCompound().setInteger("state", 0); - stack.getTagCompound().setInteger("ExchangeMode", 0); - } - - public static boolean stackTagCompoundNull(ItemStack stack) { - return stack.getTagCompound() == null; - } - - @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag bool) { - if (StringHelper.displayShiftForDetail && !StringHelper.isShiftKeyDown()) { - tooltip.add(StringHelper.getShiftText()); - } - if (!StringHelper.isShiftKeyDown()) { - return; - } - - if (stackTagCompoundNull(stack)) - setDefaultTagCompound(stack); - NBTTagCompound compound = stack.getTagCompound(); - - if (compound == null || compound.getInteger("state") == 0) { - tooltip.add(StringHelper.localize("tooltip.noselectedblock")); - } else { - - int stateID = compound.getInteger("state"); - - tooltip.add(StringHelper.localize("tooltip.selectedblock") + " " - + new ItemStack(Block.getStateById(stateID).getBlock(), 1, stateID >> 12 & 15).getDisplayName()); - tooltip.add(StringHelper.localize("tooltip.selectedmode") + " " - + modeSwitchList[compound.getInteger("ExchangeMode")]); - } - if (StringHelper.isShiftKeyDown()) { - tooltip.remove(StringHelper.getShiftText()); - tooltip.add(StringHelper.localize("tooltip.shift1")); - tooltip.add(StringHelper.localize("tooltip.shift2")); - tooltip.add(StringHelper.localize("tooltip.shift3") + " " + "(" + Keys.modeKey.getDisplayName() + ")"); - } - } - - public void switchMode(EntityPlayer player, ItemStack stack) { - if (stackTagCompoundNull(stack)) - setDefaultTagCompound(stack); - - int modeSwitch = stack.getTagCompound().getInteger("ExchangeMode"); - modeSwitch++; - - ItemStack heldItem = player.getHeldItemMainhand(); - - if (!heldItem.isEmpty() && stack.getItem() instanceof ItemExchanger) { - ItemExchanger k = (ItemExchanger) stack.getItem(); - if (modeSwitch > k.getTier().getMaxSize()) - modeSwitch = MODE_1X1; - } - - stack.getTagCompound().setInteger("ExchangeMode", modeSwitch); - } - - @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, - float hitX, float hitY, float hitZ) { - if (world.isRemote) - return EnumActionResult.SUCCESS; - ItemStack stack = player.getHeldItem(hand); - - IBlockState state = world.getBlockState(pos); - Block block = state.getBlock(); - - if (player.isSneaking()) { - - if (blockSuitableForSelection(player, world, pos)) { - setSelectedBlock(stack, block, state); - return EnumActionResult.SUCCESS; - } else { - player.sendMessage(new TextComponentTranslation(Data.MODID + ".error.invalidblock")); - return EnumActionResult.FAIL; - } - } else { - if (blockSuitableForExchange(stack, player, world, pos) - && exchangeBlocks(stack, player, world, pos, facing)) - return EnumActionResult.SUCCESS; - return EnumActionResult.FAIL; - } - } - - public static List getBlocksToExchange(ItemStack stack, BlockPos pos, World world, EnumFacing side) { - - int modeSwitch = stack.getTagCompound().getInteger("ExchangeMode"); - int range = modeSwitch; - IBlockState state = world.getBlockState(pos); - - List exchangeList = new ArrayList(); - List checkedList = new ArrayList(); - - exchangeList.add(pos); - checkedList.add(pos); - - buildExchangeList(world, pos, pos, state, side, range, exchangeList, checkedList); - - if (!exchangeList.isEmpty()) { - world.playSound(null, (double) ((float) pos.getX() + 0.5F), (double) ((float) pos.getY() + 0.5F), - (double) ((float) pos.getZ() + 0.5F), - SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.endermen.teleport")), - SoundCategory.BLOCKS, 1F, 1F); - - Collections.sort(exchangeList, new Comparator() { - @Override - public int compare(BlockPos o1, BlockPos o2) { - return o1.compareTo(o2); - } - }); - } - - return exchangeList; - } - - private static final Set softBlocks = new HashSet(); - private static final Set specialBlocks = new HashSet(); - private static final Set blacklistedBlocks = new HashSet(); - private static final Set creativeBlocks = new HashSet(); - - public static void initSpecialBlockLists() { - for (Object o : Block.REGISTRY) { - Block block = (Block) o; - if (block instanceof BlockFence || block instanceof BlockFenceGate || block instanceof BlockTrapDoor - || block instanceof BlockDoor || block instanceof BlockPistonBase || block instanceof BlockLadder) { - specialBlocks.add(block); - } - } - - for (Object o : Block.REGISTRY) { - Block block = (Block) o; - if (block instanceof BlockRedstoneLight || block instanceof BlockWorkbench) { - blacklistedBlocks.add(block); - } - } - - for (Object o : Block.REGISTRY) { - Block block = (Block) o; - if (block == Blocks.BEDROCK || block == Blocks.END_PORTAL_FRAME) { - creativeBlocks.add(block); - } - } - - for (Object o : Block.REGISTRY) { - Block block = (Block) o; - if (block instanceof BlockFluidBase || block instanceof BlockLiquid || block instanceof IPlantable - || block instanceof BlockTorch || block instanceof BlockLeaves - || block instanceof BlockHugeMushroom) { - softBlocks.add(block); - } - } - - softBlocks.add(Blocks.SNOW_LAYER); - softBlocks.add(Blocks.REDSTONE_WIRE); - softBlocks.add(Blocks.TRIPWIRE); - softBlocks.add(Blocks.VINE); - softBlocks.add(Blocks.FIRE); - softBlocks.add(Blocks.AIR); - - } - - public static boolean blockSuitableForSelection(EntityPlayer player, World world, BlockPos pos) { - Block block = world.getBlockState(pos).getBlock(); - - return (world.getTileEntity(pos) == null && !world.isAirBlock(pos) && !blacklistedBlocks.contains(block) - && !softBlocks.contains(block) && !specialBlocks.contains(block) - && !(creativeBlocks.contains(block) && !player.capabilities.isCreativeMode)); - } - - public static void setSelectedBlock(ItemStack stack, Block block, IBlockState state) { - if (stackTagCompoundNull(stack)) - setDefaultTagCompound(stack); - stack.getTagCompound().setInteger("state", Block.getStateId(state)); - } - - public static boolean blockSuitableForExchange(ItemStack stack, EntityPlayer player, World world, BlockPos pos) { - int newMeta = stack.getTagCompound().getInteger("state"); - - int worldMeta = Block.getStateId(world.getBlockState(pos)); - - if (!blockSuitableForSelection(player, world, pos)) { - player.sendMessage(new TextComponentTranslation(Data.MODID + ".error.invalidblock")); - return false; - } - - return newMeta != worldMeta; - } - - public static void buildExchangeList(World world, BlockPos pos, BlockPos origin, IBlockState origState, - EnumFacing side, int range, List exchangeList, List checkedList) { - - EnumFacing[] facesAround = DirectionHelper.getFacings(side); - - for (EnumFacing dir : facesAround) { - BlockPos newPos = pos.offset(dir); - - if (checkedList.contains(newPos) || !blockInRange(origin, newPos, range)) { - continue; - } - - checkedList.add(newPos); - IBlockState state = world.getBlockState(newPos); - - // TODO: This is just gross - boolean validExchange = !world.isAirBlock(newPos) - && (world.isAirBlock(newPos.offset(side)) - || (world.getBlockState(newPos.offset(side)) == Blocks.WATER)) - && state == origState && state.getBlock().isReplaceable(world, newPos.offset(side)); - - if (validExchange) { - exchangeList.add(newPos); - buildExchangeList(world, newPos, origin, origState, side, range, exchangeList, checkedList); - } - } - - } - - public static boolean blockInRange(BlockPos origin, BlockPos pos, int range) { - BlockPos diff = pos.subtract(origin); - return Math.abs(diff.getX()) <= range && Math.abs(diff.getY()) <= range && Math.abs(diff.getZ()) <= range; - } - - public static boolean placeBlockInInventory(EntityPlayer player, Block block, int meta) { - ItemStack oldStack = new ItemStack(block, 1, meta); - boolean successPlaceInInventory = player.inventory.addItemStackToInventory(oldStack); - if (!successPlaceInInventory) { - return false; - } - return true; - } - - public static boolean consumeBlockInInventory(EntityPlayer player, Block block, IBlockState state) { - ItemStack heldItem = player.getHeldItemMainhand(); - if (!(heldItem.getItem() instanceof ItemExchanger)) - return false; - ItemExchanger exchanger = (ItemExchanger) heldItem.getItem(); - if (!player.capabilities.isCreativeMode || exchanger.getTier() != Tier.CREATIVE) { - InventoryPlayer inv = player.inventory; - Item item = Item.getItemFromBlock(block); - int meta = block.getMetaFromState(state); - - ItemStack stack = findItemInInventory(inv, item, meta); - - if (stack.isEmpty()) - return false; - else - stack.shrink(1); - } - - return true; - } - - public static ItemStack findItemInInventory(InventoryPlayer inv, Item item, int meta) { - for (int i = 0; i < inv.mainInventory.size(); i++) { - ItemStack stack = inv.mainInventory.get(i); - if (!stack.isEmpty() && stack.getItem() == item && stack.getItemDamage() == meta) { - return stack; - } - } - return ItemStack.EMPTY; - } - - public static boolean placeBlockInWorld(World world, BlockPos exchangePos, IBlockState state) { - - queueExchanges(exchangePos, state, world); - - return true; - } - - public static String getBlockName(Block block, int meta) { - ItemStack s = new ItemStack(block, 1, meta); - return s.getDisplayName(); - } - - public static boolean exchangeBlocks(ItemStack stack, EntityPlayer player, World world, BlockPos pos, - EnumFacing facing) { - int stateID = stack.getTagCompound().getInteger("state"); - - if (stateID == 0) - return false; - world.profiler.startSection("Exchangers-Building/Queueing"); - - IBlockState newState = Block.getStateById(stateID); - List toExchange = getBlocksToExchange(stack, pos, world, facing); - - for (BlockPos exchangePos : toExchange) { - ItemStack slot = ItemStack.EMPTY; - ItemStack heldItem = player.getHeldItemMainhand(); - if (!(heldItem.getItem() instanceof ItemExchanger)) - return false; - ItemExchanger exchanger = (ItemExchanger) heldItem.getItem(); - if (player.capabilities.isCreativeMode || exchanger.getTier() == Tier.CREATIVE) { - placeBlockInWorld(world, exchangePos, newState); - } else { - try { - slot = findItemInInventory(player.inventory, Item.getItemFromBlock(newState.getBlock()), - stateID >> 12 & 15); - } catch (ArrayIndexOutOfBoundsException e) { - return false; - } - if (!slot.isEmpty()) { - Block oldBlock = world.getBlockState(exchangePos).getBlock(); - int oldMeta = oldBlock.getMetaFromState(world.getBlockState(exchangePos)); - int energy = stack.getTagCompound().getInteger("Energy"); - if (exchanger.isPowered() && energy < ((ItemPoweredExchanger) exchanger).getPerBlockCost()) { - player.sendMessage(new TextComponentTranslation(Data.MODID + ".error.nopower")); - return false; - } - if (placeBlockInInventory(player, oldBlock, oldMeta) - && placeBlockInWorld(world, exchangePos, newState) - && consumeBlockInInventory(player, newState.getBlock(), newState)) { - if (!exchanger.isPowered() && exchanger.getTier() != Tier.CREATIVE) - stack.damageItem(1, player); - else if (exchanger.isPowered()) { - ItemPoweredExchanger powered = (ItemPoweredExchanger) exchanger; - if (energy >= powered.getPerBlockCost()) - stack.getTagCompound().setInteger("Energy", energy - powered.getPerBlockCost()); - } - } else - return false; - } - } - } - world.profiler.endSection(); - - return true; - } - -} + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static me.jacky1356400.exchangers.helper.ChatHelper.msgPlayer; + +public class ExchangerHandler extends Item { + + public static final int MODE_1X1 = 0; + public static final int MODE_3X3 = 1; + public static final int MODE_5X5 = 2; + public static final int MODE_7X7 = 3; + public static final int MODE_9X9 = 4; + public static final int MODE_11X11 = 5; + public static final int MODE_13X13 = 6; + public static final int MODE_15X15 = 7; + public static final int MODE_17X17 = 8; + public static final int MODE_19X19 = 9; + public static final int MODE_21X21 = 10; + public static final int MODE_23X23 = 11; + public static final int MODE_25X25 = 12; + + public static final String[] modeSwitchList = new String[]{ + "1x1", "3x3", "5x5", "7x7", "9x9", + "11x11", "13x13", "15x15", "17x17", + "19x19", "21x21", "23x23", "25x25"}; + + public static void setDefaultTagCompound(ItemStack stack) { + stack.setTagCompound(new NBTTagCompound()); + stack.getTagCompound().setInteger("block", 0); + stack.getTagCompound().setInteger("meta", 0); + stack.getTagCompound().setInteger("mode", 0); + } + + public static boolean stackTagCompoundNull(ItemStack stack) { + return stack.getTagCompound() == null; + } + + protected static Set findSuitableBlocks(ItemStack stack, World world, EnumFacing sideHit, BlockPos pos, Block centerBlock, int centerMeta) { + Set coordinates = new HashSet(); + int mode = stack.getTagCompound().getInteger("mode"); + int dim = 0; + switch (mode) { + case 0: + dim = 0; + break; + case 1: + dim = 1; + break; + case 2: + dim = 2; + break; + case 3: + dim = 3; + break; + case 4: + dim = 4; + break; + case 5: + dim = 5; + break; + case 6: + dim = 6; + break; + case 7: + dim = 7; + break; + case 8: + dim = 8; + break; + case 9: + dim = 9; + break; + case 10: + dim = 10; + break; + case 11: + dim = 11; + break; + case 12: + dim = 12; + } + int x = pos.getX(); + int y = pos.getY(); + int z = pos.getZ(); + switch (sideHit) { + case UP: + case DOWN: + for (int dx = x - dim; dx <= x + dim; dx++) { + for (int dz = z - dim; dz <= z + dim; dz++) { + checkAndAddBlock(world, dx, y, dz, centerBlock, centerMeta, coordinates); + } + } + break; + case SOUTH: + case NORTH: + for (int dx = x - dim; dx <= x + dim; dx++) { + for (int dy = y - dim; dy <= y + dim; dy++) { + checkAndAddBlock(world, dx, dy, z, centerBlock, centerMeta, coordinates); + } + } + break; + case EAST: + case WEST: + for (int dy = y - dim; dy <= y + dim; dy++) { + for (int dz = z - dim; dz <= z + dim; dz++) { + checkAndAddBlock(world, x, dy, dz, centerBlock, centerMeta, coordinates); + } + } + } + return coordinates; + } + + private static void checkAndAddBlock(World world, int x, int y, int z, Block centerBlock, int centerMeta, Set coordinates) { + BlockPos pos = new BlockPos(x, y, z); + IBlockState state = world.getBlockState(pos); + if ((state.getBlock() == centerBlock) && (state.getBlock().getMetaFromState(state) == centerMeta)) { + coordinates.add(pos); + } + } + + private static int findItem(Item item, int meta, InventoryPlayer inv) { + for (int i = 0; i < 36; i++) { + ItemStack stack = inv.getStackInSlot(i); + if ((StackUtil.isValid(stack)) && (stack.getItem() == item) && (meta == stack.getItemDamage())) { + return i; + } + } + return -1; + } + + private static void giveItem(World world, EntityPlayer player, BlockPos pos, ItemStack oldStack) { + if (!player.inventory.addItemStackToInventory(oldStack)) { + EntityItem entityItem = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), oldStack); + world.spawnEntity(entityItem); + } + } + + protected static NBTTagCompound getTagCompound(ItemStack stack) { + NBTTagCompound tagCompound = stack.getTagCompound(); + if (tagCompound == null) { + tagCompound = new NBTTagCompound(); + stack.setTagCompound(tagCompound); + } + return tagCompound; + } + + private static String getBlockName(Block block, int meta) { + ItemStack stack = new ItemStack(block, 1, meta); + if (stack == ItemStack.EMPTY) { + return null; + } + return stack.getDisplayName(); + } + + @Override + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag advanced) { + super.addInformation(stack, world, tooltip, advanced); + if (StringHelper.displayShiftForDetail && !StringHelper.isShiftKeyDown()) { + tooltip.add(StringHelper.getShiftText()); + } + if (!StringHelper.isShiftKeyDown()) { + return; + } + + if (stackTagCompoundNull(stack)) + setDefaultTagCompound(stack); + + NBTTagCompound compound = stack.getTagCompound(); + ItemExchanger exchanger = (ItemExchanger) stack.getItem(); + + if (compound == null || compound.getInteger("block") == 0) { + tooltip.add(StringHelper.localize("tooltip.noselectedblock")); + } else { + int id = compound.getInteger("block"); + Block block = Block.getBlockById(id); + int meta = compound.getInteger("meta"); + + tooltip.add(StringHelper.localize("tooltip.selectedblock") + " " + getBlockName(block, meta)); + tooltip.add(StringHelper.localize("tooltip.currentrange") + " " + modeSwitchList[compound.getInteger("mode")]); + tooltip.add(StringHelper.localize("tooltip.maxrange") + " " + modeSwitchList[exchanger.getTier().getMaxSize()]); + } + if (StringHelper.isShiftKeyDown()) { + tooltip.remove(StringHelper.getShiftText()); + tooltip.add(StringHelper.localize("tooltip.shift1")); + tooltip.add(StringHelper.localize("tooltip.shift2")); + tooltip.add(StringHelper.localize("tooltip.shift3") + " " + "(" + Keys.modeKey.getDisplayName() + ")"); + } + } + + public boolean isCreative() { + return false; + } + + public boolean isPowered() { + return false; + } + + public void switchMode(EntityPlayer player, ItemStack stack) { + if (stackTagCompoundNull(stack)) + setDefaultTagCompound(stack); + + int modeSwitch = stack.getTagCompound().getInteger("mode"); + modeSwitch++; + + ItemStack heldItem = player.getHeldItemMainhand(); + ItemExchanger exchanger = (ItemExchanger) stack.getItem(); + + if (heldItem != null) { + if (modeSwitch > exchanger.getTier().getMaxSize()) + modeSwitch = MODE_1X1; + } + + stack.getTagCompound().setInteger("mode", modeSwitch); + } + + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + if (!world.isRemote) { + if (player.isSneaking()) { + selectBlock(player.getHeldItem(hand), player, world, pos); + } else { + placeBlock(player.getHeldItem(hand), player, world, pos, side); + } + } + return EnumActionResult.SUCCESS; + } + + @SuppressWarnings("deprecation") + private void placeBlock(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side) { + NBTTagCompound tagCompound = stack.getTagCompound(); + Block block; + int meta; + int id = tagCompound.getInteger("block"); + block = Block.REGISTRY.getObjectById(id); + meta = tagCompound.getInteger("meta"); + + IBlockState oldState = world.getBlockState(pos); + Block oldblock = oldState.getBlock(); + + int oldmeta = oldblock.getMetaFromState(oldState); + float blockHardness = oldblock.getBlockHardness(oldState, world, pos); + if ((block == oldblock) && (meta == oldmeta)) { + return; + } + if (world.getTileEntity(pos) != null) { + msgPlayer(player, StringHelper.localize("error.invalidblock")); + return; + } + if (blockHardness < -0.1F) { + if (!isCreative()) { + msgPlayer(player, StringHelper.localize("error.invalidblock")); + return; + } + } + if (stack.getItem() instanceof ItemPoweredExchanger) { + ItemPoweredExchanger powered = (ItemPoweredExchanger) stack.getItem(); + if (isPowered() && stack.getTagCompound().getInteger("Energy") < powered.getPerBlockCost()) { + if (!isCreative()) { + msgPlayer(player, StringHelper.localize("error.nopower")); + return; + } + } + } + Set coordinates = findSuitableBlocks(stack, world, side, pos, oldblock, oldmeta); + boolean notEnough = false; + for (BlockPos coordinate : coordinates) { + if (consumeItemInInventory(Item.getItemFromBlock(block), meta, player.inventory, player)) { + if (!player.capabilities.isCreativeMode && !isCreative()) { + ItemStack oldblockItem = oldblock.getItem(world, pos, oldState); + giveItem(world, player, pos, oldblockItem); + if (!isPowered() && !isCreative()) { + stack.damageItem(1, player); + } + if (stack.getItem() instanceof ItemPoweredExchanger) { + ItemPoweredExchanger powered = (ItemPoweredExchanger) stack.getItem(); + if (stack.getTagCompound().getInteger("Energy") >= powered.getPerBlockCost()) { + stack.getTagCompound().setInteger("Energy", stack.getTagCompound().getInteger("Energy") - powered.getPerBlockCost()); + } + } + } + world.playSound(null, coordinate.getX(), coordinate.getY(), coordinate.getZ(), SoundEvents.ENTITY_ENDERMEN_TELEPORT, + SoundCategory.BLOCKS, 0.1F, 1F); + world.setBlockState(coordinate, block.getStateFromMeta(meta), 3); + player.openContainer.detectAndSendChanges(); + } else { + notEnough = true; + } + } + if (notEnough) { + msgPlayer(player, StringHelper.localize("error.outofblock")); + } + } + + @SuppressWarnings("deprecation") + private void selectBlock(ItemStack stack, EntityPlayer player, World world, BlockPos pos) { + if (stackTagCompoundNull(stack)) + setDefaultTagCompound(stack); + IBlockState state = world.getBlockState(pos); + Block block = state.getBlock(); + int meta = block.getMetaFromState(state); + NBTTagCompound tagCompound = getTagCompound(stack); + String name = getBlockName(block, meta); + float blockHardness = block.getBlockHardness(state, world, pos); + if (name == null) { + msgPlayer(player, StringHelper.localize("error.invalidblock")); + } else if (world.getTileEntity(pos) != null) { + msgPlayer(player, StringHelper.localize("error.invalidblock")); + } else if (blockHardness < -0.1F) { + if (!isCreative()) { + msgPlayer(player, StringHelper.localize("error.invalidblock")); + } + } else { + int id = Block.REGISTRY.getIDForObject(block); + tagCompound.setInteger("block", id); + tagCompound.setInteger("meta", meta); + } + } + + private boolean consumeItemInInventory(Item item, int meta, InventoryPlayer inv, EntityPlayer player) { + if (player.capabilities.isCreativeMode || isCreative()) { + return true; + } + int i = findItem(item, meta, inv); + if (i < 0) { + return false; + } + ItemStack stackInSlot = inv.getStackInSlot(i); + stackInSlot = StackUtil.incStackSize(stackInSlot, -1); + if (StackUtil.getStackSize(stackInSlot) == 0) { + inv.setInventorySlotContents(i, StackUtil.getEmptyStack(new ItemStack(item))); + } + return true; + } + +} \ No newline at end of file diff --git a/src/main/java/me/jacky1356400/exchangers/handler/GUIHandler.java b/src/main/java/me/jacky1356400/exchangers/handler/GUIHandler.java index 694894c..76a5e59 100644 --- a/src/main/java/me/jacky1356400/exchangers/handler/GUIHandler.java +++ b/src/main/java/me/jacky1356400/exchangers/handler/GUIHandler.java @@ -1,12 +1,11 @@ package me.jacky1356400.exchangers.handler; -import net.minecraft.block.Block; +import me.jacky1356400.exchangers.item.ItemExchanger; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -16,110 +15,60 @@ public class GUIHandler extends Gui { - private Minecraft mc; - private ItemStack lastExchangeSource = ItemStack.EMPTY; - private int lastExchangeSourceCount = 0; - private static int timesChanged = 0; - - public GUIHandler(Minecraft mc) - { - super(); - this.mc = mc; - } - - @SubscribeEvent - public void onGameOverlayRender(RenderGameOverlayEvent event) { - if (event.isCancelable() || event.getType() != RenderGameOverlayEvent.ElementType.EXPERIENCE) return; - if (!(mc.getRenderViewEntity() instanceof EntityPlayer)) return; - - EntityPlayer player = (EntityPlayer) mc.getRenderViewEntity(); - - if (player == null || !mc.inGameHasFocus || !Minecraft.isGuiEnabled()) return; - if (player.getHeldItemMainhand() == null || !(player.getHeldItemMainhand().getItem() instanceof ExchangerHandler)) return; - - ItemStack exchangerStack = player.getHeldItemMainhand(); - ItemStack source = ItemStack.EMPTY; - - if (exchangerStack.hasTagCompound()){ - int stateID = exchangerStack.getTagCompound().getInteger("state"); - source = new ItemStack(Block.getStateById(stateID).getBlock(), 1, stateID >> 12 & 15); - } - - if (source.isEmpty()) - return; - - if (player.inventory.getTimesChanged() > timesChanged || this.lastExchangeSource.isEmpty() - || !source.isItemEqual(this.lastExchangeSource)) { - int quantity = 0; - - InventoryPlayer inv = player.inventory; - - for (int slot = 0; slot < inv.mainInventory.size(); slot++) { - ItemStack is = inv.getStackInSlot(slot); - if (is != null && is.isItemEqual(source)) - quantity += is.getCount(); - } - - this.lastExchangeSourceCount = quantity; - this.lastExchangeSource = source; - timesChanged = player.inventory.getTimesChanged(); - } - - ScaledResolution scaledresolution = new ScaledResolution(this.mc); - int i = scaledresolution.getScaledWidth(); - int j = scaledresolution.getScaledHeight(); - int xOffset = i/2; - int yOffset = j/2; - - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - - GL11.glEnable(32826 /* GL_RESCALE_NORMAL_EXT */); - GL11.glEnable(GL11.GL_COLOR_MATERIAL); - GL11.glEnable(GL11.GL_LIGHTING); - - mc.getRenderItem().renderItemAndEffectIntoGUI(this.lastExchangeSource, xOffset+2, yOffset+2); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - - GL11.glDisable(32826); - GL11.glDisable(GL11.GL_COLOR_MATERIAL); - GL11.glDisable(GL11.GL_LIGHTING); - - String am = Integer.toString(this.lastExchangeSourceCount); - if (!player.capabilities.isCreativeMode) drawItemQuantity(mc.fontRenderer, xOffset+4, yOffset+2 , am); - else drawItemQuantity(mc.fontRenderer, xOffset+2, yOffset+1 , "Inf"); - String exchangeMode; - exchangeMode = new String(modeSwitchList[exchangerStack.getTagCompound().getInteger("ExchangeMode")]); - drawExchangeMode(mc.fontRenderer, xOffset+1, yOffset+2 , exchangeMode); - - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - } - - public static void drawItemQuantity(FontRenderer fontRenderer, int x, int y, String quantity) - { - double scale = quantity.length() > 2 ? 0.5 : 1; - double sheight = 8 * scale; - double swidth = fontRenderer.getStringWidth(quantity) * scale; - - renderText(fontRenderer, (int) (x + 16 - swidth), (int) (y + 16 - sheight), scale, quantity); - } - - public static void drawExchangeMode(FontRenderer fontRenderer, int x, int y, String exchangeMode) - { - double scale = exchangeMode.length() > 2 ? 1 : 1; - double sheight = 8 * scale; - double swidth = fontRenderer.getStringWidth(exchangeMode) * scale; - - renderText(fontRenderer, (int) (x - 2 - swidth), (int) (y + 16 - sheight), scale, exchangeMode); - } - - public static void renderText(FontRenderer fontRenderer, int x, int y, double scale, String text) - { - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glPushMatrix(); - GL11.glTranslated(x, y, 0); - GL11.glScaled(scale, scale, 1); - fontRenderer.drawStringWithShadow(text, 0, 0, 0xFFFFFF); - GL11.glPopMatrix(); - GL11.glEnable(GL11.GL_DEPTH_TEST); - } + private Minecraft mc; + + public GUIHandler(Minecraft mc) { + super(); + this.mc = mc; + } + + public static void drawExchangeMode(FontRenderer fontRenderer, int x, int y, String exchangeMode) { + double scale = exchangeMode.length() > 2 ? 1 : 1; + double swidth = fontRenderer.getStringWidth(exchangeMode) * scale; + + renderText(fontRenderer, (int) (x - 2 - swidth), y, scale, exchangeMode); + } + + public static void renderText(FontRenderer fontRenderer, int x, int y, double scale, String text) { + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glPushMatrix(); + GL11.glTranslated(x, y, 0); + GL11.glScaled(scale, scale, 1); + fontRenderer.drawStringWithShadow(text, 0, 0, 0xFFFFFF); + GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + @SubscribeEvent + public void onGameOverlayRender(RenderGameOverlayEvent event) { + if (event.isCancelable() || event.getType() != RenderGameOverlayEvent.ElementType.EXPERIENCE) return; + if (!(mc.getRenderViewEntity() instanceof EntityPlayer)) return; + + EntityPlayer player = (EntityPlayer) mc.getRenderViewEntity(); + + if (player == null || !mc.inGameHasFocus || !Minecraft.isGuiEnabled()) return; + if (player.getHeldItemMainhand() == null || !(player.getHeldItemMainhand().getItem() instanceof ItemExchanger)) + return; + + ItemStack stack = player.getHeldItemMainhand(); + + ScaledResolution scaledresolution = new ScaledResolution(this.mc); + int i = scaledresolution.getScaledWidth(); + int j = scaledresolution.getScaledHeight(); + int xOffset = i / 2; + int yOffset = j / 2; + + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + + GL11.glDisable(32826); + GL11.glDisable(GL11.GL_COLOR_MATERIAL); + GL11.glDisable(GL11.GL_LIGHTING); + + if (stack.hasTagCompound()) { + String exchangeMode = modeSwitchList[stack.getTagCompound().getInteger("mode")]; + drawExchangeMode(mc.fontRenderer, xOffset, yOffset - 4, exchangeMode); + } + + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + } } \ No newline at end of file diff --git a/src/main/java/me/jacky1356400/exchangers/handler/KeyBindingsHandler.java b/src/main/java/me/jacky1356400/exchangers/handler/KeyBindingsHandler.java index 2f05ea4..5d7f1bf 100644 --- a/src/main/java/me/jacky1356400/exchangers/handler/KeyBindingsHandler.java +++ b/src/main/java/me/jacky1356400/exchangers/handler/KeyBindingsHandler.java @@ -7,10 +7,10 @@ import net.minecraftforge.fml.common.gameevent.InputEvent; public class KeyBindingsHandler { - @SubscribeEvent - public void onKeyInput(InputEvent.KeyInputEvent event) { - if (Keys.modeKey.isPressed()) { - PacketHandler.INSTANCE.sendToServer(new PacketToggleMode()); - } - } + @SubscribeEvent + public void onKeyInput(InputEvent.KeyInputEvent event) { + if (Keys.modeKey.isPressed()) { + PacketHandler.INSTANCE.sendToServer(new PacketToggleMode()); + } + } } diff --git a/src/main/java/me/jacky1356400/exchangers/handler/RenderOverlayHandler.java b/src/main/java/me/jacky1356400/exchangers/handler/RenderOverlayHandler.java index a359124..dbb27f1 100644 --- a/src/main/java/me/jacky1356400/exchangers/handler/RenderOverlayHandler.java +++ b/src/main/java/me/jacky1356400/exchangers/handler/RenderOverlayHandler.java @@ -1,130 +1,135 @@ package me.jacky1356400.exchangers.handler; +import me.jacky1356400.exchangers.item.ItemExchanger; +import me.jacky1356400.exchangers.util.StackUtil; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.item.ItemStack; -import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import org.lwjgl.opengl.GL11; -import java.util.List; +import java.util.Set; public class RenderOverlayHandler { - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void RenderWorldLastEvent(RenderWorldLastEvent event) { - - EntityPlayerSP player = Minecraft.getMinecraft().player; - World world = player.getEntityWorld(); - ItemStack stack = player.getHeldItemMainhand(); - Minecraft mc = Minecraft.getMinecraft(); - float partialTicks = event.getPartialTicks(); - - RayTraceResult mouseOver = mc.objectMouseOver; - - if (stack != null && stack.getItem() instanceof ExchangerHandler && stack.getTagCompound() != null && mouseOver != null && mouseOver.getBlockPos() != null && mouseOver.sideHit != null) { - List blocks = ExchangerHandler.getBlocksToExchange(stack, mouseOver.getBlockPos(), world, mc.objectMouseOver.sideHit); - - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder buffer = tessellator.getBuffer(); - - double offsetX = player.prevPosX + (player.posX - player.prevPosX) * (double) partialTicks; - double offsetY = player.prevPosY + (player.posY - player.prevPosY) * (double) partialTicks; - double offsetZ = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) partialTicks; - - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); - GlStateManager.color(1F, 1F, 1F, 1F); - GlStateManager.glLineWidth(3.0F); - GlStateManager.disableTexture2D(); - - for (BlockPos block : blocks) { - if (world.isAirBlock(block)) { - continue; - } - - double renderX = block.getX() - offsetX; - double renderY = block.getY() - offsetY; - double renderZ = block.getZ() - offsetZ; - - AxisAlignedBB boundingBox = new AxisAlignedBB(renderX, renderY, renderZ, renderX + 1, renderY + 1, renderZ + 1).expand(0.001, 0.001, 0.001); - - float colourR = 1F; - float colourG = 1F; - float colourB = 1F; - float colourA = 1F; - - ItemStack exchangerStack = player.getHeldItemMainhand(); - - if (exchangerStack.hasTagCompound()){ - int stateID = exchangerStack.getTagCompound().getInteger("state"); - if (stateID == 0) { - colourR = 1F; - colourG = 0.1F; - colourB = 0.1F; - colourA = 1F; - } - } - - if (player.isSneaking()) { - colourR = 0.1F; - colourG = 1F; - colourB = 0.1F; - colourA = 1F; - } - - if (!world.getBlockState(block.offset(mc.objectMouseOver.sideHit)).getBlock().isReplaceable(world, block.offset(mc.objectMouseOver.sideHit))) { - GlStateManager.disableDepth(); - colourR = 0.2F; - colourG = 0.2F; - colourB = 0.2F; - colourA = 0.2F; - } - - buffer.begin(3, DefaultVertexFormats.POSITION_COLOR); - buffer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).color(colourR, colourG, colourB, colourA).endVertex(); - buffer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).color(colourR, colourG, colourB, colourA).endVertex(); - buffer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).color(colourR, colourG, colourB, colourA).endVertex(); - buffer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).color(colourR, colourG, colourB, colourA).endVertex(); - buffer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).color(colourR, colourG, colourB, colourA).endVertex(); - tessellator.draw(); - buffer.begin(3, DefaultVertexFormats.POSITION_COLOR); - buffer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).color(colourR, colourG, colourB, colourA).endVertex(); - buffer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).color(colourR, colourG, colourB, colourA).endVertex(); - buffer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).color(colourR, colourG, colourB, colourA).endVertex(); - buffer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).color(colourR, colourG, colourB, colourA).endVertex(); - buffer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).color(colourR, colourG, colourB, colourA).endVertex(); - tessellator.draw(); - buffer.begin(1, DefaultVertexFormats.POSITION_COLOR); - buffer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).color(colourR, colourG, colourB, colourA).endVertex(); - buffer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).color(colourR, colourG, colourB, colourA).endVertex(); - buffer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).color(colourR, colourG, colourB, colourA).endVertex(); - buffer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).color(colourR, colourG, colourB, colourA).endVertex(); - buffer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).color(colourR, colourG, colourB, colourA).endVertex(); - buffer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).color(colourR, colourG, colourB, colourA).endVertex(); - buffer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).color(colourR, colourG, colourB, colourA).endVertex(); - buffer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).color(colourR, colourG, colourB, colourA).endVertex(); - tessellator.draw(); - - if (!world.getBlockState(block.offset(mc.objectMouseOver.sideHit)).getBlock().isReplaceable(world, block.offset(mc.objectMouseOver.sideHit))) { - GlStateManager.enableDepth(); - } - } - - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - } - - } + private static void renderOutlines(RenderWorldLastEvent evt, EntityPlayerSP p, Set coordinates, int r, int g, int b) { + double doubleX = p.lastTickPosX + (p.posX - p.lastTickPosX) * evt.getPartialTicks(); + double doubleY = p.lastTickPosY + (p.posY - p.lastTickPosY) * evt.getPartialTicks(); + double doubleZ = p.lastTickPosZ + (p.posZ - p.lastTickPosZ) * evt.getPartialTicks(); + + RenderHelper.disableStandardItemLighting(); + Minecraft.getMinecraft().entityRenderer.disableLightmap(); + GlStateManager.disableDepth(); + GlStateManager.disableTexture2D(); + GlStateManager.disableLighting(); + GlStateManager.disableAlpha(); + GlStateManager.depthMask(false); + + GlStateManager.pushMatrix(); + GlStateManager.translate(-doubleX, -doubleY, -doubleZ); + + renderOutlines(coordinates, r, g, b, 4); + + GlStateManager.popMatrix(); + + Minecraft.getMinecraft().entityRenderer.enableLightmap(); + GlStateManager.enableTexture2D(); + } + + private static void renderOutlines(Set coordinates, int r, int g, int b, int thickness) { + Tessellator tessellator = Tessellator.getInstance(); + + BufferBuilder buffer = tessellator.getBuffer(); + buffer.begin(1, DefaultVertexFormats.POSITION_COLOR); + + GL11.glLineWidth(thickness); + for (BlockPos coordinate : coordinates) { + float x = coordinate.getX(); + float y = coordinate.getY(); + float z = coordinate.getZ(); + + renderHighLightedBlocksOutline(buffer, x, y, z, r / 255.0F, g / 255.0F, b / 255.0F, 1.0F); + } + tessellator.draw(); + } + + private static void renderHighLightedBlocksOutline(BufferBuilder buffer, float mx, float my, float mz, float r, float g, float b, float a) { + buffer.pos(mx, my, mz).color(r, g, b, a).endVertex(); + buffer.pos(mx + 1.0F, my, mz).color(r, g, b, a).endVertex(); + buffer.pos(mx, my, mz).color(r, g, b, a).endVertex(); + buffer.pos(mx, my + 1.0F, mz).color(r, g, b, a).endVertex(); + buffer.pos(mx, my, mz).color(r, g, b, a).endVertex(); + buffer.pos(mx, my, mz + 1.0F).color(r, g, b, a).endVertex(); + buffer.pos(mx + 1.0F, my + 1.0F, mz + 1.0F).color(r, g, b, a).endVertex(); + buffer.pos(mx, my + 1.0F, mz + 1.0F).color(r, g, b, a).endVertex(); + buffer.pos(mx + 1.0F, my + 1.0F, mz + 1.0F).color(r, g, b, a).endVertex(); + buffer.pos(mx + 1.0F, my, mz + 1.0F).color(r, g, b, a).endVertex(); + buffer.pos(mx + 1.0F, my + 1.0F, mz + 1.0F).color(r, g, b, a).endVertex(); + buffer.pos(mx + 1.0F, my + 1.0F, mz).color(r, g, b, a).endVertex(); + + buffer.pos(mx, my + 1.0F, mz).color(r, g, b, a).endVertex(); + buffer.pos(mx, my + 1.0F, mz + 1.0F).color(r, g, b, a).endVertex(); + buffer.pos(mx, my + 1.0F, mz).color(r, g, b, a).endVertex(); + buffer.pos(mx + 1.0F, my + 1.0F, mz).color(r, g, b, a).endVertex(); + + buffer.pos(mx + 1.0F, my, mz).color(r, g, b, a).endVertex(); + buffer.pos(mx + 1.0F, my, mz + 1.0F).color(r, g, b, a).endVertex(); + buffer.pos(mx + 1.0F, my, mz).color(r, g, b, a).endVertex(); + buffer.pos(mx + 1.0F, my + 1.0F, mz).color(r, g, b, a).endVertex(); + + buffer.pos(mx, my, mz + 1.0F).color(r, g, b, a).endVertex(); + buffer.pos(mx + 1.0F, my, mz + 1.0F).color(r, g, b, a).endVertex(); + buffer.pos(mx, my, mz + 1.0F).color(r, g, b, a).endVertex(); + buffer.pos(mx, my + 1.0F, mz + 1.0F).color(r, g, b, a).endVertex(); + } + + @SubscribeEvent + public void renderWorldLastEvent(RenderWorldLastEvent event) { + Minecraft mc = Minecraft.getMinecraft(); + EntityPlayerSP player = mc.player; + ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND); + if (StackUtil.isEmpty(stack)) { + return; + } + if ((stack.getItem() instanceof ItemExchanger)) { + renderOverlay(event, player, stack); + } + } + + @SideOnly(Side.CLIENT) + @SuppressWarnings("deprecation") + public void renderOverlay(RenderWorldLastEvent evt, EntityPlayerSP player, ItemStack stack) { + RayTraceResult mouseOver = Minecraft.getMinecraft().objectMouseOver; + if ((mouseOver != null) && (mouseOver.getBlockPos() != null) && (mouseOver.sideHit != null)) { + IBlockState state = player.getEntityWorld().getBlockState(mouseOver.getBlockPos()); + Block block = state.getBlock(); + if ((block != null) && (block.getMaterial(state) != Material.AIR)) { + int meta = block.getMetaFromState(state); + + int exId = ExchangerHandler.getTagCompound(stack).getInteger("block"); + Block exblock = Block.REGISTRY.getObjectById(exId); + int wandMeta = ExchangerHandler.getTagCompound(stack).getInteger("meta"); + if ((exblock == block) && (wandMeta == meta)) { + return; + } + Set coordinates = ExchangerHandler.findSuitableBlocks(stack, player.getEntityWorld(), mouseOver.sideHit, mouseOver.getBlockPos(), block, meta); + renderOutlines(evt, player, coordinates, 200, 230, 180); + } + } + } } \ No newline at end of file diff --git a/src/main/java/me/jacky1356400/exchangers/handler/WorldEventHandler.java b/src/main/java/me/jacky1356400/exchangers/handler/WorldEventHandler.java deleted file mode 100644 index a0899b6..0000000 --- a/src/main/java/me/jacky1356400/exchangers/handler/WorldEventHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -package me.jacky1356400.exchangers.handler; - -import me.jacky1356400.exchangers.util.Exchange; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - -import java.util.*; - -public class WorldEventHandler { - - public static Map> exchanges = new HashMap<>(); - - @SubscribeEvent - public void onWorldTick(TickEvent.WorldTickEvent event) { - exchangeTick(event.world); - } - - public static void queueExchanges(BlockPos pos, IBlockState state, World world) { - int dimId = world.provider.getDimension(); - Set queue = (LinkedHashSet) exchanges.get(dimId); - - if (queue == null) { - exchanges.put(dimId, new LinkedHashSet()); - queue = exchanges.get(dimId); - } - - queue.add(new Exchange(pos, state)); - exchanges.put(dimId, queue); - } - - private void exchangeTick(World world) { - int dimId = world.provider.getDimension(); - Set queue = exchanges.get(dimId); - - if (queue == null || queue.size() == 0) - return; - - world.profiler.startSection("Exchangers-Exchanging"); - List queueList = new ArrayList(queue); - Exchange exchange = queueList.get(0); - - world.destroyBlock(exchange.pos, false); - world.setBlockState(exchange.pos, exchange.state, 3); - - queue.remove(exchange); - world.profiler.endSection(); - } - -} \ No newline at end of file diff --git a/src/main/java/me/jacky1356400/exchangers/handler/network/PacketHandler.java b/src/main/java/me/jacky1356400/exchangers/handler/network/PacketHandler.java index d84ea74..0a8be00 100644 --- a/src/main/java/me/jacky1356400/exchangers/handler/network/PacketHandler.java +++ b/src/main/java/me/jacky1356400/exchangers/handler/network/PacketHandler.java @@ -5,19 +5,19 @@ import net.minecraftforge.fml.relauncher.Side; public class PacketHandler { - public static SimpleNetworkWrapper INSTANCE; - private static int packetId = 0; + public static SimpleNetworkWrapper INSTANCE; + private static int packetId = 0; - public static int nextID() { - return packetId++; - } + public static int nextID() { + return packetId++; + } - public static void registerMessages(String channelName) { - INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(channelName); + public static void registerMessages(String channelName) { + INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(channelName); - // Server side - INSTANCE.registerMessage(PacketToggleMode.class, PacketToggleMode.class, nextID(), Side.SERVER); + // Server side + INSTANCE.registerMessage(PacketToggleMode.class, PacketToggleMode.class, nextID(), Side.SERVER); - // Client side - } + // Client side + } } \ No newline at end of file diff --git a/src/main/java/me/jacky1356400/exchangers/handler/network/PacketToggleMode.java b/src/main/java/me/jacky1356400/exchangers/handler/network/PacketToggleMode.java index 6d11cce..e8f15ad 100644 --- a/src/main/java/me/jacky1356400/exchangers/handler/network/PacketToggleMode.java +++ b/src/main/java/me/jacky1356400/exchangers/handler/network/PacketToggleMode.java @@ -10,25 +10,25 @@ public class PacketToggleMode implements IMessage, IMessageHandler { - @Override - public void fromBytes(ByteBuf buf) { - } + public PacketToggleMode() { + } - @Override - public void toBytes(ByteBuf buf) { - } + @Override + public void fromBytes(ByteBuf buf) { + } - public PacketToggleMode() { - } + @Override + public void toBytes(ByteBuf buf) { + } - @Override - public IMessage onMessage(PacketToggleMode message, MessageContext context) { - EntityPlayerMP playerMP = context.getServerHandler().player; - ItemStack heldItem = playerMP.getHeldItemMainhand(); - if (heldItem != null && heldItem.getItem() instanceof ExchangerHandler) { - ExchangerHandler exchanger = (ExchangerHandler) (heldItem.getItem()); - exchanger.switchMode(playerMP, heldItem); - } - return null; - } + @Override + public IMessage onMessage(PacketToggleMode message, MessageContext context) { + EntityPlayerMP playerMP = context.getServerHandler().player; + ItemStack heldItem = playerMP.getHeldItemMainhand(); + if (heldItem != null && heldItem.getItem() instanceof ExchangerHandler) { + ExchangerHandler exchanger = (ExchangerHandler) (heldItem.getItem()); + exchanger.switchMode(playerMP, heldItem); + } + return null; + } } \ No newline at end of file diff --git a/src/main/java/me/jacky1356400/exchangers/helper/ChatHelper.java b/src/main/java/me/jacky1356400/exchangers/helper/ChatHelper.java new file mode 100644 index 0000000..18ab702 --- /dev/null +++ b/src/main/java/me/jacky1356400/exchangers/helper/ChatHelper.java @@ -0,0 +1,12 @@ +package me.jacky1356400.exchangers.helper; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.text.TextComponentString; + +public class ChatHelper { + + public static void msgPlayer(EntityPlayer player, String msg) { + player.sendMessage(new TextComponentString(msg)); + } + +} diff --git a/src/main/java/me/jacky1356400/exchangers/helper/DirectionHelper.java b/src/main/java/me/jacky1356400/exchangers/helper/DirectionHelper.java deleted file mode 100644 index 203d216..0000000 --- a/src/main/java/me/jacky1356400/exchangers/helper/DirectionHelper.java +++ /dev/null @@ -1,53 +0,0 @@ -package me.jacky1356400.exchangers.helper; - -import net.minecraft.util.EnumFacing; - -import java.util.ArrayList; -import java.util.List; - -public class DirectionHelper { - - /*** Facings for the 4 faces around X Axis */ - private static EnumFacing[] FACES_AROUND_X = new EnumFacing[1]; - /*** Facings for the 4 faces around Y Axis */ - private static EnumFacing[] FACES_AROUND_Y = new EnumFacing[1]; - /*** Facings for the 4 faces around Z Axis */ - private static EnumFacing[] FACES_AROUND_Z = new EnumFacing[1]; - - public static void initFacings() { - List x = new ArrayList(); - List y = new ArrayList(); - List z = new ArrayList(); - - for (EnumFacing facing : EnumFacing.VALUES) { - if (facing.getAxis() != EnumFacing.Axis.X) { - x.add(facing); - } - if (facing.getAxis() != EnumFacing.Axis.Y) { - y.add(facing); - } - if (facing.getAxis() != EnumFacing.Axis.Z) { - z.add(facing); - } - } - - FACES_AROUND_X = x.toArray(new EnumFacing[1]); - FACES_AROUND_Y = y.toArray(new EnumFacing[1]); - FACES_AROUND_Z = z.toArray(new EnumFacing[1]); - } - - public static EnumFacing[] getFacings(EnumFacing side) { - EnumFacing[] facesAround = new EnumFacing[1]; - - if (side.getAxis() == EnumFacing.Axis.X) { - facesAround = FACES_AROUND_X; - } else if (side.getAxis() == EnumFacing.Axis.Y) { - facesAround = FACES_AROUND_Y; - } else { - facesAround = FACES_AROUND_Z; - } - - return facesAround; - } - -} diff --git a/src/main/java/me/jacky1356400/exchangers/helper/NBTHelper.java b/src/main/java/me/jacky1356400/exchangers/helper/NBTHelper.java index 6ecf931..185be6b 100644 --- a/src/main/java/me/jacky1356400/exchangers/helper/NBTHelper.java +++ b/src/main/java/me/jacky1356400/exchangers/helper/NBTHelper.java @@ -5,45 +5,45 @@ public class NBTHelper { - public static NBTTagCompound getTag(ItemStack stack) { - if (!stack.hasTagCompound()) - stack.setTagCompound(new NBTTagCompound()); - return stack.getTagCompound(); - } - - public static boolean hasTag(ItemStack stack) { - return stack.hasTagCompound(); - } - - public static void setInt(ItemStack stack, String key, int val) { - getTag(stack).setInteger(key, val); - } - - public static int getInt(ItemStack stack, String key) { - return hasTag(stack) ? getTag(stack).getInteger(key) : 0; - } - - public static int receiveEnergy(ItemStack container, int energy, int maxEnergy, boolean simulate) { - int stored = getEnergyStored(container); - int accepted = Math.min(energy, maxEnergy - stored); - if (!simulate) { - stored += accepted; - NBTHelper.setInt(container, "Energy", stored); - } - return accepted; - } - - public static int extractEnergy(ItemStack container, int energy, boolean simulate) { - int stored = getEnergyStored(container); - int extracted = Math.min(energy, stored); - if (!simulate) { - stored -= extracted; - NBTHelper.setInt(container, "Energy", stored); - } - return extracted; - } - - public static int getEnergyStored(ItemStack container) { - return getInt(container, "Energy"); - } + public static NBTTagCompound getTag(ItemStack stack) { + if (!stack.hasTagCompound()) + stack.setTagCompound(new NBTTagCompound()); + return stack.getTagCompound(); + } + + public static boolean hasTag(ItemStack stack) { + return stack.hasTagCompound(); + } + + public static void setInt(ItemStack stack, String key, int val) { + getTag(stack).setInteger(key, val); + } + + public static int getInt(ItemStack stack, String key) { + return hasTag(stack) ? getTag(stack).getInteger(key) : 0; + } + + public static int receiveEnergy(ItemStack container, int energy, int maxEnergy, boolean simulate) { + int stored = getEnergyStored(container); + int accepted = Math.min(energy, maxEnergy - stored); + if (!simulate) { + stored += accepted; + NBTHelper.setInt(container, "Energy", stored); + } + return accepted; + } + + public static int extractEnergy(ItemStack container, int energy, boolean simulate) { + int stored = getEnergyStored(container); + int extracted = Math.min(energy, stored); + if (!simulate) { + stored -= extracted; + NBTHelper.setInt(container, "Energy", stored); + } + return extracted; + } + + public static int getEnergyStored(ItemStack container) { + return getInt(container, "Energy"); + } } diff --git a/src/main/java/me/jacky1356400/exchangers/helper/RecipeHelper.java b/src/main/java/me/jacky1356400/exchangers/helper/RecipeHelper.java index 6e05abb..e4a8ac9 100644 --- a/src/main/java/me/jacky1356400/exchangers/helper/RecipeHelper.java +++ b/src/main/java/me/jacky1356400/exchangers/helper/RecipeHelper.java @@ -18,231 +18,231 @@ public class RecipeHelper { - private static int j = 0; - private static final String MODID = Data.MODID; - private static final String MODNAME = Data.MODNAME; - /* - * This needs to be looped through and passed in a RegistryEvent.Register, it should also be populated during that event. - * Yes, I could do it here with @EventBusSubcriber, but I won't. - */ - public static final List RECIPES = Data.RECIPES; - - /* - * This adds the recipe to the list of crafting recipes. Since who cares about names, it adds it as recipesX, where X is the current recipe you are adding. - */ - public static void addRecipe(int j, IRecipe rec) { - if (rec.getRegistryName() == null) - RECIPES.add(rec.setRegistryName(new ResourceLocation(MODID, "recipes" + j))); - else - RECIPES.add(rec); - } - - /* - * This adds the recipe to the list of crafting recipes. Cares about names. - */ - public static void addRecipe(String name, IRecipe rec) { - if (rec.getRegistryName() == null) - RECIPES.add(rec.setRegistryName(new ResourceLocation(MODID, name))); - else - RECIPES.add(rec); - } - - /* - * This adds a shaped recipe to the list of crafting recipes, using the forge format. - */ - @Deprecated //Use GameRegistry.addShapedRecipe - public static void addOldShaped(ItemStack output, Object... input) { - ShapedPrimer primer = CraftingHelper.parseShaped(input); - addRecipe(j++, new ShapedRecipes(new ResourceLocation(MODID, "recipes" + j).toString(), primer.width, - primer.height, primer.input, output)); - } - - /* - * This adds a shaped recipe to the list of crafting recipes, using the forge format, with a custom group. - */ - @Deprecated //Use GameRegistry.addShapedRecipe - public static void addOldShaped(String group, ItemStack output, Object... input) { - ShapedPrimer primer = CraftingHelper.parseShaped(input); - addRecipe(j++, new ShapedRecipes(new ResourceLocation(MODID, group).toString(), primer.width, primer.height, - primer.input, output)); - } - - /* - * This adds a shaped recipe to the list of crafting recipes, using the forge format, with a custom group. - */ - @Deprecated //Use GameRegistry.addShapedRecipe - public static void addOldShaped(String name, String group, ItemStack output, Object... input) { - ShapedPrimer primer = CraftingHelper.parseShaped(input); - addRecipe(j++, new ShapedRecipes(new ResourceLocation(MODID, group).toString(), primer.width, primer.height, - primer.input, output).setRegistryName(MODID, name)); - } - - /* - * This adds a shapeless recipe to the list of crafting recipes, using the forge format. - */ - @Deprecated //Use GameRegistry.addShapelessRecipe - public static void addOldShapeless(ItemStack output, Object... input) { - addRecipe(j++, new ShapelessRecipes(new ResourceLocation(MODID, "recipes" + j).toString(), output, - createInput(input))); - } - - /* - * This adds a shapeless recipe to the list of crafting recipes, using the forge format. - */ - @Deprecated //Use GameRegistry.addShapedRecipe - public static void addOldShaped(Item output, Object... input) { - addOldShaped(new ItemStack(output), input); - } - - /* - * This adds a shapeless recipe to the list of crafting recipes, using the forge format, with a custom group. - */ - @Deprecated //Use GameRegistry.addShapelessRecipe - public static void addOldShapeless(String group, ItemStack output, Object... input) { - addRecipe(j++, new ShapelessRecipes(new ResourceLocation(MODID, group).toString(), output, createInput(input))); - } - - @Deprecated //Use GameRegistry.addShapelessRecipe - public static void addOldShapeless(String name, String group, ItemStack output, Object... input) { - addRecipe(j++, new ShapelessRecipes(new ResourceLocation(MODID, group).toString(), output, createInput(input)) - .setRegistryName(MODID, name)); - } - - /* - * Adds a shapeless recipe with X output using an array of inputs. Use Strings for OreDictionary support. This array is not ordered. - */ - public static void addShapeless(ItemStack output, Object... inputs) { - addRecipe(j++, new ShapelessRecipes(MODID + ":" + j, output, createInput(inputs))); - } - - public static void addShapeless(Item output, Object... inputs) { - addShapeless(new ItemStack(output), inputs); - } - - public static void addShapeless(Block output, Object... inputs) { - addShapeless(new ItemStack(output), inputs); - } - - /* - * Adds a shapeless recipe with X output using an array of inputs. Use Strings for OreDictionary support. This array is not ordered. This has a custom group. - */ - public static void addShapeless(String group, ItemStack output, Object... inputs) { - addRecipe(j++, new ShapelessRecipes(MODID + ":" + group, output, createInput(inputs))); - } - - public static void addShapeless(String group, Item output, Object... inputs) { - addShapeless(group, new ItemStack(output), inputs); - } - - public static void addShapeless(String group, Block output, Object... inputs) { - addShapeless(group, new ItemStack(output), inputs); - } - - /* - * Adds a shapeless recipe with X output on a crafting grid that is W x H, using an array of inputs. Use null for nothing, use Strings for OreDictionary support, this array must have a length of width * height. - * This array is ordered, and items must follow from left to right, top to bottom of the crafting grid. - */ - public static void addShaped(ItemStack output, int width, int height, Object... input) { - addRecipe(j++, genShaped(output, width, height, input)); - } - - public static void addShaped(Item output, int width, int height, Object... input) { - addShaped(new ItemStack(output), width, height, input); - } - - public static void addShaped(Block output, int width, int height, Object... input) { - addShaped(new ItemStack(output), width, height, input); - } - - /* - * Adds a shapeless recipe with X output on a crafting grid that is W x H, using an array of inputs. Use null for nothing, use Strings for OreDictionary support, this array must have a length of width * height. - * This array is ordered, and items must follow from left to right, top to bottom of the crafting grid. This has a custom group. - */ - public static void addShaped(String group, ItemStack output, int width, int height, Object... input) { - addRecipe(j++, genShaped(MODID + ":" + group, output, width, height, input)); - } - - public static void addShaped(String group, Item output, int width, int height, Object... input) { - addShaped(group, new ItemStack(output), width, height, input); - } - - public static void addShaped(String group, Block output, int width, int height, Object... input) { - addShaped(group, new ItemStack(output), width, height, input); - } - - public static ShapedRecipes genShaped(ItemStack output, int l, int w, Object[] input) { - if (input[0] instanceof Object[]) - input = (Object[]) input[0]; - if (l * w != input.length) - throw new UnsupportedOperationException( - "Attempted to add invalid shaped recipe. Complain to the author of " + MODNAME); - NonNullList inputL = NonNullList.create(); - for (int i = 0; i < input.length; i++) { - Object k = input[i]; - if (k instanceof String) { - inputL.add(i, new OreIngredient((String) k)); - } else if (k instanceof ItemStack && !((ItemStack) k).isEmpty()) { - inputL.add(i, Ingredient.fromStacks((ItemStack) k)); - } else if (k instanceof Item) { - inputL.add(i, Ingredient.fromStacks(new ItemStack((Item) k))); - } else if (k instanceof Block) { - inputL.add(i, Ingredient.fromStacks(new ItemStack((Block) k))); - } else { - inputL.add(i, Ingredient.EMPTY); - } - } - - return new ShapedRecipes(MODID + ":" + j, l, w, inputL, output); - } - - public static ShapedRecipes genShaped(String group, ItemStack output, int l, int w, Object[] input) { - if (input[0] instanceof List) - input = ((List) input[0]).toArray(); - else if (input[0] instanceof Object[]) - input = (Object[]) input[0]; - if (l * w != input.length) - throw new UnsupportedOperationException( - "Attempted to add invalid shaped recipe. Complain to the author of " + MODNAME); - NonNullList inputL = NonNullList.create(); - for (int i = 0; i < input.length; i++) { - Object k = input[i]; - if (k instanceof String) { - inputL.add(i, new OreIngredient((String) k)); - } else if (k instanceof ItemStack && !((ItemStack) k).isEmpty()) { - inputL.add(i, Ingredient.fromStacks((ItemStack) k)); - } else if (k instanceof Item) { - inputL.add(i, Ingredient.fromStacks(new ItemStack((Item) k))); - } else if (k instanceof Block) { - inputL.add(i, Ingredient.fromStacks(new ItemStack((Block) k))); - } else { - inputL.add(i, Ingredient.EMPTY); - } - } - - return new ShapedRecipes(group, l, w, inputL, output); - } - - public static NonNullList createInput(Object[] input) { - if (input[0] instanceof List) - input = ((List) input[0]).toArray(); - else if (input[0] instanceof Object[]) - input = (Object[]) input[0]; - NonNullList inputL = NonNullList.create(); - for (int i = 0; i < input.length; i++) { - Object k = input[i]; - if (k instanceof String) { - inputL.add(i, new OreIngredient((String) k)); - } else if (k instanceof ItemStack) { - inputL.add(i, Ingredient.fromStacks((ItemStack) k)); - } else if (k instanceof Item) { - inputL.add(i, Ingredient.fromStacks(new ItemStack((Item) k))); - } else if (k instanceof Block) { - inputL.add(i, Ingredient.fromStacks(new ItemStack((Block) k))); - } else { - throw new UnsupportedOperationException( - "Attempted to add invalid shapeless recipe. Complain to the author of " + MODNAME); - } - } - return inputL; - } + /* + * This needs to be looped through and passed in a RegistryEvent.Register, it should also be populated during that event. + * Yes, I could do it here with @EventBusSubcriber, but I won't. + */ + public static final List RECIPES = Data.RECIPES; + private static final String MODID = Data.MODID; + private static final String MODNAME = Data.MODNAME; + private static int j = 0; + + /* + * This adds the recipe to the list of crafting recipes. Since who cares about names, it adds it as recipesX, where X is the current recipe you are adding. + */ + public static void addRecipe(int j, IRecipe rec) { + if (rec.getRegistryName() == null) + RECIPES.add(rec.setRegistryName(new ResourceLocation(MODID, "recipes" + j))); + else + RECIPES.add(rec); + } + + /* + * This adds the recipe to the list of crafting recipes. Cares about names. + */ + public static void addRecipe(String name, IRecipe rec) { + if (rec.getRegistryName() == null) + RECIPES.add(rec.setRegistryName(new ResourceLocation(MODID, name))); + else + RECIPES.add(rec); + } + + /* + * This adds a shaped recipe to the list of crafting recipes, using the forge format. + */ + @Deprecated //Use GameRegistry.addShapedRecipe + public static void addOldShaped(ItemStack output, Object... input) { + ShapedPrimer primer = CraftingHelper.parseShaped(input); + addRecipe(j++, new ShapedRecipes(new ResourceLocation(MODID, "recipes" + j).toString(), primer.width, + primer.height, primer.input, output)); + } + + /* + * This adds a shaped recipe to the list of crafting recipes, using the forge format, with a custom group. + */ + @Deprecated //Use GameRegistry.addShapedRecipe + public static void addOldShaped(String group, ItemStack output, Object... input) { + ShapedPrimer primer = CraftingHelper.parseShaped(input); + addRecipe(j++, new ShapedRecipes(new ResourceLocation(MODID, group).toString(), primer.width, primer.height, + primer.input, output)); + } + + /* + * This adds a shaped recipe to the list of crafting recipes, using the forge format, with a custom group. + */ + @Deprecated //Use GameRegistry.addShapedRecipe + public static void addOldShaped(String name, String group, ItemStack output, Object... input) { + ShapedPrimer primer = CraftingHelper.parseShaped(input); + addRecipe(j++, new ShapedRecipes(new ResourceLocation(MODID, group).toString(), primer.width, primer.height, + primer.input, output).setRegistryName(MODID, name)); + } + + /* + * This adds a shapeless recipe to the list of crafting recipes, using the forge format. + */ + @Deprecated //Use GameRegistry.addShapelessRecipe + public static void addOldShapeless(ItemStack output, Object... input) { + addRecipe(j++, new ShapelessRecipes(new ResourceLocation(MODID, "recipes" + j).toString(), output, + createInput(input))); + } + + /* + * This adds a shapeless recipe to the list of crafting recipes, using the forge format. + */ + @Deprecated //Use GameRegistry.addShapedRecipe + public static void addOldShaped(Item output, Object... input) { + addOldShaped(new ItemStack(output), input); + } + + /* + * This adds a shapeless recipe to the list of crafting recipes, using the forge format, with a custom group. + */ + @Deprecated //Use GameRegistry.addShapelessRecipe + public static void addOldShapeless(String group, ItemStack output, Object... input) { + addRecipe(j++, new ShapelessRecipes(new ResourceLocation(MODID, group).toString(), output, createInput(input))); + } + + @Deprecated //Use GameRegistry.addShapelessRecipe + public static void addOldShapeless(String name, String group, ItemStack output, Object... input) { + addRecipe(j++, new ShapelessRecipes(new ResourceLocation(MODID, group).toString(), output, createInput(input)) + .setRegistryName(MODID, name)); + } + + /* + * Adds a shapeless recipe with X output using an array of inputs. Use Strings for OreDictionary support. This array is not ordered. + */ + public static void addShapeless(ItemStack output, Object... inputs) { + addRecipe(j++, new ShapelessRecipes(MODID + ":" + j, output, createInput(inputs))); + } + + public static void addShapeless(Item output, Object... inputs) { + addShapeless(new ItemStack(output), inputs); + } + + public static void addShapeless(Block output, Object... inputs) { + addShapeless(new ItemStack(output), inputs); + } + + /* + * Adds a shapeless recipe with X output using an array of inputs. Use Strings for OreDictionary support. This array is not ordered. This has a custom group. + */ + public static void addShapeless(String group, ItemStack output, Object... inputs) { + addRecipe(j++, new ShapelessRecipes(MODID + ":" + group, output, createInput(inputs))); + } + + public static void addShapeless(String group, Item output, Object... inputs) { + addShapeless(group, new ItemStack(output), inputs); + } + + public static void addShapeless(String group, Block output, Object... inputs) { + addShapeless(group, new ItemStack(output), inputs); + } + + /* + * Adds a shapeless recipe with X output on a crafting grid that is W x H, using an array of inputs. Use null for nothing, use Strings for OreDictionary support, this array must have a length of width * height. + * This array is ordered, and items must follow from left to right, top to bottom of the crafting grid. + */ + public static void addShaped(ItemStack output, int width, int height, Object... input) { + addRecipe(j++, genShaped(output, width, height, input)); + } + + public static void addShaped(Item output, int width, int height, Object... input) { + addShaped(new ItemStack(output), width, height, input); + } + + public static void addShaped(Block output, int width, int height, Object... input) { + addShaped(new ItemStack(output), width, height, input); + } + + /* + * Adds a shapeless recipe with X output on a crafting grid that is W x H, using an array of inputs. Use null for nothing, use Strings for OreDictionary support, this array must have a length of width * height. + * This array is ordered, and items must follow from left to right, top to bottom of the crafting grid. This has a custom group. + */ + public static void addShaped(String group, ItemStack output, int width, int height, Object... input) { + addRecipe(j++, genShaped(MODID + ":" + group, output, width, height, input)); + } + + public static void addShaped(String group, Item output, int width, int height, Object... input) { + addShaped(group, new ItemStack(output), width, height, input); + } + + public static void addShaped(String group, Block output, int width, int height, Object... input) { + addShaped(group, new ItemStack(output), width, height, input); + } + + public static ShapedRecipes genShaped(ItemStack output, int l, int w, Object[] input) { + if (input[0] instanceof Object[]) + input = (Object[]) input[0]; + if (l * w != input.length) + throw new UnsupportedOperationException( + "Attempted to add invalid shaped recipe. Complain to the author of " + MODNAME); + NonNullList inputL = NonNullList.create(); + for (int i = 0; i < input.length; i++) { + Object k = input[i]; + if (k instanceof String) { + inputL.add(i, new OreIngredient((String) k)); + } else if (k instanceof ItemStack && !((ItemStack) k).isEmpty()) { + inputL.add(i, Ingredient.fromStacks((ItemStack) k)); + } else if (k instanceof Item) { + inputL.add(i, Ingredient.fromStacks(new ItemStack((Item) k))); + } else if (k instanceof Block) { + inputL.add(i, Ingredient.fromStacks(new ItemStack((Block) k))); + } else { + inputL.add(i, Ingredient.EMPTY); + } + } + + return new ShapedRecipes(MODID + ":" + j, l, w, inputL, output); + } + + public static ShapedRecipes genShaped(String group, ItemStack output, int l, int w, Object[] input) { + if (input[0] instanceof List) + input = ((List) input[0]).toArray(); + else if (input[0] instanceof Object[]) + input = (Object[]) input[0]; + if (l * w != input.length) + throw new UnsupportedOperationException( + "Attempted to add invalid shaped recipe. Complain to the author of " + MODNAME); + NonNullList inputL = NonNullList.create(); + for (int i = 0; i < input.length; i++) { + Object k = input[i]; + if (k instanceof String) { + inputL.add(i, new OreIngredient((String) k)); + } else if (k instanceof ItemStack && !((ItemStack) k).isEmpty()) { + inputL.add(i, Ingredient.fromStacks((ItemStack) k)); + } else if (k instanceof Item) { + inputL.add(i, Ingredient.fromStacks(new ItemStack((Item) k))); + } else if (k instanceof Block) { + inputL.add(i, Ingredient.fromStacks(new ItemStack((Block) k))); + } else { + inputL.add(i, Ingredient.EMPTY); + } + } + + return new ShapedRecipes(group, l, w, inputL, output); + } + + public static NonNullList createInput(Object[] input) { + if (input[0] instanceof List) + input = ((List) input[0]).toArray(); + else if (input[0] instanceof Object[]) + input = (Object[]) input[0]; + NonNullList inputL = NonNullList.create(); + for (int i = 0; i < input.length; i++) { + Object k = input[i]; + if (k instanceof String) { + inputL.add(i, new OreIngredient((String) k)); + } else if (k instanceof ItemStack) { + inputL.add(i, Ingredient.fromStacks((ItemStack) k)); + } else if (k instanceof Item) { + inputL.add(i, Ingredient.fromStacks(new ItemStack((Item) k))); + } else if (k instanceof Block) { + inputL.add(i, Ingredient.fromStacks(new ItemStack((Block) k))); + } else { + throw new UnsupportedOperationException( + "Attempted to add invalid shapeless recipe. Complain to the author of " + MODNAME); + } + } + return inputL; + } } \ No newline at end of file diff --git a/src/main/java/me/jacky1356400/exchangers/helper/StringHelper.java b/src/main/java/me/jacky1356400/exchangers/helper/StringHelper.java index a8043ba..74b49c9 100644 --- a/src/main/java/me/jacky1356400/exchangers/helper/StringHelper.java +++ b/src/main/java/me/jacky1356400/exchangers/helper/StringHelper.java @@ -11,40 +11,40 @@ public final class StringHelper { - public static boolean displayShiftForDetail = true; - - private StringHelper() { - - } - - @SideOnly(Side.CLIENT) - public static String getShiftText() { - return TextFormatting.GRAY - + localize("tooltip.holdShift", TextFormatting.YELLOW.toString() + TextFormatting.ITALIC - + localize("tooltip.holdShift.shift") + TextFormatting.RESET + TextFormatting.GRAY); - } - - public static boolean isShiftKeyDown() { - return Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54); - } - - public static String formatNumber(long number) { - return NumberFormat.getInstance().format(number); - } - - @SideOnly(Side.CLIENT) - public static String localize(String unlocalized, Object... args) { - return localize(unlocalized, true, args); - } - - @SideOnly(Side.CLIENT) - public static String localize(String unlocalized, boolean prefix, Object... args) { - String toLocalize = (prefix ? Data.MODID + "." : "") + unlocalized; - if (args != null && args.length > 0) { - return I18n.format(toLocalize, args); - } else { - return I18n.format(toLocalize); - } - } + public static boolean displayShiftForDetail = true; + + private StringHelper() { + + } + + @SideOnly(Side.CLIENT) + public static String getShiftText() { + return TextFormatting.GRAY + + localize("tooltip.holdShift", TextFormatting.YELLOW.toString() + TextFormatting.ITALIC + + localize("tooltip.holdShift.shift") + TextFormatting.RESET + TextFormatting.GRAY); + } + + public static boolean isShiftKeyDown() { + return Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54); + } + + public static String formatNumber(long number) { + return NumberFormat.getInstance().format(number); + } + + @SideOnly(Side.CLIENT) + public static String localize(String unlocalized, Object... args) { + return localize(unlocalized, true, args); + } + + @SideOnly(Side.CLIENT) + public static String localize(String unlocalized, boolean prefix, Object... args) { + String toLocalize = (prefix ? Data.MODID + "." : "") + unlocalized; + if (args != null && args.length > 0) { + return I18n.format(toLocalize, args); + } else { + return I18n.format(toLocalize); + } + } } diff --git a/src/main/java/me/jacky1356400/exchangers/init/ModRegistry.java b/src/main/java/me/jacky1356400/exchangers/init/ModRegistry.java index 5b04988..7e4d4c4 100644 --- a/src/main/java/me/jacky1356400/exchangers/init/ModRegistry.java +++ b/src/main/java/me/jacky1356400/exchangers/init/ModRegistry.java @@ -1,13 +1,14 @@ package me.jacky1356400.exchangers.init; import me.jacky1356400.exchangers.Config; +import me.jacky1356400.exchangers.helper.RecipeHelper; +import me.jacky1356400.exchangers.integration.MekanismIntegration; import me.jacky1356400.exchangers.integration.ThermalExpansionIntegration; import me.jacky1356400.exchangers.item.ItemBasic; import me.jacky1356400.exchangers.item.ItemExchanger; import me.jacky1356400.exchangers.item.ItemPoweredExchanger; import me.jacky1356400.exchangers.item.special.ItemTuberousExchanger; import me.jacky1356400.exchangers.util.Data; -import me.jacky1356400.exchangers.helper.RecipeHelper; import me.jacky1356400.exchangers.util.Tier; import net.minecraft.block.Block; import net.minecraft.init.Items; @@ -28,15 +29,23 @@ public class ModRegistry { public static final Item EMERALD = new ItemExchanger("exemerald", Tier.SIX, Config.emeMaxDmg); public static final Item OBSIDIAN = new ItemExchanger("exobsidian", Tier.SEVEN, Config.obsMaxDmg); public static final Item LEADSTONE = new ItemPoweredExchanger("exleadstone", Tier.TE_ONE, Config.leadstoneMaxEnergy, - Config.leadstonePerBlockUse); + Config.leadstonePerBlockUse); public static final Item HARDENED = new ItemPoweredExchanger("exhardened", Tier.TE_TWO, Config.hardenedMaxEnergy, - Config.hardenedPerBlockUse); + Config.hardenedPerBlockUse); public static final Item REINFORCED = new ItemPoweredExchanger("exreinforced", Tier.TE_THREE, - Config.reinforcedMaxEnergy, Config.reinforcedPerBlockUse); + Config.reinforcedMaxEnergy, Config.reinforcedPerBlockUse); public static final Item SIGNALUM = new ItemPoweredExchanger("exsignalum", Tier.TE_FOUR, Config.signalumMaxEnergy, - Config.signalumPerBlockUse); + Config.signalumPerBlockUse); public static final Item RESONANT = new ItemPoweredExchanger("exresonant", Tier.TE_FIVE, Config.resonantMaxEnergy, - Config.resonantPerBlockUse); + Config.resonantPerBlockUse); + public static final Item BASIC = new ItemPoweredExchanger("exbasic", Tier.MEK_ONE, Config.basicMaxEnergy, + Config.basicPerBlockUse); + public static final Item ADVANCED = new ItemPoweredExchanger("exadvanced", Tier.MEK_TWO, Config.advancedMaxEnergy, + Config.advancedPerBlockUse); + public static final Item ELITE = new ItemPoweredExchanger("exelite", Tier.MEK_THREE, Config.eliteMaxEnergy, + Config.elitePerBlockUse); + public static final Item ULTIMATE = new ItemPoweredExchanger("exultimate", Tier.MEK_FOUR, Config.ultimateMaxEnergy, + Config.ultimatePerBlockUse); public static final Item CREATIVE = new ItemExchanger("excreative", Tier.CREATIVE, 9001); public static final Item POTATO = new ItemTuberousExchanger(); public static final Item CORE_1 = new ItemBasic("excore_t1"); @@ -45,126 +54,163 @@ public class ModRegistry { public static final Item TECORE_1 = new ItemBasic("teexcore_t1"); public static final Item TECORE_2 = new ItemBasic("teexcore_t2"); public static final Item TECORE_3 = new ItemBasic("teexcore_t3"); + public static final Item MEKCORE_1 = new ItemBasic("mekexcore_t1"); + public static final Item MEKCORE_2 = new ItemBasic("mekexcore_t2"); + public static final Item MEKCORE_3 = new ItemBasic("mekexcore_t3"); private static void initRecipes() { - if (Config.vanillaModule) { - String W = "logWood"; - String R = "dyeRed"; - String S = "stone"; - String G = "ingotGold"; - String I = "ingotIron"; - String D = "gemDiamond"; - String Db = "blockDiamond"; - String E = "gemEmerald"; - String L = "gemLapis"; - String O = "obsidian"; - String Pe = "enderpearl"; - Item EYE = Items.ENDER_EYE; - - RecipeHelper.addShaped(WOODEN, 3, 3, W, EYE, W, W, CORE_1, W, W, EYE, W); - - if (Config.vanillaProgressiveRecipes) { - RecipeHelper.addShaped(STONE, 3, 3, S, EYE, S, CORE_1, WOODEN, CORE_1, S, EYE, S); - RecipeHelper.addShaped(GOLD, 3, 3, G, EYE, G, CORE_2, STONE, CORE_2, G, EYE, G); - RecipeHelper.addShaped(IRON, 3, 3, I, EYE, I, CORE_2, GOLD, CORE_2, I, EYE, I); - RecipeHelper.addShaped(DIAMOND, 3, 3, D, EYE, D, CORE_3, IRON, CORE_3, D, EYE, D); - RecipeHelper.addShaped(EMERALD, 3, 3, E, EYE, E, CORE_3, DIAMOND, CORE_3, E, EYE, E); - RecipeHelper.addShaped(OBSIDIAN, 3, 3, O, EYE, O, CORE_3, EMERALD, CORE_3, O, EYE, O); - } else { - RecipeHelper.addShaped(STONE, 3, 3, S, EYE, S, S, CORE_1, S, S, EYE, S); - RecipeHelper.addShaped(GOLD, 3, 3, G, EYE, G, G, CORE_2, G, G, EYE, G); - RecipeHelper.addShaped(IRON, 3, 3, I, EYE, I, I, CORE_2, I, I, EYE, I); - RecipeHelper.addShaped(DIAMOND, 3, 3, D, EYE, D, D, CORE_3, D, D, EYE, D); - RecipeHelper.addShaped(EMERALD, 3, 3, E, EYE, E, E, CORE_3, E, E, EYE, E); - RecipeHelper.addShaped(OBSIDIAN, 3, 3, O, EYE, O, O, CORE_3, O, O, EYE, O); - } - - RecipeHelper.addShaped(CORE_1, 3, 3, W, R, W, R, Pe, R, W, R, W); - RecipeHelper.addShaped(CORE_2, 3, 3, I, L, I, CORE_1, EYE, CORE_1, I, L, I); - RecipeHelper.addShaped(CORE_3, 3, 3, D, CORE_2, E, CORE_2, Db, CORE_2, E, CORE_2, D); - } - if (Config.specialModule) { - String Pe = "enderpearl"; - String nG = "nuggetGold"; - Item Po = Items.POTATO; - - RecipeHelper.addShaped(POTATO, 3, 3, Po, nG, Po, Po, Pe, Po, Po, nG, Po); - } - if (Config.thermalExpansionModule) { - if (Loader.isModLoaded(Data.THERMAL)) { - String iLe = "ingotLead"; - String iI = "ingotInvar"; - String iEle = "ingotElectrum"; - String iS = "ingotSignalum"; - String iEn = "ingotEnderium"; - String gC = "gearCopper"; - String gB = "gearBronze"; - String gI = "gearInvar"; - String gLu = "gearLumium"; - ItemStack S = ThermalExpansionIntegration.redstoneServo; - ItemStack C1 = ThermalExpansionIntegration.redstoneReceptionCoil; - ItemStack C2 = ThermalExpansionIntegration.redstoneTransmissionCoil; - ItemStack C3 = ThermalExpansionIntegration.redstoneConductanceCoil; - ItemStack F1 = ThermalExpansionIntegration.fluxCapacitorBasic; - ItemStack F2 = ThermalExpansionIntegration.fluxCapacitorHardened; - ItemStack F3 = ThermalExpansionIntegration.fluxCapacitorReinforced; - ItemStack F4 = ThermalExpansionIntegration.fluxCapacitorSignalum; - ItemStack F5 = ThermalExpansionIntegration.fluxCapacitorResonant; - ItemStack B1 = ThermalExpansionIntegration.bucketResonantEnder; - ItemStack B2 = ThermalExpansionIntegration.bucketEnergizedGlowstone; - ItemStack B3 = ThermalExpansionIntegration.bucketGelidCryotheum; - - RecipeHelper.addShaped(LEADSTONE, 3, 3, iLe, S, iLe, iLe, TECORE_1, iLe, iLe, F1, iLe); - - if (Config.thermalExpansionProgressiveRecipes) { - RecipeHelper.addShaped(HARDENED, 3, 3, iI, C1, iI, TECORE_1, LEADSTONE, TECORE_1, iI, F2, iI); - RecipeHelper.addShaped(REINFORCED, 3, 3, iEle, C2, iEle, TECORE_2, HARDENED, TECORE_2, iEle, F3, - iEle); - RecipeHelper.addShaped(SIGNALUM, 3, 3, iS, C3, iS, TECORE_3, REINFORCED, TECORE_3, iS, F4, iS); - RecipeHelper.addShaped(RESONANT, 3, 3, iEn, C3, iEn, TECORE_3, SIGNALUM, TECORE_3, iEn, F5, iEn); - } else { - RecipeHelper.addShaped(HARDENED, 3, 3, iI, C1, iI, iI, TECORE_1, iI, iI, F2, iI); - RecipeHelper.addShaped(REINFORCED, 3, 3, iEle, C2, iEle, iEle, TECORE_2, iEle, iEle, F3, iEle); - RecipeHelper.addShaped(SIGNALUM, 3, 3, iS, C3, iS, iS, TECORE_3, iS, iS, F4, iS); - RecipeHelper.addShaped(RESONANT, 3, 3, iEn, C3, iEn, iEn, TECORE_3, iEn, iEn, F5, iEn); - } - - RecipeHelper.addShaped(TECORE_1, 3, 3, gC, iLe, gC, iLe, B1, iLe, gC, iLe, gC); - RecipeHelper.addShaped(TECORE_2, 3, 3, gB, gI, gB, TECORE_1, B2, TECORE_1, gB, gI, gB); - RecipeHelper.addShaped(TECORE_3, 3, 3, gLu, TECORE_2, gLu, TECORE_2, B3, TECORE_2, gLu, TECORE_2, gLu); - } - } + if (Config.vanillaModule) { + String W = "logWood"; + String R = "dyeRed"; + String S = "stone"; + String G = "ingotGold"; + String I = "ingotIron"; + String D = "gemDiamond"; + String Db = "blockDiamond"; + String E = "gemEmerald"; + String L = "gemLapis"; + String O = "obsidian"; + String Pe = "enderpearl"; + Item EYE = Items.ENDER_EYE; + + RecipeHelper.addShaped(WOODEN, 3, 3, W, EYE, W, W, CORE_1, W, W, EYE, W); + + if (Config.vanillaProgressiveRecipes) { + RecipeHelper.addShaped(STONE, 3, 3, S, EYE, S, CORE_1, WOODEN, CORE_1, S, EYE, S); + RecipeHelper.addShaped(GOLD, 3, 3, G, EYE, G, CORE_2, STONE, CORE_2, G, EYE, G); + RecipeHelper.addShaped(IRON, 3, 3, I, EYE, I, CORE_2, GOLD, CORE_2, I, EYE, I); + RecipeHelper.addShaped(DIAMOND, 3, 3, D, EYE, D, CORE_3, IRON, CORE_3, D, EYE, D); + RecipeHelper.addShaped(EMERALD, 3, 3, E, EYE, E, CORE_3, DIAMOND, CORE_3, E, EYE, E); + RecipeHelper.addShaped(OBSIDIAN, 3, 3, O, EYE, O, CORE_3, EMERALD, CORE_3, O, EYE, O); + } else { + RecipeHelper.addShaped(STONE, 3, 3, S, EYE, S, S, CORE_1, S, S, EYE, S); + RecipeHelper.addShaped(GOLD, 3, 3, G, EYE, G, G, CORE_2, G, G, EYE, G); + RecipeHelper.addShaped(IRON, 3, 3, I, EYE, I, I, CORE_2, I, I, EYE, I); + RecipeHelper.addShaped(DIAMOND, 3, 3, D, EYE, D, D, CORE_3, D, D, EYE, D); + RecipeHelper.addShaped(EMERALD, 3, 3, E, EYE, E, E, CORE_3, E, E, EYE, E); + RecipeHelper.addShaped(OBSIDIAN, 3, 3, O, EYE, O, O, CORE_3, O, O, EYE, O); + } + + RecipeHelper.addShaped(CORE_1, 3, 3, W, R, W, R, Pe, R, W, R, W); + RecipeHelper.addShaped(CORE_2, 3, 3, I, L, I, CORE_1, EYE, CORE_1, I, L, I); + RecipeHelper.addShaped(CORE_3, 3, 3, D, CORE_2, E, CORE_2, Db, CORE_2, E, CORE_2, D); + } + if (Config.specialModule) { + String Pe = "enderpearl"; + String nG = "nuggetGold"; + Item Po = Items.POTATO; + + RecipeHelper.addShaped(POTATO, 3, 3, Po, nG, Po, Po, Pe, Po, Po, nG, Po); + } + if (Config.thermalExpansionModule) { + if (Loader.isModLoaded(Data.THERMAL)) { + String iLe = "ingotLead"; + String iI = "ingotInvar"; + String iEle = "ingotElectrum"; + String iS = "ingotSignalum"; + String iEn = "ingotEnderium"; + String gC = "gearCopper"; + String gB = "gearBronze"; + String gI = "gearInvar"; + String gLu = "gearLumium"; + ItemStack S = ThermalExpansionIntegration.redstoneServo; + ItemStack C1 = ThermalExpansionIntegration.redstoneReceptionCoil; + ItemStack C2 = ThermalExpansionIntegration.redstoneTransmissionCoil; + ItemStack C3 = ThermalExpansionIntegration.redstoneConductanceCoil; + ItemStack F1 = ThermalExpansionIntegration.fluxCapacitorBasic; + ItemStack F2 = ThermalExpansionIntegration.fluxCapacitorHardened; + ItemStack F3 = ThermalExpansionIntegration.fluxCapacitorReinforced; + ItemStack F4 = ThermalExpansionIntegration.fluxCapacitorSignalum; + ItemStack F5 = ThermalExpansionIntegration.fluxCapacitorResonant; + ItemStack B1 = ThermalExpansionIntegration.bucketResonantEnder; + ItemStack B2 = ThermalExpansionIntegration.bucketEnergizedGlowstone; + ItemStack B3 = ThermalExpansionIntegration.bucketGelidCryotheum; + + RecipeHelper.addShaped(LEADSTONE, 3, 3, iLe, S, iLe, iLe, TECORE_1, iLe, iLe, F1, iLe); + + if (Config.thermalExpansionProgressiveRecipes) { + RecipeHelper.addShaped(HARDENED, 3, 3, iI, C1, iI, TECORE_1, LEADSTONE, TECORE_1, iI, F2, iI); + RecipeHelper.addShaped(REINFORCED, 3, 3, iEle, C2, iEle, TECORE_2, HARDENED, TECORE_2, iEle, F3, iEle); + RecipeHelper.addShaped(SIGNALUM, 3, 3, iS, C3, iS, TECORE_3, REINFORCED, TECORE_3, iS, F4, iS); + RecipeHelper.addShaped(RESONANT, 3, 3, iEn, C3, iEn, TECORE_3, SIGNALUM, TECORE_3, iEn, F5, iEn); + } else { + RecipeHelper.addShaped(HARDENED, 3, 3, iI, C1, iI, iI, TECORE_1, iI, iI, F2, iI); + RecipeHelper.addShaped(REINFORCED, 3, 3, iEle, C2, iEle, iEle, TECORE_2, iEle, iEle, F3, iEle); + RecipeHelper.addShaped(SIGNALUM, 3, 3, iS, C3, iS, iS, TECORE_3, iS, iS, F4, iS); + RecipeHelper.addShaped(RESONANT, 3, 3, iEn, C3, iEn, iEn, TECORE_3, iEn, iEn, F5, iEn); + } + + RecipeHelper.addShaped(TECORE_1, 3, 3, gC, iLe, gC, iLe, B1, iLe, gC, iLe, gC); + RecipeHelper.addShaped(TECORE_2, 3, 3, gB, gI, gB, TECORE_1, B2, TECORE_1, gB, gI, gB); + RecipeHelper.addShaped(TECORE_3, 3, 3, gLu, TECORE_2, gLu, TECORE_2, B3, TECORE_2, gLu, TECORE_2, gLu); + } + } + if (Config.mekanismModule) { + if (Loader.isModLoaded(Data.MEK)) { + String iO = "ingotOsmium"; + String iS = "ingotSteel"; + String iRG = "ingotRefinedGlowstone"; + String dD = "dustDiamond"; + String dRO = "dustRefinedObsidian"; + String A1 = "alloyAdvanced"; + String A2 = "alloyElite"; + String A3 = "alloyUltimate"; + ItemStack C1 = MekanismIntegration.circuitBasic; + ItemStack C2 = MekanismIntegration.circuitAdvanced; + ItemStack C3 = MekanismIntegration.circuitElite; + ItemStack C4 = MekanismIntegration.circuitUltimate; + ItemStack T = MekanismIntegration.energyTablet; + ItemStack Tel = MekanismIntegration.portableTeleporter; + ItemStack TelC = MekanismIntegration.teleportationCore; + + RecipeHelper.addShaped(BASIC, 3, 3, C1, T, C1, C1, MEKCORE_1, C1, C1, T, C1); + + if (Config.mekanismProgressiveRecipes) { + RecipeHelper.addShaped(ADVANCED, 3, 3, C2, T, C2, MEKCORE_2, BASIC, MEKCORE_2, C2, T, C2); + RecipeHelper.addShaped(ELITE, 3, 3, C3, TelC, C3, MEKCORE_3, ADVANCED, MEKCORE_3, C3, T, C3); + RecipeHelper.addShaped(ULTIMATE, 3, 3, C4, Tel, C4, MEKCORE_3, ELITE, MEKCORE_3, C4, Tel, C4); + } else { + RecipeHelper.addShaped(ADVANCED, 3, 3, C2, T, C2, C2, MEKCORE_2, C2, C2, T, C2); + RecipeHelper.addShaped(ELITE, 3, 3, C3, TelC, C3, C3, MEKCORE_3, C3, C3, T, C3); + RecipeHelper.addShaped(ULTIMATE, 3, 3, C4, Tel, C4, C4, MEKCORE_3, C4, C4, Tel, C4); + } + + RecipeHelper.addShaped(MEKCORE_1, 3, 3, iO, iS, iO, iS, A1, iS, iO, iS, iO); + RecipeHelper.addShaped(MEKCORE_2, 3, 3, dD, iRG, dD, MEKCORE_1, A2, MEKCORE_1, dD, iRG, dD); + RecipeHelper.addShaped(MEKCORE_3, 3, 3, dRO, MEKCORE_2, dRO, MEKCORE_2, A3, MEKCORE_2, dRO, MEKCORE_2, dRO); + } + } } @SubscribeEvent public void onBlockRegistry(RegistryEvent.Register e) { - e.getRegistry().registerAll(Data.BLOCKS.toArray(new Block[0])); + e.getRegistry().registerAll(Data.BLOCKS.toArray(new Block[0])); } @SubscribeEvent public void onItemRegistry(RegistryEvent.Register e) { - e.getRegistry().registerAll(Data.ITEMS.toArray(new Item[0])); + e.getRegistry().registerAll(Data.ITEMS.toArray(new Item[0])); } @SubscribeEvent public void onRecipeRegistry(RegistryEvent.Register e) { - if (Config.enderIOModule = true) { - if (Loader.isModLoaded(Data.EIO)) { - // EnderIOIntegration.init(); - } - } - if (Config.thermalExpansionModule = true) { - if (Loader.isModLoaded(Data.THERMAL)) { - ThermalExpansionIntegration.init(); - } - } - if (Config.mekanismModule = true) { - if (Loader.isModLoaded(Data.MEK)) { - // MekanismIntegration.init(); - } - } - initRecipes(); - e.getRegistry().registerAll(Data.RECIPES.toArray(new IRecipe[0])); + if (Config.enderIOModule) { + if (Loader.isModLoaded(Data.EIO)) { + // EnderIOIntegration.init(); + } + } + if (Config.thermalExpansionModule) { + if (Loader.isModLoaded(Data.THERMAL)) { + ThermalExpansionIntegration.init(); + } + } + if (Config.mekanismModule) { + if (Loader.isModLoaded(Data.MEK)) { + MekanismIntegration.init(); + } + } + initRecipes(); + e.getRegistry().registerAll(Data.RECIPES.toArray(new IRecipe[0])); } } diff --git a/src/main/java/me/jacky1356400/exchangers/integration/EnderIOIntegration.java b/src/main/java/me/jacky1356400/exchangers/integration/EnderIOIntegration.java index b702832..33d83c2 100644 --- a/src/main/java/me/jacky1356400/exchangers/integration/EnderIOIntegration.java +++ b/src/main/java/me/jacky1356400/exchangers/integration/EnderIOIntegration.java @@ -12,47 +12,47 @@ public class EnderIOIntegration { - public static ItemStack capacitorBankBasic; - public static ItemStack capacitorBank; - public static ItemStack capacitorBankVibrant; - public static ItemStack basicCapacitor; - public static ItemStack doubleLayerCapacitor; - public static ItemStack octadicCapacitor; - public static ItemStack pulsatingCrystal; - public static ItemStack vibrantCrystal; - public static ItemStack enderCrystal; - public static ItemStack bucketNutrientDistillation; - public static ItemStack bucketDewOfTheVoid; - public static ItemStack bucketVaporOfLevity; - - public static void init() { - Exchangers.logger.info("Fetching items for Ender IO integration..."); - - Block capBankBlock = Block.REGISTRY.getObject(new ResourceLocation("enderio", "blockCapBank")); - capacitorBankBasic = new ItemStack(capBankBlock, 1, 1); - capacitorBank = new ItemStack(capBankBlock, 1, 2); - capacitorBankVibrant = new ItemStack(capBankBlock, 1, 3); - - Item capacitorItem = Item.REGISTRY.getObject(new ResourceLocation("enderio", "itemBasicCapacitor")); - if (capacitorItem != null) { - basicCapacitor = new ItemStack(capacitorItem, 1, 0); - doubleLayerCapacitor = new ItemStack(capacitorItem, 1, 1); - octadicCapacitor = new ItemStack(capacitorItem, 1, 2); - } - - Item eioMaterialsItem = Item.REGISTRY.getObject(new ResourceLocation("enderio", "itemMaterial")); - if (eioMaterialsItem != null) { - pulsatingCrystal = new ItemStack(eioMaterialsItem, 1, 5); - vibrantCrystal = new ItemStack(eioMaterialsItem, 1, 6); - enderCrystal = new ItemStack(eioMaterialsItem, 1, 8); - } - - Fluid nutrientDistillation = FluidRegistry.getFluid("nutrient_distillation"); - bucketNutrientDistillation = FluidUtil.getFilledBucket(new FluidStack(nutrientDistillation, 1000)); - Fluid dewOfTheVoid = FluidRegistry.getFluid("ender_distillation"); - bucketDewOfTheVoid = FluidUtil.getFilledBucket(new FluidStack(dewOfTheVoid, 1000)); - Fluid vaporOfLevity = FluidRegistry.getFluid("vapor_of_levity"); - bucketVaporOfLevity = FluidUtil.getFilledBucket(new FluidStack(vaporOfLevity, 1000)); - } + public static ItemStack capacitorBankBasic; + public static ItemStack capacitorBank; + public static ItemStack capacitorBankVibrant; + public static ItemStack basicCapacitor; + public static ItemStack doubleLayerCapacitor; + public static ItemStack octadicCapacitor; + public static ItemStack pulsatingCrystal; + public static ItemStack vibrantCrystal; + public static ItemStack enderCrystal; + public static ItemStack bucketNutrientDistillation; + public static ItemStack bucketDewOfTheVoid; + public static ItemStack bucketVaporOfLevity; + + public static void init() { + Exchangers.logger.info("Fetching items for Ender IO integration..."); + + Block capBankBlock = Block.REGISTRY.getObject(new ResourceLocation("enderio", "blockCapBank")); + capacitorBankBasic = new ItemStack(capBankBlock, 1, 1); + capacitorBank = new ItemStack(capBankBlock, 1, 2); + capacitorBankVibrant = new ItemStack(capBankBlock, 1, 3); + + Item capacitorItem = Item.REGISTRY.getObject(new ResourceLocation("enderio", "itemBasicCapacitor")); + if (capacitorItem != null) { + basicCapacitor = new ItemStack(capacitorItem, 1, 0); + doubleLayerCapacitor = new ItemStack(capacitorItem, 1, 1); + octadicCapacitor = new ItemStack(capacitorItem, 1, 2); + } + + Item eioMaterialsItem = Item.REGISTRY.getObject(new ResourceLocation("enderio", "itemMaterial")); + if (eioMaterialsItem != null) { + pulsatingCrystal = new ItemStack(eioMaterialsItem, 1, 5); + vibrantCrystal = new ItemStack(eioMaterialsItem, 1, 6); + enderCrystal = new ItemStack(eioMaterialsItem, 1, 8); + } + + Fluid nutrientDistillation = FluidRegistry.getFluid("nutrient_distillation"); + bucketNutrientDistillation = FluidUtil.getFilledBucket(new FluidStack(nutrientDistillation, 1000)); + Fluid dewOfTheVoid = FluidRegistry.getFluid("ender_distillation"); + bucketDewOfTheVoid = FluidUtil.getFilledBucket(new FluidStack(dewOfTheVoid, 1000)); + Fluid vaporOfLevity = FluidRegistry.getFluid("vapor_of_levity"); + bucketVaporOfLevity = FluidUtil.getFilledBucket(new FluidStack(vaporOfLevity, 1000)); + } } diff --git a/src/main/java/me/jacky1356400/exchangers/integration/MekanismIntegration.java b/src/main/java/me/jacky1356400/exchangers/integration/MekanismIntegration.java index 013b8a3..841a1a0 100644 --- a/src/main/java/me/jacky1356400/exchangers/integration/MekanismIntegration.java +++ b/src/main/java/me/jacky1356400/exchangers/integration/MekanismIntegration.java @@ -7,39 +7,38 @@ public class MekanismIntegration { - public static ItemStack circuitBasic; - public static ItemStack circuitAdvanced; - public static ItemStack circuitElite; - public static ItemStack circuitUltimate; - public static ItemStack teleportationCore; - public static ItemStack energyTablet; - public static ItemStack portableTeleporter; - - public static void init() { - Exchangers.logger.info("Fetching items for Mekanism integration..."); - - Item circuitsItem = Item.REGISTRY.getObject(new ResourceLocation("mekanism", "ControlCircuit")); - if (circuitsItem != null) { - circuitBasic = new ItemStack(circuitsItem, 1, 0); - circuitAdvanced = new ItemStack(circuitsItem, 1, 1); - circuitElite = new ItemStack(circuitsItem, 1, 2); - circuitUltimate = new ItemStack(circuitsItem, 1, 3); - } - - Item energyTabletItem = Item.REGISTRY.getObject(new ResourceLocation("mekanism", "EnergyTablet")); - if (energyTabletItem != null) { - energyTablet = new ItemStack(energyTabletItem, 1, 0); - } - - Item teleportationCoreItem = Item.REGISTRY.getObject(new ResourceLocation("mekanism", "TeleportationCore")); - if (teleportationCoreItem != null) { - teleportationCore = new ItemStack(teleportationCoreItem, 1, 0); - } - - Item portableTeleporterItem = Item.REGISTRY.getObject(new ResourceLocation("mekanism", "PortableTeleporter")); - if (portableTeleporterItem != null) { - portableTeleporter = new ItemStack(portableTeleporterItem, 1, 0); - } - } - + public static ItemStack circuitBasic; + public static ItemStack circuitAdvanced; + public static ItemStack circuitElite; + public static ItemStack circuitUltimate; + public static ItemStack teleportationCore; + public static ItemStack energyTablet; + public static ItemStack portableTeleporter; + + public static void init() { + Exchangers.logger.info("Fetching items for Mekanism integration..."); + + Item circuitsItem = Item.REGISTRY.getObject(new ResourceLocation("mekanism", "controlcircuit")); + if (circuitsItem != null) { + circuitBasic = new ItemStack(circuitsItem, 1, 0); + circuitAdvanced = new ItemStack(circuitsItem, 1, 1); + circuitElite = new ItemStack(circuitsItem, 1, 2); + circuitUltimate = new ItemStack(circuitsItem, 1, 3); + } + + Item energyTabletItem = Item.REGISTRY.getObject(new ResourceLocation("mekanism", "energytablet")); + if (energyTabletItem != null) { + energyTablet = new ItemStack(energyTabletItem, 1, 0); + } + + Item teleportationCoreItem = Item.REGISTRY.getObject(new ResourceLocation("mekanism", "teleportationcore")); + if (teleportationCoreItem != null) { + teleportationCore = new ItemStack(teleportationCoreItem, 1, 0); + } + + Item portableTeleporterItem = Item.REGISTRY.getObject(new ResourceLocation("mekanism", "portableteleporter")); + if (portableTeleporterItem != null) { + portableTeleporter = new ItemStack(portableTeleporterItem, 1, 0); + } + } } diff --git a/src/main/java/me/jacky1356400/exchangers/integration/ThermalExpansionIntegration.java b/src/main/java/me/jacky1356400/exchangers/integration/ThermalExpansionIntegration.java index 06a6ea7..09da404 100644 --- a/src/main/java/me/jacky1356400/exchangers/integration/ThermalExpansionIntegration.java +++ b/src/main/java/me/jacky1356400/exchangers/integration/ThermalExpansionIntegration.java @@ -11,46 +11,46 @@ public class ThermalExpansionIntegration { - public static ItemStack fluxCapacitorBasic; - public static ItemStack fluxCapacitorHardened; - public static ItemStack fluxCapacitorReinforced; - public static ItemStack fluxCapacitorSignalum; - public static ItemStack fluxCapacitorResonant; - public static ItemStack redstoneServo; - public static ItemStack redstoneReceptionCoil; - public static ItemStack redstoneTransmissionCoil; - public static ItemStack redstoneConductanceCoil; - public static ItemStack bucketResonantEnder; - public static ItemStack bucketEnergizedGlowstone; - public static ItemStack bucketGelidCryotheum; - - public static void init() { - Exchangers.logger.info("Fetching items for Thermal Expansion integration..."); - - Item fluxCapacitorItem = Item.REGISTRY.getObject(new ResourceLocation("thermalexpansion", "capacitor")); - if (fluxCapacitorItem != null) { - fluxCapacitorBasic = new ItemStack(fluxCapacitorItem, 1, 0); - fluxCapacitorHardened = new ItemStack(fluxCapacitorItem, 1, 1); - fluxCapacitorReinforced = new ItemStack(fluxCapacitorItem, 1, 2); - fluxCapacitorSignalum = new ItemStack(fluxCapacitorItem, 1, 3); - fluxCapacitorResonant = new ItemStack(fluxCapacitorItem, 1, 4); - } - - Item teMaterialsItem = Item.REGISTRY.getObject(new ResourceLocation("thermalfoundation", "material")); - if (teMaterialsItem != null) { - redstoneServo = new ItemStack(teMaterialsItem, 1, 512); - redstoneReceptionCoil = new ItemStack(teMaterialsItem, 1, 513); - redstoneTransmissionCoil = new ItemStack(teMaterialsItem, 1, 514); - redstoneConductanceCoil = new ItemStack(teMaterialsItem, 1, 515); - } - - Fluid ender = FluidRegistry.getFluid("ender"); - bucketResonantEnder = FluidUtil.getFilledBucket(new FluidStack(ender, 1000)); - Fluid glowstone = FluidRegistry.getFluid("glowstone"); - bucketEnergizedGlowstone = FluidUtil.getFilledBucket(new FluidStack(glowstone, 1000)); - Fluid cryotheum = FluidRegistry.getFluid("cryotheum"); - bucketGelidCryotheum = FluidUtil.getFilledBucket(new FluidStack(cryotheum, 1000)); - - } + public static ItemStack fluxCapacitorBasic; + public static ItemStack fluxCapacitorHardened; + public static ItemStack fluxCapacitorReinforced; + public static ItemStack fluxCapacitorSignalum; + public static ItemStack fluxCapacitorResonant; + public static ItemStack redstoneServo; + public static ItemStack redstoneReceptionCoil; + public static ItemStack redstoneTransmissionCoil; + public static ItemStack redstoneConductanceCoil; + public static ItemStack bucketResonantEnder; + public static ItemStack bucketEnergizedGlowstone; + public static ItemStack bucketGelidCryotheum; + + public static void init() { + Exchangers.logger.info("Fetching items for Thermal Expansion integration..."); + + Item fluxCapacitorItem = Item.REGISTRY.getObject(new ResourceLocation("thermalexpansion", "capacitor")); + if (fluxCapacitorItem != null) { + fluxCapacitorBasic = new ItemStack(fluxCapacitorItem, 1, 0); + fluxCapacitorHardened = new ItemStack(fluxCapacitorItem, 1, 1); + fluxCapacitorReinforced = new ItemStack(fluxCapacitorItem, 1, 2); + fluxCapacitorSignalum = new ItemStack(fluxCapacitorItem, 1, 3); + fluxCapacitorResonant = new ItemStack(fluxCapacitorItem, 1, 4); + } + + Item teMaterialsItem = Item.REGISTRY.getObject(new ResourceLocation("thermalfoundation", "material")); + if (teMaterialsItem != null) { + redstoneServo = new ItemStack(teMaterialsItem, 1, 512); + redstoneReceptionCoil = new ItemStack(teMaterialsItem, 1, 513); + redstoneTransmissionCoil = new ItemStack(teMaterialsItem, 1, 514); + redstoneConductanceCoil = new ItemStack(teMaterialsItem, 1, 515); + } + + Fluid ender = FluidRegistry.getFluid("ender"); + bucketResonantEnder = FluidUtil.getFilledBucket(new FluidStack(ender, 1000)); + Fluid glowstone = FluidRegistry.getFluid("glowstone"); + bucketEnergizedGlowstone = FluidUtil.getFilledBucket(new FluidStack(glowstone, 1000)); + Fluid cryotheum = FluidRegistry.getFluid("cryotheum"); + bucketGelidCryotheum = FluidUtil.getFilledBucket(new FluidStack(cryotheum, 1000)); + + } } diff --git a/src/main/java/me/jacky1356400/exchangers/item/ItemBasic.java b/src/main/java/me/jacky1356400/exchangers/item/ItemBasic.java index 67dc191..7b4f561 100644 --- a/src/main/java/me/jacky1356400/exchangers/item/ItemBasic.java +++ b/src/main/java/me/jacky1356400/exchangers/item/ItemBasic.java @@ -6,11 +6,11 @@ public class ItemBasic extends Item implements IHasModel { - public ItemBasic(String name) { - setRegistryName(Data.MODID, name); - setUnlocalizedName(Data.MODID + "." + name); - setCreativeTab(Data.TAB); - Data.ITEMS.add(this); - } + public ItemBasic(String name) { + setRegistryName(Data.MODID, name); + setUnlocalizedName(Data.MODID + "." + name); + setCreativeTab(Data.TAB); + Data.ITEMS.add(this); + } } diff --git a/src/main/java/me/jacky1356400/exchangers/item/ItemExchanger.java b/src/main/java/me/jacky1356400/exchangers/item/ItemExchanger.java index e6a70c2..4331cbc 100644 --- a/src/main/java/me/jacky1356400/exchangers/item/ItemExchanger.java +++ b/src/main/java/me/jacky1356400/exchangers/item/ItemExchanger.java @@ -15,44 +15,50 @@ public class ItemExchanger extends ExchangerHandler implements IHasModel { - private final Tier t; - - public ItemExchanger(String name, boolean noRepair, Tier tier, int maxDmg) { - setRegistryName(Data.MODID, name); - setUnlocalizedName(Data.MODID + "." + name); - setCreativeTab(Data.TAB); - if (noRepair) - setNoRepair(); - setMaxStackSize(1); - t = tier; - if (maxDmg > 0) - setMaxDamage(maxDmg); - Data.ITEMS.add(this); - } - - public ItemExchanger(String name, Tier tier, int maxDmg) { - this(name, false, tier, maxDmg); - } - - public boolean showDurabilityBar(ItemStack stack) { - return stack.isItemDamaged(); - } - - @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag bool) { - super.addInformation(stack, world, tooltip, bool); - if (!isPowered()){ - tooltip.add(StringHelper.formatNumber(stack.getMaxDamage() - stack.getItemDamage()) + " / " + StringHelper.formatNumber(stack.getMaxDamage()) + " " + localize("tooltip.durability")); - tooltip.add(getTier().getFormattedText()); - } - } - - public Tier getTier() { - return t; - } - - public boolean isPowered() { - return false; - } + private final Tier t; + + public ItemExchanger(String name, boolean noRepair, Tier tier, int maxDmg) { + setRegistryName(Data.MODID, name); + setUnlocalizedName(Data.MODID + "." + name); + setCreativeTab(Data.TAB); + if (noRepair) + setNoRepair(); + setMaxStackSize(1); + t = tier; + if (maxDmg > 0) + setMaxDamage(maxDmg); + Data.ITEMS.add(this); + } + + public ItemExchanger(String name, Tier tier, int maxDmg) { + this(name, false, tier, maxDmg); + } + + public boolean showDurabilityBar(ItemStack stack) { + return stack.isItemDamaged(); + } + + @Override + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag bool) { + super.addInformation(stack, world, tooltip, bool); + if (!isPowered()) { + tooltip.add(StringHelper.formatNumber(stack.getMaxDamage() - stack.getItemDamage()) + " / " + StringHelper.formatNumber(stack.getMaxDamage()) + " " + localize("tooltip.durability")); + tooltip.add(getTier().getFormattedText()); + } + } + + public Tier getTier() { + return t; + } + + @Override + public boolean isPowered() { + return false; + } + + @Override + public boolean isCreative() { + return this.getTier() == Tier.CREATIVE; + } } diff --git a/src/main/java/me/jacky1356400/exchangers/item/ItemPoweredExchanger.java b/src/main/java/me/jacky1356400/exchangers/item/ItemPoweredExchanger.java index c3aa77a..d4aaad0 100644 --- a/src/main/java/me/jacky1356400/exchangers/item/ItemPoweredExchanger.java +++ b/src/main/java/me/jacky1356400/exchangers/item/ItemPoweredExchanger.java @@ -1,7 +1,5 @@ package me.jacky1356400.exchangers.item; -import java.util.List; - import cofh.redstoneflux.api.IEnergyContainerItem; import cofh.redstoneflux.util.EnergyContainerItemWrapper; import me.jacky1356400.exchangers.helper.EnergyHelper; @@ -16,87 +14,94 @@ import net.minecraft.world.World; import net.minecraftforge.common.capabilities.ICapabilityProvider; +import java.util.List; + public class ItemPoweredExchanger extends ItemExchanger implements IEnergyContainerItem { private final int maxEnergy; private final int perBlockUse; public ItemPoweredExchanger(String name, Tier tier, int maxStorage, int perBlock) { - super(name, true, tier, 0); - maxEnergy = maxStorage; - perBlockUse = perBlock; + super(name, true, tier, 0); + maxEnergy = maxStorage; + perBlockUse = perBlock; } @Override public int receiveEnergy(ItemStack container, int energy, boolean simulate) { - return NBTHelper.receiveEnergy(container, energy, getMaxEnergyStored(container), simulate); + return NBTHelper.receiveEnergy(container, energy, getMaxEnergyStored(container), simulate); } @Override public int extractEnergy(ItemStack container, int energy, boolean simulate) { - return NBTHelper.extractEnergy(container, energy, simulate); + return NBTHelper.extractEnergy(container, energy, simulate); } @Override public int getEnergyStored(ItemStack container) { - return NBTHelper.getEnergyStored(container); + return NBTHelper.getEnergyStored(container); } @Override public int getMaxEnergyStored(ItemStack container) { - return maxEnergy; + return maxEnergy; } public int getPerBlockCost() { - return perBlockUse; + return perBlockUse; } @Override public boolean showDurabilityBar(ItemStack stack) { - return true; + return true; } @Override public double getDurabilityForDisplay(ItemStack stack) { - if (stack.getTagCompound() == null) { - EnergyHelper.setDefaultEnergyTag(stack, 0); - } - return 1D - ((double) stack.getTagCompound().getInteger("Energy") / (double) getMaxEnergyStored(stack)); + if (stack.getTagCompound() == null) { + EnergyHelper.setDefaultEnergyTag(stack, 0); + } + return 1D - ((double) stack.getTagCompound().getInteger("Energy") / (double) getMaxEnergyStored(stack)); } @Override public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { - super.addInformation(stack, world, tooltip, flag); - tooltip.add(StringHelper.formatNumber(getEnergyStored(stack)) + " / " - + StringHelper.formatNumber(getMaxEnergyStored(stack)) + " RF"); - tooltip.add(getTier().getFormattedText()); + super.addInformation(stack, world, tooltip, flag); + tooltip.add(StringHelper.formatNumber(getEnergyStored(stack)) + " / " + + StringHelper.formatNumber(getMaxEnergyStored(stack)) + " RF"); + tooltip.add(getTier().getFormattedText()); } @Override public boolean isDamaged(ItemStack stack) { - return true; + return true; } @Override public boolean isPowered() { - return true; + return true; + } + + @Override + public boolean isCreative() { + return false; } @Override public void getSubItems(CreativeTabs tab, NonNullList list) { - if (this.isInCreativeTab(tab)) { - ItemStack empty = new ItemStack(this); - list.add(empty); - ItemStack full = new ItemStack(this); - EnergyHelper.setDefaultEnergyTag(full, maxEnergy); - list.add(full); - } + if (this.isInCreativeTab(tab)) { + ItemStack empty = new ItemStack(this); + list.add(empty); + ItemStack full = new ItemStack(this); + EnergyHelper.setDefaultEnergyTag(full, maxEnergy); + list.add(full); + } } /* CAPABILITIES */ @Override public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { - return new EnergyContainerItemWrapper(stack, this); + return new EnergyContainerItemWrapper(stack, this); } } diff --git a/src/main/java/me/jacky1356400/exchangers/item/special/ItemTuberousExchanger.java b/src/main/java/me/jacky1356400/exchangers/item/special/ItemTuberousExchanger.java index ed11a54..4a1c924 100644 --- a/src/main/java/me/jacky1356400/exchangers/item/special/ItemTuberousExchanger.java +++ b/src/main/java/me/jacky1356400/exchangers/item/special/ItemTuberousExchanger.java @@ -16,38 +16,38 @@ public class ItemTuberousExchanger extends ItemExchanger { - public ItemTuberousExchanger() { - super("expotato", Tier.ZERO, 1); - } - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag bool) { - super.addInformation(stack, world, tooltip, bool); - if (StringHelper.isShiftKeyDown()) { - tooltip.add(StringHelper.localize("tooltip.tuberousExchanger.warning")); - } - } - - @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, - float hitX, float hitY, float hitZ) { - ItemStack stack = player.getHeldItem(hand); - return killPlayer(player, stack) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; - } - - @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - ItemStack stack = player.getHeldItem(hand); - boolean result = killPlayer(player, stack); - return ActionResult.newResult(result ? EnumActionResult.SUCCESS : EnumActionResult.FAIL, stack); - } - - private static boolean killPlayer(EntityPlayer player, ItemStack stack) { - stack.setCount(0); - player.attackEntityFrom(new EntityDamageSource("exchangerpotato", player), 100000.0F); - player.world.createExplosion(player, player.posX, player.posY, player.posZ, 1.0F, false); - return true; - } + public ItemTuberousExchanger() { + super("expotato", Tier.ZERO, 1); + } + + private static boolean killPlayer(EntityPlayer player, ItemStack stack) { + stack.setCount(0); + player.attackEntityFrom(new EntityDamageSource("exchangerpotato", player), 100000.0F); + player.world.createExplosion(player, player.posX, player.posY, player.posZ, 1.0F, false); + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag bool) { + super.addInformation(stack, world, tooltip, bool); + if (StringHelper.isShiftKeyDown()) { + tooltip.add(StringHelper.localize("tooltip.tuberousExchanger.warning")); + } + } + + @Override + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, + float hitX, float hitY, float hitZ) { + ItemStack stack = player.getHeldItem(hand); + return killPlayer(player, stack) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; + } + + @Override + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); + boolean result = killPlayer(player, stack); + return ActionResult.newResult(result ? EnumActionResult.SUCCESS : EnumActionResult.FAIL, stack); + } } diff --git a/src/main/java/me/jacky1356400/exchangers/proxy/ClientProxy.java b/src/main/java/me/jacky1356400/exchangers/proxy/ClientProxy.java index 1059a9d..b004c02 100644 --- a/src/main/java/me/jacky1356400/exchangers/proxy/ClientProxy.java +++ b/src/main/java/me/jacky1356400/exchangers/proxy/ClientProxy.java @@ -16,30 +16,30 @@ public class ClientProxy extends CommonProxy { - @Override - public void preInit(FMLPreInitializationEvent e) { - super.preInit(e); - MinecraftForge.EVENT_BUS.register(this); - } + @Override + public void preInit(FMLPreInitializationEvent e) { + super.preInit(e); + MinecraftForge.EVENT_BUS.register(this); + } - @SubscribeEvent - public void onModelRegistry(ModelRegistryEvent e) { - for (Item item : Data.ITEMS) - if (item instanceof IHasModel) - ((IHasModel) item).initModel(e); - } + @SubscribeEvent + public void onModelRegistry(ModelRegistryEvent e) { + for (Item item : Data.ITEMS) + if (item instanceof IHasModel) + ((IHasModel) item).initModel(e); + } - @Override - public void init(FMLInitializationEvent e) { - super.init(e); - MinecraftForge.EVENT_BUS.register(new KeyBindingsHandler()); - Keys.init(); - } + @Override + public void init(FMLInitializationEvent e) { + super.init(e); + MinecraftForge.EVENT_BUS.register(new KeyBindingsHandler()); + Keys.init(); + } - @Override - public void postInit(FMLPostInitializationEvent e) { - super.postInit(e); - MinecraftForge.EVENT_BUS.register(new GUIHandler((Minecraft.getMinecraft()))); - } + @Override + public void postInit(FMLPostInitializationEvent e) { + super.postInit(e); + MinecraftForge.EVENT_BUS.register(new GUIHandler((Minecraft.getMinecraft()))); + } } \ No newline at end of file diff --git a/src/main/java/me/jacky1356400/exchangers/proxy/CommonProxy.java b/src/main/java/me/jacky1356400/exchangers/proxy/CommonProxy.java index 3ce6da8..3899824 100644 --- a/src/main/java/me/jacky1356400/exchangers/proxy/CommonProxy.java +++ b/src/main/java/me/jacky1356400/exchangers/proxy/CommonProxy.java @@ -1,14 +1,9 @@ package me.jacky1356400.exchangers.proxy; -import java.io.File; - import me.jacky1356400.exchangers.Config; import me.jacky1356400.exchangers.handler.RenderOverlayHandler; -import me.jacky1356400.exchangers.handler.WorldEventHandler; import me.jacky1356400.exchangers.handler.network.PacketHandler; -import me.jacky1356400.exchangers.helper.DirectionHelper; import me.jacky1356400.exchangers.init.ModRegistry; -import me.jacky1356400.exchangers.item.ItemExchanger; import me.jacky1356400.exchangers.util.Data; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; @@ -16,26 +11,25 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import java.io.File; + public class CommonProxy { public static Configuration config; public void preInit(FMLPreInitializationEvent e) { - File configDir = e.getModConfigurationDirectory(); - config = new Configuration(new File(configDir.getPath(), "exchangers.cfg")); - Config.readConfig(); - MinecraftForge.EVENT_BUS.register(new ModRegistry()); - PacketHandler.registerMessages(Data.MODID); + File configDir = e.getModConfigurationDirectory(); + config = new Configuration(new File(configDir.getPath(), "exchangers.cfg")); + Config.readConfig(); + MinecraftForge.EVENT_BUS.register(new ModRegistry()); + PacketHandler.registerMessages(Data.MODID); } public void init(FMLInitializationEvent e) { - MinecraftForge.EVENT_BUS.register(new RenderOverlayHandler()); - MinecraftForge.EVENT_BUS.register(new WorldEventHandler()); + MinecraftForge.EVENT_BUS.register(new RenderOverlayHandler()); } public void postInit(FMLPostInitializationEvent e) { - ItemExchanger.initSpecialBlockLists(); - DirectionHelper.initFacings(); } } diff --git a/src/main/java/me/jacky1356400/exchangers/proxy/ServerProxy.java b/src/main/java/me/jacky1356400/exchangers/proxy/ServerProxy.java index a57884a..45fbd78 100644 --- a/src/main/java/me/jacky1356400/exchangers/proxy/ServerProxy.java +++ b/src/main/java/me/jacky1356400/exchangers/proxy/ServerProxy.java @@ -5,18 +5,18 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public class ServerProxy extends CommonProxy { - @Override - public void preInit(FMLPreInitializationEvent e) { - super.preInit(e); - } + @Override + public void preInit(FMLPreInitializationEvent e) { + super.preInit(e); + } - @Override - public void init(FMLInitializationEvent e) { - super.init(e); - } + @Override + public void init(FMLInitializationEvent e) { + super.init(e); + } - @Override - public void postInit(FMLPostInitializationEvent e) { - super.postInit(e); - } + @Override + public void postInit(FMLPostInitializationEvent e) { + super.postInit(e); + } } \ No newline at end of file diff --git a/src/main/java/me/jacky1356400/exchangers/util/Data.java b/src/main/java/me/jacky1356400/exchangers/util/Data.java index b877637..b7ac468 100644 --- a/src/main/java/me/jacky1356400/exchangers/util/Data.java +++ b/src/main/java/me/jacky1356400/exchangers/util/Data.java @@ -12,20 +12,20 @@ public class Data { - public static final List ITEMS = new ArrayList(); - public static final List BLOCKS = new ArrayList(); - public static final List RECIPES = new ArrayList(); - public static final String EIO = "enderio"; - public static final String MEK = "mekanism"; - public static final String THERMAL = "thermalexpansion"; - public static final String VERSION = "1.12-2.2"; - public static final String MODID = "exchangers"; - public static final String MODNAME = "Exchangers"; - public static final CreativeTabs TAB = new CreativeTabs(MODID) { - @Override - public ItemStack getTabIconItem() { - return new ItemStack(ModRegistry.OBSIDIAN); - } - }; + public static final List ITEMS = new ArrayList(); + public static final List BLOCKS = new ArrayList(); + public static final List RECIPES = new ArrayList(); + public static final String EIO = "enderio"; + public static final String MEK = "mekanism"; + public static final String THERMAL = "thermalexpansion"; + public static final String VERSION = "1.12-2.3"; + public static final String MODID = "exchangers"; + public static final String MODNAME = "Exchangers"; + public static final CreativeTabs TAB = new CreativeTabs(MODID) { + @Override + public ItemStack getTabIconItem() { + return new ItemStack(ModRegistry.OBSIDIAN); + } + }; } diff --git a/src/main/java/me/jacky1356400/exchangers/util/Exchange.java b/src/main/java/me/jacky1356400/exchangers/util/Exchange.java deleted file mode 100644 index f5f8203..0000000 --- a/src/main/java/me/jacky1356400/exchangers/util/Exchange.java +++ /dev/null @@ -1,16 +0,0 @@ -package me.jacky1356400.exchangers.util; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.math.BlockPos; - -public class Exchange { - - public BlockPos pos; - public IBlockState state; - - public Exchange(BlockPos pos, IBlockState state) { - this.pos = pos; - this.state = state; - } - -} \ No newline at end of file diff --git a/src/main/java/me/jacky1356400/exchangers/util/IHasModel.java b/src/main/java/me/jacky1356400/exchangers/util/IHasModel.java index 8f76705..9d19972 100644 --- a/src/main/java/me/jacky1356400/exchangers/util/IHasModel.java +++ b/src/main/java/me/jacky1356400/exchangers/util/IHasModel.java @@ -9,15 +9,15 @@ public interface IHasModel { - default public void initModel(ModelRegistryEvent e) { - if (this instanceof Item) - ModelLoader.setCustomModelResourceLocation((Item) this, 0, - new ModelResourceLocation(((IForgeRegistryEntry) this).getRegistryName(), "inventory")); - else if (this instanceof Block) - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock((Block) this), 0, - new ModelResourceLocation(((IForgeRegistryEntry) this).getRegistryName(), "inventory")); - else - throw new IllegalArgumentException("wat are u doin"); - } + default public void initModel(ModelRegistryEvent e) { + if (this instanceof Item) + ModelLoader.setCustomModelResourceLocation((Item) this, 0, + new ModelResourceLocation(((IForgeRegistryEntry) this).getRegistryName(), "inventory")); + else if (this instanceof Block) + ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock((Block) this), 0, + new ModelResourceLocation(((IForgeRegistryEntry) this).getRegistryName(), "inventory")); + else + throw new IllegalArgumentException("wat are u doin"); + } } diff --git a/src/main/java/me/jacky1356400/exchangers/util/StackUtil.java b/src/main/java/me/jacky1356400/exchangers/util/StackUtil.java new file mode 100644 index 0000000..29efdf8 --- /dev/null +++ b/src/main/java/me/jacky1356400/exchangers/util/StackUtil.java @@ -0,0 +1,45 @@ +package me.jacky1356400.exchangers.util; + +import net.minecraft.item.ItemStack; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class StackUtil { + + @Nullable + public static ItemStack incStackSize(@Nonnull ItemStack stack, int amount) { + stack.setCount(stack.getCount() + amount); + if (stack.getCount() <= 0) { + return ItemStack.EMPTY; + } + return stack; + } + + public static int getStackSize(@Nullable ItemStack stack) { + if (stack == ItemStack.EMPTY) { + return 0; + } + return stack.getCount(); + } + + @Nullable + public static ItemStack getEmptyStack(@Nullable ItemStack stack) { + return ItemStack.EMPTY; + } + + public static boolean isValid(@Nullable ItemStack stack) { + if (stack == ItemStack.EMPTY) { + return false; + } + return stack.getCount() > 0; + } + + public static boolean isEmpty(@Nullable ItemStack stack) { + if (stack == stack.EMPTY) { + return true; + } + return stack.getCount() <= 0; + } + +} diff --git a/src/main/java/me/jacky1356400/exchangers/util/Tier.java b/src/main/java/me/jacky1356400/exchangers/util/Tier.java index b9cf0ed..a771677 100644 --- a/src/main/java/me/jacky1356400/exchangers/util/Tier.java +++ b/src/main/java/me/jacky1356400/exchangers/util/Tier.java @@ -6,40 +6,48 @@ import net.minecraftforge.fml.relauncher.SideOnly; public enum Tier { - ZERO(-1), - ONE(ExchangerHandler.MODE_1X1), - TWO(ExchangerHandler.MODE_3X3), - THREE(ExchangerHandler.MODE_5X5), - FOUR(ExchangerHandler.MODE_7X7), - FIVE(ExchangerHandler.MODE_9X9), - SIX(ExchangerHandler.MODE_11X11), - SEVEN(ExchangerHandler.MODE_15X15), - TE_ONE(ExchangerHandler.MODE_3X3), - TE_TWO(ExchangerHandler.MODE_7X7), - TE_THREE(ExchangerHandler.MODE_11X11), - TE_FOUR(ExchangerHandler.MODE_13X13), - TE_FIVE(ExchangerHandler.MODE_15X15), - CREATIVE(ExchangerHandler.MODE_25X25); + ZERO(-1), + ONE(ExchangerHandler.MODE_1X1), + TWO(ExchangerHandler.MODE_3X3), + THREE(ExchangerHandler.MODE_5X5), + FOUR(ExchangerHandler.MODE_7X7), + FIVE(ExchangerHandler.MODE_9X9), + SIX(ExchangerHandler.MODE_11X11), + SEVEN(ExchangerHandler.MODE_15X15), + TE_ONE(ExchangerHandler.MODE_3X3), + TE_TWO(ExchangerHandler.MODE_7X7), + TE_THREE(ExchangerHandler.MODE_11X11), + TE_FOUR(ExchangerHandler.MODE_13X13), + TE_FIVE(ExchangerHandler.MODE_15X15), + MEK_ONE(ExchangerHandler.MODE_7X7), + MEK_TWO(ExchangerHandler.MODE_11X11), + MEK_THREE(ExchangerHandler.MODE_13X13), + MEK_FOUR(ExchangerHandler.MODE_15X15), + CREATIVE(ExchangerHandler.MODE_25X25); - final int size; + final int size; - Tier(int maxSize) { - size = maxSize; - } + Tier(int maxSize) { + size = maxSize; + } - @SideOnly(Side.CLIENT) - public String getFormattedText() { - int k = this.ordinal(); - if(this == Tier.TE_ONE) k = 1; - if(this == Tier.TE_TWO) k = 2; - if(this == Tier.TE_THREE) k = 3; - if(this == Tier.TE_FOUR) k = 4; - if(this == Tier.TE_FIVE) k = 5; - if(this == Tier.CREATIVE) k = 9001; - return I18n.format(Data.MODID + ".tooltip.tier", k); - } + @SideOnly(Side.CLIENT) + public String getFormattedText() { + int k = this.ordinal(); + if (this == Tier.TE_ONE) k = 1; + if (this == Tier.TE_TWO) k = 2; + if (this == Tier.TE_THREE) k = 3; + if (this == Tier.TE_FOUR) k = 4; + if (this == Tier.TE_FIVE) k = 5; + if (this == Tier.MEK_ONE) k = 1; + if (this == Tier.MEK_TWO) k = 2; + if (this == Tier.MEK_THREE) k = 3; + if (this == Tier.MEK_FOUR) k = 4; + if (this == Tier.CREATIVE) k = 9001; + return I18n.format(Data.MODID + ".tooltip.tier", k); + } - public int getMaxSize() { - return size; - } + public int getMaxSize() { + return size; + } } diff --git a/src/main/resources/assets/exchangers/lang/en_US.lang b/src/main/resources/assets/exchangers/lang/en_US.lang index 4c7d044..c022701 100644 --- a/src/main/resources/assets/exchangers/lang/en_US.lang +++ b/src/main/resources/assets/exchangers/lang/en_US.lang @@ -20,11 +20,13 @@ exchangers.tooltip.shift2=Right click on a block to exchange. exchangers.tooltip.shift3=Use the mode key to switch modes. exchangers.tooltip.tuberousExchanger.warning=§c§oClever! But not exchangeable. exchangers.tooltip.selectedblock=§2Selected Block: -exchangers.tooltip.selectedmode=§2Selected Mode: +exchangers.tooltip.currentrange=§2Current Range: +exchangers.tooltip.maxrange=§2Maximum Range: exchangers.tooltip.noselectedblock=§4No Selected Block #Error Messages exchangers.error.invalidblock=§cError: Invalid block! +exchangers.error.outofblock=§cError: Out of block! exchangers.error.nopower=§cError: Out of power! #Crafting Components diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index df4f753..0bf7e19 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -3,7 +3,7 @@ "modid": "exchangers", "name": "Exchangers", "description": "Block Exchangers.", - "version": "1.12-2.2", + "version": "1.12-2.3", "mcversion": "1.12", "url": "https://github.com/Jacky1356400/Exchangers", "updateUrl": "",