From a6a3bfa6f313adba5afe6eb4a0da049a8d641cfc Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Fri, 5 Jun 2015 01:53:14 +0100 Subject: Stuff! --- .classpath | 81 +- .project | 39 +- build.gradle | 282 +++--- changelog.txt | 28 +- src/.classpath | 9 + src/.gitignore | 1 + src/.project | 17 + .../darkknight/jewelrycraft/JewelrycraftMod.java | 263 +++--- .../java/darkknight/jewelrycraft/api/Curse.java | 365 ++++---- .../jewelrycraft/api/ModifierEffects.java | 214 +++-- .../jewelrycraft/block/BlockMoltenMetal.java | 545 ++++++------ .../jewelrycraft/block/BlockSmelter.java | 531 ++++++----- .../darkknight/jewelrycraft/curses/CurseBlind.java | 77 +- .../jewelrycraft/curses/CurseInfamy.java | 158 ++-- .../jewelrycraft/curses/CurseMidasTouch.java | 215 ++--- .../jewelrycraft/curses/CurseRabbitsPaw.java | 146 +-- .../jewelrycraft/effects/EffectBlazePowder.java | 167 ++-- .../jewelrycraft/effects/EffectEnderEye.java | 178 ++-- .../jewelrycraft/effects/EffectEnderPearl.java | 187 ++-- .../jewelrycraft/effects/EffectFeather.java | 193 ++-- .../jewelrycraft/effects/EffectObsidian.java | 201 +++-- .../jewelrycraft/entities/EntityHalfHeart.java | 73 +- .../jewelrycraft/entities/EntityList.java | 38 +- .../entities/renders/RenderHelper.java | 45 +- .../jewelrycraft/events/EntityEventHandler.java | 975 +++++++++++---------- .../jewelrycraft/events/PlayerRenderHandler.java | 435 ++++----- .../jewelrycraft/item/ItemBaseJewelry.java | 554 ++++++------ .../jewelrycraft/item/ItemStructureGen.java | 84 +- .../jewelrycraft/item/render/BraceletRender.java | 66 +- .../jewelrycraft/item/render/MaskRender.java | 64 +- .../jewelrycraft/item/render/RingRender.java | 56 +- .../darkknight/jewelrycraft/proxy/ClientProxy.java | 240 ++--- .../jewelrycraft/random/WeightedRandomCurse.java | 23 + .../jewelrycraft/random/WeightedRandomItem.java | 67 ++ .../darkknight/jewelrycraft/thirdparty/Alpaca.java | 27 + .../darkknight/jewelrycraft/thirdparty/EE3.java | 84 +- .../darkknight/jewelrycraft/thirdparty/ModIds.java | 55 +- .../jewelrycraft/thirdparty/ThirdPartyManager.java | 287 +++--- .../jewelrycraft/util/JewelrycraftUtil.java | 495 ++++++----- .../darkknight/jewelrycraft/util/Variables.java | 42 +- .../jewelrycraft/worldGen/ChestGeneration.java | 103 +++ .../jewelrycraft/worldGen/Generation.java | 199 +++-- .../jewelrycraft/worldGen/WeightedRandomItem.java | 67 -- .../jewelrycraft/worldGen/WorldGenStructure1.java | 121 ++- .../jewelrycraft/worldGen/WorldGenStructure10.java | 29 + .../jewelrycraft/worldGen/WorldGenStructure11.java | 29 + .../jewelrycraft/worldGen/WorldGenStructure2.java | 70 ++ .../jewelrycraft/worldGen/WorldGenStructure3.java | 68 ++ .../jewelrycraft/worldGen/WorldGenStructure4.java | 63 ++ .../jewelrycraft/worldGen/WorldGenStructure5.java | 99 +++ .../jewelrycraft/worldGen/WorldGenStructure6.java | 29 + .../jewelrycraft/worldGen/WorldGenStructure7.java | 29 + .../jewelrycraft/worldGen/WorldGenStructure8.java | 29 + .../jewelrycraft/worldGen/WorldGenStructure9.java | 29 + .../jewelrycraft/worldGen/village/JCTrades.java | 250 +++--- .../resources/assets/jewelrycraft2/lang/en_US.lang | 302 +++---- 56 files changed, 4989 insertions(+), 4134 deletions(-) create mode 100644 src/.classpath create mode 100644 src/.gitignore create mode 100644 src/.project create mode 100644 src/main/java/darkknight/jewelrycraft/random/WeightedRandomCurse.java create mode 100644 src/main/java/darkknight/jewelrycraft/random/WeightedRandomItem.java create mode 100644 src/main/java/darkknight/jewelrycraft/thirdparty/Alpaca.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/ChestGeneration.java delete mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure10.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure11.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure7.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure8.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure9.java diff --git a/.classpath b/.classpath index 121e65f..75e7da8 100644 --- a/.classpath +++ b/.classpath @@ -1,75 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + diff --git a/.project b/.project index 2536001..a5a2957 100644 --- a/.project +++ b/.project @@ -1,22 +1,17 @@ - - - 1.7.10 - - - - org.eclipse.jdt.core.javanature - - - - org.eclipse.jdt.core.javabuilder - - - - - - .link1 - 2 - C:/Users/Sorin/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.10-10.13.3.1395-1710ls/start - - - + + + 1.7.10 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/build.gradle b/build.gradle index 835c864..ff55f17 100644 --- a/build.gradle +++ b/build.gradle @@ -1,141 +1,141 @@ -buildscript { - repositories { - mavenCentral() - maven { - name = "forge" - url = "http://files.minecraftforge.net/maven" - } - maven { - name = "sonatype" - url = "https://oss.sonatype.org/content/repositories/snapshots/" - } - } - dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' - } -} - -apply plugin: 'forge' -apply plugin: 'curseforge' - -project.ext { - massive = "1" - major = "0" - minor = "10" - mcVersion = "1.7.10" - ee3Version = "0.3.505" -} - -if (System.getenv().BUILD_NUMBER != null) { - version += "-${System.getenv().BUILD_NUMBER}" -} else { - version += "-err" -} - -version = "${project.ext.massive}.${project.ext.major}.${project.minor}" -group= "darkknight.jewelrycraft2" -archivesBaseName = "[${project.ext.mcVersion}] Jewelrycraft2" - -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 - -repositories { - maven { - name 'forge' - url 'http://files.minecraftforge.net/maven/' - } - maven { - name 'Mobius' - url "http://mobiusstrip.eu/maven" - } - maven { - name 'ChickenBones' - url "http://chickenbones.net/maven/" - } -} - -dependencies { - compile "com.pahimar.ee3:EquivalentExchange3:${project.mcVersion}-${project.ee3Version}:dev" -} - -minecraft { - version = "1.7.10-10.13.3.1395-1710ls" - runDir = "minecraft/assets" - - // replacing stuff in the source - replace '@MASSIVE@', project.massive - replace '@MAJOR@', project.major - replace '@MINOR@', project.minor - replace '@MC_VERSION@', version - if (System.getenv("BUILD_NUMBER") != null) { - replace '@BUILD_NUMBER@', System.getenv("BUILD_NUMBER") - } else { - replace '@BUILD_NUMBER@', 0 - } -} - -processResources{ - inputs.property "version", project.version - inputs.property "mcversion", project.minecraft.version - - from(sourceSets.main.resources.srcDirs) { - include 'mcmod.info' - - expand 'version':project.version, 'mcversion':project.minecraft.version - } - - from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' - } -} - -task ensureCurseAPI { - if (!project.hasProperty("curseForgeApiKey")){ - project.ext.curseForgeApiKey = null - } -} - -curse.dependsOn ensureCurseAPI - -curse { - apiKey = project.curseForgeApiKey - projectId = "229927" // my project url is http://minecraft.curseforge.com/mc-mods/229927-jewelrycraft-2 - changelog = new File('changelog.txt').text - releaseType = "release" - - // the default obfuscated jar is uploaded by default - // artifact = project.file("build/libs/to/upload.jar") - - // allows you to add extra compatible MC versions. The one specified in the minecraft{} block is used by default. - // addGameversion "1.7.0", "1.7.4" -} - -sourceSets { - main { - output.resourcesDir = output.classesDir - java { - srcDir 'java' - } - resources { - srcDir 'resources' - } - } -} - -jar { - classifier = 'universal' -} - -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'src' - from sourceSets.main.allSource -} - -task devJar(type: Jar) { - classifier = 'dev' - from sourceSets.main.output -} - -artifacts { - archives sourcesJar, devJar -} +buildscript { + repositories { + mavenCentral() + maven { + name = "forge" + url = "http://files.minecraftforge.net/maven" + } + maven { + name = "sonatype" + url = "https://oss.sonatype.org/content/repositories/snapshots/" + } + } + dependencies { + classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' + } +} + +apply plugin: 'forge' +apply plugin: 'curseforge' + +project.ext { + massive = "1" + major = "0" + minor = "10" + mcVersion = "1.7.10" + ee3Version = "0.3.505" +} + +if (System.getenv().BUILD_NUMBER != null) { + version += "-${System.getenv().BUILD_NUMBER}" +} else { + version += "-err" +} + +version = "${project.ext.massive}.${project.ext.major}.${project.minor}" +group= "darkknight.jewelrycraft2" +archivesBaseName = "[${project.ext.mcVersion}] Jewelrycraft2" + +sourceCompatibility = JavaVersion.VERSION_1_7 +targetCompatibility = JavaVersion.VERSION_1_7 + +repositories { + maven { + name 'forge' + url 'http://files.minecraftforge.net/maven/' + } + maven { + name 'Mobius' + url "http://mobiusstrip.eu/maven" + } + maven { + name 'ChickenBones' + url "http://chickenbones.net/maven/" + } +} + +dependencies { + compile "com.pahimar.ee3:EquivalentExchange3:${project.mcVersion}-${project.ee3Version}:dev" +} + +minecraft { + version = "1.7.10-10.13.3.1428-1.7.10" + runDir = "minecraft/assets" + + // replacing stuff in the source + replace '@MASSIVE@', project.massive + replace '@MAJOR@', project.major + replace '@MINOR@', project.minor + replace '@MC_VERSION@', version + if (System.getenv("BUILD_NUMBER") != null) { + replace '@BUILD_NUMBER@', System.getenv("BUILD_NUMBER") + } else { + replace '@BUILD_NUMBER@', 0 + } +} + +processResources{ + inputs.property "version", project.version + inputs.property "mcversion", project.minecraft.version + + from(sourceSets.main.resources.srcDirs) { + include 'mcmod.info' + + expand 'version':project.version, 'mcversion':project.minecraft.version + } + + from(sourceSets.main.resources.srcDirs) { + exclude 'mcmod.info' + } +} + +task ensureCurseAPI { + if (!project.hasProperty("curseForgeApiKey")){ + project.ext.curseForgeApiKey = null + } +} + +curse.dependsOn ensureCurseAPI + +curse { + apiKey = project.curseForgeApiKey + projectId = "229927" // my project url is http://minecraft.curseforge.com/mc-mods/229927-jewelrycraft-2 + changelog = new File('changelog.txt').text + releaseType = "release" + + // the default obfuscated jar is uploaded by default + // artifact = project.file("build/libs/to/upload.jar") + + // allows you to add extra compatible MC versions. The one specified in the minecraft{} block is used by default. + // addGameversion "1.7.0", "1.7.4" +} + +sourceSets { + main { + output.resourcesDir = output.classesDir + java { + srcDir 'java' + } + resources { + srcDir 'resources' + } + } +} + +jar { + classifier = 'universal' +} + +task sourcesJar(type: Jar, dependsOn: classes) { + classifier = 'src' + from sourceSets.main.allSource +} + +task devJar(type: Jar) { + classifier = 'dev' + from sourceSets.main.output +} + +artifacts { + archives sourcesJar, devJar +} diff --git a/changelog.txt b/changelog.txt index 327cfa2..01072c1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,2 +1,26 @@ -- Changed Crystal from craftable items to blocks that generate in the world -- Fixed NEI from overlapping the guide GUI \ No newline at end of file +Added: +- Added Crystal blocks that generate in the world +- Added a few items to generate in Dungeon chests, Blacksmith chests and Stronghold chests +- Added a total of 5 new structures that generate in the world +- The Pentagram now has an actual effect (takes 1 health from an entity that is right by the player and heals the player; if the player is at full health, an extra empty heart is added) +- The player renders in the Jewelry GUI (makes it easier for you to see how the jewelry render) +- Added different loot to chests in different places (Dungeons, Pyramids, Strongholds etc) +- Added a new 'weight' value to the Curse api + +Removed: +- Removed the Crystal item + +Changed: +- The Pentagram now renders beneath your feet when you look down and no longer does it in your inventory; it is also a lot smaller +- Changed Entity registration so it only uses 'registerModEntity' to fix potential issues +- Changed Crystal from craftable items to blocks that generate in the world +- Changed Jewelry Tab to not override TiCon tabs (sorry TiCon, your system is good, but not for me) +- Some curses can no longer acquired in hardcore (such as Rotten Heart, Midas Touch etc) which would make it impossible to work with and require a total restart of the game +- Updated the curse API so now people can specify when a curse can be activated (I believe the world is all you need :p) +- Curses now use a random weight system in order to get chooses (this allows for different curses to have a lower chance to appear than others) +- Midas Touch now has a lower chance of appearing + +Fixed: +- Fixed NEI from overlapping the guide GUI +- Fixed an issue with the Liquids tab crashing +- Fixed Jewelers having only rings as jewelry options \ No newline at end of file diff --git a/src/.classpath b/src/.classpath new file mode 100644 index 0000000..fe4c989 --- /dev/null +++ b/src/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/src/.project b/src/.project new file mode 100644 index 0000000..954353a --- /dev/null +++ b/src/.project @@ -0,0 +1,17 @@ + + + JewelryCraft + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java index 65e5c24..e97ee07 100644 --- a/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java +++ b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java @@ -1,124 +1,139 @@ -/* - * Mod made by DarkKnight during the Modjam 3 - * It's an awesome mod - * I love me! :D - */ -package darkknight.jewelrycraft; - -import java.io.File; -import java.io.IOException; -import java.util.logging.Logger; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.WeightedRandomChestContent; -import net.minecraftforge.common.ChestGenHooks; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.Mod.Instance; -import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStartingEvent; -import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; -import darkknight.jewelrycraft.block.BlockList; -import darkknight.jewelrycraft.commands.JewelrycraftCommands; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.curses.CurseList; -import darkknight.jewelrycraft.entities.EntityList; -import darkknight.jewelrycraft.events.EventList; -import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.network.PacketHandler; -import darkknight.jewelrycraft.potions.PotionList; -import darkknight.jewelrycraft.proxy.CommonProxy; -import darkknight.jewelrycraft.recipes.CraftingRecipes; -import darkknight.jewelrycraft.thirdparty.ThirdPartyManager; -import darkknight.jewelrycraft.util.Variables; -import darkknight.jewelrycraft.worldGen.village.VillageHandler; - -@Mod (modid = Variables.MODID, name = Variables.MODNAME, version = Variables.VERSION, guiFactory = Variables.CONFIG_GUI, acceptedMinecraftVersions = "[1.7.10,1.8)") -public class JewelrycraftMod -{ - @Instance (Variables.MODID) - public static JewelrycraftMod instance; - @SidedProxy (clientSide = Variables.CLIENT_PROXY, serverSide = Variables.SERVER_PROXY) - public static CommonProxy proxy; - public static final Logger logger = Logger.getLogger(Variables.MODNAME); - public static File dir; - public static CreativeTabs jewelrycraft = new CreativeTabs(Variables.MODID){ - @Override - public Item getTabIconItem() - { - return Item.getItemFromBlock(BlockList.jewelCraftingTable); - } - }; - public static CreativeTabs liquids = new CreativeTabLiquids("Liquids").setBackgroundImageName("item_search.png"); - public static NBTTagCompound saveData = new NBTTagCompound(); - public static NBTTagCompound clientData = new NBTTagCompound(); - public static File liquidsConf; - public static SimpleNetworkWrapper netWrapper; - public static boolean fancyRender = false; - - /** - * Pre initialization of mod stuff. - * - * @param e FMLPreInitializationEvent - * @throws IOException Signals that an I/O exception has occurred. - */ - @EventHandler - public void preInit(FMLPreInitializationEvent e) throws IOException - { - dir = e.getModConfigurationDirectory(); - ConfigHandler.INSTANCE.loadConfig(e); - ThirdPartyManager.instance().index(); - BlockList.preInit(e); - ItemList.preInit(e); - CraftingRecipes.preInit(e); - CurseList.preInit(e); - PacketHandler.preInit(e); - EntityList.preInit(e); - VillageHandler.preInit(e); - EventList.preInit(e); - PotionList.preInit(e); - ThirdPartyManager.instance().preInit(); - - ChestGenHooks.addItem("dungeonChest", new WeightedRandomChestContent(new ItemStack(ItemList.thiefGloves), 1, 1, 1)); - ChestGenHooks.addItem("villageBlacksmith", new WeightedRandomChestContent(new ItemStack(ItemList.thiefGloves), 1, 1, 1)); - ChestGenHooks.addItem("strongholdCorridor", new WeightedRandomChestContent(new ItemStack(ItemList.thiefGloves), 1, 1, 5)); - for(int i = 0; i < 16; i++) ChestGenHooks.addItem("mineshaftCorridor", new WeightedRandomChestContent(new ItemStack(BlockList.crystal, 1, i), 1, 4, 15)); - } - - @EventHandler - public void init(FMLInitializationEvent e) - { - EventList.init(e); - PotionList.init(e); - ThirdPartyManager.instance().init(); - } - - @EventHandler - public void postInit(FMLPostInitializationEvent e) - { - ThirdPartyManager.instance().postInit(); - EventList.postInit(e); - PotionList.postInit(e); - } - - @EventHandler - public void serverLoad(FMLServerStartingEvent event) - { - event.registerServerCommand(new JewelrycraftCommands()); - } - - @EventHandler - public void imcCallback(FMLInterModComms.IMCEvent event) - { - for (final FMLInterModComms.IMCMessage imcMessage : event.getMessages()) - { - logger.info("The mod " + imcMessage.getSender() + " has sent the following message: " + imcMessage.getStringValue()); - } - } -} +/* + * Mod made by DarkKnight during the Modjam 3 + * It's an awesome mod + * I love me! :D + */ +package darkknight.jewelrycraft; + +import java.io.File; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraftforge.common.ChestGenHooks; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.commands.JewelrycraftCommands; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.curses.CurseList; +import darkknight.jewelrycraft.entities.EntityList; +import darkknight.jewelrycraft.events.EventList; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.network.PacketHandler; +import darkknight.jewelrycraft.potions.PotionList; +import darkknight.jewelrycraft.proxy.CommonProxy; +import darkknight.jewelrycraft.recipes.CraftingRecipes; +import darkknight.jewelrycraft.thirdparty.ThirdPartyManager; +import darkknight.jewelrycraft.util.Variables; +import darkknight.jewelrycraft.worldGen.ChestGeneration; +import darkknight.jewelrycraft.worldGen.village.VillageHandler; + +@Mod (modid = Variables.MODID, name = Variables.MODNAME, version = Variables.VERSION, guiFactory = Variables.CONFIG_GUI, acceptedMinecraftVersions = "[1.7.10,1.8)") +public class JewelrycraftMod +{ + @Instance (Variables.MODID) + public static JewelrycraftMod instance; + @SidedProxy (clientSide = Variables.CLIENT_PROXY, serverSide = Variables.SERVER_PROXY) + public static CommonProxy proxy; + public static final Logger logger = Logger.getLogger(Variables.MODNAME); + public static File dir; + public static CreativeTabs jewelrycraft = new CreativeTabs(Variables.MODID){ + @Override + public Item getTabIconItem() + { + return Item.getItemFromBlock(BlockList.jewelCraftingTable); + } + }; + public static CreativeTabs liquids = new CreativeTabLiquids("Liquids").setBackgroundImageName("item_search.png"); + public static NBTTagCompound saveData = new NBTTagCompound(); + public static NBTTagCompound clientData = new NBTTagCompound(); + public static File liquidsConf; + public static SimpleNetworkWrapper netWrapper; + public static boolean fancyRender = false; + + /** + * Pre initialization of mod stuff. + * + * @param e FMLPreInitializationEvent + * @throws IOException Signals that an I/O exception has occurred. + */ + @EventHandler + public void preInit(FMLPreInitializationEvent e) throws IOException + { + dir = e.getModConfigurationDirectory(); + ConfigHandler.INSTANCE.loadConfig(e); + ThirdPartyManager.instance().index(); + logger.log(Level.INFO, "Registering Blocks"); + BlockList.preInit(e); + logger.log(Level.INFO, "Registering Items"); + ItemList.preInit(e); + logger.log(Level.INFO, "Registering Crafting Recipes"); + CraftingRecipes.preInit(e); + logger.log(Level.INFO, "Registering Curses"); + CurseList.preInit(e); + logger.log(Level.INFO, "Registering Packets"); + PacketHandler.preInit(e); + logger.log(Level.INFO, "Registering Entities"); + EntityList.preInit(e); + logger.log(Level.INFO, "Registering Village Stuff"); + VillageHandler.preInit(e); + logger.log(Level.INFO, "Registering Events"); + EventList.preInit(e); + logger.log(Level.INFO, "Registering Potions"); + PotionList.preInit(e); + logger.log(Level.INFO, "Loading Third Party Mods"); + ThirdPartyManager.instance().preInit(); + logger.log(Level.INFO, "Adding Dungeons loot"); + ChestGeneration.preInit(e); + } + + @EventHandler + public void init(FMLInitializationEvent e) + { + logger.log(Level.INFO, "Registering Events"); + EventList.init(e); + logger.log(Level.INFO, "Registering Potions"); + PotionList.init(e); + logger.log(Level.INFO, "Loading Third Party Mods"); + ThirdPartyManager.instance().init(); + } + + @EventHandler + public void postInit(FMLPostInitializationEvent e) + { + logger.log(Level.INFO, "Loading Third Party Mods"); + ThirdPartyManager.instance().postInit(); + logger.log(Level.INFO, "Registering Events"); + EventList.postInit(e); + logger.log(Level.INFO, "Registering Potions"); + PotionList.postInit(e); + } + + @EventHandler + public void serverLoad(FMLServerStartingEvent event) + { + event.registerServerCommand(new JewelrycraftCommands()); + } + + @EventHandler + public void imcCallback(FMLInterModComms.IMCEvent event) + { + for (final FMLInterModComms.IMCMessage imcMessage : event.getMessages()) + { + logger.info("The mod " + imcMessage.getSender() + " has sent the following message: " + imcMessage.getStringValue()); + } + } +} diff --git a/src/main/java/darkknight/jewelrycraft/api/Curse.java b/src/main/java/darkknight/jewelrycraft/api/Curse.java index c030aad..bf21a5e 100644 --- a/src/main/java/darkknight/jewelrycraft/api/Curse.java +++ b/src/main/java/darkknight/jewelrycraft/api/Curse.java @@ -1,150 +1,215 @@ -package darkknight.jewelrycraft.api; - -import java.util.ArrayList; -import java.util.Random; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiIngame; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; -import net.minecraftforge.client.event.RenderHandEvent; -import net.minecraftforge.client.event.RenderPlayerEvent; -import net.minecraftforge.event.world.BlockEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class Curse -{ - protected int textureID; - protected String name, description, texturePackName; - protected Random rand = new Random(); - private static ArrayList curses = new ArrayList(); - public static ArrayList availableCurses = new ArrayList(); - - /** - * @param id the ID of the curse - * @param name the name of the curse - * @param texturepack the ID of the pack the texture is located in - */ - protected Curse(String name, int txtID, String texturepack) - { - this.name = name; - this.texturePackName = texturepack; - this.textureID = txtID; - curses.add(this); - availableCurses.add(this); - } - - /** - * @return the name of the curse - */ - public String getName() - { - return name; - } - - /** - * @return the description of the curse - */ - public String getDescription() - { - return description; - } - - public Curse setDescription(String desc) - { - description = desc; - return this; - } - - /** - * @return the texture pack ID - */ - public String getTexturePack() - { - return texturePackName; - } - - /** - * @return the texture ID - */ - public int getTextureID() - { - return textureID; - } - - /** - * @param world - * @param player - */ - public void action(World world, EntityPlayer player) - {} - - /** - * @param world - * @param player - */ - public void playerDeathAction(World world, EntityPlayer player) - {} - - public void entityDeathAction(World world, EntityLivingBase target, EntityPlayer player) - {} - - /** - * @param world - * @param player - */ - public void respawnAction(World world, EntityPlayer player) - {} - - /** - * @param world - * @param player - */ - public void attackedAction(World world, EntityPlayer player) - {} - - /** - * @param world - * @param player - */ - public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) - {} - - public void entityDropItems(EntityPlayer player, Entity target, ArrayList drops) - {} - - @SideOnly(Side.CLIENT) - public void playerRender(EntityPlayer player, RenderPlayerEvent.Specials.Post event) - {} - - @SideOnly(Side.CLIENT) - public void playerHandRender(EntityPlayer player, RenderHandEvent event) - {} - - public void onBlockItemsDrop(EntityPlayer player, BlockEvent.HarvestDropsEvent event) - {} - - public void onBlockDestroyed(EntityPlayer player, BlockEvent.BreakEvent event) - {} - - public boolean itemToss() - { - return false; - } - - public boolean canCurseBeActivated(World world) - { - return true; - } - - /** - * @return - */ - public static ArrayList getCurseList() - { - return curses; - } -} +package darkknight.jewelrycraft.api; + +import java.util.ArrayList; +import java.util.Random; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiIngame; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; +import net.minecraftforge.client.event.RenderHandEvent; +import net.minecraftforge.client.event.RenderPlayerEvent; +import net.minecraftforge.event.world.BlockEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Curse +{ + protected int textureID; + protected String name, description, texturePackName; + protected Random rand = new Random(); + private static ArrayList curses = new ArrayList(); + public static ArrayList availableCurses = new ArrayList(); + + /** + * @param name The name of the curse + * @param txtID The texture ID of it + * @param texturepack The texturepack location + */ + protected Curse(String name, int txtID, String texturepack) + { + this.name = name; + this.texturePackName = texturepack; + this.textureID = txtID; + curses.add(this); + availableCurses.add(this); + } + + /** + * @return The name of the curse + */ + public String getName() + { + return name; + } + + /** + * @return The description of the curse + */ + public String getDescription() + { + return description; + } + + /** + * @param The description of the curse + * @return The class + */ + public Curse setDescription(String desc) + { + description = desc; + return this; + } + + /** + * @return the texture pack ID + */ + public String getTexturePack() + { + return texturePackName; + } + + /** + * @return The texture ID + */ + public int getTextureID() + { + return textureID; + } + + /** + * This runs every tick + * @param world The worldthe player is in + * @param player The cursed player + */ + public void action(World world, EntityPlayer player) + {} + + /** + * This runs when the player dies + * @param world The world the player is in + * @param player The cursed player + */ + public void playerDeathAction(World world, EntityPlayer player) + {} + + /** + * This runs when an entity is killed (whether by a player or other causes) + * @param world The world the player is in + * @param target The entity that died + * @param player The cursed player + */ + public void entityDeathAction(World world, EntityLivingBase target, EntityPlayer player) + {} + + /** + * This runs when the player respawns + * @param world The world the player is in + * @param player The cursed player + */ + public void respawnAction(World world, EntityPlayer player) + {} + + /** + * This runs when a player gets attacked by anything but another player + * @param world The world the player is in + * @param player The cursed player + */ + public void attackedAction(World world, EntityPlayer player) + {} + + /** + * This runs when an entity is attacked by a player (this includes other players) + * @param world The world the player is in + * @param player The player that caused the damage + * @param target The entity damaged + */ + public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) + {} + + /** + * This runs when an item is dropped by an entity + * @param player The cursed player + * @param target The entity that drops the item + * @param drops An array list containing the dropped items + */ + public void entityDropItems(EntityPlayer player, Entity target, ArrayList drops) + {} + + /** + * This is for rendering special things on the player in 3rd person (meaning you won't see this render); + * This will also render in the inventory. + * @param player The cursed player + * @param event The event used for this + */ + @SideOnly(Side.CLIENT) + public void playerRender(EntityPlayer player, RenderPlayerEvent.Specials.Post event) + {} + + /** + * This is for rendering special things on the player in 1st and 3rd person, but not in the player inventory. + * @param player The cursed player + * @param event The event used for this + */ + @SideOnly(Side.CLIENT) + public void playerHandRender(EntityPlayer player, RenderHandEvent event) + {} + + /** + * This runs when a block drops an item (such as breaking a block and dropping itself, or breaking like a Diamond ore and dropping diamonds) + * @param player The cursed player + * @param event The BlockEvent that triggers this + */ + public void onBlockItemsDrop(EntityPlayer player, BlockEvent.HarvestDropsEvent event) + {} + + /** + * This runs when a block is destroyed + * @param player The cursed player + * @param event The BlockEvent that runs this + */ + public void onBlockDestroyed(EntityPlayer player, BlockEvent.BreakEvent event) + {} + + /** + * This determines if the player can toss an item or not (with Q) + * @return True if the player can no longer toss items; False if he can. (by default false) + */ + public boolean itemToss() + { + return false; + } + + /** + * This controls whether a curse can be activated or not (makes it easy to do things like disable certain curses if in hardcore) + * @param world The world the player is in + * @return True for curses to be used; False otherwise (by default true) + */ + public boolean canCurseBeActivated(World world) + { + return true; + } + + /** + * This is the list of all curses + * @return The list of registered curses + */ + public static ArrayList getCurseList() + { + return curses; + } + + /** + * This is the weight of the curse when it chooses it. The lower the value, the less it gets chosen; the higher the value, the higher the chance of it getting picked. + * @param world The world the player is currently in + * @param player The cursed player + * @param random A random class + * @return The weight of the curse (by default 10) + */ + public int weight(World world, EntityPlayer player, Random random) + { + return 10; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/api/ModifierEffects.java b/src/main/java/darkknight/jewelrycraft/api/ModifierEffects.java index 2aa3254..be88d31 100644 --- a/src/main/java/darkknight/jewelrycraft/api/ModifierEffects.java +++ b/src/main/java/darkknight/jewelrycraft/api/ModifierEffects.java @@ -1,92 +1,122 @@ -package darkknight.jewelrycraft.api; - -import java.util.ArrayList; -import java.util.Random; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.DamageSource; -import net.minecraftforge.event.entity.player.PlayerEvent; - -public class ModifierEffects -{ - protected ItemStack modifier; - protected Random rand = new Random(); - protected static ArrayList effects = new ArrayList(); - - /** - * @param modifier - */ - public ModifierEffects(ItemStack modifier) - { - this.modifier = modifier; - effects.add(this); - } - - /** - * @return - */ - public static ArrayList getEffects() - { - return effects; - } - - /** - * @param item - * @param player - * @param jewelry - */ - public void action(ItemStack item, EntityPlayer player, Item jewelry) - {}; - - /** - * @param item - * @param player - * @param target - * @param jewelry - * @return - */ - public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) - { - return false; - } - - /** - * @param item - * @param player - * @param source - * @param jewelry - * @return - */ - public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) - { - return false; - } - - /** - * @param item - * @param player - * @param target - * @param jewelry - * @return - */ - public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) - {} - - /** - * @param item - * @param player - * @param source - * @param jewelry - * @return - */ - public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) - {} - - public void onPlayerDead(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry) - {} - - public void onPlayerRespawn(ItemStack item, PlayerEvent.Clone event, Item jewelry) - {} -} +package darkknight.jewelrycraft.api; + +import java.util.ArrayList; +import java.util.Random; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraftforge.event.entity.player.PlayerEvent; + +public class ModifierEffects +{ + protected ItemStack modifier; + protected Random rand = new Random(); + protected static ArrayList effects = new ArrayList(); + + /** + * @param modifier The item to use as modifier + */ + public ModifierEffects(ItemStack modifier) + { + this.modifier = modifier; + effects.add(this); + } + + /** + * @return The list of all effects registered + */ + public static ArrayList getEffects() + { + return effects; + } + + /** + * @return The ItemStack set as the modifier + */ + public ItemStack getModifier() + { + return modifier; + } + + /** + * This runs every tick + * @param item The ItemStack representing the jewelry that runs the effect + * @param player The player wearing the jewelry wearing a jewelry with this modifier on it + * @param jewelry The actual jewelry item (used by me to determine the type of jewelry so I don't have to call item.getItem() blah blah blah) + */ + public void action(ItemStack item, EntityPlayer player, Item jewelry) + {}; + + /** + * This runs when an entity is attacked. This event can be canceled. + * @param item The ItemStack representing the jewelry that runs the effect + * @param player The player wearing the jewelry wearing a jewelry with this modifier on it + * @param target The attacked entity + * @param jewelry The actual jewelry item (aka item.getItem(), almost) + * @param amount The amount of damage the entity took + * @return The state of the event (true to cancel it, false to not) + */ + public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) + { + return false; + } + + /** + * This runs when a player gets damaged. This event can be canceled. + * @param item The ItemStack representing the jewelry that runs the effect + * @param player The attacked player wearing a jewelry with this modifier on it + * @param source The source of the damage + * @param jewelry The actual jewelry item (aka item.getItem(), almost) + * @param amount The amount of damage the player took + * @return The state of the event (true to cancel it, false to not) + */ + public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) + { + return false; + } + + /** + * This is the same as onEntityAttackedCacellable, but this can not be canceled. + * I recommend using this over onEntityAttackedCacellable, as it is more reliable. + * @param item The ItemStack representing the jewelry that runs the effect + * @param player The player wearing the jewelry wearing a jewelry with this modifier on it + * @param target The attacked entity + * @param jewelry The actual jewelry item (aka item.getItem(), almost) + * @param amount The amount of damage the entity took + */ + public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) + {} + + /** + * This is just like onPlayerAttackedCacellable, only that this can not be canceled. + * I recommend using this over onPlayerAttackedCacellable, as it is more reliable. + * @param item The ItemStack representing the jewelry that runs the effect + * @param player The attacked player wearing a jewelry with this modifier on it + * @param source The source of the damage + * @param jewelry The actual jewelry item (aka item.getItem(), almost) + * @param amount The amount of damage the player took + */ + public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) + {} + + /** + * This runs when the player dies + * @param item The ItemStack representing the jewelry that runs the effect + * @param player The player that died wearing a jewelry with this modifier on it + * @param source The source of the killing blow + * @param jewelry The actual jewelry item (aka item.getItem(), almost) + */ + public void onPlayerDead(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry) + {} + + /** + * This runs when the player respawns + * @param item The ItemStack representing the jewelry that runs the effect + * @param event The PlayerEvent that runs when the player respawns (this is also called when a player moves between dimensions) + * @param jewelry The actual jewelry item (aka item.getItem(), almost) + */ + public void onPlayerRespawn(ItemStack item, PlayerEvent.Clone event, Item jewelry) + {} +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java b/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java index 017c459..fd7c264 100644 --- a/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java @@ -1,270 +1,275 @@ -package darkknight.jewelrycraft.block; - -import java.io.IOException; -import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.fluids.BlockFluidClassic; -import net.minecraftforge.fluids.Fluid; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.network.PacketRequestLiquidData; -import darkknight.jewelrycraft.network.PacketSendLiquidData; -import darkknight.jewelrycraft.util.Variables; - -public class BlockMoltenMetal extends BlockFluidClassic -{ - @SideOnly (Side.CLIENT) - protected IIcon stillIcon; - @SideOnly (Side.CLIENT) - protected IIcon flowingIcon; - - /** - * @param fluid - * @param material - */ - public BlockMoltenMetal(Fluid fluid, Material material) - { - super(fluid, material); - setBlockName(Variables.MODID + ".moltenMetal"); - setQuantaPerBlock(5); - setRenderPass(1); - setLightLevel(15f); - } - - /** - * @param side - * @param meta - * @return - */ - @Override - public IIcon getIcon(int side, int meta) - { - return side == 0 || side == 1 ? stillIcon : flowingIcon; - } - - /** - * @param register - */ - @Override - @SideOnly (Side.CLIENT) - public void registerBlockIcons(IIconRegister register) - { - stillIcon = register.registerIcon(Variables.MODID + ":moltenMetalStill"); - flowingIcon = register.registerIcon(Variables.MODID + ":moltenMetalFlow"); - } - - /** - * @param world - * @param x - * @param y - * @param z - * @return - */ - @Override - public boolean canDisplace(IBlockAccess world, int x, int y, int z) - { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; - return super.canDisplace(world, x, y, z); - } - - /** - * @param world - * @param x - * @param y - * @param z - * @return - */ - @Override - public boolean displaceIfPossible(World world, int x, int y, int z) - { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; - return super.displaceIfPossible(world, x, y, z); - } - - /** - * @param world - * @param x - * @param y - * @param z - * @return - */ - @Override - protected boolean canFlowInto(IBlockAccess world, int x, int y, int z) - { - if (world.getBlock(x, y, z).isAir(world, x, y, z)) return true; - Block block = world.getBlock(x, y, z); - if (block == this) return false; - if (displacements.containsKey(block)) return displacements.get(block); - Material material = block.getMaterial(); - if (material.blocksMovement() || material == Material.water || material == Material.lava || material == Material.portal) return false; - int density = getDensity(world, x, y, z); - if (density == Integer.MAX_VALUE) return true; - if (this.density > density) return true; - else return false; - } - - /** - * @param world - * @param i - * @param j - * @param k - * @return - */ - @Override - @SideOnly (Side.CLIENT) - public int colorMultiplier(IBlockAccess world, int i, int j, int k) - { - try{ - return color(world, i, j, k, false, null); - } - catch(IOException e){ - e.printStackTrace(); - } - return 0; - } - - /** - * @param world - * @param x - * @param y - * @param z - * @param rand - */ - @Override - public void updateTick(World world, int x, int y, int z, Random rand) - { - int quantaRemaining = quantaPerBlock - world.getBlockMetadata(x, y, z); - int expQuanta = -101; - // check adjacent block levels if non-source - if (quantaRemaining < quantaPerBlock){ - int y2 = y - densityDir; - if (world.getBlock(x, y2, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y2, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x - 1, y2, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x - 1, y2, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x + 1, y2, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x + 1, y2, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x, y2, z - 1) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y2, z - 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x, y2, z + 1) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y2, z + 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) expQuanta = quantaPerBlock - 1; - else{ - int maxQuanta = -100; - if (JewelrycraftMod.saveData.getString(stringFromLocation(x - 1, y, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x - 1, y, z, maxQuanta); - if (JewelrycraftMod.saveData.getString(stringFromLocation(x + 1, y, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x + 1, y, z, maxQuanta); - if (JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z - 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x, y, z - 1, maxQuanta); - if (JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z + 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x, y, z + 1, maxQuanta); - expQuanta = maxQuanta - 1; - } - // decay calculation - if (expQuanta != quantaRemaining){ - quantaRemaining = expQuanta; - if (expQuanta <= 0) world.setBlock(x, y, z, Blocks.air); - else{ - world.setBlockMetadataWithNotify(x, y, z, quantaPerBlock - expQuanta, 3); - world.scheduleBlockUpdate(x, y, z, this, tickRate); - world.notifyBlocksOfNeighborChange(x, y, z, this); - } - } - } - // This is a "source" block, set meta to zero, and send a server only - // update - else if (quantaRemaining >= quantaPerBlock) world.setBlockMetadataWithNotify(x, y, z, 0, 2); - String originData = JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)); - // Flow vertically if possible - if (canDisplace(world, x, y + densityDir, z)){ - JewelrycraftMod.saveData.setString(stringFromLocation(x, y + densityDir, z, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))); - flowIntoBlock(world, x, y + densityDir, z, 1, originData); - return; - } - // Flow outward if possible - int flowMeta = quantaPerBlock - quantaRemaining + 1; - if (flowMeta >= quantaPerBlock) return; - if (isSourceBlock(world, x, y, z) || !isFlowingVertically(world, x, y, z)){ - if (world.getBlock(x, y - densityDir, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y - densityDir, z, world.provider.dimensionId)))) flowMeta = 1; - boolean flowTo[] = getOptimalFlowDirections(world, x, y, z); - if (flowTo[0]){ - if (JewelrycraftMod.saveData.getTag(stringFromLocation(x - 1, y, z, world.provider.dimensionId)) == null || world.getBlock(x - 1, y, z).isAir(world, x - 1, y, z)) JewelrycraftMod.saveData.setString(stringFromLocation(x - 1, y, z, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))); - flowIntoBlock(world, x - 1, y, z, flowMeta, originData); - } - if (flowTo[1]){ - if (JewelrycraftMod.saveData.getTag(stringFromLocation(x + 1, y, z, world.provider.dimensionId)) == null || world.getBlock(x + 1, y, z).isAir(world, x + 1, y, z)) JewelrycraftMod.saveData.setString(stringFromLocation(x + 1, y, z, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))); - flowIntoBlock(world, x + 1, y, z, flowMeta, originData); - } - if (flowTo[2]){ - if (JewelrycraftMod.saveData.getTag(stringFromLocation(x, y, z - 1, world.provider.dimensionId)) == null || world.getBlock(x, y, z - 1).isAir(world, x, y, z - 1)) JewelrycraftMod.saveData.setString(stringFromLocation(x, y, z - 1, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))); - flowIntoBlock(world, x, y, z - 1, flowMeta, originData); - } - if (flowTo[3]){ - if (JewelrycraftMod.saveData.getTag(stringFromLocation(x, y, z + 1, world.provider.dimensionId)) == null || world.getBlock(x, y, z + 1).isAir(world, x, y, z + 1)) JewelrycraftMod.saveData.setString(stringFromLocation(x, y, z + 1, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))); - flowIntoBlock(world, x, y, z + 1, flowMeta, originData); - } - } - } - - /** - * @param world - * @param x - * @param y - * @param z - * @param meta - * @param originData - */ - public void flowIntoBlock(World world, int x, int y, int z, int meta, String originData) - { - if (meta < 0 || world.isRemote) return; - if (displaceIfPossible(world, x, y, z)){ - world.setBlock(x, y, z, this, meta, 3); - JewelrycraftMod.saveData.setString(stringFromLocation(x, y, z, world.provider.dimensionId), originData); - String[] data = originData.split(":"); - JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Integer.parseInt(data[0]), Integer.parseInt(data[1]), Integer.parseInt(data[2]))); - } - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param forcecolor - * @param itemC - * @return - * @throws IOException - */ - @SideOnly (Side.CLIENT) - public static int color(IBlockAccess world, int i, int j, int k, boolean forcecolor, Item itemC) throws IOException - { - String ingotData = JewelrycraftMod.clientData.getString(String.valueOf(i) + " " + String.valueOf(j) + " " + String.valueOf(k) + " " + Minecraft.getMinecraft().theWorld.provider.dimensionId); - if (ingotData == ""){ - JewelrycraftMod.netWrapper.sendToServer(new PacketRequestLiquidData(Minecraft.getMinecraft().theWorld.provider.dimensionId, i, j, k)); - return 0xFFFFFF; - }else{ - String[] splitData = ingotData.split(":"); - if (splitData.length == 3){ - int color; - try{ - Integer.parseInt(splitData[0]); - Integer.parseInt(splitData[1]); - color = Integer.parseInt(splitData[2]); - return color; - } - catch(Exception e){ - e.printStackTrace(); - } - } - } - return 16777215; - } - - /** - * @param x - * @param y - * @param z - * @param dimID - * @return - */ - public static String stringFromLocation(int x, int y, int z, int dimID) - { - return x + " " + y + " " + z + " " + dimID; - } -} +package darkknight.jewelrycraft.block; + +import java.io.IOException; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fluids.BlockFluidClassic; +import net.minecraftforge.fluids.Fluid; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.network.PacketRequestLiquidData; +import darkknight.jewelrycraft.network.PacketSendLiquidData; +import darkknight.jewelrycraft.util.Variables; + +public class BlockMoltenMetal extends BlockFluidClassic +{ + @SideOnly (Side.CLIENT) + protected IIcon stillIcon; + @SideOnly (Side.CLIENT) + protected IIcon flowingIcon; + + /** + * @param fluid + * @param material + */ + public BlockMoltenMetal(Fluid fluid, Material material) + { + super(fluid, material); + setBlockName(Variables.MODID + ".moltenMetal"); + setQuantaPerBlock(5); + setRenderPass(1); + setLightLevel(15f); + } + + /** + * @param side + * @param meta + * @return + */ + @Override + public IIcon getIcon(int side, int meta) + { + return side == 0 || side == 1 ? stillIcon : flowingIcon; + } + + /** + * @param register + */ + @Override + @SideOnly (Side.CLIENT) + public void registerBlockIcons(IIconRegister register) + { + stillIcon = register.registerIcon(Variables.MODID + ":moltenMetalStill"); + flowingIcon = register.registerIcon(Variables.MODID + ":moltenMetalFlow"); + } + + /** + * @param world + * @param x + * @param y + * @param z + * @return + */ + @Override + public boolean canDisplace(IBlockAccess world, int x, int y, int z) + { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; + return super.canDisplace(world, x, y, z); + } + + /** + * @param world + * @param x + * @param y + * @param z + * @return + */ + @Override + public boolean displaceIfPossible(World world, int x, int y, int z) + { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; + return super.displaceIfPossible(world, x, y, z); + } + + /** + * @param world + * @param x + * @param y + * @param z + * @return + */ + @Override + protected boolean canFlowInto(IBlockAccess world, int x, int y, int z) + { + if (world.getBlock(x, y, z).isAir(world, x, y, z)) return true; + Block block = world.getBlock(x, y, z); + if (block == this) return false; + if (displacements.containsKey(block)) return displacements.get(block); + Material material = block.getMaterial(); + if (material.blocksMovement() || material == Material.water || material == Material.lava || material == Material.portal) return false; + int density = getDensity(world, x, y, z); + if (density == Integer.MAX_VALUE) return true; + if (this.density > density) return true; + else return false; + } + + /** + * @param world + * @param i + * @param j + * @param k + * @return + */ + @Override + @SideOnly (Side.CLIENT) + public int colorMultiplier(IBlockAccess world, int i, int j, int k) + { + try{ + return color(world, i, j, k, false, null); + } + catch(IOException e){ + e.printStackTrace(); + } + return 0; + } + + /** + * @param world + * @param x + * @param y + * @param z + * @param rand + */ + @Override + public void updateTick(World world, int x, int y, int z, Random rand) + { + int quantaRemaining = quantaPerBlock - world.getBlockMetadata(x, y, z); + int expQuanta = -101; + // check adjacent block levels if non-source + if (quantaRemaining < quantaPerBlock){ + int y2 = y - densityDir; + if (world.getBlock(x, y2, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y2, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x - 1, y2, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x - 1, y2, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x + 1, y2, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x + 1, y2, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x, y2, z - 1) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y2, z - 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x, y2, z + 1) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y2, z + 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) expQuanta = quantaPerBlock - 1; + else{ + int maxQuanta = -100; + if (JewelrycraftMod.saveData.getString(stringFromLocation(x - 1, y, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x - 1, y, z, maxQuanta); + if (JewelrycraftMod.saveData.getString(stringFromLocation(x + 1, y, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x + 1, y, z, maxQuanta); + if (JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z - 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x, y, z - 1, maxQuanta); + if (JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z + 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x, y, z + 1, maxQuanta); + expQuanta = maxQuanta - 1; + } + // decay calculation + if (expQuanta != quantaRemaining){ + quantaRemaining = expQuanta; + if (expQuanta <= 0) world.setBlock(x, y, z, Blocks.air); + else{ + world.setBlockMetadataWithNotify(x, y, z, quantaPerBlock - expQuanta, 3); + world.scheduleBlockUpdate(x, y, z, this, tickRate); + world.notifyBlocksOfNeighborChange(x, y, z, this); + } + } + } + // This is a "source" block, set meta to zero, and send a server only + // update + else if (quantaRemaining >= quantaPerBlock) world.setBlockMetadataWithNotify(x, y, z, 0, 2); + String originData = JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)); + // Flow vertically if possible + if (canDisplace(world, x, y + densityDir, z)){ + JewelrycraftMod.saveData.setString(stringFromLocation(x, y + densityDir, z, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))); + flowIntoBlock(world, x, y + densityDir, z, 1, originData); + return; + } + // Flow outward if possible + int flowMeta = quantaPerBlock - quantaRemaining + 1; + if (flowMeta >= quantaPerBlock) return; + if (isSourceBlock(world, x, y, z) || !isFlowingVertically(world, x, y, z)){ + if (world.getBlock(x, y - densityDir, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y - densityDir, z, world.provider.dimensionId)))) flowMeta = 1; + boolean flowTo[] = getOptimalFlowDirections(world, x, y, z); + if (flowTo[0]){ + if (JewelrycraftMod.saveData.getTag(stringFromLocation(x - 1, y, z, world.provider.dimensionId)) == null || world.getBlock(x - 1, y, z).isAir(world, x - 1, y, z)) JewelrycraftMod.saveData.setString(stringFromLocation(x - 1, y, z, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))); + flowIntoBlock(world, x - 1, y, z, flowMeta, originData); + } + if (flowTo[1]){ + if (JewelrycraftMod.saveData.getTag(stringFromLocation(x + 1, y, z, world.provider.dimensionId)) == null || world.getBlock(x + 1, y, z).isAir(world, x + 1, y, z)) JewelrycraftMod.saveData.setString(stringFromLocation(x + 1, y, z, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))); + flowIntoBlock(world, x + 1, y, z, flowMeta, originData); + } + if (flowTo[2]){ + if (JewelrycraftMod.saveData.getTag(stringFromLocation(x, y, z - 1, world.provider.dimensionId)) == null || world.getBlock(x, y, z - 1).isAir(world, x, y, z - 1)) JewelrycraftMod.saveData.setString(stringFromLocation(x, y, z - 1, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))); + flowIntoBlock(world, x, y, z - 1, flowMeta, originData); + } + if (flowTo[3]){ + if (JewelrycraftMod.saveData.getTag(stringFromLocation(x, y, z + 1, world.provider.dimensionId)) == null || world.getBlock(x, y, z + 1).isAir(world, x, y, z + 1)) JewelrycraftMod.saveData.setString(stringFromLocation(x, y, z + 1, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))); + flowIntoBlock(world, x, y, z + 1, flowMeta, originData); + } + } + } + + /** + * @param world + * @param x + * @param y + * @param z + * @param meta + * @param originData + */ + public void flowIntoBlock(World world, int x, int y, int z, int meta, String originData) + { + if (meta < 0 || world.isRemote) return; + if (displaceIfPossible(world, x, y, z)){ + world.setBlock(x, y, z, this, meta, 3); + JewelrycraftMod.saveData.setString(stringFromLocation(x, y, z, world.provider.dimensionId), originData); + String[] data = originData.split(":"); + try{ + JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Integer.parseInt(data[0]), Integer.parseInt(data[1]), Integer.parseInt(data[2]))); + } + catch(Exception e){ + System.out.println("The liquids file is either corrupt, missing or the metal for the liquid simply doesn't exist!"); + } + } + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param forcecolor + * @param itemC + * @return + * @throws IOException + */ + @SideOnly (Side.CLIENT) + public static int color(IBlockAccess world, int i, int j, int k, boolean forcecolor, Item itemC) throws IOException + { + String ingotData = JewelrycraftMod.clientData.getString(String.valueOf(i) + " " + String.valueOf(j) + " " + String.valueOf(k) + " " + Minecraft.getMinecraft().theWorld.provider.dimensionId); + if (ingotData == ""){ + JewelrycraftMod.netWrapper.sendToServer(new PacketRequestLiquidData(Minecraft.getMinecraft().theWorld.provider.dimensionId, i, j, k)); + return 0xFFFFFF; + }else{ + String[] splitData = ingotData.split(":"); + if (splitData.length == 3){ + int color; + try{ + Integer.parseInt(splitData[0]); + Integer.parseInt(splitData[1]); + color = Integer.parseInt(splitData[2]); + return color; + } + catch(Exception e){ + e.printStackTrace(); + } + } + } + return 16777215; + } + + /** + * @param x + * @param y + * @param z + * @param dimID + * @return + */ + public static String stringFromLocation(int x, int y, int z, int dimID) + { + return x + " " + y + " " + z + " " + dimID; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java b/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java index e6e74cc..4e20a43 100644 --- a/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java @@ -1,266 +1,265 @@ -package darkknight.jewelrycraft.block; - -import java.io.IOException; -import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.MathHelper; -import net.minecraft.util.StatCollector; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.item.ItemMoltenMetalBucket; -import darkknight.jewelrycraft.network.PacketSendLiquidData; -import darkknight.jewelrycraft.tileentity.TileEntityMolder; -import darkknight.jewelrycraft.tileentity.TileEntitySmelter; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.JewelrycraftUtil; -import darkknight.jewelrycraft.util.Variables; - -public class BlockSmelter extends BlockContainer -{ - Random rand = new Random(); - - public BlockSmelter() - { - super(Material.rock); - } - - @Override - public TileEntity createNewTileEntity(World world, int var2) - { - return new TileEntitySmelter(); - } - - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - /** - * Spawns an item in the world at the specified location - * - * @param world - * @param x - * @param y - * @param z - * @param stack - */ - public void dropItem(World world, double x, double y, double z, ItemStack stack) - { - EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1.3D, z + 0.5D, stack); - entityitem.motionX = 0; - entityitem.motionZ = 0; - entityitem.motionY = 0.11000000298023224D; - entityitem.delayBeforeCanPickup = 0; - world.spawnEntityInWorld(entityitem); - } - - @Override - public void breakBlock(World world, int i, int j, int k, Block par5, int par6) - { - TileEntitySmelter te = (TileEntitySmelter)world.getTileEntity(i, j, k); - if (te != null){ - if (te.hasMetal) dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.metal.copy()); - if (te.hasMoltenMetal && te.moltenMetal != null && Item.getIdFromItem(te.moltenMetal.getItem()) > 0){ - ItemStack metal = te.moltenMetal; - ItemStack item = te.moltenMetal; - if (Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.carpet)) metal.setItemDamage(15 - metal.getItemDamage()); - int color = 16777215; - JewelryNBT.addMetal(item, metal); - try{ - color = ItemMoltenMetalBucket.color(item, 1); - System.out.println(color); - } - catch(IOException e){ - e.printStackTrace(); - } - JewelrycraftMod.saveData.setString(i + " " + j + " " + k + " " + world.provider.dimensionId, Item.getIdFromItem(metal.getItem()) + ":" + metal.getItemDamage() + ":" + color); - JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, i, j, k, Item.getIdFromItem(metal.getItem()), metal.getItemDamage(), color)); - world.setBlock(i, j, k, BlockList.moltenMetal, 0, 3); - int quant = (int)(te.quantity * 10); - if (quant == 1) world.setBlockMetadataWithNotify(i, j, k, 4, 3); - if (quant == 2) world.setBlockMetadataWithNotify(i, j, k, 4, 3); - if (quant == 3) world.setBlockMetadataWithNotify(i, j, k, 3, 3); - if (quant == 4) world.setBlockMetadataWithNotify(i, j, k, 3, 3); - if (quant == 5) world.setBlockMetadataWithNotify(i, j, k, 2, 3); - if (quant == 6) world.setBlockMetadataWithNotify(i, j, k, 2, 3); - if (quant == 7) world.setBlockMetadataWithNotify(i, j, k, 1, 3); - if (quant == 8) world.setBlockMetadataWithNotify(i, j, k, 1, 3); - if (quant == 9) world.setBlockMetadataWithNotify(i, j, k, 0, 3); - } - world.removeTileEntity(i, j, k); - } - super.breakBlock(world, i, j, k, par5, par6); - } - - @Override - public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) - { - TileEntitySmelter te = (TileEntitySmelter)world.getTileEntity(i, j, k); - ItemStack item = entityPlayer.inventory.getCurrentItem(); - if (te != null && te.hasMoltenMetal && te.quantity >= .9f && !te.pouring && item != null && item.getItem() == Items.bucket){ - te.quantity = 0f; - te.hasMoltenMetal = false; - ItemStack metalBucket = new ItemStack(ItemList.bucket, 1); - ItemStack ingot = te.moltenMetal.copy(); - if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage()); - JewelryNBT.addMetal(metalBucket, ingot); - --item.stackSize; - entityPlayer.inventory.addItemStackToInventory(metalBucket); - te.isDirty = true; - return true; - } - if (te != null && !world.isRemote){ - if (te.hasMetal && entityPlayer.isSneaking()){ - dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.metal.copy()); - te.hasMetal = false; - te.melting = -1; - te.isDirty = true; - } - if (item != null && item.getItem() != null && !(item.getItem() instanceof ItemMoltenMetalBucket)){ - int index = -1; - for(int a = 0; a < JewelrycraftUtil.jamcraftPlayers.size(); a++) - if (entityPlayer.getUniqueID().toString().equals(JewelrycraftUtil.jamcraftPlayers.get(a))) index = a; - if(entityPlayer.capabilities.isCreativeMode) index = 1; - boolean canPlace = item != null && (JewelrycraftUtil.isMetal(item) || JewelrycraftUtil.isOre(item) || index >= 0 || JewelryNBT.ingot(item) != null); - boolean isOre = false, oreCoincidesWithMetal = false, itemCoincidesWithMetal = false, itemCoincidesWithMoltenMetal = false, overflow = false; - isOre = JewelrycraftUtil.isOre(item); - if (te.metal != null && te.metal.getItem() != null) { - if(JewelryNBT.ingot(item) == null) itemCoincidesWithMetal = item.getItem().equals(te.metal.getItem()) && item.getItemDamage() == te.metal.getItemDamage(); - else itemCoincidesWithMetal = item.getItem().equals(te.metal.getItem()) && item.getItemDamage() == te.metal.getItemDamage() && JewelryNBT.ingot(item).getItem().equals(JewelryNBT.ingot(te.metal).getItem()) && JewelryNBT.ingot(item).getItemDamage() == JewelryNBT.ingot(te.metal).getItemDamage(); - } - if (te.moltenMetal != null && te.moltenMetal.getItem() != null){ - if(JewelryNBT.ingot(item) == null) itemCoincidesWithMoltenMetal = item.getItem().equals(te.moltenMetal.getItem()) && item.getItemDamage() == te.moltenMetal.getItemDamage(); - else itemCoincidesWithMoltenMetal = JewelryNBT.ingot(item).getItem().equals(te.moltenMetal.getItem()) && JewelryNBT.ingot(item).getItemDamage() == te.moltenMetal.getItemDamage(); - if (isOre) oreCoincidesWithMetal = te.moltenMetal.getItem().equals(JewelrycraftUtil.getIngotFromOre(item).getItem()) && te.moltenMetal.getItemDamage() == JewelrycraftUtil.getIngotFromOre(item).getItemDamage(); - } - overflow = isOre ? te.metal.stackSize * 0.2f + te.quantity < 0.8f : te.metal.stackSize*0.1f + te.quantity < 0.9f; - boolean isValid = te.hasMoltenMetal ? isOre ? oreCoincidesWithMetal : itemCoincidesWithMoltenMetal : true; - if (te.quantity < 0.9f && !te.pouring && canPlace && isValid){ - boolean check = isOre ? oreCoincidesWithMetal && te.quantity < 0.8f : itemCoincidesWithMoltenMetal; - boolean check2 = isOre ? oreCoincidesWithMetal : itemCoincidesWithMetal; - if (!te.hasMetal && !te.hasMoltenMetal || !te.hasMetal && te.hasMoltenMetal && check){ - entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.nowsmeltingingot", item.getDisplayName()))); - te.metal = item.copy(); - // if (Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.carpet)) te.metal.setItemDamage(15 - te.metal.getItemDamage()); - te.metal.stackSize = 1; - te.hasMetal = true; - te.melting = ConfigHandler.INGOT_MELTING_TIME; - if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; - te.isDirty = true; - }else if (te.hasMetal && te.hasMoltenMetal && check2 && overflow || te.hasMetal && !te.hasMoltenMetal && itemCoincidesWithMetal && overflow){ - entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("Smelting extra " + (isOre ? "ores" : "ingots") + " (" + (te.metal.stackSize + 1) + ")"))); - te.metal.stackSize++; - te.hasMetal = true; - te.melting += ConfigHandler.INGOT_MELTING_TIME; - if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; - te.isDirty = true; - } - te.isDirty = true; - }else if (item != null && (te.hasMetal || te.hasMoltenMetal) && !itemCoincidesWithMoltenMetal && te.quantity < .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.contentdoesnotmatch"))); - else if (item != null && !item.getUnlocalizedName().toLowerCase().contains("ingot") && item.getDisplayName().toLowerCase().contains("ingot") && te.quantity < .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.itemrenamedtoingot"))); - else if (item != null && te.quantity >= .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.full"))); - else entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.cannotsmelt"))); - }else if (item != null && item.getItem() != null && item.getItem() instanceof ItemMoltenMetalBucket && !te.hasMoltenMetal && !te.hasMetal){ - te.hasMoltenMetal = true; - ItemStack ingot = JewelryNBT.ingot(item); - if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage()); - te.moltenMetal = ingot; - te.quantity = .9f; - te.isDirty = true; - if (!entityPlayer.capabilities.isCreativeMode){ - --item.stackSize; - dropItem(world, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, new ItemStack(Items.bucket)); - } - } - else if (item == null && te.hasMoltenMetal && te.moltenMetal.getItem() != null) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.hasmolteningot", te.moltenMetal.getDisplayName().replace(" Ingot","")))); - world.setTileEntity(i, j, k, te); - } - return true; - } - - @Override - public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) - { - TileEntitySmelter te = (TileEntitySmelter)world.getTileEntity(i, j, k); - TileEntityMolder me = null; - if (world.getBlockMetadata(i, j, k) == 0 && world.getTileEntity(i, j, k - 1) != null && world.getTileEntity(i, j, k - 1) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i, j, k - 1); - else if (world.getBlockMetadata(i, j, k) == 1 && world.getTileEntity(i + 1, j, k) != null && world.getTileEntity(i + 1, j, k) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i + 1, j, k); - else if (world.getBlockMetadata(i, j, k) == 2 && world.getTileEntity(i, j, k + 1) != null && world.getTileEntity(i, j, k + 1) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i, j, k + 1); - else if (world.getBlockMetadata(i, j, k) == 3 && world.getTileEntity(i - 1, j, k) != null && world.getTileEntity(i - 1, j, k) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i - 1, j, k); - if (te != null && me != null && !world.isRemote) if (te.hasMoltenMetal && isConnectedToMolder(world, i, j, k) && me != null && me.hasMold && !me.hasMoltenMetal && !me.hasJewelBase){ - te.pouring = true; - te.isDirty = true; - }else if (te.hasMetal && te.melting > 0) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.metalismelting", te.metal.getDisplayName()) + " (" + (ConfigHandler.INGOT_MELTING_TIME * te.metal.stackSize - te.melting) * 100 / (ConfigHandler.INGOT_MELTING_TIME * te.metal.stackSize) + "%)")); - else if (te.hasMoltenMetal && !isConnectedToMolder(world, i, j, k)) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderismissing"))); - else if (!me.hasMold && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderhasnomold"))); - else if (me.hasMoltenMetal && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderhasmoltenmetal"))); - else if (me.hasJewelBase && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.modlerhasitem"))); - else player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.empty"))); - } - - /** - * Determines if a molder is placed in front of this - * - * @param world - * @param i - * @param j - * @param k - * @return true if a molder is attached, false otherwise - */ - public boolean isConnectedToMolder(World world, int i, int j, int k) - { - int blockMeta = world.getBlockMetadata(i, j, k); - if (blockMeta == 0 && world.getBlock(i, j, k - 1) instanceof BlockMolder) return true; - else if (blockMeta == 1 && world.getBlock(i + 1, j, k) instanceof BlockMolder) return true; - else if (blockMeta == 2 && world.getBlock(i, j, k + 1) instanceof BlockMolder) return true; - else if (blockMeta == 3 && world.getBlock(i - 1, j, k) instanceof BlockMolder) return true; - return false; - } - - @Override - public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack) - { - int rotation = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - world.setBlockMetadataWithNotify(i, j, k, rotation, 2); - } - - @Override - public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) - { - return false; - } - - @Override - public boolean isOpaqueCube() - { - return false; - } - - @Override - public int getRenderType() - { - return -1; - } - - @Override - public void registerBlockIcons(IIconRegister icon) - { - blockIcon = icon.registerIcon(Variables.MODID + ":smelter"); - } -} +package darkknight.jewelrycraft.block; + +import java.io.IOException; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.item.ItemMoltenMetalBucket; +import darkknight.jewelrycraft.network.PacketSendLiquidData; +import darkknight.jewelrycraft.tileentity.TileEntityMolder; +import darkknight.jewelrycraft.tileentity.TileEntitySmelter; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; +import darkknight.jewelrycraft.util.Variables; + +public class BlockSmelter extends BlockContainer +{ + Random rand = new Random(); + + public BlockSmelter() + { + super(Material.rock); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) + { + return new TileEntitySmelter(); + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + /** + * Spawns an item in the world at the specified location + * + * @param world + * @param x + * @param y + * @param z + * @param stack + */ + public void dropItem(World world, double x, double y, double z, ItemStack stack) + { + EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1.3D, z + 0.5D, stack); + entityitem.motionX = 0; + entityitem.motionZ = 0; + entityitem.motionY = 0.11000000298023224D; + entityitem.delayBeforeCanPickup = 0; + world.spawnEntityInWorld(entityitem); + } + + @Override + public void breakBlock(World world, int i, int j, int k, Block par5, int par6) + { + TileEntitySmelter te = (TileEntitySmelter)world.getTileEntity(i, j, k); + if (te != null){ + if (te.hasMetal) dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.metal.copy()); + if (te.hasMoltenMetal && te.moltenMetal != null && Item.getIdFromItem(te.moltenMetal.getItem()) > 0){ + ItemStack metal = te.moltenMetal; + ItemStack item = te.moltenMetal; + if (Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.carpet)) metal.setItemDamage(15 - metal.getItemDamage()); + int color = 16777215; + JewelryNBT.addMetal(item, metal); + try{ + color = ItemMoltenMetalBucket.color(item, 1); + } + catch(IOException e){ + e.printStackTrace(); + } + JewelrycraftMod.saveData.setString(i + " " + j + " " + k + " " + world.provider.dimensionId, Item.getIdFromItem(metal.getItem()) + ":" + metal.getItemDamage() + ":" + color); + JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, i, j, k, Item.getIdFromItem(metal.getItem()), metal.getItemDamage(), color)); + world.setBlock(i, j, k, BlockList.moltenMetal, 0, 3); + int quant = (int)(te.quantity * 10); + if (quant == 1) world.setBlockMetadataWithNotify(i, j, k, 4, 3); + if (quant == 2) world.setBlockMetadataWithNotify(i, j, k, 4, 3); + if (quant == 3) world.setBlockMetadataWithNotify(i, j, k, 3, 3); + if (quant == 4) world.setBlockMetadataWithNotify(i, j, k, 3, 3); + if (quant == 5) world.setBlockMetadataWithNotify(i, j, k, 2, 3); + if (quant == 6) world.setBlockMetadataWithNotify(i, j, k, 2, 3); + if (quant == 7) world.setBlockMetadataWithNotify(i, j, k, 1, 3); + if (quant == 8) world.setBlockMetadataWithNotify(i, j, k, 1, 3); + if (quant == 9) world.setBlockMetadataWithNotify(i, j, k, 0, 3); + } + world.removeTileEntity(i, j, k); + } + super.breakBlock(world, i, j, k, par5, par6); + } + + @Override + public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) + { + TileEntitySmelter te = (TileEntitySmelter)world.getTileEntity(i, j, k); + ItemStack item = entityPlayer.inventory.getCurrentItem(); + if (te != null && te.hasMoltenMetal && te.quantity >= .9f && !te.pouring && item != null && item.getItem() == Items.bucket){ + te.quantity = 0f; + te.hasMoltenMetal = false; + ItemStack metalBucket = new ItemStack(ItemList.bucket, 1); + ItemStack ingot = te.moltenMetal.copy(); + if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage()); + JewelryNBT.addMetal(metalBucket, ingot); + --item.stackSize; + entityPlayer.inventory.addItemStackToInventory(metalBucket); + te.isDirty = true; + return true; + } + if (te != null && !world.isRemote){ + if (te.hasMetal && entityPlayer.isSneaking()){ + dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.metal.copy()); + te.hasMetal = false; + te.melting = -1; + te.isDirty = true; + } + if (item != null && item.getItem() != null && !(item.getItem() instanceof ItemMoltenMetalBucket)){ + int index = -1; + for(int a = 0; a < JewelrycraftUtil.jamcraftPlayers.size(); a++) + if (entityPlayer.getUniqueID().toString().equals(JewelrycraftUtil.jamcraftPlayers.get(a))) index = a; + if(entityPlayer.capabilities.isCreativeMode) index = 1; + boolean canPlace = item != null && (JewelrycraftUtil.isMetal(item) || JewelrycraftUtil.isOre(item) || index >= 0 || JewelryNBT.ingot(item) != null); + boolean isOre = false, oreCoincidesWithMetal = false, itemCoincidesWithMetal = false, itemCoincidesWithMoltenMetal = false, overflow = false; + isOre = JewelrycraftUtil.isOre(item); + if (te.metal != null && te.metal.getItem() != null) { + if(JewelryNBT.ingot(item) == null) itemCoincidesWithMetal = item.getItem().equals(te.metal.getItem()) && item.getItemDamage() == te.metal.getItemDamage(); + else itemCoincidesWithMetal = item.getItem().equals(te.metal.getItem()) && item.getItemDamage() == te.metal.getItemDamage() && JewelryNBT.ingot(item).getItem().equals(JewelryNBT.ingot(te.metal).getItem()) && JewelryNBT.ingot(item).getItemDamage() == JewelryNBT.ingot(te.metal).getItemDamage(); + } + if (te.moltenMetal != null && te.moltenMetal.getItem() != null){ + if(JewelryNBT.ingot(item) == null) itemCoincidesWithMoltenMetal = item.getItem().equals(te.moltenMetal.getItem()) && item.getItemDamage() == te.moltenMetal.getItemDamage(); + else itemCoincidesWithMoltenMetal = JewelryNBT.ingot(item).getItem().equals(te.moltenMetal.getItem()) && JewelryNBT.ingot(item).getItemDamage() == te.moltenMetal.getItemDamage(); + if (isOre) oreCoincidesWithMetal = te.moltenMetal.getItem().equals(JewelrycraftUtil.getIngotFromOre(item).getItem()) && te.moltenMetal.getItemDamage() == JewelrycraftUtil.getIngotFromOre(item).getItemDamage(); + } + overflow = isOre ? te.metal.stackSize * 0.2f + te.quantity < 0.8f : te.metal.stackSize*0.1f + te.quantity < 0.9f; + boolean isValid = te.hasMoltenMetal ? isOre ? oreCoincidesWithMetal : itemCoincidesWithMoltenMetal : true; + if (te.quantity < 0.9f && !te.pouring && canPlace && isValid){ + boolean check = isOre ? oreCoincidesWithMetal && te.quantity < 0.8f : itemCoincidesWithMoltenMetal; + boolean check2 = isOre ? oreCoincidesWithMetal : itemCoincidesWithMetal; + if (!te.hasMetal && !te.hasMoltenMetal || !te.hasMetal && te.hasMoltenMetal && check){ + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.nowsmeltingingot", item.getDisplayName()))); + te.metal = item.copy(); + // if (Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.carpet)) te.metal.setItemDamage(15 - te.metal.getItemDamage()); + te.metal.stackSize = 1; + te.hasMetal = true; + te.melting = ConfigHandler.INGOT_MELTING_TIME; + if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; + te.isDirty = true; + }else if (te.hasMetal && te.hasMoltenMetal && check2 && overflow || te.hasMetal && !te.hasMoltenMetal && itemCoincidesWithMetal && overflow){ + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("Smelting extra " + (isOre ? "ores" : "ingots") + " (" + (te.metal.stackSize + 1) + ")"))); + te.metal.stackSize++; + te.hasMetal = true; + te.melting += ConfigHandler.INGOT_MELTING_TIME; + if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; + te.isDirty = true; + } + te.isDirty = true; + }else if (item != null && (te.hasMetal || te.hasMoltenMetal) && !itemCoincidesWithMoltenMetal && te.quantity < .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.contentdoesnotmatch"))); + else if (item != null && !item.getUnlocalizedName().toLowerCase().contains("ingot") && item.getDisplayName().toLowerCase().contains("ingot") && te.quantity < .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.itemrenamedtoingot"))); + else if (item != null && te.quantity >= .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.full"))); + else entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.cannotsmelt"))); + }else if (item != null && item.getItem() != null && item.getItem() instanceof ItemMoltenMetalBucket && !te.hasMoltenMetal && !te.hasMetal){ + te.hasMoltenMetal = true; + ItemStack ingot = JewelryNBT.ingot(item); + if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage()); + te.moltenMetal = ingot; + te.quantity = .9f; + te.isDirty = true; + if (!entityPlayer.capabilities.isCreativeMode){ + --item.stackSize; + dropItem(world, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, new ItemStack(Items.bucket)); + } + } + else if (item == null && te.hasMoltenMetal && te.moltenMetal.getItem() != null) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.hasmolteningot", te.moltenMetal.getDisplayName().replace(" Ingot","")))); + world.setTileEntity(i, j, k, te); + } + return true; + } + + @Override + public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) + { + TileEntitySmelter te = (TileEntitySmelter)world.getTileEntity(i, j, k); + TileEntityMolder me = null; + if (world.getBlockMetadata(i, j, k) == 0 && world.getTileEntity(i, j, k - 1) != null && world.getTileEntity(i, j, k - 1) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i, j, k - 1); + else if (world.getBlockMetadata(i, j, k) == 1 && world.getTileEntity(i + 1, j, k) != null && world.getTileEntity(i + 1, j, k) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i + 1, j, k); + else if (world.getBlockMetadata(i, j, k) == 2 && world.getTileEntity(i, j, k + 1) != null && world.getTileEntity(i, j, k + 1) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i, j, k + 1); + else if (world.getBlockMetadata(i, j, k) == 3 && world.getTileEntity(i - 1, j, k) != null && world.getTileEntity(i - 1, j, k) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i - 1, j, k); + if (te != null && me != null && !world.isRemote) if (te.hasMoltenMetal && isConnectedToMolder(world, i, j, k) && me != null && me.hasMold && !me.hasMoltenMetal && !me.hasJewelBase){ + te.pouring = true; + te.isDirty = true; + }else if (te.hasMetal && te.melting > 0) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.metalismelting", te.metal.getDisplayName()) + " (" + (ConfigHandler.INGOT_MELTING_TIME * te.metal.stackSize - te.melting) * 100 / (ConfigHandler.INGOT_MELTING_TIME * te.metal.stackSize) + "%)")); + else if (te.hasMoltenMetal && !isConnectedToMolder(world, i, j, k)) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderismissing"))); + else if (!me.hasMold && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderhasnomold"))); + else if (me.hasMoltenMetal && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderhasmoltenmetal"))); + else if (me.hasJewelBase && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.modlerhasitem"))); + else player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.empty"))); + } + + /** + * Determines if a molder is placed in front of this + * + * @param world + * @param i + * @param j + * @param k + * @return true if a molder is attached, false otherwise + */ + public boolean isConnectedToMolder(World world, int i, int j, int k) + { + int blockMeta = world.getBlockMetadata(i, j, k); + if (blockMeta == 0 && world.getBlock(i, j, k - 1) instanceof BlockMolder) return true; + else if (blockMeta == 1 && world.getBlock(i + 1, j, k) instanceof BlockMolder) return true; + else if (blockMeta == 2 && world.getBlock(i, j, k + 1) instanceof BlockMolder) return true; + else if (blockMeta == 3 && world.getBlock(i - 1, j, k) instanceof BlockMolder) return true; + return false; + } + + @Override + public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack) + { + int rotation = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + world.setBlockMetadataWithNotify(i, j, k, rotation, 2); + } + + @Override + public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) + { + return false; + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public int getRenderType() + { + return -1; + } + + @Override + public void registerBlockIcons(IIconRegister icon) + { + blockIcon = icon.registerIcon(Variables.MODID + ":smelter"); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseBlind.java b/src/main/java/darkknight/jewelrycraft/curses/CurseBlind.java index 8716ba9..932e23b 100644 --- a/src/main/java/darkknight/jewelrycraft/curses/CurseBlind.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseBlind.java @@ -1,35 +1,42 @@ -package darkknight.jewelrycraft.curses; - -import darkknight.jewelrycraft.api.Curse; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.util.Variables; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - -public class CurseBlind extends Curse -{ - public CurseBlind(String name, int txtID, String pack) - { - super(name, txtID, pack); - } - - @Override - public void action(World world, EntityPlayer player) - { - if (!player.isPotionActive(Potion.blindness) || player.getActivePotionEffect(Potion.blindness).getDuration() < 30) player.addPotionEffect(new PotionEffect(Potion.blindness.id, 60)); - } - - public String getDescription() - { - return StatCollector.translateToLocal("curse." + Variables.MODID + ".blind.description"); - } - - @Override - public boolean canCurseBeActivated(World world) - { - return world.getWorldInfo().isHardcoreModeEnabled() ? false : ConfigHandler.CURSE_BLIND; - } -} +package darkknight.jewelrycraft.curses; + +import java.util.Random; +import darkknight.jewelrycraft.api.Curse; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.util.Variables; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +public class CurseBlind extends Curse +{ + public CurseBlind(String name, int txtID, String pack) + { + super(name, txtID, pack); + } + + @Override + public void action(World world, EntityPlayer player) + { + if (!player.isPotionActive(Potion.blindness) || player.getActivePotionEffect(Potion.blindness).getDuration() < 30) player.addPotionEffect(new PotionEffect(Potion.blindness.id, 60)); + } + + public String getDescription() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".blind.description"); + } + + @Override + public boolean canCurseBeActivated(World world) + { + return world.getWorldInfo().isHardcoreModeEnabled() ? false : ConfigHandler.CURSE_BLIND; + } + + @Override + public int weight(World world, EntityPlayer player, Random random) + { + return 7; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java b/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java index 90d01ac..c30ca8a 100644 --- a/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java @@ -1,79 +1,79 @@ -package darkknight.jewelrycraft.curses; - -import org.lwjgl.opengl.GL11; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.monster.EntityMob; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; -import net.minecraftforge.client.event.RenderPlayerEvent; -import darkknight.jewelrycraft.api.Curse; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.damage.DamageSourceList; -import darkknight.jewelrycraft.entities.EntityHalfHeart; -import darkknight.jewelrycraft.entities.EntityHeart; -import darkknight.jewelrycraft.entities.renders.RenderHelper; -import darkknight.jewelrycraft.item.render.MaskRender; -import darkknight.jewelrycraft.util.JewelrycraftUtil; -import darkknight.jewelrycraft.util.PlayerUtils; -import darkknight.jewelrycraft.util.Variables; - -public class CurseInfamy extends Curse -{ - public CurseInfamy(String name, int txtID, String pack) - { - super(name, txtID, pack); - } - - @Override - public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) - { - if (rand.nextInt(5) == 0 && !world.isRemote && !(target instanceof EntityMob) && target instanceof EntityLiving && !(target instanceof EntityHeart) && !(target instanceof EntityHalfHeart) && target.canAttackWithItem()){ - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - playerInfo.setFloat("BlackHeart", playerInfo.getFloat("BlackHeart") + 1.0F); - if (player.getMaxHealth() >= 3F){ - player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() - 1.0F); - player.setHealth(player.getHealth() - 1.0F); - } - JewelrycraftUtil.addCursePoints(player, 10); - } - } - - @Override - public void playerRender(EntityPlayer player, RenderPlayerEvent.Specials.Post event) - { - MaskRender mask = new MaskRender(); - float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * event.partialRenderTick; - float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * event.partialRenderTick; - float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * event.partialRenderTick; - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 1); - GL11.glRotatef(yawOffset, 0, -1, 0); - GL11.glRotatef(yaw - 90, 0, 1, 0); - GL11.glRotatef(pitch, 0, 0, -1); - GL11.glRotatef(90F, 0, 1F, 0F); - RenderHelper.translateToHeadLevel(player); - GL11.glScalef(1.6f, 1.6f, 1.6f); - GL11.glTranslatef(-0.25F, -0.25F, -0.25F); - mask.doRender(event.entityPlayer, 0F, 0F, 0F, 0F, 0F); - GL11.glPopMatrix(); - } - - public String getDescription() - { - return StatCollector.translateToLocal("curse." + Variables.MODID + ".infamy.description"); - } - - @Override - public boolean canCurseBeActivated(World world) - { - return ConfigHandler.CURSE_INFAMY; - } -} +package darkknight.jewelrycraft.curses; + +import org.lwjgl.opengl.GL11; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.client.event.RenderPlayerEvent; +import darkknight.jewelrycraft.api.Curse; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.damage.DamageSourceList; +import darkknight.jewelrycraft.entities.EntityHalfHeart; +import darkknight.jewelrycraft.entities.EntityHeart; +import darkknight.jewelrycraft.entities.renders.RenderHelper; +import darkknight.jewelrycraft.item.render.MaskRender; +import darkknight.jewelrycraft.util.JewelrycraftUtil; +import darkknight.jewelrycraft.util.PlayerUtils; +import darkknight.jewelrycraft.util.Variables; + +public class CurseInfamy extends Curse +{ + public CurseInfamy(String name, int txtID, String pack) + { + super(name, txtID, pack); + } + + @Override + public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) + { + if (rand.nextInt(5) == 0 && !world.isRemote && !(target instanceof EntityMob) && target instanceof EntityLiving && !(target instanceof EntityHeart) && !(target instanceof EntityHalfHeart) && target.canAttackWithItem()){ + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + playerInfo.setFloat("BlackHeart", playerInfo.getFloat("BlackHeart") + 1.0F); + if (player.getMaxHealth() >= 3F){ + player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() - 1.0F); + player.setHealth(player.getHealth() - 1.0F); + } + JewelrycraftUtil.addCursePoints(player, 10); + } + } + + @Override + public void playerRender(EntityPlayer player, RenderPlayerEvent.Specials.Post event) + { + MaskRender mask = new MaskRender(); + float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * event.partialRenderTick; + float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * event.partialRenderTick; + float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * event.partialRenderTick; + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 1); + GL11.glRotatef(yawOffset, 0, -1, 0); + GL11.glRotatef(yaw - 90, 0, 1, 0); + GL11.glRotatef(pitch, 0, 0, -1); + GL11.glRotatef(90F, 0, 1F, 0F); + RenderHelper.translateToHeadLevel(player); + GL11.glScalef(1.6f, 1.6f, 1.6f); + GL11.glTranslatef(-0.25F, -0.25F, -0.25F); + mask.doRender(event.entityPlayer, 0F, 0F, 0F, 0F, 0F); + GL11.glPopMatrix(); + } + + public String getDescription() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".infamy.description"); + } + + @Override + public boolean canCurseBeActivated(World world) + { + return ConfigHandler.CURSE_INFAMY; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java b/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java index 688acb6..198a0e0 100644 --- a/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java @@ -1,104 +1,111 @@ -package darkknight.jewelrycraft.curses; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockCompressed; -import net.minecraft.block.BlockPressurePlate; -import net.minecraft.block.BlockPressurePlateWeighted; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemArmor; -import net.minecraft.item.ItemAxe; -import net.minecraft.item.ItemHoe; -import net.minecraft.item.ItemPickaxe; -import net.minecraft.item.ItemSpade; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemSword; -import net.minecraft.util.MathHelper; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; -import darkknight.jewelrycraft.api.Curse; -import darkknight.jewelrycraft.block.BlockList; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.entities.EntityHalfHeart; -import darkknight.jewelrycraft.entities.EntityHeart; -import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.Variables; - -public class CurseMidasTouch extends Curse -{ - public CurseMidasTouch(String name, int txtID, String pack) - { - super(name, txtID, pack); - } - - @Override - public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) - { - if (!world.isRemote && target instanceof EntityLivingBase && !(target instanceof EntityHeart) && !(target instanceof EntityHalfHeart) && player.inventory.getCurrentItem() == null){ - world.setBlock(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ), BlockList.midasTouchBlock, 0, 2); - TileEntityMidasTouch midasTouchVictim = new TileEntityMidasTouch(); - midasTouchVictim.setEntity(target); - world.setTileEntity(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ), midasTouchVictim); - target.setDead(); - } - } - - @Override - public void action(World world, EntityPlayer player) - { - ItemStack curItem = player.inventory.getCurrentItem(); - if(curItem != null && curItem.getItem() != ItemList.goldObj && !isGoldenObject(curItem.getItem())){ - int index = player.inventory.currentItem; - ItemStack item = curItem; - ItemStack result = new ItemStack(ItemList.goldObj, item.stackSize, item.getItemDamage()); - JewelryNBT.addItem(result, item); - if(changeItem(curItem) != null) result = changeItem(curItem); - player.inventory.setInventorySlotContents(index, result); - } - } - - public ItemStack changeItem(ItemStack currItem) - { - if(currItem.getItem() instanceof ItemSword) return new ItemStack(Items.golden_sword, currItem.stackSize, currItem.getItemDamage()); - else if(currItem.getItem() instanceof ItemSpade) return new ItemStack(Items.golden_shovel, currItem.stackSize, currItem.getItemDamage()); - else if(currItem.getItem() instanceof ItemPickaxe) return new ItemStack(Items.golden_pickaxe, currItem.stackSize, currItem.getItemDamage()); - else if(currItem.getItem() instanceof ItemAxe) return new ItemStack(Items.golden_axe, currItem.stackSize, currItem.getItemDamage()); - else if(currItem.getItem() instanceof ItemHoe) return new ItemStack(Items.golden_hoe, currItem.stackSize, currItem.getItemDamage()); - else if(currItem.getItem() instanceof ItemArmor && ((ItemArmor)currItem.getItem()).armorType == 0) return new ItemStack(Items.golden_helmet, currItem.stackSize, currItem.getItemDamage()); - else if(currItem.getItem() instanceof ItemArmor && ((ItemArmor)currItem.getItem()).armorType == 1) return new ItemStack(Items.golden_chestplate, currItem.stackSize, currItem.getItemDamage()); - else if(currItem.getItem() instanceof ItemArmor && ((ItemArmor)currItem.getItem()).armorType == 2) return new ItemStack(Items.golden_leggings, currItem.stackSize, currItem.getItemDamage()); - else if(currItem.getItem() instanceof ItemArmor && ((ItemArmor)currItem.getItem()).armorType == 3) return new ItemStack(Items.golden_boots, currItem.stackSize, currItem.getItemDamage()); - else if(currItem.getItem().getUnlocalizedName().toLowerCase().contains("horsearmor")) return new ItemStack(Items.golden_horse_armor, currItem.stackSize, 0); - else if(currItem.getItem().getUnlocalizedName().toLowerCase().contains("nugget") || currItem.getItem().getItemStackDisplayName(currItem).toLowerCase().contains(" nugget") || currItem.getItem().getItemStackDisplayName(currItem).toLowerCase().contains("nugget ")) return new ItemStack(Items.gold_nugget, currItem.stackSize, 0); - else if(currItem.getItem().getUnlocalizedName().toLowerCase().contains("ingot") || currItem.getItem().getItemStackDisplayName(currItem).toLowerCase().contains(" ingot") || currItem.getItem().getItemStackDisplayName(currItem).toLowerCase().contains("ingot ")) return new ItemStack(Items.gold_ingot, currItem.stackSize, 0); - else if(Block.getBlockFromItem(currItem.getItem()) instanceof BlockPressurePlate || Block.getBlockFromItem(currItem.getItem()) instanceof BlockPressurePlateWeighted) return new ItemStack(Blocks.light_weighted_pressure_plate, currItem.stackSize, 0); - else if(Block.getBlockFromItem(currItem.getItem()) instanceof BlockCompressed) return new ItemStack(Blocks.gold_block, currItem.stackSize, 0); - return null; - } - - public boolean isGoldenObject(Item item) - { - return item.equals(Items.gold_ingot) || item.equals(Items.gold_nugget) || item.equals(Items.golden_helmet) || item.equals(Items.golden_chestplate) || - item.equals(Items.golden_leggings) || item.equals(Items.golden_boots) || item.equals(Items.golden_sword) || item.equals(Items.golden_shovel) || - item.equals(Items.golden_pickaxe) || item.equals(Items.golden_axe) || item.equals(Items.golden_hoe) || item.equals(Items.golden_horse_armor) || - Block.getBlockFromItem(item).equals(Blocks.gold_block) || Block.getBlockFromItem(item).equals(Blocks.light_weighted_pressure_plate); - } - - public String getDescription() - { - return StatCollector.translateToLocal("curse." + Variables.MODID + ".midastouch.description"); - } - - @Override - public boolean canCurseBeActivated(World world) - { - return world.getWorldInfo().isHardcoreModeEnabled() ? false : ConfigHandler.CURSE_MIDAS_TOUCH; - } -} +package darkknight.jewelrycraft.curses; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockCompressed; +import net.minecraft.block.BlockPressurePlate; +import net.minecraft.block.BlockPressurePlateWeighted; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemAxe; +import net.minecraft.item.ItemHoe; +import net.minecraft.item.ItemPickaxe; +import net.minecraft.item.ItemSpade; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import darkknight.jewelrycraft.api.Curse; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.entities.EntityHalfHeart; +import darkknight.jewelrycraft.entities.EntityHeart; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.Variables; + +public class CurseMidasTouch extends Curse +{ + public CurseMidasTouch(String name, int txtID, String pack) + { + super(name, txtID, pack); + } + + @Override + public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) + { + if (!world.isRemote && target instanceof EntityLivingBase && !(target instanceof EntityHeart) && !(target instanceof EntityHalfHeart) && player.inventory.getCurrentItem() == null){ + world.setBlock(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ), BlockList.midasTouchBlock, 0, 2); + TileEntityMidasTouch midasTouchVictim = new TileEntityMidasTouch(); + midasTouchVictim.setEntity(target); + world.setTileEntity(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ), midasTouchVictim); + target.setDead(); + } + } + + @Override + public void action(World world, EntityPlayer player) + { + ItemStack curItem = player.inventory.getCurrentItem(); + if(curItem != null && curItem.getItem() != ItemList.goldObj && !isGoldenObject(curItem.getItem())){ + int index = player.inventory.currentItem; + ItemStack item = curItem; + ItemStack result = new ItemStack(ItemList.goldObj, item.stackSize, item.getItemDamage()); + JewelryNBT.addItem(result, item); + if(changeItem(curItem) != null) result = changeItem(curItem); + player.inventory.setInventorySlotContents(index, result); + } + } + + public ItemStack changeItem(ItemStack currItem) + { + if(currItem.getItem() instanceof ItemSword) return new ItemStack(Items.golden_sword, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemSpade) return new ItemStack(Items.golden_shovel, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemPickaxe) return new ItemStack(Items.golden_pickaxe, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemAxe) return new ItemStack(Items.golden_axe, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemHoe) return new ItemStack(Items.golden_hoe, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemArmor && ((ItemArmor)currItem.getItem()).armorType == 0) return new ItemStack(Items.golden_helmet, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemArmor && ((ItemArmor)currItem.getItem()).armorType == 1) return new ItemStack(Items.golden_chestplate, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemArmor && ((ItemArmor)currItem.getItem()).armorType == 2) return new ItemStack(Items.golden_leggings, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemArmor && ((ItemArmor)currItem.getItem()).armorType == 3) return new ItemStack(Items.golden_boots, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem().getUnlocalizedName().toLowerCase().contains("horsearmor")) return new ItemStack(Items.golden_horse_armor, currItem.stackSize, 0); + else if(currItem.getItem().getUnlocalizedName().toLowerCase().contains("nugget") || currItem.getItem().getItemStackDisplayName(currItem).toLowerCase().contains(" nugget") || currItem.getItem().getItemStackDisplayName(currItem).toLowerCase().contains("nugget ")) return new ItemStack(Items.gold_nugget, currItem.stackSize, 0); + else if(currItem.getItem().getUnlocalizedName().toLowerCase().contains("ingot") || currItem.getItem().getItemStackDisplayName(currItem).toLowerCase().contains(" ingot") || currItem.getItem().getItemStackDisplayName(currItem).toLowerCase().contains("ingot ")) return new ItemStack(Items.gold_ingot, currItem.stackSize, 0); + else if(Block.getBlockFromItem(currItem.getItem()) instanceof BlockPressurePlate || Block.getBlockFromItem(currItem.getItem()) instanceof BlockPressurePlateWeighted) return new ItemStack(Blocks.light_weighted_pressure_plate, currItem.stackSize, 0); + else if(Block.getBlockFromItem(currItem.getItem()) instanceof BlockCompressed) return new ItemStack(Blocks.gold_block, currItem.stackSize, 0); + return null; + } + + public boolean isGoldenObject(Item item) + { + return item.equals(Items.gold_ingot) || item.equals(Items.gold_nugget) || item.equals(Items.golden_helmet) || item.equals(Items.golden_chestplate) || + item.equals(Items.golden_leggings) || item.equals(Items.golden_boots) || item.equals(Items.golden_sword) || item.equals(Items.golden_shovel) || + item.equals(Items.golden_pickaxe) || item.equals(Items.golden_axe) || item.equals(Items.golden_hoe) || item.equals(Items.golden_horse_armor) || + Block.getBlockFromItem(item).equals(Blocks.gold_block) || Block.getBlockFromItem(item).equals(Blocks.light_weighted_pressure_plate); + } + + public String getDescription() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".midastouch.description"); + } + + @Override + public boolean canCurseBeActivated(World world) + { + return world.getWorldInfo().isHardcoreModeEnabled() ? false : ConfigHandler.CURSE_MIDAS_TOUCH; + } + + @Override + public int weight(World world, EntityPlayer player, Random random) + { + return 2; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseRabbitsPaw.java b/src/main/java/darkknight/jewelrycraft/curses/CurseRabbitsPaw.java index 1c26558..b675954 100644 --- a/src/main/java/darkknight/jewelrycraft/curses/CurseRabbitsPaw.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseRabbitsPaw.java @@ -1,73 +1,73 @@ -/** - * - */ -package darkknight.jewelrycraft.curses; - -import java.util.ArrayList; -import darkknight.jewelrycraft.api.Curse; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.entities.EntityHalfHeart; -import darkknight.jewelrycraft.entities.EntityHeart; -import darkknight.jewelrycraft.util.JewelrycraftUtil; -import darkknight.jewelrycraft.util.Variables; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.item.EntityXPOrb; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.MathHelper; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - -public class CurseRabbitsPaw extends Curse -{ - public CurseRabbitsPaw(String name, int txtID, String pack) - { - super(name, txtID, pack); - } - - @Override - public void entityDropItems(EntityPlayer player, Entity target, ArrayList drops) - { - for(EntityItem item: drops){ - ItemStack drop = item.getEntityItem().copy(); - drop.stackSize = this.rand.nextInt(4); - if (drop.stackSize > 0) target.entityDropItem(drop, 0.5F); - } - } - - public void entityDeathAction(World world, EntityLivingBase target, EntityPlayer player) - { - String[] types = {"Red", "Blue", "White", "Black"}; - String type = types[rand.nextInt(4)]; - if (rand.nextInt(3) == 0 && target.getCreatureAttribute() != JewelrycraftUtil.HEART){ - if (type == "White"){ - EntityHeart h = new EntityHalfHeart(world); - h.setType(type); - h.setLocationAndAngles(target.posX, target.posY, target.posZ, MathHelper.wrapAngleTo180_float(rand.nextFloat() * 360.0F), 0.0F); - world.spawnEntityInWorld(h); - }else{ - for(int i = 1; i <= 1 + rand.nextInt(1 + (int)(target.getMaxHealth() / 20)); i++){ - EntityHeart[] hearts = {new EntityHeart(world), new EntityHalfHeart(world)}; - EntityHeart h = hearts[rand.nextInt(2)]; - h.setType(type); - h.setLocationAndAngles(target.posX, target.posY, target.posZ, MathHelper.wrapAngleTo180_float(rand.nextFloat() * 360.0F), 0.0F); - world.spawnEntityInWorld(h); - } - } - } - if (rand.nextInt(3) == 0) world.spawnEntityInWorld(new EntityXPOrb(world, target.posX, target.posY, target.posZ, 1 + rand.nextInt(40))); - } - - public String getDescription() - { - return StatCollector.translateToLocal("curse." + Variables.MODID + ".rabbitspaw.description"); - } - - @Override - public boolean canCurseBeActivated(World world) - { - return ConfigHandler.CURSE_RABBIT_PAW; - } -} +/** + * + */ +package darkknight.jewelrycraft.curses; + +import java.util.ArrayList; +import darkknight.jewelrycraft.api.Curse; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.entities.EntityHalfHeart; +import darkknight.jewelrycraft.entities.EntityHeart; +import darkknight.jewelrycraft.util.JewelrycraftUtil; +import darkknight.jewelrycraft.util.Variables; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +public class CurseRabbitsPaw extends Curse +{ + public CurseRabbitsPaw(String name, int txtID, String pack) + { + super(name, txtID, pack); + } + + @Override + public void entityDropItems(EntityPlayer player, Entity target, ArrayList drops) + { + for(EntityItem item: drops){ + ItemStack drop = item.getEntityItem().copy(); + drop.stackSize = this.rand.nextInt(4); + if (drop.stackSize > 0) target.entityDropItem(drop, 0.5F); + } + } + + public void entityDeathAction(World world, EntityLivingBase target, EntityPlayer player) + { + String[] types = {"Red", "Blue", "White", "Black"}; + String type = types[rand.nextInt(4)]; + if (rand.nextInt(3) == 0 && target.getCreatureAttribute() != JewelrycraftUtil.HEART){ + if (type == "White"){ + EntityHeart h = new EntityHalfHeart(world); + h.setType(type); + h.setLocationAndAngles(target.posX, target.posY, target.posZ, MathHelper.wrapAngleTo180_float(rand.nextFloat() * 360.0F), 0.0F); + world.spawnEntityInWorld(h); + }else{ + for(int i = 1; i <= 1 + rand.nextInt(1 + (int)(target.getMaxHealth() / 20)); i++){ + EntityHeart[] hearts = {new EntityHeart(world), new EntityHalfHeart(world)}; + EntityHeart h = hearts[rand.nextInt(2)]; + h.setType(type); + h.setLocationAndAngles(target.posX, target.posY, target.posZ, MathHelper.wrapAngleTo180_float(rand.nextFloat() * 360.0F), 0.0F); + world.spawnEntityInWorld(h); + } + } + } + if (rand.nextInt(3) == 0) world.spawnEntityInWorld(new EntityXPOrb(world, target.posX, target.posY, target.posZ, 1 + rand.nextInt(40))); + } + + public String getDescription() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".rabbitspaw.description"); + } + + @Override + public boolean canCurseBeActivated(World world) + { + return ConfigHandler.CURSE_RABBIT_PAW; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java b/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java index 1ddc364..17db979 100644 --- a/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java +++ b/src/main/java/darkknight/jewelrycraft/effects/EffectBlazePowder.java @@ -1,85 +1,82 @@ -package darkknight.jewelrycraft.effects; - -import net.minecraft.block.material.Material; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; -import darkknight.jewelrycraft.api.ModifierEffects; -import darkknight.jewelrycraft.item.ItemBracelet; -import darkknight.jewelrycraft.item.ItemEarrings; -import darkknight.jewelrycraft.item.ItemNecklace; -import darkknight.jewelrycraft.item.ItemRing; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.PlayerUtils; -import darkknight.jewelrycraft.util.Variables; - -public class EffectBlazePowder extends ModifierEffects -{ - public EffectBlazePowder() - { - super(new ItemStack(Items.blaze_powder)); - } - - @Override - public void action(ItemStack item, EntityPlayer player, Item jewelry) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - if (jewelry instanceof ItemNecklace && exists){ - // Positive for necklace - if (player.isBurning() && rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0) player.extinguish(); - // Negative for necklace - if (player.isInWater()) player.attackEntityFrom(DamageSource.drown, 1f + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F); - } - // Negative for bracelet - if (jewelry instanceof ItemBracelet && exists && player.isInWater()){ - double slowAmount = 0.6D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.05D; - player.motionX *= slowAmount; - player.motionY *= slowAmount; - player.motionZ *= slowAmount; - player.motionY -= (0.02D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.005D); - if (player.isCollidedHorizontally) player.motionY = 0.30000001192092896D; - } - // Negative for earrings - if (jewelry instanceof ItemEarrings && exists){ - if (player.getAir() >= 300) player.setAir(player.getAir() / 2); - else player.setAir(player.getAir() - JewelryNBT.numberOfModifiers(item)); - } - } - - @Override - public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - // Balanced for ring - if (jewelry instanceof ItemRing && exists && !player.isInWater() && rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0) target.setFire(2); - return false; - } - - @Override - public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) - { - return false; - } - - public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) - {} - - public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - if (jewelry instanceof ItemEarrings && exists && rand.nextInt(4) == 0) if (source == DamageSource.lava || source == DamageSource.inFire || source == DamageSource.onFire){ - // Positive for earrings - int stackSize = JewelryNBT.modifierSize(item, modifier); - player.heal(stackSize*0.05F - (JewelryNBT.numberOfModifiers(item) - 1)*0.01F); - playerInfo.setBoolean("negateDamage", true); - } - // Positive for bracelet - if (jewelry instanceof ItemBracelet && exists) if (source == DamageSource.inFire || source == DamageSource.onFire || source == DamageSource.lava && player.worldObj.isMaterialInBB(AxisAlignedBB.getBoundingBox(player.boundingBox.minX, player.boundingBox.minY, player.boundingBox.minZ, player.boundingBox.maxX, player.boundingBox.maxY - 0.7, player.boundingBox.maxZ), Material.lava) && !player.worldObj.isMaterialInBB(AxisAlignedBB.getBoundingBox(player.boundingBox.minX, player.boundingBox.minY + 0.9, player.boundingBox.minZ, player.boundingBox.maxX, player.boundingBox.maxY, player.boundingBox.maxZ), Material.lava)) playerInfo.setBoolean("negateDamage", true); - } -} +package darkknight.jewelrycraft.effects; + +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import darkknight.jewelrycraft.api.ModifierEffects; +import darkknight.jewelrycraft.item.ItemBracelet; +import darkknight.jewelrycraft.item.ItemEarrings; +import darkknight.jewelrycraft.item.ItemNecklace; +import darkknight.jewelrycraft.item.ItemRing; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.PlayerUtils; +import darkknight.jewelrycraft.util.Variables; + +public class EffectBlazePowder extends ModifierEffects +{ + public EffectBlazePowder() + { + super(new ItemStack(Items.blaze_powder)); + } + + @Override + public void action(ItemStack item, EntityPlayer player, Item jewelry) + { + if (jewelry instanceof ItemNecklace){ + // Positive for necklace + if (player.isBurning() && rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0) player.extinguish(); + // Negative for necklace + if (player.isInWater()) player.attackEntityFrom(DamageSource.drown, 1f + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F); + } + // Negative for bracelet + if (jewelry instanceof ItemBracelet && player.isInWater()){ + double slowAmount = 0.6D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.05D; + player.motionX *= slowAmount; + player.motionY *= slowAmount; + player.motionZ *= slowAmount; + player.motionY -= (0.02D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.005D); + if (player.isCollidedHorizontally) player.motionY = 0.30000001192092896D; + } + // Negative for earrings + if (jewelry instanceof ItemEarrings){ + if (player.getAir() >= 300) player.setAir(player.getAir() / 2); + else player.setAir(player.getAir() - JewelryNBT.numberOfModifiers(item)); + } + } + + @Override + public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) + { + // Balanced for ring + if (jewelry instanceof ItemRing && !player.isInWater() && rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0) target.setFire(2); + return false; + } + + @Override + public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) + { + return false; + } + + public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) + {} + + public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) + { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + if (jewelry instanceof ItemEarrings && rand.nextInt(4) == 0) if (source == DamageSource.lava || source == DamageSource.inFire || source == DamageSource.onFire){ + // Positive for earrings + int stackSize = JewelryNBT.modifierSize(item, modifier); + player.heal(stackSize*0.05F - (JewelryNBT.numberOfModifiers(item) - 1)*0.01F); + playerInfo.setBoolean("negateDamage", true); + } + // Positive for bracelet + if (jewelry instanceof ItemBracelet) if (source == DamageSource.inFire || source == DamageSource.onFire || source == DamageSource.lava && player.worldObj.isMaterialInBB(AxisAlignedBB.getBoundingBox(player.boundingBox.minX, player.boundingBox.minY, player.boundingBox.minZ, player.boundingBox.maxX, player.boundingBox.maxY - 0.7, player.boundingBox.maxZ), Material.lava) && !player.worldObj.isMaterialInBB(AxisAlignedBB.getBoundingBox(player.boundingBox.minX, player.boundingBox.minY + 0.9, player.boundingBox.minZ, player.boundingBox.maxX, player.boundingBox.maxY, player.boundingBox.maxZ), Material.lava)) playerInfo.setBoolean("negateDamage", true); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java index afaa376..4457961 100644 --- a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java +++ b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderEye.java @@ -1,90 +1,88 @@ -package darkknight.jewelrycraft.effects; - -import net.minecraft.block.BlockOre; -import net.minecraft.client.Minecraft; -import net.minecraft.client.settings.GameSettings.Options; -import net.minecraft.entity.monster.EntityEnderman; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.DamageSource; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; -import net.minecraft.util.Vec3; -import net.minecraft.world.ChunkPosition; -import net.minecraft.world.biome.BiomeGenBase; -import cpw.mods.fml.relauncher.ReflectionHelper; -import darkknight.jewelrycraft.api.ModifierEffects; -import darkknight.jewelrycraft.item.ItemBracelet; -import darkknight.jewelrycraft.item.ItemEarrings; -import darkknight.jewelrycraft.item.ItemNecklace; -import darkknight.jewelrycraft.item.ItemRing; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.Variables; - -public class EffectEnderEye extends ModifierEffects -{ - private boolean originalVD = false; - private float originalViewDistance; - - public EffectEnderEye() - { - super(new ItemStack(Items.ender_eye)); - } - - @Override - public void action(ItemStack item, EntityPlayer player, Item jewelry) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - if (jewelry instanceof ItemEarrings && exists && !player.worldObj.isRemote){ - for(Object e: player.worldObj.getEntitiesWithinAABB(EntityEnderman.class, player.boundingBox.expand(100D, 0D, 100D))){ - EntityEnderman enderman = (EntityEnderman)e; - ReflectionHelper.setPrivateValue(EntityEnderman.class, enderman, -1, "stareTimer", "field_70826_g"); - Vec3 vec3 = player.getLook(1.0F).normalize(); - Vec3 vec31 = Vec3.createVectorHelper(enderman.posX - player.posX, enderman.boundingBox.minY + (double)(enderman.height / 2.0F) - (player.posY + (double)player.getEyeHeight()), enderman.posZ - player.posZ); - double d0 = vec31.lengthVector(); - vec31 = vec31.normalize(); - double d1 = vec3.dotProduct(vec31); - if (d1 > 1.0D - 0.025D / d0 && player.canEntityBeSeen(enderman)){ - // Positive earrings - if (rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0) enderman.setTarget(null); - // Negative earrings - if (!player.isPotionActive(Potion.confusion) || player.getActivePotionEffect(Potion.confusion).getDuration() <= 80) player.addPotionEffect(new PotionEffect(Potion.confusion.id, 300, 2 + JewelryNBT.numberOfModifiers(item) / 4)); - } - } - } - // Positive necklace - if (jewelry instanceof ItemNecklace && exists && !player.worldObj.isRemote){ - ChunkPosition chunkposition = player.worldObj.findClosestStructure("Stronghold", (int)player.posX, (int)player.posY, (int)player.posZ); - if (chunkposition != null){ - Minecraft.getMinecraft().thePlayer.motionX += 0.01D * Math.signum((double)chunkposition.chunkPosX - player.posX) * (rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0 ? 1 : -1); - Minecraft.getMinecraft().thePlayer.motionZ += 0.01D * Math.signum((double)chunkposition.chunkPosZ - player.posZ) * (rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0 ? 1 : -1); - } - } - // Positive bracelet - if (jewelry instanceof ItemBracelet && exists && !player.worldObj.isRemote && player.worldObj.getBiomeGenForCoords((int)player.posX, (int)player.posZ) == BiomeGenBase.sky && (!player.isPotionActive(Potion.moveSpeed) || player.getActivePotionEffect(Potion.moveSpeed).getDuration() < 30)) player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 150 - JewelryNBT.numberOfModifiers(item) * 10, 2 - JewelryNBT.numberOfModifiers(item) / 5)); - // Negative bracelet - if (jewelry instanceof ItemBracelet && exists && !player.worldObj.isRemote && rand.nextInt(520 - JewelryNBT.numberOfModifiers(item) * 20) == 15) player.setPositionAndUpdate(player.posX + rand.nextInt(30) * (rand.nextBoolean() ? -1 : 1), player.posY, player.posZ + rand.nextInt(30) * (rand.nextBoolean() ? -1 : 1)); - // Negative ring - if (jewelry instanceof ItemRing && exists) Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.RENDER_DISTANCE, 2.2F - JewelryNBT.numberOfModifiers(item) * 0.1F); - // Positive ring - if (jewelry instanceof ItemRing && exists && rand.nextInt(180 + JewelryNBT.numberOfModifiers(item)*20) == 12){ - for(int i = (int)player.posX - 2; i <= (int)player.posX + 2; i++) - for(int j = (int)player.posY - 2; j <= (int)player.posY + 2; j++) - for(int k = (int)player.posZ - 2; k <= (int)player.posZ + 2; k++) - if (player.worldObj.getBlock(i, j, k) instanceof BlockOre) player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GRAY + StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".effect.endereye.1")+" " + player.worldObj.getBlock(i, j, k).getLocalizedName() + " "+StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".effect.endereye.2"))); - } - } - - @Override - public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - // Negative necklace - if (jewelry instanceof ItemNecklace && exists && !player.worldObj.isRemote) player.addPotionEffect(new PotionEffect(Potion.blindness.id, 100 + JewelryNBT.numberOfModifiers(item)*30, 1)); - } -} +package darkknight.jewelrycraft.effects; + +import net.minecraft.block.BlockOre; +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.GameSettings.Options; +import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.util.Vec3; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.biome.BiomeGenBase; +import cpw.mods.fml.relauncher.ReflectionHelper; +import darkknight.jewelrycraft.api.ModifierEffects; +import darkknight.jewelrycraft.item.ItemBracelet; +import darkknight.jewelrycraft.item.ItemEarrings; +import darkknight.jewelrycraft.item.ItemNecklace; +import darkknight.jewelrycraft.item.ItemRing; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.Variables; + +public class EffectEnderEye extends ModifierEffects +{ + private boolean originalVD = false; + private float originalViewDistance; + + public EffectEnderEye() + { + super(new ItemStack(Items.ender_eye)); + } + + @Override + public void action(ItemStack item, EntityPlayer player, Item jewelry) + { + if (jewelry instanceof ItemEarrings && !player.worldObj.isRemote){ + for(Object e: player.worldObj.getEntitiesWithinAABB(EntityEnderman.class, player.boundingBox.expand(100D, 0D, 100D))){ + EntityEnderman enderman = (EntityEnderman)e; + ReflectionHelper.setPrivateValue(EntityEnderman.class, enderman, -1, "stareTimer", "field_70826_g"); + Vec3 vec3 = player.getLook(1.0F).normalize(); + Vec3 vec31 = Vec3.createVectorHelper(enderman.posX - player.posX, enderman.boundingBox.minY + (double)(enderman.height / 2.0F) - (player.posY + (double)player.getEyeHeight()), enderman.posZ - player.posZ); + double d0 = vec31.lengthVector(); + vec31 = vec31.normalize(); + double d1 = vec3.dotProduct(vec31); + if (d1 > 1.0D - 0.025D / d0 && player.canEntityBeSeen(enderman)){ + // Positive earrings + if (rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0) enderman.setTarget(null); + // Negative earrings + if (!player.isPotionActive(Potion.confusion) || player.getActivePotionEffect(Potion.confusion).getDuration() <= 80) player.addPotionEffect(new PotionEffect(Potion.confusion.id, 300, 2 + JewelryNBT.numberOfModifiers(item) / 4)); + } + } + } + // Positive necklace + if (jewelry instanceof ItemNecklace && !player.worldObj.isRemote){ + ChunkPosition chunkposition = player.worldObj.findClosestStructure("Stronghold", (int)player.posX, (int)player.posY, (int)player.posZ); + if (chunkposition != null){ + Minecraft.getMinecraft().thePlayer.motionX += 0.01D * Math.signum((double)chunkposition.chunkPosX - player.posX) * (rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0 ? 1 : -1); + Minecraft.getMinecraft().thePlayer.motionZ += 0.01D * Math.signum((double)chunkposition.chunkPosZ - player.posZ) * (rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0 ? 1 : -1); + } + } + // Positive bracelet + if (jewelry instanceof ItemBracelet && !player.worldObj.isRemote && player.worldObj.getBiomeGenForCoords((int)player.posX, (int)player.posZ) == BiomeGenBase.sky && (!player.isPotionActive(Potion.moveSpeed) || player.getActivePotionEffect(Potion.moveSpeed).getDuration() < 30)) player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 150 - JewelryNBT.numberOfModifiers(item) * 10, 2 - JewelryNBT.numberOfModifiers(item) / 5)); + // Negative bracelet + if (jewelry instanceof ItemBracelet && !player.worldObj.isRemote && rand.nextInt(520 - JewelryNBT.numberOfModifiers(item) * 20) == 15) player.setPositionAndUpdate(player.posX + rand.nextInt(30) * (rand.nextBoolean() ? -1 : 1), player.posY, player.posZ + rand.nextInt(30) * (rand.nextBoolean() ? -1 : 1)); + // Negative ring + if (jewelry instanceof ItemRing) Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.RENDER_DISTANCE, 2.2F - JewelryNBT.numberOfModifiers(item) * 0.1F); + // Positive ring + if (jewelry instanceof ItemRing && rand.nextInt(180 + JewelryNBT.numberOfModifiers(item)*20) == 12){ + for(int i = (int)player.posX - 2; i <= (int)player.posX + 2; i++) + for(int j = (int)player.posY - 2; j <= (int)player.posY + 2; j++) + for(int k = (int)player.posZ - 2; k <= (int)player.posZ + 2; k++) + if (player.worldObj.getBlock(i, j, k) instanceof BlockOre) player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GRAY + StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".effect.endereye.1")+" " + player.worldObj.getBlock(i, j, k).getLocalizedName() + " "+StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".effect.endereye.2"))); + } + } + + @Override + public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) + { + // Negative necklace + if (jewelry instanceof ItemNecklace && !player.worldObj.isRemote) player.addPotionEffect(new PotionEffect(Potion.blindness.id, 100 + JewelryNBT.numberOfModifiers(item)*30, 1)); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java index 531a1c1..0ea08c7 100644 --- a/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java +++ b/src/main/java/darkknight/jewelrycraft/effects/EffectEnderPearl.java @@ -1,95 +1,92 @@ -package darkknight.jewelrycraft.effects; - -import java.util.Iterator; -import java.util.List; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityTNTPrimed; -import net.minecraft.entity.monster.EntityEnderman; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; -import darkknight.jewelrycraft.api.ModifierEffects; -import darkknight.jewelrycraft.item.ItemBracelet; -import darkknight.jewelrycraft.item.ItemEarrings; -import darkknight.jewelrycraft.item.ItemNecklace; -import darkknight.jewelrycraft.item.ItemRing; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.PlayerUtils; -import darkknight.jewelrycraft.util.Variables; - -public class EffectEnderPearl extends ModifierEffects -{ - public EffectEnderPearl() - { - super(new ItemStack(Items.ender_pearl)); - } - - @Override - public void action(ItemStack item, EntityPlayer player, Item jewelry) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - if (jewelry instanceof ItemEarrings && exists){ - AxisAlignedBB axisalignedbb = player.boundingBox.expand(2.0D, 2.0D, 2.0D); - List list = player.worldObj.getEntitiesWithinAABB(EntityArrow.class, axisalignedbb); - if (!player.worldObj.isRemote && list != null && !list.isEmpty()){ - Iterator iterator = list.iterator(); - while (iterator.hasNext()){ - EntityArrow arrow = (EntityArrow)iterator.next(); - if (arrow.shootingEntity == null || !(arrow.shootingEntity.equals(player))) - // Negative earrings - if (rand.nextInt(30) == 0){ - arrow.worldObj.createExplosion(new EntityTNTPrimed(arrow.worldObj), arrow.posX, arrow.posY, arrow.posZ, 2F, true); - arrow.setDead(); - } - // Positive earrings - else arrow.setPosition(arrow.posX + rand.nextInt(16) - rand.nextInt(16), arrow.posY + rand.nextInt(16), arrow.posZ + rand.nextInt(16) - rand.nextInt(16)); - } - } - } - // Negative Necklace - if (jewelry instanceof ItemNecklace && exists) player.addPotionEffect(new PotionEffect(Potion.resistance.id, 60, -10, true)); - // Negative bracelet - if (jewelry instanceof ItemBracelet && exists && player.isInWater()) player.setPositionAndUpdate(player.posX + rand.nextInt(16) - rand.nextInt(16), player.posY + rand.nextInt(4), player.posZ + rand.nextInt(16) - rand.nextInt(16)); - } - - @Override - public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - // Positive Necklace - if (jewelry instanceof ItemNecklace && exists && source.getEntity() != null) source.getEntity().attackEntityFrom(source, amount); - // Positive bracelet - if (jewelry instanceof ItemBracelet && exists && !player.worldObj.isRemote){ - int id = player.worldObj.provider.dimensionId; - if (player.getHealth() <= 6F) if (player.getBedLocation(id) != null) player.setPositionAndUpdate(player.getBedLocation(id).posX, player.getBedLocation(id).posY, player.getBedLocation(id).posZ); - else player.setPositionAndUpdate(player.worldObj.getSpawnPoint().posX, player.worldObj.getSpawnPoint().posY, player.worldObj.getSpawnPoint().posZ); - } - } - - public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - NBTTagCompound enemyData = target.getEntityData(); - if (jewelry instanceof ItemRing && exists){ - // Negative ring - if (target instanceof EntityEnderman) player.addPotionEffect(new PotionEffect(Potion.weakness.id, 400, 2, true)); - // Positive ring - else target.setPosition(target.posX + rand.nextInt(16) - rand.nextInt(16), target.posY + rand.nextInt(4), target.posZ + rand.nextInt(16) - rand.nextInt(16)); - } - } - - public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) - { - return false; - } -} +package darkknight.jewelrycraft.effects; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import darkknight.jewelrycraft.api.ModifierEffects; +import darkknight.jewelrycraft.item.ItemBracelet; +import darkknight.jewelrycraft.item.ItemEarrings; +import darkknight.jewelrycraft.item.ItemNecklace; +import darkknight.jewelrycraft.item.ItemRing; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.PlayerUtils; +import darkknight.jewelrycraft.util.Variables; + +public class EffectEnderPearl extends ModifierEffects +{ + public EffectEnderPearl() + { + super(new ItemStack(Items.ender_pearl)); + } + + @Override + public void action(ItemStack item, EntityPlayer player, Item jewelry) + { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + if (jewelry instanceof ItemEarrings){ + AxisAlignedBB axisalignedbb = player.boundingBox.expand(2.0D, 2.0D, 2.0D); + List list = player.worldObj.getEntitiesWithinAABB(EntityArrow.class, axisalignedbb); + if (!player.worldObj.isRemote && list != null && !list.isEmpty()){ + Iterator iterator = list.iterator(); + while (iterator.hasNext()){ + EntityArrow arrow = (EntityArrow)iterator.next(); + if (arrow.shootingEntity == null || !(arrow.shootingEntity.equals(player))) + // Negative earrings + if (rand.nextInt(30) == 0){ + arrow.worldObj.createExplosion(new EntityTNTPrimed(arrow.worldObj), arrow.posX, arrow.posY, arrow.posZ, 2F, true); + arrow.setDead(); + } + // Positive earrings + else arrow.setPosition(arrow.posX + rand.nextInt(16) - rand.nextInt(16), arrow.posY + rand.nextInt(16), arrow.posZ + rand.nextInt(16) - rand.nextInt(16)); + } + } + } + // Negative Necklace + if (jewelry instanceof ItemNecklace) player.addPotionEffect(new PotionEffect(Potion.resistance.id, 60, -10, true)); + // Negative bracelet + if (jewelry instanceof ItemBracelet && player.isInWater()) player.setPositionAndUpdate(player.posX + rand.nextInt(16) - rand.nextInt(16), player.posY + rand.nextInt(4), player.posZ + rand.nextInt(16) - rand.nextInt(16)); + } + + @Override + public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) + { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + // Positive Necklace + if (jewelry instanceof ItemNecklace && source.getEntity() != null) source.getEntity().attackEntityFrom(source, amount); + // Positive bracelet + if (jewelry instanceof ItemBracelet && !player.worldObj.isRemote){ + int id = player.worldObj.provider.dimensionId; + if (player.getHealth() <= 6F) if (player.getBedLocation(id) != null) player.setPositionAndUpdate(player.getBedLocation(id).posX, player.getBedLocation(id).posY, player.getBedLocation(id).posZ); + else player.setPositionAndUpdate(player.worldObj.getSpawnPoint().posX, player.worldObj.getSpawnPoint().posY, player.worldObj.getSpawnPoint().posZ); + } + } + + public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) + { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + NBTTagCompound enemyData = target.getEntityData(); + if (jewelry instanceof ItemRing){ + // Negative ring + if (target instanceof EntityEnderman) player.addPotionEffect(new PotionEffect(Potion.weakness.id, 400, 2, true)); + // Positive ring + else target.setPosition(target.posX + rand.nextInt(16) - rand.nextInt(16), target.posY + rand.nextInt(4), target.posZ + rand.nextInt(16) - rand.nextInt(16)); + } + } + + public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) + { + return false; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java b/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java index aa427b1..d0a48d5 100644 --- a/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java +++ b/src/main/java/darkknight/jewelrycraft/effects/EffectFeather.java @@ -1,98 +1,95 @@ -package darkknight.jewelrycraft.effects; - -import java.util.Iterator; -import java.util.List; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.DamageSource; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; -import darkknight.jewelrycraft.api.ModifierEffects; -import darkknight.jewelrycraft.damage.DamageSourceList; -import darkknight.jewelrycraft.item.ItemBracelet; -import darkknight.jewelrycraft.item.ItemEarrings; -import darkknight.jewelrycraft.item.ItemNecklace; -import darkknight.jewelrycraft.item.ItemRing; -import darkknight.jewelrycraft.potions.PotionList; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.PlayerUtils; -import darkknight.jewelrycraft.util.Variables; - -public class EffectFeather extends ModifierEffects -{ - public EffectFeather() - { - super(new ItemStack(Items.feather)); - } - - @Override - public void action(ItemStack item, EntityPlayer player, Item jewelry) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - // Positive earrings - if (jewelry instanceof ItemEarrings && exists){ - AxisAlignedBB axisalignedbb = player.boundingBox.expand(1.0D, 1.0D, 1.0D); - List list = player.worldObj.getEntitiesWithinAABB(EntityArrow.class, axisalignedbb); - if (!player.worldObj.isRemote && list != null && !list.isEmpty()){ - Iterator iterator = list.iterator(); - while (iterator.hasNext()){ - EntityArrow arrow = (EntityArrow)iterator.next(); - if ((arrow.shootingEntity == null || !(arrow.shootingEntity.equals(player)) || arrow.canBePickedUp == 0) && rand.nextInt(2 + JewelryNBT.numberOfModifiers(item)) == 0) arrow.setDead(); - } - } - } - if (jewelry instanceof ItemBracelet && exists){ - // Positive bracelet - if (player.motionY < 0) player.motionY *= (0.6D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.03D); - if (rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0) player.fallDistance = 0F; - // Negative bracelet - if (!player.isPotionActive(Potion.moveSlowdown) || player.getActivePotionEffect(Potion.moveSlowdown).getDuration() < 30) player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 80 + JewelryNBT.numberOfModifiers(item) * 10, 1 + JewelryNBT.numberOfModifiers(item) / 4)); - } - } - - @Override - public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - NBTTagCompound enemyData = target.getEntityData(); - if (jewelry instanceof ItemRing && exists){ - if (enemyData.getInteger("reAttacked") == 0){ - // Negative ring - enemyData.setInteger("reAttacked", enemyData.getInteger("reAttacked") + 1); - target.attackEntityFrom(DamageSource.causePlayerDamage(player), amount / (2F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F)); - // Positive ring - if (rand.nextInt(2) == 0 && target instanceof EntityLivingBase) ((EntityLivingBase)target).addPotionEffect(new PotionEffect(PotionList.stun.id, (51 - JewelryNBT.numberOfModifiers(item))*2, 0, false)); - playerInfo.setBoolean("weakDamage", true); - } - if (enemyData.getInteger("reAttacked") == 1) enemyData.setInteger("reAttacked", 0); - } - } - - @Override - public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - // Positive necklace - if (jewelry instanceof ItemNecklace && exists && rand.nextInt(3 + JewelryNBT.numberOfModifiers(item)) == 0 && source != DamageSourceList.weak && source != DamageSource.inFire && source != DamageSource.onFire && source != DamageSource.lava){ - player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GRAY + StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".effect.feather"))); - playerInfo.setBoolean("negateDamage", true); - } - // Negative necklace - if (jewelry instanceof ItemNecklace && exists && (source == DamageSource.inFire || source == DamageSource.onFire || source == DamageSource.lava) && source != DamageSourceList.weak) player.attackEntityFrom(DamageSourceList.weak, amount * (3F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F)); - // Negative earrings - if (jewelry instanceof ItemEarrings && exists && source.damageType.equals("arrow") && source != DamageSourceList.weak) player.attackEntityFrom(DamageSourceList.weak, amount * (2F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F)); - } -} +package darkknight.jewelrycraft.effects; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import darkknight.jewelrycraft.api.ModifierEffects; +import darkknight.jewelrycraft.damage.DamageSourceList; +import darkknight.jewelrycraft.item.ItemBracelet; +import darkknight.jewelrycraft.item.ItemEarrings; +import darkknight.jewelrycraft.item.ItemNecklace; +import darkknight.jewelrycraft.item.ItemRing; +import darkknight.jewelrycraft.potions.PotionList; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.PlayerUtils; +import darkknight.jewelrycraft.util.Variables; + +public class EffectFeather extends ModifierEffects +{ + public EffectFeather() + { + super(new ItemStack(Items.feather)); + } + + @Override + public void action(ItemStack item, EntityPlayer player, Item jewelry) + { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + // Positive earrings + if (jewelry instanceof ItemEarrings){ + AxisAlignedBB axisalignedbb = player.boundingBox.expand(1.0D, 1.0D, 1.0D); + List list = player.worldObj.getEntitiesWithinAABB(EntityArrow.class, axisalignedbb); + if (!player.worldObj.isRemote && list != null && !list.isEmpty()){ + Iterator iterator = list.iterator(); + while (iterator.hasNext()){ + EntityArrow arrow = (EntityArrow)iterator.next(); + if ((arrow.shootingEntity == null || !(arrow.shootingEntity.equals(player)) || arrow.canBePickedUp == 0) && rand.nextInt(2 + JewelryNBT.numberOfModifiers(item)) == 0) arrow.setDead(); + } + } + } + if (jewelry instanceof ItemBracelet){ + // Positive bracelet + if (player.motionY < 0) player.motionY *= (0.6D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.03D); + if (rand.nextInt(JewelryNBT.numberOfModifiers(item)) == 0) player.fallDistance = 0F; + // Negative bracelet + if (!player.isPotionActive(Potion.moveSlowdown) || player.getActivePotionEffect(Potion.moveSlowdown).getDuration() < 30) player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 80 + JewelryNBT.numberOfModifiers(item) * 10, 1 + JewelryNBT.numberOfModifiers(item) / 4)); + } + } + + @Override + public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) + { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + NBTTagCompound enemyData = target.getEntityData(); + if (jewelry instanceof ItemRing){ + if (enemyData.getInteger("reAttacked") == 0){ + // Negative ring + enemyData.setInteger("reAttacked", enemyData.getInteger("reAttacked") + 1); + target.attackEntityFrom(DamageSource.causePlayerDamage(player), amount / (2F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F)); + // Positive ring + if (rand.nextInt(2) == 0 && target instanceof EntityLivingBase) ((EntityLivingBase)target).addPotionEffect(new PotionEffect(PotionList.stun.id, (51 - JewelryNBT.numberOfModifiers(item))*2, 0, false)); + playerInfo.setBoolean("weakDamage", true); + } + if (enemyData.getInteger("reAttacked") == 1) enemyData.setInteger("reAttacked", 0); + } + } + + @Override + public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) + { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + // Positive necklace + if (jewelry instanceof ItemNecklace && rand.nextInt(3 + JewelryNBT.numberOfModifiers(item)) == 0 && source != DamageSourceList.weak && source != DamageSource.inFire && source != DamageSource.onFire && source != DamageSource.lava){ + player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GRAY + StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".effect.feather"))); + playerInfo.setBoolean("negateDamage", true); + } + // Negative necklace + if (jewelry instanceof ItemNecklace && (source == DamageSource.inFire || source == DamageSource.onFire || source == DamageSource.lava) && source != DamageSourceList.weak) player.attackEntityFrom(DamageSourceList.weak, amount * (3F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F)); + // Negative earrings + if (jewelry instanceof ItemEarrings && source.damageType.equals("arrow") && source != DamageSourceList.weak) player.attackEntityFrom(DamageSourceList.weak, amount * (2F + (JewelryNBT.numberOfModifiers(item) - 1) * 0.1F)); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java b/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java index 68c502d..cf409b2 100644 --- a/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java +++ b/src/main/java/darkknight/jewelrycraft/effects/EffectObsidian.java @@ -1,102 +1,99 @@ -package darkknight.jewelrycraft.effects; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.DamageSource; -import darkknight.jewelrycraft.api.ModifierEffects; -import darkknight.jewelrycraft.damage.DamageSourceList; -import darkknight.jewelrycraft.item.ItemBracelet; -import darkknight.jewelrycraft.item.ItemEarrings; -import darkknight.jewelrycraft.item.ItemNecklace; -import darkknight.jewelrycraft.item.ItemRing; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.PlayerUtils; -import darkknight.jewelrycraft.util.Variables; - -public class EffectObsidian extends ModifierEffects -{ - public EffectObsidian() - { - super(new ItemStack(Blocks.obsidian)); - } - - @Override - public void action(ItemStack item, EntityPlayer player, Item jewelry) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - if (jewelry instanceof ItemNecklace && exists){ - // Positive necklace - player.addPotionEffect(new PotionEffect(Potion.resistance.id, 60, 2, true)); - // Negative necklace - if (player.isInWater() && !player.capabilities.isCreativeMode){ - double slowAmount = 0.2D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.05D; - player.motionX *= slowAmount; - player.motionY *= slowAmount; - player.motionZ *= slowAmount; - player.motionY = -0.5D; - if (rand.nextInt(50) == 0) player.attackEntityFrom(DamageSourceList.weak, 2F); - } - } - // Negative bracelet - if (jewelry instanceof ItemBracelet && exists && playerInfo.hasKey("falls") && playerInfo.getInteger("falls") >= 300) player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 60, 1, true)); - // Negative ring - if (jewelry instanceof ItemRing && exists && playerInfo.hasKey("strikes") && playerInfo.getInteger("strikes") >= 200){ - player.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 0, true)); - player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 60, 1, true)); - } - } - - @Override - public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - if (jewelry instanceof ItemEarrings && exists && (source == DamageSource.anvil || source.damageType.equals("arrow"))){ - if (playerInfo.hasKey("protected")) playerInfo.setInteger("protected", playerInfo.getInteger("protected") + 1); - else playerInfo.setInteger("protected", 1); - // Positive && Negative earrings - if (playerInfo.getInteger("protected") < 200) playerInfo.setBoolean("negateDamage", true); - else player.attackEntityFrom(DamageSourceList.weak, player.getHealth() * 3F); - } - if (jewelry instanceof ItemBracelet && exists && source == DamageSource.fall){ - if (playerInfo.hasKey("falls")) playerInfo.setInteger("falls", playerInfo.getInteger("falls") + 1); - else playerInfo.setInteger("falls", 1); - // Positive bracelet - if (playerInfo.getInteger("falls") < 300) playerInfo.setBoolean("negateDamage", true); - } - } - - public void onPlayerDead(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry) - { - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - playerInfo.setInteger("falls", 0); - playerInfo.setInteger("strikes", 0); - playerInfo.setInteger("protected", 0); - } - - public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) - { - boolean exists = JewelryNBT.doesModifierExist(item, modifier); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - NBTTagCompound enemyData = target.getEntityData(); - // Positive ring - if (jewelry instanceof ItemRing && exists && playerInfo.getInteger("strikes") < 200 && !player.worldObj.isRemote){ - if (enemyData.getInteger("reAttacked") == 0){ - if (playerInfo.hasKey("strikes")) playerInfo.setInteger("strikes", playerInfo.getInteger("strikes") + 1); - else playerInfo.setInteger("strikes", 1); - // Negative ring - enemyData.setInteger("reAttacked", enemyData.getInteger("reAttacked") + 1); - target.attackEntityFrom(DamageSource.causePlayerDamage(player), amount * 2F); - playerInfo.setBoolean("weakDamage", true); - } - if (enemyData.getInteger("reAttacked") == 1) enemyData.setInteger("reAttacked", 0); - } - } -} +package darkknight.jewelrycraft.effects; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.DamageSource; +import darkknight.jewelrycraft.api.ModifierEffects; +import darkknight.jewelrycraft.damage.DamageSourceList; +import darkknight.jewelrycraft.item.ItemBracelet; +import darkknight.jewelrycraft.item.ItemEarrings; +import darkknight.jewelrycraft.item.ItemNecklace; +import darkknight.jewelrycraft.item.ItemRing; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.PlayerUtils; +import darkknight.jewelrycraft.util.Variables; + +public class EffectObsidian extends ModifierEffects +{ + public EffectObsidian() + { + super(new ItemStack(Blocks.obsidian)); + } + + @Override + public void action(ItemStack item, EntityPlayer player, Item jewelry) + { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + if (jewelry instanceof ItemNecklace){ + // Positive necklace + player.addPotionEffect(new PotionEffect(Potion.resistance.id, 60, 2, true)); + // Negative necklace + if (player.isInWater() && !player.capabilities.isCreativeMode){ + double slowAmount = 0.2D + (JewelryNBT.numberOfModifiers(item) - 1) * 0.05D; + player.motionX *= slowAmount; + player.motionY *= slowAmount; + player.motionZ *= slowAmount; + player.motionY = -0.5D; + if (rand.nextInt(50) == 0) player.attackEntityFrom(DamageSourceList.weak, 2F); + } + } + // Negative bracelet + if (jewelry instanceof ItemBracelet && playerInfo.hasKey("falls") && playerInfo.getInteger("falls") >= 300) player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 60, 1, true)); + // Negative ring + if (jewelry instanceof ItemRing && playerInfo.hasKey("strikes") && playerInfo.getInteger("strikes") >= 200){ + player.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 0, true)); + player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 60, 1, true)); + } + } + + @Override + public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) + { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + if (jewelry instanceof ItemEarrings && (source == DamageSource.anvil || source.damageType.equals("arrow"))){ + if (playerInfo.hasKey("protected")) playerInfo.setInteger("protected", playerInfo.getInteger("protected") + 1); + else playerInfo.setInteger("protected", 1); + // Positive && Negative earrings + if (playerInfo.getInteger("protected") < 200) playerInfo.setBoolean("negateDamage", true); + else player.attackEntityFrom(DamageSourceList.weak, player.getHealth() * 3F); + } + if (jewelry instanceof ItemBracelet && source == DamageSource.fall){ + if (playerInfo.hasKey("falls")) playerInfo.setInteger("falls", playerInfo.getInteger("falls") + 1); + else playerInfo.setInteger("falls", 1); + // Positive bracelet + if (playerInfo.getInteger("falls") < 300) playerInfo.setBoolean("negateDamage", true); + } + } + + public void onPlayerDead(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry) + { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + playerInfo.setInteger("falls", 0); + playerInfo.setInteger("strikes", 0); + playerInfo.setInteger("protected", 0); + } + + public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) + { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + NBTTagCompound enemyData = target.getEntityData(); + // Positive ring + if (jewelry instanceof ItemRing && playerInfo.getInteger("strikes") < 200 && !player.worldObj.isRemote){ + if (enemyData.getInteger("reAttacked") == 0){ + if (playerInfo.hasKey("strikes")) playerInfo.setInteger("strikes", playerInfo.getInteger("strikes") + 1); + else playerInfo.setInteger("strikes", 1); + // Negative ring + enemyData.setInteger("reAttacked", enemyData.getInteger("reAttacked") + 1); + target.attackEntityFrom(DamageSource.causePlayerDamage(player), amount * 2F); + playerInfo.setBoolean("weakDamage", true); + } + if (enemyData.getInteger("reAttacked") == 1) enemyData.setInteger("reAttacked", 0); + } + } +} diff --git a/src/main/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java b/src/main/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java index c538f86..6b9561f 100644 --- a/src/main/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java +++ b/src/main/java/darkknight/jewelrycraft/entities/EntityHalfHeart.java @@ -1,38 +1,35 @@ -/** - * - */ -package darkknight.jewelrycraft.entities; - -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.world.World; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.network.PacketRequestPlayerInfo; -import darkknight.jewelrycraft.util.PlayerUtils; -import darkknight.jewelrycraft.util.Variables; - -/** - * @author Sorin - */ -public class EntityHalfHeart extends EntityHeart -{ - public EntityHalfHeart(World world) - { - super(world); - } - - protected void entityInit() - { - super.entityInit(); - this.dataWatcher.updateObject(17, 1f); - } - - @Override - public void onCollideWithPlayer(EntityPlayer player) - { - super.onCollideWithPlayer(player); - } -} +package darkknight.jewelrycraft.entities; + +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.world.World; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.network.PacketRequestPlayerInfo; +import darkknight.jewelrycraft.util.PlayerUtils; +import darkknight.jewelrycraft.util.Variables; + +/** + * @author Sorin + */ +public class EntityHalfHeart extends EntityHeart +{ + public EntityHalfHeart(World world) + { + super(world); + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.updateObject(17, 1f); + } + + @Override + public void onCollideWithPlayer(EntityPlayer player) + { + super.onCollideWithPlayer(player); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/entities/EntityList.java b/src/main/java/darkknight/jewelrycraft/entities/EntityList.java index c17c553..831f3ca 100644 --- a/src/main/java/darkknight/jewelrycraft/entities/EntityList.java +++ b/src/main/java/darkknight/jewelrycraft/entities/EntityList.java @@ -1,22 +1,16 @@ -package darkknight.jewelrycraft.entities; - -import net.minecraft.entity.Entity; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.registry.EntityRegistry; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.util.Variables; - -public class EntityList -{ - public static void preInit(FMLPreInitializationEvent e) - { - createEntity(EntityHeart.class, Variables.MODID + ".Heart"); - createEntity(EntityHalfHeart.class, Variables.MODID + ".Half-Heart"); - } - - public static void createEntity(Class entity, String entityName) - { - int randomID = EntityRegistry.findGlobalUniqueEntityId(); - EntityRegistry.registerModEntity(entity, entityName, randomID, JewelrycraftMod.instance, 40, 3, false); - } -} +package darkknight.jewelrycraft.entities; + +import net.minecraft.entity.Entity; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.registry.EntityRegistry; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.util.Variables; + +public class EntityList +{ + public static void preInit(FMLPreInitializationEvent e) + { + EntityRegistry.registerModEntity(EntityHeart.class, "Heart", 1, JewelrycraftMod.instance, 40, 3, false); + EntityRegistry.registerModEntity(EntityHalfHeart.class, "HalfHeart", 2, JewelrycraftMod.instance, 40, 3, false); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/entities/renders/RenderHelper.java b/src/main/java/darkknight/jewelrycraft/entities/renders/RenderHelper.java index 16ddfe1..8012d84 100644 --- a/src/main/java/darkknight/jewelrycraft/entities/renders/RenderHelper.java +++ b/src/main/java/darkknight/jewelrycraft/entities/renders/RenderHelper.java @@ -1,23 +1,24 @@ -package darkknight.jewelrycraft.entities.renders; - -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import org.lwjgl.opengl.GL11; - -public class RenderHelper -{ - public static void rotateIfSneaking(EntityPlayer player) - { - if (player.isSneaking()) applySneakingRotation(); - } - - public static void applySneakingRotation() - { - GL11.glRotatef(28.64789F, 1.0F, 0.0F, 0.0F); - } - - public static void translateToHeadLevel(EntityPlayer player) - { - GL11.glTranslated(0, (player != Minecraft.getMinecraft().thePlayer ? 1.62F : 0F) - player.getDefaultEyeHeight() + (player.isSneaking() ? 0.0625 : 0), 0); - } +package darkknight.jewelrycraft.entities.renders; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import org.lwjgl.opengl.GL11; +import cpw.mods.fml.common.Loader; + +public class RenderHelper +{ + public static void rotateIfSneaking(EntityPlayer player) + { + if (player.isSneaking()) applySneakingRotation(); + } + + public static void applySneakingRotation() + { + GL11.glRotatef(28.64789F, 1.0F, 0.0F, 0.0F); + } + + public static void translateToHeadLevel(EntityPlayer player) + { + GL11.glTranslated(0, (player != Minecraft.getMinecraft().thePlayer ? 1.62F : 0F) - player.getDefaultEyeHeight() + (player.isSneaking() ? 0.0625 : 0), 0); + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java index 7157759..786a8ae 100644 --- a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java +++ b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java @@ -1,488 +1,489 @@ -package darkknight.jewelrycraft.events; - -import java.io.EOFException; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Iterator; -import java.util.List; -import java.util.Random; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.MathHelper; -import net.minecraftforge.client.event.EntityViewRenderEvent; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.event.entity.item.ItemTossEvent; -import net.minecraftforge.event.entity.living.LivingAttackEvent; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.living.LivingDropsEvent; -import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; -import net.minecraftforge.event.entity.player.PlayerEvent; -import net.minecraftforge.event.world.WorldEvent; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.api.Curse; -import darkknight.jewelrycraft.api.IJewelryItem; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.damage.DamageSourceList; -import darkknight.jewelrycraft.entities.EntityHalfHeart; -import darkknight.jewelrycraft.entities.EntityHeart; -import darkknight.jewelrycraft.item.ItemBaseJewelry; -import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.network.PacketClearColorCache; -import darkknight.jewelrycraft.network.PacketRequestPlayerInfo; -import darkknight.jewelrycraft.network.PacketSendServerPlayersInfo; -import darkknight.jewelrycraft.potions.PotionList; -import darkknight.jewelrycraft.util.BlockUtils; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.JewelrycraftUtil; -import darkknight.jewelrycraft.util.PlayerUtils; -import darkknight.jewelrycraft.util.Variables; - -/** - * Code taken from OpenBlocks - */ -public class EntityEventHandler -{ - int updateTime = 0, totalUnavailableCurses = 0; - boolean addedCurses = false; - - /** - * @param event - */ - @SubscribeEvent - public void onEntityJoinWorld(EntityJoinWorldEvent event) - { - if (event.entity instanceof EntityPlayerMP) JewelrycraftMod.netWrapper.sendTo(new PacketClearColorCache(), (EntityPlayerMP)event.entity); - if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); - final Entity entity = event.entity; - if (!event.world.isRemote && entity instanceof EntityPlayer){ - EntityPlayer player = (EntityPlayer)entity; - NBTTagCompound persistTag = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - boolean shouldGiveManual = ItemList.guide != null && !persistTag.getBoolean("givenGuide"); - if (shouldGiveManual){ - ItemStack manual = new ItemStack(ItemList.guide); - if (!player.inventory.addItemStackToInventory(manual)) BlockUtils.dropItemStackInWorld(player.worldObj, player.posX, player.posY, player.posZ, manual); - persistTag.setBoolean("givenGuide", true); - } - boolean render = persistTag.getBoolean("fancyRender"); - JewelrycraftMod.fancyRender = render; - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) - if (curse.canCurseBeActivated(event.world) && !persistTag.hasKey(curse.getName())) persistTag.setInteger(curse.getName(), 0); - for(Curse curse: Curse.getCurseList()) - if (!curse.canCurseBeActivated(event.world)){ - Curse.availableCurses.remove(curse); - persistTag.setInteger(curse.getName(), 0); - totalUnavailableCurses++; - }else if (!Curse.availableCurses.contains(curse)) Curse.availableCurses.add(curse); - persistTag.setBoolean("sendInfo", true); - } - } - - /** - * @param event - */ - @SubscribeEvent - public void onEntityUpdate(LivingUpdateEvent event) - { - Entity entity = event.entity; - EntityLivingBase entityLiving = event.entityLiving; - if (entityLiving.isPotionActive(PotionList.stun)){ - entityLiving.motionX *= 0D; - entityLiving.motionZ *= 0D; - entityLiving.motionY *= 0D; - entityLiving.isSwingInProgress = false; - entityLiving.moveForward = 0F; - entityLiving.moveStrafing = 0F; - entityLiving.setAIMoveSpeed(0F); - entityLiving.limbSwing = 0F; - entityLiving.limbSwingAmount = 0F; - entityLiving.swingProgressInt = 0; - entityLiving.rotationPitch = entity.prevRotationPitch; - entityLiving.rotationYaw = entity.prevRotationYaw; - entityLiving.worldObj.spawnParticle("spell", entityLiving.posX, entityLiving.posY + entityLiving.getEyeHeight(), entityLiving.posZ, 0.0D, 0.3D, 0.0D); - } - if (entityLiving.isPotionActive(PotionList.stun) && entityLiving.getActivePotionEffect(PotionList.stun).getDuration() == 0) entityLiving.removePotionEffect(PotionList.stun.id); - if (entity instanceof EntityPlayer){ - EntityPlayer player = (EntityPlayer)entity; - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - playerInfo.setBoolean("fancyRender", JewelrycraftMod.fancyRender); - if (updateTime > 0) updateTime--; - for(int i = 0; i < 18; i++) - if (playerInfo.hasKey("ext" + i)){ - NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); - ItemStack item = ItemStack.loadItemStackFromNBT(nbt); - if (item != null){ - if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).action(item, player); - if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onWearAction(item, player); - } - } - if (!player.worldObj.isRemote){ - if (playerInfo.hasKey("reselectCurses") && !playerInfo.getBoolean("reselectCurses")){ - playerInfo.setInteger("curseTime", playerInfo.getInteger("curseTime") - 10000); - if (playerInfo.getInteger("curseTime") <= 0) playerInfo.setBoolean("reselectCurses", true); - } - if (playerInfo.hasKey("playerCursePointsChanged") && playerInfo.getBoolean("playerCursePointsChanged")){ - int points = playerInfo.getInteger("cursePoints"); - for(int i = 1; i <= Variables.MAX_CURSES; i++) - if (points > (i - 1) * 1750) addCurse(player, playerInfo, i); - if (!playerInfo.hasKey("curseTime") || !playerInfo.hasKey("reselectCurses") || playerInfo.getBoolean("reselectCurses")){ - playerInfo.setInteger("curseTime", 23000); - playerInfo.setBoolean("reselectCurses", false); - } - JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); - if (addedCurses){ - JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo()); - // player.openGui(JewelrycraftMod.instance, 4, player.worldObj, 0, 0, 0); - addedCurses = false; - } - } - if (playerInfo.getBoolean("playerCursePointsChanged")) playerInfo.setBoolean("playerCursePointsChanged", false); - if (updateTime == 0){ - JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo()); - updateTime = 200; - } - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) - if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.action(player.worldObj, player); - } - } - } - - @SubscribeEvent - public void onEntityLivingDropItems(LivingDropsEvent event) - { - if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer){ - EntityPlayer player = (EntityPlayer)event.source.getEntity(); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) - if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.entityDropItems(player, event.entityLiving, event.drops); - } - } - - /** - * @param event - */ - @SubscribeEvent - public void onEntityAttacked(LivingAttackEvent event) - { - EntityLivingBase entity = event.entityLiving; - if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityLivingBase && ((EntityLivingBase)event.source.getEntity()).isPotionActive(PotionList.stun)) event.setCanceled(true); - if (entity instanceof EntityPlayer && !(event.source.getEntity() instanceof EntityPlayer)){ - EntityPlayer player = (EntityPlayer)entity; - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - if (!player.worldObj.isRemote) for(int i = 0; i < 18; i++) - if (playerInfo.hasKey("ext" + i)){ - NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); - ItemStack item = ItemStack.loadItemStackFromNBT(nbt); - if (item != null && item.getItem() instanceof ItemBaseJewelry && ((ItemBaseJewelry)item.getItem()).onPlayerAttackedCacellable(item, player, event.source, event.ammount)){ - event.setCanceled(true); - break; - } - if (playerInfo.getBoolean("negateDamage")){ - playerInfo.setBoolean("negateDamage", false); - event.setCanceled(true); - break; - } - if (item != null){ - if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onPlayerAttacked(item, player, event.source, event.ammount); - if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onPlayerAttackedAction(item, player, event.source, event.ammount); - } - } - if (player.getHealth() != player.prevHealth){ - if (playerInfo.getFloat("WhiteHeart") > 0){ - playerInfo.setFloat("WhiteHeart", 0f); - JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); - } - if (playerInfo.getFloat("BlueHeart") > 0){ - float damage = playerInfo.getFloat("BlueHeart") - event.ammount; - if (damage >= 0){ - playerInfo.setFloat("BlueHeart", damage); - JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); - player.heal(event.ammount); - }else{ - playerInfo.setFloat("BlueHeart", 0f); - JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); - player.heal(Math.abs(damage)); - } - }else if (playerInfo.getFloat("BlackHeart") > 0){ - AxisAlignedBB axisalignedbb = player.boundingBox.expand(2.0D, 0.0D, 2.0D); - List enemies = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, axisalignedbb); - if (enemies != null && !enemies.isEmpty()){ - Iterator iterator = enemies.iterator(); - while (iterator.hasNext()){ - Entity enemy = (Entity)iterator.next(); - enemy.attackEntityFrom(DamageSourceList.blackHeart, 5f * event.ammount); - } - } - float damage = playerInfo.getFloat("BlackHeart") - event.ammount; - if (damage >= 0){ - playerInfo.setFloat("BlackHeart", damage); - JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); - player.heal(event.ammount); - }else{ - playerInfo.setFloat("BlackHeart", 0f); - JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); - player.heal(Math.abs(damage)); - } - } - } - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) - if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.attackedAction(player.worldObj, player); - }else if (event.source.getEntity() instanceof EntityPlayer){ - EntityPlayer player = (EntityPlayer)event.source.getEntity(); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - for(int i = 0; i < 18; i++) - if (playerInfo.hasKey("ext" + i)){ - NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); - ItemStack item = ItemStack.loadItemStackFromNBT(nbt); - if (item != null && item.getItem() instanceof ItemBaseJewelry && ((ItemBaseJewelry)item.getItem()).onEntityAttackedCacellable(item, player, entity, event.ammount)){ - event.setCanceled(true); - break; - } - if (playerInfo.getBoolean("weakDamage")){ - playerInfo.setBoolean("weakDamage", false); - event.setCanceled(true); - break; - } - if (item != null){ - if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onEntityAttacked(item, player, entity, event.ammount); - if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onEntityAttackedByPlayer(item, player, entity, event.ammount); - } - } - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) - if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.attackedByPlayerAction(entity.worldObj, player, entity); - } - } - - /** - * @param event - */ - @SubscribeEvent - public void onPlayerRespawn(PlayerEvent.Clone event) - { - EntityPlayer player = event.entityPlayer; - if (!player.worldObj.isRemote){ - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - if (playerInfo.hasKey("cursePoints")){ - int points = playerInfo.getInteger("cursePoints"); - for(int i = 1; i <= Variables.MAX_CURSES; i++) - if (points > (i - 1) * 1750) addCurse(player, playerInfo, i); - if (!playerInfo.hasKey("curseTime") || !playerInfo.hasKey("reselectCurses") || playerInfo.getBoolean("reselectCurses")){ - playerInfo.setInteger("curseTime", 23000); - playerInfo.setBoolean("reselectCurses", false); - } - } - playerInfo.setFloat("BlueHeart", 0f); - playerInfo.setFloat("BlackHeart", 0f); - playerInfo.setFloat("WhiteHeart", 0f); - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) - if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.respawnAction(player.worldObj, player); - for(int i = 0; i < 18; i++) - if (playerInfo.hasKey("ext" + i)){ - NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); - ItemStack item = ItemStack.loadItemStackFromNBT(nbt); - if (item != null){ - if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onPlayerRespawn(item, event); - if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onPlayerRespawnAction(item, event); - } - } - } - if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); - if (!player.worldObj.isRemote){ - JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); - if (addedCurses){ - JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo()); - // player.openGui(JewelrycraftMod.instance, 4, player.worldObj, 0, 0, 0); - addedCurses = false; - } - } - } - - /** - * @param player - * @param playerInfo - * @param curse - */ - public void addCurse(EntityPlayer player, NBTTagCompound playerInfo, int curseNo) - { - if (ConfigHandler.CURSES_ENABLED && Curse.availableCurses.size() > 0 && curseNo > Curse.getCurseList().size() - Curse.availableCurses.size() - totalUnavailableCurses){ - int no = JewelrycraftUtil.rand.nextInt(Curse.availableCurses.size()); - Curse cur = Curse.availableCurses.get(no); - playerInfo.setInteger(cur.getName(), 1); - Curse.availableCurses.remove(cur); - addedCurses = true; - } - } - - @SubscribeEvent - public void itemToss(ItemTossEvent event) - { - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(event.player, Variables.MODID); - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) - if (curse.canCurseBeActivated(event.player.worldObj) && playerInfo.getInteger(curse.getName()) > 0 && curse.itemToss()){ - EntityItem entityitem = new EntityItem(event.player.worldObj, event.player.posX + 0.5D, event.player.posY + 0.5D, event.player.posZ + 0.5D, event.entityItem.getEntityItem()); - entityitem.motionX = 0; - entityitem.motionZ = 0; - entityitem.motionY = 0.11000000298023224D; - event.player.worldObj.spawnEntityInWorld(entityitem); - MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentText("<" + event.player.getDisplayName() + "> This is MY item! MINE! I will NEVER give it to you! Mine! Mine! MINE!")); - event.setCanceled(true); - } - } - - /** - * @param event - */ - @SubscribeEvent - public void playerFileSave(PlayerEvent.SaveToFile event) - { - if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); - } - - /** - * @param event - */ - @SubscribeEvent - public void onEntityDead(LivingDeathEvent event) - { - final Entity entity = event.entity; - Random rand = new Random(); - String[] types = {"Red", "Blue", "White", "Black"}; - if (!entity.worldObj.isRemote && !(entity instanceof EntityPlayer) && entity instanceof EntityLiving){ - EntityLiving live = (EntityLiving)entity; - String type = types[rand.nextInt(4)]; - if (rand.nextInt(6) == 0 && live.getCreatureAttribute() != JewelrycraftUtil.HEART){ - if (type == "White"){ - EntityHeart h = new EntityHalfHeart(live.worldObj); - h.setType(type); - h.setLocationAndAngles(live.posX, live.posY, live.posZ, MathHelper.wrapAngleTo180_float(rand.nextFloat() * 360.0F), 0.0F); - live.worldObj.spawnEntityInWorld(h); - }else{ - for(int i = 1; i <= 1 + rand.nextInt(1 + (int)(live.getMaxHealth() / 20)); i++){ - EntityHeart[] hearts = {new EntityHeart(live.worldObj), new EntityHalfHeart(entity.worldObj)}; - EntityHeart h = hearts[rand.nextInt(2)]; - h.setType(type); - h.setLocationAndAngles(live.posX, live.posY, live.posZ, MathHelper.wrapAngleTo180_float(rand.nextFloat() * 360.0F), 0.0F); - live.worldObj.spawnEntityInWorld(h); - } - } - } - if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer){ - EntityPlayer player = (EntityPlayer)event.source.getEntity(); - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) - if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.entityDeathAction(player.worldObj, event.entityLiving, player); - } - } - if (entity instanceof EntityPlayer){ - EntityPlayer player = (EntityPlayer)entity; - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - playerInfo.setFloat("BlueHeart", 0f); - playerInfo.setFloat("BlackHeart", 0f); - playerInfo.setFloat("WhiteHeart", 0f); - if (playerInfo.hasKey("reselectCurses") && playerInfo.getBoolean("reselectCurses")){ - if (ConfigHandler.CURSES_ENABLED) for(Curse l: Curse.getCurseList()){ - if (l.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(l.getName()) == 1){ - playerInfo.setInteger(l.getName(), 0); - if (!Curse.availableCurses.contains(l)) Curse.availableCurses.add(l); - }else if (l.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(l.getName()) >= 2) playerInfo.setInteger(l.getName(), 1); - } - if (entity.worldObj.isRemote) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); - } - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) - if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.playerDeathAction(player.worldObj, player); - for(int i = 0; i < 18; i++) - if (playerInfo.hasKey("ext" + i)){ - NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); - ItemStack item = ItemStack.loadItemStackFromNBT(nbt); - if (item != null){ - if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onPlayerDead(item, player, event.source); - if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onPlayerDeadAction(item, player, event.source); - } - } - } - if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); - } - - /** - * @param event - */ - @SubscribeEvent - public void onWorldLoad(WorldEvent.Load event) - { - if (!event.world.isRemote){ - new File(JewelrycraftMod.dir + File.separator + Variables.MODID).mkdirs(); - JewelrycraftMod.liquidsConf = new File(JewelrycraftMod.dir + File.separator + Variables.MODID, "JLP" + event.world.getWorldInfo().getWorldName() + ".cfg"); - try{ - if (!JewelrycraftMod.liquidsConf.exists()) JewelrycraftMod.liquidsConf.createNewFile(); - } - catch(IOException e){ - e.printStackTrace(); - } - } - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) try{ - if (JewelrycraftMod.liquidsConf.exists()) JewelrycraftMod.saveData = CompressedStreamTools.readCompressed(new FileInputStream(JewelrycraftMod.liquidsConf)); - } - catch(EOFException e){ - e.printStackTrace(); - } - catch(IOException e){ - e.printStackTrace(); - } - } - - /** - * @param event - */ - @SubscribeEvent - public void onWorldSave(WorldEvent.Save event) - { - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) try{ - if (JewelrycraftMod.liquidsConf.exists()) CompressedStreamTools.writeCompressed(JewelrycraftMod.saveData, new FileOutputStream(JewelrycraftMod.liquidsConf)); - } - catch(EOFException e){ - e.printStackTrace(); - } - catch(IOException e){ - e.printStackTrace(); - } - } - - /** - * @param event - */ - @SubscribeEvent - @SideOnly (Side.CLIENT) - public void fogColors(EntityViewRenderEvent.FogColors event) - {} - - /** - * @param event - */ - @SubscribeEvent - @SideOnly (Side.CLIENT) - public void fogDensity(EntityViewRenderEvent.FogDensity event) - {} - - /** - * @param event - */ - @SubscribeEvent - @SideOnly (Side.CLIENT) - public void renderFog(EntityViewRenderEvent.RenderFogEvent event) - {} +package darkknight.jewelrycraft.events; + +import java.io.EOFException; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.MathHelper; +import net.minecraft.util.WeightedRandom; +import net.minecraftforge.client.event.EntityViewRenderEvent; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.entity.item.ItemTossEvent; +import net.minecraftforge.event.entity.living.LivingAttackEvent; +import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.event.entity.living.LivingDropsEvent; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import net.minecraftforge.event.entity.player.PlayerEvent; +import net.minecraftforge.event.world.WorldEvent; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.api.Curse; +import darkknight.jewelrycraft.api.IJewelryItem; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.damage.DamageSourceList; +import darkknight.jewelrycraft.entities.EntityHalfHeart; +import darkknight.jewelrycraft.entities.EntityHeart; +import darkknight.jewelrycraft.item.ItemBaseJewelry; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.network.PacketClearColorCache; +import darkknight.jewelrycraft.network.PacketRequestPlayerInfo; +import darkknight.jewelrycraft.network.PacketSendServerPlayersInfo; +import darkknight.jewelrycraft.potions.PotionList; +import darkknight.jewelrycraft.random.WeightedRandomCurse; +import darkknight.jewelrycraft.util.BlockUtils; +import darkknight.jewelrycraft.util.JewelrycraftUtil; +import darkknight.jewelrycraft.util.PlayerUtils; +import darkknight.jewelrycraft.util.Variables; + +/** + * Code taken from OpenBlocks + */ +public class EntityEventHandler +{ + int updateTime = 0, totalUnavailableCurses = 0; + boolean addedCurses = false; + Random rand = new Random(); + + /** + * @param event + */ + @SubscribeEvent + public void onEntityJoinWorld(EntityJoinWorldEvent event) + { + if (event.entity instanceof EntityPlayerMP) JewelrycraftMod.netWrapper.sendTo(new PacketClearColorCache(), (EntityPlayerMP)event.entity); + if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); + final Entity entity = event.entity; + if (!event.world.isRemote && entity instanceof EntityPlayer){ + EntityPlayer player = (EntityPlayer)entity; + NBTTagCompound persistTag = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + boolean shouldGiveManual = ItemList.guide != null && !persistTag.getBoolean("givenGuide"); + if (shouldGiveManual){ + ItemStack manual = new ItemStack(ItemList.guide); + if (!player.inventory.addItemStackToInventory(manual)) BlockUtils.dropItemStackInWorld(player.worldObj, player.posX, player.posY, player.posZ, manual); + persistTag.setBoolean("givenGuide", true); + } + boolean render = persistTag.getBoolean("fancyRender"); + JewelrycraftMod.fancyRender = render; + if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) + if (curse.canCurseBeActivated(event.world) && !persistTag.hasKey(curse.getName())) persistTag.setInteger(curse.getName(), 0); + for(Curse curse: Curse.getCurseList()) + if (!curse.canCurseBeActivated(event.world)){ + Curse.availableCurses.remove(curse); + persistTag.setInteger(curse.getName(), 0); + totalUnavailableCurses++; + }else if (!Curse.availableCurses.contains(curse)) Curse.availableCurses.add(curse); + persistTag.setBoolean("sendInfo", true); + } + } + + /** + * @param event + */ + @SubscribeEvent + public void onEntityUpdate(LivingUpdateEvent event) + { + Entity entity = event.entity; + EntityLivingBase entityLiving = event.entityLiving; + if (entityLiving.isPotionActive(PotionList.stun)){ + entityLiving.motionX *= 0D; + entityLiving.motionZ *= 0D; + entityLiving.motionY *= 0D; + entityLiving.isSwingInProgress = false; + entityLiving.moveForward = 0F; + entityLiving.moveStrafing = 0F; + entityLiving.setAIMoveSpeed(0F); + entityLiving.limbSwing = 0F; + entityLiving.limbSwingAmount = 0F; + entityLiving.swingProgressInt = 0; + entityLiving.rotationPitch = entity.prevRotationPitch; + entityLiving.rotationYaw = entity.prevRotationYaw; + entityLiving.worldObj.spawnParticle("spell", entityLiving.posX, entityLiving.posY + entityLiving.getEyeHeight(), entityLiving.posZ, 0.0D, 0.3D, 0.0D); + } + if (entityLiving.isPotionActive(PotionList.stun) && entityLiving.getActivePotionEffect(PotionList.stun).getDuration() == 0) entityLiving.removePotionEffect(PotionList.stun.id); + if (entity instanceof EntityPlayer){ + EntityPlayer player = (EntityPlayer)entity; + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + playerInfo.setBoolean("fancyRender", JewelrycraftMod.fancyRender); + if (updateTime > 0) updateTime--; + for(int i = 0; i < 18; i++) + if (playerInfo.hasKey("ext" + i)){ + NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); + ItemStack item = ItemStack.loadItemStackFromNBT(nbt); + if (item != null){ + if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).action(item, player); + if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onWearAction(item, player); + } + } + if (!player.worldObj.isRemote){ + if (playerInfo.hasKey("reselectCurses") && !playerInfo.getBoolean("reselectCurses")){ + playerInfo.setInteger("curseTime", playerInfo.getInteger("curseTime") - 10000); + if (playerInfo.getInteger("curseTime") <= 0) playerInfo.setBoolean("reselectCurses", true); + } + if (playerInfo.hasKey("playerCursePointsChanged") && playerInfo.getBoolean("playerCursePointsChanged")){ + int points = playerInfo.getInteger("cursePoints"); + for(int i = 1; i <= Variables.MAX_CURSES; i++) + if (points > (i - 1) * 1750) addCurse(player, playerInfo, i); + if (!playerInfo.hasKey("curseTime") || !playerInfo.hasKey("reselectCurses") || playerInfo.getBoolean("reselectCurses")){ + playerInfo.setInteger("curseTime", 23000); + playerInfo.setBoolean("reselectCurses", false); + } + JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); + if (addedCurses){ + JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo()); + // player.openGui(JewelrycraftMod.instance, 4, player.worldObj, 0, 0, 0); + addedCurses = false; + } + } + if (playerInfo.getBoolean("playerCursePointsChanged")) playerInfo.setBoolean("playerCursePointsChanged", false); + if (updateTime == 0){ + JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo()); + updateTime = 200; + } + if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) + if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.action(player.worldObj, player); + } + } + } + + @SubscribeEvent + public void onEntityLivingDropItems(LivingDropsEvent event) + { + if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer){ + EntityPlayer player = (EntityPlayer)event.source.getEntity(); + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) + if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.entityDropItems(player, event.entityLiving, event.drops); + } + } + + /** + * @param event + */ + @SubscribeEvent + public void onEntityAttacked(LivingAttackEvent event) + { + EntityLivingBase entity = event.entityLiving; + if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityLivingBase && ((EntityLivingBase)event.source.getEntity()).isPotionActive(PotionList.stun)) event.setCanceled(true); + if (entity instanceof EntityPlayer && !(event.source.getEntity() instanceof EntityPlayer)){ + EntityPlayer player = (EntityPlayer)entity; + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + if (!player.worldObj.isRemote) for(int i = 0; i < 18; i++) + if (playerInfo.hasKey("ext" + i)){ + NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); + ItemStack item = ItemStack.loadItemStackFromNBT(nbt); + if (item != null && item.getItem() instanceof ItemBaseJewelry && ((ItemBaseJewelry)item.getItem()).onPlayerAttackedCacellable(item, player, event.source, event.ammount)){ + event.setCanceled(true); + break; + } + if (playerInfo.getBoolean("negateDamage")){ + playerInfo.setBoolean("negateDamage", false); + event.setCanceled(true); + break; + } + if (item != null){ + if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onPlayerAttacked(item, player, event.source, event.ammount); + if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onPlayerAttackedAction(item, player, event.source, event.ammount); + } + } + if (player.getHealth() != player.prevHealth){ + if (playerInfo.getFloat("WhiteHeart") > 0){ + playerInfo.setFloat("WhiteHeart", 0f); + JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); + } + if (playerInfo.getFloat("BlueHeart") > 0){ + float damage = playerInfo.getFloat("BlueHeart") - event.ammount; + if (damage >= 0){ + playerInfo.setFloat("BlueHeart", damage); + JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); + player.heal(event.ammount); + }else{ + playerInfo.setFloat("BlueHeart", 0f); + JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); + player.heal(Math.abs(damage)); + } + }else if (playerInfo.getFloat("BlackHeart") > 0){ + AxisAlignedBB axisalignedbb = player.boundingBox.expand(2.0D, 0.0D, 2.0D); + List enemies = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, axisalignedbb); + if (enemies != null && !enemies.isEmpty()){ + Iterator iterator = enemies.iterator(); + while (iterator.hasNext()){ + Entity enemy = (Entity)iterator.next(); + enemy.attackEntityFrom(DamageSourceList.blackHeart, 5f * event.ammount); + } + } + float damage = playerInfo.getFloat("BlackHeart") - event.ammount; + if (damage >= 0){ + playerInfo.setFloat("BlackHeart", damage); + JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); + player.heal(event.ammount); + }else{ + playerInfo.setFloat("BlackHeart", 0f); + JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); + player.heal(Math.abs(damage)); + } + } + } + if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) + if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.attackedAction(player.worldObj, player); + }else if (event.source.getEntity() instanceof EntityPlayer){ + EntityPlayer player = (EntityPlayer)event.source.getEntity(); + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + for(int i = 0; i < 18; i++) + if (playerInfo.hasKey("ext" + i)){ + NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); + ItemStack item = ItemStack.loadItemStackFromNBT(nbt); + if (item != null && item.getItem() instanceof ItemBaseJewelry && ((ItemBaseJewelry)item.getItem()).onEntityAttackedCacellable(item, player, entity, event.ammount)){ + event.setCanceled(true); + break; + } + if (playerInfo.getBoolean("weakDamage")){ + playerInfo.setBoolean("weakDamage", false); + event.setCanceled(true); + break; + } + if (item != null){ + if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onEntityAttacked(item, player, entity, event.ammount); + if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onEntityAttackedByPlayer(item, player, entity, event.ammount); + } + } + if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) + if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.attackedByPlayerAction(entity.worldObj, player, entity); + } + } + + /** + * @param event + */ + @SubscribeEvent + public void onPlayerRespawn(PlayerEvent.Clone event) + { + EntityPlayer player = event.entityPlayer; + if (!player.worldObj.isRemote){ + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + if (playerInfo.hasKey("cursePoints")){ + int points = playerInfo.getInteger("cursePoints"); + for(int i = 1; i <= Variables.MAX_CURSES; i++) + if (points > (i - 1) * 1750) addCurse(player, playerInfo, i); + if (!playerInfo.hasKey("curseTime") || !playerInfo.hasKey("reselectCurses") || playerInfo.getBoolean("reselectCurses")){ + playerInfo.setInteger("curseTime", 23000); + playerInfo.setBoolean("reselectCurses", false); + } + } + playerInfo.setFloat("BlueHeart", 0f); + playerInfo.setFloat("BlackHeart", 0f); + playerInfo.setFloat("WhiteHeart", 0f); + if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) + if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.respawnAction(player.worldObj, player); + for(int i = 0; i < 18; i++) + if (playerInfo.hasKey("ext" + i)){ + NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); + ItemStack item = ItemStack.loadItemStackFromNBT(nbt); + if (item != null){ + if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onPlayerRespawn(item, event); + if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onPlayerRespawnAction(item, event); + } + } + } + if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); + if (!player.worldObj.isRemote){ + JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); + if (addedCurses){ + JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo()); + // player.openGui(JewelrycraftMod.instance, 4, player.worldObj, 0, 0, 0); + addedCurses = false; + } + } + } + + /** + * @param player + * @param playerInfo + * @param curse + */ + public void addCurse(EntityPlayer player, NBTTagCompound playerInfo, int curseNo) + { + if (ConfigHandler.CURSES_ENABLED && Curse.availableCurses.size() > 0 && curseNo > Curse.getCurseList().size() - Curse.availableCurses.size() - totalUnavailableCurses){ + Curse cur = ((WeightedRandomCurse)WeightedRandom.getRandomItem(rand, JewelrycraftUtil.getCurses(player.worldObj, player, rand))).getCurse(rand); + playerInfo.setInteger(cur.getName(), 1); + Curse.availableCurses.remove(cur); + addedCurses = true; + } + } + + @SubscribeEvent + public void itemToss(ItemTossEvent event) + { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(event.player, Variables.MODID); + if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) + if (curse.canCurseBeActivated(event.player.worldObj) && playerInfo.getInteger(curse.getName()) > 0 && curse.itemToss()){ + EntityItem entityitem = new EntityItem(event.player.worldObj, event.player.posX + 0.5D, event.player.posY + 0.5D, event.player.posZ + 0.5D, event.entityItem.getEntityItem()); + entityitem.motionX = 0; + entityitem.motionZ = 0; + entityitem.motionY = 0.11000000298023224D; + event.player.worldObj.spawnEntityInWorld(entityitem); + MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentText("<" + event.player.getDisplayName() + "> This is MY item! MINE! I will NEVER give it to you! Mine! Mine! MINE!")); + event.setCanceled(true); + } + } + + /** + * @param event + */ + @SubscribeEvent + public void playerFileSave(PlayerEvent.SaveToFile event) + { + if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); + } + + /** + * @param event + */ + @SubscribeEvent + public void onEntityDead(LivingDeathEvent event) + { + final Entity entity = event.entity; + Random rand = new Random(); + String[] types = {"Red", "Blue", "White", "Black"}; + if (!entity.worldObj.isRemote && !(entity instanceof EntityPlayer) && entity instanceof EntityLiving){ + EntityLiving live = (EntityLiving)entity; + String type = types[rand.nextInt(4)]; + if (rand.nextInt(6) == 0 && live.getCreatureAttribute() != JewelrycraftUtil.HEART){ + if (type == "White"){ + EntityHeart h = new EntityHalfHeart(live.worldObj); + h.setType(type); + h.setLocationAndAngles(live.posX, live.posY, live.posZ, MathHelper.wrapAngleTo180_float(rand.nextFloat() * 360.0F), 0.0F); + live.worldObj.spawnEntityInWorld(h); + }else{ + for(int i = 1; i <= 1 + rand.nextInt(1 + (int)(live.getMaxHealth() / 20)); i++){ + EntityHeart[] hearts = {new EntityHeart(live.worldObj), new EntityHalfHeart(entity.worldObj)}; + EntityHeart h = hearts[rand.nextInt(2)]; + h.setType(type); + h.setLocationAndAngles(live.posX, live.posY, live.posZ, MathHelper.wrapAngleTo180_float(rand.nextFloat() * 360.0F), 0.0F); + live.worldObj.spawnEntityInWorld(h); + } + } + } + if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer){ + EntityPlayer player = (EntityPlayer)event.source.getEntity(); + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) + if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.entityDeathAction(player.worldObj, event.entityLiving, player); + } + } + if (entity instanceof EntityPlayer){ + EntityPlayer player = (EntityPlayer)entity; + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + playerInfo.setFloat("BlueHeart", 0f); + playerInfo.setFloat("BlackHeart", 0f); + playerInfo.setFloat("WhiteHeart", 0f); + if (playerInfo.hasKey("reselectCurses") && playerInfo.getBoolean("reselectCurses")){ + if (ConfigHandler.CURSES_ENABLED) for(Curse l: Curse.getCurseList()){ + if (l.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(l.getName()) == 1){ + playerInfo.setInteger(l.getName(), 0); + if (!Curse.availableCurses.contains(l)) Curse.availableCurses.add(l); + }else if (l.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(l.getName()) >= 2) playerInfo.setInteger(l.getName(), 1); + } + if (entity.worldObj.isRemote) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); + } + if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) + if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.playerDeathAction(player.worldObj, player); + for(int i = 0; i < 18; i++) + if (playerInfo.hasKey("ext" + i)){ + NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); + ItemStack item = ItemStack.loadItemStackFromNBT(nbt); + if (item != null){ + if (item.getItem() instanceof ItemBaseJewelry) ((ItemBaseJewelry)item.getItem()).onPlayerDead(item, player, event.source); + if (item.getItem() instanceof IJewelryItem) ((IJewelryItem)item.getItem()).onPlayerDeadAction(item, player, event.source); + } + } + } + if (event.entity instanceof EntityPlayer && !(event.entity instanceof EntityPlayerMP)) JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); + } + + /** + * @param event + */ + @SubscribeEvent + public void onWorldLoad(WorldEvent.Load event) + { + if (!event.world.isRemote){ + new File(JewelrycraftMod.dir + File.separator + Variables.MODID).mkdirs(); + JewelrycraftMod.liquidsConf = new File(JewelrycraftMod.dir + File.separator + Variables.MODID, "JLP" + event.world.getWorldInfo().getWorldName() + ".cfg"); + try{ + if (!JewelrycraftMod.liquidsConf.exists()) JewelrycraftMod.liquidsConf.createNewFile(); + } + catch(IOException e){ + e.printStackTrace(); + } + } + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) try{ + if (JewelrycraftMod.liquidsConf.exists()) JewelrycraftMod.saveData = CompressedStreamTools.readCompressed(new FileInputStream(JewelrycraftMod.liquidsConf)); + } + catch(EOFException e){ + e.printStackTrace(); + } + catch(IOException e){ + e.printStackTrace(); + } + } + + /** + * @param event + */ + @SubscribeEvent + public void onWorldSave(WorldEvent.Save event) + { + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) try{ + if (JewelrycraftMod.liquidsConf.exists()) CompressedStreamTools.writeCompressed(JewelrycraftMod.saveData, new FileOutputStream(JewelrycraftMod.liquidsConf)); + } + catch(EOFException e){ + e.printStackTrace(); + } + catch(IOException e){ + e.printStackTrace(); + } + } + + /** + * @param event + */ + @SubscribeEvent + @SideOnly (Side.CLIENT) + public void fogColors(EntityViewRenderEvent.FogColors event) + {} + + /** + * @param event + */ + @SubscribeEvent + @SideOnly (Side.CLIENT) + public void fogDensity(EntityViewRenderEvent.FogDensity event) + {} + + /** + * @param event + */ + @SubscribeEvent + @SideOnly (Side.CLIENT) + public void renderFog(EntityViewRenderEvent.RenderFogEvent event) + {} } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java b/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java index 9eb783f..5da4b7a 100644 --- a/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java +++ b/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java @@ -1,201 +1,234 @@ -package darkknight.jewelrycraft.events; - -import java.nio.FloatBuffer; -import java.util.Iterator; -import net.minecraft.block.Block; -import net.minecraft.block.BlockAir; -import net.minecraft.client.Minecraft; -import net.minecraft.client.model.ModelBiped; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.Vec3; -import net.minecraftforge.client.event.RenderHandEvent; -import net.minecraftforge.client.event.RenderPlayerEvent; -import org.lwjgl.BufferUtils; -import org.lwjgl.opengl.GL11; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import darkknight.jewelrycraft.api.Curse; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.item.render.BraceletRender; -import darkknight.jewelrycraft.item.render.EarringsRender; -import darkknight.jewelrycraft.item.render.NecklaceRender; -import darkknight.jewelrycraft.item.render.RingRender; -import darkknight.jewelrycraft.util.JewelryNBT; - -public class PlayerRenderHandler -{ - EarringsRender earrings = new EarringsRender(); - BraceletRender bracelet = new BraceletRender(); - NecklaceRender necklace = new NecklaceRender(); - RingRender ring = new RingRender(); - public static NBTTagCompound playersInfo = new NBTTagCompound(); - float size = 0.055F; - - @SubscribeEvent - public void renderScreen(RenderPlayerEvent.Specials.Post event) - { - GL11.glPushMatrix(); - ModelBiped main = event.renderer.modelBipedMain; - ModelRenderer rightArm = event.renderer.modelBipedMain.bipedRightArm; - ModelRenderer leftArm = event.renderer.modelBipedMain.bipedLeftArm; - ModelRenderer head = event.renderer.modelBipedMain.bipedHead; - ModelRenderer body = event.renderer.modelBipedMain.bipedBody; - Iterator players = event.entityPlayer.worldObj.playerEntities.iterator(); - if (playersInfo != null){ - while (players.hasNext()){ - int[] gemColor = {-1, -1, -1, -1}; - int[] ingotColor = {-1, -1, -1, -1}; - int gem = -1; - int ingot = -1; - EntityPlayer player = players.next(); - NBTTagCompound playerInfo = (NBTTagCompound)playersInfo.getTag(player.getDisplayName()); - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) - if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0 && event.entityPlayer.getDisplayName().equals(player.getDisplayName()) && playerInfo.getInteger("cursePoints") > 0) curse.playerRender(player, event); - int no = 0; - ModelRenderer arm = rightArm; - if (player.inventory.getCurrentItem() != null && Block.getBlockFromItem(player.inventory.getCurrentItem().getItem()) instanceof BlockAir){ - GL11.glDisable(GL11.GL_LIGHT1); - FloatBuffer colorBuffer = BufferUtils.createFloatBuffer(4); - Vec3 lightPos = Vec3.createVectorHelper(0.0D, 2.0D, 1.0D).normalize(); - colorBuffer.clear(); - colorBuffer.put((float)lightPos.xCoord).put((float)lightPos.yCoord).put((float)lightPos.zCoord).put(-1F); - colorBuffer.flip(); - GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, colorBuffer); - colorBuffer.clear(); - colorBuffer.put(0.03f).put(0.03f).put(0.03f).put(1.0F); - colorBuffer.flip(); - GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, colorBuffer); - // GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, setColorBuffer(var2, var2, var2, 1.0F)); - } - for(int i = 0; i <= 9; i++) - if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){ - gem = -1; - ingot = -1; - if (no > 4) arm = leftArm; - NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); - ItemStack item = ItemStack.loadItemStackFromNBT(nbt); - GL11.glPushMatrix(); - if (arm.rotateAngleX == 0.0F && arm.rotateAngleY == 0.0F && arm.rotateAngleZ == 0.0F){ - if (arm.rotationPointX != 0.0F || arm.rotationPointY != 0.0F || arm.rotationPointZ != 0.0F) GL11.glTranslatef(arm.rotationPointX * size, arm.rotationPointY * size, arm.rotationPointZ * size); - }else{ - GL11.glTranslatef(arm.rotationPointX * size, arm.rotationPointY * size, arm.rotationPointZ * size); - if (arm.rotateAngleZ != 0.0F) GL11.glRotatef(arm.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); - if (arm.rotateAngleY != 0.0F) GL11.glRotatef(arm.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); - if (arm.rotateAngleX != 0.0F) GL11.glRotatef(arm.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); - } - if (JewelryNBT.ingot(item) != null) ingot = JewelryNBT.ingotColor(item); - if (JewelryNBT.gem(item) != null) gem = JewelryNBT.gemColor(item); - if (no <= 4) GL11.glTranslatef(0.64F + 0.05F * no, -1.15F, 0.07F); - else GL11.glTranslatef(0.59F + 0.05F * no, -1.15F, 0.07F); - GL11.glScalef(0.1f, 0.15f, 0.1f); - ring.doRender(event.entityPlayer, 0F, 0F, (float)ingot, (float)gem, 0F); - GL11.glPopMatrix(); - no++; - } - for(int i = 10; i <= 13; i++) - if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){ - NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); - ItemStack item = ItemStack.loadItemStackFromNBT(nbt); - if (JewelryNBT.gem(item) != null) gemColor[i - 10] = JewelryNBT.gemColor(item); - if (JewelryNBT.ingot(item) != null) ingotColor[i - 10] = JewelryNBT.ingotColor(item); - } - if ((playerInfo.hasKey("ext10") || playerInfo.hasKey("ext11")) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){ - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 1); - if (rightArm.rotateAngleX == 0.0F && rightArm.rotateAngleY == 0.0F && rightArm.rotateAngleZ == 0.0F){ - if (rightArm.rotationPointX != 0.0F || rightArm.rotationPointY != 0.0F || rightArm.rotationPointZ != 0.0F) GL11.glTranslatef(rightArm.rotationPointX * size, rightArm.rotationPointY * size, rightArm.rotationPointZ * size); - }else{ - GL11.glTranslatef(rightArm.rotationPointX * size, rightArm.rotationPointY * size, rightArm.rotationPointZ * size); - if (rightArm.rotateAngleZ != 0.0F) GL11.glRotatef(rightArm.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); - if (rightArm.rotateAngleY != 0.0F) GL11.glRotatef(rightArm.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); - if (rightArm.rotateAngleX != 0.0F) GL11.glRotatef(rightArm.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); - } - GL11.glScalef(0.05f, 0.03f, 0.05f); - bracelet.doRender(event.entityPlayer, (float)ingotColor[0], (float)gemColor[0], (float)ingotColor[1], (float)gemColor[1], 0.0F); - GL11.glPopMatrix(); - } - if ((playerInfo.hasKey("ext12") || playerInfo.hasKey("ext13")) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){ - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 1); - if (leftArm.rotateAngleX == 0.0F && leftArm.rotateAngleY == 0.0F && leftArm.rotateAngleZ == 0.0F){ - if (leftArm.rotationPointX != 0.0F || leftArm.rotationPointY != 0.0F || leftArm.rotationPointZ != 0.0F) GL11.glTranslatef(leftArm.rotationPointX * size, leftArm.rotationPointY * size, leftArm.rotationPointZ * size); - }else{ - GL11.glTranslatef(leftArm.rotationPointX * size + 0.2F, leftArm.rotationPointY * size, leftArm.rotationPointZ * size); - if (leftArm.rotateAngleZ != 0.0F) GL11.glRotatef(leftArm.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); - if (leftArm.rotateAngleY != 0.0F) GL11.glRotatef(leftArm.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); - if (leftArm.rotateAngleX != 0.0F) GL11.glRotatef(leftArm.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); - } - GL11.glScalef(0.05f, 0.03f, 0.05f); - bracelet.doRender(event.entityPlayer, (float)ingotColor[2], (float)gemColor[2], (float)ingotColor[3], (float)gemColor[3], 0F); - GL11.glPopMatrix(); - } - no = 0; - for(int i = 14; i <= 16; i++) - if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){ - gem = -1; - ingot = -1; - NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); - ItemStack item = ItemStack.loadItemStackFromNBT(nbt); - GL11.glPushMatrix(); - if (body.rotateAngleX == 0.0F && body.rotateAngleY == 0.0F && body.rotateAngleZ == 0.0F){ - if (body.rotationPointX != 0.0F || body.rotationPointY != 0.0F || body.rotationPointZ != 0.0F) GL11.glTranslatef(body.rotationPointX * size, body.rotationPointY * size, body.rotationPointZ * size); - }else{ - GL11.glTranslatef(body.rotationPointX * size, body.rotationPointY * size, body.rotationPointZ * size); - if (body.rotateAngleZ != 0.0F) GL11.glRotatef(body.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); - if (body.rotateAngleY != 0.0F) GL11.glRotatef(body.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); - if (body.rotateAngleX != 0.0F) GL11.glRotatef(body.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); - } - GL11.glScalef(0.0625f, 0.0625f, 0.0625f); - if (JewelryNBT.gem(item) != null) gem = JewelryNBT.gemColor(item); - if (JewelryNBT.ingot(item) != null) ingot = JewelryNBT.ingotColor(item); - if (no > 0){ - GL11.glRotatef(no == 1 ? 25f : -25f, 0F, 0f, 1f); - GL11.glRotatef(no == 1 ? -5f : -10f, 1F, 0f, 0f); - } - necklace.doRender(event.entityPlayer, 0F, 0F, (float)ingot, (float)gem, 0F); - GL11.glPopMatrix(); - no++; - } - if (playerInfo.hasKey("ext17") && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){ - gem = -1; - ingot = -1; - NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext17"); - ItemStack item = ItemStack.loadItemStackFromNBT(nbt); - GL11.glPushMatrix(); - if (head.rotateAngleX == 0.0F && head.rotateAngleY == 0.0F && head.rotateAngleZ == 0.0F){ - if (head.rotationPointX != 0.0F || head.rotationPointY != 0.0F || head.rotationPointZ != 0.0F) GL11.glTranslatef(head.rotationPointX * size, head.rotationPointY * size, head.rotationPointZ * size); - }else{ - GL11.glTranslatef(head.rotationPointX * size, head.rotationPointY * size, head.rotationPointZ * size); - if (head.rotateAngleZ != 0.0F) GL11.glRotatef(head.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); - if (head.rotateAngleY != 0.0F) GL11.glRotatef(head.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); - if (head.rotateAngleX != 0.0F) GL11.glRotatef(head.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); - } - GL11.glScalef(0.0625f, 0.0625f, 0.0625f); - GL11.glTranslatef(0.0F, 1.0F, -2.0F); - if (JewelryNBT.gem(item) != null) gem = JewelryNBT.gemColor(item); - if (JewelryNBT.ingot(item) != null) ingot = JewelryNBT.ingotColor(item); - earrings.doRender(event.entityPlayer, 0F, 0F, (float)ingot, (float)gem, 0F); - GL11.glPopMatrix(); - } - } - } - GL11.glPopMatrix(); - } - - float rot = 0F; - - @SubscribeEvent - public void renderHand(RenderHandEvent event) - { - if (playersInfo != null){ - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - if (player != null){ - NBTTagCompound playerInfo = (NBTTagCompound)playersInfo.getTag(player.getDisplayName()); - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) - if (curse.canCurseBeActivated(player.worldObj) && curse != null && playerInfo != null && playerInfo.hasKey(curse.getName()) && playerInfo.getInteger(curse.getName()) > 0 && playerInfo.hasKey("cursePoints") && playerInfo.getInteger("cursePoints") > 0) curse.playerHandRender(player, event); - } - } - } -} +package darkknight.jewelrycraft.events; + +import java.nio.FloatBuffer; +import java.util.Iterator; +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.client.Minecraft; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.Vec3; +import net.minecraftforge.client.event.RenderHandEvent; +import net.minecraftforge.client.event.RenderPlayerEvent; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import darkknight.jewelrycraft.api.Curse; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.item.render.BraceletRender; +import darkknight.jewelrycraft.item.render.EarringsRender; +import darkknight.jewelrycraft.item.render.NecklaceRender; +import darkknight.jewelrycraft.item.render.RingRender; +import darkknight.jewelrycraft.util.JewelryNBT; + +public class PlayerRenderHandler +{ + EarringsRender earrings = new EarringsRender(); + BraceletRender bracelet = new BraceletRender(); + NecklaceRender necklace = new NecklaceRender(); + RingRender ring = new RingRender(); + public static NBTTagCompound playersInfo = new NBTTagCompound(); + float size = 0.055F; + + @SubscribeEvent + public void renderScreen(RenderPlayerEvent.Specials.Post event) + { + GL11.glPushMatrix(); + ModelBiped main = event.renderer.modelBipedMain; + ModelRenderer rightArm = event.renderer.modelBipedMain.bipedRightArm; + ModelRenderer leftArm = event.renderer.modelBipedMain.bipedLeftArm; + ModelRenderer head = event.renderer.modelBipedMain.bipedHead; + ModelRenderer body = event.renderer.modelBipedMain.bipedBody; + Iterator players = event.entityPlayer.worldObj.playerEntities.iterator(); + float rotAngleX = 0F, rotAngleY = 0F, rotAngleZ = 0F; + if (playersInfo != null){ + while (players.hasNext()){ + int[] gemColor = {-1, -1, -1, -1}; + int[] ingotColor = {-1, -1, -1, -1}; + int gem = -1; + int ingot = -1; + EntityPlayer player = players.next(); + NBTTagCompound playerInfo = (NBTTagCompound)playersInfo.getTag(player.getDisplayName()); + if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) + if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0 && event.entityPlayer.getDisplayName().equals(player.getDisplayName()) && playerInfo.getInteger("cursePoints") > 0) curse.playerRender(player, event); + int no = 0; + ModelRenderer arm = rightArm; + if (player.inventory.getCurrentItem() != null && Block.getBlockFromItem(player.inventory.getCurrentItem().getItem()) instanceof BlockAir){ + GL11.glDisable(GL11.GL_LIGHT1); + FloatBuffer colorBuffer = BufferUtils.createFloatBuffer(4); + Vec3 lightPos = Vec3.createVectorHelper(0.0D, 2.0D, 1.0D).normalize(); + colorBuffer.clear(); + colorBuffer.put((float)lightPos.xCoord).put((float)lightPos.yCoord).put((float)lightPos.zCoord).put(-1F); + colorBuffer.flip(); + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, colorBuffer); + colorBuffer.clear(); + colorBuffer.put(0.03f).put(0.03f).put(0.03f).put(1.0F); + colorBuffer.flip(); + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, colorBuffer); + } + for(int i = 0; i <= 9; i++) + if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){ + gem = -1; + ingot = -1; + if (no > 4) arm = leftArm; + float s = 0.055F; + NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); + ItemStack item = ItemStack.loadItemStackFromNBT(nbt); + if (Loader.isModLoaded("alpaca")) arm = body; + GL11.glPushMatrix(); + if (arm.rotateAngleX == 0.0F && arm.rotateAngleY == 0.0F && arm.rotateAngleZ == 0.0F){ + if ((arm.rotationPointX + rotAngleX) != 0.0F || (arm.rotationPointY + rotAngleY) != 0.0F || (arm.rotationPointZ + rotAngleZ) != 0.0F) GL11.glTranslatef((arm.rotationPointX + rotAngleX) * s, (arm.rotationPointY + rotAngleY) * s, (arm.rotationPointZ + rotAngleZ) * s); + }else if(!Loader.isModLoaded("alpaca")){ + GL11.glTranslatef((arm.rotationPointX + rotAngleX) * s, (arm.rotationPointY + rotAngleY) * s, (arm.rotationPointZ + rotAngleZ) * s); + if (arm.rotateAngleZ != 0.0F) GL11.glRotatef(arm.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + if (arm.rotateAngleY != 0.0F) GL11.glRotatef(arm.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + if (arm.rotateAngleX != 0.0F) GL11.glRotatef(arm.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + } + if (JewelryNBT.ingot(item) != null) ingot = JewelryNBT.ingotColor(item); + if (JewelryNBT.gem(item) != null) gem = JewelryNBT.gemColor(item); + float scale = 0.1f; + if (Loader.isModLoaded("alpaca")){ + if (no <= 4){ + GL11.glTranslatef(0.35F, -4.35F, -2.8F + 0.15F * no); + GL11.glRotatef(90f, 0F, 1F, 0F); + } + else{ + GL11.glTranslatef(-0.35F, -4.35F, 1.48F + 0.15F * no); + GL11.glRotatef(-90f, 0F, 1F, 0F); + } + scale = 0.3F; + } + else{ + if (no <= 4) GL11.glTranslatef(0.64F + 0.05F * no, -1.15F, 0.07F); + else GL11.glTranslatef(0.59F + 0.05F * no, -1.15F, 0.07F); + } + GL11.glScalef(scale, scale + scale/2, scale); + ring.doRender(event.entityPlayer, 0F, 0F, (float)ingot, (float)gem, 0F); + GL11.glPopMatrix(); + no++; + } + for(int i = 10; i <= 13; i++) + if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){ + NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); + ItemStack item = ItemStack.loadItemStackFromNBT(nbt); + if (JewelryNBT.gem(item) != null) gemColor[i - 10] = JewelryNBT.gemColor(item); + if (JewelryNBT.ingot(item) != null) ingotColor[i - 10] = JewelryNBT.ingotColor(item); + } + if ((playerInfo.hasKey("ext10") || playerInfo.hasKey("ext11")) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){ + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 1); + if (Loader.isModLoaded("alpaca")) + { + rightArm = body; + GL11.glTranslatef(0.0F, 0.05F, 0.0F); + GL11.glRotatef(-30F, 0.0F, 1.0F, 0.0F); + } + if (rightArm.rotateAngleX == 0.0F && rightArm.rotateAngleY == 0.0F && rightArm.rotateAngleZ == 0.0F){ + if ((rightArm.rotationPointX + rotAngleX) != 0.0F || (rightArm.rotationPointY + rotAngleY) != 0.0F || (rightArm.rotationPointZ + rotAngleZ) != 0.0F) GL11.glTranslatef((rightArm.rotationPointX + rotAngleX) * size, (rightArm.rotationPointY + rotAngleY) * size, (rightArm.rotationPointZ + rotAngleZ) * size); + }else if(!Loader.isModLoaded("alpaca")){ + GL11.glTranslatef((rightArm.rotationPointX + rotAngleX) * size, (rightArm.rotationPointY + rotAngleY) * size, (rightArm.rotationPointZ + rotAngleZ) * size); + if (rightArm.rotateAngleZ != 0.0F) GL11.glRotatef(rightArm.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + if (rightArm.rotateAngleY != 0.0F) GL11.glRotatef(rightArm.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + if (rightArm.rotateAngleX != 0.0F) GL11.glRotatef(rightArm.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + } + GL11.glScalef(0.05f, 0.03f, 0.05f); + bracelet.doRender(event.entityPlayer, (float)ingotColor[0], (float)gemColor[0], (float)ingotColor[1], (float)gemColor[1], 0.0F); + GL11.glPopMatrix(); + } + if ((playerInfo.hasKey("ext12") || playerInfo.hasKey("ext13")) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){ + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 1); + if (Loader.isModLoaded("alpaca")) + { + leftArm = body; + GL11.glTranslatef(-0.1F, 0.0F, 0.1F); + GL11.glRotatef(-140F, 0.0F, 1.0F, 0.0F); + } + if (leftArm.rotateAngleX == 0.0F && leftArm.rotateAngleY == 0.0F && leftArm.rotateAngleZ == 0.0F){ + if ((leftArm.rotationPointX + rotAngleX) != 0.0F || (leftArm.rotationPointY + rotAngleY) != 0.0F || (leftArm.rotationPointZ + rotAngleZ) != 0.0F) GL11.glTranslatef((leftArm.rotationPointX + rotAngleX) * size, (leftArm.rotationPointY + rotAngleY) * size, (leftArm.rotationPointZ + rotAngleZ) * size); + }else if(!Loader.isModLoaded("alpaca")){ + GL11.glTranslatef((leftArm.rotationPointX + rotAngleX) * size + 0.2F, (leftArm.rotationPointY + rotAngleY) * size, (leftArm.rotationPointZ + rotAngleZ) * size); + if (leftArm.rotateAngleZ != 0.0F) GL11.glRotatef(leftArm.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + if (leftArm.rotateAngleY != 0.0F) GL11.glRotatef(leftArm.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + if (leftArm.rotateAngleX != 0.0F) GL11.glRotatef(leftArm.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + } + GL11.glScalef(0.05f, 0.03f, 0.05f); + bracelet.doRender(event.entityPlayer, (float)ingotColor[2], (float)gemColor[2], (float)ingotColor[3], (float)gemColor[3], 0F); + GL11.glPopMatrix(); + } + no = 0; + for(int i = 14; i <= 16; i++) + if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){ + gem = -1; + ingot = -1; + NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i); + ItemStack item = ItemStack.loadItemStackFromNBT(nbt); + GL11.glPushMatrix(); + if (body.rotateAngleX == 0.0F && body.rotateAngleY == 0.0F && body.rotateAngleZ == 0.0F){ + if (body.rotationPointX != 0.0F || body.rotationPointY != 0.0F || body.rotationPointZ != 0.0F) GL11.glTranslatef(body.rotationPointX * size, body.rotationPointY * size, body.rotationPointZ * size); + }else if(!Loader.isModLoaded("alpaca")){ + GL11.glTranslatef(body.rotationPointX * size, body.rotationPointY * size, body.rotationPointZ * size); + if (body.rotateAngleZ != 0.0F) GL11.glRotatef(body.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + if (body.rotateAngleY != 0.0F) GL11.glRotatef(body.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + if (body.rotateAngleX != 0.0F) GL11.glRotatef(body.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + } + if (Loader.isModLoaded("alpaca")) GL11.glTranslatef(0.0F, 0.55F, -0.28F); + GL11.glScalef(0.0625f, 0.0625f, 0.0625f); + if (JewelryNBT.gem(item) != null) gem = JewelryNBT.gemColor(item); + if (JewelryNBT.ingot(item) != null) ingot = JewelryNBT.ingotColor(item); + if (no > 0){ + GL11.glRotatef(no == 1 ? 25f : -25f, 0F, 0f, 1f); + GL11.glRotatef(no == 1 ? -5f : -10f, 1F, 0f, 0f); + } + necklace.doRender(event.entityPlayer, 0F, 0F, (float)ingot, (float)gem, 0F); + GL11.glPopMatrix(); + no++; + } + if (playerInfo.hasKey("ext17") && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){ + gem = -1; + ingot = -1; + NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext17"); + ItemStack item = ItemStack.loadItemStackFromNBT(nbt); + GL11.glPushMatrix(); + float s = 0.0625F; + if (Loader.isModLoaded("alpaca")) head = body; + if (head.rotateAngleX == 0.0F && head.rotateAngleY == 0.0F && head.rotateAngleZ == 0.0F){ + if (head.rotationPointX != 0.0F || head.rotationPointY != 0.0F || head.rotationPointZ != 0.0F) GL11.glTranslatef(head.rotationPointX * size, head.rotationPointY * size, head.rotationPointZ * size); + }else if(!Loader.isModLoaded("alpaca")){ + GL11.glTranslatef(head.rotationPointX * size, head.rotationPointY * size, head.rotationPointZ * size); + if (head.rotateAngleZ != 0.0F) GL11.glRotatef(head.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + if (head.rotateAngleY != 0.0F) GL11.glRotatef(head.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + if (head.rotateAngleX != 0.0F) GL11.glRotatef(head.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + } + if (Loader.isModLoaded("alpaca")) GL11.glTranslatef(0.0F, 0.7F, -0.2F); + GL11.glScalef(s, s, s); + GL11.glTranslatef(0.0F, 1.0F, -2.0F); + if (JewelryNBT.gem(item) != null) gem = JewelryNBT.gemColor(item); + if (JewelryNBT.ingot(item) != null) ingot = JewelryNBT.ingotColor(item); + earrings.doRender(event.entityPlayer, 0F, 0F, (float)ingot, (float)gem, 0F); + GL11.glPopMatrix(); + } + } + } + GL11.glPopMatrix(); + } + + float rot = 0F; + + @SubscribeEvent + public void renderHand(RenderHandEvent event) + { + if (playersInfo != null){ + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + if (player != null){ + NBTTagCompound playerInfo = (NBTTagCompound)playersInfo.getTag(player.getDisplayName()); + if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) + if (curse.canCurseBeActivated(player.worldObj) && curse != null && playerInfo != null && playerInfo.hasKey(curse.getName()) && playerInfo.getInteger(curse.getName()) > 0 && playerInfo.hasKey("cursePoints") && playerInfo.getInteger("cursePoints") > 0) curse.playerHandRender(player, event); + } + } + } +} diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java index 41a44e1..8a3af07 100644 --- a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java +++ b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java @@ -1,276 +1,278 @@ -package darkknight.jewelrycraft.item; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import javax.imageio.ImageIO; -import net.minecraft.block.Block; -import net.minecraft.block.BlockAir; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.DamageSource; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IIcon; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; -import net.minecraftforge.event.entity.player.PlayerEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.api.ModifierEffects; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.Variables; - -public abstract class ItemBaseJewelry extends Item -{ - public ItemBaseJewelry() - { - super(); - setMaxStackSize(1); - setCreativeTab(JewelrycraftMod.jewelrycraft); - } - - public boolean requiresMultipleRenderPasses() - { - return true; - } - - @SideOnly (Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int pass) - { - try{ - return color(stack, pass); - } - catch(IOException e){ - e.printStackTrace(); - } - return 16777215; - } - - /** - * @param stack - * @param pass - * @return - * @throws IOException - */ - public static int color(ItemStack stack, int pass) throws IOException - { - IResourceManager rm = Minecraft.getMinecraft().getResourceManager(); - BufferedImage icon; - if (pass == 0 && stack != null && JewelryNBT.ingot(stack) != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0 && JewelryNBT.ingot(stack).getIconIndex() != null && JewelryNBT.ingotColor(stack) == 16777215){ - ItemStack ingot = JewelryNBT.ingot(stack); - icon = ImageIO.read(rm.getResource(getLocation(ingot, stack, true)).getInputStream()); - int height = icon.getHeight(); - int width = icon.getWidth(); - Map m = new HashMap(); - for(int i = 0; i < width; i++) - for(int j = 0; j < height; j++){ - int rgb = icon.getRGB(i, j); - int red = rgb >> 16 & 0xff; - int green = rgb >> 8 & 0xff; - int blue = rgb & 0xff; - int[] rgbArr = {red, green, blue}; - int Cmax = Math.max(red, Math.max(green, blue)); - int Cmin = Math.min(red, Math.min(green, blue)); - if (!isGray(rgbArr)) m.put(rgb, (Cmax + Cmin) / 2); - } - int color = getMostCommonColour(m); - if (JewelryNBT.ingot(stack) != null && JewelryNBT.ingot(stack).getItem().getColorFromItemStack(JewelryNBT.ingot(stack), 1) != 16777215) JewelryNBT.addIngotColor(stack, JewelryNBT.ingot(stack).getItem().getColorFromItemStack(JewelryNBT.ingot(stack), 1)); - else JewelryNBT.addIngotColor(stack, color); - }else if (pass == 1 && stack != null && stack.getItem() != null && JewelryNBT.gem(stack) != null && !(Block.getBlockFromItem(JewelryNBT.gem(stack).getItem()) instanceof BlockAir) && JewelryNBT.gem(stack).getIconIndex() != null){ - ItemStack gem = JewelryNBT.gem(stack); - icon = ImageIO.read(rm.getResource(getLocation(gem, stack, true)).getInputStream()); - int height = icon.getHeight(); - int width = icon.getWidth(); - Map m = new HashMap(); - for(int i = 0; i < width; i++) - for(int j = 0; j < height; j++){ - int rgb = icon.getRGB(i, j); - int red = rgb >> 16 & 0xff; - int green = rgb >> 8 & 0xff; - int blue = rgb & 0xff; - int[] rgbArr = {red, green, blue}; - int Cmax = Math.max(red, Math.max(green, blue)); - int Cmin = Math.min(red, Math.min(green, blue)); - if (!isGray(rgbArr)) m.put(rgb, (Cmax + Cmin) / 2); - } - int color = getMostCommonColour(m); - if (JewelryNBT.gem(stack).getItem().getColorFromItemStack(JewelryNBT.gem(stack), 1) == 16777215) JewelryNBT.addGemColor(stack, color); - else JewelryNBT.addGemColor(stack, JewelryNBT.gem(stack).getItem().getColorFromItemStack(JewelryNBT.gem(stack), 1)); - } - if (pass == 0 && JewelryNBT.ingot(stack) != null) return JewelryNBT.ingotColor(stack); - if (pass == 1 && JewelryNBT.gem(stack) != null) return JewelryNBT.gemColor(stack); - else if (JewelryNBT.ingot(stack) != null) return JewelryNBT.ingotColor(stack); - return 16777215; - } - - /** - * @param item - * @param stack - * @param changeMeta - * @return - */ - public static ResourceLocation getLocation(ItemStack item, ItemStack stack, boolean changeMeta) - { - String domain = ""; - String texture; - if (changeMeta && (Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.carpet))) item.setItemDamage(15 - item.getItemDamage()); - IIcon itemIcon = item.getItem().getIcon(item, 0); - String iconName = itemIcon.getIconName(); - if (iconName.substring(0, iconName.indexOf(":") + 1) != "") domain = iconName.substring(0, iconName.indexOf(":") + 1).replace(":", " ").trim(); - else domain = "minecraft"; - texture = iconName.substring(iconName.lastIndexOf(":") + 1) + ".png"; - ResourceLocation textureLocation = null; - TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - if (texturemanager.getResourceLocation(item.getItemSpriteNumber()).toString().contains("items")) textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/items/" + texture); - else textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/blocks/" + texture); - return textureLocation; - } - - /** - * @param map - * @return - */ - public static int getMostCommonColour(Map map) - { - List list = new LinkedList(map.entrySet()); - Collections.sort(list, new Comparator(){ - public int compare(Object o1, Object o2) - { - return ((Comparable)((Map.Entry)o1).getValue()).compareTo(((Map.Entry)o2).getValue()); - } - }); - Map.Entry me = (Map.Entry)list.get(list.size() - 1); - for(int i = 0; i < list.size(); i++){ - float alpha = Float.valueOf(list.get(i).toString().split("=")[1]); - if (alpha < 180) me = (Map.Entry)list.get(i); - } - int rgb = (Integer)me.getKey(); - return rgb; - } - - /** - * @param rgbArr - * @return - */ - public static boolean isGray(int[] rgbArr) - { - int rgbSum = rgbArr[0] + rgbArr[1] + rgbArr[2]; - if (rgbSum > 0 && rgbSum < 256 * 3) return false; - return true; - } - - /** - * @param stack - * @return - */ - public String getItemStackDisplayName(ItemStack stack) - { - if (JewelryNBT.ingot(stack) != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) return JewelryNBT.ingot(stack).getDisplayName().replace("Ingot", " ").trim() + " " + ("" + StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name")).trim(); - return ("" + StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name")).trim(); - } - - /** - * allows items to add custom lines of information to the mouseover description. - * - * @param stack - * @param player - * @param list - * @param par4 - */ - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) - { - if (stack.hasTagCompound() && par4){ - ItemStack ingot = JewelryNBT.ingot(stack); - if (ingot != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".metal") +": " + EnumChatFormatting.YELLOW + ingot.getDisplayName().replace(StatCollector.translateToLocal("info." + Variables.MODID + ".ingot"), " ")); - ItemStack gem = JewelryNBT.gem(stack); - if (gem != null) list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".gem")+": " + EnumChatFormatting.BLUE + gem.getDisplayName()); - ArrayList modifier = JewelryNBT.modifier(stack); - if (!modifier.isEmpty()) list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".modifiers")+": "); - for(int i = 0; i < modifier.size(); i++) - list.add(EnumChatFormatting.DARK_PURPLE + modifier.get(i).getDisplayName() + " x" + modifier.get(i).stackSize); - } - } - - /** - * @param stack - * @param player - */ - public void action(ItemStack stack, EntityPlayer player) - { - for(ModifierEffects mod: ModifierEffects.getEffects()) - mod.action(stack, player, this); - } - - /** - * @param item - * @param player - * @param source - * @return - */ - public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, float amount) - { - for(ModifierEffects mod: ModifierEffects.getEffects()) - return mod.onPlayerAttackedCacellable(item, player, source, this, amount); - return false; - } - - /** - * @param item - * @param player - * @param target - * @return - */ - public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, float amount) - { - for(ModifierEffects mod: ModifierEffects.getEffects()) - return mod.onEntityAttackedCacellable(item, player, target, this, amount); - return false; - } - - /** - * @param item - * @param player - * @param source - * @return - */ - public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, float amount) - { - for(ModifierEffects mod: ModifierEffects.getEffects()) mod.onPlayerAttacked(item, player, source, this, amount); - } - - /** - * @param item - * @param player - * @param target - * @return - */ - public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, float amount) - { - for(ModifierEffects mod: ModifierEffects.getEffects()) mod.onEntityAttacked(item, player, target, this, amount); - } - - public void onPlayerDead(ItemStack stack, EntityPlayer player, DamageSource source) - { - for(ModifierEffects mod: ModifierEffects.getEffects()) - mod.onPlayerDead(stack, player, source, this); - } - - public void onPlayerRespawn(ItemStack stack, PlayerEvent.Clone event) - { - for(ModifierEffects mod: ModifierEffects.getEffects()) - mod.onPlayerRespawn(stack, event, this); - } -} +package darkknight.jewelrycraft.item; + +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import javax.imageio.ImageIO; +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraftforge.event.entity.player.PlayerEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.api.ModifierEffects; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.Variables; + +public abstract class ItemBaseJewelry extends Item +{ + public ItemBaseJewelry() + { + super(); + setMaxStackSize(1); + setCreativeTab(JewelrycraftMod.jewelrycraft); + } + + public boolean requiresMultipleRenderPasses() + { + return true; + } + + @SideOnly (Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int pass) + { + try{ + return color(stack, pass); + } + catch(IOException e){ + e.printStackTrace(); + } + return 16777215; + } + + /** + * @param stack + * @param pass + * @return + * @throws IOException + */ + public static int color(ItemStack stack, int pass) throws IOException + { + IResourceManager rm = Minecraft.getMinecraft().getResourceManager(); + BufferedImage icon; + if (pass == 0 && stack != null && JewelryNBT.ingot(stack) != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0 && JewelryNBT.ingot(stack).getIconIndex() != null && JewelryNBT.ingotColor(stack) == 16777215){ + ItemStack ingot = JewelryNBT.ingot(stack); + icon = ImageIO.read(rm.getResource(getLocation(ingot, stack, true)).getInputStream()); + int height = icon.getHeight(); + int width = icon.getWidth(); + Map m = new HashMap(); + for(int i = 0; i < width; i++) + for(int j = 0; j < height; j++){ + int rgb = icon.getRGB(i, j); + int red = rgb >> 16 & 0xff; + int green = rgb >> 8 & 0xff; + int blue = rgb & 0xff; + int[] rgbArr = {red, green, blue}; + int Cmax = Math.max(red, Math.max(green, blue)); + int Cmin = Math.min(red, Math.min(green, blue)); + if (!isGray(rgbArr)) m.put(rgb, (Cmax + Cmin) / 2); + } + int color = getMostCommonColour(m); + if (JewelryNBT.ingot(stack) != null && JewelryNBT.ingot(stack).getItem().getColorFromItemStack(JewelryNBT.ingot(stack), 1) != 16777215) JewelryNBT.addIngotColor(stack, JewelryNBT.ingot(stack).getItem().getColorFromItemStack(JewelryNBT.ingot(stack), 1)); + else JewelryNBT.addIngotColor(stack, color); + }else if (pass == 1 && stack != null && stack.getItem() != null && JewelryNBT.gem(stack) != null && !(Block.getBlockFromItem(JewelryNBT.gem(stack).getItem()) instanceof BlockAir) && JewelryNBT.gem(stack).getIconIndex() != null){ + ItemStack gem = JewelryNBT.gem(stack); + icon = ImageIO.read(rm.getResource(getLocation(gem, stack, true)).getInputStream()); + int height = icon.getHeight(); + int width = icon.getWidth(); + Map m = new HashMap(); + for(int i = 0; i < width; i++) + for(int j = 0; j < height; j++){ + int rgb = icon.getRGB(i, j); + int red = rgb >> 16 & 0xff; + int green = rgb >> 8 & 0xff; + int blue = rgb & 0xff; + int[] rgbArr = {red, green, blue}; + int Cmax = Math.max(red, Math.max(green, blue)); + int Cmin = Math.min(red, Math.min(green, blue)); + if (!isGray(rgbArr)) m.put(rgb, (Cmax + Cmin) / 2); + } + int color = getMostCommonColour(m); + if (JewelryNBT.gem(stack).getItem().getColorFromItemStack(JewelryNBT.gem(stack), 1) == 16777215) JewelryNBT.addGemColor(stack, color); + else JewelryNBT.addGemColor(stack, JewelryNBT.gem(stack).getItem().getColorFromItemStack(JewelryNBT.gem(stack), 1)); + } + if (pass == 0 && JewelryNBT.ingot(stack) != null) return JewelryNBT.ingotColor(stack); + if (pass == 1 && JewelryNBT.gem(stack) != null) return JewelryNBT.gemColor(stack); + else if (JewelryNBT.ingot(stack) != null) return JewelryNBT.ingotColor(stack); + return 16777215; + } + + /** + * @param item + * @param stack + * @param changeMeta + * @return + */ + public static ResourceLocation getLocation(ItemStack item, ItemStack stack, boolean changeMeta) + { + String domain = ""; + String texture; + if (changeMeta && (Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(item.getItem()) == Block.getIdFromBlock(Blocks.carpet))) item.setItemDamage(15 - item.getItemDamage()); + IIcon itemIcon = item.getItem().getIcon(item, 0); + String iconName = itemIcon.getIconName(); + if (iconName.substring(0, iconName.indexOf(":") + 1) != "") domain = iconName.substring(0, iconName.indexOf(":") + 1).replace(":", " ").trim(); + else domain = "minecraft"; + texture = iconName.substring(iconName.lastIndexOf(":") + 1) + ".png"; + ResourceLocation textureLocation = null; + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + if (texturemanager.getResourceLocation(item.getItemSpriteNumber()).toString().contains("items")) textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/items/" + texture); + else textureLocation = new ResourceLocation(domain.toLowerCase(), "textures/blocks/" + texture); + return textureLocation; + } + + /** + * @param map + * @return + */ + public static int getMostCommonColour(Map map) + { + List list = new LinkedList(map.entrySet()); + Collections.sort(list, new Comparator(){ + public int compare(Object o1, Object o2) + { + return ((Comparable)((Map.Entry)o1).getValue()).compareTo(((Map.Entry)o2).getValue()); + } + }); + Map.Entry me = (Map.Entry)list.get(list.size() - 1); + for(int i = 0; i < list.size(); i++){ + float alpha = Float.valueOf(list.get(i).toString().split("=")[1]); + if (alpha < 180) me = (Map.Entry)list.get(i); + } + int rgb = (Integer)me.getKey(); + return rgb; + } + + /** + * @param rgbArr + * @return + */ + public static boolean isGray(int[] rgbArr) + { + int rgbSum = rgbArr[0] + rgbArr[1] + rgbArr[2]; + if (rgbSum > 0 && rgbSum < 256 * 3) return false; + return true; + } + + /** + * @param stack + * @return + */ + public String getItemStackDisplayName(ItemStack stack) + { + if (JewelryNBT.ingot(stack) != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) return JewelryNBT.ingot(stack).getDisplayName().replace("Ingot", " ").trim() + " " + ("" + StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name")).trim(); + return ("" + StatCollector.translateToLocal(getUnlocalizedNameInefficiently(stack) + ".name")).trim(); + } + + /** + * allows items to add custom lines of information to the mouseover description. + * + * @param stack + * @param player + * @param list + * @param par4 + */ + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) + { + if (stack.hasTagCompound() && par4){ + ItemStack ingot = JewelryNBT.ingot(stack); + if (ingot != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".metal") + ": " + EnumChatFormatting.YELLOW + ingot.getDisplayName().replace(StatCollector.translateToLocal("info." + Variables.MODID + ".ingot"), " ")); + ItemStack gem = JewelryNBT.gem(stack); + if (gem != null) list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".gem") + ": " + EnumChatFormatting.BLUE + gem.getDisplayName()); + ArrayList modifier = JewelryNBT.modifier(stack); + if (!modifier.isEmpty()) list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".modifiers") + ": "); + for(int i = 0; i < modifier.size(); i++) + list.add(EnumChatFormatting.DARK_PURPLE + modifier.get(i).getDisplayName() + " x" + modifier.get(i).stackSize); + } + } + + /** + * @param stack + * @param player + */ + public void action(ItemStack item, EntityPlayer player) + { + for(ModifierEffects mod: ModifierEffects.getEffects()) + if (JewelryNBT.doesModifierExist(item, mod.getModifier())) mod.action(item, player, this); + } + + /** + * @param item + * @param player + * @param source + * @return + */ + public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, float amount) + { + for(ModifierEffects mod: ModifierEffects.getEffects()) + return JewelryNBT.doesModifierExist(item, mod.getModifier()) ? mod.onPlayerAttackedCacellable(item, player, source, this, amount) : false; + return false; + } + + /** + * @param item + * @param player + * @param target + * @return + */ + public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, float amount) + { + for(ModifierEffects mod: ModifierEffects.getEffects()) + return JewelryNBT.doesModifierExist(item, mod.getModifier()) ? mod.onEntityAttackedCacellable(item, player, target, this, amount) : false; + return false; + } + + /** + * @param item + * @param player + * @param source + * @return + */ + public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, float amount) + { + for(ModifierEffects mod: ModifierEffects.getEffects()) + if (JewelryNBT.doesModifierExist(item, mod.getModifier())) mod.onPlayerAttacked(item, player, source, this, amount); + } + + /** + * @param item + * @param player + * @param target + * @return + */ + public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, float amount) + { + for(ModifierEffects mod: ModifierEffects.getEffects()) + if (JewelryNBT.doesModifierExist(item, mod.getModifier())) mod.onEntityAttacked(item, player, target, this, amount); + } + + public void onPlayerDead(ItemStack item, EntityPlayer player, DamageSource source) + { + for(ModifierEffects mod: ModifierEffects.getEffects()) + if (JewelryNBT.doesModifierExist(item, mod.getModifier())) mod.onPlayerDead(item, player, source, this); + } + + public void onPlayerRespawn(ItemStack item, PlayerEvent.Clone event) + { + for(ModifierEffects mod: ModifierEffects.getEffects()) + if (JewelryNBT.doesModifierExist(item, mod.getModifier())) mod.onPlayerRespawn(item, event, this); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemStructureGen.java b/src/main/java/darkknight/jewelrycraft/item/ItemStructureGen.java index 6b736d2..25f5f4d 100644 --- a/src/main/java/darkknight/jewelrycraft/item/ItemStructureGen.java +++ b/src/main/java/darkknight/jewelrycraft/item/ItemStructureGen.java @@ -1,44 +1,42 @@ -package darkknight.jewelrycraft.item; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ChatComponentText; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.WorldGenerator; -import darkknight.jewelrycraft.worldGen.WorldGenStructure1; - -public class ItemStructureGen extends Item -{ - int structure = 0; - WorldGenerator[] structures = new WorldGenerator[]{new WorldGenStructure1(), new WorldGenStructure1(), new WorldGenStructure1()}; - - public ItemStructureGen() - { - super(); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) - { - if (!world.isRemote){ - if (!player.isSneaking()){ - if (structure < structures.length - 1) structure++; - else structure = 0; - }else - { - if (structure > 0) structure--; - else structure = structures.length - 1; - } - player.addChatMessage(new ChatComponentText("Structure no. " + structure)); - } - return stack; - } - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par1, float par2, float par3, float par4) - { - structures[structure].generate(world, itemRand, x, y + 1, z); - return true; - } +package darkknight.jewelrycraft.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChatComponentText; +import net.minecraft.world.World; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +public class ItemStructureGen extends Item +{ + int no = 0; + + public ItemStructureGen() + { + super(); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { + if (!world.isRemote){ + if (!player.isSneaking()){ + if (no < JewelrycraftUtil.structures.size() - 1) no++; + else no = 0; + }else + { + if (no > 0) no--; + else no = JewelrycraftUtil.structures.size() - 1; + } + player.addChatMessage(new ChatComponentText("Structure no. " + (no + 1))); + } + return stack; + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par1, float par2, float par3, float par4) + { + JewelrycraftUtil.structures.get(no).generate(world, itemRand, x, y + 1, z); + return true; + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/item/render/BraceletRender.java b/src/main/java/darkknight/jewelrycraft/item/render/BraceletRender.java index e9609ae..047cd93 100644 --- a/src/main/java/darkknight/jewelrycraft/item/render/BraceletRender.java +++ b/src/main/java/darkknight/jewelrycraft/item/render/BraceletRender.java @@ -1,31 +1,37 @@ -package darkknight.jewelrycraft.item.render; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -import darkknight.jewelrycraft.model.ModelBracelet; -import darkknight.jewelrycraft.util.Variables; - -public class BraceletRender extends TileEntitySpecialRenderer -{ - public ModelBracelet bracelet = new ModelBracelet(); - ResourceLocation texture = new ResourceLocation(Variables.MODID, "textures/entities/Bracelet.png"); - - @Override - public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) - { - } - - public void doRender(Entity entity, double x, double y, double z, float f, float g) - { - GL11.glPushMatrix(); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - if ((float)z != -1) bracelet.render(entity, 0F, 0F, 0F, (float)z, f, 1.0F); - GL11.glTranslatef(0F, 3F, 0F); - if ((float)x != -1) bracelet.render(entity, 0F, 0F, 0F, (float)x, (float)y, 1.0F); - GL11.glPopMatrix(); - } +package darkknight.jewelrycraft.item.render; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import cpw.mods.fml.common.Loader; +import darkknight.jewelrycraft.model.ModelBracelet; +import darkknight.jewelrycraft.util.Variables; + +public class BraceletRender extends TileEntitySpecialRenderer +{ + public ModelBracelet bracelet = new ModelBracelet(); + ResourceLocation texture = new ResourceLocation(Variables.MODID, "textures/entities/Bracelet.png"); + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) + { + } + + public void doRender(Entity entity, double x, double y, double z, float f, float g) + { + GL11.glPushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + if ((float)z != -1) bracelet.render(entity, 0F, 0F, 0F, (float)z, f, 1.0F); + if (Loader.isModLoaded("alpaca")){ + GL11.glTranslatef(1F, 0F, -9F); + GL11.glRotatef(25F, 1F, 0F, 0F); + GL11.glRotatef(-25F, 0F, 1F, 0F); + } + else GL11.glTranslatef(0F, 3F, 0F); + if ((float)x != -1) bracelet.render(entity, 0F, 0F, 0F, (float)x, (float)y, 1.0F); + GL11.glPopMatrix(); + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/item/render/MaskRender.java b/src/main/java/darkknight/jewelrycraft/item/render/MaskRender.java index 3bd4afe..b4e20a9 100644 --- a/src/main/java/darkknight/jewelrycraft/item/render/MaskRender.java +++ b/src/main/java/darkknight/jewelrycraft/item/render/MaskRender.java @@ -1,33 +1,33 @@ -package darkknight.jewelrycraft.item.render; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -import darkknight.jewelrycraft.model.ModelMask; -import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; -import darkknight.jewelrycraft.util.Variables; - -public class MaskRender extends TileEntitySpecialRenderer -{ - ModelMask mask = new ModelMask(); - ResourceLocation texture = new ResourceLocation(Variables.MODID, "textures/entities/Mask.png"); - - @Override - public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) - { - } - - public void doRender(Entity entity, double x, double y, double z, float f, float g) - { - GL11.glPushMatrix(); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - GL11.glTranslatef(0.1615F, 0F, 0.03F); - GL11.glScalef(1.0F, 1.0F, 0.5F); - mask.render(entity, 0F, 0F, 0F, 0F, 0F, 0.02F); - GL11.glPopMatrix(); - } +package darkknight.jewelrycraft.item.render; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import darkknight.jewelrycraft.model.ModelMask; +import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; +import darkknight.jewelrycraft.util.Variables; + +public class MaskRender extends TileEntitySpecialRenderer +{ + ModelMask mask = new ModelMask(); + ResourceLocation texture = new ResourceLocation(Variables.MODID, "textures/entities/Mask.png"); + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) + { + } + + public void doRender(Entity entity, double x, double y, double z, float f, float g) + { + GL11.glPushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + GL11.glTranslatef(0.1615F, 0F, 0.03F); + GL11.glScalef(1.0F, 1.0F, 0.5F); + mask.render(entity, 0F, 0F, 0F, 0F, 0F, 0.02F); + GL11.glPopMatrix(); + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/item/render/RingRender.java b/src/main/java/darkknight/jewelrycraft/item/render/RingRender.java index 084f716..5385fe1 100644 --- a/src/main/java/darkknight/jewelrycraft/item/render/RingRender.java +++ b/src/main/java/darkknight/jewelrycraft/item/render/RingRender.java @@ -1,29 +1,29 @@ -package darkknight.jewelrycraft.item.render; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -import darkknight.jewelrycraft.model.ModelRing; -import darkknight.jewelrycraft.util.Variables; - -public class RingRender extends TileEntitySpecialRenderer -{ - public ModelRing ring = new ModelRing(); - ResourceLocation texture = new ResourceLocation(Variables.MODID, "textures/entities/Ring.png"); - - @Override - public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) - { - } - - public void doRender(Entity entity, double x, double y, double z, float f, float g) - { - GL11.glPushMatrix(); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - if ((float)z != -1) ring.render(entity, 0F, 0F, 0F, (float)z, f, 1.0F); - GL11.glPopMatrix(); - } +package darkknight.jewelrycraft.item.render; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import darkknight.jewelrycraft.model.ModelRing; +import darkknight.jewelrycraft.util.Variables; + +public class RingRender extends TileEntitySpecialRenderer +{ + public ModelRing ring = new ModelRing(); + ResourceLocation texture = new ResourceLocation(Variables.MODID, "textures/entities/Ring.png"); + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) + { + } + + public void doRender(Entity entity, double x, double y, double z, float f, float g) + { + GL11.glPushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + if ((float)z != -1) ring.render(entity, 0F, 0F, 0F, (float)z, f, 1.0F); + GL11.glPopMatrix(); + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java b/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java index 8c58e47..01d1303 100644 --- a/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java +++ b/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java @@ -1,120 +1,120 @@ -package darkknight.jewelrycraft.proxy; - -import net.minecraft.client.Minecraft; -import net.minecraft.item.Item; -import net.minecraftforge.client.MinecraftForgeClient; -import net.minecraftforge.common.MinecraftForge; -import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.client.registry.RenderingRegistry; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.registry.VillagerRegistry; -import cpw.mods.fml.relauncher.Side; -import darkknight.jewelrycraft.block.BlockList; -import darkknight.jewelrycraft.block.render.BlockCrystalRenderer; -import darkknight.jewelrycraft.client.InventoryTabVanilla; -import darkknight.jewelrycraft.client.TabJewelry; -import darkknight.jewelrycraft.client.TabRegistry; -import darkknight.jewelrycraft.client.gui.GuiHandler; -import darkknight.jewelrycraft.entities.EntityHalfHeart; -import darkknight.jewelrycraft.entities.EntityHeart; -import darkknight.jewelrycraft.entities.renders.HeartRender; -import darkknight.jewelrycraft.events.KeyBindings; -import darkknight.jewelrycraft.events.PlayerRenderHandler; -import darkknight.jewelrycraft.events.ScreenHandler; -import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.item.render.ItemRender; -import darkknight.jewelrycraft.model.ModelDisplayer; -import darkknight.jewelrycraft.model.ModelHalfHeart; -import darkknight.jewelrycraft.model.ModelHandPedestal; -import darkknight.jewelrycraft.model.ModelHeart; -import darkknight.jewelrycraft.model.ModelJewlersCraftingBench; -import darkknight.jewelrycraft.model.ModelMolder; -import darkknight.jewelrycraft.model.ModelShadowEye; -import darkknight.jewelrycraft.model.ModelShadowHand; -import darkknight.jewelrycraft.model.ModelSmelter; -import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; -import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; -import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; -import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch; -import darkknight.jewelrycraft.tileentity.TileEntityMolder; -import darkknight.jewelrycraft.tileentity.TileEntityShadowEye; -import darkknight.jewelrycraft.tileentity.TileEntityShadowHand; -import darkknight.jewelrycraft.tileentity.TileEntitySmelter; -import darkknight.jewelrycraft.tileentity.renders.TileEntityDisplayerRender; -import darkknight.jewelrycraft.tileentity.renders.TileEntityHandPedestalRender; -import darkknight.jewelrycraft.tileentity.renders.TileEntityJewelrsCraftingTableRender; -import darkknight.jewelrycraft.tileentity.renders.TileEntityMidasTouchRender; -import darkknight.jewelrycraft.tileentity.renders.TileEntityMolderRender; -import darkknight.jewelrycraft.tileentity.renders.TileEntityShadowEyeRender; -import darkknight.jewelrycraft.tileentity.renders.TileEntityShadowHandRender; -import darkknight.jewelrycraft.tileentity.renders.TileEntitySmelterRender; -import darkknight.jewelrycraft.util.JewelrycraftUtil; -import darkknight.jewelrycraft.util.Variables; - -public class ClientProxy extends CommonProxy -{ - public enum BlockRenderIDs { - CRYSTAL; - - private final int ID; - - BlockRenderIDs() - { - ID = RenderingRegistry.getNextAvailableRenderId(); - } - - public int id() - { - return ID; - } - } - - @Override - public void preInit() - { - TileEntityHandPedestalRender pedestalRender = new TileEntityHandPedestalRender(new ModelHandPedestal(Variables.PEDESTAL_TEXTURE), Variables.PEDESTAL_TEXTURE); - TileEntityShadowHandRender shadowHandRender = new TileEntityShadowHandRender(new ModelShadowHand(Variables.SHADOW_HAND_TEXTURE), Variables.SHADOW_HAND_TEXTURE); - - ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySmelter.class, new TileEntitySmelterRender()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMolder.class, new TileEntityMolderRender()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityJewelrsCraftingTable.class, new TileEntityJewelrsCraftingTableRender()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDisplayer.class, new TileEntityDisplayerRender()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityShadowEye.class, new TileEntityShadowEyeRender()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMidasTouch.class, new TileEntityMidasTouchRender()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityHandPedestal.class, pedestalRender); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityShadowHand.class, shadowHandRender); - - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.displayer), new ItemRender(new TileEntityDisplayerRender(), new TileEntityDisplayer(), new ModelDisplayer())); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.jewelCraftingTable), new ItemRender(new TileEntityJewelrsCraftingTableRender(), new TileEntityJewelrsCraftingTable(), new ModelJewlersCraftingBench())); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.smelter), new ItemRender(new TileEntitySmelterRender(), new TileEntitySmelter(), new ModelSmelter())); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.molder), new ItemRender(new TileEntityMolderRender(), new TileEntityMolder(), new ModelMolder())); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.shadowEye), new ItemRender(new TileEntityShadowEyeRender(), new TileEntityShadowEye(), new ModelShadowEye())); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.handPedestal), new ItemRender(pedestalRender, new TileEntityHandPedestal(), new ModelHandPedestal(Variables.PEDESTAL_TEXTURE))); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.shadowHand), new ItemRender(shadowHandRender, new TileEntityShadowHand(), new ModelShadowHand(Variables.SHADOW_HAND_TEXTURE))); - MinecraftForgeClient.registerItemRenderer(ItemList.goldObj, new ItemRender()); - - VillagerRegistry.instance().registerVillagerSkin(3000, Variables.VILLAGER_TEXTURE); - - RenderingRegistry.registerEntityRenderingHandler(EntityHeart.class, new HeartRender(new ModelHeart(), 0.25F)); - RenderingRegistry.registerEntityRenderingHandler(EntityHalfHeart.class, new HeartRender(new ModelHalfHeart(), 0.25F)); - - RenderingRegistry.registerBlockHandler(new BlockCrystalRenderer()); - - TabRegistry.registerTab(new InventoryTabVanilla()); - TabRegistry.registerTab(new TabJewelry()); - MinecraftForge.EVENT_BUS.register(new TabRegistry()); - MinecraftForge.EVENT_BUS.register(new PlayerRenderHandler()); - MinecraftForge.EVENT_BUS.register(new ScreenHandler(Minecraft.getMinecraft())); - } - - @Override - public void init() - { - FMLCommonHandler.instance().bus().register(new KeyBindings()); - } - - @Override - public void postInit() - { - } -} +package darkknight.jewelrycraft.proxy; + +import net.minecraft.client.Minecraft; +import net.minecraft.item.Item; +import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.common.MinecraftForge; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.registry.VillagerRegistry; +import cpw.mods.fml.relauncher.Side; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.block.render.BlockCrystalRenderer; +import darkknight.jewelrycraft.client.InventoryTabVanilla; +import darkknight.jewelrycraft.client.TabJewelry; +import darkknight.jewelrycraft.client.TabRegistry; +import darkknight.jewelrycraft.client.gui.GuiHandler; +import darkknight.jewelrycraft.entities.EntityHalfHeart; +import darkknight.jewelrycraft.entities.EntityHeart; +import darkknight.jewelrycraft.entities.renders.HeartRender; +import darkknight.jewelrycraft.events.KeyBindings; +import darkknight.jewelrycraft.events.PlayerRenderHandler; +import darkknight.jewelrycraft.events.ScreenHandler; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.item.render.ItemRender; +import darkknight.jewelrycraft.model.ModelDisplayer; +import darkknight.jewelrycraft.model.ModelHalfHeart; +import darkknight.jewelrycraft.model.ModelHandPedestal; +import darkknight.jewelrycraft.model.ModelHeart; +import darkknight.jewelrycraft.model.ModelJewlersCraftingBench; +import darkknight.jewelrycraft.model.ModelMolder; +import darkknight.jewelrycraft.model.ModelShadowEye; +import darkknight.jewelrycraft.model.ModelShadowHand; +import darkknight.jewelrycraft.model.ModelSmelter; +import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; +import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; +import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; +import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch; +import darkknight.jewelrycraft.tileentity.TileEntityMolder; +import darkknight.jewelrycraft.tileentity.TileEntityShadowEye; +import darkknight.jewelrycraft.tileentity.TileEntityShadowHand; +import darkknight.jewelrycraft.tileentity.TileEntitySmelter; +import darkknight.jewelrycraft.tileentity.renders.TileEntityDisplayerRender; +import darkknight.jewelrycraft.tileentity.renders.TileEntityHandPedestalRender; +import darkknight.jewelrycraft.tileentity.renders.TileEntityJewelrsCraftingTableRender; +import darkknight.jewelrycraft.tileentity.renders.TileEntityMidasTouchRender; +import darkknight.jewelrycraft.tileentity.renders.TileEntityMolderRender; +import darkknight.jewelrycraft.tileentity.renders.TileEntityShadowEyeRender; +import darkknight.jewelrycraft.tileentity.renders.TileEntityShadowHandRender; +import darkknight.jewelrycraft.tileentity.renders.TileEntitySmelterRender; +import darkknight.jewelrycraft.util.JewelrycraftUtil; +import darkknight.jewelrycraft.util.Variables; + +public class ClientProxy extends CommonProxy +{ + public enum BlockRenderIDs { + CRYSTAL; + + private final int ID; + + BlockRenderIDs() + { + ID = RenderingRegistry.getNextAvailableRenderId(); + } + + public int id() + { + return ID; + } + } + + @Override + public void preInit() + { + TileEntityHandPedestalRender pedestalRender = new TileEntityHandPedestalRender(new ModelHandPedestal(Variables.PEDESTAL_TEXTURE), Variables.PEDESTAL_TEXTURE); + TileEntityShadowHandRender shadowHandRender = new TileEntityShadowHandRender(new ModelShadowHand(Variables.SHADOW_HAND_TEXTURE), Variables.SHADOW_HAND_TEXTURE); + + ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySmelter.class, new TileEntitySmelterRender()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMolder.class, new TileEntityMolderRender()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityJewelrsCraftingTable.class, new TileEntityJewelrsCraftingTableRender()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDisplayer.class, new TileEntityDisplayerRender()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityShadowEye.class, new TileEntityShadowEyeRender()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMidasTouch.class, new TileEntityMidasTouchRender()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityHandPedestal.class, pedestalRender); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityShadowHand.class, shadowHandRender); + + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.displayer), new ItemRender(new TileEntityDisplayerRender(), new TileEntityDisplayer(), new ModelDisplayer())); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.jewelCraftingTable), new ItemRender(new TileEntityJewelrsCraftingTableRender(), new TileEntityJewelrsCraftingTable(), new ModelJewlersCraftingBench())); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.smelter), new ItemRender(new TileEntitySmelterRender(), new TileEntitySmelter(), new ModelSmelter())); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.molder), new ItemRender(new TileEntityMolderRender(), new TileEntityMolder(), new ModelMolder())); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.shadowEye), new ItemRender(new TileEntityShadowEyeRender(), new TileEntityShadowEye(), new ModelShadowEye())); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.handPedestal), new ItemRender(pedestalRender, new TileEntityHandPedestal(), new ModelHandPedestal(Variables.PEDESTAL_TEXTURE))); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.shadowHand), new ItemRender(shadowHandRender, new TileEntityShadowHand(), new ModelShadowHand(Variables.SHADOW_HAND_TEXTURE))); + MinecraftForgeClient.registerItemRenderer(ItemList.goldObj, new ItemRender()); + + VillagerRegistry.instance().registerVillagerSkin(3000, Variables.VILLAGER_TEXTURE); + + RenderingRegistry.registerEntityRenderingHandler(EntityHeart.class, new HeartRender(new ModelHeart(), 0.25F)); + RenderingRegistry.registerEntityRenderingHandler(EntityHalfHeart.class, new HeartRender(new ModelHalfHeart(), 0.25F)); + + RenderingRegistry.registerBlockHandler(new BlockCrystalRenderer()); + + TabRegistry.registerTab(new InventoryTabVanilla()); + TabRegistry.registerTab(new TabJewelry()); + MinecraftForge.EVENT_BUS.register(new TabRegistry()); + MinecraftForge.EVENT_BUS.register(new PlayerRenderHandler()); + MinecraftForge.EVENT_BUS.register(new ScreenHandler(Minecraft.getMinecraft())); + } + + @Override + public void init() + { + FMLCommonHandler.instance().bus().register(new KeyBindings()); + } + + @Override + public void postInit() + { + } +} diff --git a/src/main/java/darkknight/jewelrycraft/random/WeightedRandomCurse.java b/src/main/java/darkknight/jewelrycraft/random/WeightedRandomCurse.java new file mode 100644 index 0000000..117b514 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/random/WeightedRandomCurse.java @@ -0,0 +1,23 @@ +package darkknight.jewelrycraft.random; + +import java.util.Random; +import darkknight.jewelrycraft.api.Curse; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandom; + +public class WeightedRandomCurse extends WeightedRandom.Item +{ + private final Curse curse; + + public WeightedRandomCurse(Curse curse, int weight) + { + super(weight); + this.curse = curse; + } + + public Curse getCurse(Random random) + { + return curse; + } +} \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/random/WeightedRandomItem.java b/src/main/java/darkknight/jewelrycraft/random/WeightedRandomItem.java new file mode 100644 index 0000000..8e28973 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/random/WeightedRandomItem.java @@ -0,0 +1,67 @@ +package darkknight.jewelrycraft.random; + +import java.util.Random; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandom; + +public class WeightedRandomItem extends WeightedRandom.Item +{ + private final ItemStack item; + private int maxMeta, minMeta, minItem, maxItem; + + public WeightedRandomItem(ItemStack item, int weight) + { + super(weight); + this.item = item; + this.minItem = 1; + this.maxItem = 1; + this.maxMeta = 0; + this.minMeta = 0; + } + + public WeightedRandomItem(ItemStack item, int maxMetadata, int weight) + { + this(item, weight); + this.maxMeta = maxMetadata; + } + + public WeightedRandomItem(ItemStack item, int weight, int minItem, int maxItem) + { + this(item, weight); + this.minItem = minItem; + this.maxItem = maxItem; + } + + public WeightedRandomItem setMaxMetadata(int meta) + { + this.maxMeta = meta; + return this; + } + + public WeightedRandomItem setMinMetadata(int meta) + { + this.minMeta = meta; + return this; + } + + public WeightedRandomItem setMinItem(int min) + { + this.minItem = min; + return this; + } + + public WeightedRandomItem setMaxItem(int max) + { + this.maxItem = max; + return this; + } + + public ItemStack getItem(Random random) + { + ItemStack itemstack = this.item.copy(); + if(maxMeta > 0) itemstack.setItemDamage(minMeta + random.nextInt(maxMeta - minMeta)); + if(maxItem > 1) itemstack.stackSize = this.minItem + random.nextInt(this.maxItem - this.minItem + 1); + return itemstack; + } +} \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/thirdparty/Alpaca.java b/src/main/java/darkknight/jewelrycraft/thirdparty/Alpaca.java new file mode 100644 index 0000000..09f96b3 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/thirdparty/Alpaca.java @@ -0,0 +1,27 @@ +package darkknight.jewelrycraft.thirdparty; + +/** + * @author Sorin + */ +public class Alpaca implements IThirdParty +{ + @Override + public void preInit() + {} + + @Override + public void init() + {} + + @Override + public void postInit() + {} + + @Override + public void clientSide() + {} + + @Override + public void clientInit() + {} +} diff --git a/src/main/java/darkknight/jewelrycraft/thirdparty/EE3.java b/src/main/java/darkknight/jewelrycraft/thirdparty/EE3.java index 76770b7..7a8a331 100644 --- a/src/main/java/darkknight/jewelrycraft/thirdparty/EE3.java +++ b/src/main/java/darkknight/jewelrycraft/thirdparty/EE3.java @@ -1,41 +1,45 @@ -package darkknight.jewelrycraft.thirdparty; - -import net.minecraft.item.ItemStack; -import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; -import darkknight.jewelrycraft.block.BlockCrystal; -import darkknight.jewelrycraft.block.BlockList; -import darkknight.jewelrycraft.item.ItemClayMolds; -import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.item.ItemMolds; - -public class EE3 implements IThirdParty -{ - @Override - public void preInit() - {} - - @Override - public void init() - {} - - @Override - public void postInit() - { - EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(BlockList.shadowOre), 4096); - EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(BlockList.shadowBlock), 36864); - EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(ItemList.shadowIngot), 4096); - EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(BlockList.jewelCraftingTable), 16640); - EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(ItemList.guide), 288); - for(int i = 0; i < ItemClayMolds.moldsItemNames.length; i++) EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(ItemList.clayMolds, 1, i), 128); - for(int i = 0; i < ItemMolds.moldsItemNames.length; i++) EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(ItemList.molds, 1, i), 128); - for(int i = 0; i < BlockCrystal.colors.length; i++) EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(BlockList.crystal, 1, i), 64); - } - - @Override - public void clientSide() - {} - - @Override - public void clientInit() - {} +package darkknight.jewelrycraft.thirdparty; + +import net.minecraft.item.ItemStack; +import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; +import com.pahimar.ee3.init.ModItems; +import com.pahimar.ee3.reference.Names; +import darkknight.jewelrycraft.block.BlockCrystal; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.item.ItemClayMolds; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.item.ItemMolds; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +public class EE3 implements IThirdParty +{ + @Override + public void preInit() + {} + + @Override + public void init() + {} + + @Override + public void postInit() + { + EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(BlockList.shadowOre), 4096); + EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(BlockList.shadowBlock), 36864); + EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(ItemList.shadowIngot), 4096); + EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(BlockList.jewelCraftingTable), 16640); + EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(ItemList.guide), 288); + for(int i = 0; i < ItemClayMolds.moldsItemNames.length; i++) EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(ItemList.clayMolds, 1, i), 128); + for(int i = 0; i < ItemMolds.moldsItemNames.length; i++) EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(ItemList.molds, 1, i), 128); + for(int i = 0; i < BlockCrystal.colors.length; i++) EnergyValueRegistryProxy.addPostAssignedEnergyValue(new ItemStack(BlockList.crystal, 1, i), 64); + for(int i = 0; i < Names.Items.GEM_SUBTYPES.length; i++) JewelrycraftUtil.gem.add(new ItemStack(ModItems.gem, 1, i)); + } + + @Override + public void clientSide() + {} + + @Override + public void clientInit() + {} } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/thirdparty/ModIds.java b/src/main/java/darkknight/jewelrycraft/thirdparty/ModIds.java index 61fcf99..b4a64c9 100644 --- a/src/main/java/darkknight/jewelrycraft/thirdparty/ModIds.java +++ b/src/main/java/darkknight/jewelrycraft/thirdparty/ModIds.java @@ -1,28 +1,29 @@ -package darkknight.jewelrycraft.thirdparty; - -/** - * @author MineMarteen from Pneumaticraft - */ -public class ModIds{ - public static final String BUILDCRAFT = "BuildCraft|Core"; - public static final String COMPUTERCRAFT = "ComputerCraft"; - public static final String INDUSTRIALCRAFT = "IC2"; - public static final String IGWMOD = "IGWMod"; - public static final String FMP = "ForgeMultipart"; - public static final String WAILA = "Waila"; - public static final String TE = "ThermalExpansion"; - public static final String HC = "HydCraft"; - public static final String NEI = "NotEnoughItems"; - public static final String THAUMCRAFT = "Thaumcraft"; - public static final String BLOOD_MAGIC = "AWWayofTime"; - public static final String AE2 = "appliedenergistics2"; - public static final String CHISEL = "chisel"; - public static final String FORESTRY = "Forestry"; - public static final String MFR = "MineFactoryReloaded"; - public static final String OPEN_BLOCKS = "OpenBlocks"; - public static final String COFH_CORE = "CoFHCore"; - public static final String NOT_ENOUGH_KEYS = "notenoughkeys"; - public static final String OPEN_COMPUTERS = "OpenComputers|Core"; - public static final String EE3 = "EE3"; - public static final String PENUMATICRAFT = "PneumaticCraft"; +package darkknight.jewelrycraft.thirdparty; + +/** + * @author MineMarteen from Pneumaticraft + */ +public class ModIds{ + public static final String BUILDCRAFT = "BuildCraft|Core"; + public static final String COMPUTERCRAFT = "ComputerCraft"; + public static final String INDUSTRIALCRAFT = "IC2"; + public static final String IGWMOD = "IGWMod"; + public static final String FMP = "ForgeMultipart"; + public static final String WAILA = "Waila"; + public static final String TE = "ThermalExpansion"; + public static final String HC = "HydCraft"; + public static final String NEI = "NotEnoughItems"; + public static final String THAUMCRAFT = "Thaumcraft"; + public static final String BLOOD_MAGIC = "AWWayofTime"; + public static final String AE2 = "appliedenergistics2"; + public static final String CHISEL = "chisel"; + public static final String FORESTRY = "Forestry"; + public static final String MFR = "MineFactoryReloaded"; + public static final String OPEN_BLOCKS = "OpenBlocks"; + public static final String COFH_CORE = "CoFHCore"; + public static final String NOT_ENOUGH_KEYS = "notenoughkeys"; + public static final String OPEN_COMPUTERS = "OpenComputers|Core"; + public static final String EE3 = "EE3"; + public static final String PENUMATICRAFT = "PneumaticCraft"; + public static final String ALPACA = "alpaca"; } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/thirdparty/ThirdPartyManager.java b/src/main/java/darkknight/jewelrycraft/thirdparty/ThirdPartyManager.java index 5bc45b6..c2808f9 100644 --- a/src/main/java/darkknight/jewelrycraft/thirdparty/ThirdPartyManager.java +++ b/src/main/java/darkknight/jewelrycraft/thirdparty/ThirdPartyManager.java @@ -1,144 +1,145 @@ -package darkknight.jewelrycraft.thirdparty; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.world.World; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.common.network.IGuiHandler; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.config.ConfigHandler; - -/** - * @author MineMarteen from Pneumaticraft - */ -public class ThirdPartyManager implements IGuiHandler{ - - private static ThirdPartyManager INSTANCE = new ThirdPartyManager(); - private final List thirdPartyMods = new ArrayList(); - - public static ThirdPartyManager instance(){ - return INSTANCE; - } - - public void index(){ - Map> thirdPartyClasses = new HashMap>(); - thirdPartyClasses.put(ModIds.EE3, EE3.class); - - List enabledThirdParty = new ArrayList(); - ConfigHandler.config.addCustomCategoryComment("third_party_enabling", "With these options you can disable third party content by mod. Useful if something in the mod changes and causes crashes."); - for(String modid : thirdPartyClasses.keySet()) { - if(ConfigHandler.config.get("Third_Party_Enabling", modid, true).getBoolean()) { - enabledThirdParty.add(modid); - } - } - ConfigHandler.config.save(); - - for(Map.Entry> entry : thirdPartyClasses.entrySet()) { - if(enabledThirdParty.contains(entry.getKey()) && Loader.isModLoaded(entry.getKey())) { - try { - thirdPartyMods.add(entry.getValue().newInstance()); - } catch(Exception e) { - JewelrycraftMod.logger.log(Level.SEVERE, "Failed to instantiate third party handler!"); - e.printStackTrace(); - } - } - } - } - - public void onItemRegistry(Item item){ - for(IThirdParty thirdParty : thirdPartyMods) { - if(thirdParty instanceof IRegistryListener) ((IRegistryListener)thirdParty).onItemRegistry(item); - } - } - - public void onBlockRegistry(Block block){ - for(IThirdParty thirdParty : thirdPartyMods) { - if(thirdParty instanceof IRegistryListener) ((IRegistryListener)thirdParty).onBlockRegistry(block); - } - } - - public void preInit(){ - for(IThirdParty thirdParty : thirdPartyMods) { - try { - thirdParty.preInit(); - } catch(Throwable e) { - JewelrycraftMod.logger.log(Level.SEVERE, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " in the PreInit phase!"); - e.printStackTrace(); - } - } - } - - public void init(){ - for(IThirdParty thirdParty : thirdPartyMods) { - try { - thirdParty.init(); - } catch(Throwable e) { - JewelrycraftMod.logger.log(Level.SEVERE, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " in the Init phase!"); - e.printStackTrace(); - } - } - } - - public void postInit(){ - for(IThirdParty thirdParty : thirdPartyMods) { - try { - thirdParty.postInit(); - } catch(Throwable e) { - JewelrycraftMod.logger.log(Level.SEVERE, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " in the PostInit phase!"); - e.printStackTrace(); - } - } - } - - public void clientSide(){ - for(IThirdParty thirdParty : thirdPartyMods) { - try { - thirdParty.clientSide(); - } catch(Throwable e) { - JewelrycraftMod.logger.log(Level.SEVERE, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " client side!"); - e.printStackTrace(); - } - } - } - - public void clientInit(){ - for(IThirdParty thirdParty : thirdPartyMods) { - try { - thirdParty.clientInit(); - } catch(Throwable e) { - JewelrycraftMod.logger.log(Level.SEVERE, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " client side on the init!"); - e.printStackTrace(); - } - } - } - - @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z){ - for(IThirdParty thirdParty : thirdPartyMods) { - if(thirdParty instanceof IGuiHandler) { - Object obj = ((IGuiHandler)thirdParty).getServerGuiElement(ID, player, world, x, y, z); - if(obj != null) return obj; - } - } - return null; - } - - @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z){ - for(IThirdParty thirdParty : thirdPartyMods) { - if(thirdParty instanceof IGuiHandler) { - Object obj = ((IGuiHandler)thirdParty).getClientGuiElement(ID, player, world, x, y, z); - if(obj != null) return obj; - } - } - return null; - } - +package darkknight.jewelrycraft.thirdparty; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.world.World; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.network.IGuiHandler; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.config.ConfigHandler; + +/** + * @author MineMarteen from Pneumaticraft + */ +public class ThirdPartyManager implements IGuiHandler{ + + private static ThirdPartyManager INSTANCE = new ThirdPartyManager(); + private final List thirdPartyMods = new ArrayList(); + + public static ThirdPartyManager instance(){ + return INSTANCE; + } + + public void index(){ + Map> thirdPartyClasses = new HashMap>(); + thirdPartyClasses.put(ModIds.EE3, EE3.class); + thirdPartyClasses.put(ModIds.ALPACA, Alpaca.class); + + List enabledThirdParty = new ArrayList(); + ConfigHandler.config.addCustomCategoryComment("third_party_enabling", "With these options you can disable third party content by mod. Useful if something in the mod changes and causes crashes."); + for(String modid : thirdPartyClasses.keySet()) { + if(ConfigHandler.config.get("Third_Party_Enabling", modid, true).getBoolean()) { + enabledThirdParty.add(modid); + } + } + ConfigHandler.config.save(); + + for(Map.Entry> entry : thirdPartyClasses.entrySet()) { + if(enabledThirdParty.contains(entry.getKey()) && Loader.isModLoaded(entry.getKey())) { + try { + thirdPartyMods.add(entry.getValue().newInstance()); + } catch(Exception e) { + JewelrycraftMod.logger.log(Level.SEVERE, "Failed to instantiate third party handler!"); + e.printStackTrace(); + } + } + } + } + + public void onItemRegistry(Item item){ + for(IThirdParty thirdParty : thirdPartyMods) { + if(thirdParty instanceof IRegistryListener) ((IRegistryListener)thirdParty).onItemRegistry(item); + } + } + + public void onBlockRegistry(Block block){ + for(IThirdParty thirdParty : thirdPartyMods) { + if(thirdParty instanceof IRegistryListener) ((IRegistryListener)thirdParty).onBlockRegistry(block); + } + } + + public void preInit(){ + for(IThirdParty thirdParty : thirdPartyMods) { + try { + thirdParty.preInit(); + } catch(Throwable e) { + JewelrycraftMod.logger.log(Level.SEVERE, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " in the PreInit phase!"); + e.printStackTrace(); + } + } + } + + public void init(){ + for(IThirdParty thirdParty : thirdPartyMods) { + try { + thirdParty.init(); + } catch(Throwable e) { + JewelrycraftMod.logger.log(Level.SEVERE, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " in the Init phase!"); + e.printStackTrace(); + } + } + } + + public void postInit(){ + for(IThirdParty thirdParty : thirdPartyMods) { + try { + thirdParty.postInit(); + } catch(Throwable e) { + JewelrycraftMod.logger.log(Level.SEVERE, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " in the PostInit phase!"); + e.printStackTrace(); + } + } + } + + public void clientSide(){ + for(IThirdParty thirdParty : thirdPartyMods) { + try { + thirdParty.clientSide(); + } catch(Throwable e) { + JewelrycraftMod.logger.log(Level.SEVERE, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " client side!"); + e.printStackTrace(); + } + } + } + + public void clientInit(){ + for(IThirdParty thirdParty : thirdPartyMods) { + try { + thirdParty.clientInit(); + } catch(Throwable e) { + JewelrycraftMod.logger.log(Level.SEVERE, "Jewelrycraft wasn't able to load third party content from the third party class " + thirdParty.getClass() + " client side on the init!"); + e.printStackTrace(); + } + } + } + + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z){ + for(IThirdParty thirdParty : thirdPartyMods) { + if(thirdParty instanceof IGuiHandler) { + Object obj = ((IGuiHandler)thirdParty).getServerGuiElement(ID, player, world, x, y, z); + if(obj != null) return obj; + } + } + return null; + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z){ + for(IThirdParty thirdParty : thirdPartyMods) { + if(thirdParty instanceof IGuiHandler) { + Object obj = ((IGuiHandler)thirdParty).getClientGuiElement(ID, player, world, x, y, z); + if(obj != null) return obj; + } + } + return null; + } + } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java index 3325f0d..e8beb57 100644 --- a/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java +++ b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java @@ -1,236 +1,259 @@ -package darkknight.jewelrycraft.util; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Random; -import net.minecraft.entity.EnumCreatureAttribute; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.FurnaceRecipes; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.oredict.OreDictionary; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.registry.GameData; -import cpw.mods.fml.relauncher.Side; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.block.BlockList; -import darkknight.jewelrycraft.item.ItemList; - -public class JewelrycraftUtil -{ - public static ArrayList objects = new ArrayList(); - public static ArrayList gem = new ArrayList(); - public static ArrayList jewelry = new ArrayList(); - public static ArrayList metal = new ArrayList(); - public static ArrayList ores = new ArrayList(); - public static HashMap oreToIngot = new HashMap(); - public static ArrayList jamcraftPlayers = new ArrayList(); - private static ArrayList items = new ArrayList(); - public static Random rand = new Random(); - public static EnumCreatureAttribute HEART; - - /** - * Adds gems and jewelry to their appropriate list - */ - public static void addStuff() - { - // Jewels - for(int i = 0; i < 16; i++) - gem.add(new ItemStack(BlockList.crystal, 1, i)); - gem.add(new ItemStack(Blocks.redstone_block)); - gem.add(new ItemStack(Blocks.lapis_block)); - gem.add(new ItemStack(Blocks.obsidian)); - gem.add(new ItemStack(Items.diamond)); - gem.add(new ItemStack(Items.emerald)); - gem.add(new ItemStack(Items.ender_pearl)); - gem.add(new ItemStack(Items.nether_star)); - // Jewelry - jewelry.add(new ItemStack(ItemList.ring)); - jewelry.add(new ItemStack(ItemList.necklace)); - jewelry.add(new ItemStack(ItemList.bracelet)); - jewelry.add(new ItemStack(ItemList.earrings)); - for(Object item: GameData.getItemRegistry()){ - if (Loader.isModLoaded("Mantle") && ((Item)item).getUnlocalizedName().equals("Mantle:item.mantle.manual")) continue; - try{ - if (item != null && (Item)item != null && ((Item)item).getHasSubtypes() && FMLCommonHandler.instance().getSide() == Side.CLIENT){ - ((Item)item).getSubItems((Item)item, null, items); - }else objects.add(new ItemStack((Item)item)); - if (!items.isEmpty()) objects.addAll(items); - items.removeAll(items); - } - catch(Exception e){ - JewelrycraftMod.logger.info("Error, tried to add subtypes of item " + ((Item)item).getUnlocalizedName() + "\nItem is not added in the list."); - } - } - } - - /** - * Adds curse points to a player - * - * @param player the player to add the points to - * @param points amount of curse points - */ - public static void addCursePoints(EntityPlayer player, int points) - { - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - playerInfo.setInteger("cursePoints", playerInfo.hasKey("cursePoints") ? (playerInfo.getInteger("cursePoints") + points) : points); - playerInfo.setBoolean("playerCursePointsChanged", true); - } - - public static int getCursePoints(EntityPlayer player) - { - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - return playerInfo.getInteger("cursePoints"); - } - - /** - * Adds the UUID's of the jamcrafters in a list - */ - public static void jamcrafters() - { - jamcraftPlayers.add("d3214311-7550-4c9c-a372-d9292c10b8a6"); - jamcraftPlayers.add("a690119f-c4a2-4bd6-a99d-d63679abb328"); - jamcraftPlayers.add("de7c9903-51fa-4a24-88cd-48faf122ca36"); - jamcraftPlayers.add("70aeb298-3a7b-46da-a393-ab10df9359f2"); - jamcraftPlayers.add("6fbe603c-14bf-4085-afdd-abe592c26e7c"); - jamcraftPlayers.add("b0d21306-36bf-4d85-84df-a956d183c45a"); - jamcraftPlayers.add("1733a31f-01f9-4f4d-82aa-7de30ca810d3"); - jamcraftPlayers.add("4833eacf-1d94-49a7-9f89-4cf88d69dcf9"); - jamcraftPlayers.add("718cf671-9084-4e78-b91f-033e80aa11bf"); - jamcraftPlayers.add("bea5e0c4-85c4-454d-a081-e1eaae6895ee"); - jamcraftPlayers.add("7ecf3e2f-fedf-4f7e-8d24-6731d078db4f"); - jamcraftPlayers.add("1b11ad3a-f0ca-4695-a019-2d7e5d83a5fd"); - jamcraftPlayers.add("3ec9ac58-2f1b-4d3f-b4eb-3b875da877ae"); - jamcraftPlayers.add("cf9fa23f-205e-4eed-aba3-9f2848cd6a4d"); - jamcraftPlayers.add("91880caa-b032-48e3-bfe8-c2c7ed31824e"); - jamcraftPlayers.add("8d0b3804-f71c-4219-897b-8c315448ea7c"); - jamcraftPlayers.add("bbb87dbe-690f-4205-bdc5-72ffb8ebc29d"); - } - - /** - * Adds a random amount of modifiers to a list - * - * @param randValue maximum number of modifiers - * @return a list containing the random modifiers - */ - public static ArrayList addRandomModifiers(int randValue) - { - ArrayList list = new ArrayList(); - for(int i = 0; i < 2 + randValue; i++){ - ItemStack item = objects.get(new Random().nextInt(objects.size())); - item.stackSize = 1 + new Random().nextInt(2); - list.add(item); - } - return list; - } - - /** - * Links ores with their appropriate ingot - */ - public static void addMetals() - { - int index = 0; - while (index < OreDictionary.getOreNames().length){ - Iterator i = OreDictionary.getOres(OreDictionary.getOreNames()[index]).iterator(); - while (i.hasNext()){ - ItemStack nextStack = i.next(); - String stackName = nextStack.getItem().getUnlocalizedName().toLowerCase(); - if ((stackName.contains("ingot") || stackName.contains("alloy")) && !metal.contains(nextStack)) - metal.add(nextStack); - if (nextStack.getItem().getUnlocalizedName().toLowerCase().contains("ore") && !ores.contains(nextStack)){ - ItemStack ingot = FurnaceRecipes.smelting().getSmeltingResult(nextStack); - if(ingot != null && (ingot.getItem().getUnlocalizedName().toLowerCase().contains("ingot") || ingot.getItem().getUnlocalizedName().toLowerCase().contains("alloy"))) - { - ores.add(nextStack); - oreToIngot.put(nextStack, ingot); - JewelrycraftMod.logger.info(nextStack + " Adding " + nextStack.getDisplayName() + " with damage value " + nextStack.getItemDamage() + " and with " + nextStack.stackSize + " in stack"); - JewelrycraftMod.logger.info(ingot + " Adding ingot " + ingot.getDisplayName() + " with damage value " + ingot.getItemDamage() + " and with " + ingot.stackSize + " in stack\n"); - } - } - } - index++; - } - } - - /** - * Checks to see if the specified item is a gem - * - * @param item ItemStack containing the item - * @return is the item a gem - */ - public static boolean isGem(ItemStack item) - { - Iterator i = gem.iterator(); - while (i.hasNext()){ - ItemStack temp = i.next(); - if (temp.getItem() == item.getItem() && temp.getItemDamage() == item.getItemDamage()) return true; - } - return false; - } - - /** - * Checks to see if the specified item is a metal - * - * @param item ItemStack containing the item - * @return is the item a metal - */ - public static boolean isMetal(ItemStack item) - { - Iterator i = metal.iterator(); - while (i.hasNext()){ - ItemStack temp = i.next(); - if (temp.getItem() == item.getItem() && temp.getItemDamage() == item.getItemDamage()) return true; - } - return false; - } - - /** - * Checks to see if the specified item is a piece of jewelry - * - * @param item ItemStack containing the item - * @return is the item a piece of jewelry - */ - public static boolean isJewelry(ItemStack item) - { - Iterator i = jewelry.iterator(); - while (i.hasNext()){ - ItemStack temp = i.next(); - if (temp.getItem() == item.getItem() && temp.getItemDamage() == item.getItemDamage()) return true; - } - return false; - } - - /** - * Checks to see if the specified item is an ore - * - * @param item ItemStack containing the item - * @return is the item an ore - */ - public static boolean isOre(ItemStack item) - { - Iterator i = ores.iterator(); - while (i.hasNext()){ - ItemStack temp = i.next(); - if (temp.getItem().equals(item.getItem()) && temp.getItemDamage() == item.getItemDamage()) return true; - } - return false; - } - - /** - * Gets the ingot from the ore - * - * @param ore the ore - * @return the ingot - */ - public static ItemStack getIngotFromOre(ItemStack ore) - { - for(ItemStack ores: JewelrycraftUtil.oreToIngot.keySet()) - if(ores.getItem().equals(ore.getItem()) && ores.getItemDamage() == ore.getItemDamage()) return oreToIngot.get(ores); - return null; - } -} +package darkknight.jewelrycraft.util; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Random; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.registry.GameData; +import cpw.mods.fml.relauncher.Side; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.api.Curse; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.random.WeightedRandomCurse; +import darkknight.jewelrycraft.worldGen.Generation; + +public class JewelrycraftUtil +{ + public static ArrayList objects = new ArrayList(); + public static ArrayList gem = new ArrayList(); + public static ArrayList jewelry = new ArrayList(); + public static ArrayList metal = new ArrayList(); + public static ArrayList ores = new ArrayList(); + public static HashMap oreToIngot = new HashMap(); + public static ArrayList jamcraftPlayers = new ArrayList(); + private static ArrayList items = new ArrayList(); + public static ArrayList structures = new ArrayList(); + public static Random rand = new Random(); + public static EnumCreatureAttribute HEART; + + /** + * Adds gems and jewelry to their appropriate list + */ + public static void addStuff() + { + // Jewels + for(int i = 0; i < 16; i++) + gem.add(new ItemStack(BlockList.crystal, 1, i)); + gem.add(new ItemStack(Blocks.redstone_block)); + gem.add(new ItemStack(Blocks.lapis_block)); + gem.add(new ItemStack(Blocks.obsidian)); + gem.add(new ItemStack(Items.diamond)); + gem.add(new ItemStack(Items.emerald)); + gem.add(new ItemStack(Items.ender_pearl)); + gem.add(new ItemStack(Items.nether_star)); + // Jewelry + jewelry.add(new ItemStack(ItemList.ring)); + jewelry.add(new ItemStack(ItemList.necklace)); + jewelry.add(new ItemStack(ItemList.bracelet)); + jewelry.add(new ItemStack(ItemList.earrings)); + for(Object item: GameData.getItemRegistry()){ + if (Loader.isModLoaded("Mantle") && ((Item)item).getUnlocalizedName().equals("Mantle:item.mantle.manual")) continue; + try{ + if (item != null && (Item)item != null && ((Item)item).getHasSubtypes() && FMLCommonHandler.instance().getSide() == Side.CLIENT){ + ((Item)item).getSubItems((Item)item, null, items); + }else objects.add(new ItemStack((Item)item)); + if (!items.isEmpty()) objects.addAll(items); + items.removeAll(items); + } + catch(Exception e){ + JewelrycraftMod.logger.info("Error, tried to add subtypes of item " + ((Item)item).getUnlocalizedName() + "\nItem is not added in the list."); + } + } + // Structures + try{ + for(Field f: Generation.class.getDeclaredFields()){ + Object obj = f.get(null); + if (obj instanceof WorldGenerator) structures.add((WorldGenerator)obj); + } + } + catch(IllegalAccessException e){ + throw new RuntimeException(e); + } + } + + public static WeightedRandomCurse[] getCurses(World world, EntityPlayer player, Random random) + { + WeightedRandomCurse[] curses = new WeightedRandomCurse[Curse.availableCurses.size()]; + for(int c = 0; c < Curse.availableCurses.size(); c++) + curses[c] = new WeightedRandomCurse(Curse.availableCurses.get(c), Curse.availableCurses.get(c).weight(world, player, random)); + return curses; + } + + /** + * Adds curse points to a player + * + * @param player the player to add the points to + * @param points amount of curse points + */ + public static void addCursePoints(EntityPlayer player, int points) + { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + playerInfo.setInteger("cursePoints", playerInfo.hasKey("cursePoints") ? (playerInfo.getInteger("cursePoints") + points) : points); + playerInfo.setBoolean("playerCursePointsChanged", true); + } + + public static int getCursePoints(EntityPlayer player) + { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + return playerInfo.getInteger("cursePoints"); + } + + /** + * Adds the UUID's of the jamcrafters in a list + */ + public static void jamcrafters() + { + jamcraftPlayers.add("d3214311-7550-4c9c-a372-d9292c10b8a6"); + jamcraftPlayers.add("a690119f-c4a2-4bd6-a99d-d63679abb328"); + jamcraftPlayers.add("de7c9903-51fa-4a24-88cd-48faf122ca36"); + jamcraftPlayers.add("70aeb298-3a7b-46da-a393-ab10df9359f2"); + jamcraftPlayers.add("6fbe603c-14bf-4085-afdd-abe592c26e7c"); + jamcraftPlayers.add("b0d21306-36bf-4d85-84df-a956d183c45a"); + jamcraftPlayers.add("1733a31f-01f9-4f4d-82aa-7de30ca810d3"); + jamcraftPlayers.add("4833eacf-1d94-49a7-9f89-4cf88d69dcf9"); + jamcraftPlayers.add("718cf671-9084-4e78-b91f-033e80aa11bf"); + jamcraftPlayers.add("bea5e0c4-85c4-454d-a081-e1eaae6895ee"); + jamcraftPlayers.add("7ecf3e2f-fedf-4f7e-8d24-6731d078db4f"); + jamcraftPlayers.add("1b11ad3a-f0ca-4695-a019-2d7e5d83a5fd"); + jamcraftPlayers.add("3ec9ac58-2f1b-4d3f-b4eb-3b875da877ae"); + jamcraftPlayers.add("cf9fa23f-205e-4eed-aba3-9f2848cd6a4d"); + jamcraftPlayers.add("91880caa-b032-48e3-bfe8-c2c7ed31824e"); + jamcraftPlayers.add("8d0b3804-f71c-4219-897b-8c315448ea7c"); + jamcraftPlayers.add("bbb87dbe-690f-4205-bdc5-72ffb8ebc29d"); + } + + /** + * Adds a random amount of modifiers to a list + * + * @param randValue maximum number of modifiers + * @return a list containing the random modifiers + */ + public static ArrayList addRandomModifiers(int randValue) + { + ArrayList list = new ArrayList(); + for(int i = 0; i < 2 + randValue; i++){ + ItemStack item = objects.get(new Random().nextInt(objects.size())); + item.stackSize = 1 + new Random().nextInt(2); + list.add(item); + } + return list; + } + + /** + * Links ores with their appropriate ingot + */ + public static void addMetals() + { + int index = 0; + while (index < OreDictionary.getOreNames().length){ + Iterator i = OreDictionary.getOres(OreDictionary.getOreNames()[index]).iterator(); + while (i.hasNext()){ + ItemStack nextStack = i.next(); + String stackName = nextStack.getItem().getUnlocalizedName().toLowerCase(); + if ((stackName.contains("ingot") || stackName.contains("alloy")) && !metal.contains(nextStack)) metal.add(nextStack); + if (nextStack.getItem().getUnlocalizedName().toLowerCase().contains("ore") && !ores.contains(nextStack)){ + ItemStack ingot = FurnaceRecipes.smelting().getSmeltingResult(nextStack); + if (ingot != null && (ingot.getItem().getUnlocalizedName().toLowerCase().contains("ingot") || ingot.getItem().getUnlocalizedName().toLowerCase().contains("alloy"))){ + ores.add(nextStack); + oreToIngot.put(nextStack, ingot); + JewelrycraftMod.logger.info(nextStack + " Adding " + nextStack.getDisplayName() + " with damage value " + nextStack.getItemDamage() + " and with " + nextStack.stackSize + " in stack"); + JewelrycraftMod.logger.info(ingot + " Adding ingot " + ingot.getDisplayName() + " with damage value " + ingot.getItemDamage() + " and with " + ingot.stackSize + " in stack\n"); + } + } + } + index++; + } + } + + /** + * Checks to see if the specified item is a gem + * + * @param item ItemStack containing the item + * @return is the item a gem + */ + public static boolean isGem(ItemStack item) + { + Iterator i = gem.iterator(); + while (i.hasNext()){ + ItemStack temp = i.next(); + if (temp.getItem() == item.getItem() && temp.getItemDamage() == item.getItemDamage()) return true; + } + return false; + } + + /** + * Checks to see if the specified item is a metal + * + * @param item ItemStack containing the item + * @return is the item a metal + */ + public static boolean isMetal(ItemStack item) + { + Iterator i = metal.iterator(); + while (i.hasNext()){ + ItemStack temp = i.next(); + if (temp.getItem() == item.getItem() && temp.getItemDamage() == item.getItemDamage()) return true; + } + return false; + } + + /** + * Checks to see if the specified item is a piece of jewelry + * + * @param item ItemStack containing the item + * @return is the item a piece of jewelry + */ + public static boolean isJewelry(ItemStack item) + { + Iterator i = jewelry.iterator(); + while (i.hasNext()){ + ItemStack temp = i.next(); + if (temp.getItem() == item.getItem() && temp.getItemDamage() == item.getItemDamage()) return true; + } + return false; + } + + /** + * Checks to see if the specified item is an ore + * + * @param item ItemStack containing the item + * @return is the item an ore + */ + public static boolean isOre(ItemStack item) + { + Iterator i = ores.iterator(); + while (i.hasNext()){ + ItemStack temp = i.next(); + if (temp.getItem().equals(item.getItem()) && temp.getItemDamage() == item.getItemDamage()) return true; + } + return false; + } + + /** + * Gets the ingot from the ore + * + * @param ore the ore + * @return the ingot + */ + public static ItemStack getIngotFromOre(ItemStack ore) + { + for(ItemStack ores: JewelrycraftUtil.oreToIngot.keySet()) + if (ores.getItem().equals(ore.getItem()) && ores.getItemDamage() == ore.getItemDamage()) return oreToIngot.get(ores); + return null; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/util/Variables.java b/src/main/java/darkknight/jewelrycraft/util/Variables.java index dc43254..a0abe50 100644 --- a/src/main/java/darkknight/jewelrycraft/util/Variables.java +++ b/src/main/java/darkknight/jewelrycraft/util/Variables.java @@ -1,21 +1,21 @@ -package darkknight.jewelrycraft.util; - -import net.minecraft.util.ResourceLocation; - -public class Variables -{ - public static final String MODID = "jewelrycraft2"; - public static final String MODNAME = "Jewelrycraft 2"; - public static final String VERSION = "1.0.9"; - public static final String PACKET_CHANNEL = "jewelrycraft2"; - - public static final String CONFIG_GUI = "darkknight.jewelrycraft.config.ConfigGuiFactory"; - public static final String CLIENT_PROXY = "darkknight.jewelrycraft.proxy.ClientProxy"; - public static final String SERVER_PROXY = "darkknight.jewelrycraft.proxy.CommonProxy"; - - public static final int MAX_CURSES = 10; - public static final ResourceLocation PEDESTAL_TEXTURE = new ResourceLocation(Variables.MODID, "textures/tileentities/BricksPedestal.png"); - public static final ResourceLocation SHADOW_HAND_TEXTURE = new ResourceLocation(Variables.MODID, "textures/tileentities/ShadowHand.png"); - public static final ResourceLocation VILLAGER_TEXTURE = new ResourceLocation(Variables.MODID, "textures/entities/jeweler.png"); - public static final ResourceLocation MISC_TEXTURE = new ResourceLocation(Variables.MODID, "textures/gui/hearts.png"); -} +package darkknight.jewelrycraft.util; + +import net.minecraft.util.ResourceLocation; + +public class Variables +{ + public static final String MODID = "jewelrycraft2"; + public static final String MODNAME = "Jewelrycraft 2"; + public static final String VERSION = "1.0.10"; + public static final String PACKET_CHANNEL = "jewelrycraft2"; + + public static final String CONFIG_GUI = "darkknight.jewelrycraft.config.ConfigGuiFactory"; + public static final String CLIENT_PROXY = "darkknight.jewelrycraft.proxy.ClientProxy"; + public static final String SERVER_PROXY = "darkknight.jewelrycraft.proxy.CommonProxy"; + + public static final int MAX_CURSES = 10; + public static final ResourceLocation PEDESTAL_TEXTURE = new ResourceLocation(Variables.MODID, "textures/tileentities/BricksPedestal.png"); + public static final ResourceLocation SHADOW_HAND_TEXTURE = new ResourceLocation(Variables.MODID, "textures/tileentities/ShadowHand.png"); + public static final ResourceLocation VILLAGER_TEXTURE = new ResourceLocation(Variables.MODID, "textures/entities/jeweler.png"); + public static final ResourceLocation MISC_TEXTURE = new ResourceLocation(Variables.MODID, "textures/gui/hearts.png"); +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/ChestGeneration.java b/src/main/java/darkknight/jewelrycraft/worldGen/ChestGeneration.java new file mode 100644 index 0000000..f8eb9d5 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/ChestGeneration.java @@ -0,0 +1,103 @@ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraftforge.common.ChestGenHooks; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +/** + * @author Sorin + * + */ +public class ChestGeneration +{ + static Item[] jewelry = new Item[]{ItemList.ring, ItemList.necklace, ItemList.bracelet, ItemList.earrings}; + static Random random = new Random(); + public static void preInit(FMLPreInitializationEvent e) + { + addItemToDifferentPlaces(new WeightedRandomChestContent(new ItemStack(ItemList.thiefGloves), 1, 1, 2), true, true, false, false, true); + addItemToDifferentPlaces(new WeightedRandomChestContent(new ItemStack(ItemList.guide), 1, 1, 7), true, true, true, true, true, false, true, true); + addVillageBlacksmithLoot(new WeightedRandomChestContent(new ItemStack(ItemList.shadowIngot), 1, 4, 5)); + for(int i = 0; i < 16; i++) addItemToDifferentPlaces(new WeightedRandomChestContent(new ItemStack(BlockList.crystal, 1, i), 1, 4, 4), true, true, true, true); + + ItemStack special = new ItemStack(jewelry[random.nextInt(4)]); + int randValue = random.nextInt(4); + if(JewelrycraftUtil.metal.size() > 0) JewelryNBT.addMetal(special, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()))); + if(JewelrycraftUtil.objects.size() > 0) JewelryNBT.addModifiers(special, JewelrycraftUtil.addRandomModifiers(randValue)); + if(JewelrycraftUtil.gem.size() > 0) JewelryNBT.addGem(special, JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size()))); + addItemToDifferentPlaces(new WeightedRandomChestContent(special, 1, 1, 1), true, true, true, true); + } + + /** + * The booleans determine in which places should the items be added. The order is like so: + *

    + *
  • Dungeon + *
  • Stronhold + *
  • Pyramid + *
  • Mineshaft + *
  • Village Blacksmith + *
  • Dispenser + *
  • Bonus Chest + *
  • Stronghold Library + *

+ */ + public static void addItemToDifferentPlaces(WeightedRandomChestContent item, Boolean ... options) + { + if(options.length > 0 && options[0]) addDungeonLoot(item); + if(options.length > 1 && options[1]) addStrongholdLoot(item); + if(options.length > 2 && options[2]) addPyramidLoot(item); + if(options.length > 3 && options[3]) addMineshaftLoot(item); + if(options.length > 4 && options[4]) addVillageBlacksmithLoot(item); + if(options.length > 5 && options[5]) addDispenserLoot(item); + if(options.length > 6 && options[6]) addBonusChestLoot(item); + if(options.length > 7 && options[7]) addStrongholdLibraryLoot(item); + } + + public static void addDungeonLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.DUNGEON_CHEST, item); + } + + public static void addStrongholdLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_CORRIDOR, item); + ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_CROSSING, item); + } + + public static void addPyramidLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.PYRAMID_DESERT_CHEST, item); + ChestGenHooks.addItem(ChestGenHooks.PYRAMID_JUNGLE_CHEST, item); + } + + public static void addMineshaftLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.MINESHAFT_CORRIDOR, item); + } + + public static void addVillageBlacksmithLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.VILLAGE_BLACKSMITH, item); + } + + public static void addDispenserLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.PYRAMID_JUNGLE_DISPENSER, item); + } + + public static void addBonusChestLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.BONUS_CHEST, item); + } + + public static void addStrongholdLibraryLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_LIBRARY, item); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java index d71b44c..d3bd3e5 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java @@ -1,60 +1,139 @@ -package darkknight.jewelrycraft.worldGen; - -import java.util.Random; -import net.minecraft.init.Blocks; -import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkProvider; -import cpw.mods.fml.common.IWorldGenerator; -import darkknight.jewelrycraft.block.BlockList; - -public class Generation implements IWorldGenerator -{ - WorldGenStructure1 STRUCTURE_1 = new WorldGenStructure1(); - - @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) - { - switch(world.provider.dimensionId) - { - case -1: - generateNether(world, random, chunkX << 4, chunkZ << 4); - break; - case 0: - generateSurface(world, random, chunkX << 4, chunkZ << 4); - break; - case 1: - generateEnd(world, random, chunkX << 4, chunkZ << 4); - break; - } - } - - private void generateEnd(World world, Random random, int i, int j) - {} - - private void generateSurface(World world, Random random, int i, int j) - { - for(int k = 0; k < 1; k++){ - int x = i + random.nextInt(16); - int y = 5 + random.nextInt(4); - int z = j + random.nextInt(16); - if (world.getBlock(x, y, z) == Blocks.stone) world.setBlock(x, y, z, BlockList.shadowOre); - int randX = random.nextInt(2), randY = random.nextInt(1), randZ = random.nextInt(2); - if (random.nextInt(3) == 0 && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.stone) world.setBlock(x + randX, y + randY, z + randZ, BlockList.shadowOre); - } - for(int k = 0; k < 16; k++){ - int x = i + random.nextInt(12); - int y = 5 + random.nextInt(64); - int z = j + random.nextInt(12); - for(int r = 0; r < 12; r++){ - int randX = random.nextInt(4); - int randY = random.nextInt(2); - int randZ = random.nextInt(4); - if (world.getBlock(x + randX, y + randY - 1, z + randZ) == Blocks.stone && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.air) - world.setBlock(x + randX, y + randY, z + randZ, BlockList.crystal, random.nextInt(16), 2); - } - } - } - - private void generateNether(World world, Random random, int i, int j) - {} -} +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.feature.WorldGenerator; +import cpw.mods.fml.common.IWorldGenerator; +import darkknight.jewelrycraft.block.BlockList; + +public class Generation implements IWorldGenerator +{ + public static WorldGenStructure1 STRUCTURE_1 = new WorldGenStructure1(); + public static WorldGenStructure2 STRUCTURE_2 = new WorldGenStructure2(); + public static WorldGenStructure3 STRUCTURE_3 = new WorldGenStructure3(); + public static WorldGenStructure4 STRUCTURE_4 = new WorldGenStructure4(); + public static WorldGenStructure5 STRUCTURE_5 = new WorldGenStructure5(); + + // public static WorldGenerator STRUCTURE_6 = new WorldGenStructure6(); + // public static WorldGenerator STRUCTURE_7 = new WorldGenStructure7(); + // public static WorldGenerator STRUCTURE_8 = new WorldGenStructure8(); + // public static WorldGenerator STRUCTURE_9 = new WorldGenStructure9(); + // public static WorldGenerator STRUCTURE_10 = new WorldGenStructure10(); + // public static WorldGenerator STRUCTURE_11 = new WorldGenStructure11(); + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) + { + switch(world.provider.dimensionId) + { + case -1: + generateNether(world, random, chunkX << 4, chunkZ << 4); + break; + case 0: + generateSurface(world, random, chunkX << 4, chunkZ << 4); + break; + case 1: + generateEnd(world, random, chunkX << 4, chunkZ << 4); + break; + } + } + + private void generateEnd(World world, Random random, int i, int j) + {} + + private void generateSurface(World world, Random random, int i, int j) + { + generateShadowOre(world, random, i, j); + generateCrystals(world, random, i, j); + generateStructure1(world, random, i, j); + generateStructure2(world, random, i, j); + generateStructure3(world, random, i, j); + generateStructure4(world, random, i, j); + generateStructure5(world, random, i, j); + } + + private void generateNether(World world, Random random, int i, int j) + {} + + private void generateShadowOre(World world, Random random, int i, int j) + { + for(int k = 0; k < 1; k++){ + int x = i + random.nextInt(16); + int y = 5 + random.nextInt(4); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.stone) world.setBlock(x, y, z, BlockList.shadowOre); + int randX = random.nextInt(2), randY = random.nextInt(1), randZ = random.nextInt(2); + if (random.nextInt(3) == 0 && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.stone) world.setBlock(x + randX, y + randY, z + randZ, BlockList.shadowOre); + } + } + + private void generateCrystals(World world, Random random, int i, int j) + { + for(int k = 0; k < 16; k++){ + int x = i + random.nextInt(12); + int y = 5 + random.nextInt(64); + int z = j + random.nextInt(12); + for(int r = 0; r < 12; r++){ + int randX = random.nextInt(4); + int randY = random.nextInt(2); + int randZ = random.nextInt(4); + if (world.getBlock(x + randX, y + randY - 1, z + randZ) == Blocks.stone && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.air) world.setBlock(x + randX, y + randY, z + randZ, BlockList.crystal, random.nextInt(16), 2); + } + } + } + + private void generateStructure1(World world, Random random, int i, int j) + { + BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); + int x = i + random.nextInt(16); + int y = random.nextInt(100); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone || world.getBlock(x, y - 1, z) == Blocks.sand || world.getBlock(x, y - 1, z) == Blocks.grass)) STRUCTURE_1.generate(world, biomeBase, random, x, y, z); + } + + private void generateStructure2(World world, Random random, int i, int j) + { + BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); + if (random.nextInt(3) == 0){ + int x = i + random.nextInt(16); + int y = random.nextInt(100); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.stone) STRUCTURE_2.generate(world, biomeBase, random, x, y, z); + } + } + + private void generateStructure3(World world, Random random, int i, int j) + { + BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); + if (random.nextInt(3) == 0){ + int x = i + random.nextInt(16); + int y = random.nextInt(100); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.stone) STRUCTURE_3.generate(world, biomeBase, random, x, y, z); + } + } + + private void generateStructure4(World world, Random random, int i, int j) + { + BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); + if (random.nextInt(5) == 0){ + int x = i + random.nextInt(16); + int y = random.nextInt(100); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone || world.getBlock(x, y - 1, z) == Blocks.sand || world.getBlock(x, y - 1, z) == Blocks.grass)) STRUCTURE_4.generate(world, biomeBase, random, x, y, z); + } + } + + private void generateStructure5(World world, Random random, int i, int j) + { + BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); + if (random.nextInt(3) == 0){ + int x = i + random.nextInt(16); + int y = random.nextInt(100); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.stone) STRUCTURE_5.generate(world, biomeBase, random, x, y, z); + } + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java b/src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java deleted file mode 100644 index 0528b66..0000000 --- a/src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java +++ /dev/null @@ -1,67 +0,0 @@ -package darkknight.jewelrycraft.worldGen; - -import java.util.Random; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.util.WeightedRandom; - -public class WeightedRandomItem extends WeightedRandom.Item -{ - private final ItemStack item; - private int maxMeta, minMeta, minItem, maxItem; - - public WeightedRandomItem(ItemStack item, int weight) - { - super(weight); - this.item = item; - this.minItem = 1; - this.maxItem = 1; - this.maxMeta = 0; - this.minMeta = 0; - } - - public WeightedRandomItem(ItemStack item, int maxMetadata, int weight) - { - this(item, weight); - this.maxMeta = maxMetadata; - } - - public WeightedRandomItem(ItemStack item, int weight, int minItem, int maxItem) - { - this(item, weight); - this.minItem = minItem; - this.maxItem = maxItem; - } - - public WeightedRandomItem setMaxMetadata(int meta) - { - this.maxMeta = meta; - return this; - } - - public WeightedRandomItem setMinMetadata(int meta) - { - this.minMeta = meta; - return this; - } - - public WeightedRandomItem setMinItem(int min) - { - this.minItem = min; - return this; - } - - public WeightedRandomItem setMaxItem(int max) - { - this.maxItem = max; - return this; - } - - public ItemStack getItem(Random random) - { - ItemStack itemstack = this.item.copy(); - if(maxMeta > 0) itemstack.setItemDamage(minMeta + random.nextInt(maxMeta - minMeta)); - if(maxItem > 1) itemstack.stackSize = this.minItem + random.nextInt(this.maxItem - this.minItem + 1); - return itemstack; - } -} \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java index 2d11cb5..5d9118f 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java @@ -1,61 +1,60 @@ -/** - * - */ -package darkknight.jewelrycraft.worldGen; - -import java.util.Arrays; -import java.util.List; -import java.util.Random; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.WeightedRandom; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.WorldGenerator; -import darkknight.jewelrycraft.block.BlockList; -import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; -import darkknight.jewelrycraft.util.JewelrycraftUtil; - -/** - * @author Sorin - */ -public class WorldGenStructure1 extends WorldGenerator -{ - public static final WeightedRandomItem[] items = new WeightedRandomItem[] { - new WeightedRandomItem(new ItemStack(ItemList.thiefGloves), 7), - new WeightedRandomItem(new ItemStack(Items.golden_apple), 5), - new WeightedRandomItem(new ItemStack(Items.golden_apple, 1, 1), 1), - new WeightedRandomItem(new ItemStack(ItemList.guide), 10), - new WeightedRandomItem(new ItemStack(ItemList.shadowIngot), 15), - new WeightedRandomItem(new ItemStack(BlockList.shadowEye), 2), - new WeightedRandomItem(new ItemStack(Items.nether_star), 1), - new WeightedRandomItem(new ItemStack(BlockList.shadowBlock), 2), - new WeightedRandomItem(new ItemStack(BlockList.crystal), 16, 10) - }; - - @Override - public boolean generate(World world, Random rand, int x, int y, int z) - { - for(int i = -2; i <= 2; i++) - for(int j = -1; j <= 4; j++) - for(int k = -2; k <= 2; k++) - world.setBlock(x + i, y + j, z + k, Blocks.air); - - for(int i = -2; i <= 2; i++) - for(int k = -2; k <= 2; k++){ - world.setBlock(x + i, y - 1, z + k, Blocks.stonebrick); - if (i % 2 == 0 && k % 2 == 0 && i != 0 && k != 0) world.setBlock(x + i, y, z + k, BlockList.crystal); - } - for(int i = -1; i <= 1; i++) - for(int k = -1; k <= 1; k++) - world.setBlock(x + i, y, z + k, Blocks.stone_slab, 5, 2); - - world.setBlock(x, y, z, Blocks.stonebrick); - world.setBlock(x, y+1, z, BlockList.handPedestal, 6, 2); - TileEntityHandPedestal pedestal = (TileEntityHandPedestal)world.getTileEntity(x, y+1, z); - pedestal.setHeldItemStack(((WeightedRandomItem)WeightedRandom.getRandomItem(rand, items)).getItem(rand)); - - return true; - } -} +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandom; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.random.WeightedRandomItem; +import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; + +/** + * @author Sorin + */ +public class WorldGenStructure1 extends WorldGenerator +{ + public static final WeightedRandomItem[] items = new WeightedRandomItem[]{new WeightedRandomItem(new ItemStack(ItemList.thiefGloves), 10), new WeightedRandomItem(new ItemStack(Items.golden_apple), 8), new WeightedRandomItem(new ItemStack(Items.golden_apple, 1, 1), 1), new WeightedRandomItem(new ItemStack(ItemList.guide), 20), new WeightedRandomItem(new ItemStack(ItemList.shadowIngot), 25), new WeightedRandomItem(new ItemStack(BlockList.shadowEye), 2), new WeightedRandomItem(new ItemStack(Items.nether_star), 1), new WeightedRandomItem(new ItemStack(BlockList.shadowBlock), 2), new WeightedRandomItem(new ItemStack(BlockList.crystal), 16, 20)}; + + public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) + { + Block block = Blocks.stonebrick; + int metadata = 0, slabMeta = 5; + if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills){ + block = Blocks.sandstone; + metadata = 2; + slabMeta = 1; + } + for(int i = -2; i <= 2; i++) + for(int j = -1; j <= 4; j++) + for(int k = -2; k <= 2; k++) + world.setBlock(x + i, y + j, z + k, Blocks.air); + for(int i = -2; i <= 2; i++) + for(int k = -2; k <= 2; k++){ + world.setBlock(x + i, y - 1, z + k, block, metadata, 2); + if (i % 2 == 0 && k % 2 == 0 && i != 0 && k != 0) world.setBlock(x + i, y, z + k, BlockList.crystal); + } + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y, z + k, Blocks.stone_slab, slabMeta, 2); + world.setBlock(x, y, z, block, metadata, 2); + world.setBlock(x, y + 1, z, BlockList.handPedestal, 6, 2); + TileEntityHandPedestal pedestal = (TileEntityHandPedestal)world.getTileEntity(x, y + 1, z); + pedestal.setHeldItemStack(((WeightedRandomItem)WeightedRandom.getRandomItem(rand, items)).getItem(rand)); + return true; + } + + @Override + public boolean generate(World world, Random rand, int x, int y, int z) + { + return generate(world, BiomeGenBase.plains, rand, x, y, z); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure10.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure10.java new file mode 100644 index 0000000..b838368 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure10.java @@ -0,0 +1,29 @@ +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.DungeonHooks; + +/** + * @author Sorin + */ +public class WorldGenStructure10 extends WorldGenerator +{ + public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) + { + return true; + } + + @Override + public boolean generate(World world, Random rand, int x, int y, int z) + { + return generate(world, BiomeGenBase.plains, rand, x, y, z); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure11.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure11.java new file mode 100644 index 0000000..cfe84fb --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure11.java @@ -0,0 +1,29 @@ +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.DungeonHooks; + +/** + * @author Sorin + */ +public class WorldGenStructure11 extends WorldGenerator +{ + public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) + { + return true; + } + + @Override + public boolean generate(World world, Random rand, int x, int y, int z) + { + return generate(world, BiomeGenBase.plains, rand, x, y, z); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java new file mode 100644 index 0000000..f8b3094 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java @@ -0,0 +1,70 @@ +package darkknight.jewelrycraft.worldGen; + +import java.io.IOException; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.item.ItemMoltenMetalBucket; +import darkknight.jewelrycraft.network.PacketSendLiquidData; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +/** + * @author Sorin + */ +public class WorldGenStructure2 extends WorldGenerator +{ + public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) + { + Block block = Blocks.stonebrick; + Block stair = Blocks.stone_brick_stairs; + int metadata = 0, slabMeta = 5; + if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills){ + block = Blocks.sandstone; + stair = Blocks.sandstone_stairs; + metadata = 2; + } + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y, z + k, Blocks.air); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y - 1, z + k, block, metadata, 2); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y, z + k, stair); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlockMetadataWithNotify(x + i, y, z + k, (k == -1) ? 3 : (k == 0) ? (i == 1) ? 0 : 1 : 2, 2); + world.setBlock(x, y, z, Blocks.air); + ItemStack stack = new ItemStack(ItemList.bucket); + JewelryNBT.addMetal(stack, JewelrycraftUtil.metal.get(rand.nextInt(JewelrycraftUtil.metal.size()))); + try{ + if (stack != null && JewelryNBT.ingot(stack) != null){ + if (!world.isRemote) world.func_147480_a(x, y, z, true); + int color = ItemMoltenMetalBucket.color(stack, 1); + JewelrycraftMod.saveData.setString(x + " " + y + " " + z + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage() + ":" + color); + JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage(), color)); + world.setBlock(x, y, z, BlockList.moltenMetal, 0, 3); + } + } + catch(IOException e){ + e.printStackTrace(); + } + return true; + } + + @Override + public boolean generate(World world, Random rand, int x, int y, int z) + { + return generate(world, BiomeGenBase.plains, rand, x, y, z); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java new file mode 100644 index 0000000..7234aa9 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java @@ -0,0 +1,68 @@ +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.DungeonHooks; + +/** + * @author Sorin + */ +public class WorldGenStructure3 extends WorldGenerator +{ + public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) + { + Block slab = Blocks.stone_slab; + Block stair = Blocks.stone_brick_stairs; + int slabMeta = 13; + if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills){ + stair = Blocks.sandstone_stairs; + slabMeta = 9; + } + for(int i = -1; i <= 1; i++) + for(int j = -1; j <= 2; j++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y + j, z + k, Blocks.air); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y - 1, z + k, slab, slabMeta, 1); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y, z + k, stair); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlockMetadataWithNotify(x + i, y, z + k, (k == -1) ? 3 : (k == 0) ? (i == 1) ? 0 : 1 : 2, 2); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y + 1, z + k, stair); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlockMetadataWithNotify(x + i, y + 1, z + k, (k == -1) ? 7 : (k == 0) ? (i == 1) ? 4 : 5 : 6, 2); + slabMeta = 5; + if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills) slabMeta = 1; + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y + 2, z + k, slab, slabMeta, 1); + world.setBlock(x, y, z, Blocks.mob_spawner); + world.setBlock(x, y + 1, z, Blocks.mob_spawner); + for(int l = 0; l < 2; l++){ + TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getTileEntity(x, y + l, z); + if (tileentitymobspawner != null) tileentitymobspawner.func_145881_a().setEntityName(DungeonHooks.getRandomDungeonMob(rand)); + else System.err.println("Failed to fetch mob spawner entity at (" + x + ", " + (y + l) + ", " + z + ")"); + } + return true; + } + + @Override + public boolean generate(World world, Random rand, int x, int y, int z) + { + return generate(world, BiomeGenBase.plains, rand, x, y, z); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java new file mode 100644 index 0000000..4171438 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java @@ -0,0 +1,63 @@ +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import darkknight.jewelrycraft.block.BlockList; + +/** + * @author Sorin + */ +public class WorldGenStructure4 extends WorldGenerator +{ + public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) + { + Block slab = Blocks.stone_slab; + Block stair = Blocks.stone_brick_stairs; + Block block = Blocks.stonebrick; + int metadata = 0, slabMeta = 5; + if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills){ + stair = Blocks.sandstone_stairs; + block = Blocks.sandstone; + metadata = 2; + slabMeta = 1; + } + for(int i = -1; i <= 1; i++) + for(int j = 0; j <= 3; j++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y + j, z + k, Blocks.air); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y, z + k, Blocks.stone_slab, slabMeta, 1); + world.setBlock(x, y, z, block, metadata, 2); + world.setBlock(x, y, z - 1, stair, 3, 1); + world.setBlock(x, y, z + 1, stair, 2, 1); + world.setBlock(x - 1, y, z, stair, 1, 1); + world.setBlock(x + 1, y, z, stair, 0, 1); + world.setBlock(x, y + 1, z - 1, stair, 7, 1); + world.setBlock(x, y + 1, z + 1, stair, 6, 1); + world.setBlock(x - 1, y + 1, z, stair, 5, 1); + world.setBlock(x + 1, y + 1, z, stair, 4, 1); + world.setBlock(x, y + 1, z, BlockList.shadowBlock); + slabMeta = 5; + if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills) slabMeta = 1; + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + if (i == 0 || k == 0) world.setBlock(x + i, y + 2, z + k, Blocks.stone_slab, slabMeta, 1); + world.setBlock(x, y + 2, z, block, metadata, 2); + world.setBlock(x, y + 3, z, BlockList.crystal); + return true; + } + + @Override + public boolean generate(World world, Random rand, int x, int y, int z) + { + return generate(world, BiomeGenBase.plains, rand, x, y, z); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java new file mode 100644 index 0000000..0533a1b --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java @@ -0,0 +1,99 @@ +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.io.IOException; +import java.util.Random; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.item.ItemMoltenMetalBucket; +import darkknight.jewelrycraft.network.PacketSendLiquidData; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.DungeonHooks; + +/** + * @author Sorin + */ +public class WorldGenStructure5 extends WorldGenerator +{ + public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) + { + Block slab = Blocks.stone_slab; + Block stair = Blocks.stone_brick_stairs; + Block block = Blocks.stonebrick; + int metadata = 0, slabMeta = 5; + if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills){ + stair = Blocks.sandstone_stairs; + block = Blocks.sandstone; + metadata = 2; + slabMeta = 1; + } + for(int i = -2; i <= 2; i++) + for(int j = 0; j <= 3; j++) + for(int k = -3; k <= -1; k++) + world.setBlock(x + i, y + j, z + k, Blocks.air); + for(int i = -5; i <= -3; i++) + for(int k = -3; k <= 2; k++) + world.setBlock(x + i, y, z + k, Blocks.air); + for(int i = -2; i <= 2; i++) + for(int k = -3; k <= -1; k++) + world.setBlock(x + i, y, z + k, block, metadata, 1); + for(int i = 1; i <= 2; i++) + for(int k = -3; k <= -1; k++) + world.setBlock(x + i, y + 1, z + k, block, metadata, 1); + for(int i = -5; i <= -3; i++) + for(int k = -3; k <= 2; k++) + world.setBlock(x + i, y - 1, z + k, block, metadata, 1); + for(int i = -5; i <= -3; i++) + for(int k = -3; k <= 2; k++) + if ((i != -4 || k <= -3 || k >= 2) && !(i == -3 && k == -2)) world.setBlock(x + i, y, z + k, slab, slabMeta, 2); + world.setBlock(x - 3, y, z - 1, stair, 0, 2); + world.setBlock(x - 3, y, z - 3, stair, 0, 2); + world.setBlock(x - 2, y + 1, z - 3, slab, slabMeta, 2); + world.setBlock(x - 2, y + 1, z - 1, slab, slabMeta, 2); + world.setBlock(x - 1, y + 1, z - 3, slab, slabMeta, 2); + world.setBlock(x - 1, y + 1, z - 1, slab, slabMeta, 2); + world.setBlock(x, y + 1, z - 1, stair, 0, 2); + world.setBlock(x, y + 1, z - 3, stair, 0, 2); + world.setBlock(x + 1, y + 2, z - 3, slab, slabMeta, 2); + world.setBlock(x + 1, y + 2, z - 1, slab, slabMeta, 2); + for(int k = -3; k <= -1; k++) + world.setBlock(x + 2, y + 2, z + k, block, metadata, 1); + if (rand.nextInt(5) == 0){ + ItemStack stack = new ItemStack(ItemList.bucket); + JewelryNBT.addMetal(stack, new ItemStack(Items.gold_ingot)); + try{ + if (stack != null && JewelryNBT.ingot(stack) != null){ + if (!world.isRemote) world.func_147480_a(x, y, z, true); + int color = ItemMoltenMetalBucket.color(stack, 1); + JewelrycraftMod.saveData.setString((x + 1) + " " + (y + 2) + " " + (z - 2) + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage() + ":" + color); + JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x + 1, y + 2, z - 2, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage(), color)); + world.setBlock(x + 1, y + 2, z - 2, BlockList.moltenMetal, 0, 3); + } + } + catch(IOException e){ + e.printStackTrace(); + } + }else if (rand.nextBoolean()) world.setBlock(x + 1, y + 2, z - 2, Blocks.lava, 0, 3); + else world.setBlock(x + 1, y + 2, z - 2, Blocks.water, 0, 3); + return true; + } + + @Override + public boolean generate(World world, Random rand, int x, int y, int z) + { + return generate(world, BiomeGenBase.plains, rand, x, y, z); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java new file mode 100644 index 0000000..1755396 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java @@ -0,0 +1,29 @@ +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.DungeonHooks; + +/** + * @author Sorin + */ +public class WorldGenStructure6 extends WorldGenerator +{ + public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) + { + return true; + } + + @Override + public boolean generate(World world, Random rand, int x, int y, int z) + { + return generate(world, BiomeGenBase.plains, rand, x, y, z); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure7.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure7.java new file mode 100644 index 0000000..964e8e6 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure7.java @@ -0,0 +1,29 @@ +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.DungeonHooks; + +/** + * @author Sorin + */ +public class WorldGenStructure7 extends WorldGenerator +{ + public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) + { + return true; + } + + @Override + public boolean generate(World world, Random rand, int x, int y, int z) + { + return generate(world, BiomeGenBase.plains, rand, x, y, z); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure8.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure8.java new file mode 100644 index 0000000..868b623 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure8.java @@ -0,0 +1,29 @@ +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.DungeonHooks; + +/** + * @author Sorin + */ +public class WorldGenStructure8 extends WorldGenerator +{ + public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) + { + return true; + } + + @Override + public boolean generate(World world, Random rand, int x, int y, int z) + { + return generate(world, BiomeGenBase.plains, rand, x, y, z); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure9.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure9.java new file mode 100644 index 0000000..e349ac6 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure9.java @@ -0,0 +1,29 @@ +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.DungeonHooks; + +/** + * @author Sorin + */ +public class WorldGenStructure9 extends WorldGenerator +{ + public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) + { + return true; + } + + @Override + public boolean generate(World world, Random rand, int x, int y, int z) + { + return generate(world, BiomeGenBase.plains, rand, x, y, z); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java index 015e939..a1b508b 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java @@ -1,127 +1,125 @@ -package darkknight.jewelrycraft.worldGen.village; - -import java.util.Random; -import net.minecraft.entity.passive.EntityVillager; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.village.MerchantRecipe; -import net.minecraft.village.MerchantRecipeList; -import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; -import darkknight.jewelrycraft.block.BlockList; -import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.item.ItemMolds; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.JewelrycraftUtil; - -public class JCTrades implements IVillageTradeHandler -{ - - /** - * - */ - public JCTrades() - { - super(); - } - - /** - * @param villager - * @param recipeList - * @param random - */ - @Override - public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) - { - if (villager.getProfession() == 3000){ - ItemStack ingredient = null; - ItemStack ingredient2 = null; - ItemStack result; - int type = random.nextInt(12); - switch(type) - { - case 0:if(JewelrycraftUtil.metal.size() > 0){ - result = JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())); - result.stackSize = 5 + random.nextInt(5); - ingredient = new ItemStack(Items.emerald, 2 + random.nextInt(7)); - if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 2 + random.nextInt(2)); - break; - } - case 1:{ - result = new ItemStack(ItemList.molds, 5 + random.nextInt(7), random.nextInt(ItemMolds.moldsItemNames.length)); - ingredient = new ItemStack(Items.emerald, 1); - if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1 + random.nextInt(2)); - break; - } - case 2:{ - int number = random.nextInt(3); - result = new ItemStack(BlockList.displayer, 1 + number); - ingredient = new ItemStack(Blocks.emerald_block, 2 + number * 3 + random.nextInt(2)); - ingredient2 = new ItemStack(Items.emerald, 3 + number + random.nextInt(8)); - break; - } - case 3:{ - result = new ItemStack(BlockList.jewelCraftingTable); - ingredient = new ItemStack(Items.emerald, 1 + random.nextInt(2)); - if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1 + random.nextInt(2)); - break; - } - case 4:{ - result = new ItemStack(BlockList.shadowOre, 1 + random.nextInt(6)); - ingredient = new ItemStack(Items.emerald, 3 + random.nextInt(4)); - if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 3 + random.nextInt(4)); - break; - } - case 5:{ - result = new ItemStack(BlockList.molder, 5 + random.nextInt(5)); - ingredient = new ItemStack(Items.emerald, 1); - if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1); - break; - } - case 6:{ - result = new ItemStack(BlockList.smelter); - ingredient = new ItemStack(Items.emerald, 1 + random.nextInt(2)); - if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1 + random.nextInt(2)); - break; - } - case 7:if(JewelrycraftUtil.gem.size() > 0){ - int end = random.nextInt(JewelrycraftUtil.gem.size()); - result = JewelrycraftUtil.gem.get(end); - result.stackSize = 1 + random.nextInt(JewelrycraftUtil.gem.size() - end); - if (JewelrycraftUtil.gem.size() - 1 - end >= 1){ - int value = end; - if (value > 64) value = 64; - ingredient = new ItemStack(Items.emerald, 2 + random.nextInt(value)); - if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 2 + random.nextInt(value)); - }else{ - ingredient = new ItemStack(Blocks.emerald_block, 16 + random.nextInt(32)); - ingredient2 = new ItemStack(Blocks.emerald_block, 8 + random.nextInt(48)); - } - break; - } - case 8:if(JewelrycraftUtil.ores.size() > 0){ - result = JewelrycraftUtil.ores.get(random.nextInt(JewelrycraftUtil.ores.size())); - result.stackSize = 3 + random.nextInt(3); - ingredient = new ItemStack(Items.emerald, 2 + random.nextInt(5)); - if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 2 + random.nextInt(6)); - break; - } - case 9:{ - result = new ItemStack(ItemList.guide, 1); - ingredient = new ItemStack(Items.emerald, 1); - break; - } - default:{ - result = new ItemStack(ItemList.ring, 1, 0); - int randValue = random.nextInt(4); - if(JewelrycraftUtil.metal.size() > 0) JewelryNBT.addMetal(result, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()))); - if(JewelrycraftUtil.objects.size() > 0) JewelryNBT.addModifiers(result, JewelrycraftUtil.addRandomModifiers(randValue)); - if(JewelrycraftUtil.gem.size() > 0) JewelryNBT.addGem(result, JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size()))); - ingredient = new ItemStack(Items.emerald, 16 + random.nextInt(20)); - ingredient2 = new ItemStack(Blocks.emerald_block, 2 + randValue); - } - } - recipeList.addToListWithCheck(new MerchantRecipe(ingredient, ingredient2, result)); - } - } +package darkknight.jewelrycraft.worldGen.village; + +import java.util.Random; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.village.MerchantRecipe; +import net.minecraft.village.MerchantRecipeList; +import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.item.ItemMolds; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +public class JCTrades implements IVillageTradeHandler +{ + Item[] jewelry = new Item[]{ItemList.ring, ItemList.necklace, ItemList.bracelet, ItemList.earrings}; + public JCTrades() + { + super(); + } + + /** + * @param villager + * @param recipeList + * @param random + */ + @Override + public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) + { + if (villager.getProfession() == 3000){ + ItemStack ingredient = null; + ItemStack ingredient2 = null; + ItemStack result; + int type = random.nextInt(12); + switch(type) + { + case 0:if(JewelrycraftUtil.metal.size() > 0){ + result = JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())); + result.stackSize = 5 + random.nextInt(5); + ingredient = new ItemStack(Items.emerald, 2 + random.nextInt(7)); + if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 2 + random.nextInt(2)); + break; + } + case 1:{ + result = new ItemStack(ItemList.molds, 5 + random.nextInt(7), random.nextInt(ItemMolds.moldsItemNames.length)); + ingredient = new ItemStack(Items.emerald, 1); + if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1 + random.nextInt(2)); + break; + } + case 2:{ + int number = random.nextInt(3); + result = new ItemStack(BlockList.displayer, 1 + number); + ingredient = new ItemStack(Blocks.emerald_block, 2 + number * 3 + random.nextInt(2)); + ingredient2 = new ItemStack(Items.emerald, 3 + number + random.nextInt(8)); + break; + } + case 3:{ + result = new ItemStack(BlockList.jewelCraftingTable); + ingredient = new ItemStack(Items.emerald, 1 + random.nextInt(2)); + if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1 + random.nextInt(2)); + break; + } + case 4:{ + result = new ItemStack(BlockList.shadowOre, 1 + random.nextInt(6)); + ingredient = new ItemStack(Items.emerald, 3 + random.nextInt(4)); + if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 3 + random.nextInt(4)); + break; + } + case 5:{ + result = new ItemStack(BlockList.molder, 5 + random.nextInt(5)); + ingredient = new ItemStack(Items.emerald, 1); + if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1); + break; + } + case 6:{ + result = new ItemStack(BlockList.smelter); + ingredient = new ItemStack(Items.emerald, 1 + random.nextInt(2)); + if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1 + random.nextInt(2)); + break; + } + case 7:if(JewelrycraftUtil.gem.size() > 0){ + int end = random.nextInt(JewelrycraftUtil.gem.size()); + result = JewelrycraftUtil.gem.get(end); + result.stackSize = 1 + random.nextInt(JewelrycraftUtil.gem.size() - end); + if (JewelrycraftUtil.gem.size() - 1 - end >= 1){ + int value = end; + if (value > 64) value = 64; + ingredient = new ItemStack(Items.emerald, 2 + random.nextInt(value)); + if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 2 + random.nextInt(value)); + }else{ + ingredient = new ItemStack(Blocks.emerald_block, 16 + random.nextInt(32)); + ingredient2 = new ItemStack(Blocks.emerald_block, 8 + random.nextInt(48)); + } + break; + } + case 8:if(JewelrycraftUtil.ores.size() > 0){ + result = JewelrycraftUtil.ores.get(random.nextInt(JewelrycraftUtil.ores.size())); + result.stackSize = 3 + random.nextInt(3); + ingredient = new ItemStack(Items.emerald, 2 + random.nextInt(5)); + if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 2 + random.nextInt(6)); + break; + } + case 9:{ + result = new ItemStack(ItemList.guide, 1); + ingredient = new ItemStack(Items.emerald, 1); + break; + } + default:{ + result = new ItemStack(jewelry[random.nextInt(4)], 1, 0); + int randValue = random.nextInt(4); + if(JewelrycraftUtil.metal.size() > 0) JewelryNBT.addMetal(result, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()))); + if(JewelrycraftUtil.objects.size() > 0) JewelryNBT.addModifiers(result, JewelrycraftUtil.addRandomModifiers(randValue)); + if(JewelrycraftUtil.gem.size() > 0) JewelryNBT.addGem(result, JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size()))); + ingredient = new ItemStack(Items.emerald, 16 + random.nextInt(20)); + ingredient2 = new ItemStack(Blocks.emerald_block, 2 + randValue); + } + } + recipeList.addToListWithCheck(new MerchantRecipe(ingredient, ingredient2, result)); + } + } } \ No newline at end of file diff --git a/src/main/resources/assets/jewelrycraft2/lang/en_US.lang b/src/main/resources/assets/jewelrycraft2/lang/en_US.lang index e1d9fe4..efedd54 100644 --- a/src/main/resources/assets/jewelrycraft2/lang/en_US.lang +++ b/src/main/resources/assets/jewelrycraft2/lang/en_US.lang @@ -1,152 +1,152 @@ -item.jewelrycraft2.thiefGloves.name=Thieving Gloves -item.jewelrycraft2.ingotShadow.name=Shadow Ingot -item.jewelrycraft2.mold.ingot.name=Ingot Mold -item.jewelrycraft2.mold.ring.name=Ring Mold -item.jewelrycraft2.mold.necklace.name=Necklace Mold -item.jewelrycraft2.mold.bracelet.name=Bracelet Mold -item.jewelrycraft2.mold.earrings.name=Earrings Mold -item.jewelrycraft2.mold.clayIngot.name=Clay Ingot Mold -item.jewelrycraft2.mold.clayRing.name=Clay Ring Mold -item.jewelrycraft2.mold.clayNecklace.name=Clay Necklace Mold -item.jewelrycraft2.mold.clayBracelet.name=Clay Bracelet Mold -item.jewelrycraft2.mold.clayEarrings.name=Clay Earrings Mold -item.jewelrycraft2.ring.name=Ring -item.jewelrycraft2.necklace.name=Necklace -item.jewelrycraft2.bracelet.name=Bracelet -item.jewelrycraft2.earrings.name=Earrings -item.jewelrycraft2.guide.name=Jewelrycraft 2 Guide -item.jewelrycraft2.bucket.name=Bucket of Molten - -item.jewelrycraft2.jewelryModifier.name=Jewelry Modifier (Creative Only) -item.jewelrycraft2.goldObject.name=Golden Object -item.jewelrycraft2.structureGen.name=Structure Generator (Creative Only) - -item.jewelrycraft2.goldObject.info.standard=Shiny, but useless :( -item.jewelrycraft2.goldObject.info.food=It's made of solid gold! How are you suppose to eat this? -item.jewelrycraft2.thievingGloves.info.extra=Press for more information. -item.jewelrycraft2.thievingGloves.info.1=Right click with the gloves, -item.jewelrycraft2.thievingGloves.info.2=while sneaking, on a villager -item.jewelrycraft2.thievingGloves.info.3=to steal his stuff. - -tile.jewelrycraft2.oreShadow.name=Shadow Ore -tile.jewelrycraft2.blockShadow.name=Shadow Block -tile.jewelrycraft2.glow.name=Glow -tile.jewelrycraft2.smelter.name=Smelter -tile.jewelrycraft2.molder.name=Molder -tile.jewelrycraft2.displayer.name=Storage Displayer -tile.jewelrycraft2.jewelCraftingTable.name=Jeweler's Crafting Table -tile.jewelrycraft2.altar.name=Jewel Altar -tile.jewelrycraft2.moltenMetal.name=Molten -tile.jewelrycraft2.shadowHand.name=Shadow Hand -tile.jewelrycraft2.shadowEye.name=Cursed Eye -tile.jewelrycraft2.handPedestal.name=Hand Pedestal -tile.jewelrycraft2.midasTouchBlock.name=Golden Creature - -tile.jewelrycraft2.blockCrystal.0.name=Squidium Black Crystal -tile.jewelrycraft2.blockCrystal.1.name=Pokefennum Red Crystal -tile.jewelrycraft2.blockCrystal.2.name=Onyxium Green Crystal -tile.jewelrycraft2.blockCrystal.3.name=XCompium Brown Crystal -tile.jewelrycraft2.blockCrystal.4.name=Laurium Blue Crystal -tile.jewelrycraft2.blockCrystal.5.name=Jadium Purple Crystal -tile.jewelrycraft2.blockCrystal.6.name=Ecutruinium Cyan Crystal -tile.jewelrycraft2.blockCrystal.7.name=Fiskium Light Gray Crystal -tile.jewelrycraft2.blockCrystal.8.name=Pigmented Gray Crystal -tile.jewelrycraft2.blockCrystal.9.name=Aureylium Pink Crystal -tile.jewelrycraft2.blockCrystal.10.name=Soarynum Lime Crystal -tile.jewelrycraft2.blockCrystal.11.name=Blorphium Yellow Crystal -tile.jewelrycraft2.blockCrystal.12.name=Direium Light Blue Crystal -tile.jewelrycraft2.blockCrystal.13.name=Vazkiium Magenta Crystal -tile.jewelrycraft2.blockCrystal.14.name=Sipsium Orange Crystal -tile.jewelrycraft2.blockCrystal.15.name=Pahium White Crystal - -itemGroup.jewelrycraft2=Jewelrycraft 2 -itemGroup.Liquids=Liquids - -chatmessage.jewelrycraft2.molder.addedmold=Added %s to molder. -chatmessage.jewelrycraft2.molder.metaliscooling=Molten metal is cooling... -chatmessage.jewelrycraft2.molder.moldisempty=Mold is currently empty. -chatmessage.jewelrycraft2.molder.moldismissing=Molder does not contain a mold. -chatmessage.jewelrycraft2.molder.hasmoltenmetal=You can't remove the mold. It contains molten metal! - -chatmessage.jewelrycraft2.smelter.alreadyhasingot=The Smelter already contains %s -chatmessage.jewelrycraft2.smelter.hasmolteningot=The Smelter contains molten %s -chatmessage.jewelrycraft2.smelter.itemneedstobeingot=The item needs to be an ingot! -chatmessage.jewelrycraft2.smelter.itemrenamedtoingot=Nice try, but renaming it to an ingot doesn't make it an ingot :p You can't fool me player! -chatmessage.jewelrycraft2.smelter.molderhasmoltenmetal=The Molder already has molten metal in it! -chatmessage.jewelrycraft2.smelter.molderhasnomold=The Molder doesn't have a mold in it! You might as well pour this stuff on the ground, eh? -chatmessage.jewelrycraft2.smelter.modlerhasitem=The Molder contains an item in it. Now you wouldn't want it to be destroyed, would you? -chatmessage.jewelrycraft2.smelter.molderismissing=You need a Molder in front of this block in order to pour the molten metal! -chatmessage.jewelrycraft2.smelter.nowsmeltingingot=Smelter is now smelting a(n) %s. -chatmessage.jewelrycraft2.smelter.metalismelting=%s is being melted. -chatmessage.jewelrycraft2.smelter.empty=The Smelter is empty. -chatmessage.jewelrycraft2.smelter.contentdoesnotmatch=Item does not match contents! -chatmessage.jewelrycraft2.smelter.full=Smelter is at full capacity. -chatmessage.jewelrycraft2.smelter.cannotsmelt=You can not smelt this item. - -chatmessage.jewelrycraft2.table.hasenditem=First take out the crafted jewel before inserting new stuff. -chatmessage.jewelrycraft2.table.missinggem=You need a gem. -chatmessage.jewelrycraft2.table.missingjewelry=You're missing a piece of jewelry. -chatmessage.jewelrycraft2.table.iscrafting=The %s is being modified. -chatmessage.jewelrycraft2.table.jewelrymodifiedfull=This piece of jewelry is already modified at maximum. You can't modify it anymore! -chatmessage.jewelrycraft2.table.jewelrycontainsmodifier=The piece of jewelry already contains a modifier. -chatmessage.jewelrycraft2.table.jewelrycontainsjewel=The piece of jewelry already contains a jewel. - -chatmessage.jewelrycraft2.steal1=caught you trying to steal from him. -chatmessage.jewelrycraft2.steal2=curses you for the attempt. -chatmessage.jewelrycraft2.whisper=You hear a faint whisper in your ear -chatmessage.jewelrycraft2.stealSuccess1=Those who steal but don't get caught get rewarded and do not. -chatmessage.jewelrycraft2.stealSuccess2=Embrace the path you have gone, for the darkness will not -chatmessage.jewelrycraft2.stealSuccess3=dwell on. -chatmessage.jewelrycraft2.villager.confusion=Hmmm... I seem to have lost my -chatmessage.jewelrycraft2.steal.fail=sensed a strange presence around him, making him cling on to his items. You didn't get anything. -chatmessage.jewelrycraft2.steal.caught1=As he was passing by, a random villager caught you trying to steal from -chatmessage.jewelrycraft2.steal.caught2=A villager nearby saw you trying to steal from - -chatmessage.jewelrycraft2.endereye.1=You sense some -chatmessage.jewelrycraft2.endereye.2=around you. -chatmessage.jewelrycraft2.feather=The necklace protected you from taking damage! - -curse.jewelrycraft2.blind.description=You see the light slowly fading in front of you -curse.jewelrycraft2.flamingsoul.description=Is it me or is it getting hot in here? -curse.jewelrycraft2.greed.description=You might need that later -curse.jewelrycraft2.humblebundle.description=Two at the price of one -curse.jewelrycraft2.infamy.description=What have you done?! -curse.jewelrycraft2.midastouch.description=Be careful what you wish for... -curse.jewelrycraft2.pentagram.description=The Dark Lord has mysterious ways of showing you his love -curse.jewelrycraft2.rabbitspaw.description=The Dark Lord is giving you a gift. Don't lose it. -curse.jewelrycraft2.rottenheart.description=Your heart slowly rots inside -curse.jewelrycraft2.vampirehunger.description=You feel the need for blood - -death.attack.weak=%1$s was weakened by a piece of jewelry and died -death.attack.shadows=%1$s was consumed by the shadows -death.attack.blackHeart=%1$s was killed by %2$s's curse - -entity.jewelrycraft2.Heart.name=Heart -entity.jewelrycraft2.Half-Heart.name=Half-Heart - -jewelrycraft2.potion.stun=Stun - -info.jewelrycraft2.metal=Metal -info.jewelrycraft2.ingot=Ingot -info.jewelrycraft2.gem=Gem -info.jewelrycraft2.modifiers=Modifiers -info.jewelrycraft2.golden=Golden -info.jewelrycraft2.villager=Villager - -jeweler.jewelrycraft2.jewelerchest=Jeweler's Chest -jeweler.jewelrycraft2.ingotchest=Ingot Chest -jeweler.jewelrycraft2.orechest=Ores Chest - -guide.jewelrycraft2.tab.introduction=Introduction -guide.jewelrycraft2.tab.introduction.1=Welcome to Jewelrycraft 2! This mod is about making jewelry that you can modify to your own will. To find out how to create a jewelry, please consult the book and look at the Smelter block. To add modifiers to it you need to perform a ritual. To see how to do that, look at the Cursed Eye -guide.jewelrycraft2.tab.introduction.2=block in this guide. Please be aware that even if you can add anything as a modifier and can have multiple modifiers on one jewelry, this mod is still in alpha and does not have that many modifiers implemented and currently don't have any different effects depending on -guide.jewelrycraft2.tab.introduction.3=the gem used. To see what modifiers are currently implemented, just look in the Modifiers tab located in this guide (it is the one with the blaze powder as an icon). This mod was made by OnyxDarkKnight and the help of domi1819, pau101, Damien Hazard, boni and MineMarteen. - -guide.jewelrycraft2.tab.blocks=Blocks -guide.jewelrycraft2.tab.misc=Gems, Ores and Ingots -guide.jewelrycraft2.tab.items=Items -guide.jewelrycraft2.tab.modifiers=Modifiers -guide.jewelrycraft2.tab.oretoingot=Ores to Ingots -guide.jewelrycraft2.tab.ritual=Ritual - +item.jewelrycraft2.thiefGloves.name=Thieving Gloves +item.jewelrycraft2.ingotShadow.name=Shadow Ingot +item.jewelrycraft2.mold.ingot.name=Ingot Mold +item.jewelrycraft2.mold.ring.name=Ring Mold +item.jewelrycraft2.mold.necklace.name=Necklace Mold +item.jewelrycraft2.mold.bracelet.name=Bracelet Mold +item.jewelrycraft2.mold.earrings.name=Earrings Mold +item.jewelrycraft2.mold.clayIngot.name=Clay Ingot Mold +item.jewelrycraft2.mold.clayRing.name=Clay Ring Mold +item.jewelrycraft2.mold.clayNecklace.name=Clay Necklace Mold +item.jewelrycraft2.mold.clayBracelet.name=Clay Bracelet Mold +item.jewelrycraft2.mold.clayEarrings.name=Clay Earrings Mold +item.jewelrycraft2.ring.name=Ring +item.jewelrycraft2.necklace.name=Necklace +item.jewelrycraft2.bracelet.name=Bracelet +item.jewelrycraft2.earrings.name=Earrings +item.jewelrycraft2.guide.name=Jewelrycraft 2 Guide +item.jewelrycraft2.bucket.name=Bucket of Molten + +item.jewelrycraft2.jewelryModifier.name=Jewelry Modifier (Creative Only) +item.jewelrycraft2.goldObject.name=Golden Object +item.jewelrycraft2.structureGen.name=Structure Generator (Creative Only) + +item.jewelrycraft2.goldObject.info.standard=Shiny, but useless :( +item.jewelrycraft2.goldObject.info.food=It's made of solid gold! How are you suppose to eat this? +item.jewelrycraft2.thievingGloves.info.extra=Press for more information. +item.jewelrycraft2.thievingGloves.info.1=Right click with the gloves, +item.jewelrycraft2.thievingGloves.info.2=while sneaking, on a villager +item.jewelrycraft2.thievingGloves.info.3=to steal his stuff. + +tile.jewelrycraft2.oreShadow.name=Shadow Ore +tile.jewelrycraft2.blockShadow.name=Shadow Block +tile.jewelrycraft2.glow.name=Glow +tile.jewelrycraft2.smelter.name=Smelter +tile.jewelrycraft2.molder.name=Molder +tile.jewelrycraft2.displayer.name=Storage Displayer +tile.jewelrycraft2.jewelCraftingTable.name=Jeweler's Crafting Table +tile.jewelrycraft2.altar.name=Jewel Altar +tile.jewelrycraft2.moltenMetal.name=Molten +tile.jewelrycraft2.shadowHand.name=Shadow Hand +tile.jewelrycraft2.shadowEye.name=Cursed Eye +tile.jewelrycraft2.handPedestal.name=Hand Pedestal +tile.jewelrycraft2.midasTouchBlock.name=Golden Creature + +tile.jewelrycraft2.blockCrystal.0.name=Squidium Black Crystal +tile.jewelrycraft2.blockCrystal.1.name=Pokefennum Red Crystal +tile.jewelrycraft2.blockCrystal.2.name=Onyxium Green Crystal +tile.jewelrycraft2.blockCrystal.3.name=XCompium Brown Crystal +tile.jewelrycraft2.blockCrystal.4.name=Laurium Blue Crystal +tile.jewelrycraft2.blockCrystal.5.name=Jadium Purple Crystal +tile.jewelrycraft2.blockCrystal.6.name=Ecutruinium Cyan Crystal +tile.jewelrycraft2.blockCrystal.7.name=Fiskium Light Gray Crystal +tile.jewelrycraft2.blockCrystal.8.name=Pigmented Gray Crystal +tile.jewelrycraft2.blockCrystal.9.name=Aureylium Pink Crystal +tile.jewelrycraft2.blockCrystal.10.name=Soarynum Lime Crystal +tile.jewelrycraft2.blockCrystal.11.name=Blorphium Yellow Crystal +tile.jewelrycraft2.blockCrystal.12.name=Direium Light Blue Crystal +tile.jewelrycraft2.blockCrystal.13.name=Vazkiium Magenta Crystal +tile.jewelrycraft2.blockCrystal.14.name=Sipsium Orange Crystal +tile.jewelrycraft2.blockCrystal.15.name=Pahium White Crystal + +itemGroup.jewelrycraft2=Jewelrycraft 2 +itemGroup.Liquids=Liquids + +chatmessage.jewelrycraft2.molder.addedmold=Added %s to molder. +chatmessage.jewelrycraft2.molder.metaliscooling=Molten metal is cooling... +chatmessage.jewelrycraft2.molder.moldisempty=Mold is currently empty. +chatmessage.jewelrycraft2.molder.moldismissing=Molder does not contain a mold. +chatmessage.jewelrycraft2.molder.hasmoltenmetal=You can't remove the mold. It contains molten metal! + +chatmessage.jewelrycraft2.smelter.alreadyhasingot=The Smelter already contains %s +chatmessage.jewelrycraft2.smelter.hasmolteningot=The Smelter contains molten %s +chatmessage.jewelrycraft2.smelter.itemneedstobeingot=The item needs to be an ingot! +chatmessage.jewelrycraft2.smelter.itemrenamedtoingot=Nice try, but renaming it to an ingot doesn't make it an ingot :p You can't fool me player! +chatmessage.jewelrycraft2.smelter.molderhasmoltenmetal=The Molder already has molten metal in it! +chatmessage.jewelrycraft2.smelter.molderhasnomold=The Molder doesn't have a mold in it! You might as well pour this stuff on the ground, eh? +chatmessage.jewelrycraft2.smelter.modlerhasitem=The Molder contains an item in it. Now you wouldn't want it to be destroyed, would you? +chatmessage.jewelrycraft2.smelter.molderismissing=You need a Molder in front of this block in order to pour the molten metal! +chatmessage.jewelrycraft2.smelter.nowsmeltingingot=Smelter is now smelting a(n) %s. +chatmessage.jewelrycraft2.smelter.metalismelting=%s is being melted. +chatmessage.jewelrycraft2.smelter.empty=The Smelter is empty. +chatmessage.jewelrycraft2.smelter.contentdoesnotmatch=Item does not match contents! +chatmessage.jewelrycraft2.smelter.full=Smelter is at full capacity. +chatmessage.jewelrycraft2.smelter.cannotsmelt=You can not smelt this item. + +chatmessage.jewelrycraft2.table.hasenditem=First take out the crafted jewel before inserting new stuff. +chatmessage.jewelrycraft2.table.missinggem=You need a gem. +chatmessage.jewelrycraft2.table.missingjewelry=You're missing a piece of jewelry. +chatmessage.jewelrycraft2.table.iscrafting=The %s is being modified. +chatmessage.jewelrycraft2.table.jewelrymodifiedfull=This piece of jewelry is already modified at maximum. You can't modify it anymore! +chatmessage.jewelrycraft2.table.jewelrycontainsmodifier=The piece of jewelry already contains a modifier. +chatmessage.jewelrycraft2.table.jewelrycontainsjewel=The piece of jewelry already contains a jewel. + +chatmessage.jewelrycraft2.steal1=caught you trying to steal from him. +chatmessage.jewelrycraft2.steal2=curses you for the attempt. +chatmessage.jewelrycraft2.whisper=You hear a faint whisper in your ear +chatmessage.jewelrycraft2.stealSuccess1=Those who steal but don't get caught get rewarded and do not. +chatmessage.jewelrycraft2.stealSuccess2=Embrace the path you have gone, for the darkness will not +chatmessage.jewelrycraft2.stealSuccess3=dwell on. +chatmessage.jewelrycraft2.villager.confusion=Hmmm... I seem to have lost my +chatmessage.jewelrycraft2.steal.fail=sensed a strange presence around him, making him cling on to his items. You didn't get anything. +chatmessage.jewelrycraft2.steal.caught1=As he was passing by, a random villager caught you trying to steal from +chatmessage.jewelrycraft2.steal.caught2=A villager nearby saw you trying to steal from + +chatmessage.jewelrycraft2.endereye.1=You sense some +chatmessage.jewelrycraft2.endereye.2=around you. +chatmessage.jewelrycraft2.feather=The necklace protected you from taking damage! + +curse.jewelrycraft2.blind.description=You see the light slowly fading in front of you +curse.jewelrycraft2.flamingsoul.description=Is it me or is it getting hot in here? +curse.jewelrycraft2.greed.description=You might need that later +curse.jewelrycraft2.humblebundle.description=Two at the price of one +curse.jewelrycraft2.infamy.description=What have you done?! +curse.jewelrycraft2.midastouch.description=Be careful what you wish for... +curse.jewelrycraft2.pentagram.description=The Dark Lord has mysterious ways of showing you his love +curse.jewelrycraft2.rabbitspaw.description=The Dark Lord is giving you a gift. Don't lose it. +curse.jewelrycraft2.rottenheart.description=Your heart slowly rots inside +curse.jewelrycraft2.vampirehunger.description=You feel the need for blood + +death.attack.weak=%1$s was weakened by a piece of jewelry and died +death.attack.shadows=%1$s was consumed by the shadows +death.attack.blackHeart=%1$s was killed by %2$s's curse + +entity.jewelrycraft2.Heart.name=Heart +entity.jewelrycraft2.HalfHeart.name=Half-Heart + +jewelrycraft2.potion.stun=Stun + +info.jewelrycraft2.metal=Metal +info.jewelrycraft2.ingot=Ingot +info.jewelrycraft2.gem=Gem +info.jewelrycraft2.modifiers=Modifiers +info.jewelrycraft2.golden=Golden +info.jewelrycraft2.villager=Villager + +jeweler.jewelrycraft2.jewelerchest=Jeweler's Chest +jeweler.jewelrycraft2.ingotchest=Ingot Chest +jeweler.jewelrycraft2.orechest=Ores Chest + +guide.jewelrycraft2.tab.introduction=Introduction +guide.jewelrycraft2.tab.introduction.1=Welcome to Jewelrycraft 2! This mod is about making jewelry that you can modify to your own will. To find out how to create a jewelry, please consult the book and look at the Smelter block. To add modifiers to it you need to perform a ritual. To see how to do that, look at the Cursed Eye +guide.jewelrycraft2.tab.introduction.2=block in this guide. Please be aware that even if you can add anything as a modifier and can have multiple modifiers on one jewelry, this mod is still in alpha and does not have that many modifiers implemented and currently don't have any different effects depending on +guide.jewelrycraft2.tab.introduction.3=the gem used. To see what modifiers are currently implemented, just look in the Modifiers tab located in this guide (it is the one with the blaze powder as an icon). This mod was made by OnyxDarkKnight and the help of domi1819, pau101, Damien Hazard, boni and MineMarteen. + +guide.jewelrycraft2.tab.blocks=Blocks +guide.jewelrycraft2.tab.misc=Gems, Ores and Ingots +guide.jewelrycraft2.tab.items=Items +guide.jewelrycraft2.tab.modifiers=Modifiers +guide.jewelrycraft2.tab.oretoingot=Ores to Ingots +guide.jewelrycraft2.tab.ritual=Ritual + bucket.unknown=Bucket of Unknown Content \ No newline at end of file -- cgit v1.2.3