diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..dfe07704 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/build.gradle b/build.gradle index ed1e5ab8..e581fdbc 100644 --- a/build.gradle +++ b/build.gradle @@ -8,26 +8,28 @@ buildscript { } } apply plugin: 'net.minecraftforge.gradle.forge' -//Only edit below this line, the above code adds and enables the nessasary things for Forge to be setup. +//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -version = " 2.1.0 - MC 1.10.2" -group= "electroblob.wizardry"// http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = "Electroblob's Wizardry " +version = "1.0" +group = "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html +archivesBaseName = "modid" -srcCompat = JavaVersion.VERSION_1_8 -targetCompat = JavaVersion.VERSION_1_8 +sourceCompatibility = targetCompatibility = "1.6" // Need this here so eclipse task generates correctly. +compileJava { + sourceCompatibility = targetCompatibility = "1.6" +} minecraft { - version = "1.10.2-12.18.3.2185" + version = "1.11.2-13.20.1.2386" runDir = "run" // the mappings can be changed at any time, and must be in the following format. // snapshot_YYYYMMDD snapshot are built nightly. // stable_# stables are built at the discretion of the MCP team. - // Use non-default mappings at your own risk. they may not allways work. + // Use non-default mappings at your own risk. they may not always work. // simply re-run your setup task after changing the mappings to update your workspace. - mappings = "snapshot_20161111" + mappings = "snapshot_20161220" // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. } @@ -55,8 +57,7 @@ dependencies { } -processResources -{ +processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version @@ -69,7 +70,7 @@ processResources expand 'version':project.version, 'mcversion':project.minecraft.version } - // copy everything else, thats not the mcmod.info + // copy everything else except the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' } diff --git a/src/main/java/electroblob/wizardry/CommonProxy.java b/src/main/java/electroblob/wizardry/CommonProxy.java index 1ae24b85..a5ae25a3 100644 --- a/src/main/java/electroblob/wizardry/CommonProxy.java +++ b/src/main/java/electroblob/wizardry/CommonProxy.java @@ -23,119 +23,137 @@ import net.minecraftforge.common.config.Property; /** * The common proxy for wizardry, serving the usual purpose of dealing with all things that need to be handled - * differently on the client and the server. A lot of the methods here appear to do absolutely nothing; this is - * because they do client-only things which are only handled in the client proxy. + * differently on the client and the server. A lot of the methods here appear to do absolutely nothing; this is because + * they do client-only things which are only handled in the client proxy. + * * @see {@link electroblob.wizardry.client.ClientProxy} * @author Electroblob * @since Wizardry 1.0 - * */ + */ @SuppressWarnings("deprecation") public class CommonProxy { - + // SECTION Registry // =============================================================================================================== - public void registerRenderers(){} + public void registerRenderers(){ + } - public void initialiseLayers(){} - - public void registerKeyBindings(){} - - public void registerSpellHUD(){} - - public net.minecraft.client.model.ModelBiped getWizardArmourModel(){ return null; } + public void initialiseLayers(){ + } + + public void registerKeyBindings(){ + } + + public void registerSpellHUD(){ + } + + public net.minecraft.client.model.ModelBiped getWizardArmourModel(){ + return null; + } + + public void initMixedFontRenderer(){ + } - public void initMixedFontRenderer(){} - // SECTION Particles // =============================================================================================================== - - /** - * Spawns a custom particle of the specified type. - * - * @param type EnumParticleType of the particle - * @param world Reference to the World object - * @param x Particle x position - * @param y Particle y position - * @param z Particle z position - * @param velX Particle x velocity - * @param velY Particle y velocity - * @param velZ Particle z velocity - * @param maxAge Lifetime of the particle in ticks - * @param r Red component of particle colour; will be clamped to between 0 and 1 - * @param g Red component of particle colour; will be clamped to between 0 and 1 - * @param b Red component of particle colour; will be clamped to between 0 and 1 - * @param doGravity Whether the particle is affected by gravity (only affects SPARKLE at the moment) - * @param radius The radius of the particle's motion, for cirular motion particles - */ - public void spawnParticle(WizardryParticleType type, World world, double x, double y, double z, double velX, double velY, double velZ, int maxAge, float r, float g, float b, boolean doGravity, double radius){ - // Does nothing since particles are client-side only - } - - /** Spawns a custom particle of the specified type. doGravity defaults to false and radius defaults to 0. - * Note that some of these settings may not affect the particle; some particles are always affected by - * gravity, for instance. - * - * @param type EnumParticleType of the particle - * @param world Reference to the World object - * @param x Particle x position - * @param y Particle y position - * @param z Particle z position - * @param velX Particle x velocity - * @param velY Particle y velocity - * @param velZ Particle z velocity - * @param maxAge Lifetime of the particle in ticks - * @param r Red component of particle colour; will be clamped to between 0 and 1 (unless this is a MAGIC_FIRE particle, in which case this is the scale) - * @param g Red component of particle colour; will be clamped to between 0 and 1 - * @param b Red component of particle colour; will be clamped to between 0 and 1 - */ - public void spawnParticle(WizardryParticleType type, World world, double x, double y, double z, double velX, double velY, double velZ, int maxAge, float r, float g, float b){ - this.spawnParticle(type, world, x, y, z, velX, velY, velZ, maxAge, r, g, b, false, 0); - } - - /** Spawns a custom particle of the specified type. Colour defaults to white, doGravity defaults to false and radius - * defaults to 0. Note that some of these settings may not affect the particle; some particles are always affected by - * gravity, for instance. - * - * @param type EnumParticleType of the particle - * @param world Reference to the World object - * @param x Particle x position - * @param y Particle y position - * @param z Particle z position - * @param velX Particle x velocity - * @param velY Particle y velocity - * @param velZ Particle z velocity - * @param maxAge Lifetime of the particle in ticks - */ - public void spawnParticle(WizardryParticleType type, World world, double x, double y, double z, double velX, double velY, double velZ, int maxAge){ - this.spawnParticle(type, world, x, y, z, velX, velY, velZ, maxAge, 1, 1, 1, false, 0); - } - - public void spawnTornadoParticle(World world, double x, double y, double z, double velX, double velZ, double radius, int maxAge, IBlockState block, BlockPos pos){} + + /** + * Spawns a custom particle of the specified type. + * + * @param type EnumParticleType of the particle + * @param world Reference to the World object + * @param x Particle x position + * @param y Particle y position + * @param z Particle z position + * @param velX Particle x velocity + * @param velY Particle y velocity + * @param velZ Particle z velocity + * @param maxAge Lifetime of the particle in ticks + * @param r Red component of particle colour; will be clamped to between 0 and 1 + * @param g Red component of particle colour; will be clamped to between 0 and 1 + * @param b Red component of particle colour; will be clamped to between 0 and 1 + * @param doGravity Whether the particle is affected by gravity (only affects SPARKLE at the moment) + * @param radius The radius of the particle's motion, for cirular motion particles + */ + public void spawnParticle(WizardryParticleType type, World world, double x, double y, double z, double velX, + double velY, double velZ, int maxAge, float r, float g, float b, boolean doGravity, double radius){ + // Does nothing since particles are client-side only + } + + /** + * Spawns a custom particle of the specified type. doGravity defaults to false and radius defaults to 0. Note that + * some of these settings may not affect the particle; some particles are always affected by gravity, for instance. + * + * @param type EnumParticleType of the particle + * @param world Reference to the World object + * @param x Particle x position + * @param y Particle y position + * @param z Particle z position + * @param velX Particle x velocity + * @param velY Particle y velocity + * @param velZ Particle z velocity + * @param maxAge Lifetime of the particle in ticks + * @param r Red component of particle colour; will be clamped to between 0 and 1 (unless this is a MAGIC_FIRE + * particle, in which case this is the scale) + * @param g Red component of particle colour; will be clamped to between 0 and 1 + * @param b Red component of particle colour; will be clamped to between 0 and 1 + */ + public void spawnParticle(WizardryParticleType type, World world, double x, double y, double z, double velX, + double velY, double velZ, int maxAge, float r, float g, float b){ + this.spawnParticle(type, world, x, y, z, velX, velY, velZ, maxAge, r, g, b, false, 0); + } + + /** + * Spawns a custom particle of the specified type. Colour defaults to white, doGravity defaults to false and radius + * defaults to 0. Note that some of these settings may not affect the particle; some particles are always affected + * by gravity, for instance. + * + * @param type EnumParticleType of the particle + * @param world Reference to the World object + * @param x Particle x position + * @param y Particle y position + * @param z Particle z position + * @param velX Particle x velocity + * @param velY Particle y velocity + * @param velZ Particle z velocity + * @param maxAge Lifetime of the particle in ticks + */ + public void spawnParticle(WizardryParticleType type, World world, double x, double y, double z, double velX, + double velY, double velZ, int maxAge){ + this.spawnParticle(type, world, x, y, z, velX, velY, velZ, maxAge, 1, 1, 1, false, 0); + } + + public void spawnTornadoParticle(World world, double x, double y, double z, double velX, double velZ, double radius, + int maxAge, IBlockState block, BlockPos pos){ + } // SECTION Items // =============================================================================================================== - - public net.minecraft.client.gui.FontRenderer getFontRenderer(ItemStack stack) { + + public net.minecraft.client.gui.FontRenderer getFontRenderer(ItemStack stack){ return null; } - - /** Returns the translated name of the scroll, taking spell discovery into account. If, for some reason, this gets + + /** + * Returns the translated name of the scroll, taking spell discovery into account. If, for some reason, this gets * called server-side, it uses the deprecated server version of I18n, with a warning. Since any likely server-side * use of this method will be for text-based logic purposes (like Bibliocraft's book checking system), and since no - * particular player instance can be accessed, spell discovery is ignored. */ + * particular player instance can be accessed, spell discovery is ignored. + */ public String getScrollDisplayName(ItemStack scroll){ - + // I have now learnt that the server side I18n always translates to the default en_US, so I could just return // a hardcoded name in English instead. Wizardry.logger.info("A mod has called ItemScroll#getItemStackDisplayName from the server side. Using the" + "deprecated server-side translation methods as a fallback."); - + // Displays [Empty slot] if spell is continuous. Spell spell = Spell.get(scroll.getItemDamage()); if(spell.isContinuous) spell = Spells.none; - - return I18n.translateToLocalFormatted("item.wizardry:wizardry:scroll.name", I18n.translateToLocal("spell." + spell.getUnlocalisedName())).trim(); + + return I18n.translateToLocalFormatted("item.wizardry:wizardry:scroll.name", + I18n.translateToLocal("spell." + spell.getUnlocalisedName())).trim(); } public double getConjuredBowDurability(ItemStack stack){ @@ -144,33 +162,53 @@ public class CommonProxy { // SECTION Packet Handlers // =============================================================================================================== - - public void handlePlayerSyncPacket(PacketPlayerSync.Message message){} - public void handleGlyphDataPacket(PacketGlyphData.Message message){} - public void handleCastSpellPacket(PacketCastSpell.Message message){} - public void handleCastContinuousSpellPacket(PacketCastContinuousSpell.Message message){} - public void handleNPCCastSpellPacket(Message message){} - public void handleTransportationPacket(PacketTransportation.Message message){} - public void handleClairvoyancePacket(PacketClairvoyance.Message message){} - + + public void handlePlayerSyncPacket(PacketPlayerSync.Message message){ + } + + public void handleGlyphDataPacket(PacketGlyphData.Message message){ + } + + public void handleCastSpellPacket(PacketCastSpell.Message message){ + } + + public void handleCastContinuousSpellPacket(PacketCastContinuousSpell.Message message){ + } + + public void handleNPCCastSpellPacket(Message message){ + } + + public void handleTransportationPacket(PacketTransportation.Message message){ + } + + public void handleClairvoyancePacket(PacketClairvoyance.Message message){ + } + // SECTION Misc // =============================================================================================================== - public void setToNumberSliderEntry(Property property){} - //public void setToEntityNameEntry(Property property){} - - /** Plays a sound which moves with the given entity. - * - * @param entity The source of the sound - * @param sound The SoundEvent to play - * @param volume Volume relative to 1 - * @param pitch Pitch relative to 1 - * @param repeat Whether to repeat the sound for as long as the entity is alive (or until stopped manually) - */ - public void playMovingSound(Entity entity, SoundEvent sound, float volume, float pitch, boolean repeat){} - - /** Gets the client side world using Minecraft.getMinecraft().theWorld. Only to be called client side! - * Returns null on the server side. */ - public World getTheWorld(){ return null; } + public void setToNumberSliderEntry(Property property){ + } + // public void setToEntityNameEntry(Property property){} + + /** + * Plays a sound which moves with the given entity. + * + * @param entity The source of the sound + * @param sound The SoundEvent to play + * @param volume Volume relative to 1 + * @param pitch Pitch relative to 1 + * @param repeat Whether to repeat the sound for as long as the entity is alive (or until stopped manually) + */ + public void playMovingSound(Entity entity, SoundEvent sound, float volume, float pitch, boolean repeat){ + } + + /** + * Gets the client side world using Minecraft.getMinecraft().world. Only to be called client side! Returns + * null on the server side. + */ + public World getTheWorld(){ + return null; + } } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/Settings.java b/src/main/java/electroblob/wizardry/Settings.java index 8d56dce6..dae93928 100644 --- a/src/main/java/electroblob/wizardry/Settings.java +++ b/src/main/java/electroblob/wizardry/Settings.java @@ -11,6 +11,7 @@ import electroblob.wizardry.util.MagicDamage; import electroblob.wizardry.util.MagicDamage.DamageType; import net.minecraft.entity.EntityList; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.translation.I18n; import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.common.config.Configuration; @@ -18,7 +19,8 @@ import net.minecraftforge.common.config.Property; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; -/** Singleton class which deals with everything related to wizardry's config file. To access individual settings, use +/** + * Singleton class which deals with everything related to wizardry's config file. To access individual settings, use * {@link Wizardry#settings}. Also stores a few string constants for easy access. *

* As part of the 1.2 update and code overhaul, the way the config settings work in multiplayer has been tightened up. @@ -28,22 +30,25 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; * has an effect if the local game is the host, i.e. a dedicated server, a LAN host or a singleplayer world. Examples * include worldgen, mob drops and commands. *

  • Synchronised settings. These settings affect both client-side AND server-side code, and are synchronised with - * each client on login via {@link Settings#sync(EntityPlayerMP)}. Changing these locally - * only has an effect if the local game is the host, i.e. a dedicated server, a LAN host or a singleplayer world. - * Examples include discovery mode and crafting recipes. Note that as far as users are concerned, - * there is no difference in behaviour between server-only and synchronised settings. - *
  • Client-only settings. These settings only affect client-side code and hence are not synced. Each client obeys - * its own values for these, and changing them on a dedicated server will have no effect. These are usually only display - * and controls settings.
  • + * each client on login via {@link Settings#sync(EntityPlayerMP)}. Changing these locally only has an effect if the + * local game is the host, i.e. a dedicated server, a LAN host or a singleplayer world. Examples include discovery mode + * and crafting recipes. Note that as far as users are concerned, there is no difference in behaviour between + * server-only and synchronised settings. + *
  • Client-only settings. These settings only affect client-side code and hence are not synced. Each client obeys its + * own values for these, and changing them on a dedicated server will have no effect. These are usually only display and + * controls settings.
  • *

    - * Each of the settings fields in this class is marked with one of the above categories to indicate which it belongs - * to. This in turn dictates which logical side it should be called from: client, server or both. Do not access a - * config setting from the wrong side, because it may cause unexpected or strange behaviour. + * Each of the settings fields in this class is marked with one of the above categories to indicate which it belongs to. + * This in turn dictates which logical side it should be called from: client, server or both. Do not access a config + * setting from the wrong side, because it may cause unexpected or strange behaviour. + * * @since Wizardry 1.2 - * @author Electroblob */ -// NOTE: We could convert over to the @Config system IF it is sufficiently complete in this Forge version for my purposes. + * @author Electroblob + */ +// NOTE: We could convert over to the @Config system IF it is sufficiently complete in this Forge version for my +// purposes. // (For one, I know that the LangKey annotation is not applicable to type declarations in 1.10.2, unlike in 1.11.2) -//@Config(modid = Wizardry.MODID) +// @Config(modid = Wizardry.MODID) @SuppressWarnings("deprecation") // Used server I18n deliberately; we want to write the comments in english. public final class Settings { @@ -66,7 +71,7 @@ public final class Settings { // Server-only settings. These only affect server-side code and hence are not synced. Changing these locally only // has an effect if the local game is the host, i.e. a dedicated server, a LAN host or a singleplayer world. - + // Worldgen /** [Server-only] The rarity of wizard towers, used by the world generator. Larger numbers are rarer. */ public int towerRarity = 8; @@ -76,33 +81,46 @@ public final class Settings { public int[] flowerDimensions = {0}; /** [Server-only] List of dimension ids in which to generate crystal ore. */ public int[] towerDimensions = {0}; - /** [Server-only] Whether or not wizardry loot should generate in dungeon chests. Note that this does not - * affect the generation of loot in wizard towers. */ + /** + * [Server-only] Whether or not wizardry loot should generate in dungeon chests. Note that this does not + * affect the generation of loot in wizard towers. + */ public boolean generateLoot = true; - + // Entities' drops, targeting, damage, etc. /** [Server-only] Chance (out of 200) for mobs to drop spell books. */ public int spellBookDropChance = 3; - /** [Server-only] Whether or not players can teleport through unbreakable blocks (e.g. bedrock) using the phase step spell. */ + /** + * [Server-only] Whether or not players can teleport through unbreakable blocks (e.g. bedrock) using the + * phase step spell. + */ public boolean teleportThroughUnbreakableBlocks = false; /** [Server-only] Whether to allow players to damage their designated allies using magic. */ public boolean friendlyFire = true; /** [Server-only] Whether to allow players to disarm other players using the telekinesis spell. */ public boolean telekineticDisarmament = true; - /** [Server-only] Whether summoned creatures can revenge attack their caster if their caster attacks them. */ + /** [Server-only] Whether summoned creatures can revenge attack their caster if their caster attacks them. */ public boolean minionRevengeTargeting = true; - /** [Server-only] List of names of entities which summoned creatures are allowed to attack, in addition to the defaults. */ + /** + * [Server-only] List of names of entities which summoned creatures are allowed to attack, in addition to the + * defaults. + */ public String[] summonedCreatureTargetsWhitelist = {}; - /** [Server-only] List of names of entities which summoned creatures are specifically not allowed to attack, overriding the defaults and the whitelist. */ + /** + * [Server-only] List of names of entities which summoned creatures are specifically not allowed to attack, + * overriding the defaults and the whitelist. + */ public String[] summonedCreatureTargetsBlacklist = {"creeper"}; /** [Server-only] Global damage scaling factor for all player magic damage. */ public double playerDamageScale = 1.0f; /** [Server-only] Global damage scaling factor for all npc magic damage. */ public double npcDamageScale = 1.0f; - + // Commands (these don't need synchronising since typing a command always queries the server). - /** [Server-only] The maximum allowed multiplier for the /cast command. This limit is here to stop people from accidentally - * breaking their worlds! */ + /** + * [Server-only] The maximum allowed multiplier for the /cast command. This limit is here to stop people from + * accidentally breaking their worlds! + */ public double maxSpellCommandMultiplier = 20d; /** [Server-only] The name of the /cast command. */ public String castCommandName = "cast"; @@ -112,10 +130,10 @@ public final class Settings { public String allyCommandName = "ally"; /** [Server-only] The name of the /allies command. */ public String alliesCommandName = "allies"; - + // Synchronised settings. These settings affect both client-side AND server-side code. Changing these locally // only has an effect if the local game is the host, i.e. a dedicated server, a LAN host or a singleplayer world. - + // Recipes (only need syncing for display in the wizard's handbook) /** [Synchronised] Whether or not firebombs should be craftable. */ public boolean firebombIsCraftable = true; @@ -123,20 +141,28 @@ public final class Settings { public boolean poisonBombIsCraftable = true; /** [Synchronised] Whether or not poison bombs should be craftable. */ public boolean smokeBombIsCraftable = true; - /** [Synchronised] Whether to require a magic crystal in the blank scroll crafting recipe (in case it conflicts with another mod). */ + /** + * [Synchronised] Whether to require a magic crystal in the blank scroll crafting recipe (in case it + * conflicts with another mod). + */ public boolean useAlternateScrollRecipe = false; - + // Gamemodes - /** [Synchronised] When set to true, spells a player hasn't cast yet will be unreadable until they are cast (on a per-world basis). Has no effect when in creative mode. Spells of - * identification will be unobtainable in survival mode if this is false. */ + /** + * [Synchronised] When set to true, spells a player hasn't cast yet will be unreadable until they are cast + * (on a per-world basis). Has no effect when in creative mode. Spells of identification will be unobtainable in + * survival mode if this is false. + */ public boolean discoveryMode = true; - + // Client-only settings. These settings only affect client-side code and hence are not synced. Each client obeys // its own values for these, and changing them on a dedicated server will have no effect. - + // Controls - /** [Client-only] Whether the player can switch between spells on a wand by scrolling with the mouse wheel while - * sneaking. */ + /** + * [Client-only] Whether the player can switch between spells on a wand by scrolling with the mouse wheel + * while sneaking. + */ public boolean enableShiftScrolling = true; // Display @@ -144,103 +170,108 @@ public final class Settings { public boolean showSummonedCreatureNames = true; /** [Client-only] The position of the spell HUD. */ public GuiPosition spellHUDPosition = GuiPosition.BOTTOM_LEFT; - + /** Set of constants for each of the four positions that the spell HUD can be in. */ public enum GuiPosition { - - BOTTOM_LEFT("Bottom left"), - TOP_LEFT("Top left"), - TOP_RIGHT("Top right"), - BOTTOM_RIGHT("Bottom right"); - + + BOTTOM_LEFT("Bottom left"), TOP_LEFT("Top left"), TOP_RIGHT("Top right"), BOTTOM_RIGHT("Bottom right"); + /** Constant array storing the names of each of the constants, in the order they are declared. */ public static final String[] names; - - static { + + static{ names = new String[values().length]; for(GuiPosition position : values()){ names[position.ordinal()] = position.name; } } - + /** The readable name for this GUI position that will be displayed on the button in the config GUI. */ public final String name; - + GuiPosition(String name){ this.name = name; } - - /** Gets a GUI position from its string name (ignoring case), or BOTTOM_LEFT if the given name is not a valid position. */ + + /** + * Gets a GUI position from its string name (ignoring case), or BOTTOM_LEFT if the given name is not a valid + * position. + */ public static GuiPosition fromName(String name){ - + for(GuiPosition position : values()){ if(position.name.equalsIgnoreCase(name)) return position; } - + Wizardry.logger.info("Invalid string for the spell HUD position. Using default (bottom left) instead."); return BOTTOM_LEFT; } - + } // As of Wizardry 1.1, all keys used in the config file itself are now hardcoded, not localised. The localisations // are done in the config GUI. The config file has to be written in one language or it will end up with multiple // options for different languages. - + // These methods are package-protected to stop anyone else from calling them. - - /** Called from preInit to initialise the config file. The first part of the config file has to be done here (as is + + /** + * Called from preInit to initialise the config file. The first part of the config file has to be done here (as is * conventional) so that the various registries can change what they do accordingly. The spell part of the config - * has to be done in the init method.*/ + * has to be done in the init method. + */ void initConfig(FMLPreInitializationEvent event){ - + config = new Configuration(event.getSuggestedConfigurationFile()); config.load(); - + Wizardry.logger.info("Setting up main config"); - + setupGeneralConfig(); - + config.save(); } - - /** Called from init to initialise the parts of the config file that depend on other mods. For example, the spell - * config is done here and not in preInit because all spells must be registered before it is added, including - * those in other mods. */ + + /** + * Called from init to initialise the parts of the config file that depend on other mods. For example, the spell + * config is done here and not in preInit because all spells must be registered before it is added, including those + * in other mods. + */ void initConfigExtras(){ - + Wizardry.logger.info("Setting up spells config for " + Spell.getTotalSpellCount() + " spells"); - + setupSpellsConfig(); config.save(); } - + /** Called to save changes to the config file after it has been edited in game from the menus. */ void saveConfigChanges(){ Wizardry.logger.info("Saving in-game config changes"); - + setupGeneralConfig(); setupSpellsConfig(); config.save(); } - + /** Sends a packet to the specified player's client containing all the synchronised settings. */ public void sync(EntityPlayerMP player){ Wizardry.logger.info("Synchronising config settings for " + player.getName()); IMessage message = new PacketSyncSettings.Message(this); WizardryPacketHandler.net.sendTo(message, player); } - + public ConfigCategory getConfigCategory(String name){ return config.getCategory(name); } private void setupSpellsConfig(){ - config.addCustomCategoryComment(SPELLS_CATEGORY, "Set a spell to false to disable it. Disabled spells will still have their associated spell book (mainly so the spell books don't all change) and can still be bound to wands, but cannot be cast in game, will not appear in any subsequently generated chests or wizard trades and will not drop from mobs. Disable a spell if it is causing problems, conflicts with another mod or creates an unintended exploit."); + config.addCustomCategoryComment(SPELLS_CATEGORY, + "Set a spell to false to disable it. Disabled spells will still have their associated spell book (mainly so the spell books don't all change) and can still be bound to wands, but cannot be cast in game, will not appear in any subsequently generated chests or wizard trades and will not drop from mobs. Disable a spell if it is causing problems, conflicts with another mod or creates an unintended exploit."); Property property; @@ -261,172 +292,206 @@ public final class Settings { Property property; - config.addCustomCategoryComment(Configuration.CATEGORY_GENERAL, "Please note that changing some of these settings may make the mod very difficult to play."); + config.addCustomCategoryComment(Configuration.CATEGORY_GENERAL, + "Please note that changing some of these settings may make the mod very difficult to play."); - property = config.get(Configuration.CATEGORY_GENERAL, "towerRarity", 8, "Rarity of wizard towers. Higher numbers are rarer. Set to 0 to disable wizard towers completely.", 0, 50); + property = config.get(Configuration.CATEGORY_GENERAL, "towerRarity", 8, + "Rarity of wizard towers. Higher numbers are rarer. Set to 0 to disable wizard towers completely.", 0, + 50); property.setLanguageKey("config.wizardry.tower_rarity"); property.setRequiresWorldRestart(true); Wizardry.proxy.setToNumberSliderEntry(property); towerRarity = property.getInt(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "spellBookDropChance", 3, "The chance for mobs to drop a spell book when killed. The greater this number, the more often they will drop. Set to 0 to disable spell book drops. Set to 200 for guaranteed drops.", 0, 200); + property = config.get(Configuration.CATEGORY_GENERAL, "spellBookDropChance", 3, + "The chance for mobs to drop a spell book when killed. The greater this number, the more often they will drop. Set to 0 to disable spell book drops. Set to 200 for guaranteed drops.", + 0, 200); property.setLanguageKey("config.wizardry.spell_book_drop_chance"); Wizardry.proxy.setToNumberSliderEntry(property); spellBookDropChance = property.getInt(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "oreDimensions", new int[]{0}, "List of dimension ids in which crystal ore will generate. Note that removing the overworld (id 0) from this list will make the mod VERY difficult to play!"); + property = config.get(Configuration.CATEGORY_GENERAL, "oreDimensions", new int[]{0}, + "List of dimension ids in which crystal ore will generate. Note that removing the overworld (id 0) from this list will make the mod VERY difficult to play!"); property.setLanguageKey("config.wizardry.ore_dimensions"); property.setRequiresWorldRestart(true); oreDimensions = property.getIntList(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "flowerDimensions", new int[]{0}, "List of dimension ids in which crystal flowers will generate."); + property = config.get(Configuration.CATEGORY_GENERAL, "flowerDimensions", new int[]{0}, + "List of dimension ids in which crystal flowers will generate."); property.setLanguageKey("config.wizardry.flower_dimensions"); property.setRequiresWorldRestart(true); flowerDimensions = property.getIntList(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "towerDimensions", new int[]{0}, "List of dimension ids in which wizard towers will generate."); + property = config.get(Configuration.CATEGORY_GENERAL, "towerDimensions", new int[]{0}, + "List of dimension ids in which wizard towers will generate."); property.setLanguageKey("config.wizardry.tower_dimensions"); property.setRequiresWorldRestart(true); towerDimensions = property.getIntList(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "generateLoot", true, "Whether to generate wizardry loot in dungeon chests."); + property = config.get(Configuration.CATEGORY_GENERAL, "generateLoot", true, + "Whether to generate wizardry loot in dungeon chests."); property.setLanguageKey("config.wizardry.generate_loot"); property.setRequiresWorldRestart(true); generateLoot = property.getBoolean(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "firebombIsCraftable", true, "Whether firebombs can be crafted or not."); + property = config.get(Configuration.CATEGORY_GENERAL, "firebombIsCraftable", true, + "Whether firebombs can be crafted or not."); property.setLanguageKey("config.wizardry.firebomb_is_craftable"); property.setRequiresMcRestart(true); firebombIsCraftable = property.getBoolean(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "poisonBombIsCraftable", true, "Whether poison bombs can be crafted or not."); + property = config.get(Configuration.CATEGORY_GENERAL, "poisonBombIsCraftable", true, + "Whether poison bombs can be crafted or not."); property.setLanguageKey("config.wizardry.poison_bomb_is_craftable"); property.setRequiresMcRestart(true); poisonBombIsCraftable = property.getBoolean(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "smokeBombIsCraftable", true, "Whether smoke bombs can be crafted or not."); + property = config.get(Configuration.CATEGORY_GENERAL, "smokeBombIsCraftable", true, + "Whether smoke bombs can be crafted or not."); property.setLanguageKey("config.wizardry.smoke_bomb_is_craftable"); property.setRequiresMcRestart(true); smokeBombIsCraftable = property.getBoolean(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "useAlternateScrollRecipe", false, "Whether to require a magic crystal in the shapeless crafting recipe for blank scrolls. Set to true if another mod adds a conflicting recipe."); + property = config.get(Configuration.CATEGORY_GENERAL, "useAlternateScrollRecipe", false, + "Whether to require a magic crystal in the shapeless crafting recipe for blank scrolls. Set to true if another mod adds a conflicting recipe."); property.setLanguageKey("config.wizardry.use_alternate_scroll_recipe"); property.setRequiresMcRestart(true); useAlternateScrollRecipe = property.getBoolean(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "teleportThroughUnbreakableBlocks", false, "Whether players are allowed to teleport through unbreakable blocks (e.g. bedrock) using the phase step spell."); + property = config.get(Configuration.CATEGORY_GENERAL, "teleportThroughUnbreakableBlocks", false, + "Whether players are allowed to teleport through unbreakable blocks (e.g. bedrock) using the phase step spell."); property.setLanguageKey("config.wizardry.teleport_through_unbreakable_blocks"); teleportThroughUnbreakableBlocks = property.getBoolean(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "showSummonedCreatureNames", true, "Whether to show summoned creatures' names and owners above their heads."); + property = config.get(Configuration.CATEGORY_GENERAL, "showSummonedCreatureNames", true, + "Whether to show summoned creatures' names and owners above their heads."); property.setLanguageKey("config.wizardry.show_summoned_creature_names"); showSummonedCreatureNames = property.getBoolean(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "friendlyFire", true, "Whether to allow players to damage their designated allies using magic."); + property = config.get(Configuration.CATEGORY_GENERAL, "friendlyFire", true, + "Whether to allow players to damage their designated allies using magic."); property.setLanguageKey("config.wizardry.friendly_fire"); friendlyFire = property.getBoolean(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "telekineticDisarmament", true, "Whether to allow players to disarm other players using the telekinesis spell. Set to false to prevent stealing of items."); + property = config.get(Configuration.CATEGORY_GENERAL, "telekineticDisarmament", true, + "Whether to allow players to disarm other players using the telekinesis spell. Set to false to prevent stealing of items."); property.setLanguageKey("config.wizardry.telekinetic_disarmament"); telekineticDisarmament = property.getBoolean(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "discoveryMode", true, "For those who like a sense of mystery! When set to true, spells you haven't cast yet will be unreadable until you cast them (on a per-world basis). Has no effect when in creative mode. Spells of identification will be unobtainable in survival mode if this is false."); + property = config.get(Configuration.CATEGORY_GENERAL, "discoveryMode", true, + "For those who like a sense of mystery! When set to true, spells you haven't cast yet will be unreadable until you cast them (on a per-world basis). Has no effect when in creative mode. Spells of identification will be unobtainable in survival mode if this is false."); property.setLanguageKey("config.wizardry.discovery_mode"); property.setRequiresWorldRestart(true); discoveryMode = property.getBoolean(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "enableShiftScrolling", true, "Whether you can switch between spells on a wand by scrolling with the mouse wheel while sneaking. Note that this will only affect you; other players connected to the same server obey their own settings."); + property = config.get(Configuration.CATEGORY_GENERAL, "enableShiftScrolling", true, + "Whether you can switch between spells on a wand by scrolling with the mouse wheel while sneaking. Note that this will only affect you; other players connected to the same server obey their own settings."); property.setLanguageKey("config.wizardry.enable_shift_scrolling"); property.setRequiresWorldRestart(false); enableShiftScrolling = property.getBoolean(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "minionRevengeTargeting", true, "Whether summoned creatures can revenge attack their owner if their owner attacks them."); + property = config.get(Configuration.CATEGORY_GENERAL, "minionRevengeTargeting", true, + "Whether summoned creatures can revenge attack their owner if their owner attacks them."); property.setLanguageKey("config.wizardry.minion_revenge_targeting"); property.setRequiresWorldRestart(false); minionRevengeTargeting = property.getBoolean(); propOrder.add(property.getName()); // These two aren't sliders because using a slider makes it difficult to fine-tune the numbers; the nature of a - // scaling factor means that 0.5 is as big a change as 2.0, so whilst a slider is fine for increasing the damage, + // scaling factor means that 0.5 is as big a change as 2.0, so whilst a slider is fine for increasing the + // damage, // it doesn't give fine enough control for values less than 1. - property = config.get(Configuration.CATEGORY_GENERAL, "playerDamageScaling", 1.0, "Global damage scaling factor for the damage dealt by players casting spells, relative to 1.", 0, 20); + property = config.get(Configuration.CATEGORY_GENERAL, "playerDamageScaling", 1.0, + "Global damage scaling factor for the damage dealt by players casting spells, relative to 1.", 0, 20); property.setLanguageKey("config.wizardry.player_damage_scaling"); playerDamageScale = property.getDouble(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "npcDamageScaling", 1.0, "Global damage scaling factor for the damage dealt by NPCs casting spells, relative to 1.", 0, 20); + property = config.get(Configuration.CATEGORY_GENERAL, "npcDamageScaling", 1.0, + "Global damage scaling factor for the damage dealt by NPCs casting spells, relative to 1.", 0, 20); property.setLanguageKey("config.wizardry.npc_damage_scaling"); npcDamageScale = property.getDouble(); propOrder.add(property.getName()); - // This one isn't a slider either because people are likely to want exact values ("it must be at most 50.3" is a bit strange!). - property = config.get(Configuration.CATEGORY_GENERAL, "castCommandMultiplierLimit", 20.0, "Upper limit for the multipliers passed into the /cast command. This is here to stop players from accidentally breaking a world/server. Large blast mutipliers can cause extreme lag - you have been warned!", 1, 255); + // This one isn't a slider either because people are likely to want exact values ("it must be at most 50.3" is a + // bit strange!). + property = config.get(Configuration.CATEGORY_GENERAL, "castCommandMultiplierLimit", 20.0, + "Upper limit for the multipliers passed into the /cast command. This is here to stop players from accidentally breaking a world/server. Large blast mutipliers can cause extreme lag - you have been warned!", + 1, 255); property.setLanguageKey("config.wizardry.cast_command_multiplier_limit"); maxSpellCommandMultiplier = property.getDouble(); propOrder.add(property.getName()); - property = config.get(Configuration.CATEGORY_GENERAL, "summonedCreatureTargetsWhitelist", new String[0], "List of names of entities which summoned creatures and wizards are allowed to attack, in addition to the defaults. Add mod creatures to this list if you want summoned creatures to attack them and they aren't already doing so. Entity names are not case sensitive. For mod entities, prefix with the mod ID (e.g. wizardry:Wizard)."); + property = config.get(Configuration.CATEGORY_GENERAL, "summonedCreatureTargetsWhitelist", new String[0], + "List of names of entities which summoned creatures and wizards are allowed to attack, in addition to the defaults. Add mod creatures to this list if you want summoned creatures to attack them and they aren't already doing so. Entity names are not case sensitive. For mod entities, prefix with the mod ID (e.g. wizardry:Wizard)."); property.setLanguageKey("config.wizardry.summoned_creature_targets_whitelist"); property.setRequiresWorldRestart(true); - //Wizardry.proxy.setToEntityNameEntry(property); + // Wizardry.proxy.setToEntityNameEntry(property); summonedCreatureTargetsWhitelist = property.getStringList(); // Converts all strings in the list to lower case, to ignore case sensitivity, and trims them. - for(int i=0; i propOrder1 = new ArrayList(); - config.addCustomCategoryComment(RESISTANCES_CATEGORY, "Settings which allow entities to be made immune to certain types of magic. In multiplayer, the server/LAN host settings will apply."); + config.addCustomCategoryComment(RESISTANCES_CATEGORY, + "Settings which allow entities to be made immune to certain types of magic. In multiplayer, the server/LAN host settings will apply."); - property = config.get(RESISTANCES_CATEGORY, "mobsImmuneToFire", new String[]{}, "List of names of entities that are immune to fire, in addition to the defaults. Add mod creatures to this list if you want them to be immune to fire magic and they aren't already. Entity names are not case sensitive. For mod entities, prefix with the mod ID (e.g. wizardry:Wizard)."); + property = config.get(RESISTANCES_CATEGORY, "mobsImmuneToFire", new String[]{}, + "List of names of entities that are immune to fire, in addition to the defaults. Add mod creatures to this list if you want them to be immune to fire magic and they aren't already. Entity names are not case sensitive. For mod entities, prefix with the mod ID (e.g. wizardry:Wizard)."); property.setLanguageKey("config.wizardry.mobs_immune_to_fire"); property.setRequiresMcRestart(true); - //Wizardry.proxy.setToEntityNameEntry(property); + // Wizardry.proxy.setToEntityNameEntry(property); // Converts all strings in the list to lower case, to ignore case sensitivity, and trims them. - for(int i=0; i randomNames = new HashMap(Spell.getTotalSpellCount()); public Map randomDescriptions = new HashMap(Spell.getTotalSpellCount()); // Required constructors - public SpellGlyphData() { + public SpellGlyphData(){ this(NAME); } public SpellGlyphData(String name){ super(name); } - + /** Generates random names and descriptions for any spells which don't already have them. */ public void generateGlyphNames(World world){ for(Spell spell : Spell.getSpells(Spell.allSpells)){ if(!randomNames.containsKey(spell)) randomNames.put(spell, generateRandomName(world.rand)); } - + for(Spell spell : Spell.getSpells(Spell.allSpells)){ - if(!randomDescriptions.containsKey(spell)) randomDescriptions.put(spell, generateRandomDescription(world.rand)); + if(!randomDescriptions.containsKey(spell)) + randomDescriptions.put(spell, generateRandomDescription(world.rand)); } - + this.markDirty(); } - + private String generateRandomName(Random random){ - + String name = ""; - - for(int i=0; i names = new ArrayList(); List descriptions = new ArrayList(); - + for(Spell spell : Spell.getSpells(Spell.allSpells)){ names.add(this.randomNames.get(spell)); descriptions.add(this.randomDescriptions.get(spell)); } - + PacketGlyphData.Message msg = new PacketGlyphData.Message(names, descriptions); - + WizardryPacketHandler.net.sendTo(msg, player); Wizardry.logger.info("Synchronising spell glyph data for " + player.getName()); - + } - + /** Helper method to retrieve the random glyph name for the given spell from the map stored in the given world. */ public static String getGlyphName(Spell spell, World world){ Map names = SpellGlyphData.get(world).randomNames; return names == null ? "" : names.get(spell); } - - /** Helper method to retrieve the random glyph description for the given spell from the map stored in the given world. */ + + /** + * Helper method to retrieve the random glyph description for the given spell from the map stored in the given + * world. + */ public static String getGlyphDescription(Spell spell, World world){ Map descriptions = SpellGlyphData.get(world).randomDescriptions; return descriptions == null ? "" : descriptions.get(spell); @@ -132,13 +143,13 @@ public class SpellGlyphData extends WorldSavedData { @Override public void readFromNBT(NBTTagCompound nbt){ - + this.randomNames = new HashMap(); this.randomDescriptions = new HashMap(); - + NBTTagList tagList = nbt.getTagList("spellGlyphData", NBT.TAG_COMPOUND); - - for(int i=0; i - * Forge seems to have separate classes to hold the Capability<...> instance ('key') and - * methods for getting the capability, but in my opinion there are already too many classes to deal with, so I'm not - * adding any more than are necessary, meaning those constants and values are kept here instead. + * Forge seems to have separate classes to hold the Capability<...> instance ('key') and methods for getting the + * capability, but in my opinion there are already too many classes to deal with, so I'm not adding any more than are + * necessary, meaning those constants and values are kept here instead. + * * @since Wizardry 1.2 - * @author Electroblob */ + * @author Electroblob + */ // On the plus side, having to rethink this class allowed me to clean it up a lot. @Mod.EventBusSubscriber public class WizardData implements INBTSerializable { @@ -85,14 +88,20 @@ public class WizardData implements INBTSerializable { public boolean hasSpiritWolf; public boolean hasSpiritHorse; - /** Whether this player is currently casting a continuous spell via commands. Not saved over world reload - * and reset on player death. */ + /** + * Whether this player is currently casting a continuous spell via commands. Not saved over world reload and reset + * on player death. + */ private Spell currentlyCasting; - /** The time for which this player has been casting a continuous spell via commands. Increments by 1 each tick. - * Not saved over world reload and reset on player death. */ + /** + * The time for which this player has been casting a continuous spell via commands. Increments by 1 each tick. Not + * saved over world reload and reset on player death. + */ private int castingTick; - /** SpellModifiers object for the current continuous spell cast via commands. Not saved over world reload and - * reset on player death. */ + /** + * SpellModifiers object for the current continuous spell cast via commands. Not saved over world reload and reset + * on player death. + */ private SpellModifiers spellModifiers; /** Coordinates for the saved transportation stone circle location. Will be null if no location is saved. */ private BlockPos stoneCircleLocation; @@ -110,14 +119,18 @@ public class WizardData implements INBTSerializable { public WeakReference selectedMinion; - /** Set of this player's discovered spells. Do not write to this list directly, use - * {@link WizardData#discoverSpell(Spell)} instead. */ + /** + * Set of this player's discovered spells. Do not write to this list directly, use + * {@link WizardData#discoverSpell(Spell)} instead. + */ public Set spellsDiscovered; private Set allies; - /** List of usernames of this player's allies. May not be accurate 100% of the time. This is here so that a player - * can view the usernames of their allies even when those allies are not online. - * Do not use this for any other purpose than displaying the names! */ + /** + * List of usernames of this player's allies. May not be accurate 100% of the time. This is here so that a player + * can view the usernames of their allies even when those allies are not online. Do not use this for any other + * purpose than displaying the names! + */ public Set allyNames; private Set soulboundCreatures; @@ -147,9 +160,10 @@ public class WizardData implements INBTSerializable { } /** - * Adds the given spell to the list of discovered spells for this player. Automatically takes into account - * whether the spell has been discovered. Use this method rather than adding directly to the list because it - * handles achievements. + * Adds the given spell to the list of discovered spells for this player. Automatically takes into account whether + * the spell has been discovered. Use this method rather than adding directly to the list because it handles + * achievements. + * * @param spell The spell to be discovered * @return True if the spell had not already been discovered; false otherwise. */ @@ -168,7 +182,8 @@ public class WizardData implements INBTSerializable { } for(Element element : Element.values()){ - if(element != Element.MAGIC && spellsDiscovered.containsAll(Spell.getSpells(new Spell.TierElementFilter(null, element)))){ + if(element != Element.MAGIC + && spellsDiscovered.containsAll(Spell.getSpells(new Spell.TierElementFilter(null, element)))){ this.player.addStat(WizardryAchievements.element_master); } } @@ -183,13 +198,22 @@ public class WizardData implements INBTSerializable { } /** Returns the coordinates of the associated player's saved transportation stone circle. */ - public BlockPos getStoneCircleLocation(){ return stoneCircleLocation; } + public BlockPos getStoneCircleLocation(){ + return stoneCircleLocation; + } + /** Returns the dimension ID of the associated player's saved transportation stone circle. */ - public int getStoneCircleDimension(){ return stoneCircleDimension; } + public int getStoneCircleDimension(){ + return stoneCircleDimension; + } - public int getTpCountdown() { return tpCountdown; } + public int getTpCountdown(){ + return tpCountdown; + } - public void setTpCountdown(int tpCountdown) { this.tpCountdown = tpCountdown; } + public void setTpCountdown(int tpCountdown){ + this.tpCountdown = tpCountdown; + } /** Sets the player's saved clairvoyance location. */ public void setClairvoyancePoint(BlockPos pos, int dimensionID){ @@ -198,46 +222,60 @@ public class WizardData implements INBTSerializable { } /** Returns the coordinates for the saved clairvoyance location. Will be null if no location is saved. */ - public BlockPos getClairvoyanceLocation(){ return clairvoyanceLocation; } + public BlockPos getClairvoyanceLocation(){ + return clairvoyanceLocation; + } /** Returns the dimension ID for the saved clairvoyance location. Will be null if no location is saved. */ - public int getClairvoyanceDimension(){ return clairvoyanceDimension; } + public int getClairvoyanceDimension(){ + return clairvoyanceDimension; + } - /** Overwrites the imbuement duration associated with the given imubement for this player, or creates it if there - * was none previously. - * @throws IllegalArgumentException if the given {@link Enchantment} is not an {@link Imbuement}. */ + /** + * Overwrites the imbuement duration associated with the given imubement for this player, or creates it if there was + * none previously. + * + * @throws IllegalArgumentException if the given {@link Enchantment} is not an {@link Imbuement}. + */ public void setImbuementDuration(Enchantment enchantment, int duration){ - // It is best to throw an exception here, because otherwise the error would either go unnoticed (if non-imbuements + // It is best to throw an exception here, because otherwise the error would either go unnoticed (if + // non-imbuements // were ignored) or cause a ClassCastException later (if non-imbuements were allowed to be added). if(enchantment instanceof Imbuement){ - this.imbuementDurations.put((Imbuement) enchantment, duration); + this.imbuementDurations.put((Imbuement)enchantment, duration); }else{ - throw new IllegalArgumentException("Attempted to set an imbuement duration for something that isn't an Imbuement! (This exception has been thrown now to prevent a ClassCastException from occurring later.)"); + throw new IllegalArgumentException( + "Attempted to set an imbuement duration for something that isn't an Imbuement! (This exception has been thrown now to prevent a ClassCastException from occurring later.)"); } } - /** Returns the imbuement duration associated with the given imbuement for this player, or 0 if it does not exist. */ + /** + * Returns the imbuement duration associated with the given imbuement for this player, or 0 if it does not exist. + */ @SuppressWarnings("unlikely-arg-type") public int getImbuementDuration(Enchantment enchantment){ // Need to check that i is not null, otherwise it throws an NPE when Java auto-unboxes it. - // What's nice here is that the map simply accepts objects as keys, so there's no need to cast or throw exceptions. + // What's nice here is that the map simply accepts objects as keys, so there's no need to cast or throw + // exceptions. Integer i = this.imbuementDurations.get(enchantment); // If i is null, returns 0; otherwise returns i, auto-unboxed to an int. return i == null ? 0 : i; } - /** Decrements the duration for each conjured item by 1, and removes from the map any that are 0 or less or that - * the player no longer has. Also deletes the item from the player's inventory if it runs out of time. */ + /** + * Decrements the duration for each conjured item by 1, and removes from the map any that are 0 or less or that the + * player no longer has. Also deletes the item from the player's inventory if it runs out of time. + */ private void updateImbuedItems(){ - + Set activeImbuements = new HashSet(); // For each item in the player's inventory for(ItemStack stack : player.inventory.mainInventory){ - if(stack != null && stack.isItemEnchanted()){ - + if(stack.isItemEnchanted()){ + Map enchantments = EnchantmentHelper.getEnchantments(stack); - + Iterator> iterator = enchantments.entrySet().iterator(); // For each of the item's enchantments while(iterator.hasNext()){ @@ -248,10 +286,10 @@ public class WizardData implements INBTSerializable { // If the imbuement is still active: if(duration > 0){ // Decrements the timer - this.imbuementDurations.put((Imbuement)enchantment, duration-1); + this.imbuementDurations.put((Imbuement)enchantment, duration - 1); // Adds this imbuement to the set of imbuements that need to be kept activeImbuements.add((Imbuement)enchantment); - // Otherwise: + // Otherwise: }else{ // Removes the enchantment from the enchantment map iterator.remove(); @@ -266,8 +304,10 @@ public class WizardData implements INBTSerializable { this.imbuementDurations.keySet().retainAll(activeImbuements); } - /** Adds the given player to the list of allies belonging to the associated player, or removes the player if - * they are already in the list of allies. Returns true if the player was added, false if they were removed. */ + /** + * Adds the given player to the list of allies belonging to the associated player, or removes the player if they are + * already in the list of allies. Returns true if the player was added, false if they were removed. + */ public boolean toggleAlly(EntityPlayer player){ if(this.isPlayerAlly(player)){ this.allies.remove(player.getUniqueID()); @@ -296,21 +336,24 @@ public class WizardData implements INBTSerializable { return this.soulboundCreatures.contains(target.getUniqueID()); } - /** Damages all creatures soulbound to this player by the given amount, and removes from the list any that no - * longer exist. */ + /** + * Damages all creatures soulbound to this player by the given amount, and removes from the list any that no longer + * exist. + */ public void damageAllSoulboundCreatures(float damage){ for(Iterator iterator = this.soulboundCreatures.iterator(); iterator.hasNext();){ - Entity entity = WizardryUtilities.getEntityByUUID(this.player.worldObj, iterator.next()); + Entity entity = WizardryUtilities.getEntityByUUID(this.player.world, iterator.next()); if(entity == null) iterator.remove(); if(entity instanceof EntityLivingBase){ // Retaliatory effect - if(entity.attackEntityFrom(MagicDamage.causeDirectMagicDamage(this.player, DamageType.MAGIC, true), damage)){ + if(entity.attackEntityFrom(MagicDamage.causeDirectMagicDamage(this.player, DamageType.MAGIC, true), + damage)){ // Sound only plays if the damage succeeds - player.playSound(SoundEvents.ENTITY_WITHER_HURT, 1.0F, player.worldObj.rand.nextFloat() * 0.2F + 1.0F); + player.playSound(SoundEvents.ENTITY_WITHER_HURT, 1.0F, player.world.rand.nextFloat() * 0.2F + 1.0F); } } } @@ -322,10 +365,10 @@ public class WizardData implements INBTSerializable { this.currentlyCasting = spell; this.spellModifiers = modifiers; - if(!this.player.worldObj.isRemote){ + if(!this.player.world.isRemote){ PacketCastContinuousSpell.Message message = new PacketCastContinuousSpell.Message(this.player.getEntityId(), spell.id(), this.spellModifiers); - WizardryPacketHandler.net.sendToDimension(message, this.player.worldObj.provider.getDimension()); + WizardryPacketHandler.net.sendToDimension(message, this.player.world.provider.getDimension()); } } @@ -336,31 +379,33 @@ public class WizardData implements INBTSerializable { this.castingTick = 0; this.spellModifiers.reset(); - if(!this.player.worldObj.isRemote){ + if(!this.player.world.isRemote){ PacketCastContinuousSpell.Message message = new PacketCastContinuousSpell.Message(this.player.getEntityId(), Spells.none.id(), this.spellModifiers); - WizardryPacketHandler.net.sendToDimension(message, this.player.worldObj.provider.getDimension()); + WizardryPacketHandler.net.sendToDimension(message, this.player.world.provider.getDimension()); } } - + /** Casts the current continuous spell, fires relevant events and updates the castingTick field. */ public void updateContinuousSpellCasting(){ - + if(this.currentlyCasting != null && this.currentlyCasting.isContinuous){ - - if(MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Tick(player, currentlyCasting, spellModifiers, Source.COMMAND, castingTick))){ + + if(MinecraftForge.EVENT_BUS.post( + new SpellCastEvent.Tick(player, currentlyCasting, spellModifiers, Source.COMMAND, castingTick))){ this.stopCastingContinuousSpell(); return; } - - if(this.currentlyCasting.cast(player.worldObj, player, EnumHand.MAIN_HAND, castingTick, this.spellModifiers) + + if(this.currentlyCasting.cast(player.world, player, EnumHand.MAIN_HAND, castingTick, this.spellModifiers) && this.castingTick == 0){ // On the first tick casting a continuous spell via commands, SpellCastEvent.Post is fired. - MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Post(player, currentlyCasting, spellModifiers, Source.COMMAND)); + MinecraftForge.EVENT_BUS + .post(new SpellCastEvent.Post(player, currentlyCasting, spellModifiers, Source.COMMAND)); } - + castingTick++; - + }else{ // Why is this here? Surely castingTick will always be 0 if currentlyCasting is null? this.castingTick = 0; @@ -372,8 +417,10 @@ public class WizardData implements INBTSerializable { return this.currentlyCasting != null && this.currentlyCasting != Spells.none; } - /** Returns the continuous spell this player is currently casting via commands, or the 'none' spell if they aren't - * casting anything. */ + /** + * Returns the continuous spell this player is currently casting via commands, or the 'none' spell if they aren't + * casting anything. + */ public Spell currentlyCasting(){ return currentlyCasting; } @@ -387,20 +434,20 @@ public class WizardData implements INBTSerializable { // functions, just for different enchantments. updateImbuedItems(); - if(!player.worldObj.isRemote){ + if(!player.world.isRemote){ if(getTpCountdown() == 1){ player.setPositionAndUpdate(this.stoneCircleLocation.getX() + 0.5, this.stoneCircleLocation.getY(), this.stoneCircleLocation.getZ() + 0.5); player.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, 50, 0)); IMessage msg = new PacketTransportation.Message(player.getEntityId()); - WizardryPacketHandler.net.sendToDimension(msg, player.worldObj.provider.getDimension()); + WizardryPacketHandler.net.sendToDimension(msg, player.world.provider.getDimension()); } if(getTpCountdown() > 0){ setTpCountdown(getTpCountdown() - 1); } } - + updateContinuousSpellCasting(); } @@ -411,11 +458,14 @@ public class WizardData implements INBTSerializable { return player.getCapability(WIZARD_DATA_CAPABILITY, null); } - /** Called from the event handler each time the associated player entity is cloned, i.e. on respawn or when - * travelling to a different dimension. Used to copy over any variables that should persist over player death. - * This is the inverse of the old onPlayerDeath method, which reset the variables that shouldn't persist. + /** + * Called from the event handler each time the associated player entity is cloned, i.e. on respawn or when + * travelling to a different dimension. Used to copy over any variables that should persist over player death. This + * is the inverse of the old onPlayerDeath method, which reset the variables that shouldn't persist. + * * @param data The old WizardData whose variables are to be copied over. - * @param respawn True if the player died and is respawning, false if they are just travelling between dimensions. */ + * @param respawn True if the player died and is respawning, false if they are just travelling between dimensions. + */ public void copyFrom(WizardData data, boolean respawn){ // TODO: What happens with spirit wolf and spirit horse? this.hasSpiritHorse = data.hasSpiritHorse; @@ -441,14 +491,15 @@ public class WizardData implements INBTSerializable { public void sync(){ if(this.player instanceof EntityPlayerMP){ int id = -1; - if(this.selectedMinion != null && this.selectedMinion.get() instanceof Entity) id = ((Entity)this.selectedMinion.get()).getEntityId(); + if(this.selectedMinion != null && this.selectedMinion.get() instanceof Entity) + id = ((Entity)this.selectedMinion.get()).getEntityId(); IMessage msg = new PacketPlayerSync.Message(this.spellsDiscovered, id); WizardryPacketHandler.net.sendTo(msg, (EntityPlayerMP)this.player); } } @Override - public NBTTagCompound serializeNBT() { + public NBTTagCompound serializeNBT(){ NBTTagCompound properties = new NBTTagCompound(); @@ -459,21 +510,24 @@ public class WizardData implements INBTSerializable { properties.setBoolean("hasSpiritWolf", this.hasSpiritWolf); properties.setBoolean("hasSpiritHorse", this.hasSpiritHorse); - if(this.stoneCircleLocation != null) properties.setLong("stoneCircleLocation", this.stoneCircleLocation.toLong()); + if(this.stoneCircleLocation != null) + properties.setLong("stoneCircleLocation", this.stoneCircleLocation.toLong()); properties.setInteger("stoneCircleDimension", this.stoneCircleDimension); properties.setInteger("tpCountdown", this.tpCountdown); - if(this.clairvoyanceLocation != null) properties.setLong("clairvoyanceLocation", this.clairvoyanceLocation.toLong()); + if(this.clairvoyanceLocation != null) + properties.setLong("clairvoyanceLocation", this.clairvoyanceLocation.toLong()); properties.setInteger("clairvoyanceDimension", this.getClairvoyanceDimension()); // THIS is why I wrote the list/map <-> NBT methods. Look how neat this is! properties.setTag("allies", WizardryUtilities.listToNBT(this.allies, WizardryUtilities::UUIDtoTagCompound)); properties.setTag("allyNames", WizardryUtilities.listToNBT(this.allyNames, NBTTagString::new)); - properties.setTag("soulboundCreatures", WizardryUtilities.listToNBT(this.soulboundCreatures, WizardryUtilities::UUIDtoTagCompound)); + properties.setTag("soulboundCreatures", + WizardryUtilities.listToNBT(this.soulboundCreatures, WizardryUtilities::UUIDtoTagCompound)); // Might be worth converting this over to WizardryUtilities.listToNBT. int[] spells = new int[this.spellsDiscovered.size()]; - int i=0; + int i = 0; for(Spell spell : this.spellsDiscovered){ spells[i] = spell.id(); i++; @@ -484,7 +538,7 @@ public class WizardData implements INBTSerializable { } @Override - public void deserializeNBT(NBTTagCompound nbt) { + public void deserializeNBT(NBTTagCompound nbt){ if(nbt != null){ @@ -504,11 +558,11 @@ public class WizardData implements INBTSerializable { this.allies = new HashSet(WizardryUtilities.NBTToList(nbt.getTagList("allies", NBT.TAG_COMPOUND), WizardryUtilities::tagCompoundToUUID)); - this.allyNames = new HashSet(WizardryUtilities.NBTToList(nbt.getTagList("allyNames", NBT.TAG_STRING), - NBTTagString::getString)); + this.allyNames = new HashSet( + WizardryUtilities.NBTToList(nbt.getTagList("allyNames", NBT.TAG_STRING), NBTTagString::getString)); - this.soulboundCreatures = new HashSet(WizardryUtilities.NBTToList(nbt.getTagList("soulboundCreatures", NBT.TAG_COMPOUND), - WizardryUtilities::tagCompoundToUUID)); + this.soulboundCreatures = new HashSet(WizardryUtilities.NBTToList( + nbt.getTagList("soulboundCreatures", NBT.TAG_COMPOUND), WizardryUtilities::tagCompoundToUUID)); this.spellsDiscovered = new HashSet(); for(int id : nbt.getIntArray("discoveredSpells")){ @@ -516,20 +570,21 @@ public class WizardData implements INBTSerializable { } } } - + // Event handlers - + @SubscribeEvent // The type parameter here has to be Entity, not EntityPlayer, or the event won't get fired. public static void onCapabilityLoad(AttachCapabilitiesEvent event){ if(event.getObject() instanceof EntityPlayer) - event.addCapability(new ResourceLocation(Wizardry.MODID, "WizardData"), new WizardData.Provider((EntityPlayer)event.getObject())); + event.addCapability(new ResourceLocation(Wizardry.MODID, "WizardData"), + new WizardData.Provider((EntityPlayer)event.getObject())); // This demonstrates why capabilities are badly structured: The following code compiles, but what it does is put // a player into a CapabilityDispatcher, which is in turn stored in that very same player, which makes no sense // at all! - //event.addCapability(new ResourceLocation(Wizardry.MODID, "WizardData"), event.getObject()); + // event.addCapability(new ResourceLocation(Wizardry.MODID, "WizardData"), event.getObject()); } @SubscribeEvent @@ -540,32 +595,34 @@ public class WizardData implements INBTSerializable { newData.copyFrom(oldData, event.isWasDeath()); } - + @SubscribeEvent public static void onEntityJoinWorld(EntityJoinWorldEvent event){ - if(!event.getEntity().worldObj.isRemote && event.getEntity() instanceof EntityPlayerMP){ + if(!event.getEntity().world.isRemote && event.getEntity() instanceof EntityPlayerMP){ // Synchronises wizard data after loading. WizardData data = WizardData.get((EntityPlayer)event.getEntity()); if(data != null) data.sync(); } } - + @SubscribeEvent public static void onLivingUpdateEvent(LivingUpdateEvent event){ - + if(event.getEntityLiving() instanceof EntityPlayer){ - + EntityPlayer player = (EntityPlayer)event.getEntityLiving(); - + if(WizardData.get(player) != null){ WizardData.get(player).update(); } } } - /** This is a nested class for a few reasons: firstly, it makes sense because instances of this and WizardData go + /** + * This is a nested class for a few reasons: firstly, it makes sense because instances of this and WizardData go * hand-in-hand; secondly, it's too short to be worth a separate file; and thirdly (and most importantly) it allows - * me to access WIZARD_DATA_CAPABILITY while keeping it private. */ + * me to access WIZARD_DATA_CAPABILITY while keeping it private. + */ public static class Provider implements ICapabilitySerializable { private final WizardData data; @@ -575,12 +632,12 @@ public class WizardData implements INBTSerializable { } @Override - public boolean hasCapability(Capability capability, EnumFacing facing) { + public boolean hasCapability(Capability capability, EnumFacing facing){ return capability == WIZARD_DATA_CAPABILITY; } @Override - public T getCapability(Capability capability, EnumFacing facing) { + public T getCapability(Capability capability, EnumFacing facing){ if(capability == WIZARD_DATA_CAPABILITY){ return WIZARD_DATA_CAPABILITY.cast(data); @@ -590,12 +647,12 @@ public class WizardData implements INBTSerializable { } @Override - public NBTTagCompound serializeNBT() { + public NBTTagCompound serializeNBT(){ return data.serializeNBT(); } @Override - public void deserializeNBT(NBTTagCompound nbt) { + public void deserializeNBT(NBTTagCompound nbt){ data.deserializeNBT(nbt); } @@ -611,50 +668,44 @@ public class WizardData implements INBTSerializable { * "...without having to directly implement many interfaces." - Forge Docs. I still can't see what's wrong with * implementing many interfaces; surely that's what Java interfaces are designed for? * - * Other things I find annoying: - * - IStorage. It's completely redundant in the majority of cases, and I don't understand why we need yet another - * separate class. - * - Making an interface, only to implement it once and once only. This completely defeats the point of interfaces. - * - The EnumFacing parameter, which is again redundant for everything that isn't a tile entity. So much for a clean, - * neat system. + * Other things I find annoying: - IStorage. It's completely redundant in the majority of cases, and I don't + * understand why we need yet another separate class. - Making an interface, only to implement it once and once + * only. This completely defeats the point of interfaces. - The EnumFacing parameter, which is again redundant for + * everything that isn't a tile entity. So much for a clean, neat system. * * What Forge has effectively done is conflated two different functions: attaching data to stuff and cross-mod - * integration/soft dependencies. I think this is bad design; it would have been better to keep the two features separate. + * integration/soft dependencies. I think this is bad design; it would have been better to keep the two features + * separate. * - * Here's my current understanding of how the capability system works: - * - You make an interface which defines the things your capability can do (this class). I will call this the TEMPLATE. - * - You implement that interface with your default implementation (WizardData). This is the closest analog to your old - * IEEP implementation class. THIS CLASS STORES ALL THE VARIABLES, and hence has one instance for each instance of whatever - * it is attached to. I will call this the DATA. - * - The DATA class implements INBTSerializable (assuming you want it to be saved, which is nearly always the case) - * - Despite its name, Capability does NOT represent a capability itself. Instead, it acts as a sort of identifier/key, - * the idea being that you can access a particular instance of your DATA given the key (which tells forge that you want a - * capability of type TEMPLATE) and the object you want the DATA for. This is what Entity.getCapability(...) does. + * Here's my current understanding of how the capability system works: - You make an interface which defines the + * things your capability can do (this class). I will call this the TEMPLATE. - You implement that interface with + * your default implementation (WizardData). This is the closest analog to your old IEEP implementation class. THIS + * CLASS STORES ALL THE VARIABLES, and hence has one instance for each instance of whatever it is attached to. I + * will call this the DATA. - The DATA class implements INBTSerializable (assuming you want it to be saved, which is + * nearly always the case) - Despite its name, Capability does NOT represent a capability itself. Instead, it + * acts as a sort of identifier/key, the idea being that you can access a particular instance of your DATA given the + * key (which tells forge that you want a capability of type TEMPLATE) and the object you want the DATA for. This is + * what Entity.getCapability(...) does. * - * To really understand what's going on though, you need to sift through Forge's verbose data structures and find where - * capabilities are actually hooked into vanilla: - * - Anything that implements ICapabilityProvider will have a private CapabilityDispatcher field. This holds other - * ICapabilityProviders. (I know. This inheritance pattern DOES NOT MAKE SENSE, because these could, in theory, be OTHER - * ENTITIES!) - * - This field is assigned a value through Forge's event factory, which, as we are all familiar with, calls all the - * methods marked with @SubscribeEvent. These methods add individual ICapabilityProviders to a Map stored in the event, - * which the event factory then wraps in a CapabilityDispatcher (which is itself an ICapabilityProvider) for the object - * that called it. - * - In your event handler, you return a custom ICapabilityProvider which is effectively bolted on to the player, and - * duplicates the ICapabilityProvider methods so you can hook into them and return an instance of your DATA class. - * - Where before there was a simple collection of IEEPs stored in the player, there is now a tree of ICapabilityProviders: + * To really understand what's going on though, you need to sift through Forge's verbose data structures and find + * where capabilities are actually hooked into vanilla: - Anything that implements ICapabilityProvider will have a + * private CapabilityDispatcher field. This holds other ICapabilityProviders. (I know. This inheritance pattern DOES + * NOT MAKE SENSE, because these could, in theory, be OTHER ENTITIES!) - This field is assigned a value through + * Forge's event factory, which, as we are all familiar with, calls all the methods marked with @SubscribeEvent. + * These methods add individual ICapabilityProviders to a Map stored in the event, which the event factory then + * wraps in a CapabilityDispatcher (which is itself an ICapabilityProvider) for the object that called it. - In your + * event handler, you return a custom ICapabilityProvider which is effectively bolted on to the player, and + * duplicates the ICapabilityProvider methods so you can hook into them and return an instance of your DATA class. - + * Where before there was a simple collection of IEEPs stored in the player, there is now a tree of + * ICapabilityProviders: * - * - Entity/TileEntity/ItemStack - * - Vanilla ICapabilityProviders, mostly IItemHandlers, stored as fields. - * - CapabilityDispatcher, stored as a field. - * - Custom ICapabilityProviders - * - Custom CapabilityDispatchers - * - ... + * - Entity/TileEntity/ItemStack - Vanilla ICapabilityProviders, mostly IItemHandlers, stored as fields. - + * CapabilityDispatcher, stored as a field. - Custom ICapabilityProviders - Custom CapabilityDispatchers - ... * * Most importantly, EACH PLAYER HOLDS THEIR OWN INSTANCE OF THIS TREE. * - * When a capability is retrieved, the following process happens: - * 1. For the Entity/TileEntity/ItemStack instance, ICapabilityProvider.getCapability(...) is called. - * 2. The request propogates through the tree and finds the requested capability. */ + * When a capability is retrieved, the following process happens: 1. For the Entity/TileEntity/ItemStack instance, + * ICapabilityProvider.getCapability(...) is called. 2. The request propogates through the tree and finds the + * requested capability. */ } diff --git a/src/main/java/electroblob/wizardry/Wizardry.java b/src/main/java/electroblob/wizardry/Wizardry.java index 26d10ffd..80388ed0 100644 --- a/src/main/java/electroblob/wizardry/Wizardry.java +++ b/src/main/java/electroblob/wizardry/Wizardry.java @@ -37,17 +37,23 @@ import net.minecraftforge.fml.common.registry.GameRegistry.Type; public class Wizardry { /** Wizardry's mod ID. */ - public static final String MODID = "wizardry"; + // This is going to have to change for 1.12 or it'll conflict with the other wizardry mod. + // They were there first, it's only fair... although I wonder if that will have unintended side-effects? + public static final String MODID = "wizardry"; // How about 'ebwizardry', to keep it short? /** Wizardry's mod name, in readable form. */ public static final String NAME = "Electroblob's Wizardry"; - /** The version number for this version of wizardry. The following system is used for version numbers: - *

    [major Minecraft version].[major mod version].[minor mod version/patch]

    - * The major mod version is consistent across Minecraft versions, i.e. Wizardry 1.1 has the same features as - * Wizardry 2.1, but they are for different versions of Minecraft and have separate minor versioning. 1.x.x - * represents Minecraft 1.7.x versions, 2.x.x represents Minecraft 1.10.x versions, 3.x.x represents Minecraft - * 1.11.x versions, and so on. */ - public static final String VERSION = "2.1.0"; - + /** + * The version number for this version of wizardry. The following system is used for version numbers: + *

    + *

    [major Minecraft version].[major mod version].[minor mod version/patch] + *

    + *

    The major mod version is consistent across Minecraft versions, i.e. Wizardry 1.1 has the same + * features as Wizardry 2.1, but they are for different versions of Minecraft and have separate minor versioning. + * 1.x.x represents Minecraft 1.7.x versions, 2.x.x represents Minecraft 1.10.x versions, 3.x.x represents Minecraft + * 1.11.x versions, and so on. + */ + public static final String VERSION = "3.1.0"; + // IDEA: Improve the algorithm that finds a place to summon creatures to take walls into account. // IDEA: Replace all uses of Math.cos and Math.sin with MathHelper versions // IDEA: API feature that automatically injects custom wand upgrades into wizardry's loot tables @@ -55,32 +61,44 @@ public class Wizardry { // IDEA: Dispensers shooting spells from scrolls! Imagine the possibilities! // == Rendering overhaul! == // IDEA: Make spirit animals fade away when dispelled - // IDEA: Use your newfound knowledge of OpenGL to render animated boxes around entities being buffed, similar to creeper charge + // IDEA: Use your newfound knowledge of OpenGL to render animated boxes around entities being buffed, similar to + // creeper charge // IDEA: Redo RenderArc so it looks like lightning (it's literally a load of translucent boxes inside each other) // IDEA: The arcane workbench could use a few particles // IDEA: Add a box to the wizard armour model so that the robes bend when the wearer is sneaking // IDEA: Flash particle (I think it exists in vanilla somewhere) on spell impact // IDEA: Dust particles spray out from projectiles as they move // IDEA: Colour fading for particles - // IDEA: Make lightning and other effects particles. There's no reason why you can't pass in a player argument and have the particles move with them! - + // IDEA: Make lightning and other effects particles. There's no reason why you can't pass in a player argument and + // have the particles move with them! + /* Minor bugs that need fixing at some point: - * - Player skin hat layer shows through wizard hats - * - Wizard armour breaks rather than just running out of mana (I can't seem to replicate this bug, but I have had - * it happen to me before...) + * - Player skin hat layer shows through wizard hats - Wizard armour breaks rather than just running out of mana (I + * can't seem to replicate this bug, but I have had it happen to me before...) * - Shift-clicking a stack of special upgrades when in the arcane workbench causes the whole stack to be - * transferred when it should be just one (this is a bug with vanilla as well - try putting a stack of bottles into - * a brewing stand). I have at least made it so only one gets used now, so it has no impact on the game. + * transferred when it should be just one (this is a bug with vanilla as well - try putting a stack of bottles into + * a brewing stand). I have at least made it so only one gets used now, so it has no impact on the game. * - When a spell is on cooldown, you can't break blocks when holding a wand. */ - + // TODO: So somehow I have managed to overlook the fact that health is actually a float. What this means is that // I can make the healing spells use damage multipliers - hurrah! // TODO: Switch from IInventory to IItemHandler (Or don't. It's only useful for automation really.) // TODO: Triggering of inbuilt Forge events in relevant places? - // TODO: Implement custom events // TODO: Rearrange the config gui and file - + + // Updating: + // TODO: Make sure all obf reflection names are still correct + // ItemStacks can no longer be null, only empty, so: + // TODO: Replace all instances of stack = null with stack = ItemStack.EMPTY + // TODO: For each check, either replace with stack.isEmpty or simply remove it, depending on the use + // TODO: Go through each of the summoned creatures and check there are no extra vanilla methods to override + // TODO: Check whether Minecraft has added some methods that do the same job as my utilities, particularly in + // relation to itemstacks, hotbar, armour slots and inventory slots. + // TODO: Add wizard towers to the /locate command + // TODO: Fix cascading worldgen lag and backport (offset area into loaded chunks, possibly use WorldGenMinable) + // TODO: Change evil wizard sounds again to use illager sounds? + // TODO: Have particles obey Minecraft's particle setting where appropriate // (see https://github.com/RootsTeam/Embers/blob/master/src/main/java/teamroots/embers/particle/ParticleUtil.java) @@ -88,12 +106,12 @@ public class Wizardry { /** Static instance of the {@link Settings} object for Wizardry. */ public static final Settings settings = new Settings(); - + /** Static instance of the {@link Logger} object for Wizardry. */ public static Logger logger; - - //private static Pattern entityNamePattern; - + + // private static Pattern entityNamePattern; + // EventManager WizardryWorldGenerator generator = new WizardryWorldGenerator(); @@ -102,19 +120,19 @@ public class Wizardry { public static Wizardry instance; // Location of the proxy code, used by Forge. - @SidedProxy(clientSide="electroblob.wizardry.client.ClientProxy", serverSide="electroblob.wizardry.CommonProxy") + @SidedProxy(clientSide = "electroblob.wizardry.client.ClientProxy", serverSide = "electroblob.wizardry.CommonProxy") public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event){ - + logger = event.getModLog(); - + // The array in question no longer exists, so I'm pretty sure this isn't necessary any more. // expandPotionTypesArray(); settings.initConfig(event); - + // Yes - by the looks of it, having an interface is completely unnecessary in this case. CapabilityManager.INSTANCE.register(WizardData.class, new IStorage(){ // These methods are only called by Capability.writeNBT() or Capability.readNBT(), which in turn are @@ -122,8 +140,14 @@ public class Wizardry { // to allow capabilities to be saved and loaded manually. What that would be useful for I don't know. // (If an API forces most users to write redundant code for no reason, it's not user friendly, is it?) // ... well, that's my rant for today! - @Override public NBTBase writeNBT(Capability capability, WizardData instance, EnumFacing side){ return null; } - @Override public void readNBT(Capability capability, WizardData instance, EnumFacing side, NBTBase nbt){} + @Override + public NBTBase writeNBT(Capability capability, WizardData instance, EnumFacing side){ + return null; + } + + @Override + public void readNBT(Capability capability, WizardData instance, EnumFacing side, NBTBase nbt){ + } }, WizardData.class); WizardryRegistry.registerTileEntities(); @@ -131,10 +155,10 @@ public class Wizardry { WizardryRegistry.registerEntities(this); // The check for the generateLoot setting is now done within this method. WizardryRegistry.registerLoot(); - + // NOTE: Will need to be moved to init for 1.12, as will anything that needs to be after the registry events. WizardryTabs.sort(); - + // Moved to preInit, because apparently it has to be here now. proxy.registerRenderers(); @@ -160,7 +184,7 @@ public class Wizardry { // Recipes WizardryRegistry.registerRecipes(); - + proxy.initMixedFontRenderer(); } @@ -168,27 +192,20 @@ public class Wizardry { public void postInit(FMLPostInitializationEvent event){ // This needs to be here or it won't necessarily include all the mods' entities. // TODO: Re-implement this when the Forge bug is fixed. - /* Doesn't seem to be doing anything... - String entityNames = ""; - for(Object name : EntityList.classToStringMapping.values()){ - if(name instanceof String){ - entityNames = entityNames + name + '|'; - } - } - // Cuts off the last '|' - entityNames = entityNames.substring(0, entityNames.length()-1); - entityNamePattern = Pattern.compile(entityNames); - */ + /* Doesn't seem to be doing anything... String entityNames = ""; for(Object name : + * EntityList.classToStringMapping.values()){ if(name instanceof String){ entityNames = entityNames + name + + * '|'; } } // Cuts off the last '|' entityNames = entityNames.substring(0, entityNames.length()-1); + * entityNamePattern = Pattern.compile(entityNames); */ proxy.initialiseLayers(); } - + @EventHandler - public void serverStarting(FMLServerStartingEvent event){ - event.registerServerCommand(new CommandCastSpell()); - event.registerServerCommand(new CommandSetAlly()); - event.registerServerCommand(new CommandViewAllies()); - event.registerServerCommand(new CommandDiscoverSpell()); - } + public void serverStarting(FMLServerStartingEvent event){ + event.registerServerCommand(new CommandCastSpell()); + event.registerServerCommand(new CommandSetAlly()); + event.registerServerCommand(new CommandViewAllies()); + event.registerServerCommand(new CommandDiscoverSpell()); + } @SubscribeEvent public void onConfigChanged(net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent event){ @@ -206,58 +223,139 @@ public class Wizardry { // Just get, not getAll, since the mod id didn't change! for(FMLMissingMappingsEvent.MissingMapping mapping : event.get()){ if(mapping.type == Type.ITEM && mapping.resourceLocation.getResourceDomain().equals(Wizardry.MODID)){ - + Item replacement = null; - + switch(mapping.resourceLocation.getResourcePath()){ - - case "wand_basic": replacement = WizardryItems.magic_wand; break; - case "wand_basic_fire": replacement = WizardryItems.basic_fire_wand; break; - case "wand_basic_ice": replacement = WizardryItems.basic_ice_wand; break; - case "wand_basic_lightning": replacement = WizardryItems.basic_lightning_wand; break; - case "wand_basic_necromancy": replacement = WizardryItems.basic_necromancy_wand; break; - case "wand_basic_earth": replacement = WizardryItems.basic_earth_wand; break; - case "wand_basic_sorcery": replacement = WizardryItems.basic_sorcery_wand; break; - case "wand_basic_healing": replacement = WizardryItems.basic_healing_wand; break; - case "wand_apprentice": replacement = WizardryItems.apprentice_wand; break; - case "wand_apprentice_fire": replacement = WizardryItems.apprentice_fire_wand; break; - case "wand_apprentice_ice": replacement = WizardryItems.apprentice_ice_wand; break; - case "wand_apprentice_lightning": replacement = WizardryItems.apprentice_lightning_wand; break; - case "wand_apprentice_necromancy": replacement = WizardryItems.apprentice_necromancy_wand; break; - case "wand_apprentice_earth": replacement = WizardryItems.apprentice_earth_wand; break; - case "wand_apprentice_sorcery": replacement = WizardryItems.apprentice_sorcery_wand; break; - case "wand_apprentice_healing": replacement = WizardryItems.apprentice_healing_wand; break; - case "wand_advanced": replacement = WizardryItems.advanced_wand; break; - case "wand_advanced_fire": replacement = WizardryItems.advanced_fire_wand; break; - case "wand_advanced_ice": replacement = WizardryItems.advanced_ice_wand; break; - case "wand_advanced_lightning": replacement = WizardryItems.advanced_lightning_wand; break; - case "wand_advanced_necromancy": replacement = WizardryItems.advanced_necromancy_wand; break; - case "wand_advanced_earth": replacement = WizardryItems.advanced_earth_wand; break; - case "wand_advanced_sorcery": replacement = WizardryItems.advanced_sorcery_wand; break; - case "wand_advanced_healing": replacement = WizardryItems.advanced_healing_wand; break; - case "wand_master": replacement = WizardryItems.master_wand; break; - case "wand_master_fire": replacement = WizardryItems.master_fire_wand; break; - case "wand_master_ice": replacement = WizardryItems.master_ice_wand; break; - case "wand_master_lightning": replacement = WizardryItems.master_lightning_wand; break; - case "wand_master_necromancy": replacement = WizardryItems.master_necromancy_wand; break; - case "wand_master_earth": replacement = WizardryItems.master_earth_wand; break; - case "wand_master_sorcery": replacement = WizardryItems.master_sorcery_wand; break; - case "wand_master_healing": replacement = WizardryItems.master_healing_wand; break; - case "upgrade_storage": replacement = WizardryItems.storage_upgrade; break; - case "upgrade_siphon": replacement = WizardryItems.siphon_upgrade; break; - case "upgrade_condenser": replacement = WizardryItems.condenser_upgrade; break; - case "upgrade_range": replacement = WizardryItems.range_upgrade; break; - case "upgrade_duration": replacement = WizardryItems.duration_upgrade; break; - case "upgrade_cooldown": replacement = WizardryItems.cooldown_upgrade; break; - case "upgrade_blast": replacement = WizardryItems.blast_upgrade; break; - case "upgrade_attunement": replacement = WizardryItems.attunement_upgrade; break; + + case "wand_basic": + replacement = WizardryItems.magic_wand; + break; + case "wand_basic_fire": + replacement = WizardryItems.basic_fire_wand; + break; + case "wand_basic_ice": + replacement = WizardryItems.basic_ice_wand; + break; + case "wand_basic_lightning": + replacement = WizardryItems.basic_lightning_wand; + break; + case "wand_basic_necromancy": + replacement = WizardryItems.basic_necromancy_wand; + break; + case "wand_basic_earth": + replacement = WizardryItems.basic_earth_wand; + break; + case "wand_basic_sorcery": + replacement = WizardryItems.basic_sorcery_wand; + break; + case "wand_basic_healing": + replacement = WizardryItems.basic_healing_wand; + break; + case "wand_apprentice": + replacement = WizardryItems.apprentice_wand; + break; + case "wand_apprentice_fire": + replacement = WizardryItems.apprentice_fire_wand; + break; + case "wand_apprentice_ice": + replacement = WizardryItems.apprentice_ice_wand; + break; + case "wand_apprentice_lightning": + replacement = WizardryItems.apprentice_lightning_wand; + break; + case "wand_apprentice_necromancy": + replacement = WizardryItems.apprentice_necromancy_wand; + break; + case "wand_apprentice_earth": + replacement = WizardryItems.apprentice_earth_wand; + break; + case "wand_apprentice_sorcery": + replacement = WizardryItems.apprentice_sorcery_wand; + break; + case "wand_apprentice_healing": + replacement = WizardryItems.apprentice_healing_wand; + break; + case "wand_advanced": + replacement = WizardryItems.advanced_wand; + break; + case "wand_advanced_fire": + replacement = WizardryItems.advanced_fire_wand; + break; + case "wand_advanced_ice": + replacement = WizardryItems.advanced_ice_wand; + break; + case "wand_advanced_lightning": + replacement = WizardryItems.advanced_lightning_wand; + break; + case "wand_advanced_necromancy": + replacement = WizardryItems.advanced_necromancy_wand; + break; + case "wand_advanced_earth": + replacement = WizardryItems.advanced_earth_wand; + break; + case "wand_advanced_sorcery": + replacement = WizardryItems.advanced_sorcery_wand; + break; + case "wand_advanced_healing": + replacement = WizardryItems.advanced_healing_wand; + break; + case "wand_master": + replacement = WizardryItems.master_wand; + break; + case "wand_master_fire": + replacement = WizardryItems.master_fire_wand; + break; + case "wand_master_ice": + replacement = WizardryItems.master_ice_wand; + break; + case "wand_master_lightning": + replacement = WizardryItems.master_lightning_wand; + break; + case "wand_master_necromancy": + replacement = WizardryItems.master_necromancy_wand; + break; + case "wand_master_earth": + replacement = WizardryItems.master_earth_wand; + break; + case "wand_master_sorcery": + replacement = WizardryItems.master_sorcery_wand; + break; + case "wand_master_healing": + replacement = WizardryItems.master_healing_wand; + break; + case "upgrade_storage": + replacement = WizardryItems.storage_upgrade; + break; + case "upgrade_siphon": + replacement = WizardryItems.siphon_upgrade; + break; + case "upgrade_condenser": + replacement = WizardryItems.condenser_upgrade; + break; + case "upgrade_range": + replacement = WizardryItems.range_upgrade; + break; + case "upgrade_duration": + replacement = WizardryItems.duration_upgrade; + break; + case "upgrade_cooldown": + replacement = WizardryItems.cooldown_upgrade; + break; + case "upgrade_blast": + replacement = WizardryItems.blast_upgrade; + break; + case "upgrade_attunement": + replacement = WizardryItems.attunement_upgrade; + break; // If it didn't match any of the ones that changed, do nothing. - default: return; + default: + return; } // No need to log, Forge does that. mapping.remap(replacement); } } } - + } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/WizardryEventHandler.java b/src/main/java/electroblob/wizardry/WizardryEventHandler.java index a91acd2b..f535960e 100644 --- a/src/main/java/electroblob/wizardry/WizardryEventHandler.java +++ b/src/main/java/electroblob/wizardry/WizardryEventHandler.java @@ -78,6 +78,7 @@ import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; * As of Wizardry 2.1, most of the code in this class has been relocated somewhere sensible, leaving only a few * miscellaneous things that don't make much sense anywhere else, or that are better kept together. Previously, this was * a gigantic class with about half of the entire mod's logic in it! + * * @author Electroblob * @since Wizardry 1.0 */ @@ -85,16 +86,10 @@ import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; public final class WizardryEventHandler { // IDEA: Config option allowing users to specify loot locations - private static final String[] LOOT_INJECTION_LOCATIONS = { - "minecraft:chests/simple_dungeon", - "minecraft:chests/abandoned_mineshaft", - "minecraft:chests/desert_pyramid", - "minecraft:chests/jungle_temple", - "minecraft:chests/stronghold_corridor", - "minecraft:chests/stronghold_crossing", - "minecraft:chests/stronghold_library", - "minecraft:chests/igloo_chest" - }; + private static final String[] LOOT_INJECTION_LOCATIONS = {"minecraft:chests/simple_dungeon", + "minecraft:chests/abandoned_mineshaft", "minecraft:chests/desert_pyramid", "minecraft:chests/jungle_temple", + "minecraft:chests/stronghold_corridor", "minecraft:chests/stronghold_crossing", + "minecraft:chests/stronghold_library", "minecraft:chests/igloo_chest"}; @SubscribeEvent public static void onLootTableLoadEvent(LootTableLoadEvent event){ @@ -108,61 +103,65 @@ public final class WizardryEventHandler { } private static LootPool getAdditive(String entryName){ - return new LootPool(new LootEntry[] { getAdditiveEntry(entryName, 1) }, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), Wizardry.MODID + "_additive_pool"); + return new LootPool(new LootEntry[]{getAdditiveEntry(entryName, 1)}, new LootCondition[0], + new RandomValueRange(1), new RandomValueRange(0, 1), Wizardry.MODID + "_additive_pool"); } private static LootEntryTable getAdditiveEntry(String name, int weight){ - return new LootEntryTable(new ResourceLocation(name), weight, 0, new LootCondition[0], Wizardry.MODID + "_additive_entry"); + return new LootEntryTable(new ResourceLocation(name), weight, 0, new LootCondition[0], + Wizardry.MODID + "_additive_entry"); } @SubscribeEvent public static void onPlayerLoggedInEvent(PlayerLoggedInEvent event){ // When a player logs in, they are sent the glyph data and the server's settings. if(event.player instanceof EntityPlayerMP){ - SpellGlyphData.get(event.player.worldObj).sync((EntityPlayerMP)event.player); + SpellGlyphData.get(event.player.world).sync((EntityPlayerMP)event.player); Wizardry.settings.sync((EntityPlayerMP)event.player); } } - + @SubscribeEvent public static void onSpellCastPreEvent(SpellCastEvent.Pre event){ // If a spell is disabled in the config, it will not work. if(!event.getSpell().isEnabled()){ - if(!event.getEntityLiving().worldObj.isRemote) - event.getEntity().addChatMessage(new TextComponentTranslation("spell.disabled", event.getSpell().getNameForTranslationFormatted())); + if(!event.getEntityLiving().world.isRemote) event.getEntity().sendMessage( + new TextComponentTranslation("spell.disabled", event.getSpell().getNameForTranslationFormatted())); event.setCanceled(true); } } - + @SubscribeEvent public static void onSpellCastPostEvent(SpellCastEvent.Post event){ // Spell discovery (only players can discover spells, obviously) if(event.getEntity() instanceof EntityPlayer){ - + EntityPlayer player = (EntityPlayer)event.getEntity(); WizardData data = WizardData.get(player); - + if(data != null){ // Data is updated on both sides (This line was added client-side to fix a bug back in 1.1.3, so now // it's in common code, which is nice!) // Short-circuiting AND means that discoverSpell is only called if the event isn't cancelled. - if(!MinecraftForge.EVENT_BUS.post(new DiscoverSpellEvent(player, event.getSpell(), - DiscoverSpellEvent.Source.CASTING)) && data.discoverSpell(event.getSpell())){ - + if(!MinecraftForge.EVENT_BUS + .post(new DiscoverSpellEvent(player, event.getSpell(), DiscoverSpellEvent.Source.CASTING)) + && data.discoverSpell(event.getSpell())){ + // If the spell wasn't already discovered, other stuff happens: if(event.getSource() == SpellCastEvent.Source.COMMAND){ - // If the spell didn't send a packet itself, the extended player needs to be synced so the - // spell discovery updates on the client. - if(!event.getSpell().doesSpellRequirePacket()) data.sync(); - - }else if(!event.getEntity().worldObj.isRemote && !player.capabilities.isCreativeMode + // If the spell didn't send a packet itself, the extended player needs to be synced so the + // spell discovery updates on the client. + if(!event.getSpell().doesSpellRequirePacket()) data.sync(); + + }else if(!event.getEntity().world.isRemote && !player.capabilities.isCreativeMode && Wizardry.settings.discoveryMode){ // Sound and text only happen server-side, in survival, with discovery mode on, and only when // the spell wasn't cast using commands. WizardryUtilities.playSoundAtPlayer(player, SoundEvents.ENTITY_PLAYER_LEVELUP, 1.25f, 1); - player.addChatMessage(new TextComponentTranslation("spell.discover", event.getSpell().getNameForTranslationFormatted())); + player.sendMessage(new TextComponentTranslation("spell.discover", + event.getSpell().getNameForTranslationFormatted())); } } } @@ -172,32 +171,24 @@ public final class WizardryEventHandler { /* There is a subtle but important difference between LivingAttackEvent and LivingHurtEvent - LivingAttackEvent * fires immediately when attackEntityFrom is called, whereas LivingHurtEvent only fires if the attack actually * succeeded, i.e. if the entity in question takes damage (though the event is fired before that so you can cancel - * the damage). Things are processed in the following order: - * * LivingAttackEvent * - * - Invulnerability - * - Already-dead-ness - * - Fire resistance - * - Helmets vs. falling things - * - Hurt resistant time - * - Invulnerability (again) - * * LivingHurtEvent * - * - Armour - * - Potions - * - Health is finally changed - * Of course, there are no guarantees that other mods hooking into these two events will be called before or after - * yours, but you can have some degree of control by choosing which event to use. - * EDIT: Actually, there are. Firstly, you can set a priority in the @SubscribeEvent annotation which defines how - * early (higher priority) or late (lower priority) the method is called. Methods with the same priority are sorted - * alphabetically by mod id (so it's safe to assume wizardry would be fairly late on!). I wonder if there are any - * conventions for what sort of things take what priority...? */ + * the damage). Things are processed in the following order: * LivingAttackEvent * - Invulnerability - + * Already-dead-ness - Fire resistance - Helmets vs. falling things - Hurt resistant time - Invulnerability (again) + * * LivingHurtEvent * - Armour - Potions - Health is finally changed Of course, there are no guarantees that other + * mods hooking into these two events will be called before or after yours, but you can have some degree of control + * by choosing which event to use. EDIT: Actually, there are. Firstly, you can set a priority in the @SubscribeEvent + * annotation which defines how early (higher priority) or late (lower priority) the method is called. Methods with + * the same priority are sorted alphabetically by mod id (so it's safe to assume wizardry would be fairly late on!). + * I wonder if there are any conventions for what sort of things take what priority...? */ @SubscribeEvent public static void onLivingAttackEvent(LivingAttackEvent event){ // Prevents any damage to allies from magic if friendly fire is enabled - if(!Wizardry.settings.friendlyFire && event.getSource() != null && event.getSource().getEntity() instanceof EntityPlayer - && event.getEntity() instanceof EntityPlayer && event.getSource() instanceof IElementalDamage){ - if(WizardryUtilities.isPlayerAlly((EntityPlayer)event.getSource().getEntity(), (EntityPlayer)event.getEntity())){ + if(!Wizardry.settings.friendlyFire && event.getSource() != null + && event.getSource().getEntity() instanceof EntityPlayer && event.getEntity() instanceof EntityPlayer + && event.getSource() instanceof IElementalDamage){ + if(WizardryUtilities.isPlayerAlly((EntityPlayer)event.getSource().getEntity(), + (EntityPlayer)event.getEntity())){ event.setCanceled(true); // This needs to be here, since if the event is cancelled nothing else needs to happen. return; @@ -208,11 +199,11 @@ public final class WizardryEventHandler { // These are better off here because the revenge effects are pretty similar, and I'd rather keep the (lengthy) // if statement in one place. if(event.getSource() != null && event.getSource().getEntity() instanceof EntityLivingBase - && !event.getSource().isProjectile() && !(event.getSource() instanceof IElementalDamage && - ((IElementalDamage)event.getSource()).isRetaliatory())){ + && !event.getSource().isProjectile() && !(event.getSource() instanceof IElementalDamage + && ((IElementalDamage)event.getSource()).isRetaliatory())){ EntityLivingBase attacker = (EntityLivingBase)event.getSource().getEntity(); - World world = event.getEntityLiving().worldObj; + World world = event.getEntityLiving().world; // Fireskin if(event.getEntityLiving().isPotionActive(WizardryPotions.fireskin) @@ -220,8 +211,8 @@ public final class WizardryEventHandler { attacker.setFire(5); // Ice Shroud - if(event.getEntityLiving().isPotionActive(WizardryPotions.ice_shroud) && - !MagicDamage.isEntityImmune(DamageType.FROST, event.getEntityLiving())) + if(event.getEntityLiving().isPotionActive(WizardryPotions.ice_shroud) + && !MagicDamage.isEntityImmune(DamageType.FROST, event.getEntityLiving())) attacker.addPotionEffect(new PotionEffect(WizardryPotions.frost, 100, 0)); // Static Aura @@ -229,17 +220,25 @@ public final class WizardryEventHandler { if(!world.isRemote){ EntityArc arc = new EntityArc(world); - arc.setEndpointCoords(event.getEntityLiving().posX, event.getEntityLiving().posY + 1, event.getEntityLiving().posZ, - attacker.posX, attacker.posY + attacker.height/2, attacker.posZ); - world.spawnEntityInWorld(arc); + arc.setEndpointCoords(event.getEntityLiving().posX, event.getEntityLiving().posY + 1, + event.getEntityLiving().posZ, attacker.posX, attacker.posY + attacker.height / 2, + attacker.posZ); + world.spawnEntity(arc); }else{ - for(int i=0;i<8;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, attacker.posX + world.rand.nextFloat() - 0.5, attacker.getEntityBoundingBox().minY + attacker.height/2 + world.rand.nextFloat()*2 - 1, attacker.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); - world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, attacker.posX + world.rand.nextFloat() - 0.5, attacker.getEntityBoundingBox().minY + attacker.height/2 + world.rand.nextFloat()*2 - 1, attacker.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0); + for(int i = 0; i < 8; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + attacker.posX + world.rand.nextFloat() - 0.5, attacker.getEntityBoundingBox().minY + + attacker.height / 2 + world.rand.nextFloat() * 2 - 1, + attacker.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); + world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, attacker.posX + world.rand.nextFloat() - 0.5, + attacker.getEntityBoundingBox().minY + attacker.height / 2 + world.rand.nextFloat() * 2 + - 1, + attacker.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0); } } - attacker.attackEntityFrom(MagicDamage.causeDirectMagicDamage(event.getEntityLiving(), DamageType.SHOCK, true), 4.0f); + attacker.attackEntityFrom( + MagicDamage.causeDirectMagicDamage(event.getEntityLiving(), DamageType.SHOCK, true), 4.0f); attacker.playSound(WizardrySounds.SPELL_SPARK, 1.0F, world.rand.nextFloat() * 0.4F + 1.5F); } } @@ -257,25 +256,29 @@ public final class WizardryEventHandler { // Players can only ever attack with their main hand, so this is the right method to use here. if(attacker.getHeldItemMainhand() != null && attacker.getHeldItemMainhand().getItem() instanceof ItemSword){ - int level = EnchantmentHelper.getEnchantmentLevel(WizardryEnchantments.flaming_weapon, attacker.getHeldItemMainhand()); + int level = EnchantmentHelper.getEnchantmentLevel(WizardryEnchantments.flaming_weapon, + attacker.getHeldItemMainhand()); if(level > 0 && !MagicDamage.isEntityImmune(DamageType.FIRE, event.getEntityLiving())) - event.getEntityLiving().setFire(level*4); + event.getEntityLiving().setFire(level * 4); - level = EnchantmentHelper.getEnchantmentLevel(WizardryEnchantments.freezing_weapon, attacker.getHeldItemMainhand()); + level = EnchantmentHelper.getEnchantmentLevel(WizardryEnchantments.freezing_weapon, + attacker.getHeldItemMainhand()); // Frost lasts for longer because it doesn't do any actual damage if(level > 0 && !MagicDamage.isEntityImmune(DamageType.FROST, event.getEntityLiving())) - event.getEntityLiving().addPotionEffect(new PotionEffect(WizardryPotions.frost, level*200, 0)); + event.getEntityLiving().addPotionEffect(new PotionEffect(WizardryPotions.frost, level * 200, 0)); } } // Freezing bow - if(event.getSource().getSourceOfDamage() instanceof EntityArrow && event.getSource().getSourceOfDamage().getEntityData() != null){ + if(event.getSource().getSourceOfDamage() instanceof EntityArrow + && event.getSource().getSourceOfDamage().getEntityData() != null){ - int level = event.getSource().getSourceOfDamage().getEntityData().getInteger(FreezingWeapon.FREEZING_ARROW_NBT_KEY); + int level = event.getSource().getSourceOfDamage().getEntityData() + .getInteger(FreezingWeapon.FREEZING_ARROW_NBT_KEY); if(level > 0 && !MagicDamage.isEntityImmune(DamageType.FROST, event.getEntityLiving())) - event.getEntityLiving().addPotionEffect(new PotionEffect(WizardryPotions.frost, level*150, 0)); + event.getEntityLiving().addPotionEffect(new PotionEffect(WizardryPotions.frost, level * 150, 0)); } // Damage scaling @@ -296,31 +299,28 @@ public final class WizardryEventHandler { EntityPlayer player = (EntityPlayer)event.getEntityLiving(); - if(player.worldObj.isRemote) hackilyFixContinuousSpellCasting(player); + if(player.world.isRemote) hackilyFixContinuousSpellCasting(player); + // Mana flask crafting if(player.openContainer instanceof ContainerWorkbench){ - craftingTableTick(player); - } - - if(player.openContainer instanceof ContainerPlayer){ + + IInventory craftMatrix = ((ContainerWorkbench)player.openContainer).craftMatrix; + ItemStack output = ((ContainerWorkbench)player.openContainer).craftResult.getStackInSlot(0); + processManaFlaskCrafting(craftMatrix, output); + + }else if(player.openContainer instanceof ContainerPlayer){ + + IInventory craftMatrix = ((ContainerPlayer)player.openContainer).craftMatrix; + ItemStack output = ((ContainerPlayer)player.openContainer).craftResult.getStackInSlot(0); // Unfortunately I have no choice but to call this method every tick when the player isn't using another // inventory, since the only thing tracking whether the player is looking at their inventory is the GUI // itself, which is client-side only. - playerInventoryTick(player); - } - - testForArmourSet:{ - for(ItemStack stack : player.getArmorInventoryList()){ - if(stack == null || !(stack.getItem() instanceof ItemWizardArmour)){ - break testForArmourSet; - } - } - player.addStat(WizardryAchievements.armour_set); + processManaFlaskCrafting(craftMatrix, output); } } - if(event.getEntityLiving().worldObj.isRemote){ + if(event.getEntityLiving().world.isRemote){ // Client-side continuous spell casting for NPCs @@ -330,11 +330,11 @@ public final class WizardryEventHandler { SpellModifiers modifiers = ((ISpellCaster)event.getEntity()).getModifiers(); if(spell != null && spell != Spells.none){ - + if(!MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Tick(event.getEntityLiving(), spell, modifiers, SpellCastEvent.Source.NPC, 0))){ - - spell.cast(event.getEntity().worldObj, (EntityLiving)event.getEntity(), EnumHand.MAIN_HAND, 0, + + spell.cast(event.getEntity().world, (EntityLiving)event.getEntity(), EnumHand.MAIN_HAND, 0, // TODO: This implementation of modifiers relies on them being accessible client-side. ((EntityLiving)event.getEntity()).getAttackTarget(), modifiers); } @@ -352,8 +352,12 @@ public final class WizardryEventHandler { for(ItemStack stack : WizardryUtilities.getPrioritisedHotbarAndOffhand(player)){ - if(stack != null && stack.getItem() instanceof ItemWand && stack.isItemDamaged() && WandHelper.getUpgradeLevel(stack, WizardryItems.siphon_upgrade) > 0){ - int damage = stack.getItemDamage() - Constants.SIPHON_MANA_PER_LEVEL*WandHelper.getUpgradeLevel(stack, WizardryItems.siphon_upgrade) - player.worldObj.rand.nextInt(Constants.SIPHON_MANA_PER_LEVEL); + if(stack.getItem() instanceof ItemWand && stack.isItemDamaged() + && WandHelper.getUpgradeLevel(stack, WizardryItems.siphon_upgrade) > 0){ + int damage = stack.getItemDamage() + - Constants.SIPHON_MANA_PER_LEVEL + * WandHelper.getUpgradeLevel(stack, WizardryItems.siphon_upgrade) + - player.world.rand.nextInt(Constants.SIPHON_MANA_PER_LEVEL); if(damage < 0) damage = 0; stack.setItemDamage(damage); break; @@ -373,17 +377,19 @@ public final class WizardryEventHandler { // Evil wizards drop spell books themselves if(event.getEntityLiving() instanceof IMob && !(event.getEntityLiving() instanceof EntityEvilWizard) // TODO: Backport when you backport the new summoned creature system. - && !(event.getEntityLiving() instanceof ISummonedCreature) && event.getSource().getEntity() instanceof EntityPlayer - && Wizardry.settings.spellBookDropChance > 0){ + && !(event.getEntityLiving() instanceof ISummonedCreature) + && event.getSource().getEntity() instanceof EntityPlayer && Wizardry.settings.spellBookDropChance > 0){ // This does exactly what the entity drop method does, but with a different random number so that the // spell book doesn't always drop with other rare drops. - int rareDropNumber = event.getEntity().worldObj.rand.nextInt(200) - event.getLootingLevel(); + int rareDropNumber = event.getEntity().world.rand.nextInt(200) - event.getLootingLevel(); if(rareDropNumber < Wizardry.settings.spellBookDropChance){ // Drops a spell book - int id = WizardryUtilities.getStandardWeightedRandomSpellId(event.getEntity().worldObj.rand); + int id = WizardryUtilities.getStandardWeightedRandomSpellId(event.getEntity().world.rand); - event.getDrops().add(new EntityItem(event.getEntityLiving().worldObj, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, + event.getDrops() + .add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX, + event.getEntityLiving().posY, event.getEntityLiving().posZ, new ItemStack(WizardryItems.spell_book, 1, id))); } } @@ -395,13 +401,14 @@ public final class WizardryEventHandler { event.getEntityPlayer().addStat(WizardryAchievements.crystal, 1); } } - + // Private helper methods // ================================================================================================================ /** * Detects inconsistencies between player.getActiveItemStack and the actual itemstack and forces them to be equal. * Fixes issue #25. + * * @param player */ private static void hackilyFixContinuousSpellCasting(EntityPlayer player){ @@ -414,97 +421,47 @@ public final class WizardryEventHandler { } } - private static void playerInventoryTick(EntityPlayer player){ + private static void processManaFlaskCrafting(IInventory craftMatrix, ItemStack output){ // Charges wand using mana flask. It is here rather than in the crafting handler so the result displays // the proper damage before it is actually crafted. boolean flag = false; - ItemStack wand = null; - ItemStack armour = null; - IInventory craftMatrix = ((ContainerPlayer)player.openContainer).craftMatrix; - ItemStack outputItem = ((ContainerPlayer)player.openContainer).craftResult.getStackInSlot(0); + ItemStack wand = ItemStack.EMPTY; + ItemStack armour = ItemStack.EMPTY; for(int i = 0; i < craftMatrix.getSizeInventory(); i++){ - if(craftMatrix.getStackInSlot(i) != null){ - ItemStack itemstack = craftMatrix.getStackInSlot(i); + + ItemStack itemstack = craftMatrix.getStackInSlot(i); - if(itemstack.getItem() == WizardryItems.mana_flask){ - flag = true; - } + if(itemstack.getItem() == WizardryItems.mana_flask){ + flag = true; + } - if(itemstack.getItem() instanceof ItemWand){ - wand = itemstack; - } + if(itemstack.getItem() instanceof ItemWand){ + wand = itemstack; + } - if(itemstack.getItem() instanceof ItemWizardArmour){ - armour = itemstack; - } + if(itemstack.getItem() instanceof ItemWizardArmour){ + armour = itemstack; } } - if(outputItem != null && outputItem.getItem() instanceof ItemWand && flag && wand != null){ - outputItem.setTagCompound((wand.getTagCompound())); - if(wand.getItemDamage()-Constants.MANA_PER_FLASK < 0){ - outputItem.setItemDamage(0); + if(output.getItem() instanceof ItemWand && flag && !wand.isEmpty()){ + output.setTagCompound((wand.getTagCompound())); + if(wand.getItemDamage() - Constants.MANA_PER_FLASK < 0){ + output.setItemDamage(0); }else{ - outputItem.setItemDamage(wand.getItemDamage()-Constants.MANA_PER_FLASK); + output.setItemDamage(wand.getItemDamage() - Constants.MANA_PER_FLASK); } } - if(outputItem != null && outputItem.getItem() instanceof ItemWizardArmour && flag && armour != null){ - outputItem.setTagCompound((armour.getTagCompound())); - if(armour.getItemDamage()-Constants.MANA_PER_FLASK < 0){ - outputItem.setItemDamage(0); + if(output.getItem() instanceof ItemWizardArmour && flag && !armour.isEmpty()){ + output.setTagCompound((armour.getTagCompound())); + if(armour.getItemDamage() - Constants.MANA_PER_FLASK < 0){ + output.setItemDamage(0); }else{ - outputItem.setItemDamage(wand.getItemDamage()-Constants.MANA_PER_FLASK); - } - } - } - - private static void craftingTableTick(EntityPlayer player) { - - // Charges wand using mana flask - - boolean flag = false; - ItemStack wand = null; - ItemStack armour = null; - IInventory craftMatrix = ((ContainerWorkbench)player.openContainer).craftMatrix; - ItemStack outputItem = ((ContainerWorkbench)player.openContainer).craftResult.getStackInSlot(0); - - for (int i = 0; i < craftMatrix.getSizeInventory(); i++){ - if(craftMatrix.getStackInSlot(i) != null){ - ItemStack itemstack = craftMatrix.getStackInSlot(i); - - if(itemstack.getItem() == WizardryItems.mana_flask){ - flag = true; - } - - if(itemstack.getItem() instanceof ItemWand){ - wand = itemstack; - } - - if(itemstack.getItem() instanceof ItemWizardArmour){ - armour = itemstack; - } - } - } - - if(outputItem != null && outputItem.getItem() instanceof ItemWand && flag && wand != null){ - outputItem.setTagCompound((wand.getTagCompound())); - if(wand.getItemDamage()-Constants.MANA_PER_FLASK < 0){ - outputItem.setItemDamage(0); - }else{ - outputItem.setItemDamage(wand.getItemDamage()-Constants.MANA_PER_FLASK); - } - } - - if(outputItem != null && outputItem.getItem() instanceof ItemWizardArmour && flag && armour != null){ - outputItem.setTagCompound((armour.getTagCompound())); - if(armour.getItemDamage()-Constants.MANA_PER_FLASK < 0){ - outputItem.setItemDamage(0); - }else{ - outputItem.setItemDamage(wand.getItemDamage()-Constants.MANA_PER_FLASK); + output.setItemDamage(wand.getItemDamage() - Constants.MANA_PER_FLASK); } } } diff --git a/src/main/java/electroblob/wizardry/WizardryGuiFactory.java b/src/main/java/electroblob/wizardry/WizardryGuiFactory.java index 0f7c0161..6920e745 100644 --- a/src/main/java/electroblob/wizardry/WizardryGuiFactory.java +++ b/src/main/java/electroblob/wizardry/WizardryGuiFactory.java @@ -8,29 +8,34 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.fml.client.IModGuiFactory; public class WizardryGuiFactory implements IModGuiFactory { - - @Override - public void initialize(Minecraft minecraftInstance) - { - - } - - @Override - public Class mainConfigGuiClass() - { - return GuiConfigWizardry.class; - } - - @Override - public Set runtimeGuiCategories() - { - return null; - } - - @SuppressWarnings("deprecation") // It's a bit of Forge that hasn't been tidied up, but we have to implement it. + @Override - public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) - { - return null; - } + public void initialize(Minecraft minecraftInstance){ + } + + @Override + public Class mainConfigGuiClass(){ + return GuiConfigWizardry.class; + } + + @Override + public Set runtimeGuiCategories(){ + return null; + } + + @SuppressWarnings("deprecation") // It's a bit of Forge that hasn't been tidied up, but we have to implement it. + @Override + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element){ + return null; + } + + @Override + public boolean hasConfigGui(){ + return true; + } + + @Override + public GuiScreen createConfigGui(GuiScreen parentScreen){ + return new GuiConfigWizardry(parentScreen); + } } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/WizardryGuiHandler.java b/src/main/java/electroblob/wizardry/WizardryGuiHandler.java index ad17f45d..321c9df8 100644 --- a/src/main/java/electroblob/wizardry/WizardryGuiHandler.java +++ b/src/main/java/electroblob/wizardry/WizardryGuiHandler.java @@ -16,49 +16,48 @@ public class WizardryGuiHandler implements IGuiHandler { /** Incrementable index for the gui ID */ private static int nextGuiId = 0; - + public static final int SPELL_BOOK = nextGuiId++; public static final int ARCANE_WORKBENCH = nextGuiId++; public static final int WIZARD_HANDBOOK = nextGuiId++; public static final int PORTABLE_CRAFTING = nextGuiId++; @Override - public Object getServerGuiElement(int id, EntityPlayer player, World world, - int x, int y, int z) { + public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z){ if(id == ARCANE_WORKBENCH){ TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z)); if(tileEntity instanceof TileEntityArcaneWorkbench){ - return new ContainerArcaneWorkbench(player.inventory, (TileEntityArcaneWorkbench) tileEntity); + return new ContainerArcaneWorkbench(player.inventory, (TileEntityArcaneWorkbench)tileEntity); } - } - else if(id == PORTABLE_CRAFTING){ + }else if(id == PORTABLE_CRAFTING){ return new ContainerPortableWorkbench(player.inventory, world, new BlockPos(x, y, z)); } return null; } @Override - public Object getClientGuiElement(int id, EntityPlayer player, World world, - int x, int y, int z) { + public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z){ if(id == ARCANE_WORKBENCH){ TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z)); if(tileEntity instanceof TileEntityArcaneWorkbench){ - return new electroblob.wizardry.client.GuiArcaneWorkbench(player.inventory, (TileEntityArcaneWorkbench) tileEntity); + return new electroblob.wizardry.client.GuiArcaneWorkbench(player.inventory, + (TileEntityArcaneWorkbench)tileEntity); } - } - else if(id == WIZARD_HANDBOOK - && ((player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() instanceof ItemWizardHandbook) - || (player.getHeldItemOffhand() != null && player.getHeldItemOffhand().getItem() instanceof ItemWizardHandbook))){ + }else if(id == WIZARD_HANDBOOK && ((player.getHeldItemMainhand() != null + && player.getHeldItemMainhand().getItem() instanceof ItemWizardHandbook) + || (player.getHeldItemOffhand() != null + && player.getHeldItemOffhand().getItem() instanceof ItemWizardHandbook))){ return new electroblob.wizardry.client.GuiWizardHandbook(); - } - else if(id == SPELL_BOOK){ + }else if(id == SPELL_BOOK){ if(player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() instanceof ItemSpellBook){ - return new electroblob.wizardry.client.GuiSpellBook(Spell.get(player.getHeldItemMainhand().getItemDamage())); - }else if(player.getHeldItemOffhand() != null && player.getHeldItemOffhand().getItem() instanceof ItemSpellBook){ - return new electroblob.wizardry.client.GuiSpellBook(Spell.get(player.getHeldItemOffhand().getItemDamage())); + return new electroblob.wizardry.client.GuiSpellBook( + Spell.get(player.getHeldItemMainhand().getItemDamage())); + }else if(player.getHeldItemOffhand() != null + && player.getHeldItemOffhand().getItem() instanceof ItemSpellBook){ + return new electroblob.wizardry.client.GuiSpellBook( + Spell.get(player.getHeldItemOffhand().getItemDamage())); } - } - else if(id == PORTABLE_CRAFTING){ + }else if(id == PORTABLE_CRAFTING){ return new electroblob.wizardry.client.GuiPortableCrafting(player.inventory, world, new BlockPos(x, y, z)); } return null; diff --git a/src/main/java/electroblob/wizardry/WizardryKeyHandler.java b/src/main/java/electroblob/wizardry/WizardryKeyHandler.java index 9cfc7ab9..99852c4c 100644 --- a/src/main/java/electroblob/wizardry/WizardryKeyHandler.java +++ b/src/main/java/electroblob/wizardry/WizardryKeyHandler.java @@ -12,47 +12,48 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; public class WizardryKeyHandler { - boolean NkeyPressed = false; - boolean BkeyPressed = false; - boolean NkeyAlreadyPressed = false; - boolean BkeyAlreadyPressed = false; - - @SubscribeEvent - public void onKeyInput(InputEvent.KeyInputEvent event) { - + boolean NkeyPressed = false; + boolean BkeyPressed = false; + boolean NkeyAlreadyPressed = false; + boolean BkeyAlreadyPressed = false; + + @SubscribeEvent + public void onKeyInput(InputEvent.KeyInputEvent event){ + // Key pressed if(Keyboard.getEventKeyState()){ - + if(Wizardry.proxy instanceof ClientProxy){ - + if(ClientProxy.NEXT_SPELL.isPressed() && Minecraft.getMinecraft().inGameHasFocus){ - if(!NkeyPressed){ - NkeyPressed = true; - }else{ - NkeyAlreadyPressed = true; - } - if(!NkeyAlreadyPressed){ - // Packet building - IMessage msg = new PacketControlInput.Message(PacketControlInput.ControlType.NEXT_SPELL_KEY); - WizardryPacketHandler.net.sendToServer(msg); - } - } - - if(ClientProxy.PREVIOUS_SPELL.isPressed() && Minecraft.getMinecraft().inGameHasFocus){ - if(!BkeyPressed){ - BkeyPressed = true; - }else{ - BkeyAlreadyPressed = true; - } - if(!BkeyAlreadyPressed){ - // Packet building - IMessage msg = new PacketControlInput.Message(PacketControlInput.ControlType.PREVIOUS_SPELL_KEY); - WizardryPacketHandler.net.sendToServer(msg); - } - } + if(!NkeyPressed){ + NkeyPressed = true; + }else{ + NkeyAlreadyPressed = true; + } + if(!NkeyAlreadyPressed){ + // Packet building + IMessage msg = new PacketControlInput.Message(PacketControlInput.ControlType.NEXT_SPELL_KEY); + WizardryPacketHandler.net.sendToServer(msg); + } + } + + if(ClientProxy.PREVIOUS_SPELL.isPressed() && Minecraft.getMinecraft().inGameHasFocus){ + if(!BkeyPressed){ + BkeyPressed = true; + }else{ + BkeyAlreadyPressed = true; + } + if(!BkeyAlreadyPressed){ + // Packet building + IMessage msg = new PacketControlInput.Message( + PacketControlInput.ControlType.PREVIOUS_SPELL_KEY); + WizardryPacketHandler.net.sendToServer(msg); + } + } } } - + // Key released else{ if(NkeyPressed){ diff --git a/src/main/java/electroblob/wizardry/WizardryWorldGenerator.java b/src/main/java/electroblob/wizardry/WizardryWorldGenerator.java index 74fdab00..29d29ce9 100644 --- a/src/main/java/electroblob/wizardry/WizardryWorldGenerator.java +++ b/src/main/java/electroblob/wizardry/WizardryWorldGenerator.java @@ -16,8 +16,8 @@ import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockLiquid; import net.minecraft.block.BlockPlanks; import net.minecraft.block.BlockSlab; -import net.minecraft.block.BlockTorch; import net.minecraft.block.BlockSlab.EnumBlockHalf; +import net.minecraft.block.BlockTorch; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Biomes; import net.minecraft.init.Blocks; @@ -40,30 +40,35 @@ import net.minecraftforge.common.IPlantable; import net.minecraftforge.fml.common.IWorldGenerator; public class WizardryWorldGenerator implements IWorldGenerator { - + /** The string identifier for wizard tower chests, used in ChestGenHooks. */ public static final String WIZARD_TOWER = Wizardry.MODID + "wizardTower"; @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider){ + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, + IChunkProvider chunkProvider){ for(int id : Wizardry.settings.oreDimensions){ - if(id == world.provider.getDimension()) this.addOreSpawn(WizardryBlocks.crystal_ore.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 16, 16, 5, 7, 5, 30); + if(id == world.provider.getDimension()) this.addOreSpawn(WizardryBlocks.crystal_ore.getDefaultState(), + world, random, chunkX * 16, chunkZ * 16, 16, 16, 5, 7, 5, 30); } for(int id : Wizardry.settings.flowerDimensions){ - if(id == world.provider.getDimension()) this.generatePlant(WizardryBlocks.crystal_flower.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 2, 20); + if(id == world.provider.getDimension()) this.generatePlant(WizardryBlocks.crystal_flower.getDefaultState(), + world, random, chunkX * 16, chunkZ * 16, 2, 20); } if(world.getWorldInfo().isMapFeaturesEnabled()){ for(int id : Wizardry.settings.towerDimensions){ - if(id == world.provider.getDimension()) this.generateWizardTower(world, random, chunkX * 16, chunkZ * 16); + if(id == world.provider.getDimension()) + this.generateWizardTower(world, random, chunkX * 16, chunkZ * 16); } } } /** - * Adds an Ore Spawn to Minecraft. Simply register all Ores to spawn with this method in your Generation method in your IWorldGeneration extending Class + * Adds an Ore Spawn to Minecraft. Simply register all Ores to spawn with this method in your Generation method in + * your IWorldGeneration extending Class * * @param The Block to spawn * @param The World to spawn in @@ -77,18 +82,17 @@ public class WizardryWorldGenerator implements IWorldGenerator { * @param An int for the minimum Y-Coordinate height at which this block may spawn * @param An int for the maximum Y-Coordinate height at which this block may spawn **/ - public void addOreSpawn(IBlockState state, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY) - { - //int maxPossY = minY + (maxY - 1); - assert maxY > minY: "The maximum Y must be greater than the Minimum Y"; - assert maxX > 0 && maxX <= 16: "addOreSpawn: The Maximum X must be greater than 0 and less than 16"; - assert minY > 0: "addOreSpawn: The Minimum Y must be greater than 0"; - assert maxY < 256 && maxY > 0: "addOreSpawn: The Maximum Y must be less than 256 but greater than 0"; - assert maxZ > 0 && maxZ <= 16: "addOreSpawn: The Maximum Z must be greater than 0 and less than 16"; + public void addOreSpawn(IBlockState state, World world, Random random, int blockXPos, int blockZPos, int maxX, + int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY){ + // int maxPossY = minY + (maxY - 1); + assert maxY > minY : "The maximum Y must be greater than the Minimum Y"; + assert maxX > 0 && maxX <= 16 : "addOreSpawn: The Maximum X must be greater than 0 and less than 16"; + assert minY > 0 : "addOreSpawn: The Minimum Y must be greater than 0"; + assert maxY < 256 && maxY > 0 : "addOreSpawn: The Maximum Y must be less than 256 but greater than 0"; + assert maxZ > 0 && maxZ <= 16 : "addOreSpawn: The Maximum Z must be greater than 0 and less than 16"; int diffBtwnMinMaxY = maxY - minY; - for(int x = 0; x < chancesToSpawn; x++) - { + for(int x = 0; x < chancesToSpawn; x++){ int posX = blockXPos + random.nextInt(maxX); int posY = minY + random.nextInt(diffBtwnMinMaxY); int posZ = blockZPos + random.nextInt(maxZ); @@ -98,6 +102,7 @@ public class WizardryWorldGenerator implements IWorldGenerator { /** * Generates the specified plant randomly throughout the world. + * * @param block The plant block * @param world The world * @param random A random instance @@ -106,22 +111,23 @@ public class WizardryWorldGenerator implements IWorldGenerator { * @param chancesToSpawn Number of chances to spawn a flower patch * @param groupSize The number of times to try generating a flower per flower patch spawn */ - public void generatePlant(IBlockState state, World world, Random random, int x, int z, int chancesToSpawn, int groupSize){ - + public void generatePlant(IBlockState state, World world, Random random, int x, int z, int chancesToSpawn, + int groupSize){ + for(int i = 0; i < chancesToSpawn; i++){ int randPosX = x + random.nextInt(16); int randPosY = random.nextInt(256); int randPosZ = z + random.nextInt(16); - for (int l = 0; l < groupSize; ++l) - { + for(int l = 0; l < groupSize; ++l){ int i1 = randPosX + random.nextInt(8) - random.nextInt(8); int j1 = randPosY + random.nextInt(4) - random.nextInt(4); int k1 = randPosZ + random.nextInt(8) - random.nextInt(8); - + BlockPos pos = new BlockPos(i1, j1, k1); - if(world.isBlockLoaded(pos) && world.isAirBlock(pos) && (!world.provider.getHasNoSky() || j1 < 127) && state.getBlock().canPlaceBlockOnSide(world, pos, EnumFacing.UP)){ - + if(world.isBlockLoaded(pos) && world.isAirBlock(pos) && (!world.provider.hasNoSky() || j1 < 127) + && state.getBlock().canPlaceBlockOnSide(world, pos, EnumFacing.UP)){ + world.setBlockState(pos, state, 2); } } @@ -135,92 +141,106 @@ public class WizardryWorldGenerator implements IWorldGenerator { // Allows the config file to set the rarity value to 0 to disable tower generation completely. if(Wizardry.settings.towerRarity == 0) return; - - // Compensates for the lack of space in forests. Math.max is required since treeless biomes have treesPerChunk = -999 - //double treeFactor = 70 - Math.max((double)world.getBiomeGenForCoords(chunkX, chunkZ).theBiomeDecorator.treesPerChunk, 0) * 1.5d; + + // Compensates for the lack of space in forests. Math.max is required since treeless biomes have treesPerChunk = + // -999 + // double treeFactor = 70 - Math.max((double)world.getBiomeGenForCoords(chunkX, + // chunkZ).theBiomeDecorator.treesPerChunk, 0) * 1.5d; // Multiplied by 70 to (roughly) retain the old rarity scale if(random.nextInt((int)(Wizardry.settings.towerRarity * 70)) == 0){ - + BlockPos origin = new BlockPos(chunkX + random.nextInt(16), 0, chunkZ + random.nextInt(16)); - + // Despite what its name suggests, this method does not return the position of a liquid. It is in fact // exactly what is needed here since it is used for placing villages and stuff, and doesn't include leaves // or other foliage. origin = origin.up(world.getTopSolidOrLiquidBlock(origin).getY() - 1); - + int[][][] towerBlueprint = towerBlueprintSmall; - + switch(random.nextInt(4)){ - case 0: towerBlueprint = towerBlueprintSmall; break; - case 1: towerBlueprint = towerBlueprintMedium; break; - case 2: towerBlueprint = towerBlueprintTall; break; - case 3: towerBlueprint = towerBlueprintDouble; break; + case 0: + towerBlueprint = towerBlueprintSmall; + break; + case 1: + towerBlueprint = towerBlueprintMedium; + break; + case 2: + towerBlueprint = towerBlueprintTall; + break; + case 3: + towerBlueprint = towerBlueprintDouble; + break; } - + // 0 = West, 1 = North, 2 = East, 3 = South (The way you would face when walking out of the door) EnumFacing orientation = EnumFacing.getHorizontal(random.nextInt(4)); boolean flip = random.nextBoolean(); - + if(checkSpaceForTower(world, origin, towerBlueprint, orientation, flip)){ // == Setup == - + boolean evilWizard = random.nextInt(5) == 0; - + IBlockState wallMaterial = Blocks.COBBLESTONE.getDefaultState(); BlockPlanks.EnumType woodType = BlockPlanks.EnumType.OAK; - + Biome biome = world.getBiome(origin); - // The order of these is somewhat important in that biomes can be many types, so the last of these checks + // The order of these is somewhat important in that biomes can be many types, so the last of these + // checks // that is true gets priority. Generally speaking, the later the check, the more specific it is. - if(BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.DENSE)) wallMaterial = Blocks.MOSSY_COBBLESTONE.getDefaultState(); - if(BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.SWAMP)) wallMaterial = Blocks.MOSSY_COBBLESTONE.getDefaultState(); - if(BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.SANDY)) wallMaterial = Blocks.SANDSTONE.getDefaultState(); - if(BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.NETHER)) wallMaterial = Blocks.NETHER_BRICK.getDefaultState(); - if(BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.MOUNTAIN)) wallMaterial = Blocks.STONEBRICK.getDefaultState(); - if(BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.MESA)) wallMaterial = Blocks.HARDENED_CLAY.getDefaultState(); + if(BiomeDictionary.hasType(biome, BiomeDictionary.Type.DENSE)) + wallMaterial = Blocks.MOSSY_COBBLESTONE.getDefaultState(); + if(BiomeDictionary.hasType(biome, BiomeDictionary.Type.SWAMP)) + wallMaterial = Blocks.MOSSY_COBBLESTONE.getDefaultState(); + if(BiomeDictionary.hasType(biome, BiomeDictionary.Type.SANDY)) + wallMaterial = Blocks.SANDSTONE.getDefaultState(); + if(BiomeDictionary.hasType(biome, BiomeDictionary.Type.NETHER)) + wallMaterial = Blocks.NETHER_BRICK.getDefaultState(); + if(BiomeDictionary.hasType(biome, BiomeDictionary.Type.MOUNTAIN)) + wallMaterial = Blocks.STONEBRICK.getDefaultState(); + if(BiomeDictionary.hasType(biome, BiomeDictionary.Type.MESA)) + wallMaterial = Blocks.HARDENED_CLAY.getDefaultState(); // Unfortunately, I can't check all the wood types with the biome dictionary - if(BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.CONIFEROUS)) woodType = BlockPlanks.EnumType.SPRUCE; - if(biome == Biomes.BIRCH_FOREST || biome == Biomes.BIRCH_FOREST_HILLS) woodType = BlockPlanks.EnumType.BIRCH; - if(BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.JUNGLE)) woodType = BlockPlanks.EnumType.JUNGLE; - if(BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.SAVANNA)) woodType = BlockPlanks.EnumType.ACACIA; + if(BiomeDictionary.hasType(biome, BiomeDictionary.Type.CONIFEROUS)) + woodType = BlockPlanks.EnumType.SPRUCE; + if(biome == Biomes.BIRCH_FOREST || biome == Biomes.BIRCH_FOREST_HILLS) + woodType = BlockPlanks.EnumType.BIRCH; + if(BiomeDictionary.hasType(biome, BiomeDictionary.Type.JUNGLE)) woodType = BlockPlanks.EnumType.JUNGLE; + if(BiomeDictionary.hasType(biome, BiomeDictionary.Type.SAVANNA)) woodType = BlockPlanks.EnumType.ACACIA; // Not technically a tree type, but I think it fits quite well anyway - if(BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.SPOOKY)) woodType = BlockPlanks.EnumType.DARK_OAK; - - IBlockState[] blockStateList = new IBlockState[]{ - null, - Blocks.AIR.getDefaultState(), + if(BiomeDictionary.hasType(biome, BiomeDictionary.Type.SPOOKY)) + woodType = BlockPlanks.EnumType.DARK_OAK; + + IBlockState[] blockStateList = new IBlockState[]{null, Blocks.AIR.getDefaultState(), Blocks.PLANKS.getDefaultState().withProperty(BlockPlanks.VARIANT, woodType), Blocks.BOOKSHELF.getDefaultState(), Blocks.STAINED_HARDENED_CLAY.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.values()[random.nextInt(EnumDyeColor.values().length)]), Blocks.WOODEN_SLAB.getDefaultState().withProperty(BlockSlab.HALF, EnumBlockHalf.BOTTOM), Blocks.WOODEN_SLAB.getDefaultState().withProperty(BlockSlab.HALF, EnumBlockHalf.TOP), - wallMaterial, - Blocks.GLASS_PANE.getDefaultState(), - Blocks.OAK_DOOR.getDefaultState(), - WizardryBlocks.arcane_workbench.getDefaultState(), - Blocks.TORCH.getDefaultState(), - evilWizard ? Blocks.CHEST.getDefaultState() : Blocks.BOOKSHELF.getDefaultState() - }; - + wallMaterial, Blocks.GLASS_PANE.getDefaultState(), Blocks.OAK_DOOR.getDefaultState(), + WizardryBlocks.arcane_workbench.getDefaultState(), Blocks.TORCH.getDefaultState(), + evilWizard ? Blocks.CHEST.getDefaultState() : Blocks.BOOKSHELF.getDefaultState()}; + Set blocksPlaced = new HashSet(); - + // == Foundations == - + // Fills in foundations. This is done first so the door always has something to be placed on. boolean flag = true; - + // BlockPos is immutable, so I'm not sure if simply saying pos1 = pos will be sufficient. BlockPos layerCentre = new BlockPos(origin); while(flag){ - + flag = false; - + for(BlockPos offset : foundationLayer){ if(!world.isBlockNormalCube(layerCentre.add(offset), false)){ world.setBlockState(layerCentre.add(offset), wallMaterial); @@ -229,57 +249,64 @@ public class WizardryWorldGenerator implements IWorldGenerator { flag = true; } } - + layerCentre = layerCentre.down(); } // == Main Structure == - - // It is assumed that the width of the blueprint is the same all the way up, and that the layers are square. - int width = towerBlueprint[0].length-1; + + // It is assumed that the width of the blueprint is the same all the way up, and that the layers are + // square. + int width = towerBlueprint[0].length - 1; // x, y and z are the position the block is being put in. // x1, y and z1 are the position in the blueprint which determines which block is being placed. - + int x1 = 0, z1 = 0; - - for(int y=0; y 3 || world.getBlockState(pos1).getBlock() instanceof BlockLiquid)){ @@ -462,25 +499,15 @@ public class WizardryWorldGenerator implements IWorldGenerator { } } } - + return true; } - + /** Array of relative positions of each block in a layer of foundations. */ - private static final BlockPos[] foundationLayer = new BlockPos[]{ - new BlockPos(-2, 0, -1), - new BlockPos(-2, 0, 0), - new BlockPos(-2, 0, 1), - new BlockPos(2, 0, -1), - new BlockPos(2, 0, 0), - new BlockPos(2, 0, 1), - new BlockPos(-1, 0, -2), - new BlockPos(0, 0, -2), - new BlockPos(1, 0, -2), - new BlockPos(-1, 0, 2), - new BlockPos(0, 0, 2), - new BlockPos(1, 0, 2), - }; + private static final BlockPos[] foundationLayer = new BlockPos[]{new BlockPos(-2, 0, -1), new BlockPos(-2, 0, 0), + new BlockPos(-2, 0, 1), new BlockPos(2, 0, -1), new BlockPos(2, 0, 0), new BlockPos(2, 0, 1), + new BlockPos(-1, 0, -2), new BlockPos(0, 0, -2), new BlockPos(1, 0, -2), new BlockPos(-1, 0, 2), + new BlockPos(0, 0, 2), new BlockPos(1, 0, 2),}; /** * 3D matrix of integers representing the different blocks which make up the wizard tower. The blocks corresponding @@ -502,189 +529,61 @@ public class WizardryWorldGenerator implements IWorldGenerator { */ private static final int[][][] towerBlueprintSmall = { // x is horizontal, z is vertical, y is layers - { - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 2, 2, 2, 0, 0, 0}, - {0, 0, 0, 2, 2, 2, 0, 0, 0}, - {0, 0, 0, 2, 2, 2, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 1, 6, 5, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 9, 7, 0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 5, 1 ,1, 7, 0, 0}, - {0, 0, 7, 6, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 0, 7, 0, 0, 0}, - {0, 0, 0, 11,1, 11,0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 11,7, 0, 0}, - {0, 0, 7, 5, 6, 1, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 6, 7, 0, 0}, - {0, 0, 7, 1, 1, 5, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 1, 6, 5, 7, 0, 0}, - {0, 0, 7, 11,1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 5, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 2, 2, 2, 7, 0, 0}, - {0, 7, 1, 1, 1, 1, 2, 7, 0}, - {0, 7, 5, 2, 2, 6, 2, 7, 0}, - {0, 7, 2, 2, 2, 2, 2, 7, 0}, - {0, 0, 7, 2, 2, 2, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 3, 3, 3, 7, 0, 0}, - {0, 7, 1, 1, 1, 1, 3, 7, 0}, - {0, 7, 1, 1, 1, 1, 3, 7, 0}, - {0, 7, 1, 1, 10,1, 3, 7, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 7, 11,1, 11,7, 0, 0}, - {0, 7, 1, 1, 1, 1, 3, 7, 0}, - {0, 8, 1, 1, 1, 1, 3, 7, 0}, - {0, 7, 1, 1, 1, 1, 3, 7, 0}, - {0, 0, 7, 11,1, 11,7, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 4, 7, 7, 7, 4, 0, 0}, - {0, 4, 7, 1, 1, 1, 7, 4, 0}, - {4, 7, 1, 1, 1, 1, 3, 7, 4}, - {4, 7, 1, 1, 1, 1, 3, 7, 4}, - {4, 7, 1, 1, 1, 1, 12,7, 4}, - {0, 4, 7, 1, 1, 1, 7, 4, 0}, - {0, 0, 4, 7, 7, 7, 4, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 4, 1, 1, 1, 1, 1, 4, 0}, - {0, 4, 1, 1, 1, 1, 1, 4, 0}, - {0, 4, 1, 1, 1, 1, 1, 4, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 4, 1, 4, 0, 0, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 0, 0, 4, 1, 4, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 0, 4, 1, 4, 0, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 4, 1, 4, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - } - }; - + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 2, 2, 2, 0, 0, 0}, {0, 0, 0, 2, 2, 2, 0, 0, 0}, {0, 0, 0, 2, 2, 2, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 1, 6, 5, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 9, 7, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 5, 1, 1, 7, 0, 0}, {0, 0, 7, 6, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 0, 7, 0, 0, 0}, {0, 0, 0, 11, 1, 11, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 8, 7, 0, 0, 0}, + {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 11, 7, 0, 0}, {0, 0, 7, 5, 6, 1, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 6, 7, 0, 0}, {0, 0, 7, 1, 1, 5, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 1, 6, 5, 7, 0, 0}, {0, 0, 7, 11, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 8, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 5, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 7, 2, 2, 2, 7, 0, 0}, + {0, 7, 1, 1, 1, 1, 2, 7, 0}, {0, 7, 5, 2, 2, 6, 2, 7, 0}, {0, 7, 2, 2, 2, 2, 2, 7, 0}, + {0, 0, 7, 2, 2, 2, 7, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 7, 3, 3, 3, 7, 0, 0}, + {0, 7, 1, 1, 1, 1, 3, 7, 0}, {0, 7, 1, 1, 1, 1, 3, 7, 0}, {0, 7, 1, 1, 10, 1, 3, 7, 0}, + {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 8, 7, 0, 0, 0}, {0, 0, 7, 11, 1, 11, 7, 0, 0}, + {0, 7, 1, 1, 1, 1, 3, 7, 0}, {0, 8, 1, 1, 1, 1, 3, 7, 0}, {0, 7, 1, 1, 1, 1, 3, 7, 0}, + {0, 0, 7, 11, 1, 11, 7, 0, 0}, {0, 0, 0, 7, 8, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 4, 4, 4, 0, 0, 0}, {0, 0, 4, 7, 7, 7, 4, 0, 0}, {0, 4, 7, 1, 1, 1, 7, 4, 0}, + {4, 7, 1, 1, 1, 1, 3, 7, 4}, {4, 7, 1, 1, 1, 1, 3, 7, 4}, {4, 7, 1, 1, 1, 1, 12, 7, 4}, + {0, 4, 7, 1, 1, 1, 7, 4, 0}, {0, 0, 4, 7, 7, 7, 4, 0, 0}, {0, 0, 0, 4, 4, 4, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 4, 4, 4, 0, 0, 0}, {0, 0, 4, 1, 1, 1, 4, 0, 0}, + {0, 4, 1, 1, 1, 1, 1, 4, 0}, {0, 4, 1, 1, 1, 1, 1, 4, 0}, {0, 4, 1, 1, 1, 1, 1, 4, 0}, + {0, 0, 4, 1, 1, 1, 4, 0, 0}, {0, 0, 0, 4, 4, 4, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 4, 4, 4, 0, 0, 0}, + {0, 0, 4, 1, 1, 1, 4, 0, 0}, {0, 0, 4, 1, 1, 1, 4, 0, 0}, {0, 0, 4, 1, 1, 1, 4, 0, 0}, + {0, 0, 0, 4, 4, 4, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 4, 0, 0, 0, 0}, + {0, 0, 0, 4, 1, 4, 0, 0, 0}, {0, 0, 4, 1, 1, 1, 4, 0, 0}, {0, 0, 0, 4, 1, 4, 0, 0, 0}, + {0, 0, 0, 0, 4, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 4, 4, 4, 0, 0, 0}, {0, 0, 0, 4, 1, 4, 0, 0, 0}, {0, 0, 0, 4, 4, 4, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 4, 0, 0, 0, 0}, {0, 0, 0, 4, 1, 4, 0, 0, 0}, {0, 0, 0, 0, 4, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 4, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 4, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}}; + /** * 3D matrix of integers representing the different blocks which make up the wizard tower. The blocks corresponding * to each integer are as follows (note that some blocks change depending on the biome): @@ -705,229 +604,73 @@ public class WizardryWorldGenerator implements IWorldGenerator { */ private static final int[][][] towerBlueprintMedium = { // x is horizontal, z is vertical, y is layers - { - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 2, 2, 2, 0, 0, 0}, - {0, 0, 0, 2, 2, 2, 0, 0, 0}, - {0, 0, 0, 2, 2, 2, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 1, 6, 5, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 9, 7, 0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 5, 1 ,1, 7, 0, 0}, - {0, 0, 7, 6, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 0, 7, 0, 0, 0}, - {0, 0, 0, 11,1, 11,0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 11,7, 0, 0}, - {0, 0, 7, 5, 6, 1, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 6, 7, 0, 0}, - {0, 0, 7, 1, 1, 5, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 1, 6, 5, 7, 0, 0}, - {0, 0, 7, 11,1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 5, 1 ,1, 7, 0, 0}, - {0, 0, 7, 6, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 11,7, 0, 0}, - {0, 0, 7, 5, 6, 1, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 6, 7, 0, 0}, - {0, 0, 7, 1, 1, 5, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 1, 6, 5, 7, 0, 0}, - {0, 0, 7, 11,1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 5, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 2, 2, 2, 7, 0, 0}, - {0, 7, 1, 1, 1, 1, 2, 7, 0}, - {0, 7, 5, 2, 2, 6, 2, 7, 0}, - {0, 7, 2, 2, 2, 2, 2, 7, 0}, - {0, 0, 7, 2, 2, 2, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 3, 3, 3, 7, 0, 0}, - {0, 7, 1, 1, 1, 1, 3, 7, 0}, - {0, 7, 1, 1, 1, 1, 3, 7, 0}, - {0, 7, 1, 1, 10,1, 3, 7, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 7, 11,1, 11,7, 0, 0}, - {0, 7, 1, 1, 1, 1, 3, 7, 0}, - {0, 8, 1, 1, 1, 1, 3, 7, 0}, - {0, 7, 1, 1, 1, 1, 3, 7, 0}, - {0, 0, 7, 11,1, 11,7, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 4, 7, 7, 7, 4, 0, 0}, - {0, 4, 7, 1, 1, 1, 7, 4, 0}, - {4, 7, 1, 1, 1, 1, 3, 7, 4}, - {4, 7, 1, 1, 1, 1, 3, 7, 4}, - {4, 7, 1, 1, 1, 1, 12,7, 4}, - {0, 4, 7, 1, 1, 1, 7, 4, 0}, - {0, 0, 4, 7, 7, 7, 4, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 4, 1, 1, 1, 1, 1, 4, 0}, - {0, 4, 1, 1, 1, 1, 1, 4, 0}, - {0, 4, 1, 1, 1, 1, 1, 4, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 4, 1, 4, 0, 0, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 0, 0, 4, 1, 4, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 0, 4, 1, 4, 0, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 4, 1, 4, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - } - }; - + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 2, 2, 2, 0, 0, 0}, {0, 0, 0, 2, 2, 2, 0, 0, 0}, {0, 0, 0, 2, 2, 2, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 1, 6, 5, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 9, 7, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 5, 1, 1, 7, 0, 0}, {0, 0, 7, 6, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 0, 7, 0, 0, 0}, {0, 0, 0, 11, 1, 11, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 8, 7, 0, 0, 0}, + {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 11, 7, 0, 0}, {0, 0, 7, 5, 6, 1, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 6, 7, 0, 0}, {0, 0, 7, 1, 1, 5, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 1, 6, 5, 7, 0, 0}, {0, 0, 7, 11, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 8, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 5, 1, 1, 7, 0, 0}, {0, 0, 7, 6, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 8, 7, 0, 0, 0}, + {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 11, 7, 0, 0}, {0, 0, 7, 5, 6, 1, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 6, 7, 0, 0}, {0, 0, 7, 1, 1, 5, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 1, 6, 5, 7, 0, 0}, {0, 0, 7, 11, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 8, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 5, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 7, 2, 2, 2, 7, 0, 0}, + {0, 7, 1, 1, 1, 1, 2, 7, 0}, {0, 7, 5, 2, 2, 6, 2, 7, 0}, {0, 7, 2, 2, 2, 2, 2, 7, 0}, + {0, 0, 7, 2, 2, 2, 7, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 7, 3, 3, 3, 7, 0, 0}, + {0, 7, 1, 1, 1, 1, 3, 7, 0}, {0, 7, 1, 1, 1, 1, 3, 7, 0}, {0, 7, 1, 1, 10, 1, 3, 7, 0}, + {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 8, 7, 0, 0, 0}, {0, 0, 7, 11, 1, 11, 7, 0, 0}, + {0, 7, 1, 1, 1, 1, 3, 7, 0}, {0, 8, 1, 1, 1, 1, 3, 7, 0}, {0, 7, 1, 1, 1, 1, 3, 7, 0}, + {0, 0, 7, 11, 1, 11, 7, 0, 0}, {0, 0, 0, 7, 8, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 4, 4, 4, 0, 0, 0}, {0, 0, 4, 7, 7, 7, 4, 0, 0}, {0, 4, 7, 1, 1, 1, 7, 4, 0}, + {4, 7, 1, 1, 1, 1, 3, 7, 4}, {4, 7, 1, 1, 1, 1, 3, 7, 4}, {4, 7, 1, 1, 1, 1, 12, 7, 4}, + {0, 4, 7, 1, 1, 1, 7, 4, 0}, {0, 0, 4, 7, 7, 7, 4, 0, 0}, {0, 0, 0, 4, 4, 4, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 4, 4, 4, 0, 0, 0}, {0, 0, 4, 1, 1, 1, 4, 0, 0}, + {0, 4, 1, 1, 1, 1, 1, 4, 0}, {0, 4, 1, 1, 1, 1, 1, 4, 0}, {0, 4, 1, 1, 1, 1, 1, 4, 0}, + {0, 0, 4, 1, 1, 1, 4, 0, 0}, {0, 0, 0, 4, 4, 4, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 4, 4, 4, 0, 0, 0}, + {0, 0, 4, 1, 1, 1, 4, 0, 0}, {0, 0, 4, 1, 1, 1, 4, 0, 0}, {0, 0, 4, 1, 1, 1, 4, 0, 0}, + {0, 0, 0, 4, 4, 4, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 4, 0, 0, 0, 0}, + {0, 0, 0, 4, 1, 4, 0, 0, 0}, {0, 0, 4, 1, 1, 1, 4, 0, 0}, {0, 0, 0, 4, 1, 4, 0, 0, 0}, + {0, 0, 0, 0, 4, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 4, 4, 4, 0, 0, 0}, {0, 0, 0, 4, 1, 4, 0, 0, 0}, {0, 0, 0, 4, 4, 4, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 4, 0, 0, 0, 0}, {0, 0, 0, 4, 1, 4, 0, 0, 0}, {0, 0, 0, 0, 4, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 4, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 4, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}}; + /** * 3D matrix of integers representing the different blocks which make up the wizard tower. The blocks corresponding * to each integer are as follows (note that some blocks change depending on the biome): @@ -948,268 +691,84 @@ public class WizardryWorldGenerator implements IWorldGenerator { */ private static final int[][][] towerBlueprintTall = { // x is horizontal, z is vertical, y is layers - { - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 2, 2, 2, 0, 0, 0}, - {0, 0, 0, 2, 2, 2, 0, 0, 0}, - {0, 0, 0, 2, 2, 2, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 1, 6, 5, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 9, 7, 0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 5, 1 ,1, 7, 0, 0}, - {0, 0, 7, 6, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 0, 7, 0, 0, 0}, - {0, 0, 0, 11,1, 11,0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 11,7, 0, 0}, - {0, 0, 7, 5, 6, 1, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 6, 7, 0, 0}, - {0, 0, 7, 1, 1, 5, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - {0, 0, 0, 1, 1, 1, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 1, 6, 5, 7, 0, 0}, - {0, 0, 7, 11,1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 5, 1 ,1, 7, 0, 0}, - {0, 0, 7, 6, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 11,7, 0, 0}, - {0, 0, 7, 5, 6, 1, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 6, 7, 0, 0}, - {0, 0, 7, 1, 1, 5, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 1, 6, 5, 7, 0, 0}, - {0, 0, 7, 11,1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 5, 1 ,1, 7, 0, 0}, - {0, 0, 7, 6, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 11,7, 0, 0}, - {0, 0, 7, 5, 6, 1, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 6, 7, 0, 0}, - {0, 0, 7, 1, 1, 5, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 1, 6, 5, 7, 0, 0}, - {0, 0, 7, 11,1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 5, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 2, 2, 2, 7, 0, 0}, - {0, 7, 1, 1, 1, 1, 2, 7, 0}, - {0, 7, 5, 2, 2, 6, 2, 7, 0}, - {0, 7, 2, 2, 2, 2, 2, 7, 0}, - {0, 0, 7, 2, 2, 2, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 7, 3, 3, 3, 7, 0, 0}, - {0, 7, 1, 1, 1, 1, 3, 7, 0}, - {0, 7, 1, 1, 1, 1, 3, 7, 0}, - {0, 7, 1, 1, 10,1, 3, 7, 0}, - {0, 0, 7, 1, 1, 1, 7, 0, 0}, - {0, 0, 0, 7, 7, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 7, 11,1, 11,7, 0, 0}, - {0, 7, 1, 1, 1, 1, 3, 7, 0}, - {0, 8, 1, 1, 1, 1, 3, 7, 0}, - {0, 7, 1, 1, 1, 1, 3, 7, 0}, - {0, 0, 7, 11,1, 11,7, 0, 0}, - {0, 0, 0, 7, 8, 7, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 4, 7, 7, 7, 4, 0, 0}, - {0, 4, 7, 1, 1, 1, 7, 4, 0}, - {4, 7, 1, 1, 1, 1, 3, 7, 4}, - {4, 7, 1, 1, 1, 1, 3, 7, 4}, - {4, 7, 1, 1, 1, 1, 12,7, 4}, - {0, 4, 7, 1, 1, 1, 7, 4, 0}, - {0, 0, 4, 7, 7, 7, 4, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 4, 1, 1, 1, 1, 1, 4, 0}, - {0, 4, 1, 1, 1, 1, 1, 4, 0}, - {0, 4, 1, 1, 1, 1, 1, 4, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 4, 1, 4, 0, 0, 0}, - {0, 0, 4, 1, 1, 1, 4, 0, 0}, - {0, 0, 0, 4, 1, 4, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 0, 4, 1, 4, 0, 0, 0}, - {0, 0, 0, 4, 4, 4, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 4, 1, 4, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0}, - } - }; + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 2, 2, 2, 0, 0, 0}, {0, 0, 0, 2, 2, 2, 0, 0, 0}, {0, 0, 0, 2, 2, 2, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 1, 6, 5, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 9, 7, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 5, 1, 1, 7, 0, 0}, {0, 0, 7, 6, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 0, 7, 0, 0, 0}, {0, 0, 0, 11, 1, 11, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 8, 7, 0, 0, 0}, + {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 11, 7, 0, 0}, {0, 0, 7, 5, 6, 1, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 6, 7, 0, 0}, {0, 0, 7, 1, 1, 5, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 1, 6, 5, 7, 0, 0}, {0, 0, 7, 11, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 8, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 5, 1, 1, 7, 0, 0}, {0, 0, 7, 6, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 8, 7, 0, 0, 0}, + {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 11, 7, 0, 0}, {0, 0, 7, 5, 6, 1, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 6, 7, 0, 0}, {0, 0, 7, 1, 1, 5, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 1, 6, 5, 7, 0, 0}, {0, 0, 7, 11, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 8, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 5, 1, 1, 7, 0, 0}, {0, 0, 7, 6, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 8, 7, 0, 0, 0}, + {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 11, 7, 0, 0}, {0, 0, 7, 5, 6, 1, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 6, 7, 0, 0}, {0, 0, 7, 1, 1, 5, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 1, 6, 5, 7, 0, 0}, {0, 0, 7, 11, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 8, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, + {0, 0, 7, 5, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 7, 1, 1, 1, 7, 0, 0}, + {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 7, 2, 2, 2, 7, 0, 0}, + {0, 7, 1, 1, 1, 1, 2, 7, 0}, {0, 7, 5, 2, 2, 6, 2, 7, 0}, {0, 7, 2, 2, 2, 2, 2, 7, 0}, + {0, 0, 7, 2, 2, 2, 7, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 7, 3, 3, 3, 7, 0, 0}, + {0, 7, 1, 1, 1, 1, 3, 7, 0}, {0, 7, 1, 1, 1, 1, 3, 7, 0}, {0, 7, 1, 1, 10, 1, 3, 7, 0}, + {0, 0, 7, 1, 1, 1, 7, 0, 0}, {0, 0, 0, 7, 7, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 7, 8, 7, 0, 0, 0}, {0, 0, 7, 11, 1, 11, 7, 0, 0}, + {0, 7, 1, 1, 1, 1, 3, 7, 0}, {0, 8, 1, 1, 1, 1, 3, 7, 0}, {0, 7, 1, 1, 1, 1, 3, 7, 0}, + {0, 0, 7, 11, 1, 11, 7, 0, 0}, {0, 0, 0, 7, 8, 7, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 4, 4, 4, 0, 0, 0}, {0, 0, 4, 7, 7, 7, 4, 0, 0}, {0, 4, 7, 1, 1, 1, 7, 4, 0}, + {4, 7, 1, 1, 1, 1, 3, 7, 4}, {4, 7, 1, 1, 1, 1, 3, 7, 4}, {4, 7, 1, 1, 1, 1, 12, 7, 4}, + {0, 4, 7, 1, 1, 1, 7, 4, 0}, {0, 0, 4, 7, 7, 7, 4, 0, 0}, {0, 0, 0, 4, 4, 4, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 4, 4, 4, 0, 0, 0}, {0, 0, 4, 1, 1, 1, 4, 0, 0}, + {0, 4, 1, 1, 1, 1, 1, 4, 0}, {0, 4, 1, 1, 1, 1, 1, 4, 0}, {0, 4, 1, 1, 1, 1, 1, 4, 0}, + {0, 0, 4, 1, 1, 1, 4, 0, 0}, {0, 0, 0, 4, 4, 4, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 4, 4, 4, 0, 0, 0}, + {0, 0, 4, 1, 1, 1, 4, 0, 0}, {0, 0, 4, 1, 1, 1, 4, 0, 0}, {0, 0, 4, 1, 1, 1, 4, 0, 0}, + {0, 0, 0, 4, 4, 4, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 4, 0, 0, 0, 0}, + {0, 0, 0, 4, 1, 4, 0, 0, 0}, {0, 0, 4, 1, 1, 1, 4, 0, 0}, {0, 0, 0, 4, 1, 4, 0, 0, 0}, + {0, 0, 0, 0, 4, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 4, 4, 4, 0, 0, 0}, {0, 0, 0, 4, 1, 4, 0, 0, 0}, {0, 0, 0, 4, 4, 4, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 4, 0, 0, 0, 0}, {0, 0, 0, 4, 1, 4, 0, 0, 0}, {0, 0, 0, 0, 4, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 4, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 4, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},}}; /** * 3D matrix of integers representing the different blocks which make up the wizard tower. The blocks corresponding @@ -1231,316 +790,159 @@ public class WizardryWorldGenerator implements IWorldGenerator { */ private static final int[][][] towerBlueprintDouble = { // x is horizontal, z is vertical, y is layers - { - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 1, 6, 5, 7, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 9, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 5, 1 ,1, 7, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 6, 1, 1, 7, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 0, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 11,1, 11,0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 8, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 1, 1, 11,7, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 5, 6, 1, 7, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 1, 1, 6, 7, 7, 7, 0, 0}, - {0, 0, 0, 0, 7, 1, 1, 5, 7, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 1, 6, 5, 7, 7, 7, 0, 0}, - {0, 0, 0, 0, 7, 11,1, 1, 1, 1, 1, 7, 0}, - {0, 0, 0, 0, 7, 1, 1, 1, 7, 7, 7, 0, 0}, - {0, 0, 0, 0, 0, 7, 8, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 5, 1 ,1, 7, 7, 8, 7, 0}, - {0, 0, 0, 0, 7, 6, 1, 1, 1, 1, 1, 8, 0}, - {0, 0, 0, 0, 7, 1, 1, 1, 7, 7, 8, 7, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 8, 7, 0, 4, 4, 4, 0}, - {0, 0, 0, 0, 7, 1, 1, 1, 7, 7, 7, 7, 4}, - {0, 0, 0, 0, 7, 1, 1, 11,7, 1, 1, 7, 4}, - {0, 0, 0, 0, 7, 5, 6, 1, 7, 7, 7, 7, 4}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 4, 4, 4, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 1, 1, 1, 7, 4, 4, 4, 0}, - {0, 0, 0, 0, 7, 1, 1, 6, 7, 4, 1, 4, 0}, - {0, 0, 0, 0, 7, 1, 1, 5, 7, 4, 4, 4, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 1, 6, 5, 7, 0, 4, 0, 0}, - {0, 0, 0, 0, 7, 11,1, 1, 7, 4, 1, 4, 0}, - {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 4, 0, 0}, - {0, 0, 0, 0, 0, 7, 8, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 5, 1, 1, 7, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 4, 0, 0}, - {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 2, 2, 2, 7, 0, 0, 0, 0}, - {0, 0, 0, 7, 1, 1, 1, 1, 2, 7, 0, 0, 0}, - {0, 0, 0, 7, 5, 2, 2, 6, 2, 7, 4, 0, 0}, - {0, 0, 0, 7, 2, 2, 2, 2, 2, 7, 0, 0, 0}, - {0, 0, 0, 0, 7, 2, 2, 2, 7, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 3, 3, 3, 7, 0, 0, 0, 0}, - {0, 0, 0, 7, 1, 1, 1, 1, 3, 7, 0, 0, 0}, - {0, 0, 0, 7, 1, 1, 1, 1, 3, 7, 0, 0, 0}, - {0, 0, 0, 7, 1, 1, 10,1, 3, 7, 0, 0, 0}, - {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 8, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 7, 11,1, 11,7, 0, 0, 0, 0}, - {0, 0, 0, 7, 1, 1, 1, 1, 3, 7, 0, 0, 0}, - {0, 0, 0, 8, 1, 1, 1, 1, 3, 7, 0, 0, 0}, - {0, 0, 0, 7, 1, 1, 1, 1, 3, 7, 0, 0, 0}, - {0, 0, 0, 0, 7, 11,1, 11,7, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 7, 8, 7, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 7, 7, 7, 4, 0, 0, 0, 0}, - {0, 0, 0, 4, 7, 1, 1, 1, 7, 4, 0, 0, 0}, - {0, 0, 4, 7, 1, 1, 1, 1, 3, 7, 4, 0, 0}, - {0, 0, 4, 7, 1, 1, 1, 1, 3, 7, 4, 0, 0}, - {0, 0, 4, 7, 1, 1, 1, 1, 12,7, 4, 0, 0}, - {0, 0, 0, 4, 7, 1, 1, 1, 7, 4, 0, 0, 0}, - {0, 0, 0, 0, 4, 7, 7, 7, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 1, 1, 1, 4, 0, 0, 0, 0}, - {0, 0, 0, 4, 1, 1, 1, 1, 1, 4, 0, 0, 0}, - {0, 0, 0, 4, 1, 1, 1, 1, 1, 4, 0, 0, 0}, - {0, 0, 0, 4, 1, 1, 1, 1, 1, 4, 0, 0, 0}, - {0, 0, 0, 0, 4, 1, 1, 1, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 1, 1, 1, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 1, 1, 1, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 1, 1, 1, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 4, 1, 4, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 4, 1, 1, 1, 4, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 4, 1, 4, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 4, 1, 4, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 4, 1, 4, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - },{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - } - }; - - + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 7, 1, 6, 5, 7, 0, 0, 0, 0}, + {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 0, 0, 0}, {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 7, 9, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 7, 5, 1, 1, 7, 0, 0, 0, 0}, + {0, 0, 0, 0, 7, 6, 1, 1, 7, 0, 0, 0, 0}, {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 7, 0, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 11, 1, 11, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 7, 8, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 0, 0, 0}, + {0, 0, 0, 0, 7, 1, 1, 11, 7, 0, 0, 0, 0}, {0, 0, 0, 0, 7, 5, 6, 1, 7, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 0, 0, 0}, + {0, 0, 0, 0, 7, 1, 1, 6, 7, 7, 7, 0, 0}, {0, 0, 0, 0, 7, 1, 1, 5, 7, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 7, 1, 6, 5, 7, 7, 7, 0, 0}, + {0, 0, 0, 0, 7, 11, 1, 1, 1, 1, 1, 7, 0}, {0, 0, 0, 0, 7, 1, 1, 1, 7, 7, 7, 0, 0}, + {0, 0, 0, 0, 0, 7, 8, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 7, 5, 1, 1, 7, 7, 8, 7, 0}, + {0, 0, 0, 0, 7, 6, 1, 1, 1, 1, 1, 8, 0}, {0, 0, 0, 0, 7, 1, 1, 1, 7, 7, 8, 7, 0}, + {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 7, 8, 7, 0, 4, 4, 4, 0}, {0, 0, 0, 0, 7, 1, 1, 1, 7, 7, 7, 7, 4}, + {0, 0, 0, 0, 7, 1, 1, 11, 7, 1, 1, 7, 4}, {0, 0, 0, 0, 7, 5, 6, 1, 7, 7, 7, 7, 4}, + {0, 0, 0, 0, 0, 7, 7, 7, 0, 4, 4, 4, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 7, 1, 1, 1, 7, 4, 4, 4, 0}, + {0, 0, 0, 0, 7, 1, 1, 6, 7, 4, 1, 4, 0}, {0, 0, 0, 0, 7, 1, 1, 5, 7, 4, 4, 4, 0}, + {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 7, 1, 6, 5, 7, 0, 4, 0, 0}, + {0, 0, 0, 0, 7, 11, 1, 1, 7, 4, 1, 4, 0}, {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 4, 0, 0}, + {0, 0, 0, 0, 0, 7, 8, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 7, 5, 1, 1, 7, 0, 0, 0, 0}, + {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 4, 0, 0}, {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 7, 2, 2, 2, 7, 0, 0, 0, 0}, {0, 0, 0, 7, 1, 1, 1, 1, 2, 7, 0, 0, 0}, + {0, 0, 0, 7, 5, 2, 2, 6, 2, 7, 4, 0, 0}, {0, 0, 0, 7, 2, 2, 2, 2, 2, 7, 0, 0, 0}, + {0, 0, 0, 0, 7, 2, 2, 2, 7, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 7, 3, 3, 3, 7, 0, 0, 0, 0}, {0, 0, 0, 7, 1, 1, 1, 1, 3, 7, 0, 0, 0}, + {0, 0, 0, 7, 1, 1, 1, 1, 3, 7, 0, 0, 0}, {0, 0, 0, 7, 1, 1, 10, 1, 3, 7, 0, 0, 0}, + {0, 0, 0, 0, 7, 1, 1, 1, 7, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 7, 8, 7, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 7, 11, 1, 11, 7, 0, 0, 0, 0}, {0, 0, 0, 7, 1, 1, 1, 1, 3, 7, 0, 0, 0}, + {0, 0, 0, 8, 1, 1, 1, 1, 3, 7, 0, 0, 0}, {0, 0, 0, 7, 1, 1, 1, 1, 3, 7, 0, 0, 0}, + {0, 0, 0, 0, 7, 11, 1, 11, 7, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 7, 8, 7, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 4, 7, 7, 7, 4, 0, 0, 0, 0}, + {0, 0, 0, 4, 7, 1, 1, 1, 7, 4, 0, 0, 0}, {0, 0, 4, 7, 1, 1, 1, 1, 3, 7, 4, 0, 0}, + {0, 0, 4, 7, 1, 1, 1, 1, 3, 7, 4, 0, 0}, {0, 0, 4, 7, 1, 1, 1, 1, 12, 7, 4, 0, 0}, + {0, 0, 0, 4, 7, 1, 1, 1, 7, 4, 0, 0, 0}, {0, 0, 0, 0, 4, 7, 7, 7, 4, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 4, 1, 1, 1, 4, 0, 0, 0, 0}, {0, 0, 0, 4, 1, 1, 1, 1, 1, 4, 0, 0, 0}, + {0, 0, 0, 4, 1, 1, 1, 1, 1, 4, 0, 0, 0}, {0, 0, 0, 4, 1, 1, 1, 1, 1, 4, 0, 0, 0}, + {0, 0, 0, 0, 4, 1, 1, 1, 4, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 4, 1, 1, 1, 4, 0, 0, 0, 0}, + {0, 0, 0, 0, 4, 1, 1, 1, 4, 0, 0, 0, 0}, {0, 0, 0, 0, 4, 1, 1, 1, 4, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 4, 1, 4, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 4, 1, 1, 1, 4, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 4, 1, 4, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 4, 1, 4, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 4, 4, 4, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 4, 1, 4, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}, + {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},}}; + } diff --git a/src/main/java/electroblob/wizardry/block/BlockArcaneWorkbench.java b/src/main/java/electroblob/wizardry/block/BlockArcaneWorkbench.java index 4a0c3f8f..bb2a822a 100644 --- a/src/main/java/electroblob/wizardry/block/BlockArcaneWorkbench.java +++ b/src/main/java/electroblob/wizardry/block/BlockArcaneWorkbench.java @@ -22,99 +22,103 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockArcaneWorkbench extends BlockContainer { - - private static final AxisAlignedBB AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.75D, 1.0D); + + private static final AxisAlignedBB AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.75D, 1.0D); public BlockArcaneWorkbench(){ - super(Material.ROCK); - this.setLightLevel(0.8f); + super(Material.ROCK); + this.setLightLevel(0.8f); } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ - return AABB; - } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ + return AABB; + } + + @Override + public TileEntity createNewTileEntity(World world, int metadata){ return new TileEntityArcaneWorkbench(); } - + @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos){ return false; } - + @Override - public EnumBlockRenderType getRenderType(IBlockState state) { + public EnumBlockRenderType getRenderType(IBlockState state){ return EnumBlockRenderType.MODEL; } - + @Override - public boolean isOpaqueCube(IBlockState state) { + public boolean isOpaqueCube(IBlockState state){ return false; } - + @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState block, EntityPlayer player, - EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ){ - + public boolean onBlockActivated(World world, BlockPos pos, IBlockState block, EntityPlayer player, EnumHand hand, + EnumFacing side, float hitX, float hitY, float hitZ){ + TileEntity tileEntity = world.getTileEntity(pos); - + if(tileEntity == null || player.isSneaking()){ return false; } - - player.openGui(Wizardry.instance, WizardryGuiHandler.ARCANE_WORKBENCH, world, pos.getX(), pos.getY(), pos.getZ()); + + player.openGui(Wizardry.instance, WizardryGuiHandler.ARCANE_WORKBENCH, world, pos.getX(), pos.getY(), + pos.getZ()); return true; } - + @Override - public void breakBlock(World world, BlockPos pos, IBlockState block) - { + public void breakBlock(World world, BlockPos pos, IBlockState block){ + Random random = new Random(); - TileEntityArcaneWorkbench tileentityarcaneworkbench = (TileEntityArcaneWorkbench)world.getTileEntity(pos); + TileEntityArcaneWorkbench tileentityarcaneworkbench = (TileEntityArcaneWorkbench)world.getTileEntity(pos); - if (tileentityarcaneworkbench != null) - { - for (int j1 = 0; j1 < tileentityarcaneworkbench.getSizeInventory(); ++j1) - { - ItemStack itemstack = tileentityarcaneworkbench.getStackInSlot(j1); + if(tileentityarcaneworkbench != null){ - if (itemstack != null) - { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; + for(int j1 = 0; j1 < tileentityarcaneworkbench.getSizeInventory(); ++j1){ - for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem)) - { - int k1 = random.nextInt(21) + 10; + ItemStack itemstack = tileentityarcaneworkbench.getStackInSlot(j1); - if (k1 > itemstack.stackSize) - { - k1 = itemstack.stackSize; - } + if(!itemstack.isEmpty()){ - itemstack.stackSize -= k1; - entityitem = new EntityItem(world, (double)((float)pos.getX() + f), (double)((float)pos.getY() + f1), (double)((float)pos.getZ() + f2), new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (double)((float)random.nextGaussian() * f3); - entityitem.motionY = (double)((float)random.nextGaussian() * f3 + 0.2F); - entityitem.motionZ = (double)((float)random.nextGaussian() * f3); + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; - if (itemstack.hasTagCompound()) - { - entityitem.getEntityItem().setTagCompound(((NBTTagCompound)itemstack.getTagCompound().copy())); - } - } - } - } + for(float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.getCount() > 0; world + .spawnEntity(entityitem)){ - //par1World.func_96440_m(par2, par3, par4, block); - } - - super.breakBlock(world, pos, block); - } + int k1 = random.nextInt(21) + 10; + + if(k1 > itemstack.getCount()){ + k1 = itemstack.getCount(); + } + + itemstack.shrink(k1); + + entityitem = new EntityItem(world, (double)((float)pos.getX() + f), + (double)((float)pos.getY() + f1), (double)((float)pos.getZ() + f2), + new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (double)((float)random.nextGaussian() * f3); + entityitem.motionY = (double)((float)random.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double)((float)random.nextGaussian() * f3); + + if(itemstack.hasTagCompound()){ + entityitem.getEntityItem() + .setTagCompound(((NBTTagCompound)itemstack.getTagCompound().copy())); + } + } + } + } + + // par1World.func_96440_m(par2, par3, par4, block); + } + + super.breakBlock(world, pos, block); + } } diff --git a/src/main/java/electroblob/wizardry/block/BlockCrystalFlower.java b/src/main/java/electroblob/wizardry/block/BlockCrystalFlower.java index 9aded57a..1998f0f5 100644 --- a/src/main/java/electroblob/wizardry/block/BlockCrystalFlower.java +++ b/src/main/java/electroblob/wizardry/block/BlockCrystalFlower.java @@ -22,31 +22,34 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; // Extending BlockBush allows me to remove nearly everything from this class. @Mod.EventBusSubscriber public class BlockCrystalFlower extends BlockBush { - - private static final AxisAlignedBB AABB = new AxisAlignedBB(0.5F - 0.2f, 0.0F, 0.5F - 0.2f, 0.5F + 0.2f, 0.2f * 3.0F, 0.5F + 0.2f); - public BlockCrystalFlower(Material par2Material) { + private static final AxisAlignedBB AABB = new AxisAlignedBB(0.5F - 0.2f, 0.0F, 0.5F - 0.2f, 0.5F + 0.2f, + 0.2f * 3.0F, 0.5F + 0.2f); + + public BlockCrystalFlower(Material par2Material){ super(par2Material); this.setLightLevel(0.5f); - this.setTickRandomly(true); + this.setTickRandomly(true); this.setSoundType(SoundType.PLANT); } - + @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { - return AABB; - } - + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ + return AABB; + } + @Override public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random random){ if(world.isRemote && random.nextBoolean()){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, pos.getX()+random.nextDouble(), pos.getY()+random.nextDouble()/2+0.5, pos.getZ()+random.nextDouble(), 0d, 0.01, 0d, 20 + random.nextInt(10), 0.5f + (random.nextFloat()/2), 0.5f + (random.nextFloat()/2), 0.5f + (random.nextFloat()/2)); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, pos.getX() + random.nextDouble(), + pos.getY() + random.nextDouble() / 2 + 0.5, pos.getZ() + random.nextDouble(), 0d, 0.01, 0d, + 20 + random.nextInt(10), 0.5f + (random.nextFloat() / 2), 0.5f + (random.nextFloat() / 2), + 0.5f + (random.nextFloat() / 2)); } } @Override - public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) { + public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos){ return EnumPlantType.Plains; } @@ -56,11 +59,12 @@ public class BlockCrystalFlower extends BlockBush { if(event.getBlock().getBlock() == Blocks.GRASS){ BlockPos pos = event.getPos().add(event.getWorld().rand.nextInt(8) - event.getWorld().rand.nextInt(8), - event.getWorld().rand.nextInt(4) - event.getWorld().rand.nextInt(4), + event.getWorld().rand.nextInt(4) - event.getWorld().rand.nextInt(4), event.getWorld().rand.nextInt(8) - event.getWorld().rand.nextInt(8)); - if (event.getWorld().isAirBlock(new BlockPos(pos)) && (!event.getWorld().provider.getHasNoSky() || pos.getY() < 127) && WizardryBlocks.crystal_flower.canPlaceBlockAt(event.getWorld(), pos)) - { + if(event.getWorld().isAirBlock(new BlockPos(pos)) + && (!event.getWorld().provider.hasNoSky() || pos.getY() < 127) + && WizardryBlocks.crystal_flower.canPlaceBlockAt(event.getWorld(), pos)){ event.getWorld().setBlockState(pos, WizardryBlocks.crystal_flower.getDefaultState(), 2); } } diff --git a/src/main/java/electroblob/wizardry/block/BlockCrystalOre.java b/src/main/java/electroblob/wizardry/block/BlockCrystalOre.java index dc594dc0..057162a2 100644 --- a/src/main/java/electroblob/wizardry/block/BlockCrystalOre.java +++ b/src/main/java/electroblob/wizardry/block/BlockCrystalOre.java @@ -11,23 +11,22 @@ import net.minecraft.item.Item; public class BlockCrystalOre extends Block { - public BlockCrystalOre(Material material) { + public BlockCrystalOre(Material material){ super(material); this.setSoundType(SoundType.STONE); setResistance(5.0F); setHarvestLevel("pickaxe", 2); } - + @Override - public int quantityDropped(IBlockState state, int fortune, Random random) - { + public int quantityDropped(IBlockState state, int fortune, Random random){ if(fortune > 0){ return random.nextInt(2) + 1 + random.nextInt(fortune); }else{ return random.nextInt(2) + 1; } - } - + } + @Override public Item getItemDropped(IBlockState state, Random random, int fortune){ return WizardryItems.magic_crystal; diff --git a/src/main/java/electroblob/wizardry/block/BlockMagicLight.java b/src/main/java/electroblob/wizardry/block/BlockMagicLight.java index c3ef8499..77974eec 100644 --- a/src/main/java/electroblob/wizardry/block/BlockMagicLight.java +++ b/src/main/java/electroblob/wizardry/block/BlockMagicLight.java @@ -12,47 +12,48 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockMagicLight extends BlockContainer { - - private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 0, 0, 0); - public BlockMagicLight(Material par2Material) { + private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 0, 0, 0); + + public BlockMagicLight(Material par2Material){ super(par2Material); this.setLightLevel(1.0f); } - + @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos){ - // The other two bounding box methods in Block aren't nullable, so this is the only one that can return NULL_AABB. + public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos){ + // The other two bounding box methods in Block aren't nullable, so this is the + // only one that can return NULL_AABB. return NULL_AABB; } - + @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ - return AABB; - } + return AABB; + } @Override public boolean isCollidable(){ return false; } - + @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(World world, int metadata){ return new TileEntityMagicLight(600); } - + @Override - public boolean isOpaqueCube(IBlockState state) { + public boolean isOpaqueCube(IBlockState state){ return false; } - + @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos){ return false; } - + @Override - public EnumBlockRenderType getRenderType(IBlockState state) { + public EnumBlockRenderType getRenderType(IBlockState state){ return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; } } diff --git a/src/main/java/electroblob/wizardry/block/BlockSnare.java b/src/main/java/electroblob/wizardry/block/BlockSnare.java index d020a580..036e378a 100644 --- a/src/main/java/electroblob/wizardry/block/BlockSnare.java +++ b/src/main/java/electroblob/wizardry/block/BlockSnare.java @@ -24,86 +24,88 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + // TODO: Apparently you shouldn't extend BlockContainer. I feel like BlockArcaneWorkbench should, but what about the rest? public class BlockSnare extends BlockContainer { - private static final AxisAlignedBB AABB = new AxisAlignedBB(0.0f, 0.0f, 0.0f, 1.0f, 0.0625f, 1.0f); + private static final AxisAlignedBB AABB = new AxisAlignedBB(0.0f, 0.0f, 0.0f, 1.0f, 0.0625f, 1.0f); - public BlockSnare(Material par2Material){ - super(par2Material); + public BlockSnare(Material material){ + super(material); this.setSoundType(SoundType.PLANT); } - + @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ - return AABB; - } - + return AABB; + } + @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos){ - return NULL_AABB; - } - + public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos){ + return NULL_AABB; + } + @Override public boolean hasTileEntity(IBlockState state){ return true; } - + @Override - public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { - + public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity){ + if(!world.isRemote && entity instanceof EntityLivingBase){ if(world.getTileEntity(pos) instanceof TileEntityPlayerSave){ - + TileEntityPlayerSave tileentity = (TileEntityPlayerSave)world.getTileEntity(pos); - + if(WizardryUtilities.isValidTarget(tileentity.getCaster(), entity)){ - ((EntityLivingBase)entity).attackEntityFrom(MagicDamage.causeDirectMagicDamage(tileentity.getCaster(), DamageType.MAGIC), 6); + ((EntityLivingBase)entity).attackEntityFrom( + MagicDamage.causeDirectMagicDamage(tileentity.getCaster(), DamageType.MAGIC), 6); ((EntityLivingBase)entity).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 100, 2)); - + world.destroyBlock(pos, false); } } } } - + // The similarly named onNeighborChange method does NOT do the same thing. @SuppressWarnings("deprecation") @Override - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn){ - super.neighborChanged(state, world, pos, blockIn); - if(!world.isSideSolid(pos.down(), EnumFacing.UP, false)){ - world.setBlockToAir(pos); - } - } - + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos){ + super.neighborChanged(state, world, pos, block, fromPos); + if(!world.isSideSolid(pos.down(), EnumFacing.UP, false)){ + world.setBlockToAir(pos); + } + } + @Override public BlockRenderLayer getBlockLayer(){ return BlockRenderLayer.CUTOUT; } - + @Override public EnumBlockRenderType getRenderType(IBlockState state){ return EnumBlockRenderType.MODEL; } - - @Override + + @Override public boolean isOpaqueCube(IBlockState state){ - return false; - } - - @Override - public boolean isFullCube(IBlockState state){ - return false; - } - + return false; + } + + @Override + public boolean isFullCube(IBlockState state){ + return false; + } + @Override public Item getItemDropped(IBlockState state, Random rand, int fortune){ return null; } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(World world, int metadata){ return new TileEntityPlayerSave(); } diff --git a/src/main/java/electroblob/wizardry/block/BlockSpectral.java b/src/main/java/electroblob/wizardry/block/BlockSpectral.java index 23837eea..d4c91f1a 100644 --- a/src/main/java/electroblob/wizardry/block/BlockSpectral.java +++ b/src/main/java/electroblob/wizardry/block/BlockSpectral.java @@ -29,79 +29,87 @@ import net.minecraftforge.fml.relauncher.SideOnly; @Mod.EventBusSubscriber public class BlockSpectral extends BlockContainer { - public BlockSpectral(Material material) { + public BlockSpectral(Material material){ super(material); this.setSoundType(SoundType.GLASS); } - + // Replaces getRenderBlockPass @Override public BlockRenderLayer getBlockLayer(){ return BlockRenderLayer.TRANSLUCENT; } - + @Override - public EnumBlockRenderType getRenderType(IBlockState state) { + public EnumBlockRenderType getRenderType(IBlockState state){ return EnumBlockRenderType.MODEL; } - - // Apparently it's OK to override this, despite it being deprecated. More importantly, it being deprecated is not - // Forge's doing, rather it is Mojang themselves misusing the @Deprecated annotation to mean 'internal, don't call'. + + // Apparently it's OK to override this, despite it being deprecated. More + // importantly, it being deprecated is not + // Forge's doing, rather it is Mojang themselves misusing the @Deprecated + // annotation to mean 'internal, don't call'. @Override public boolean isOpaqueCube(IBlockState state){ - return false; - } - - @Override - public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } - + @Override - public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random random) { - // Middle of block - Wizardry.proxy.spawnParticle(WizardryParticleType.DUST, world, pos.getX()+random.nextDouble(), pos.getY()+random.nextDouble(), pos.getZ()+random.nextDouble(), 0, 0, 0, (int)(16.0D / (Math.random() * 0.8D + 0.2D)), - 0.4f + random.nextFloat()*0.2f, 0.6f + random.nextFloat()*0.4f, 0.6f + random.nextFloat()*0.4f); - // Top surface - Wizardry.proxy.spawnParticle(WizardryParticleType.DUST, world, pos.getX()+random.nextDouble(), pos.getY()+1, pos.getZ()+random.nextDouble(), 0, 0, 0, (int)(16.0D / (Math.random() * 0.8D + 0.2D)), - 0.4f + random.nextFloat()*0.2f, 0.6f + random.nextFloat()*0.4f, 0.6f + random.nextFloat()*0.4f); - Wizardry.proxy.spawnParticle(WizardryParticleType.DUST, world, pos.getX()+random.nextDouble(), pos.getY()+1, pos.getZ()+random.nextDouble(), 0, 0, 0, (int)(16.0D / (Math.random() * 0.8D + 0.2D)), - 0.4f + random.nextFloat()*0.2f, 0.6f + random.nextFloat()*0.4f, 0.6f + random.nextFloat()*0.4f); + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos){ + return false; } - // Overriden to make the block always look full brightness despite not emitting full light. @Override - public int getPackedLightmapCoords(IBlockState state, IBlockAccess source, BlockPos pos) { + public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random random){ + // Middle of block + Wizardry.proxy.spawnParticle(WizardryParticleType.DUST, world, pos.getX() + random.nextDouble(), + pos.getY() + random.nextDouble(), pos.getZ() + random.nextDouble(), 0, 0, 0, + (int)(16.0D / (Math.random() * 0.8D + 0.2D)), 0.4f + random.nextFloat() * 0.2f, + 0.6f + random.nextFloat() * 0.4f, 0.6f + random.nextFloat() * 0.4f); + // Top surface + Wizardry.proxy.spawnParticle(WizardryParticleType.DUST, world, pos.getX() + random.nextDouble(), pos.getY() + 1, + pos.getZ() + random.nextDouble(), 0, 0, 0, (int)(16.0D / (Math.random() * 0.8D + 0.2D)), + 0.4f + random.nextFloat() * 0.2f, 0.6f + random.nextFloat() * 0.4f, 0.6f + random.nextFloat() * 0.4f); + Wizardry.proxy.spawnParticle(WizardryParticleType.DUST, world, pos.getX() + random.nextDouble(), pos.getY() + 1, + pos.getZ() + random.nextDouble(), 0, 0, 0, (int)(16.0D / (Math.random() * 0.8D + 0.2D)), + 0.4f + random.nextFloat() * 0.2f, 0.6f + random.nextFloat() * 0.4f, 0.6f + random.nextFloat() * 0.4f); + } + + // Overriden to make the block always look full brightness despite not emitting + // full light. + @Override + public int getPackedLightmapCoords(IBlockState state, IBlockAccess source, BlockPos pos){ return 15; } - - @Override - public TileEntity createNewTileEntity(World world, int metadata) { + + @Override + public TileEntity createNewTileEntity(World world, int metadata){ return new TileEntityTimer(1200); } - - @Override + + @Override public int quantityDropped(Random par1Random){ - return 0; - } - - @SuppressWarnings("deprecation") + return 0; + } + + @SuppressWarnings("deprecation") @SideOnly(Side.CLIENT) @Override - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side){ - - IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side)); - Block block = iblockstate.getBlock(); + public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, + EnumFacing side){ - return block == this ? false : super.shouldSideBeRendered(blockState, blockAccess, pos, side); - } - - @SubscribeEvent + IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side)); + Block block = iblockstate.getBlock(); + + return block == this ? false : super.shouldSideBeRendered(blockState, blockAccess, pos, side); + } + + @SubscribeEvent public static void onBlockPlaceEvent(BlockEvent.PlaceEvent event){ // Spectral blocks cannot be built on if(event.getPlacedAgainst() == WizardryBlocks.spectral_block){ event.setCanceled(true); } } - + } diff --git a/src/main/java/electroblob/wizardry/block/BlockStatue.java b/src/main/java/electroblob/wizardry/block/BlockStatue.java index 3b3e9b5e..597f2656 100644 --- a/src/main/java/electroblob/wizardry/block/BlockStatue.java +++ b/src/main/java/electroblob/wizardry/block/BlockStatue.java @@ -24,7 +24,7 @@ public class BlockStatue extends BlockContainer { private boolean isIce; - public BlockStatue(Material material) { + public BlockStatue(Material material){ super(material); this.isIce = material == Material.ICE; if(this.isIce){ @@ -32,7 +32,7 @@ public class BlockStatue extends BlockContainer { this.setSoundType(SoundType.GLASS); } } - + @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos){ // Not a good idea to call getBlockBoundsMinX() or whatever from in here, since this method changes those! @@ -43,49 +43,71 @@ public class BlockStatue extends BlockContainer { TileEntityStatue statue = (TileEntityStatue)world.getTileEntity(pos); if(statue.creature != null){ - + // Block bounds are set to match the width and height of the entity, clamped to within 1 block. - return new AxisAlignedBB((float)Math.max(0.5 - statue.creature.width/2, 0), 0, - (float)Math.max(0.5 - statue.creature.width/2, 0), - (float)Math.min(0.5 + statue.creature.width/2, 1), - // This checks if the block is the top one and if so reduces its height so the top lines up with + return new AxisAlignedBB((float)Math.max(0.5 - statue.creature.width / 2, 0), 0, + (float)Math.max(0.5 - statue.creature.width / 2, 0), + (float)Math.min(0.5 + statue.creature.width / 2, 1), + // This checks if the block is the top one and if so reduces its height so the top lines up + // with // the top of the entity model. - statue.position == statue.parts ? (float)Math.min(statue.creature.height - statue.parts + 1, 1) : 1, - (float)Math.min(0.5 + statue.creature.width/2, 1)); + statue.position == statue.parts + ? (float)Math.min(statue.creature.height - statue.parts + 1, 1) + : 1, + (float)Math.min(0.5 + statue.creature.width / 2, 1)); } } } - + return FULL_BLOCK_AABB; } - + // getCollisionBoundingBox eventually calls getBoundingBox anyway, and since I want the collision box and the block // outline to be the same here, I've removed that getCollisionBoundingBox entirely. // The number of these methods is quite simply ridiculous. This one seems to be for placement logic and block // connections (fences, glass panes, etc.)... - @Override public boolean isFullCube(IBlockState state) { return false; } + @Override + public boolean isFullCube(IBlockState state){ + return false; + } + // ...this one isn't used much but has something to do with redstone... - @Override public boolean isBlockNormalCube(IBlockState state) { return false; } + @Override + public boolean isBlockNormalCube(IBlockState state){ + return false; + } + // ... this one is for most other game logic... - @Override public boolean isNormalCube(IBlockState state) { return false; } + @Override + public boolean isNormalCube(IBlockState state){ + return false; + } + // Forge version of the above method. I still need to override both though because vanilla uses the other one. - @Override public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } + @Override + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos){ + return false; + } + // ... and this one is for rendering. - @Override public boolean isOpaqueCube(IBlockState state){ return false; } - + @Override + public boolean isOpaqueCube(IBlockState state){ + return false; + } + @Override public BlockRenderLayer getBlockLayer(){ return this.isIce ? BlockRenderLayer.TRANSLUCENT : BlockRenderLayer.SOLID; } - + @Override public EnumBlockRenderType getRenderType(IBlockState state){ return this.isIce ? EnumBlockRenderType.MODEL : EnumBlockRenderType.ENTITYBLOCK_ANIMATED; } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(World world, int metadata){ return new TileEntityStatue(this.isIce); } @@ -93,14 +115,14 @@ public class BlockStatue extends BlockContainer { public int quantityDropped(Random random){ return 0; } - + @Override public void breakBlock(World world, BlockPos pos, IBlockState state){ - + if(!world.isRemote){ - + TileEntityStatue tileentity = (TileEntityStatue)world.getTileEntity(pos); - + if(tileentity != null){ if(tileentity.parts == 2){ if(tileentity.position == 2){ @@ -126,21 +148,22 @@ public class BlockStatue extends BlockContainer { if(tileentity != null && tileentity.position == 1 && tileentity.creature != null){ tileentity.creature.getEntityData().removeTag(Petrify.NBT_KEY); tileentity.creature.isDead = false; - world.spawnEntityInWorld(tileentity.creature); + world.spawnEntity(tileentity.creature); } } - + super.breakBlock(world, pos, state); } - + @SuppressWarnings("deprecation") @SideOnly(Side.CLIENT) @Override - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side){ - - IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side)); - Block block = iblockstate.getBlock(); + public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, + EnumFacing side){ - return this.isIce && block == this ? false : super.shouldSideBeRendered(blockState, blockAccess, pos, side); - } + IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side)); + Block block = iblockstate.getBlock(); + + return this.isIce && block == this ? false : super.shouldSideBeRendered(blockState, blockAccess, pos, side); + } } diff --git a/src/main/java/electroblob/wizardry/block/BlockTransportationStone.java b/src/main/java/electroblob/wizardry/block/BlockTransportationStone.java index 681d5266..a7c017ca 100644 --- a/src/main/java/electroblob/wizardry/block/BlockTransportationStone.java +++ b/src/main/java/electroblob/wizardry/block/BlockTransportationStone.java @@ -20,96 +20,121 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockTransportationStone extends Block { - - private static final AxisAlignedBB AABB = new AxisAlignedBB(0.0625f*5, 0, 0.0625f*5, 0.0625f*11, 0.0625f*6, 0.0625f*11); + + private static final AxisAlignedBB AABB = new AxisAlignedBB(0.0625f * 5, 0, 0.0625f * 5, 0.0625f * 11, 0.0625f * 6, + 0.0625f * 11); public BlockTransportationStone(Material material){ super(material); - this.setTickRandomly(true); + this.setTickRandomly(true); } - + @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ return AABB; } - + // The number of these methods is quite simply ridiculous. This one seems to be for placement logic and block // connections (fences, glass panes, etc.)... - @Override public boolean isFullCube(IBlockState state) { return false; } + @Override + public boolean isFullCube(IBlockState state){ + return false; + } + // ...this one isn't used much but has something to do with redstone... - @Override public boolean isBlockNormalCube(IBlockState state) { return false; } + @Override + public boolean isBlockNormalCube(IBlockState state){ + return false; + } + // ... this one is for most other game logic... - @Override public boolean isNormalCube(IBlockState state) { return false; } + @Override + public boolean isNormalCube(IBlockState state){ + return false; + } + // Forge version of the above method. I still need to override both though because vanilla uses the other one. - @Override public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { return false; } + @Override + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos){ + return false; + } + // ... and this one is for rendering. - @Override public boolean isOpaqueCube(IBlockState state){ return false; } - + @Override + public boolean isOpaqueCube(IBlockState state){ + return false; + } + @Override public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor){ - - super.onNeighborChange(world, pos, neighbor); - - if(!world.isSideSolid(pos.down(), EnumFacing.UP, false) && world instanceof World){ - this.dropBlockAsItem((World) world, pos, world.getBlockState(pos), 0); - ((World)world).setBlockToAir(pos); - } - } - - @Override - public void updateTick(World world, BlockPos pos, IBlockState state, Random random) { - if(!world.isSideSolid(pos.down(), EnumFacing.UP)){ - this.dropBlockAsItem(world, pos, world.getBlockState(pos), 0); - world.setBlockToAir(pos); - } + super.onNeighborChange(world, pos, neighbor); + + if(!world.isSideSolid(pos.down(), EnumFacing.UP, false) && world instanceof World){ + this.dropBlockAsItem((World)world, pos, world.getBlockState(pos), 0); + ((World)world).setBlockToAir(pos); + } } - + + @Override + public void updateTick(World world, BlockPos pos, IBlockState state, Random random){ + + if(!world.isSideSolid(pos.down(), EnumFacing.UP)){ + this.dropBlockAsItem(world, pos, world.getBlockState(pos), 0); + world.setBlockToAir(pos); + } + } + @Override public boolean canPlaceBlockAt(World world, BlockPos pos){ - return super.canPlaceBlockAt(world, pos) && world.isSideSolid(pos.down(), EnumFacing.UP); + return super.canPlaceBlockAt(world, pos) && world.isSideSolid(pos.down(), EnumFacing.UP); } - + @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, - EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ) { - - if(stack != null && stack.getItem() instanceof ItemWand){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, + EnumFacing side, float hitX, float hitY, float hitZ){ + + ItemStack stack = player.getHeldItem(hand); + + if(stack.getItem() instanceof ItemWand){ if(WizardData.get(player) != null){ - + WizardData data = WizardData.get(player); - - for(int x=-1; x<=1; x++){ - for(int z=-1; z<=1; z++){ + + for(int x = -1; x <= 1; x++){ + for(int z = -1; z <= 1; z++){ BlockPos pos1 = pos.add(x, 0, z); if(testForCircle(world, pos1)){ data.setStoneCircleLocation(pos1, world.provider.getDimension()); - if(!world.isRemote) player.addChatMessage(new TextComponentTranslation("tile.wizardry:transportation_stone.confirm", Spells.transportation.getNameForTranslationFormatted())); + if(!world.isRemote) player.sendMessage( + new TextComponentTranslation("tile.wizardry:transportation_stone.confirm", + Spells.transportation.getNameForTranslationFormatted())); return true; } } } - - if(!world.isRemote) player.addChatMessage(new TextComponentTranslation("tile.wizardry:transportation_stone.invalid")); + + if(!world.isRemote) + player.sendMessage(new TextComponentTranslation("tile.wizardry:transportation_stone.invalid")); return true; } } - return false; + return false; } - + /** Returns whether the specified location is surrounded by a complete cicle of 8 transportation stones. */ public static boolean testForCircle(World world, BlockPos pos){ - + if(world.getBlockState(pos).getMaterial().blocksMovement()) return false; - - for(int x=-1; x<=1; x++){ - for(int z=-1; z<=1; z++){ + + for(int x = -1; x <= 1; x++){ + for(int z = -1; z <= 1; z++){ if(world.getBlockState(pos.add(x, 0, z)).getBlock() != WizardryBlocks.transportation_stone){ if(x != 0 || z != 0) return false; } } } - + return true; } } diff --git a/src/main/java/electroblob/wizardry/block/BlockVanishingCobweb.java b/src/main/java/electroblob/wizardry/block/BlockVanishingCobweb.java index 3dcc77cd..8300834e 100644 --- a/src/main/java/electroblob/wizardry/block/BlockVanishingCobweb.java +++ b/src/main/java/electroblob/wizardry/block/BlockVanishingCobweb.java @@ -12,6 +12,7 @@ import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -19,52 +20,48 @@ import net.minecraftforge.fml.relauncher.SideOnly; // For future reference - extend BlockContainer whenever possible because it has methods for removing tile entities on block break. public class BlockVanishingCobweb extends BlockContainer { - public BlockVanishingCobweb(Material material) { + public BlockVanishingCobweb(Material material){ super(material); } - + @SideOnly(Side.CLIENT) - public BlockRenderLayer getBlockLayer() - { - return BlockRenderLayer.CUTOUT; - } - + public BlockRenderLayer getBlockLayer(){ + return BlockRenderLayer.CUTOUT; + } + @Override public EnumBlockRenderType getRenderType(IBlockState state){ return EnumBlockRenderType.MODEL; } - - @Override - public boolean isOpaqueCube(IBlockState state) - { - return false; - } @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) - { - return NULL_AABB; - } - + public boolean isOpaqueCube(IBlockState state){ + return false; + } + @Override - public boolean isFullCube(IBlockState state) - { - return false; - } - - @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos){ + return NULL_AABB; + } + + @Override + public boolean isFullCube(IBlockState state){ + return false; + } + + @Override + public TileEntity createNewTileEntity(World world, int metadata){ return new TileEntityTimer(400); } - - @Override - public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity){ - entity.setInWeb(); - } - - @Override + + @Override + public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity){ + entity.setInWeb(); + } + + @Override public int quantityDropped(Random par1Random){ - return 0; - } - + return 0; + } + } diff --git a/src/main/java/electroblob/wizardry/client/ClientProxy.java b/src/main/java/electroblob/wizardry/client/ClientProxy.java index fa6bb170..2ca0bc20 100644 --- a/src/main/java/electroblob/wizardry/client/ClientProxy.java +++ b/src/main/java/electroblob/wizardry/client/ClientProxy.java @@ -145,6 +145,7 @@ import net.minecraftforge.fml.client.registry.RenderingRegistry; /** * The client proxy for wizardry. + * * @author Electroblob * @since Wizardry 1.0 */ @@ -152,155 +153,168 @@ public class ClientProxy extends CommonProxy { /** Static instance of the mixed font renderer */ public static MixedFontRenderer mixedFontRenderer; - + // Key Bindings - public static final KeyBinding NEXT_SPELL = new KeyBinding("key.wizardry:next_spell", Keyboard.KEY_N, "key.categories.wizardry"); - public static final KeyBinding PREVIOUS_SPELL = new KeyBinding("key.wizardry:previous_spell", Keyboard.KEY_B, "key.categories.wizardry"); + public static final KeyBinding NEXT_SPELL = new KeyBinding("key.wizardry:next_spell", Keyboard.KEY_N, + "key.categories.wizardry"); + public static final KeyBinding PREVIOUS_SPELL = new KeyBinding("key.wizardry:previous_spell", Keyboard.KEY_B, + "key.categories.wizardry"); // Armour Model public static final ModelBiped WIZARD_ARMOUR_MODEL = new ModelWizardArmour(0.75f); - + // SECTION Registry // =============================================================================================================== - + @Override public ModelBiped getWizardArmourModel(){ return WIZARD_ARMOUR_MODEL; } - + @Override - public void registerKeyBindings(){ - ClientRegistry.registerKeyBinding(NEXT_SPELL); - ClientRegistry.registerKeyBinding(PREVIOUS_SPELL); + public void registerKeyBindings(){ + ClientRegistry.registerKeyBinding(NEXT_SPELL); + ClientRegistry.registerKeyBinding(PREVIOUS_SPELL); } - + @Override - public void registerSpellHUD(){ + public void registerSpellHUD(){ MinecraftForge.EVENT_BUS.register(new GuiSpellDisplay(Minecraft.getMinecraft())); } - + @Override public void initMixedFontRenderer(){ mixedFontRenderer = new MixedFontRenderer(Minecraft.getMinecraft().gameSettings, new ResourceLocation("textures/font/ascii.png"), Minecraft.getMinecraft().renderEngine, false); } - + // SECTION Misc // =============================================================================================================== - + @Override - public void setToNumberSliderEntry(Property property) { + public void setToNumberSliderEntry(Property property){ property.setConfigEntryClass(NumberSliderEntry.class); } - + @Override - public World getTheWorld() { - return Minecraft.getMinecraft().theWorld; + public World getTheWorld(){ + return Minecraft.getMinecraft().world; } @Override public void playMovingSound(Entity entity, SoundEvent sound, float volume, float pitch, boolean repeat){ - Minecraft.getMinecraft().getSoundHandler().playSound(new MovingSoundEntity(entity, sound, volume, pitch, repeat)); + Minecraft.getMinecraft().getSoundHandler() + .playSound(new MovingSoundEntity(entity, sound, volume, pitch, repeat)); } - + // SECTION Items // =============================================================================================================== - + @Override public FontRenderer getFontRenderer(ItemStack stack){ - + Spell spell = Spells.none; - + if(stack.getItem() instanceof ItemWand){ spell = WandHelper.getCurrentSpell(stack); }else if(stack.getItem() instanceof ItemSpellBook || stack.getItem() instanceof ItemScroll){ spell = Spell.get(stack.getItemDamage()); } - - if(Minecraft.getMinecraft().thePlayer != null && Wizardry.settings.discoveryMode - && WizardData.get(Minecraft.getMinecraft().thePlayer) != null - && !Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode - && !WizardData.get(Minecraft.getMinecraft().thePlayer).hasSpellBeenDiscovered(spell)){ + + if(Minecraft.getMinecraft().player != null && Wizardry.settings.discoveryMode + && WizardData.get(Minecraft.getMinecraft().player) != null + && !Minecraft.getMinecraft().player.capabilities.isCreativeMode + && !WizardData.get(Minecraft.getMinecraft().player).hasSpellBeenDiscovered(spell)){ return mixedFontRenderer; } - + return null; } - + @Override public String getScrollDisplayName(ItemStack scroll){ // Displays [Empty slot] if spell is continuous. Spell spell = Spell.get(scroll.getItemDamage()); if(spell.isContinuous) spell = Spells.none; - - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - - boolean discovered = true; - // It seems that this method is called when the world is loading, before thePlayer has been initialised. - // If the player is null, the spell is assumed to be discovered. + + EntityPlayer player = Minecraft.getMinecraft().player; + + boolean discovered = true; + // It seems that this method is called when the world is loading, before thePlayer has been initialised. + // If the player is null, the spell is assumed to be discovered. if(player != null && Wizardry.settings.discoveryMode && !player.capabilities.isCreativeMode && WizardData.get(player) != null && !WizardData.get(player).hasSpellBeenDiscovered(spell)){ discovered = false; } - + if(discovered){ return I18n.format("item.wizardry:scroll.name", spell.getDisplayName()).trim(); }else{ - return I18n.format("item.wizardry:scroll.undiscovered.name", "#" + SpellGlyphData.getGlyphName(spell, player.worldObj) + "#").trim(); + return I18n.format("item.wizardry:scroll.undiscovered.name", + "#" + SpellGlyphData.getGlyphName(spell, player.world) + "#").trim(); } } - + @Override public double getConjuredBowDurability(ItemStack stack){ - EntityPlayer player = Minecraft.getMinecraft().thePlayer; + EntityPlayer player = Minecraft.getMinecraft().player; if(player.getActiveItemStack() == stack){ - return (double)(stack.getItemDamage() + (player.getItemInUseMaxCount()) ) / (double)stack.getMaxDamage(); + return (double)(stack.getItemDamage() + (player.getItemInUseMaxCount())) / (double)stack.getMaxDamage(); } return super.getConjuredBowDurability(stack); } - + // SECTION Particles // =============================================================================================================== - + @Override - public void spawnParticle(WizardryParticleType type, World world, double x, double y, double z, double velX, double velY, double velZ, int maxAge, float r, float g, float b, boolean doGravity, double radius){ - + public void spawnParticle(WizardryParticleType type, World world, double x, double y, double z, double velX, + double velY, double velZ, int maxAge, float r, float g, float b, boolean doGravity, double radius){ + // Colour values are now automatically clamped to between 0 and 1, as values outside this range seem to // cause strange effects in 1.10 (or more specifically, particles that are bright pink!) // TODO: This is a terrible dirty fix, but it'll do for now. Find a nicer way in future. - if(type != WizardryParticleType.MAGIC_FIRE) r = MathHelper.clamp_float(r, 0, 1); - g = MathHelper.clamp_float(g, 0, 1); - b = MathHelper.clamp_float(b, 0, 1); - + if(type != WizardryParticleType.MAGIC_FIRE) r = MathHelper.clamp(r, 0, 1); + g = MathHelper.clamp(g, 0, 1); + b = MathHelper.clamp(b, 0, 1); + switch(type){ - + case BLIZZARD: Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleBlizzard(world, maxAge, x, z, radius, y)); break; case BRIGHT_DUST: - Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleDust(world, x, y, z, velX, velY, velZ, r, g, b, false)); + Minecraft.getMinecraft().effectRenderer + .addEffect(new ParticleDust(world, x, y, z, velX, velY, velZ, r, g, b, false)); break; case DARK_MAGIC: - Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleDarkMagic(world, x, y, z, velX, velY, velZ, r, g, b)); + Minecraft.getMinecraft().effectRenderer + .addEffect(new ParticleDarkMagic(world, x, y, z, velX, velY, velZ, r, g, b)); break; case DUST: - Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleDust(world, x, y, z, velX, velY, velZ, r, g, b, true)); + Minecraft.getMinecraft().effectRenderer + .addEffect(new ParticleDust(world, x, y, z, velX, velY, velZ, r, g, b, true)); break; case ICE: - Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleIce(world, x, y, z, velX, velY, velZ, maxAge)); + Minecraft.getMinecraft().effectRenderer + .addEffect(new ParticleIce(world, x, y, z, velX, velY, velZ, maxAge)); break; case LEAF: - Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleLeaf(world, x, y, z, velX, velY, velZ, maxAge)); + Minecraft.getMinecraft().effectRenderer + .addEffect(new ParticleLeaf(world, x, y, z, velX, velY, velZ, maxAge)); break; case MAGIC_BUBBLE: - Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleGiantBubble(world, x, y, z, velX, velY, velZ)); + Minecraft.getMinecraft().effectRenderer + .addEffect(new ParticleGiantBubble(world, x, y, z, velX, velY, velZ)); break; case MAGIC_FIRE: - Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleMagicFlame(world, x, y, z, velX, velY, velZ, maxAge, r == 0 ? 1 + world.rand.nextFloat() : r)); + Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleMagicFlame(world, x, y, z, velX, velY, velZ, + maxAge, r == 0 ? 1 + world.rand.nextFloat() : r)); break; case PATH: - Minecraft.getMinecraft().effectRenderer.addEffect(new ParticlePath(world, x, y, z, velX, velY, velZ, r, g, b, maxAge)); + Minecraft.getMinecraft().effectRenderer + .addEffect(new ParticlePath(world, x, y, z, velX, velY, velZ, r, g, b, maxAge)); break; case SNOW: Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleSnow(world, x, y, z, velX, velY, velZ)); @@ -309,41 +323,46 @@ public class ClientProxy extends CommonProxy { Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleSpark(world, x, y, z, velX, velY, velZ)); break; case SPARKLE: - Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleSparkle(world, x, y, z, velX, velY, velZ, r, g, b, maxAge, doGravity)); + Minecraft.getMinecraft().effectRenderer + .addEffect(new ParticleSparkle(world, x, y, z, velX, velY, velZ, r, g, b, maxAge, doGravity)); break; case SPARKLE_ROTATING: - Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleRotatingSparkle(world, maxAge, x, z, radius, y, r, g, b)); + Minecraft.getMinecraft().effectRenderer + .addEffect(new ParticleRotatingSparkle(world, maxAge, x, z, radius, y, r, g, b)); break; default: break; } } - + @Override - public void spawnTornadoParticle(World world, double x, double y, double z, double velX, double velZ, double radius, int maxAge, IBlockState block, BlockPos pos){ - Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleTornado(world, maxAge, x, z, radius, y, velX, velZ, block).setBlockPos(pos));//, world.rand.nextInt(6))); - } - + public void spawnTornadoParticle(World world, double x, double y, double z, double velX, double velZ, double radius, + int maxAge, IBlockState block, BlockPos pos){ + Minecraft.getMinecraft().effectRenderer + .addEffect(new ParticleTornado(world, maxAge, x, z, radius, y, velX, velZ, block).setBlockPos(pos));// , + // world.rand.nextInt(6))); + } + // SECTION Packet Handlers // =============================================================================================================== - + @Override public void handleCastSpellPacket(PacketCastSpell.Message message){ - World world = Minecraft.getMinecraft().theWorld; + World world = Minecraft.getMinecraft().world; Entity caster = world.getEntityByID(message.casterID); Spell spell = Spell.get(message.spellID); // Should always be true if(caster instanceof EntityPlayer){ - + ((EntityPlayer)caster).setActiveHand(message.hand); - + // Duration isn't needed because it only ever affects things server-side, and anything that is // seen client-side gets synced elsewhere. spell.cast(world, (EntityPlayer)caster, message.hand, 0, message.modifiers); - + Source source = Source.OTHER; - + if(((EntityPlayer)caster).getHeldItem(message.hand) != null){ Item item = ((EntityPlayer)caster).getHeldItem(message.hand).getItem(); if(item instanceof ItemWand){ @@ -352,56 +371,59 @@ public class ClientProxy extends CommonProxy { source = Source.SCROLL; } } - + // No need to check if the spell succeeded, because the packet is only ever sent when it succeeds. // The handler for this event now deals with discovery. - MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Post((EntityPlayer)caster, spell, message.modifiers, source)); - + MinecraftForge.EVENT_BUS + .post(new SpellCastEvent.Post((EntityPlayer)caster, spell, message.modifiers, source)); + }else{ Wizardry.logger.warn("Recieved a PacketCastSpell, but the caster ID was not the ID of a player"); } } - + @Override public void handleCastContinuousSpellPacket(PacketCastContinuousSpell.Message message){ - - World world = Minecraft.getMinecraft().theWorld; + + World world = Minecraft.getMinecraft().world; Entity caster = world.getEntityByID(message.casterID); Spell spell = Spell.get(message.spellID); // Should always be true if(caster instanceof EntityPlayer){ - + WizardData data = WizardData.get((EntityPlayer)caster); - + if(data != null){ - if(data.isCasting()){ - WizardData.get((EntityPlayer)caster).stopCastingContinuousSpell(); - }else{ - WizardData.get((EntityPlayer)caster).startCastingContinuousSpell(spell, message.modifiers); - } - } + if(data.isCasting()){ + WizardData.get((EntityPlayer)caster).stopCastingContinuousSpell(); + }else{ + WizardData.get((EntityPlayer)caster).startCastingContinuousSpell(spell, message.modifiers); + } + } }else{ Wizardry.logger.warn("Recieved a PacketCastContinuousSpell, but the caster ID was not the ID of a player"); } } - + @Override public void handleNPCCastSpellPacket(PacketNPCCastSpell.Message message){ - World world = Minecraft.getMinecraft().theWorld; + World world = Minecraft.getMinecraft().world; Entity caster = world.getEntityByID(message.casterID); Entity target = message.targetID == -1 ? null : world.getEntityByID(message.targetID); Spell spell = Spell.get(message.spellID); // Should always be true if(caster instanceof EntityLiving){ - + if(target instanceof EntityLivingBase){ - + spell.cast(world, (EntityLiving)caster, message.hand, 0, (EntityLivingBase)target, message.modifiers); - // Again, no need to check if the spell succeeded, because the packet is only ever sent when it succeeds. - MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Post((EntityLiving)caster, spell, message.modifiers, Source.NPC)); + // Again, no need to check if the spell succeeded, because the packet is only ever sent when it + // succeeds. + MinecraftForge.EVENT_BUS + .post(new SpellCastEvent.Post((EntityLiving)caster, spell, message.modifiers, Source.NPC)); } - + if(caster instanceof ISpellCaster){ if(spell.isContinuous || spell instanceof None){ ((ISpellCaster)caster).setContinuousSpell(spell); @@ -412,55 +434,56 @@ public class ClientProxy extends CommonProxy { Wizardry.logger.warn("Recieved a PacketNPCCastSpell, but the caster ID was not the ID of an EntityLiving"); } } - + @Override public void handleTransportationPacket(PacketTransportation.Message message){ - - World world = Minecraft.getMinecraft().theWorld; + + World world = Minecraft.getMinecraft().world; Entity caster = world.getEntityByID(message.casterID); // Moved from when the packet is sent to when it is received; fixes the sound not playing in first person. caster.playSound(SoundEvents.BLOCK_PORTAL_TRAVEL, 1, 1); - - for(int i=0; i<20; i++){ + + for(int i = 0; i < 20; i++){ double radius = 1; - double angle = world.rand.nextDouble()*Math.PI*2; - double x = caster.posX + radius*Math.cos(angle); - double y = caster.getEntityBoundingBox().minY + world.rand.nextDouble()*2; - double z = caster.posZ + radius*Math.sin(angle); - Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleSparkle(world, x, y, z, 0, 0.02, 0, 0.6f, 1.0f, 0.6f, 80 + world.rand.nextInt(10))); + double angle = world.rand.nextDouble() * Math.PI * 2; + double x = caster.posX + radius * Math.cos(angle); + double y = caster.getEntityBoundingBox().minY + world.rand.nextDouble() * 2; + double z = caster.posZ + radius * Math.sin(angle); + Minecraft.getMinecraft().effectRenderer.addEffect( + new ParticleSparkle(world, x, y, z, 0, 0.02, 0, 0.6f, 1.0f, 0.6f, 80 + world.rand.nextInt(10))); } - for(int i=0; i<20; i++){ + for(int i = 0; i < 20; i++){ double radius = 1; - double angle = world.rand.nextDouble()*Math.PI*2; - double x = caster.posX + radius*Math.cos(angle); - double y = caster.getEntityBoundingBox().minY + world.rand.nextDouble()*2; - double z = caster.posZ + radius*Math.sin(angle); - world.spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, x, y, z, 0, 0.02, 0); + double angle = world.rand.nextDouble() * Math.PI * 2; + double x = caster.posX + radius * Math.cos(angle); + double y = caster.getEntityBoundingBox().minY + world.rand.nextDouble() * 2; + double z = caster.posZ + radius * Math.sin(angle); + world.spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, x, y, z, 0, 0.02, 0); } - for(int i=0; i<20; i++){ + for(int i = 0; i < 20; i++){ double radius = 1; - double angle = world.rand.nextDouble()*Math.PI*2; - double x = caster.posX + radius*Math.cos(angle); - double y = caster.getEntityBoundingBox().minY + world.rand.nextDouble()*2; - double z = caster.posZ + radius*Math.sin(angle); - world.spawnParticle(EnumParticleTypes.ENCHANTMENT_TABLE, x, y, z, 0, 0.02, 0); + double angle = world.rand.nextDouble() * Math.PI * 2; + double x = caster.posX + radius * Math.cos(angle); + double y = caster.getEntityBoundingBox().minY + world.rand.nextDouble() * 2; + double z = caster.posZ + radius * Math.sin(angle); + world.spawnParticle(EnumParticleTypes.ENCHANTMENT_TABLE, x, y, z, 0, 0.02, 0); } } - + @Override public void handlePlayerSyncPacket(Message message){ - - WizardData properties = WizardData.get(Minecraft.getMinecraft().thePlayer); - + + WizardData properties = WizardData.get(Minecraft.getMinecraft().player); + if(properties != null){ - + properties.spellsDiscovered = message.spellsDiscovered; - + if(message.selectedMinionID == -1){ properties.selectedMinion = null; }else{ - Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(message.selectedMinionID); - + Entity entity = Minecraft.getMinecraft().world.getEntityByID(message.selectedMinionID); + if(entity instanceof ISummonedCreature){ properties.selectedMinion = new WeakReference((ISummonedCreature)entity); }else{ @@ -469,92 +492,119 @@ public class ClientProxy extends CommonProxy { } } } - + @Override public void handleGlyphDataPacket(electroblob.wizardry.packet.PacketGlyphData.Message message){ - SpellGlyphData data = SpellGlyphData.get(Minecraft.getMinecraft().theWorld); - + SpellGlyphData data = SpellGlyphData.get(Minecraft.getMinecraft().world); + data.randomNames = new HashMap(); data.randomDescriptions = new HashMap(); - + for(Spell spell : Spell.getSpells(Spell.allSpells)){ // -1 because the none spell isn't included data.randomNames.put(spell, message.names.get(spell.id() - 1)); data.randomDescriptions.put(spell, message.descriptions.get(spell.id() - 1)); } } - + @Override - public void handleClairvoyancePacket(electroblob.wizardry.packet.PacketClairvoyance.Message message) { - Clairvoyance.spawnPathPaticles(Minecraft.getMinecraft().theWorld, message.path, message.durationMultiplier); + public void handleClairvoyancePacket(electroblob.wizardry.packet.PacketClairvoyance.Message message){ + Clairvoyance.spawnPathPaticles(Minecraft.getMinecraft().world, message.path, message.durationMultiplier); } - + // SECTION Rendering // =============================================================================================================== - - private static final ResourceLocation ICE_WRAITH_TEXTURE = new ResourceLocation(Wizardry.MODID, "textures/entity/ice_wraith.png"); - private static final ResourceLocation LIGHTNING_WRAITH_TEXTURE = new ResourceLocation(Wizardry.MODID, "textures/entity/lightning_wraith.png"); + + private static final ResourceLocation ICE_WRAITH_TEXTURE = new ResourceLocation(Wizardry.MODID, + "textures/entity/ice_wraith.png"); + private static final ResourceLocation LIGHTNING_WRAITH_TEXTURE = new ResourceLocation(Wizardry.MODID, + "textures/entity/lightning_wraith.png"); /** Static instance of the statue renderer, used to access the block breaking texture. */ public static RenderStatue renderStatue; - + @Override public void initialiseLayers(){ LayerStone.initialiseLayers(); } - + @Override public void registerRenderers(){ - + // Minions // Yet another advantage to the new system: turns out you don't even need to register the renderer if you // just want the vanilla one for the mob you're extending. - + // An anonymous class in a lambda expression! No point writing a separate class really, is there? - RenderingRegistry.registerEntityRenderingHandler(EntityLightningWraith.class, manager -> new RenderBlaze(manager){ - @Override - protected ResourceLocation getEntityTexture(EntityBlaze entity){ - return LIGHTNING_WRAITH_TEXTURE; - } - }); - + RenderingRegistry.registerEntityRenderingHandler(EntityLightningWraith.class, + manager -> new RenderBlaze(manager){ + @Override + protected ResourceLocation getEntityTexture(EntityBlaze entity){ + return LIGHTNING_WRAITH_TEXTURE; + } + }); + RenderingRegistry.registerEntityRenderingHandler(EntityIceWraith.class, manager -> new RenderBlaze(manager){ @Override protected ResourceLocation getEntityTexture(EntityBlaze entity){ return ICE_WRAITH_TEXTURE; } }); - + RenderingRegistry.registerEntityRenderingHandler(EntityIceGiant.class, RenderIceGiant::new); RenderingRegistry.registerEntityRenderingHandler(EntityPhoenix.class, RenderPhoenix::new); // Projectiles - RenderingRegistry.registerEntityRenderingHandler(EntityMagicMissile.class, manager -> new RenderMagicArrow(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/magic_missile.png"), false, 8.0, 4.0, 16, 9, false)); - RenderingRegistry.registerEntityRenderingHandler(EntityIceShard.class, manager -> new RenderMagicArrow(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/ice_shard.png"), false, 8.0, 2.0, 16, 5, false)); - RenderingRegistry.registerEntityRenderingHandler(EntityLightningArrow.class, manager -> new RenderMagicArrow(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/lightning_arrow.png"), true, 8.0, 2.0, 16, 5, false)); - RenderingRegistry.registerEntityRenderingHandler(EntityDart.class, manager -> new RenderMagicArrow(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/dart.png"), false, 8.0, 2.0, 16, 5, true)); - RenderingRegistry.registerEntityRenderingHandler(EntityIceLance.class, manager -> new RenderMagicArrow(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/ice_lance.png"), false, 16.0, 3.0, 22, 5, true)); + RenderingRegistry.registerEntityRenderingHandler(EntityMagicMissile.class, + manager -> new RenderMagicArrow(manager, + new ResourceLocation(Wizardry.MODID, "textures/entity/magic_missile.png"), false, 8.0, 4.0, 16, + 9, false)); + RenderingRegistry.registerEntityRenderingHandler(EntityIceShard.class, manager -> new RenderMagicArrow(manager, + new ResourceLocation(Wizardry.MODID, "textures/entity/ice_shard.png"), false, 8.0, 2.0, 16, 5, false)); + RenderingRegistry.registerEntityRenderingHandler(EntityLightningArrow.class, + manager -> new RenderMagicArrow(manager, + new ResourceLocation(Wizardry.MODID, "textures/entity/lightning_arrow.png"), true, 8.0, 2.0, 16, + 5, false)); + RenderingRegistry.registerEntityRenderingHandler(EntityDart.class, manager -> new RenderMagicArrow(manager, + new ResourceLocation(Wizardry.MODID, "textures/entity/dart.png"), false, 8.0, 2.0, 16, 5, true)); + RenderingRegistry.registerEntityRenderingHandler(EntityIceLance.class, manager -> new RenderMagicArrow(manager, + new ResourceLocation(Wizardry.MODID, "textures/entity/ice_lance.png"), false, 16.0, 3.0, 22, 5, true)); RenderingRegistry.registerEntityRenderingHandler(EntityForceArrow.class, RenderForceArrow::new); // Creatures - RenderingRegistry.registerEntityRenderingHandler(EntitySpiritWolf.class, manager -> new RenderSpiritWolf(manager, 0.5f)); - RenderingRegistry.registerEntityRenderingHandler(EntitySpiritHorse.class, manager -> new RenderSpiritHorse(manager, 0.5f)); + RenderingRegistry.registerEntityRenderingHandler(EntitySpiritWolf.class, + manager -> new RenderSpiritWolf(manager)); + RenderingRegistry.registerEntityRenderingHandler(EntitySpiritHorse.class, + manager -> new RenderSpiritHorse(manager)); RenderingRegistry.registerEntityRenderingHandler(EntityWizard.class, RenderWizard::new); RenderingRegistry.registerEntityRenderingHandler(EntityEvilWizard.class, RenderEvilWizard::new); RenderingRegistry.registerEntityRenderingHandler(EntityDecoy.class, RenderDecoy::new); // Throwables - RenderingRegistry.registerEntityRenderingHandler(EntitySparkBomb.class, manager -> new RenderProjectile(manager, 0.6f, new ResourceLocation(Wizardry.MODID, "textures/entity/spark_bomb.png"), false)); - RenderingRegistry.registerEntityRenderingHandler(EntityFirebomb.class, manager -> new RenderProjectile(manager, 0.6f, new ResourceLocation(Wizardry.MODID, "textures/items/firebomb.png"), false)); - RenderingRegistry.registerEntityRenderingHandler(EntityPoisonBomb.class, manager -> new RenderProjectile(manager, 0.6f, new ResourceLocation(Wizardry.MODID, "textures/items/poison_bomb.png"), false)); - RenderingRegistry.registerEntityRenderingHandler(EntityIceCharge.class, manager -> new RenderProjectile(manager, 0.6f, new ResourceLocation(Wizardry.MODID, "textures/entity/ice_charge.png"), false)); - RenderingRegistry.registerEntityRenderingHandler(EntityForceOrb.class, manager -> new RenderProjectile(manager, 0.7f, new ResourceLocation(Wizardry.MODID, "textures/entity/force_orb.png"), true)); - RenderingRegistry.registerEntityRenderingHandler(EntitySpark.class, manager -> new RenderProjectile(manager, 0.4f, new ResourceLocation(Wizardry.MODID, "textures/entity/spark.png"), true)); - RenderingRegistry.registerEntityRenderingHandler(EntityDarknessOrb.class, manager -> new RenderProjectile(manager, 0.6f, new ResourceLocation(Wizardry.MODID, "textures/entity/darkness_orb.png"), true)); - RenderingRegistry.registerEntityRenderingHandler(EntityFirebolt.class, manager -> new RenderProjectile(manager, 0.2f, new ResourceLocation(Wizardry.MODID, "textures/entity/firebolt.png"), false)); - RenderingRegistry.registerEntityRenderingHandler(EntityLightningDisc.class, manager -> new RenderLightningDisc(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/lightning_sigil.png"), 2.0f)); - RenderingRegistry.registerEntityRenderingHandler(EntitySmokeBomb.class, manager -> new RenderProjectile(manager, 0.6f, new ResourceLocation(Wizardry.MODID, "textures/items/smoke_bomb.png"), false)); + RenderingRegistry.registerEntityRenderingHandler(EntitySparkBomb.class, manager -> new RenderProjectile(manager, + 0.6f, new ResourceLocation(Wizardry.MODID, "textures/entity/spark_bomb.png"), false)); + RenderingRegistry.registerEntityRenderingHandler(EntityFirebomb.class, manager -> new RenderProjectile(manager, + 0.6f, new ResourceLocation(Wizardry.MODID, "textures/items/firebomb.png"), false)); + RenderingRegistry.registerEntityRenderingHandler(EntityPoisonBomb.class, + manager -> new RenderProjectile(manager, 0.6f, + new ResourceLocation(Wizardry.MODID, "textures/items/poison_bomb.png"), false)); + RenderingRegistry.registerEntityRenderingHandler(EntityIceCharge.class, manager -> new RenderProjectile(manager, + 0.6f, new ResourceLocation(Wizardry.MODID, "textures/entity/ice_charge.png"), false)); + RenderingRegistry.registerEntityRenderingHandler(EntityForceOrb.class, manager -> new RenderProjectile(manager, + 0.7f, new ResourceLocation(Wizardry.MODID, "textures/entity/force_orb.png"), true)); + RenderingRegistry.registerEntityRenderingHandler(EntitySpark.class, manager -> new RenderProjectile(manager, + 0.4f, new ResourceLocation(Wizardry.MODID, "textures/entity/spark.png"), true)); + RenderingRegistry.registerEntityRenderingHandler(EntityDarknessOrb.class, + manager -> new RenderProjectile(manager, 0.6f, + new ResourceLocation(Wizardry.MODID, "textures/entity/darkness_orb.png"), true)); + RenderingRegistry.registerEntityRenderingHandler(EntityFirebolt.class, manager -> new RenderProjectile(manager, + 0.2f, new ResourceLocation(Wizardry.MODID, "textures/entity/firebolt.png"), false)); + RenderingRegistry.registerEntityRenderingHandler(EntityLightningDisc.class, + manager -> new RenderLightningDisc(manager, + new ResourceLocation(Wizardry.MODID, "textures/entity/lightning_sigil.png"), 2.0f)); + RenderingRegistry.registerEntityRenderingHandler(EntitySmokeBomb.class, manager -> new RenderProjectile(manager, + 0.6f, new ResourceLocation(Wizardry.MODID, "textures/items/smoke_bomb.png"), false)); // Effects and constructs RenderingRegistry.registerEntityRenderingHandler(EntityArc.class, RenderArc::new); @@ -576,13 +626,19 @@ public class ClientProxy extends CommonProxy { RenderingRegistry.registerEntityRenderingHandler(EntityHailstorm.class, RenderBlank::new); // Runes on ground - RenderingRegistry.registerEntityRenderingHandler(EntityHealAura.class, manager -> new RenderSigil(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/healing_aura.png"), 5.0f, false)); - RenderingRegistry.registerEntityRenderingHandler(EntityFireSigil.class, manager -> new RenderSigil(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/fire_sigil.png"), 2.0f, true)); - RenderingRegistry.registerEntityRenderingHandler(EntityFrostSigil.class, manager -> new RenderSigil(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/frost_sigil.png"), 2.0f, true)); - RenderingRegistry.registerEntityRenderingHandler(EntityLightningSigil.class, manager -> new RenderSigil(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/lightning_sigil.png"), 2.0f, true)); - RenderingRegistry.registerEntityRenderingHandler(EntityFireRing.class, manager -> new RenderFireRing(manager, new ResourceLocation(Wizardry.MODID, "textures/entity/ring_of_fire.png"), 5.0f)); + RenderingRegistry.registerEntityRenderingHandler(EntityHealAura.class, manager -> new RenderSigil(manager, + new ResourceLocation(Wizardry.MODID, "textures/entity/healing_aura.png"), 5.0f, false)); + RenderingRegistry.registerEntityRenderingHandler(EntityFireSigil.class, manager -> new RenderSigil(manager, + new ResourceLocation(Wizardry.MODID, "textures/entity/fire_sigil.png"), 2.0f, true)); + RenderingRegistry.registerEntityRenderingHandler(EntityFrostSigil.class, manager -> new RenderSigil(manager, + new ResourceLocation(Wizardry.MODID, "textures/entity/frost_sigil.png"), 2.0f, true)); + RenderingRegistry.registerEntityRenderingHandler(EntityLightningSigil.class, manager -> new RenderSigil(manager, + new ResourceLocation(Wizardry.MODID, "textures/entity/lightning_sigil.png"), 2.0f, true)); + RenderingRegistry.registerEntityRenderingHandler(EntityFireRing.class, manager -> new RenderFireRing(manager, + new ResourceLocation(Wizardry.MODID, "textures/entity/ring_of_fire.png"), 5.0f)); RenderingRegistry.registerEntityRenderingHandler(EntityDecay.class, RenderDecay::new); - RenderingRegistry.registerEntityRenderingHandler(EntityLightningPulse.class, manager -> new RenderLightningPulse(manager, 8.0f)); + RenderingRegistry.registerEntityRenderingHandler(EntityLightningPulse.class, + manager -> new RenderLightningPulse(manager, 8.0f)); // TESRs ClientRegistry.bindTileEntitySpecialRenderer(TileEntityArcaneWorkbench.class, new RenderArcaneWorkbench()); diff --git a/src/main/java/electroblob/wizardry/client/EntityNameEntry.java b/src/main/java/electroblob/wizardry/client/EntityNameEntry.java index 3221e189..597df57e 100644 --- a/src/main/java/electroblob/wizardry/client/EntityNameEntry.java +++ b/src/main/java/electroblob/wizardry/client/EntityNameEntry.java @@ -1,76 +1,81 @@ package electroblob.wizardry.client; -import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; +import java.util.stream.Collectors; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; -import net.minecraft.entity.EntityList; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.client.config.GuiButtonExt; import net.minecraftforge.fml.client.config.GuiEditArray; import net.minecraftforge.fml.client.config.GuiEditArrayEntries; import net.minecraftforge.fml.client.config.GuiEditArrayEntries.StringEntry; import net.minecraftforge.fml.client.config.GuiSelectString; import net.minecraftforge.fml.client.config.IConfigElement; +import net.minecraftforge.fml.common.registry.EntityEntry; +import net.minecraftforge.fml.common.registry.ForgeRegistries; -/** [NYI] Intended as a way of choosing entities by name from all those currently registered, within the config file, so - * that users don't have to look up the entity IDs. I can't get this to work correctly at the moment. */ +/** + * [NYI] Intended as a way of choosing entities by name from all those currently registered, within the config file, so + * that users don't have to look up the entity IDs. I can't get this to work correctly at the moment. + */ public class EntityNameEntry extends StringEntry { protected final GuiButtonExt btnValue; protected Object entityClass; - public EntityNameEntry(GuiEditArray owningScreen, GuiEditArrayEntries owningEntryList, IConfigElement configElement, Object value) - { - super(owningScreen, owningEntryList, configElement, value); - this.btnValue = new GuiButtonExt(0, 0, 0, owningEntryList.controlWidth, 18, I18n.format(this.textFieldValue.getText())); - //this.btnValue.enabled = owningScreen.enabled; - } - - @Override - public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected) - { - //super.drawEntry(slotIndex, x, y, listWidth, slotHeight, tessellator, mouseX, mouseY, isSelected); - this.btnValue.xPosition = listWidth / 4; - this.btnValue.yPosition = y; + public EntityNameEntry(GuiEditArray owningScreen, GuiEditArrayEntries owningEntryList, IConfigElement configElement, + Object value){ + super(owningScreen, owningEntryList, configElement, value); + this.btnValue = new GuiButtonExt(0, 0, 0, owningEntryList.controlWidth, 18, + I18n.format(this.textFieldValue.getText())); + // this.btnValue.enabled = owningScreen.enabled; + } - String trans = I18n.format(this.textFieldValue.getText()); - if (!trans.equals(this.textFieldValue.getText())) - this.btnValue.displayString = trans; - else - this.btnValue.displayString = this.textFieldValue.getText(); - //btnValue.packedFGColour = value ? GuiUtils.getColorCode('2', true) : GuiUtils.getColorCode('4', true); + @Override + public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, + boolean isSelected){ + // super.drawEntry(slotIndex, x, y, listWidth, slotHeight, tessellator, mouseX, mouseY, isSelected); + this.btnValue.xPosition = listWidth / 4; + this.btnValue.yPosition = y; - this.btnValue.drawButton(owningEntryList.getMC(), mouseX, mouseY); - } + String trans = I18n.format(this.textFieldValue.getText()); + if(!trans.equals(this.textFieldValue.getText())) + this.btnValue.displayString = trans; + else + this.btnValue.displayString = this.textFieldValue.getText(); + // btnValue.packedFGColour = value ? GuiUtils.getColorCode('2', true) : GuiUtils.getColorCode('4', true); - @Override - public boolean mousePressed(int index, int x, int y, int mouseEvent, int relativeX, int relativeY) - { - if (this.btnValue.mousePressed(owningEntryList.getMC(), x, y)) - { - btnValue.playPressSound(owningEntryList.getMC().getSoundHandler()); - // Some sort of type incompatiblity meant that I had to do this first. - Map map = new HashMap(EntityList.CLASS_TO_NAME); - Minecraft.getMinecraft().displayGuiScreen(new GuiSelectString(this.owningScreen, configElement, index, map, this.getValue(), true)); - owningEntryList.recalculateState(); - return true; - } + this.btnValue.drawButton(owningEntryList.getMC(), mouseX, mouseY); + } - return super.mousePressed(index, x, y, mouseEvent, relativeX, relativeY); - } + @Override + public boolean mousePressed(int index, int x, int y, int mouseEvent, int relativeX, int relativeY){ + if(this.btnValue.mousePressed(owningEntryList.getMC(), x, y)){ + btnValue.playPressSound(owningEntryList.getMC().getSoundHandler()); + // Goodness only knows if this works, but the class is unimplemented right now so it doesn't really matter. + Map map = ForgeRegistries.ENTITIES.getEntries().stream().collect( + Collectors., Object, String>toMap(e -> e.getValue().getClass(), + e -> e.getValue().getName())); + Minecraft.getMinecraft().displayGuiScreen( + new GuiSelectString(this.owningScreen, configElement, index, map, this.getValue(), true)); + owningEntryList.recalculateState(); + return true; + } - @Override - public void mouseReleased(int index, int x, int y, int mouseEvent, int relativeX, int relativeY) - { - this.btnValue.mouseReleased(x, y); - super.mouseReleased(index, x, y, mouseEvent, relativeX, relativeY); - } + return super.mousePressed(index, x, y, mouseEvent, relativeX, relativeY); + } - @Override - public Object getValue() - { - return this.textFieldValue.getText(); - } + @Override + public void mouseReleased(int index, int x, int y, int mouseEvent, int relativeX, int relativeY){ + this.btnValue.mouseReleased(x, y); + super.mouseReleased(index, x, y, mouseEvent, relativeX, relativeY); + } + + @Override + public Object getValue(){ + return this.textFieldValue.getText(); + } } diff --git a/src/main/java/electroblob/wizardry/client/GuiArcaneWorkbench.java b/src/main/java/electroblob/wizardry/client/GuiArcaneWorkbench.java index 43f0470a..2455ee8a 100644 --- a/src/main/java/electroblob/wizardry/client/GuiArcaneWorkbench.java +++ b/src/main/java/electroblob/wizardry/client/GuiArcaneWorkbench.java @@ -30,14 +30,15 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; public class GuiArcaneWorkbench extends GuiContainer { private GuiButton applyBtn; - private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, "textures/gui/arcane_workbench.png"); + private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, + "textures/gui/arcane_workbench.png"); private IInventory playerInventory; private IInventory arcaneWorkbenchInventory; private final int tooltipWidth = 164; - public GuiArcaneWorkbench(InventoryPlayer invPlayer, TileEntityArcaneWorkbench entity) { + public GuiArcaneWorkbench(InventoryPlayer invPlayer, TileEntityArcaneWorkbench entity){ super(new ContainerArcaneWorkbench(invPlayer, entity)); this.playerInventory = invPlayer; this.arcaneWorkbenchInventory = entity; @@ -49,12 +50,13 @@ public class GuiArcaneWorkbench extends GuiContainer { public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_){ // Tests if there is a wand in the workbench and edits the positioning accordingly - if(this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getHasStack() && this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getStack().getItem() instanceof ItemWand){ - guiLeft = (this.width - this.xSize - tooltipWidth)/2; - this.applyBtn.xPosition = (this.width - tooltipWidth)/2 + 48; + if(this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getHasStack() && this.inventorySlots + .getSlot(ContainerArcaneWorkbench.WAND_SLOT).getStack().getItem() instanceof ItemWand){ + guiLeft = (this.width - this.xSize - tooltipWidth) / 2; + this.applyBtn.xPosition = (this.width - tooltipWidth) / 2 + 48; }else{ - guiLeft = (this.width - this.xSize)/2; - this.applyBtn.xPosition = this.width/2 + 48; + guiLeft = (this.width - this.xSize) / 2; + this.applyBtn.xPosition = this.width / 2 + 48; } if(this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getHasStack()){ @@ -67,10 +69,10 @@ public class GuiArcaneWorkbench extends GuiContainer { } @Override - public void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { + public void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY){ GlStateManager.pushAttrib(); - + GlStateManager.color(1F, 1F, 1F, 1F); Minecraft.getMinecraft().renderEngine.bindTexture(texture); @@ -78,55 +80,58 @@ public class GuiArcaneWorkbench extends GuiContainer { drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); // Changing slots - for(int i=0; i=0 && slot.yDisplayPosition >= 0) - this.drawTexturedModalRect(guiLeft + slot.xDisplayPosition - 10, guiTop + slot.yDisplayPosition - 10, - 0, 220, 36, 36); + if(slot.xPos >= 0 && slot.yPos >= 0) + this.drawTexturedModalRect(guiLeft + slot.xPos - 10, guiTop + slot.yPos - 10, 0, 220, 36, 36); } // Tooltip only drawn if there is a wand - if(this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getHasStack() && this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getStack().getItem() instanceof ItemWand){ + if(this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getHasStack() && this.inventorySlots + .getSlot(ContainerArcaneWorkbench.WAND_SLOT).getStack().getItem() instanceof ItemWand){ // Tooltip box drawTexturedModalRect(guiLeft + xSize, guiTop, xSize, 0, 256 - xSize - 4, ySize); - drawTexturedModalRect(guiLeft + 252, guiTop, xSize + 4, 0, tooltipWidth - 2*(256 - xSize - 4), ySize); - drawTexturedModalRect(guiLeft + xSize + tooltipWidth - (256 - xSize - 4), guiTop, xSize + 4, 0, 256 - xSize - 4, ySize); + drawTexturedModalRect(guiLeft + 252, guiTop, xSize + 4, 0, tooltipWidth - 2 * (256 - xSize - 4), ySize); + drawTexturedModalRect(guiLeft + xSize + tooltipWidth - (256 - xSize - 4), guiTop, xSize + 4, 0, + 256 - xSize - 4, ySize); ItemStack wand = this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getStack(); Spell[] spells = WandHelper.getSpells(wand); - int i=0; + int i = 0; for(Spell spell : spells){ boolean discovered = true; - if(!this.mc.thePlayer.capabilities.isCreativeMode && WizardData.get(this.mc.thePlayer) != null){ - discovered = WizardData.get(this.mc.thePlayer).hasSpellBeenDiscovered(spell); + if(!this.mc.player.capabilities.isCreativeMode && WizardData.get(this.mc.player) != null){ + discovered = WizardData.get(this.mc.player).hasSpellBeenDiscovered(spell); } // As of Wizardry 1.2, the icons have been split off into their own texture files to allow for add-on // mods to add their own. - Minecraft.getMinecraft().renderEngine.bindTexture(discovered ? spell.element.getIcon() : Element.MAGIC.getIcon()); + Minecraft.getMinecraft().renderEngine + .bindTexture(discovered ? spell.element.getIcon() : Element.MAGIC.getIcon()); // Renders the little element icon - WizardryUtilities.drawTexturedRect(guiLeft + xSize + 5, guiTop + 34 + 10*i++, 8, 8); + WizardryUtilities.drawTexturedRect(guiLeft + xSize + 5, guiTop + 34 + 10 * i++, 8, 8); } int x = 0; - int y = guiTop + 50 + spells.length*10; - + int y = guiTop + 50 + spells.length * 10; + // Look how much shorter this is with the WandHelper class! for(Item item : WandHelper.getSpecialUpgrades()){ - + int level = WandHelper.getUpgradeLevel(wand, item); - + if(level > 0){ ItemStack stack = new ItemStack(item, level); GlStateManager.enableDepth(); this.itemRender.renderItemAndEffectIntoGUI(stack, guiLeft + xSize + 6 + x, y); - this.itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, stack, guiLeft + xSize + 6 + x, y, null); + this.itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, stack, guiLeft + xSize + 6 + x, y, + null); x += 18; GlStateManager.disableDepth(); } @@ -134,26 +139,33 @@ public class GuiArcaneWorkbench extends GuiContainer { } Minecraft.getMinecraft().renderEngine.bindTexture(texture); - + // Fixes the bug that caused the slot hightlight to render opaque. I don't know why it works, it just works! GlStateManager.disableBlend(); GlStateManager.enableAlpha(); - + GlStateManager.popAttrib(); } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY){ - this.fontRendererObj.drawString(this.arcaneWorkbenchInventory.hasCustomName() ? this.arcaneWorkbenchInventory.getName() : I18n.format(this.arcaneWorkbenchInventory.getName()), 8, 6, 4210752); - this.fontRendererObj.drawString(this.playerInventory.hasCustomName() ? this.playerInventory.getName() : I18n.format(this.playerInventory.getName()), 8, this.ySize - 96 + 2, 4210752); + this.fontRendererObj + .drawString(this.arcaneWorkbenchInventory.hasCustomName() ? this.arcaneWorkbenchInventory.getName() + : I18n.format(this.arcaneWorkbenchInventory.getName()), 8, 6, 4210752); + this.fontRendererObj.drawString(this.playerInventory.hasCustomName() ? this.playerInventory.getName() + : I18n.format(this.playerInventory.getName()), 8, this.ySize - 96 + 2, 4210752); - if(this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getHasStack() && this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getStack().getItem() instanceof ItemWand){ + if(this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getHasStack() && this.inventorySlots + .getSlot(ContainerArcaneWorkbench.WAND_SLOT).getStack().getItem() instanceof ItemWand){ ItemStack wand = this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getStack(); this.fontRendererObj.drawStringWithShadow("\u00A7f" + wand.getDisplayName(), xSize + 6, 6, 0); - this.fontRendererObj.drawStringWithShadow("\u00A77" + I18n.format("container.wizardry:arcane_workbench.mana") + " " + (wand.getMaxDamage() - wand.getItemDamage()) + "/" + wand.getMaxDamage(), xSize + 6, 20, 0); + this.fontRendererObj.drawStringWithShadow( + "\u00A77" + I18n.format("container.wizardry:arcane_workbench.mana") + " " + + (wand.getMaxDamage() - wand.getItemDamage()) + "/" + wand.getMaxDamage(), + xSize + 6, 20, 0); Spell[] spells = WandHelper.getSpells(wand); @@ -163,29 +175,31 @@ public class GuiArcaneWorkbench extends GuiContainer { boolean discovered = true; - if(!this.mc.thePlayer.capabilities.isCreativeMode && WizardData.get(this.mc.thePlayer) != null){ - discovered = WizardData.get(this.mc.thePlayer).hasSpellBeenDiscovered(spell); + if(!this.mc.player.capabilities.isCreativeMode && WizardData.get(this.mc.player) != null){ + discovered = WizardData.get(this.mc.player).hasSpellBeenDiscovered(spell); } if(discovered){ this.fontRendererObj.drawStringWithShadow(spell.getDisplayNameWithFormatting(), xSize + 16, y, 0); }else{ - this.mc.standardGalacticFontRenderer.drawStringWithShadow("\u00A79" + SpellGlyphData.getGlyphName(spell, this.mc.theWorld), xSize + 16, y, 0); + this.mc.standardGalacticFontRenderer.drawStringWithShadow( + "\u00A79" + SpellGlyphData.getGlyphName(spell, this.mc.world), xSize + 16, y, 0); } y += 10; } - + if(WandHelper.getTotalUpgrades(wand) > 0){ - - this.fontRendererObj.drawStringWithShadow("\u00A7f" + I18n.format("container.wizardry:arcane_workbench.upgrades"), xSize + 6, y + 6, 0); - + + this.fontRendererObj.drawStringWithShadow( + "\u00A7f" + I18n.format("container.wizardry:arcane_workbench.upgrades"), xSize + 6, y + 6, 0); + int x = 0; - y = 50 + spells.length*10; + y = 50 + spells.length * 10; // Wand upgrade tooltips for(Item item : WandHelper.getSpecialUpgrades()){ - + int level = WandHelper.getUpgradeLevel(wand, item); - + if(level > 0){ // The javadoc for isPointInRegion is ambiguous; what it means is that the REGION is // relative to the GUI but the POINT isn't. @@ -202,12 +216,12 @@ public class GuiArcaneWorkbench extends GuiContainer { @Override public void initGui(){ - this.mc.thePlayer.openContainer = this.inventorySlots; + this.mc.player.openContainer = this.inventorySlots; this.guiLeft = (this.width - this.xSize) / 2; this.guiTop = (this.height - this.ySize) / 2; Keyboard.enableRepeatEvents(true); this.buttonList.clear(); - this.buttonList.add(this.applyBtn = new GuiButtonApply(0, this.width/2 + 48, this.height/2 + 3)); + this.buttonList.add(this.applyBtn = new GuiButtonApply(0, this.width / 2 + 48, this.height / 2 + 3)); } @Override diff --git a/src/main/java/electroblob/wizardry/client/GuiButtonApply.java b/src/main/java/electroblob/wizardry/client/GuiButtonApply.java index fd54d344..dc6223e7 100644 --- a/src/main/java/electroblob/wizardry/client/GuiButtonApply.java +++ b/src/main/java/electroblob/wizardry/client/GuiButtonApply.java @@ -10,32 +10,34 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) class GuiButtonApply extends GuiButton { - public GuiButtonApply(int id, int x, int y){ - - super(id, x, y, 32, 16, I18n.format("container.wizardry:arcane_workbench.apply")); - } + public GuiButtonApply(int id, int x, int y){ + + super(id, x, y, 32, 16, I18n.format("container.wizardry:arcane_workbench.apply")); + } @Override - public void drawButton(Minecraft minecraft, int mouseX, int mouseY){ - - // Whether the button is highlighted - this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; - - int k = 36; - int l = 220; - int colour = 14737632; - - if(this.enabled){ - if(this.hovered){ - k += this.width*2; - colour = 16777120; - } - }else{ - k += this.width; - colour = 10526880; - } - - WizardryUtilities.drawTexturedRect(this.xPosition, this.yPosition, k, l, this.width, this.height, 256, 256); - this.drawCenteredString(minecraft.fontRendererObj, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, colour); - } + public void drawButton(Minecraft minecraft, int mouseX, int mouseY){ + + // Whether the button is highlighted + this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width + && mouseY < this.yPosition + this.height; + + int k = 36; + int l = 220; + int colour = 14737632; + + if(this.enabled){ + if(this.hovered){ + k += this.width * 2; + colour = 16777120; + } + }else{ + k += this.width; + colour = 10526880; + } + + WizardryUtilities.drawTexturedRect(this.xPosition, this.yPosition, k, l, this.width, this.height, 256, 256); + this.drawCenteredString(minecraft.fontRendererObj, this.displayString, this.xPosition + this.width / 2, + this.yPosition + (this.height - 8) / 2, colour); + } } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/client/GuiButtonInvisible.java b/src/main/java/electroblob/wizardry/client/GuiButtonInvisible.java index 3cc2f12e..a839b0bc 100644 --- a/src/main/java/electroblob/wizardry/client/GuiButtonInvisible.java +++ b/src/main/java/electroblob/wizardry/client/GuiButtonInvisible.java @@ -8,16 +8,17 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) class GuiButtonInvisible extends GuiButton { - public GuiButtonInvisible(int id, int x, int y, int width, int height){ - - super(id, x, y, width, height, ""); - } + public GuiButtonInvisible(int id, int x, int y, int width, int height){ + + super(id, x, y, width, height, ""); + } /** - * Draws this button to the screen. - */ - public void drawButton(Minecraft par1Minecraft, int par2, int par3){ - this.hovered = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; - } - + * Draws this button to the screen. + */ + public void drawButton(Minecraft par1Minecraft, int par2, int par3){ + this.hovered = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width + && par3 < this.yPosition + this.height; + } + } diff --git a/src/main/java/electroblob/wizardry/client/GuiButtonTurnPage.java b/src/main/java/electroblob/wizardry/client/GuiButtonTurnPage.java index b4b7e68b..a9fae985 100644 --- a/src/main/java/electroblob/wizardry/client/GuiButtonTurnPage.java +++ b/src/main/java/electroblob/wizardry/client/GuiButtonTurnPage.java @@ -12,41 +12,37 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) class GuiButtonTurnPage extends GuiButton { - /** True for pointing right (next page), false for pointing left (previous page). */ - private final boolean nextPage; - - private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, "textures/gui/handbook.png"); + /** True for pointing right (next page), false for pointing left (previous page). */ + private final boolean nextPage; - public GuiButtonTurnPage(int id, int x, int y, boolean isNextPage) - { - super(id, x, y, 23, 13, ""); - this.nextPage = isNextPage; - } + private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, "textures/gui/handbook.png"); + + public GuiButtonTurnPage(int id, int x, int y, boolean isNextPage){ + super(id, x, y, 23, 13, ""); + this.nextPage = isNextPage; + } /** - * Draws this button to the screen. - */ - public void drawButton(Minecraft par1Minecraft, int par2, int par3) - { - if (this.visible) - { - boolean flag = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - par1Minecraft.getTextureManager().bindTexture(texture); - int k = 0; - int l = 192; + * Draws this button to the screen. + */ + public void drawButton(Minecraft par1Minecraft, int par2, int par3){ + if(this.visible){ + boolean flag = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width + && par3 < this.yPosition + this.height; + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + par1Minecraft.getTextureManager().bindTexture(texture); + int k = 0; + int l = 192; - if (flag) - { - k += 23; - } + if(flag){ + k += 23; + } - if (!this.nextPage) - { - l += 13; - } + if(!this.nextPage){ + l += 13; + } - WizardryUtilities.drawTexturedRect(this.xPosition, this.yPosition, k, l, 23, 13, 288, 256); - } - } + WizardryUtilities.drawTexturedRect(this.xPosition, this.yPosition, k, l, 23, 13, 288, 256); + } + } } diff --git a/src/main/java/electroblob/wizardry/client/GuiConfigWizardry.java b/src/main/java/electroblob/wizardry/client/GuiConfigWizardry.java index 587a8603..68f375d9 100644 --- a/src/main/java/electroblob/wizardry/client/GuiConfigWizardry.java +++ b/src/main/java/electroblob/wizardry/client/GuiConfigWizardry.java @@ -18,63 +18,63 @@ import net.minecraftforge.fml.client.config.IConfigElement; public class GuiConfigWizardry extends GuiConfig { public GuiConfigWizardry(GuiScreen parent){ - super(parent, getConfigEntries(), Wizardry.MODID, false, false, Wizardry.NAME + " - " + I18n.format("config.wizardry.title.general")); - //this.titleLine2 = "File location: " + Wizardry.config.getConfigFile().getAbsolutePath(); + super(parent, getConfigEntries(), Wizardry.MODID, false, false, + Wizardry.NAME + " - " + I18n.format("config.wizardry.title.general")); + // this.titleLine2 = "File location: " + Wizardry.config.getConfigFile().getAbsolutePath(); } - + private static List getConfigEntries(){ List configList = new ArrayList(1); - configList.add(new DummyCategoryElement("spellsConfig", "config.wizardry.category." + Settings.SPELLS_CATEGORY, SpellsCategory.class)); - configList.add(new DummyCategoryElement("resistancesConfig", "config.wizardry.category." + Settings.RESISTANCES_CATEGORY, ResistancesCategory.class)); - configList.addAll(new ConfigElement(Wizardry.settings.getConfigCategory(Configuration.CATEGORY_GENERAL)).getChildElements()); + configList.add(new DummyCategoryElement("spellsConfig", "config.wizardry.category." + Settings.SPELLS_CATEGORY, + SpellsCategory.class)); + configList.add(new DummyCategoryElement("resistancesConfig", + "config.wizardry.category." + Settings.RESISTANCES_CATEGORY, ResistancesCategory.class)); + configList.addAll(new ConfigElement(Wizardry.settings.getConfigCategory(Configuration.CATEGORY_GENERAL)) + .getChildElements()); return configList; } - + /** Spells category of the config gui. This adds a button which opens up the spells category config. */ - public static class SpellsCategory extends CategoryEntry - { - public SpellsCategory(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop) - { - super(owningScreen, owningEntryList, prop); - } - - @Override - protected GuiScreen buildChildScreen() - { - // This GuiConfig object specifies the configID of the object and as such will force-save when it is closed. - // The parent GuiConfig object's entryList will also be refreshed to reflect the changes. - GuiConfig spellsMenu = new GuiConfig(this.owningScreen, - (new ConfigElement(Wizardry.settings.getConfigCategory(Settings.SPELLS_CATEGORY))).getChildElements(), - this.owningScreen.modID, Settings.SPELLS_CATEGORY, false, false, - Wizardry.NAME + " - " + I18n.format("config.wizardry.title." + Settings.SPELLS_CATEGORY)); - - spellsMenu.titleLine2 = I18n.format("config.wizardry.subtitle." + Settings.SPELLS_CATEGORY); - - return spellsMenu; - } - } - - /** Resistances category of the config gui. */ - public static class ResistancesCategory extends CategoryEntry - { - public ResistancesCategory(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop) - { - super(owningScreen, owningEntryList, prop); - } - - @Override - protected GuiScreen buildChildScreen() - { - // This GuiConfig object specifies the configID of the object and as such will force-save when it is closed. - // The parent GuiConfig object's entryList will also be refreshed to reflect the changes. - GuiConfig idsMenu = new GuiConfig(this.owningScreen, - (new ConfigElement(Wizardry.settings.getConfigCategory(Settings.RESISTANCES_CATEGORY))).getChildElements(), - this.owningScreen.modID, Settings.RESISTANCES_CATEGORY, false, false, - Wizardry.NAME + " - " + I18n.format("config.wizardry.title." + Settings.RESISTANCES_CATEGORY)); - - idsMenu.titleLine2 = I18n.format("config.wizardry.subtitle." + Settings.RESISTANCES_CATEGORY); - - return idsMenu; - } - } + public static class SpellsCategory extends CategoryEntry { + public SpellsCategory(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop){ + super(owningScreen, owningEntryList, prop); + } + + @Override + protected GuiScreen buildChildScreen(){ + // This GuiConfig object specifies the configID of the object and as such will force-save when it is closed. + // The parent GuiConfig object's entryList will also be refreshed to reflect the changes. + GuiConfig spellsMenu = new GuiConfig(this.owningScreen, + (new ConfigElement(Wizardry.settings.getConfigCategory(Settings.SPELLS_CATEGORY))) + .getChildElements(), + this.owningScreen.modID, Settings.SPELLS_CATEGORY, false, false, + Wizardry.NAME + " - " + I18n.format("config.wizardry.title." + Settings.SPELLS_CATEGORY)); + + spellsMenu.titleLine2 = I18n.format("config.wizardry.subtitle." + Settings.SPELLS_CATEGORY); + + return spellsMenu; + } + } + + /** Resistances category of the config gui. */ + public static class ResistancesCategory extends CategoryEntry { + public ResistancesCategory(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop){ + super(owningScreen, owningEntryList, prop); + } + + @Override + protected GuiScreen buildChildScreen(){ + // This GuiConfig object specifies the configID of the object and as such will force-save when it is closed. + // The parent GuiConfig object's entryList will also be refreshed to reflect the changes. + GuiConfig idsMenu = new GuiConfig(this.owningScreen, + (new ConfigElement(Wizardry.settings.getConfigCategory(Settings.RESISTANCES_CATEGORY))) + .getChildElements(), + this.owningScreen.modID, Settings.RESISTANCES_CATEGORY, false, false, + Wizardry.NAME + " - " + I18n.format("config.wizardry.title." + Settings.RESISTANCES_CATEGORY)); + + idsMenu.titleLine2 = I18n.format("config.wizardry.subtitle." + Settings.RESISTANCES_CATEGORY); + + return idsMenu; + } + } } diff --git a/src/main/java/electroblob/wizardry/client/GuiPortableCrafting.java b/src/main/java/electroblob/wizardry/client/GuiPortableCrafting.java index d4f8e225..c31f5fa1 100644 --- a/src/main/java/electroblob/wizardry/client/GuiPortableCrafting.java +++ b/src/main/java/electroblob/wizardry/client/GuiPortableCrafting.java @@ -11,29 +11,27 @@ import net.minecraft.world.World; /** Crafting table GUI that doesn't require a crafting table container object. */ public class GuiPortableCrafting extends GuiContainer { - - private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation("textures/gui/container/crafting_table.png"); - - public GuiPortableCrafting(InventoryPlayer p_i1084_1_, World p_i1084_2_, BlockPos pos) - { - super(new ContainerWorkbench(p_i1084_1_, p_i1084_2_, pos)); - } - /** - * Draw the foreground layer for the GuiContainer (everything in front of the items) - */ - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) - { - this.fontRendererObj.drawString(I18n.format("container.crafting"), 28, 6, 4210752); - this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752); - } + private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation( + "textures/gui/container/crafting_table.png"); - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) - { - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(craftingTableGuiTextures); - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); - } + public GuiPortableCrafting(InventoryPlayer p_i1084_1_, World p_i1084_2_, BlockPos pos){ + super(new ContainerWorkbench(p_i1084_1_, p_i1084_2_, pos)); + } + + /** + * Draw the foreground layer for the GuiContainer (everything in front of the items) + */ + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_){ + this.fontRendererObj.drawString(I18n.format("container.crafting"), 28, 6, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + } + + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_){ + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(craftingTableGuiTextures); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + } } diff --git a/src/main/java/electroblob/wizardry/client/GuiSpellBook.java b/src/main/java/electroblob/wizardry/client/GuiSpellBook.java index c7a90cb2..5737db8b 100644 --- a/src/main/java/electroblob/wizardry/client/GuiSpellBook.java +++ b/src/main/java/electroblob/wizardry/client/GuiSpellBook.java @@ -15,113 +15,98 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; public class GuiSpellBook extends GuiScreen { - + private int xSize, ySize; private Spell spell; - + private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, "textures/gui/spellbook.png"); - - public GuiSpellBook(Spell spell) { + + public GuiSpellBook(Spell spell){ super(); xSize = 288; ySize = 180; this.spell = spell; } - + /** - * Draws the screen and all the components in it. - */ - public void drawScreen(int par1, int par2, float par3) { - - int xPos = this.width/2 - xSize/2; - int yPos = this.height/2 - this.ySize/2; - - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - - boolean discovered = true; + * Draws the screen and all the components in it. + */ + public void drawScreen(int par1, int par2, float par3){ + + int xPos = this.width / 2 - xSize / 2; + int yPos = this.height / 2 - this.ySize / 2; + + EntityPlayer player = Minecraft.getMinecraft().player; + + boolean discovered = true; if(Wizardry.settings.discoveryMode && !player.capabilities.isCreativeMode && WizardData.get(player) != null && !WizardData.get(player).hasSpellBeenDiscovered(spell)){ discovered = false; } - // Draws spell illustration on opposite page, underneath the book so it shows through the hole. + // Draws spell illustration on opposite page, underneath the book so it shows through the hole. Minecraft.getMinecraft().renderEngine.bindTexture(discovered ? spell.getIcon() : Spells.none.getIcon()); WizardryUtilities.drawTexturedRect(xPos + 145, yPos + 20, 0, 0, 128, 128, 128, 128); - - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - WizardryUtilities.drawTexturedRect(xPos, yPos, 0, 0, xSize, ySize, xSize, 256); - - super.drawScreen(par1, par2, par3); - + + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + WizardryUtilities.drawTexturedRect(xPos, yPos, 0, 0, xSize, ySize, xSize, 256); + + super.drawScreen(par1, par2, par3); + if(discovered){ - this.fontRendererObj.drawString(spell.getDisplayName(), xPos+17, yPos+14, 0); - this.fontRendererObj.drawString(spell.type.getDisplayName(), xPos+17, yPos+25, 0x777777); + this.fontRendererObj.drawString(spell.getDisplayName(), xPos + 17, yPos + 14, 0); + this.fontRendererObj.drawString(spell.type.getDisplayName(), xPos + 17, yPos + 25, 0x777777); }else{ - this.mc.standardGalacticFontRenderer.drawString(SpellGlyphData.getGlyphName(spell, player.worldObj), xPos+17, yPos+14, 0); - this.mc.standardGalacticFontRenderer.drawString(spell.type.getDisplayName(), xPos+17, yPos+25, 0x777777); + this.mc.standardGalacticFontRenderer.drawString(SpellGlyphData.getGlyphName(spell, player.world), xPos + 17, + yPos + 14, 0); + this.mc.standardGalacticFontRenderer.drawString(spell.type.getDisplayName(), xPos + 17, yPos + 25, + 0x777777); } - - this.fontRendererObj.drawString("-------------------", xPos+17, yPos+34, 0); - - if(spell.tier == Tier.BASIC){ - // Basic is usually white but this doesn't show up. - this.fontRendererObj.drawString("Tier: \u00A77" + Tier.BASIC.getDisplayName(), xPos+17, yPos+44, 0); - }else{ - this.fontRendererObj.drawString("Tier: " + spell.tier.getDisplayNameWithFormatting(), xPos+17, yPos+44, 0); - } - - String element = "Element: " + spell.element.getFormattingCode() + spell.element.getDisplayName(); - if(!discovered) element = "Element: ?"; - this.fontRendererObj.drawString(element, xPos+17, yPos+56, 0); - - String manaCost = "Mana Cost: " + spell.cost; - if(spell.isContinuous) manaCost = "Mana Cost: " + spell.cost + "/second"; - if(!discovered) manaCost = "Mana Cost: ?"; - this.fontRendererObj.drawString(manaCost, xPos+17, yPos+68, 0); - - if(discovered){ - this.fontRendererObj.drawSplitString(spell.getDescription(), xPos+17, yPos+82, 118, 0); - }else{ - this.mc.standardGalacticFontRenderer.drawSplitString(SpellGlyphData.getGlyphDescription(spell, player.worldObj), xPos+17, yPos+82, 118, 0); - } - - /* - // Word wrapping - int charNumber = 0; - int lineNumber = 0; - - while(charNumber < spell.desc.length()){ - int lineLength = 0; - String line; - if(spell.desc.length() - charNumber > 22){ - for(int i = charNumber; i < charNumber+23; i++){ - if(spell.desc.charAt(i) == ' '){ - lineLength = i - charNumber; - } - } - line = spell.desc.substring(charNumber, charNumber + lineLength); - }else{ - line = spell.desc.substring(charNumber, spell.desc.length()); - charNumber = spell.desc.length(); - } - this.fontRendererObj.drawString("\u00A7o" + line, xPos+17, yPos+82+10*lineNumber, 0); - charNumber+=(lineLength+1); - lineNumber++; - } - */ - } - public void initGui() - { + this.fontRendererObj.drawString("-------------------", xPos + 17, yPos + 34, 0); + + if(spell.tier == Tier.BASIC){ + // Basic is usually white but this doesn't show up. + this.fontRendererObj.drawString("Tier: \u00A77" + Tier.BASIC.getDisplayName(), xPos + 17, yPos + 44, 0); + }else{ + this.fontRendererObj.drawString("Tier: " + spell.tier.getDisplayNameWithFormatting(), xPos + 17, yPos + 44, + 0); + } + + String element = "Element: " + spell.element.getFormattingCode() + spell.element.getDisplayName(); + if(!discovered) element = "Element: ?"; + this.fontRendererObj.drawString(element, xPos + 17, yPos + 56, 0); + + String manaCost = "Mana Cost: " + spell.cost; + if(spell.isContinuous) manaCost = "Mana Cost: " + spell.cost + "/second"; + if(!discovered) manaCost = "Mana Cost: ?"; + this.fontRendererObj.drawString(manaCost, xPos + 17, yPos + 68, 0); + + if(discovered){ + this.fontRendererObj.drawSplitString(spell.getDescription(), xPos + 17, yPos + 82, 118, 0); + }else{ + this.mc.standardGalacticFontRenderer.drawSplitString( + SpellGlyphData.getGlyphDescription(spell, player.world), xPos + 17, yPos + 82, 118, 0); + } + + /* // Word wrapping int charNumber = 0; int lineNumber = 0; + * + * while(charNumber < spell.desc.length()){ int lineLength = 0; String line; if(spell.desc.length() - charNumber + * > 22){ for(int i = charNumber; i < charNumber+23; i++){ if(spell.desc.charAt(i) == ' '){ lineLength = i - + * charNumber; } } line = spell.desc.substring(charNumber, charNumber + lineLength); }else{ line = + * spell.desc.substring(charNumber, spell.desc.length()); charNumber = spell.desc.length(); } + * this.fontRendererObj.drawString("\u00A7o" + line, xPos+17, yPos+82+10*lineNumber, 0); + * charNumber+=(lineLength+1); lineNumber++; } */ + } + + public void initGui(){ super.initGui(); - Keyboard.enableRepeatEvents(true); - this.buttonList.clear(); - } - - public void onGuiClosed() - { - super.onGuiClosed(); - Keyboard.enableRepeatEvents(false); - } -} + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + } + public void onGuiClosed(){ + super.onGuiClosed(); + Keyboard.enableRepeatEvents(false); + } +} diff --git a/src/main/java/electroblob/wizardry/client/GuiSpellDisplay.java b/src/main/java/electroblob/wizardry/client/GuiSpellDisplay.java index dc27a3eb..1dc07bf9 100644 --- a/src/main/java/electroblob/wizardry/client/GuiSpellDisplay.java +++ b/src/main/java/electroblob/wizardry/client/GuiSpellDisplay.java @@ -30,9 +30,10 @@ public class GuiSpellDisplay extends Gui { private Minecraft mc; - private static final ResourceLocation hudTexture = new ResourceLocation(Wizardry.MODID, "textures/gui/spell_hud.png"); + private static final ResourceLocation hudTexture = new ResourceLocation(Wizardry.MODID, + "textures/gui/spell_hud.png"); - public GuiSpellDisplay(Minecraft par1Minecraft) { + public GuiSpellDisplay(Minecraft par1Minecraft){ super(); this.mc = par1Minecraft; } @@ -40,7 +41,7 @@ public class GuiSpellDisplay extends Gui { @SubscribeEvent public void draw(RenderGameOverlayEvent event){ - EntityPlayer player = this.mc.thePlayer; + EntityPlayer player = this.mc.player; // If the player has a wand in each hand, only displays for the one in the main hand. @@ -58,7 +59,8 @@ public class GuiSpellDisplay extends Gui { Spell spell = WandHelper.getCurrentSpell(wand); int cooldown = WandHelper.getCurrentCooldown(wand); - float cooldownMultiplier = 1.0f - WandHelper.getUpgradeLevel(wand, WizardryItems.cooldown_upgrade)*Constants.COOLDOWN_REDUCTION_PER_LEVEL; + float cooldownMultiplier = 1.0f - WandHelper.getUpgradeLevel(wand, WizardryItems.cooldown_upgrade) + * Constants.COOLDOWN_REDUCTION_PER_LEVEL; if(player.isPotionActive(WizardryPotions.font_of_mana)){ // Dividing by this rather than setting it takes upgrades and font of mana into account simultaneously @@ -72,17 +74,17 @@ public class GuiSpellDisplay extends Gui { if(Wizardry.settings.spellHUDPosition == GuiPosition.BOTTOM_LEFT){ left = 0; - top = height-36; + top = height - 36; }else if(Wizardry.settings.spellHUDPosition == GuiPosition.TOP_LEFT){ left = 0; top = 0; }else if(Wizardry.settings.spellHUDPosition == GuiPosition.TOP_RIGHT){ - left = width-128; + left = width - 128; top = 0; mirror = true; }else if(Wizardry.settings.spellHUDPosition == GuiPosition.BOTTOM_RIGHT){ - left = width-128; - top = height-36; + left = width - 128; + top = height - 36; mirror = true; } @@ -95,16 +97,17 @@ public class GuiSpellDisplay extends Gui { if(event.getType() == RenderGameOverlayEvent.ElementType.TEXT){ // Makes spells greyed out if they are in cooldown or if the player has the arcane jammer effect - String colour = cooldown > 0 || player.isPotionActive(WizardryPotions.arcane_jammer) ? "\u00A78" : spell.element.getFormattingCode(); + String colour = cooldown > 0 || player.isPotionActive(WizardryPotions.arcane_jammer) ? "\u00A78" + : spell.element.getFormattingCode(); if(!discovered) colour = "\u00A79"; - String spellName = discovered ? spell.getDisplayName() : SpellGlyphData.getGlyphName(spell, player.worldObj); + String spellName = discovered ? spell.getDisplayName() : SpellGlyphData.getGlyphName(spell, player.world); FontRenderer font = discovered ? this.mc.fontRendererObj : this.mc.standardGalacticFontRenderer; int maxWidth = 90; if(font.getStringWidth(spellName) <= maxWidth){ // Single line is rendered more centrally - font.drawStringWithShadow(colour + spellName, mirror ? left+5 : left+41, top+13, 0xffffffff); + font.drawStringWithShadow(colour + spellName, mirror ? left + 5 : left + 41, top + 13, 0xffffffff); }else{ @@ -114,20 +117,21 @@ public class GuiSpellDisplay extends Gui { for(Object line : lines){ if(line instanceof String){ - font.drawStringWithShadow(colour + (String)line, mirror ? left+5 : left+41, top+6 + 11*lineNumber, 0xffffffff); + font.drawStringWithShadow(colour + (String)line, mirror ? left + 5 : left + 41, + top + 6 + 11 * lineNumber, 0xffffffff); } lineNumber++; } } }else if(event.getType() == RenderGameOverlayEvent.ElementType.HOTBAR){ - + GlStateManager.pushAttrib(); - + GlStateManager.enableBlend(); GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.color(1, 1, 1); - + this.mc.renderEngine.bindTexture(hudTexture); // Background of spell hud @@ -135,18 +139,18 @@ public class GuiSpellDisplay extends Gui { // Cooldown bar if(cooldown > 0){ - this.drawTexturedModalRect(mirror ? left+5 : left+41, height-8, 128, 6, 82, 6); + this.drawTexturedModalRect(mirror ? left + 5 : left + 41, height - 8, 128, 6, 82, 6); int l = (int)(((double)(spell.cooldown * cooldownMultiplier - cooldown) / (double)(spell.cooldown * cooldownMultiplier)) * 82); - this.drawTexturedModalRect(mirror ? left+5 : left+41, height-8, 128, 0, l, 6); + this.drawTexturedModalRect(mirror ? left + 5 : left + 41, height - 8, 128, 0, l, 6); } // Spell illustration this.mc.renderEngine.bindTexture(discovered ? spell.getIcon() : Spells.none.getIcon()); - WizardryUtilities.drawTexturedRect(mirror ? left+94 : left+2, top+2, 0, 0, 32, 32, 32, 32); + WizardryUtilities.drawTexturedRect(mirror ? left + 94 : left + 2, top + 2, 0, 0, 32, 32, 32, 32); GlStateManager.popAttrib(); } diff --git a/src/main/java/electroblob/wizardry/client/GuiWizardHandbook.java b/src/main/java/electroblob/wizardry/client/GuiWizardHandbook.java index 5cb8ee9e..6a035d36 100644 --- a/src/main/java/electroblob/wizardry/client/GuiWizardHandbook.java +++ b/src/main/java/electroblob/wizardry/client/GuiWizardHandbook.java @@ -36,23 +36,29 @@ public class GuiWizardHandbook extends GuiScreen { private int pageNumber = 0; private static final int PAGE_WIDTH = 120; - /** The integer colour for black passed into the font renderer methods. This used to be 0 but that's now white - * for some reason, so I've made a it a constant in case it changes again. */ + /** + * The integer colour for black passed into the font renderer methods. This used to be 0 but that's now white for + * some reason, so I've made a it a constant in case it changes again. + */ // I think this is actually ever-so-slightly lighter than pure black, but the difference is unnoticeable. private static final int BLACK = 1; - public static final ResourceLocation regularHandbook = new ResourceLocation(Wizardry.MODID, "textures/gui/handbook.png"); + public static final ResourceLocation regularHandbook = new ResourceLocation(Wizardry.MODID, + "textures/gui/handbook.png"); public static final ResourceLocation ore = new ResourceLocation(Wizardry.MODID, "textures/gui/ore_picture.png"); - public static final ResourceLocation crystal = new ResourceLocation(Wizardry.MODID, "textures/items/magic_crystal.png"); - public static final ResourceLocation workbenchGui = new ResourceLocation(Wizardry.MODID, "textures/gui/arcane_workbench.png"); - public static final ResourceLocation craftingGrids = new ResourceLocation(Wizardry.MODID, "textures/gui/handbook_recipes.png"); + public static final ResourceLocation crystal = new ResourceLocation(Wizardry.MODID, + "textures/items/magic_crystal.png"); + public static final ResourceLocation workbenchGui = new ResourceLocation(Wizardry.MODID, + "textures/gui/arcane_workbench.png"); + public static final ResourceLocation craftingGrids = new ResourceLocation(Wizardry.MODID, + "textures/gui/handbook_recipes.png"); private ArrayList> text; private ArrayList
    sections; - + private int guiPage, imagePage; - public GuiWizardHandbook() { + public GuiWizardHandbook(){ super(); xSize = 288; ySize = 180; @@ -60,43 +66,47 @@ public class GuiWizardHandbook extends GuiScreen { @Override public void drawScreen(int mouseX, int mouseY, float par3){ - - int xPos = this.width/2 - xSize/2; - int yPos = this.height/2 - this.ySize/2; + + int xPos = this.width / 2 - xSize / 2; + int yPos = this.height / 2 - this.ySize / 2; // Tests for crafting recipes section - if(pageNumber >= (sections.get(sections.size()-1).pageNumber-1)/2 && pageNumber < (sections.get(sections.size()-1).pageNumber-1)/2 + 4){ + if(pageNumber >= (sections.get(sections.size() - 1).pageNumber - 1) / 2 + && pageNumber < (sections.get(sections.size() - 1).pageNumber - 1) / 2 + 4){ Minecraft.getMinecraft().renderEngine.bindTexture(craftingGrids); }else{ Minecraft.getMinecraft().renderEngine.bindTexture(regularHandbook); } WizardryUtilities.drawTexturedRect(xPos, yPos, 0, 0, xSize, ySize, xSize, 256); - + // Arcane workbench gui picture - if(pageNumber == (this.guiPage-1)/2){ + if(pageNumber == (this.guiPage - 1) / 2){ Minecraft.getMinecraft().renderEngine.bindTexture(workbenchGui); - this.drawTexturedModalRect(this.guiPage % 2 == 1 ? xPos + 17 : this.width/2 + 7, yPos + 14, 28, 12, 120, 118); + this.drawTexturedModalRect(this.guiPage % 2 == 1 ? xPos + 17 : this.width / 2 + 7, yPos + 14, 28, 12, 120, + 118); } - + // Magic crystal and crystal ore images - if(pageNumber == (this.imagePage-1)/2){ - + if(pageNumber == (this.imagePage - 1) / 2){ + Minecraft.getMinecraft().renderEngine.bindTexture(ore); - WizardryUtilities.drawTexturedRect(this.imagePage % 2 == 1 ? xPos + 17 : this.width/2 + 7, yPos + 80, 0, 0, 64, 64, 64, 64); - + WizardryUtilities.drawTexturedRect(this.imagePage % 2 == 1 ? xPos + 17 : this.width / 2 + 7, yPos + 80, 0, + 0, 64, 64, 64, 64); + Minecraft.getMinecraft().renderEngine.bindTexture(crystal); - drawTexturedStretchedRect(this.imagePage % 2 == 1 ? xPos + 17 + 64 : this.width/2 + 7 + 62, yPos + 80, 0, 0, 64, 64, 1, 1); + drawTexturedStretchedRect(this.imagePage % 2 == 1 ? xPos + 17 + 64 : this.width / 2 + 7 + 62, yPos + 80, 0, + 0, 64, 64, 1, 1); } - - this.fontRendererObj.drawString("" + (pageNumber*2 + 1), xPos + xSize/4 - 3, yPos + ySize - 20, 0); - this.fontRendererObj.drawString("" + (pageNumber*2 + 2), xPos + 3*xSize/4 - 5, yPos + ySize - 20, 0); + + this.fontRendererObj.drawString("" + (pageNumber * 2 + 1), xPos + xSize / 4 - 3, yPos + ySize - 20, 0); + this.fontRendererObj.drawString("" + (pageNumber * 2 + 2), xPos + 3 * xSize / 4 - 5, yPos + ySize - 20, 0); super.drawScreen(mouseX, mouseY, par3); int lineNumber = 0; - + if(pageNumber == 1){ for(Section s : sections){ s.drawContents(); @@ -107,11 +117,13 @@ public class GuiWizardHandbook extends GuiScreen { } } - for(String paragraph : text.get(pageNumber*2)){ + for(String paragraph : text.get(pageNumber * 2)){ - this.fontRendererObj.drawSplitString(paragraph, xPos + 17, yPos + 14 + lineNumber*this.fontRendererObj.FONT_HEIGHT, PAGE_WIDTH, BLACK); + this.fontRendererObj.drawSplitString(paragraph, xPos + 17, + yPos + 14 + lineNumber * this.fontRendererObj.FONT_HEIGHT, PAGE_WIDTH, BLACK); - List list = new ArrayList(this.fontRendererObj.listFormattedStringToWidth(paragraph, GuiWizardHandbook.PAGE_WIDTH)); + List list = new ArrayList( + this.fontRendererObj.listFormattedStringToWidth(paragraph, GuiWizardHandbook.PAGE_WIDTH)); lineNumber += list.size(); } @@ -119,19 +131,23 @@ public class GuiWizardHandbook extends GuiScreen { lineNumber = 0; // Prevents crash when the last page is blank (and hence is not in the list of pages) - if(text.size() > pageNumber*2 + 1){ - for(String paragraph : text.get(pageNumber*2 + 1)){ + if(text.size() > pageNumber * 2 + 1){ + for(String paragraph : text.get(pageNumber * 2 + 1)){ // First page is centred if(pageNumber == 0){ - int startX = this.width/2 + 7 + PAGE_WIDTH/2 - this.fontRendererObj.getStringWidth(paragraph)/2; - this.fontRendererObj.drawSplitString(paragraph, startX, yPos + 14 + lineNumber*this.fontRendererObj.FONT_HEIGHT, PAGE_WIDTH, BLACK); + int startX = this.width / 2 + 7 + PAGE_WIDTH / 2 + - this.fontRendererObj.getStringWidth(paragraph) / 2; + this.fontRendererObj.drawSplitString(paragraph, startX, + yPos + 14 + lineNumber * this.fontRendererObj.FONT_HEIGHT, PAGE_WIDTH, BLACK); }else{ - this.fontRendererObj.drawSplitString(paragraph, this.width/2 + 7, yPos + 14 + lineNumber*this.fontRendererObj.FONT_HEIGHT, PAGE_WIDTH, BLACK); + this.fontRendererObj.drawSplitString(paragraph, this.width / 2 + 7, + yPos + 14 + lineNumber * this.fontRendererObj.FONT_HEIGHT, PAGE_WIDTH, BLACK); } - - List list = new ArrayList(this.fontRendererObj.listFormattedStringToWidth(paragraph, GuiWizardHandbook.PAGE_WIDTH)); - + + List list = new ArrayList( + this.fontRendererObj.listFormattedStringToWidth(paragraph, GuiWizardHandbook.PAGE_WIDTH)); + lineNumber += list.size(); } } @@ -140,7 +156,7 @@ public class GuiWizardHandbook extends GuiScreen { ItemStack craftingResult; // Tooltips are rendered after recipes to prevent tooltips on the left appearing behind items on the right. - if(pageNumber == (sections.get(sections.size()-1).pageNumber-1)/2){ + if(pageNumber == (sections.get(sections.size() - 1).pageNumber - 1) / 2){ craftingGrid = new ItemStack[3][3]; craftingGrid[0][0] = new ItemStack(Items.GOLD_NUGGET); @@ -177,7 +193,7 @@ public class GuiWizardHandbook extends GuiScreen { craftingResult = new ItemStack(WizardryItems.wizard_handbook); this.renderCraftingRecipe(xPos + 156, yPos + 98, mouseX, mouseY, craftingGrid, craftingResult); - }else if(pageNumber == (sections.get(sections.size()-1).pageNumber-1)/2 + 1){ + }else if(pageNumber == (sections.get(sections.size() - 1).pageNumber - 1) / 2 + 1){ craftingGrid = new ItemStack[3][3]; craftingGrid[0][0] = new ItemStack(WizardryBlocks.crystal_flower); @@ -215,7 +231,7 @@ public class GuiWizardHandbook extends GuiScreen { craftingResult = new ItemStack(WizardryItems.magic_silk, 2); this.renderCraftingRecipe(xPos + 156, yPos + 98, mouseX, mouseY, craftingGrid, craftingResult); - }else if(pageNumber == (sections.get(sections.size()-1).pageNumber-1)/2 + 2){ + }else if(pageNumber == (sections.get(sections.size() - 1).pageNumber - 1) / 2 + 2){ craftingGrid = new ItemStack[3][3]; craftingGrid[0][0] = new ItemStack(WizardryItems.magic_silk); @@ -257,7 +273,7 @@ public class GuiWizardHandbook extends GuiScreen { craftingResult = new ItemStack(WizardryItems.wizard_boots); this.renderCraftingRecipe(xPos + 156, yPos + 98, mouseX, mouseY, craftingGrid, craftingResult); - }else if(pageNumber == (sections.get(sections.size()-1).pageNumber-1)/2 + 3){ + }else if(pageNumber == (sections.get(sections.size() - 1).pageNumber - 1) / 2 + 3){ if(Wizardry.settings.useAlternateScrollRecipe){ craftingGrid = new ItemStack[3][3]; @@ -273,7 +289,7 @@ public class GuiWizardHandbook extends GuiScreen { craftingResult = new ItemStack(WizardryItems.blank_scroll); this.renderCraftingRecipe(xPos + 23, yPos + 39, mouseX, mouseY, craftingGrid, craftingResult); } - + if(Wizardry.settings.firebombIsCraftable){ craftingGrid = new ItemStack[3][3]; craftingGrid[0][0] = new ItemStack(Items.BLAZE_POWDER); @@ -303,10 +319,10 @@ public class GuiWizardHandbook extends GuiScreen { craftingResult = new ItemStack(WizardryItems.smoke_bomb, 3); this.renderCraftingRecipe(xPos + 156, yPos + 98, mouseX, mouseY, craftingGrid, craftingResult); } - + } - if(pageNumber == (sections.get(sections.size()-1).pageNumber-1)/2){ + if(pageNumber == (sections.get(sections.size() - 1).pageNumber - 1) / 2){ craftingGrid = new ItemStack[3][3]; craftingGrid[0][0] = new ItemStack(Items.GOLD_NUGGET); @@ -343,7 +359,7 @@ public class GuiWizardHandbook extends GuiScreen { craftingResult = new ItemStack(WizardryItems.wizard_handbook); this.renderCraftingTooltips(xPos + 156, yPos + 98, mouseX, mouseY, craftingGrid, craftingResult); - }else if(pageNumber == (sections.get(sections.size()-1).pageNumber-1)/2 + 1){ + }else if(pageNumber == (sections.get(sections.size() - 1).pageNumber - 1) / 2 + 1){ craftingGrid = new ItemStack[3][3]; craftingGrid[0][0] = new ItemStack(WizardryBlocks.crystal_flower); @@ -381,7 +397,7 @@ public class GuiWizardHandbook extends GuiScreen { craftingResult = new ItemStack(WizardryItems.magic_silk, 2); this.renderCraftingTooltips(xPos + 156, yPos + 98, mouseX, mouseY, craftingGrid, craftingResult); - }else if(pageNumber == (sections.get(sections.size()-1).pageNumber-1)/2 + 2){ + }else if(pageNumber == (sections.get(sections.size() - 1).pageNumber - 1) / 2 + 2){ craftingGrid = new ItemStack[3][3]; craftingGrid[0][0] = new ItemStack(WizardryItems.magic_silk); @@ -423,7 +439,7 @@ public class GuiWizardHandbook extends GuiScreen { craftingResult = new ItemStack(WizardryItems.wizard_boots); this.renderCraftingTooltips(xPos + 156, yPos + 98, mouseX, mouseY, craftingGrid, craftingResult); - }else if(pageNumber == (sections.get(sections.size()-1).pageNumber-1)/2 + 3){ + }else if(pageNumber == (sections.get(sections.size() - 1).pageNumber - 1) / 2 + 3){ if(Wizardry.settings.useAlternateScrollRecipe){ craftingGrid = new ItemStack[3][3]; @@ -439,7 +455,7 @@ public class GuiWizardHandbook extends GuiScreen { craftingResult = new ItemStack(WizardryItems.blank_scroll); this.renderCraftingTooltips(xPos + 23, yPos + 39, mouseX, mouseY, craftingGrid, craftingResult); } - + if(Wizardry.settings.firebombIsCraftable){ craftingGrid = new ItemStack[3][3]; craftingGrid[0][0] = new ItemStack(Items.BLAZE_POWDER); @@ -469,11 +485,12 @@ public class GuiWizardHandbook extends GuiScreen { craftingResult = new ItemStack(WizardryItems.smoke_bomb, 3); this.renderCraftingTooltips(xPos + 156, yPos + 98, mouseX, mouseY, craftingGrid, craftingResult); } - + } } - private void renderCraftingRecipe(int xPos, int yPos, int mouseX, int mouseY, ItemStack[][] craftingGrid, ItemStack craftingResult) { + private void renderCraftingRecipe(int xPos, int yPos, int mouseX, int mouseY, ItemStack[][] craftingGrid, + ItemStack craftingResult){ GlStateManager.pushMatrix(); RenderHelper.enableGUIStandardItemLighting(); @@ -483,11 +500,12 @@ public class GuiWizardHandbook extends GuiScreen { GlStateManager.enableLighting(); itemRender.zLevel = 100.0F; - for(int i=0; i>(1); sections = new ArrayList
    (1); - - BufferedReader bufferedreader = null; - - String textFilepath = "wizardry:texts/handbook_" + Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode() + ".txt"; - - try { - - bufferedreader = new BufferedReader(new InputStreamReader(this.mc.getResourceManager().getResource(new ResourceLocation(textFilepath)).getInputStream(), Charsets.UTF_8)); - } catch (IOException e){ - - Wizardry.logger.info("Wizard handbook text file missing for the current language. Using default (English - US) instead."); + BufferedReader bufferedreader = null; + + String textFilepath = "wizardry:texts/handbook_" + + Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode() + ".txt"; + + try{ + + bufferedreader = new BufferedReader(new InputStreamReader( + this.mc.getResourceManager().getResource(new ResourceLocation(textFilepath)).getInputStream(), + Charsets.UTF_8)); + + }catch (IOException e){ + + Wizardry.logger.info( + "Wizard handbook text file missing for the current language. Using default (English - US) instead."); textFilepath = "wizardry:texts/handbook_en_US.txt"; - - try { - - bufferedreader = new BufferedReader(new InputStreamReader(this.mc.getResourceManager().getResource(new ResourceLocation(textFilepath)).getInputStream(), Charsets.UTF_8)); - } catch (IOException x){ + try{ + + bufferedreader = new BufferedReader(new InputStreamReader( + this.mc.getResourceManager().getResource(new ResourceLocation(textFilepath)).getInputStream(), + Charsets.UTF_8)); + + }catch (IOException x){ Wizardry.logger.error("Couldn't find file: wizardry:assets/texts/handbook_en_US.txt. The file may be" + "missing; please try re-downloading and reinstalling Wizardry.", x); } } - + if(bufferedreader != null){ - - try { - + + try{ + String paragraph = bufferedreader.readLine(); ArrayList page = new ArrayList(1); - + int linesPerPage = 16; - + int lineNumber = 0; - + while(paragraph != null){ - - //System.out.println(paragraph); - + + // System.out.println(paragraph); + if(paragraph.contains("PAGEBREAK") || lineNumber >= linesPerPage){ - + text.add(page); - + page = new ArrayList(1); - + lineNumber = 0; - + if(paragraph.contains("PAGEBREAK")) paragraph = bufferedreader.readLine(); - + }else if(paragraph.contains("LINEBREAK")){ - + lineNumber++; - + page.add(""); - + paragraph = bufferedreader.readLine(); - + }else if(paragraph.contains("SECTION")){ - - sections.add(new Section(paragraph.replace("SECTION ", ""), text.size() + 1, this.width/2 + 7, - this.height/2 - this.ySize/2 + 14 + (sections.size()+2)*this.fontRendererObj.FONT_HEIGHT, nextButtonId++)); + + sections.add( + new Section(paragraph.replace("SECTION ", ""), text.size() + 1, this.width / 2 + 7, + this.height / 2 - this.ySize / 2 + 14 + + (sections.size() + 2) * this.fontRendererObj.FONT_HEIGHT, + nextButtonId++)); paragraph = bufferedreader.readLine(); - + }else if(paragraph.contains("IMAGE")){ - + if(paragraph.contains("WORKBENCH")){ this.guiPage = text.size() + 1; }else if(paragraph.contains("CRYSTAL")){ this.imagePage = text.size() + 1; } - + paragraph = bufferedreader.readLine(); - + }else{ - - paragraph = paragraph.replaceAll("NEXT_SPELL_KEY", Keyboard.getKeyName(ClientProxy.NEXT_SPELL.getKeyCode())); - paragraph = paragraph.replaceAll("PREVIOUS_SPELL_KEY", Keyboard.getKeyName(ClientProxy.PREVIOUS_SPELL.getKeyCode())); - paragraph = paragraph.replaceAll("MANA_PER_CRYSTAL_MINUS_30", "" + (Constants.MANA_PER_CRYSTAL - 30)); + + paragraph = paragraph.replaceAll("NEXT_SPELL_KEY", + Keyboard.getKeyName(ClientProxy.NEXT_SPELL.getKeyCode())); + paragraph = paragraph.replaceAll("PREVIOUS_SPELL_KEY", + Keyboard.getKeyName(ClientProxy.PREVIOUS_SPELL.getKeyCode())); + paragraph = paragraph.replaceAll("MANA_PER_CRYSTAL_MINUS_30", + "" + (Constants.MANA_PER_CRYSTAL - 30)); paragraph = paragraph.replaceAll("MANA_PER_CRYSTAL", "" + Constants.MANA_PER_CRYSTAL); paragraph = paragraph.replaceAll("BASIC_MAX_CHARGE", "" + Tier.BASIC.maxCharge); paragraph = paragraph.replaceAll("APPRENTICE_MAX_CHARGE", "" + Tier.APPRENTICE.maxCharge); @@ -647,35 +681,37 @@ public class GuiWizardHandbook extends GuiScreen { paragraph = paragraph.replaceAll("HEALING_COLOUR", Element.HEALING.getFormattingCode()); paragraph = paragraph.replaceAll("RESET_COLOUR", "\u00A70"); paragraph = paragraph.replaceAll("VERSION", Wizardry.VERSION); - - int linesInParagraph = this.fontRendererObj.listFormattedStringToWidth(paragraph, GuiWizardHandbook.PAGE_WIDTH).size(); - + + int linesInParagraph = this.fontRendererObj + .listFormattedStringToWidth(paragraph, GuiWizardHandbook.PAGE_WIDTH).size(); + // Ignores empty lines at the top of a page. if(paragraph.isEmpty() && lineNumber == 0){ - + paragraph = bufferedreader.readLine(); - - // Normal paragraph, all on one page + + // Normal paragraph, all on one page }else if(lineNumber + linesInParagraph <= linesPerPage){ - + page.add(paragraph); - + lineNumber += linesInParagraph; - + paragraph = bufferedreader.readLine(); - - // Paragraphs split across two pages (or more?) + + // Paragraphs split across two pages (or more?) }else{ - + int linesInFirstPart = linesPerPage - lineNumber; - + String paragraphFirstPart = ""; String paragraphLastPart = ""; - + int i = 0; - - List strings = this.fontRendererObj.listFormattedStringToWidth(paragraph, GuiWizardHandbook.PAGE_WIDTH); - + + List strings = this.fontRendererObj.listFormattedStringToWidth(paragraph, + GuiWizardHandbook.PAGE_WIDTH); + for(Object s : strings){ if(i < linesInFirstPart){ paragraphFirstPart = paragraphFirstPart.concat((String)s + " "); @@ -684,23 +720,24 @@ public class GuiWizardHandbook extends GuiScreen { } i++; } - - //System.out.println("Paragraph crosses page boundary; string split into: \"" + paragraphFirstPart + "\" and \"" + paragraphLastPart + "\""); - + + // System.out.println("Paragraph crosses page boundary; string split into: \"" + + // paragraphFirstPart + "\" and \"" + paragraphLastPart + "\""); + page.add(paragraphFirstPart); - + lineNumber += linesInFirstPart; - + paragraph = paragraphLastPart; } } } - + text.add(page); - - } catch (IOException e){ - Wizardry.logger.error("Something went wrong reading file: " + textFilepath + ". The file may be damaged;" - + "please try re-downloading and reinstalling wizardry.", e); + + }catch (IOException e){ + Wizardry.logger.error("Something went wrong reading file: " + textFilepath + + ". The file may be damaged;" + "please try re-downloading and reinstalling wizardry.", e); } } } @@ -709,7 +746,7 @@ public class GuiWizardHandbook extends GuiScreen { /** The integer text colour used for the section when it is moused over. Currently orange. */ private static final int HIGHLIGHT_COLOUR = 0xdd4c1d; - + String name; int pageNumber; int x, y; @@ -721,7 +758,8 @@ public class GuiWizardHandbook extends GuiScreen { this.x = x; this.y = y; this.buttonId = id; - GuiWizardHandbook.this.buttonList.add(new GuiButtonInvisible(id, x, y, GuiWizardHandbook.PAGE_WIDTH, GuiWizardHandbook.this.fontRendererObj.FONT_HEIGHT)); + GuiWizardHandbook.this.buttonList.add(new GuiButtonInvisible(id, x, y, GuiWizardHandbook.PAGE_WIDTH, + GuiWizardHandbook.this.fontRendererObj.FONT_HEIGHT)); } void hideButton(){ @@ -729,26 +767,28 @@ public class GuiWizardHandbook extends GuiScreen { } void drawContents(){ - + GuiWizardHandbook.this.buttonList.get(buttonId).visible = true; - GuiWizardHandbook.this.fontRendererObj.drawString(name, x, y, GuiWizardHandbook.this.buttonList.get(buttonId).isMouseOver() ? HIGHLIGHT_COLOUR : BLACK); + GuiWizardHandbook.this.fontRendererObj.drawString(name, x, y, + GuiWizardHandbook.this.buttonList.get(buttonId).isMouseOver() ? HIGHLIGHT_COLOUR : BLACK); int nameWidth = GuiWizardHandbook.this.fontRendererObj.getStringWidth(name); String dotsAndNumber = " " + this.pageNumber; - while(GuiWizardHandbook.this.fontRendererObj.getStringWidth(dotsAndNumber) < GuiWizardHandbook.PAGE_WIDTH - nameWidth - 2){ + while(GuiWizardHandbook.this.fontRendererObj.getStringWidth(dotsAndNumber) < GuiWizardHandbook.PAGE_WIDTH + - nameWidth - 2){ dotsAndNumber = "." + dotsAndNumber; } - GuiWizardHandbook.this.fontRendererObj.drawString(dotsAndNumber, x + GuiWizardHandbook.PAGE_WIDTH - GuiWizardHandbook.this.fontRendererObj.getStringWidth(dotsAndNumber), y, BLACK); + GuiWizardHandbook.this.fontRendererObj.drawString(dotsAndNumber, x + GuiWizardHandbook.PAGE_WIDTH + - GuiWizardHandbook.this.fontRendererObj.getStringWidth(dotsAndNumber), y, BLACK); } } @Override - public void onGuiClosed() - { + public void onGuiClosed(){ super.onGuiClosed(); Keyboard.enableRepeatEvents(false); } @@ -761,11 +801,11 @@ public class GuiWizardHandbook extends GuiScreen { if(par1GuiButton.enabled){ if(par1GuiButton.id == 0){ - if(pageNumber < (text.size()-1)/2) pageNumber++; + if(pageNumber < (text.size() - 1) / 2) pageNumber++; }else if(par1GuiButton.id == 1){ if(pageNumber > 0) pageNumber--; }else{ - if(pageNumber == 1) pageNumber = (sections.get(par1GuiButton.id - 2).pageNumber-1)/2; + if(pageNumber == 1) pageNumber = (sections.get(par1GuiButton.id - 2).pageNumber - 1) / 2; } } } @@ -774,36 +814,39 @@ public class GuiWizardHandbook extends GuiScreen { * Args: left, top, width, height, pointX, pointY. Note: left, top are local to Gui, pointX, pointY are local to * screen */ - protected boolean isPointInRegion(int par1, int par2, int par3, int par4, int par5, int par6) - { - int k1 = this.width/2 - xSize/2; - int l1 = this.height/2 - this.ySize/2; + protected boolean isPointInRegion(int par1, int par2, int par3, int par4, int par5, int par6){ + int k1 = this.width / 2 - xSize / 2; + int l1 = this.height / 2 - this.ySize / 2; par5 -= k1; par6 -= l1; return par5 >= par1 - 1 && par5 < par1 + par3 + 1 && par6 >= par2 - 1 && par6 < par2 + par4 + 1; } - + /** * Draws a textured rectangle, stretching the section of the image to fit the size given. + * * @param x The x position of the rectangle * @param y The y position of the rectangle - * @param u The x position of the top left corner of the section of the image wanted, expressed as a fraction of the image width - * @param v The y position of the top left corner of the section of the image wanted, expressed as a fraction of the image width + * @param u The x position of the top left corner of the section of the image wanted, expressed as a fraction of the + * image width + * @param v The y position of the top left corner of the section of the image wanted, expressed as a fraction of the + * image width * @param finalWidth The width as rendered * @param finalHeight The height as rendered * @param width The width of the section, expressed as a fraction of the image width * @param height The height of the section, expressed as a fraction of the image width */ - public static void drawTexturedStretchedRect(int x, int y, int u, int v, int finalWidth, int finalHeight, int width, int height){ - - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buffer = tessellator.getBuffer(); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - buffer.pos((x), y + finalHeight, 0).tex(u, v + height).endVertex(); - buffer.pos(x + finalWidth, y + finalHeight, 0).tex(u + width, v + height).endVertex(); - buffer.pos(x + finalWidth, (y), 0).tex(u + width, v).endVertex(); - buffer.pos((x), (y), 0).tex(u, v).endVertex(); - tessellator.draw(); + public static void drawTexturedStretchedRect(int x, int y, int u, int v, int finalWidth, int finalHeight, int width, + int height){ + + Tessellator tessellator = Tessellator.getInstance(); + VertexBuffer buffer = tessellator.getBuffer(); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + buffer.pos((x), y + finalHeight, 0).tex(u, v + height).endVertex(); + buffer.pos(x + finalWidth, y + finalHeight, 0).tex(u + width, v + height).endVertex(); + buffer.pos(x + finalWidth, (y), 0).tex(u + width, v).endVertex(); + buffer.pos((x), (y), 0).tex(u, v).endVertex(); + tessellator.draw(); } } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/client/MixedFontRenderer.java b/src/main/java/electroblob/wizardry/client/MixedFontRenderer.java index 43b51f8b..da27bb2a 100644 --- a/src/main/java/electroblob/wizardry/client/MixedFontRenderer.java +++ b/src/main/java/electroblob/wizardry/client/MixedFontRenderer.java @@ -8,87 +8,91 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -/** Font renderer that renders parts of strings surrounded by '#' (without quotes) in the SGA instead of normal text. - * @since Wizardry 1.1 */ +/** + * Font renderer that renders parts of strings surrounded by '#' (without quotes) in the SGA instead of normal text. + * + * @since Wizardry 1.1 + */ @SideOnly(Side.CLIENT) public class MixedFontRenderer extends FontRenderer { - + public MixedFontRenderer(GameSettings p_i1035_1_, ResourceLocation p_i1035_2_, TextureManager p_i1035_3_, - boolean p_i1035_4_) { + boolean p_i1035_4_){ super(p_i1035_1_, p_i1035_2_, p_i1035_3_, p_i1035_4_); } - + @Override - public int drawString(String string, float x, float y, int colour, boolean shadow){ - + public int drawString(String string, float x, float y, int colour, boolean shadow){ + int l = 0; - + boolean sga = false; - + while(string.indexOf('#') > -1){ - + String section = string.substring(0, string.indexOf('#')); - + if(sga){ - l += Minecraft.getMinecraft().standardGalacticFontRenderer.drawString(section, x, y, colour, shadow); + l += Minecraft.getMinecraft().standardGalacticFontRenderer.drawString(section, x, y, colour, shadow); x += Minecraft.getMinecraft().standardGalacticFontRenderer.getStringWidth(section); - }else{ - l += Minecraft.getMinecraft().fontRendererObj.drawString(section, x, y, colour, shadow); + }else{ + l += Minecraft.getMinecraft().fontRendererObj.drawString(section, x, y, colour, shadow); x += Minecraft.getMinecraft().fontRendererObj.getStringWidth(section); - } - + } + string = string.substring(string.indexOf('#') + 1); sga = !sga; } - + if(sga){ - l += Minecraft.getMinecraft().standardGalacticFontRenderer.drawString(string, x, y, colour, shadow); - }else{ - l += Minecraft.getMinecraft().fontRendererObj.drawString(string, x, y, colour, shadow); - } - - return l; - } - + l += Minecraft.getMinecraft().standardGalacticFontRenderer.drawString(string, x, y, colour, shadow); + }else{ + l += Minecraft.getMinecraft().fontRendererObj.drawString(string, x, y, colour, shadow); + } + + return l; + } + @Override public int getStringWidth(String string){ - + int l = 0; - + boolean sga = false; - + while(string.indexOf('#') > -1){ - + String section = string.substring(0, string.indexOf('#')); - + if(sga){ - l += Minecraft.getMinecraft().standardGalacticFontRenderer.getStringWidth(section); - }else{ - l += Minecraft.getMinecraft().fontRendererObj.getStringWidth(section); - } - + l += Minecraft.getMinecraft().standardGalacticFontRenderer.getStringWidth(section); + }else{ + l += Minecraft.getMinecraft().fontRendererObj.getStringWidth(section); + } + string = string.substring(string.indexOf('#') + 1); sga = !sga; } - + if(sga){ - l += Minecraft.getMinecraft().standardGalacticFontRenderer.getStringWidth(string); - }else{ - l += Minecraft.getMinecraft().fontRendererObj.getStringWidth(string); - } - - return l; + l += Minecraft.getMinecraft().standardGalacticFontRenderer.getStringWidth(string); + }else{ + l += Minecraft.getMinecraft().fontRendererObj.getStringWidth(string); + } + + return l; } - + // This doesn't work the same way yet @Override - public void drawSplitString(String string, int x, int y, int width, int colour){ - + public void drawSplitString(String string, int x, int y, int width, int colour){ + if(string.contains("#")){ - Minecraft.getMinecraft().standardGalacticFontRenderer.drawSplitString(string.substring(1), x, y, width, colour); - }else{ - Minecraft.getMinecraft().fontRendererObj.drawSplitString(string, x, y, width, colour); - } - } + Minecraft.getMinecraft().standardGalacticFontRenderer.drawSplitString(string.substring(1), x, y, width, + colour); + }else{ + Minecraft.getMinecraft().fontRendererObj.drawSplitString(string, x, y, width, colour); + } + } } diff --git a/src/main/java/electroblob/wizardry/client/MovingSoundEntity.java b/src/main/java/electroblob/wizardry/client/MovingSoundEntity.java index 3696e866..0fdd1165 100644 --- a/src/main/java/electroblob/wizardry/client/MovingSoundEntity.java +++ b/src/main/java/electroblob/wizardry/client/MovingSoundEntity.java @@ -10,50 +10,43 @@ import net.minecraftforge.fml.relauncher.SideOnly; // Copied from MovingSoundMinecart; if it ever breaks between updates take a look at that. @SideOnly(Side.CLIENT) -public class MovingSoundEntity extends MovingSound -{ - private final Entity source; - private float distance = 0.0F; +public class MovingSoundEntity extends MovingSound { + private final Entity source; + private float distance = 0.0F; - public MovingSoundEntity(Entity entity, SoundEvent sound, float volume, float pitch, boolean repeat) - { - // Uses BLOCKS because that's the closest thing to inanimate entities. Could use NEUTRAL like MovingSoundMinecart. - super(sound, SoundCategory.BLOCKS); - this.source = entity; - this.repeat = repeat; - this.volume = volume; - this.pitch = pitch; - this.repeatDelay = 0; - } + public MovingSoundEntity(Entity entity, SoundEvent sound, float volume, float pitch, boolean repeat){ + // Uses BLOCKS because that's the closest thing to inanimate entities. Could use NEUTRAL like + // MovingSoundMinecart. + super(sound, SoundCategory.BLOCKS); + this.source = entity; + this.repeat = repeat; + this.volume = volume; + this.pitch = pitch; + this.repeatDelay = 0; + } - /** - * Updates the JList with a new model. - */ - @Override - public void update() - { - if (this.source.isDead && repeat) - { - this.donePlaying = true; - } - else - { - this.xPosF = (float)this.source.posX; - this.yPosF = (float)this.source.posY; - this.zPosF = (float)this.source.posZ; - float f = MathHelper.sqrt_double(this.source.motionX * this.source.motionX + this.source.motionY * this.source.motionY + this.source.motionZ * this.source.motionZ); + /** + * Updates the JList with a new model. + */ + @Override + public void update(){ + if(this.source.isDead && repeat){ + this.donePlaying = true; + }else{ + this.xPosF = (float)this.source.posX; + this.yPosF = (float)this.source.posY; + this.zPosF = (float)this.source.posZ; + float f = MathHelper.sqrt(this.source.motionX * this.source.motionX + + this.source.motionY * this.source.motionY + this.source.motionZ * this.source.motionZ); - // Is this something to do with the Doppler effect? - if ((double)f >= 0.01D) - { - this.distance = MathHelper.clamp_float(this.distance + 0.0025F, 0.0F, 1.0F); - this.volume = 0.0F + MathHelper.clamp_float(f, 0.0F, 0.5F) * 0.7F; - } - else - { - //this.pitch = 0.0F; - //this.volume = 0.0F; - } - } - } + // Is this something to do with the Doppler effect? + if((double)f >= 0.01D){ + this.distance = MathHelper.clamp(this.distance + 0.0025F, 0.0F, 1.0F); + this.volume = 0.0F + MathHelper.clamp(f, 0.0F, 0.5F) * 0.7F; + }else{ + // this.pitch = 0.0F; + // this.volume = 0.0F; + } + } + } } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/client/WizardryClientEventHandler.java b/src/main/java/electroblob/wizardry/client/WizardryClientEventHandler.java index 84b0d552..a8fa9616 100644 --- a/src/main/java/electroblob/wizardry/client/WizardryClientEventHandler.java +++ b/src/main/java/electroblob/wizardry/client/WizardryClientEventHandler.java @@ -42,20 +42,29 @@ import net.minecraftforge.fml.relauncher.Side; /** * Event handler responsible for all client-side only events, mostly rendering. + * * @author Electroblob * @since Wizardry 1.0 */ @Mod.EventBusSubscriber(Side.CLIENT) public final class WizardryClientEventHandler { - private static final ResourceLocation shieldTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/shield.png"); - private static final ResourceLocation wingTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/wing.png"); - private static final ResourceLocation shadowWardTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/shadow_ward.png"); - private static final ResourceLocation sixthSenseTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/sixth_sense.png"); - private static final ResourceLocation sixthSenseOverlayTexture = new ResourceLocation(Wizardry.MODID, "textures/gui/sixth_sense_overlay.png"); - private static final ResourceLocation frostOverlayTexture = new ResourceLocation(Wizardry.MODID, "textures/gui/frost_overlay.png"); - private static final ResourceLocation pointerTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/pointer.png"); - private static final ResourceLocation targetPointerTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/target_pointer.png"); + private static final ResourceLocation shieldTexture = new ResourceLocation(Wizardry.MODID, + "textures/entity/shield.png"); + private static final ResourceLocation wingTexture = new ResourceLocation(Wizardry.MODID, + "textures/entity/wing.png"); + private static final ResourceLocation shadowWardTexture = new ResourceLocation(Wizardry.MODID, + "textures/entity/shadow_ward.png"); + private static final ResourceLocation sixthSenseTexture = new ResourceLocation(Wizardry.MODID, + "textures/entity/sixth_sense.png"); + private static final ResourceLocation sixthSenseOverlayTexture = new ResourceLocation(Wizardry.MODID, + "textures/gui/sixth_sense_overlay.png"); + private static final ResourceLocation frostOverlayTexture = new ResourceLocation(Wizardry.MODID, + "textures/gui/frost_overlay.png"); + private static final ResourceLocation pointerTexture = new ResourceLocation(Wizardry.MODID, + "textures/entity/pointer.png"); + private static final ResourceLocation targetPointerTexture = new ResourceLocation(Wizardry.MODID, + "textures/entity/target_pointer.png"); @SubscribeEvent public static void onTextureStitchEvent(TextureStitchEvent.Pre event){ @@ -66,8 +75,8 @@ public final class WizardryClientEventHandler { // Shift-scrolling to change spells @SubscribeEvent public static void onMouseEvent(MouseEvent event){ - - EntityPlayer player = Minecraft.getMinecraft().thePlayer; + + EntityPlayer player = Minecraft.getMinecraft().player; ItemStack wand = player.getHeldItemMainhand(); if(wand == null || !(wand.getItem() instanceof ItemWand)){ @@ -75,7 +84,7 @@ public final class WizardryClientEventHandler { // If the player isn't holding a wand, then nothing else needs to be done. if(wand == null || !(wand.getItem() instanceof ItemWand)) return; } - + if(Minecraft.getMinecraft().inGameHasFocus && wand != null && event.getDwheel() != 0 && player.isSneaking() && Wizardry.settings.enableShiftScrolling){ @@ -100,19 +109,19 @@ public final class WizardryClientEventHandler { // Bow zoom. Taken directly from AbstractClientPlayer so it works exactly like vanilla. if(event.getEntity().isHandActive() && event.getEntity().getActiveItemStack() != null && event.getEntity().getActiveItemStack().getItem() instanceof ItemSpectralBow){ - - int maxUseTicks = event.getEntity().getItemInUseMaxCount(); - - float maxUseSeconds = (float)maxUseTicks / 20.0F; - if(maxUseSeconds > 1.0F){ - maxUseSeconds = 1.0F; - }else{ - maxUseSeconds = maxUseSeconds * maxUseSeconds; - } + int maxUseTicks = event.getEntity().getItemInUseMaxCount(); - event.setNewfov(event.getFov() * 1.0F - maxUseSeconds * 0.15F); - } + float maxUseSeconds = (float)maxUseTicks / 20.0F; + + if(maxUseSeconds > 1.0F){ + maxUseSeconds = 1.0F; + }else{ + maxUseSeconds = maxUseSeconds * maxUseSeconds; + } + + event.setNewfov(event.getFov() * 1.0F - maxUseSeconds * 0.15F); + } } // Third person @@ -128,126 +137,101 @@ public final class WizardryClientEventHandler { public static void onRenderWorldLastEvent(RenderWorldLastEvent event){ // Now only fires in first person. if(Minecraft.getMinecraft().gameSettings.thirdPersonView == 0){ - renderShieldFirstPerson(Minecraft.getMinecraft().thePlayer); - renderShadowWardFirstPerson(Minecraft.getMinecraft().thePlayer); + renderShieldFirstPerson(Minecraft.getMinecraft().player); + renderShadowWardFirstPerson(Minecraft.getMinecraft().player); } } @SubscribeEvent public static void onRenderLivingEvent(RenderLivingEvent.Post event){ - /* - // Frost effect - if(event.entity.isPotionActive(Wizardry.frost)){ + /* // Frost effect if(event.entity.isPotionActive(Wizardry.frost)){ + * + * GlStateManager.pushMatrix(); GL11.glDisable(GL11.GL_TEXTURE_2D); GlStateManager.enableBlend(); + * GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + * + * float someScalingFactor = 0.0625f; + * + * float yaw = event.entity.prevRotationYaw; + * + * //int brightness = event.entity.getBrightnessForRender(0); + * + * //int j = brightness % 65536; //int k = brightness / 65536; + * //OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); + * //GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + * + * + * GlStateManager.translate(event.x, event.y, event.z); + * + * GlStateManager.rotate(-yaw + 180, 0F, 1F, 0F); + * + * Render render = renderManager.getEntityRenderObject(event.entity); + * + * RenderLiving renderliving = event.renderer; + * + * // Reflection + * + * try { + * + * Timer timer = ReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "timer"); + * + * // Chooses the appropriate zombie model, normal or villager // Fixed by moving before the model fields are + * accessed if(render instanceof RenderZombie && event.entity instanceof EntityZombie){ // The second argument + * is never used... ReflectionHelper.findMethod(RenderZombie.class, (RenderZombie)render, new + * String[]{"func_82427_a"}, EntityZombie.class) .invoke(renderliving, (EntityZombie)event.entity); } + * + * // Turns out that java automatically infers the type parameter T in this method from the type // I am + * assigning the returned value to. Neat! ModelBase mainModel = + * ReflectionHelper.getPrivateValue(RenderLiving.class, renderliving, "mainModel"); + * + * mainModel.isRiding = event.entity.isRiding(); mainModel.isChild = event.entity.isChild(); + * + * GlStateManager.enableRescaleNormal(); GlStateManager.scale(-1.0F, -1.0F, 1.0F); + * + * // The second argument is never used... ReflectionHelper.findMethod(RenderLiving.class, renderliving, new + * String[]{"preRenderCallback"}, EntityLivingBase.class, float.class) .invoke(renderliving, event.entity, + * someScalingFactor); + * + * // Why is this -1.5f? No idea! GlStateManager.translate(0, -1.5f, 0); + * + * float f6 = event.entity.prevLimbSwingAmount + (event.entity.limbSwingAmount - + * event.entity.prevLimbSwingAmount) * timer.renderPartialTicks; float f7 = event.entity.limbSwing - + * event.entity.limbSwingAmount * (1.0F - timer.renderPartialTicks); + * + * if (event.entity.isChild()) { f7 *= 3.0F; } + * + * if (f6 > 1.0F) { f6 = 1.0F; } + * + * mainModel.setLivingAnimations(event.entity, f7, f6, timer.renderPartialTicks); + * + * GlStateManager.enableAlpha(); GlStateManager.color(0.5f, 0.7f, 1, 0.5f); + * + * mainModel.render(event.entity, f7, f6, 0, 0, 0, someScalingFactor); + * + * GL11.glDepthMask(true); + * + * // 'Pokemon' exception handling... Because why not?! } catch (Exception e) { + * System.err.println("Something went very wrong! Error while rendering frost effect:"); e.printStackTrace(); } + * + * GlStateManager.disableAlpha(); GlStateManager.disableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, + * GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.disableRescaleNormal(); GL11.glEnable(GL11.GL_TEXTURE_2D); + * GlStateManager.popMatrix(); } */ - GlStateManager.pushMatrix(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - float someScalingFactor = 0.0625f; - - float yaw = event.entity.prevRotationYaw; - - //int brightness = event.entity.getBrightnessForRender(0); - - //int j = brightness % 65536; - //int k = brightness / 65536; - //OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); - //GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - - - GlStateManager.translate(event.x, event.y, event.z); - - GlStateManager.rotate(-yaw + 180, 0F, 1F, 0F); - - Render render = renderManager.getEntityRenderObject(event.entity); - - RenderLiving renderliving = event.renderer; - - // Reflection - - try { - - Timer timer = ReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "timer"); - - // Chooses the appropriate zombie model, normal or villager - // Fixed by moving before the model fields are accessed - if(render instanceof RenderZombie && event.entity instanceof EntityZombie){ - // The second argument is never used... - ReflectionHelper.findMethod(RenderZombie.class, (RenderZombie)render, new String[]{"func_82427_a"}, EntityZombie.class) - .invoke(renderliving, (EntityZombie)event.entity); - } - - // Turns out that java automatically infers the type parameter T in this method from the type - // I am assigning the returned value to. Neat! - ModelBase mainModel = ReflectionHelper.getPrivateValue(RenderLiving.class, renderliving, "mainModel"); - - mainModel.isRiding = event.entity.isRiding(); - mainModel.isChild = event.entity.isChild(); - - GlStateManager.enableRescaleNormal(); - GlStateManager.scale(-1.0F, -1.0F, 1.0F); - - // The second argument is never used... - ReflectionHelper.findMethod(RenderLiving.class, renderliving, new String[]{"preRenderCallback"}, EntityLivingBase.class, float.class) - .invoke(renderliving, event.entity, someScalingFactor); - - // Why is this -1.5f? No idea! - GlStateManager.translate(0, -1.5f, 0); - - float f6 = event.entity.prevLimbSwingAmount + (event.entity.limbSwingAmount - event.entity.prevLimbSwingAmount) * timer.renderPartialTicks; - float f7 = event.entity.limbSwing - event.entity.limbSwingAmount * (1.0F - timer.renderPartialTicks); - - if (event.entity.isChild()) - { - f7 *= 3.0F; - } - - if (f6 > 1.0F) - { - f6 = 1.0F; - } - - mainModel.setLivingAnimations(event.entity, f7, f6, timer.renderPartialTicks); - - GlStateManager.enableAlpha(); - GlStateManager.color(0.5f, 0.7f, 1, 0.5f); - - mainModel.render(event.entity, f7, f6, 0, 0, 0, someScalingFactor); - - GL11.glDepthMask(true); - - // 'Pokemon' exception handling... Because why not?! - } catch (Exception e) { - System.err.println("Something went very wrong! Error while rendering frost effect:"); - e.printStackTrace(); - } - - GlStateManager.disableAlpha(); - GlStateManager.disableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.disableRescaleNormal(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GlStateManager.popMatrix(); - } - */ - Minecraft mc = Minecraft.getMinecraft(); - WizardData properties = WizardData.get(mc.thePlayer); - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(mc.theWorld, mc.thePlayer, 16); + WizardData properties = WizardData.get(mc.player); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(mc.world, mc.player, 16); RenderManager renderManager = event.getRenderer().getRenderManager(); - - ItemStack wand = mc.thePlayer.getHeldItemMainhand(); + + ItemStack wand = mc.player.getHeldItemMainhand(); if(wand == null || !(wand.getItem() instanceof ItemWand)){ - wand = mc.thePlayer.getHeldItemOffhand(); + wand = mc.player.getHeldItemOffhand(); } - + // Target selection pointer - if(mc.thePlayer.isSneaking() && wand != null && wand.getItem() instanceof ItemWand && rayTrace != null + if(mc.player.isSneaking() && wand != null && wand.getItem() instanceof ItemWand && rayTrace != null && rayTrace.entityHit instanceof EntityLivingBase && rayTrace.entityHit == event.getEntity() && properties != null && properties.selectedMinion != null){ - + Tessellator tessellator = Tessellator.getInstance(); VertexBuffer buffer = tessellator.getBuffer(); @@ -273,9 +257,9 @@ public final class WizardryClientEventHandler { mc.renderEngine.bindTexture(targetPointerTexture); buffer.pos(-0.2, 0.24, 0).tex(0, 0).endVertex(); - buffer.pos(0.2, 0.24, 0).tex(9f/16f, 0).endVertex(); - buffer.pos(0.2, -0.24, 0).tex(9f/16f, 11f/16f).endVertex(); - buffer.pos(-0.2, -0.24, 0).tex(0, 11f/16f).endVertex(); + buffer.pos(0.2, 0.24, 0).tex(9f / 16f, 0).endVertex(); + buffer.pos(0.2, -0.24, 0).tex(9f / 16f, 11f / 16f).endVertex(); + buffer.pos(-0.2, -0.24, 0).tex(0, 11f / 16f).endVertex(); tessellator.draw(); @@ -287,8 +271,9 @@ public final class WizardryClientEventHandler { } // Summoned creature selection pointer - if(properties != null && properties.selectedMinion != null && properties.selectedMinion.get() == event.getEntity()){ - + if(properties != null && properties.selectedMinion != null + && properties.selectedMinion.get() == event.getEntity()){ + Tessellator tessellator = Tessellator.getInstance(); VertexBuffer buffer = tessellator.getBuffer(); @@ -314,9 +299,9 @@ public final class WizardryClientEventHandler { mc.renderEngine.bindTexture(pointerTexture); buffer.pos(-0.2, 0.24, 0).tex(0, 0).endVertex(); - buffer.pos(0.2, 0.24, 0).tex(9f/16f, 0).endVertex(); - buffer.pos(0.2, -0.24, 0).tex(9f/16f, 11f/16f).endVertex(); - buffer.pos(-0.2, -0.24, 0).tex(0, 11f/16f).endVertex(); + buffer.pos(0.2, 0.24, 0).tex(9f / 16f, 0).endVertex(); + buffer.pos(0.2, -0.24, 0).tex(9f / 16f, 11f / 16f).endVertex(); + buffer.pos(-0.2, -0.24, 0).tex(0, 11f / 16f).endVertex(); tessellator.draw(); @@ -326,11 +311,13 @@ public final class WizardryClientEventHandler { GlStateManager.popMatrix(); } - + // Sixth sense - if(mc.thePlayer.isPotionActive(WizardryPotions.sixth_sense) && event.getEntity() != mc.thePlayer - && mc.thePlayer.getActivePotionEffect(WizardryPotions.sixth_sense) != null - && event.getEntity().getDistanceToEntity(mc.thePlayer) < 20*(1+mc.thePlayer.getActivePotionEffect(WizardryPotions.sixth_sense).getAmplifier()*Constants.RANGE_INCREASE_PER_LEVEL)){ + if(mc.player.isPotionActive(WizardryPotions.sixth_sense) && event.getEntity() != mc.player + && mc.player.getActivePotionEffect(WizardryPotions.sixth_sense) != null + && event.getEntity().getDistanceToEntity(mc.player) < 20 + * (1 + mc.player.getActivePotionEffect(WizardryPotions.sixth_sense).getAmplifier() + * Constants.RANGE_INCREASE_PER_LEVEL)){ Tessellator tessellator = Tessellator.getInstance(); VertexBuffer buffer = tessellator.getBuffer(); @@ -375,9 +362,9 @@ public final class WizardryClientEventHandler { @SubscribeEvent public static void onRenderGameOverlayEvent(RenderGameOverlayEvent.Post event){ - + if(event.getType() == RenderGameOverlayEvent.ElementType.HELMET - && Minecraft.getMinecraft().thePlayer.isPotionActive(WizardryPotions.sixth_sense)){ + && Minecraft.getMinecraft().player.isPotionActive(WizardryPotions.sixth_sense)){ GlStateManager.pushMatrix(); @@ -387,17 +374,18 @@ public final class WizardryClientEventHandler { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.disableAlpha(); Minecraft.getMinecraft().renderEngine.bindTexture(sixthSenseOverlayTexture); - + Tessellator tessellator = Tessellator.getInstance(); VertexBuffer buffer = tessellator.getBuffer(); - + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.pos(0.0D, (double)event.getResolution().getScaledHeight(), -90.0D).tex(0.0D, 1.0D).endVertex(); - buffer.pos((double)event.getResolution().getScaledWidth(), (double)event.getResolution().getScaledHeight(), -90.0D).tex(1.0D, 1.0D).endVertex(); + buffer.pos((double)event.getResolution().getScaledWidth(), (double)event.getResolution().getScaledHeight(), + -90.0D).tex(1.0D, 1.0D).endVertex(); buffer.pos((double)event.getResolution().getScaledWidth(), 0.0D, -90.0D).tex(1.0D, 0.0D).endVertex(); buffer.pos(0.0D, 0.0D, -90.0D).tex(0.0D, 0.0D).endVertex(); tessellator.draw(); - + GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); GlStateManager.enableAlpha(); @@ -407,7 +395,7 @@ public final class WizardryClientEventHandler { } if(event.getType() == RenderGameOverlayEvent.ElementType.HELMET - && Minecraft.getMinecraft().thePlayer.isPotionActive(WizardryPotions.frost)){ + && Minecraft.getMinecraft().player.isPotionActive(WizardryPotions.frost)){ GlStateManager.pushMatrix(); @@ -417,16 +405,17 @@ public final class WizardryClientEventHandler { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.disableAlpha(); Minecraft.getMinecraft().renderEngine.bindTexture(frostOverlayTexture); - + Tessellator tessellator = Tessellator.getInstance(); VertexBuffer buffer = tessellator.getBuffer(); - + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.pos(0.0D, (double)event.getResolution().getScaledHeight(), -90.0D).tex(0.0D, 1.0D).endVertex(); - buffer.pos((double)event.getResolution().getScaledWidth(), (double)event.getResolution().getScaledHeight(), -90.0D).tex(1.0D, 1.0D).endVertex(); + buffer.pos((double)event.getResolution().getScaledWidth(), (double)event.getResolution().getScaledHeight(), + -90.0D).tex(1.0D, 1.0D).endVertex(); buffer.pos((double)event.getResolution().getScaledWidth(), 0.0D, -90.0D).tex(1.0D, 0.0D).endVertex(); buffer.pos(0.0D, 0.0D, -90.0D).tex(0.0D, 0.0D).endVertex(); - + tessellator.draw(); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); @@ -440,8 +429,10 @@ public final class WizardryClientEventHandler { // FIXME: Something in here is making the first person shadow ward rather translucent. private static void renderShadowWardFirstPerson(EntityPlayer entityplayer){ ItemStack wand = entityplayer.getActiveItemStack(); - if(WizardData.get(entityplayer) != null && WizardData.get(entityplayer).currentlyCasting() instanceof ShadowWard || (entityplayer.isHandActive() && wand != null && wand.getItemDamage() < wand.getMaxDamage() - && wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof ShadowWard)){ + if(WizardData.get(entityplayer) != null && WizardData.get(entityplayer).currentlyCasting() instanceof ShadowWard + || (entityplayer.isHandActive() && wand != null && wand.getItemDamage() < wand.getMaxDamage() + && wand.getItem() instanceof ItemWand + && WandHelper.getCurrentSpell(wand) instanceof ShadowWard)){ GlStateManager.pushMatrix(); @@ -455,18 +446,18 @@ public final class WizardryClientEventHandler { GlStateManager.translate(0, 1.2, 0); GlStateManager.rotate(-entityplayer.rotationYaw, 0, 1, 0); GlStateManager.rotate(entityplayer.rotationPitch, 1, 0, 0); - + Minecraft.getMinecraft().renderEngine.bindTexture(shadowWardTexture); GlStateManager.pushMatrix(); GlStateManager.translate(0, 0, 1.2); - GlStateManager.rotate(entityplayer.worldObj.getWorldTime()*-2, 0, 0, 1); + GlStateManager.rotate(entityplayer.world.getWorldTime() * -2, 0, 0, 1); GlStateManager.scale(1.1, 1.1, 1.1); Tessellator tessellator = Tessellator.getInstance(); VertexBuffer buffer = tessellator.getBuffer(); - + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.pos(-0.5, 0.5, -0.5).tex(0, 0).endVertex(); @@ -498,8 +489,9 @@ public final class WizardryClientEventHandler { private static void renderShadowWardIfActive(EntityPlayer entityplayer){ ItemStack wand = entityplayer.getActiveItemStack(); - if(WizardData.get(entityplayer).currentlyCasting() instanceof ShadowWard || (entityplayer.isHandActive() && wand != null - && wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof ShadowWard)){ + if(WizardData.get(entityplayer).currentlyCasting() instanceof ShadowWard || (entityplayer.isHandActive() + && wand != null && wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand + && WandHelper.getCurrentSpell(wand) instanceof ShadowWard)){ GlStateManager.pushMatrix(); @@ -510,14 +502,14 @@ public final class WizardryClientEventHandler { GlStateManager.rotate(180, 0, 1, 0); GlStateManager.rotate(-entityplayer.renderYawOffset, 0, 1, 0); - + Minecraft.getMinecraft().renderEngine.bindTexture(shadowWardTexture); - + Tessellator tessellator = Tessellator.getInstance(); VertexBuffer buffer = tessellator.getBuffer(); GlStateManager.translate(0, 1.2, 0); - GlStateManager.rotate(entityplayer.worldObj.getWorldTime()*-2, 0, 0, 1); + GlStateManager.rotate(entityplayer.world.getWorldTime() * -2, 0, 0, 1); GlStateManager.scale(1.1, 1.1, 1.1); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); @@ -548,8 +540,9 @@ public final class WizardryClientEventHandler { private static void renderWingsIfActive(EntityPlayer entityplayer, float partialTickTime){ ItemStack wand = entityplayer.getActiveItemStack(); - if(WizardData.get(entityplayer).currentlyCasting() instanceof Flight || (entityplayer.isHandActive() && wand != null - && wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof Flight)){ + if(WizardData.get(entityplayer).currentlyCasting() instanceof Flight + || (entityplayer.isHandActive() && wand != null && wand.getItemDamage() < wand.getMaxDamage() + && wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof Flight)){ GlStateManager.pushMatrix(); @@ -558,9 +551,9 @@ public final class WizardryClientEventHandler { GlStateManager.disableLighting(); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); - //GlStateManager.rotate(-entityplayer.rotationYawHead, 0, 1, 0); + // GlStateManager.rotate(-entityplayer.rotationYawHead, 0, 1, 0); GlStateManager.rotate(-entityplayer.renderYawOffset, 0, 1, 0); - //GlStateManager.rotate(180, 1, 0, 0); + // GlStateManager.rotate(180, 1, 0, 0); Minecraft.getMinecraft().renderEngine.bindTexture(wingTexture); Tessellator tessellator = Tessellator.getInstance(); @@ -569,7 +562,7 @@ public final class WizardryClientEventHandler { GlStateManager.pushMatrix(); GlStateManager.translate(0.1, 0.4, -0.15); - GlStateManager.rotate(20 + 20*(float)Math.sin(entityplayer.worldObj.getWorldTime()*0.3), 0, 1, 0); + GlStateManager.rotate(20 + 20 * (float)Math.sin(entityplayer.world.getWorldTime() * 0.3), 0, 1, 0); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); @@ -594,7 +587,7 @@ public final class WizardryClientEventHandler { GlStateManager.pushMatrix(); GlStateManager.translate(-0.1, 0.4, -0.15); - GlStateManager.rotate(-200 - 20*(float)Math.sin(entityplayer.worldObj.getWorldTime()*0.3), 0, 1, 0); + GlStateManager.rotate(-200 - 20 * (float)Math.sin(entityplayer.world.getWorldTime() * 0.3), 0, 1, 0); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); @@ -625,8 +618,10 @@ public final class WizardryClientEventHandler { private static void renderShieldFirstPerson(EntityPlayer entityplayer){ ItemStack wand = entityplayer.getActiveItemStack(); - if(WizardData.get(entityplayer) != null && WizardData.get(entityplayer).shield != null && (WizardData.get(entityplayer).currentlyCasting() instanceof Shield || (entityplayer.isHandActive() && wand != null - && wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof Shield))){ + if(WizardData.get(entityplayer) != null && WizardData.get(entityplayer).shield != null + && (WizardData.get(entityplayer).currentlyCasting() instanceof Shield || (entityplayer.isHandActive() + && wand != null && wand.getItemDamage() < wand.getMaxDamage() + && wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof Shield))){ GlStateManager.pushMatrix(); @@ -649,13 +644,13 @@ public final class WizardryClientEventHandler { Minecraft.getMinecraft().renderEngine.bindTexture(shieldTexture); renderShield(tessellator); - + GlStateManager.enableLighting(); GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.enableCull(); GlStateManager.disableBlend(); - //RenderHelper.enableStandardItemLighting(); + // RenderHelper.enableStandardItemLighting(); GlStateManager.popMatrix(); } @@ -663,8 +658,10 @@ public final class WizardryClientEventHandler { private static void renderShieldIfActive(EntityPlayer entityplayer){ ItemStack wand = entityplayer.getActiveItemStack(); - if(WizardData.get(entityplayer).shield != null && (WizardData.get(entityplayer).currentlyCasting() instanceof Shield || (entityplayer.isHandActive() && wand != null - && wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof Shield))){ + if(WizardData.get(entityplayer).shield != null + && (WizardData.get(entityplayer).currentlyCasting() instanceof Shield || (entityplayer.isHandActive() + && wand != null && wand.getItemDamage() < wand.getMaxDamage() + && wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof Shield))){ GlStateManager.pushMatrix(); @@ -679,9 +676,9 @@ public final class WizardryClientEventHandler { GlStateManager.translate(0, 1.3, 0); - //GlStateManager.rotate(180, 0, 1, 0); + // GlStateManager.rotate(180, 0, 1, 0); GlStateManager.rotate(-entityplayer.renderYawOffset, 0, 1, 0); - //GlStateManager.rotate(-entityplayer.rotationPitch, 1, 0, 0); + // GlStateManager.rotate(-entityplayer.rotationPitch, 1, 0, 0); GlStateManager.translate(0, 0, 0.8); @@ -696,7 +693,7 @@ public final class WizardryClientEventHandler { GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.enableCull(); GlStateManager.disableBlend(); - //RenderHelper.enableStandardItemLighting(); + // RenderHelper.enableStandardItemLighting(); GlStateManager.popMatrix(); } diff --git a/src/main/java/electroblob/wizardry/client/model/ModelHammer.java b/src/main/java/electroblob/wizardry/client/model/ModelHammer.java index e1445f05..85a164f7 100644 --- a/src/main/java/electroblob/wizardry/client/model/ModelHammer.java +++ b/src/main/java/electroblob/wizardry/client/model/ModelHammer.java @@ -4,80 +4,75 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -public class ModelHammer extends ModelBase -{ - ModelRenderer Shape1; - ModelRenderer Shape2; - ModelRenderer Shape3; - ModelRenderer Shape4; - ModelRenderer Shape5; - ModelRenderer Shape6; - - public ModelHammer() - { - textureWidth = 64; - textureHeight = 64; - - Shape1 = new ModelRenderer(this, 0, 0); - Shape1.addBox(0F, 0F, 0F, 20, 12, 12); - Shape1.setRotationPoint(-10F, 12F, -6F); - Shape1.setTextureSize(64, 64); - Shape1.mirror = true; - setRotation(Shape1, 0F, 0F, 0F); - Shape2 = new ModelRenderer(this, 0, 24); - Shape2.addBox(0F, 0F, 0F, 4, 14, 4); - Shape2.setRotationPoint(-2F, -2F, -2F); - Shape2.setTextureSize(64, 64); - Shape2.mirror = true; - setRotation(Shape2, 0F, 0F, 0F); - Shape3 = new ModelRenderer(this, 0, 49); - Shape3.addBox(0F, 0F, 0F, 5, 5, 5); - Shape3.setRotationPoint(-2.5F, -7F, -2.5F); - Shape3.setTextureSize(64, 64); - Shape3.mirror = true; - setRotation(Shape3, 0F, 0F, 0F); - Shape4 = new ModelRenderer(this, 0, 42); - Shape4.addBox(0F, 0F, 0F, 5, 2, 5); - Shape4.setRotationPoint(-2.5F, 10F, -2.5F); - Shape4.setTextureSize(64, 64); - Shape4.mirror = true; - setRotation(Shape4, 0F, 0F, 0F); - Shape5 = new ModelRenderer(this, 20, 24); - Shape5.addBox(0F, 0F, 0F, 2, 14, 14); - Shape5.setRotationPoint(-8F, 11F, -7F); - Shape5.setTextureSize(64, 64); - Shape5.mirror = true; - setRotation(Shape5, 0F, 0F, 0F); - Shape6 = new ModelRenderer(this, 20, 24); - Shape6.addBox(0F, 0F, 0F, 2, 14, 14); - Shape6.setRotationPoint(6F, 11F, -7F); - Shape6.setTextureSize(64, 64); - Shape6.mirror = true; - setRotation(Shape6, 0F, 0F, 0F); - } - - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - setRotationAngles(f, f1, f2, f3, f4, f5, entity); - Shape1.render(f5); - Shape2.render(f5); - Shape3.render(f5); - Shape4.render(f5); - Shape5.render(f5); - Shape6.render(f5); - } - - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } - - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) - { - super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - } +public class ModelHammer extends ModelBase { + ModelRenderer Shape1; + ModelRenderer Shape2; + ModelRenderer Shape3; + ModelRenderer Shape4; + ModelRenderer Shape5; + ModelRenderer Shape6; + + public ModelHammer(){ + textureWidth = 64; + textureHeight = 64; + + Shape1 = new ModelRenderer(this, 0, 0); + Shape1.addBox(0F, 0F, 0F, 20, 12, 12); + Shape1.setRotationPoint(-10F, 12F, -6F); + Shape1.setTextureSize(64, 64); + Shape1.mirror = true; + setRotation(Shape1, 0F, 0F, 0F); + Shape2 = new ModelRenderer(this, 0, 24); + Shape2.addBox(0F, 0F, 0F, 4, 14, 4); + Shape2.setRotationPoint(-2F, -2F, -2F); + Shape2.setTextureSize(64, 64); + Shape2.mirror = true; + setRotation(Shape2, 0F, 0F, 0F); + Shape3 = new ModelRenderer(this, 0, 49); + Shape3.addBox(0F, 0F, 0F, 5, 5, 5); + Shape3.setRotationPoint(-2.5F, -7F, -2.5F); + Shape3.setTextureSize(64, 64); + Shape3.mirror = true; + setRotation(Shape3, 0F, 0F, 0F); + Shape4 = new ModelRenderer(this, 0, 42); + Shape4.addBox(0F, 0F, 0F, 5, 2, 5); + Shape4.setRotationPoint(-2.5F, 10F, -2.5F); + Shape4.setTextureSize(64, 64); + Shape4.mirror = true; + setRotation(Shape4, 0F, 0F, 0F); + Shape5 = new ModelRenderer(this, 20, 24); + Shape5.addBox(0F, 0F, 0F, 2, 14, 14); + Shape5.setRotationPoint(-8F, 11F, -7F); + Shape5.setTextureSize(64, 64); + Shape5.mirror = true; + setRotation(Shape5, 0F, 0F, 0F); + Shape6 = new ModelRenderer(this, 20, 24); + Shape6.addBox(0F, 0F, 0F, 2, 14, 14); + Shape6.setRotationPoint(6F, 11F, -7F); + Shape6.setTextureSize(64, 64); + Shape6.mirror = true; + setRotation(Shape6, 0F, 0F, 0F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5){ + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + Shape1.render(f5); + Shape2.render(f5); + Shape3.render(f5); + Shape4.render(f5); + Shape5.render(f5); + Shape6.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z){ + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity){ + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + } } diff --git a/src/main/java/electroblob/wizardry/client/model/ModelIceGiant.java b/src/main/java/electroblob/wizardry/client/model/ModelIceGiant.java index 4a8591d7..798cfcb4 100644 --- a/src/main/java/electroblob/wizardry/client/model/ModelIceGiant.java +++ b/src/main/java/electroblob/wizardry/client/model/ModelIceGiant.java @@ -13,309 +13,299 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class ModelIceGiant extends ModelBase -{ - /** The head model for the iron golem. */ - public ModelRenderer iceGiantHead; +public class ModelIceGiant extends ModelBase { + /** The head model for the iron golem. */ + public ModelRenderer iceGiantHead; - /** The body model for the iron golem. */ - public ModelRenderer iceGiantBody; + /** The body model for the iron golem. */ + public ModelRenderer iceGiantBody; - /** The right arm model for the iron golem. */ - public ModelRenderer iceGiantRightArm; + /** The right arm model for the iron golem. */ + public ModelRenderer iceGiantRightArm; - /** The left arm model for the iron golem. */ - public ModelRenderer iceGiantLeftArm; + /** The left arm model for the iron golem. */ + public ModelRenderer iceGiantLeftArm; - /** The left leg model for the Iron Golem. */ - public ModelRenderer iceGiantLeftLeg; + /** The left leg model for the Iron Golem. */ + public ModelRenderer iceGiantLeftLeg; - /** The right leg model for the Iron Golem. */ - public ModelRenderer iceGiantRightLeg; - - ModelRenderer headSpike1; - ModelRenderer headSpike2; - ModelRenderer headSpike3; - ModelRenderer headSpike4; - ModelRenderer headSpike5; - ModelRenderer headSpike6; - ModelRenderer headSpike7; - ModelRenderer rightArmSpike1; - ModelRenderer rightArmSpike2; - ModelRenderer leftArmSpike1; - ModelRenderer leftArmSpike2; - ModelRenderer bodySpike1; - ModelRenderer bodySpike2; - ModelRenderer bodySpike3; - ModelRenderer bodySpike4; - ModelRenderer bodySpike5; + /** The right leg model for the Iron Golem. */ + public ModelRenderer iceGiantRightLeg; - public ModelIceGiant() - { - this(0.0F); - } + ModelRenderer headSpike1; + ModelRenderer headSpike2; + ModelRenderer headSpike3; + ModelRenderer headSpike4; + ModelRenderer headSpike5; + ModelRenderer headSpike6; + ModelRenderer headSpike7; + ModelRenderer rightArmSpike1; + ModelRenderer rightArmSpike2; + ModelRenderer leftArmSpike1; + ModelRenderer leftArmSpike2; + ModelRenderer bodySpike1; + ModelRenderer bodySpike2; + ModelRenderer bodySpike3; + ModelRenderer bodySpike4; + ModelRenderer bodySpike5; - public ModelIceGiant(float par1) - { - this(par1, -7.0F); - } + public ModelIceGiant(){ + this(0.0F); + } - public ModelIceGiant(float par1, float par2) - { - short short1 = 128; - short short2 = 128; - - this.iceGiantHead = (new ModelRenderer(this)).setTextureSize(short1, short2); - this.iceGiantHead.setRotationPoint(0.0F, 0.0F + par2, -1.0F); - this.iceGiantHead.setTextureOffset(0, 10).addBox(-6.0F, -14.0F, -6.5F, 12, 12, 12, par1); - - this.iceGiantBody = (new ModelRenderer(this)).setTextureSize(short1, short2); - this.iceGiantBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F); - this.iceGiantBody.setTextureOffset(0, 40).addBox(-9.0F, -2.0F, -6.0F, 18, 12, 11, par1); - this.iceGiantBody.setTextureOffset(0, 70).addBox(-4.5F, 10.0F, -3.0F, 9, 5, 6, par1 + 0.5F); - - this.iceGiantRightArm = (new ModelRenderer(this)).setTextureSize(short1, short2); - this.iceGiantRightArm.setRotationPoint(0.0F, -7.0F, 0.0F); - this.iceGiantRightArm.setTextureOffset(60, 21).addBox(-13.0F, -2.5F, -3.0F, 4, 30, 6, par1); - - this.iceGiantLeftArm = (new ModelRenderer(this)).setTextureSize(short1, short2); - this.iceGiantLeftArm.setRotationPoint(0.0F, -7.0F, 0.0F); - this.iceGiantLeftArm.setTextureOffset(60, 58).addBox(9.0F, -2.5F, -3.0F, 4, 30, 6, par1); - - this.iceGiantLeftLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(short1, short2); - this.iceGiantLeftLeg.setRotationPoint(-4.0F, 18.0F + par2, 0.0F); - this.iceGiantLeftLeg.setTextureOffset(37, 0).addBox(-3.5F, -3.0F, -3.0F, 6, 16, 5, par1); - - this.iceGiantRightLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(short1, short2); - this.iceGiantRightLeg.mirror = true; - this.iceGiantRightLeg.setTextureOffset(60, 0).setRotationPoint(5.0F, 18.0F + par2, 0.0F); - this.iceGiantRightLeg.addBox(-3.5F, -3.0F, -3.0F, 6, 16, 5, par1); - - headSpike1 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); - headSpike1.addBox(-4F, -4F, 0F, 4, 4, 4); - headSpike1.setRotationPoint(-4F, -10F, -5F); - headSpike1.mirror = true; - setRotationWithEulerYzx(headSpike1, -0.1047198F, -0.5235988F, 0.9599311F); - - headSpike2 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); - headSpike2.addBox(0F, -4F, 0F, 4, 4, 4); - headSpike2.setRotationPoint(4F, -16F, 0F); - headSpike2.mirror = true; - setRotationWithEulerYzx(headSpike2, 0.5585054F, 0.9250245F, -0.5235988F); - - headSpike3 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); - headSpike3.addBox(-2F, -2F, -2F, 4, 4, 4); - headSpike3.setRotationPoint(4F, -13F, 4F); - headSpike3.mirror = true; - setRotationWithEulerYzx(headSpike3, 0.7853982F, -1.396263F, 0.7853982F); - - headSpike4 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); - headSpike4.addBox(-4F, -4F, 0F, 4, 4, 4); - headSpike4.setRotationPoint(-4F, -16F, 0F); - headSpike4.mirror = true; - setRotationWithEulerYzx(headSpike4, 0.5585054F, -0.9250245F, 0.5235988F); - - headSpike5 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); - headSpike5.addBox(0F, -4F, 0F, 4, 4, 4); - headSpike5.setRotationPoint(4F, -10F, -5F); - headSpike5.mirror = true; - setRotationWithEulerYzx(headSpike5, 0.5235988F, -0.9599311F, 0.1047198F); - - rightArmSpike1 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); - rightArmSpike1.addBox(-2F, -2F, -2F, 4, 4, 4); - rightArmSpike1.setRotationPoint(-11F, -8F, 0F); - rightArmSpike1.mirror = true; - setRotationWithEulerYzx(rightArmSpike1, 0.7853982F, 1.134464F, 0.9599311F); - - headSpike6 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); - headSpike6.addBox(-2F, -2F, -2F, 4, 4, 4); - headSpike6.setRotationPoint(-4F, -13F, 4F); - headSpike6.mirror = true; - setRotationWithEulerYzx(headSpike6, 0.7853982F, -1.745329F, 0.7853982F); - - leftArmSpike1 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); - leftArmSpike1.addBox(-2F, -2F, -2F, 4, 4, 4); - leftArmSpike1.setRotationPoint(11F, -8F, 0F); - leftArmSpike1.mirror = true; - setRotationWithEulerYzx(leftArmSpike1, 0.7853982F, -1.134464F, -0.9599311F); - - leftArmSpike2 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); - leftArmSpike2.addBox(-2F, -2F, -2F, 4, 4, 4); - leftArmSpike2.setRotationPoint(12F, -4F, 0F); - leftArmSpike2.mirror = true; - setRotationWithEulerYzx(leftArmSpike2, 0.7853982F, 0F, -0.9599311F); - - bodySpike1 = new ModelRenderer(this, 32, 69).setTextureSize(short1, short2); - bodySpike1.addBox(-3F, -3F, -3F, 6, 6, 6); - bodySpike1.setRotationPoint(-4F, -4F, 3F); - bodySpike1.mirror = true; - setRotationWithEulerYzx(bodySpike1, 0.2808018F, 0.8096675F, 0.8339369F); - - rightArmSpike2 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); - rightArmSpike2.addBox(-2F, -2F, -2F, 4, 4, 4); - rightArmSpike2.setRotationPoint(-12F, -4F, 0F); - rightArmSpike2.mirror = true; - setRotationWithEulerYzx(rightArmSpike2, 0.7853982F, 0F, 0.9599311F); - - bodySpike2 = new ModelRenderer(this, 32, 69).setTextureSize(short1, short2); - bodySpike2.addBox(-3F, -3F, -3F, 6, 6, 6); - bodySpike2.setRotationPoint(4F, -4F, 3F); - bodySpike2.mirror = true; - setRotationWithEulerYzx(bodySpike2, 0.2808018F, -0.8096757F, -0.8339358F); - - bodySpike3 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); - bodySpike3.addBox(-2F, -2F, -2F, 4, 4, 4); - bodySpike3.setRotationPoint(6F, -2F, -5F); - bodySpike3.mirror = true; - setRotationWithEulerYzx(bodySpike3, 1.120006F, -1.347726F, -0.8969422F); - - bodySpike4 = new ModelRenderer(this, 32, 69).setTextureSize(short1, short2); - bodySpike4.addBox(-3F, -3F, -3F, 6, 6, 6); - bodySpike4.setRotationPoint(0F, -4F, -4F); - bodySpike4.mirror = true; - setRotationWithEulerYzx(bodySpike4, 0.7853982F, -1.570796F, 0.9599311F); - - headSpike7 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); - headSpike7.addBox(-2F, -2F, -2F, 4, 4, 4); - headSpike7.setRotationPoint(0F, -20F, 4F); - headSpike7.mirror = true; - setRotationWithEulerYzx(headSpike7, 0.7853982F, 1.570796F, 0.7853982F); - - bodySpike5 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); - bodySpike5.addBox(-2F, -2F, -2F, 4, 4, 4); - bodySpike5.setRotationPoint(-6F, -2F, -5F); - bodySpike5.mirror = true; - setRotationWithEulerYzx(bodySpike5, 1.120006F, 1.347725F, 0.896934F); - - this.convertToChild(this.iceGiantHead, headSpike1); - this.convertToChild(this.iceGiantHead, headSpike2); - this.convertToChild(this.iceGiantHead, headSpike3); - this.convertToChild(this.iceGiantHead, headSpike4); - this.convertToChild(this.iceGiantHead, headSpike5); - this.convertToChild(this.iceGiantHead, headSpike6); - this.convertToChild(this.iceGiantHead, headSpike7); - this.convertToChild(this.iceGiantRightArm, rightArmSpike1); - this.convertToChild(this.iceGiantRightArm, rightArmSpike2); - this.convertToChild(this.iceGiantLeftArm, leftArmSpike1); - this.convertToChild(this.iceGiantLeftArm, leftArmSpike2); - this.convertToChild(this.iceGiantBody, bodySpike1); - this.convertToChild(this.iceGiantBody, bodySpike2); - this.convertToChild(this.iceGiantBody, bodySpike3); - this.convertToChild(this.iceGiantBody, bodySpike4); - this.convertToChild(this.iceGiantBody, bodySpike5); - - } + public ModelIceGiant(float par1){ + this(par1, -7.0F); + } - /** - * Sets the models various rotation angles then renders the model. - */ - public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) - { - this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); - this.iceGiantHead.render(par7); - this.iceGiantBody.render(par7); - this.iceGiantLeftLeg.render(par7); - this.iceGiantRightLeg.render(par7); - this.iceGiantRightArm.render(par7); - this.iceGiantLeftArm.render(par7); - } + public ModelIceGiant(float par1, float par2){ + short short1 = 128; + short short2 = 128; - /** - * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms - * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how - * "far" arms and legs can swing at most. - */ - public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) - { - this.iceGiantHead.rotateAngleY = par4 / (180F / (float)Math.PI); - this.iceGiantHead.rotateAngleX = par5 / (180F / (float)Math.PI); - this.iceGiantLeftLeg.rotateAngleX = -1.5F * this.func_78172_a(par1, 13.0F) * par2; - this.iceGiantRightLeg.rotateAngleX = 1.5F * this.func_78172_a(par1, 13.0F) * par2; - this.iceGiantLeftLeg.rotateAngleY = 0.0F; - this.iceGiantRightLeg.rotateAngleY = 0.0F; - } + this.iceGiantHead = (new ModelRenderer(this)).setTextureSize(short1, short2); + this.iceGiantHead.setRotationPoint(0.0F, 0.0F + par2, -1.0F); + this.iceGiantHead.setTextureOffset(0, 10).addBox(-6.0F, -14.0F, -6.5F, 12, 12, 12, par1); - /** - * Used for easily adding entity-dependent animations. The second and third float params here are the same second - * and third as in the setRotationAngles method. - */ - public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) - { - EntityIceGiant entityicegiant = (EntityIceGiant)par1EntityLivingBase; - int i = entityicegiant.getAttackTimer(); + this.iceGiantBody = (new ModelRenderer(this)).setTextureSize(short1, short2); + this.iceGiantBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F); + this.iceGiantBody.setTextureOffset(0, 40).addBox(-9.0F, -2.0F, -6.0F, 18, 12, 11, par1); + this.iceGiantBody.setTextureOffset(0, 70).addBox(-4.5F, 10.0F, -3.0F, 9, 5, 6, par1 + 0.5F); - if (i > 0) - { - this.iceGiantRightArm.rotateAngleX = -2.0F + 1.5F * this.func_78172_a((float)i - par4, 10.0F); - this.iceGiantLeftArm.rotateAngleX = -2.0F + 1.5F * this.func_78172_a((float)i - par4, 10.0F); - } - else - { - this.iceGiantRightArm.rotateAngleX = (-0.2F + 1.5F * this.func_78172_a(par2, 13.0F)) * par3; - this.iceGiantLeftArm.rotateAngleX = (-0.2F - 1.5F * this.func_78172_a(par2, 13.0F)) * par3; - } - } + this.iceGiantRightArm = (new ModelRenderer(this)).setTextureSize(short1, short2); + this.iceGiantRightArm.setRotationPoint(0.0F, -7.0F, 0.0F); + this.iceGiantRightArm.setTextureOffset(60, 21).addBox(-13.0F, -2.5F, -3.0F, 4, 30, 6, par1); - private float func_78172_a(float par1, float par2) - { - return (Math.abs(par1 % par2 - par2 * 0.5F) - par2 * 0.25F) / (par2 * 0.25F); - } - - /** This is really useful for converting the source from a Techne model export - * which will have absolute rotation points that need to be converted before - * creating the addChild() relationship. [Courtesy of jabelar] */ - protected void convertToChild(ModelRenderer parent, ModelRenderer child) - { - // move child rotation point to be relative to parent - child.rotationPointX -= parent.rotationPointX; - child.rotationPointY -= parent.rotationPointY; - child.rotationPointZ -= parent.rotationPointZ; - // make rotations relative to parent - child.rotateAngleX -= parent.rotateAngleX; - child.rotateAngleY -= parent.rotateAngleY; - child.rotateAngleZ -= parent.rotateAngleZ; - // create relationship - parent.addChild(child); - } - - /** Fixes the Techne rotation order bug. [Courtesy of tprk77] */ - private Vector3f ConvertEulerYzxToZyx(Vector3f eulerYzx) { - // Create a matrix from YZX ordered Euler angles - float a = MathHelper.cos(eulerYzx.x); - float b = MathHelper.sin(eulerYzx.x); - float c = MathHelper.cos(eulerYzx.y); - float d = MathHelper.sin(eulerYzx.y); - float e = MathHelper.cos(eulerYzx.z); - float f = MathHelper.sin(eulerYzx.z); - Matrix4f matrix = new Matrix4f(); - matrix.m00 = c * e; - matrix.m01 = b * d - a * c * f; - matrix.m02 = b * c * f + a * d; - matrix.m10 = f; - matrix.m11 = a * e; - matrix.m12 = -b * e; - matrix.m20 = -d * e; - matrix.m21 = a * d * f + b * c; - matrix.m22 = a * c - b * d * f; - matrix.m33 = 1.0F; - // Create ZYX ordered Euler angles from the matrix - Vector3f eulerZyx = new Vector3f(); - eulerZyx.y = (float) Math.asin(MathHelper.clamp_float(-matrix.m20, -1, 1)); - if (MathHelper.abs(matrix.m20) < 0.99999) { - eulerZyx.x = (float) Math.atan2(matrix.m21, matrix.m22); - eulerZyx.z = (float) Math.atan2(matrix.m10, matrix.m00); - } else { - eulerZyx.x = 0.0F; - eulerZyx.z = (float) Math.atan2(-matrix.m01, matrix.m11); - } - return eulerZyx; - } - - private void setRotationWithEulerYzx(ModelRenderer model, float x, float y, float z) { - Vector3f eulerYzx = new Vector3f(x, y, z); - Vector3f eulerZyx = ConvertEulerYzxToZyx(eulerYzx); - model.rotateAngleX = eulerZyx.x; - model.rotateAngleY = eulerZyx.y; - model.rotateAngleZ = eulerZyx.z; - } + this.iceGiantLeftArm = (new ModelRenderer(this)).setTextureSize(short1, short2); + this.iceGiantLeftArm.setRotationPoint(0.0F, -7.0F, 0.0F); + this.iceGiantLeftArm.setTextureOffset(60, 58).addBox(9.0F, -2.5F, -3.0F, 4, 30, 6, par1); + + this.iceGiantLeftLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(short1, short2); + this.iceGiantLeftLeg.setRotationPoint(-4.0F, 18.0F + par2, 0.0F); + this.iceGiantLeftLeg.setTextureOffset(37, 0).addBox(-3.5F, -3.0F, -3.0F, 6, 16, 5, par1); + + this.iceGiantRightLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(short1, short2); + this.iceGiantRightLeg.mirror = true; + this.iceGiantRightLeg.setTextureOffset(60, 0).setRotationPoint(5.0F, 18.0F + par2, 0.0F); + this.iceGiantRightLeg.addBox(-3.5F, -3.0F, -3.0F, 6, 16, 5, par1); + + headSpike1 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); + headSpike1.addBox(-4F, -4F, 0F, 4, 4, 4); + headSpike1.setRotationPoint(-4F, -10F, -5F); + headSpike1.mirror = true; + setRotationWithEulerYzx(headSpike1, -0.1047198F, -0.5235988F, 0.9599311F); + + headSpike2 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); + headSpike2.addBox(0F, -4F, 0F, 4, 4, 4); + headSpike2.setRotationPoint(4F, -16F, 0F); + headSpike2.mirror = true; + setRotationWithEulerYzx(headSpike2, 0.5585054F, 0.9250245F, -0.5235988F); + + headSpike3 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); + headSpike3.addBox(-2F, -2F, -2F, 4, 4, 4); + headSpike3.setRotationPoint(4F, -13F, 4F); + headSpike3.mirror = true; + setRotationWithEulerYzx(headSpike3, 0.7853982F, -1.396263F, 0.7853982F); + + headSpike4 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); + headSpike4.addBox(-4F, -4F, 0F, 4, 4, 4); + headSpike4.setRotationPoint(-4F, -16F, 0F); + headSpike4.mirror = true; + setRotationWithEulerYzx(headSpike4, 0.5585054F, -0.9250245F, 0.5235988F); + + headSpike5 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); + headSpike5.addBox(0F, -4F, 0F, 4, 4, 4); + headSpike5.setRotationPoint(4F, -10F, -5F); + headSpike5.mirror = true; + setRotationWithEulerYzx(headSpike5, 0.5235988F, -0.9599311F, 0.1047198F); + + rightArmSpike1 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); + rightArmSpike1.addBox(-2F, -2F, -2F, 4, 4, 4); + rightArmSpike1.setRotationPoint(-11F, -8F, 0F); + rightArmSpike1.mirror = true; + setRotationWithEulerYzx(rightArmSpike1, 0.7853982F, 1.134464F, 0.9599311F); + + headSpike6 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); + headSpike6.addBox(-2F, -2F, -2F, 4, 4, 4); + headSpike6.setRotationPoint(-4F, -13F, 4F); + headSpike6.mirror = true; + setRotationWithEulerYzx(headSpike6, 0.7853982F, -1.745329F, 0.7853982F); + + leftArmSpike1 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); + leftArmSpike1.addBox(-2F, -2F, -2F, 4, 4, 4); + leftArmSpike1.setRotationPoint(11F, -8F, 0F); + leftArmSpike1.mirror = true; + setRotationWithEulerYzx(leftArmSpike1, 0.7853982F, -1.134464F, -0.9599311F); + + leftArmSpike2 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); + leftArmSpike2.addBox(-2F, -2F, -2F, 4, 4, 4); + leftArmSpike2.setRotationPoint(12F, -4F, 0F); + leftArmSpike2.mirror = true; + setRotationWithEulerYzx(leftArmSpike2, 0.7853982F, 0F, -0.9599311F); + + bodySpike1 = new ModelRenderer(this, 32, 69).setTextureSize(short1, short2); + bodySpike1.addBox(-3F, -3F, -3F, 6, 6, 6); + bodySpike1.setRotationPoint(-4F, -4F, 3F); + bodySpike1.mirror = true; + setRotationWithEulerYzx(bodySpike1, 0.2808018F, 0.8096675F, 0.8339369F); + + rightArmSpike2 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); + rightArmSpike2.addBox(-2F, -2F, -2F, 4, 4, 4); + rightArmSpike2.setRotationPoint(-12F, -4F, 0F); + rightArmSpike2.mirror = true; + setRotationWithEulerYzx(rightArmSpike2, 0.7853982F, 0F, 0.9599311F); + + bodySpike2 = new ModelRenderer(this, 32, 69).setTextureSize(short1, short2); + bodySpike2.addBox(-3F, -3F, -3F, 6, 6, 6); + bodySpike2.setRotationPoint(4F, -4F, 3F); + bodySpike2.mirror = true; + setRotationWithEulerYzx(bodySpike2, 0.2808018F, -0.8096757F, -0.8339358F); + + bodySpike3 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); + bodySpike3.addBox(-2F, -2F, -2F, 4, 4, 4); + bodySpike3.setRotationPoint(6F, -2F, -5F); + bodySpike3.mirror = true; + setRotationWithEulerYzx(bodySpike3, 1.120006F, -1.347726F, -0.8969422F); + + bodySpike4 = new ModelRenderer(this, 32, 69).setTextureSize(short1, short2); + bodySpike4.addBox(-3F, -3F, -3F, 6, 6, 6); + bodySpike4.setRotationPoint(0F, -4F, -4F); + bodySpike4.mirror = true; + setRotationWithEulerYzx(bodySpike4, 0.7853982F, -1.570796F, 0.9599311F); + + headSpike7 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); + headSpike7.addBox(-2F, -2F, -2F, 4, 4, 4); + headSpike7.setRotationPoint(0F, -20F, 4F); + headSpike7.mirror = true; + setRotationWithEulerYzx(headSpike7, 0.7853982F, 1.570796F, 0.7853982F); + + bodySpike5 = new ModelRenderer(this, 0, 0).setTextureSize(short1, short2); + bodySpike5.addBox(-2F, -2F, -2F, 4, 4, 4); + bodySpike5.setRotationPoint(-6F, -2F, -5F); + bodySpike5.mirror = true; + setRotationWithEulerYzx(bodySpike5, 1.120006F, 1.347725F, 0.896934F); + + this.convertToChild(this.iceGiantHead, headSpike1); + this.convertToChild(this.iceGiantHead, headSpike2); + this.convertToChild(this.iceGiantHead, headSpike3); + this.convertToChild(this.iceGiantHead, headSpike4); + this.convertToChild(this.iceGiantHead, headSpike5); + this.convertToChild(this.iceGiantHead, headSpike6); + this.convertToChild(this.iceGiantHead, headSpike7); + this.convertToChild(this.iceGiantRightArm, rightArmSpike1); + this.convertToChild(this.iceGiantRightArm, rightArmSpike2); + this.convertToChild(this.iceGiantLeftArm, leftArmSpike1); + this.convertToChild(this.iceGiantLeftArm, leftArmSpike2); + this.convertToChild(this.iceGiantBody, bodySpike1); + this.convertToChild(this.iceGiantBody, bodySpike2); + this.convertToChild(this.iceGiantBody, bodySpike3); + this.convertToChild(this.iceGiantBody, bodySpike4); + this.convertToChild(this.iceGiantBody, bodySpike5); + + } + + /** + * Sets the models various rotation angles then renders the model. + */ + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7){ + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + this.iceGiantHead.render(par7); + this.iceGiantBody.render(par7); + this.iceGiantLeftLeg.render(par7); + this.iceGiantRightLeg.render(par7); + this.iceGiantRightArm.render(par7); + this.iceGiantLeftArm.render(par7); + } + + /** + * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms + * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how + * "far" arms and legs can swing at most. + */ + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, + Entity par7Entity){ + this.iceGiantHead.rotateAngleY = par4 / (180F / (float)Math.PI); + this.iceGiantHead.rotateAngleX = par5 / (180F / (float)Math.PI); + this.iceGiantLeftLeg.rotateAngleX = -1.5F * this.func_78172_a(par1, 13.0F) * par2; + this.iceGiantRightLeg.rotateAngleX = 1.5F * this.func_78172_a(par1, 13.0F) * par2; + this.iceGiantLeftLeg.rotateAngleY = 0.0F; + this.iceGiantRightLeg.rotateAngleY = 0.0F; + } + + /** + * Used for easily adding entity-dependent animations. The second and third float params here are the same second + * and third as in the setRotationAngles method. + */ + public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4){ + EntityIceGiant entityicegiant = (EntityIceGiant)par1EntityLivingBase; + int i = entityicegiant.getAttackTimer(); + + if(i > 0){ + this.iceGiantRightArm.rotateAngleX = -2.0F + 1.5F * this.func_78172_a((float)i - par4, 10.0F); + this.iceGiantLeftArm.rotateAngleX = -2.0F + 1.5F * this.func_78172_a((float)i - par4, 10.0F); + }else{ + this.iceGiantRightArm.rotateAngleX = (-0.2F + 1.5F * this.func_78172_a(par2, 13.0F)) * par3; + this.iceGiantLeftArm.rotateAngleX = (-0.2F - 1.5F * this.func_78172_a(par2, 13.0F)) * par3; + } + } + + private float func_78172_a(float par1, float par2){ + return (Math.abs(par1 % par2 - par2 * 0.5F) - par2 * 0.25F) / (par2 * 0.25F); + } + + /** + * This is really useful for converting the source from a Techne model export which will have absolute rotation + * points that need to be converted before creating the addChild() relationship. [Courtesy of jabelar] + */ + protected void convertToChild(ModelRenderer parent, ModelRenderer child){ + // move child rotation point to be relative to parent + child.rotationPointX -= parent.rotationPointX; + child.rotationPointY -= parent.rotationPointY; + child.rotationPointZ -= parent.rotationPointZ; + // make rotations relative to parent + child.rotateAngleX -= parent.rotateAngleX; + child.rotateAngleY -= parent.rotateAngleY; + child.rotateAngleZ -= parent.rotateAngleZ; + // create relationship + parent.addChild(child); + } + + /** Fixes the Techne rotation order bug. [Courtesy of tprk77] */ + private Vector3f ConvertEulerYzxToZyx(Vector3f eulerYzx){ + // Create a matrix from YZX ordered Euler angles + float a = MathHelper.cos(eulerYzx.x); + float b = MathHelper.sin(eulerYzx.x); + float c = MathHelper.cos(eulerYzx.y); + float d = MathHelper.sin(eulerYzx.y); + float e = MathHelper.cos(eulerYzx.z); + float f = MathHelper.sin(eulerYzx.z); + Matrix4f matrix = new Matrix4f(); + matrix.m00 = c * e; + matrix.m01 = b * d - a * c * f; + matrix.m02 = b * c * f + a * d; + matrix.m10 = f; + matrix.m11 = a * e; + matrix.m12 = -b * e; + matrix.m20 = -d * e; + matrix.m21 = a * d * f + b * c; + matrix.m22 = a * c - b * d * f; + matrix.m33 = 1.0F; + // Create ZYX ordered Euler angles from the matrix + Vector3f eulerZyx = new Vector3f(); + eulerZyx.y = (float)Math.asin(MathHelper.clamp(-matrix.m20, -1, 1)); + if(MathHelper.abs(matrix.m20) < 0.99999){ + eulerZyx.x = (float)Math.atan2(matrix.m21, matrix.m22); + eulerZyx.z = (float)Math.atan2(matrix.m10, matrix.m00); + }else{ + eulerZyx.x = 0.0F; + eulerZyx.z = (float)Math.atan2(-matrix.m01, matrix.m11); + } + return eulerZyx; + } + + private void setRotationWithEulerYzx(ModelRenderer model, float x, float y, float z){ + Vector3f eulerYzx = new Vector3f(x, y, z); + Vector3f eulerZyx = ConvertEulerYzxToZyx(eulerYzx); + model.rotateAngleX = eulerZyx.x; + model.rotateAngleY = eulerZyx.y; + model.rotateAngleZ = eulerZyx.z; + } } diff --git a/src/main/java/electroblob/wizardry/client/model/ModelPhoenix.java b/src/main/java/electroblob/wizardry/client/model/ModelPhoenix.java index 568b580c..e664bcd2 100644 --- a/src/main/java/electroblob/wizardry/client/model/ModelPhoenix.java +++ b/src/main/java/electroblob/wizardry/client/model/ModelPhoenix.java @@ -6,134 +6,126 @@ import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; public class ModelPhoenix extends ModelBase { - - ModelRenderer body; - ModelRenderer rightWing; - ModelRenderer leftWing; - ModelRenderer tailFeathers; - ModelRenderer tail; - ModelRenderer head; - ModelRenderer neck; - ModelRenderer beak; - ModelRenderer plume; - - public ModelPhoenix() - { - textureWidth = 64; - textureHeight = 64; - - /* For future reference: - * - setRotationPoint sets the origin of a part relative to that of its parent. - * - The first 3 arguments of addBox set the position of a part relative to its rotation point, and the last - * 3 arguments are the size of the part. - * (This means that rotation point and position seem to be the wrong way round, since changing the rotation point - * will move the component without changing which point on the component it rotates about.) - * - The two integer arguments in the ModelRenderer constructor are the texture offset. - * - Mirror does nothing unless you set it before addBox. - * - Rotation is the usual pitch, yaw, roll. - */ - - body = new ModelRenderer(this, 0, 34); - body.addBox(0F, 0F, -3F, 6, 15, 6); - body.setRotationPoint(-3F, 0F, -5F); - body.setTextureSize(64, 64); - body.mirror = true; - setRotation(body, 0.296706F, 0F, 0F); - - rightWing = new ModelRenderer(this, 0, 0); - rightWing.mirror = true; - rightWing.addBox(-27F, -27F, 0F, 27, 34, 0); - rightWing.setRotationPoint(0F, 5F, 0F); - rightWing.setTextureSize(64, 64); - setRotation(rightWing, 0.1745329F, 0F, 0F); - - leftWing = new ModelRenderer(this, 0, 0); - leftWing.addBox(0F, -27F, 0F, 27, 34, 0); - leftWing.setRotationPoint(6F, 5F, 0F); - leftWing.setTextureSize(64, 64); - setRotation(leftWing, 0.1745329F, 0F, 0F); - - tailFeathers = new ModelRenderer(this, 0, 57); - tailFeathers.addBox(-5F, 0F, 0F, 10, 7, 0); - tailFeathers.setRotationPoint(0F, 7F, 1F); - tailFeathers.setTextureSize(64, 64); - tailFeathers.mirror = true; - setRotation(tailFeathers, 0.5235988F, 0F, 0F); - - tail = new ModelRenderer(this, 20, 55); - tail.addBox(-1F, 0F, -1F, 2, 7, 2); - tail.setRotationPoint(3F, 15F, 2F); - tail.setTextureSize(64, 64); - tail.mirror = true; - setRotation(tail, 0.4014257F, 0F, 0F); - - head = new ModelRenderer(this, 24, 34); - head.addBox(-2F, -4F, -5F, 4, 4, 6); - head.setRotationPoint(0F, -4F, 0F); - head.setTextureSize(64, 64); - head.mirror = true; - setRotation(head, 0F, 0F, 0F); - - neck = new ModelRenderer(this, 24, 44); - neck.addBox(-1F, -4F, -1F, 2, 4, 2); - neck.setRotationPoint(0F, 0F, -4F); - neck.setTextureSize(64, 64); - neck.mirror = true; - setRotation(neck, 0.2443461F, 0F, 0F); - - beak = new ModelRenderer(this, 32, 44); - beak.addBox(-0.5F, 4F, -1F, 1, 2, 3); - beak.setRotationPoint(0F, -5F, -8F); - beak.setTextureSize(64, 64); - beak.mirror = true; - setRotation(beak, 0.2792527F, 0F, 0F); - - plume = new ModelRenderer(this, 28, 50); - plume.addBox(-0.03333334F, 1F, 0F, 0, 5, 5); - plume.setRotationPoint(0F, -7F, 0F); - plume.setTextureSize(64, 64); - plume.mirror = true; - setRotation(plume, 0F, 0F, 0F); - - neck.addChild(head); - head.addChild(plume); - head.addChild(beak); - tail.addChild(tailFeathers); - body.addChild(tail); - body.addChild(rightWing); - body.addChild(leftWing); - } - - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - setRotationAngles(f, f1, f2, f3, f4, f5, entity); - - //float f6 = (180F / (float)Math.PI); - this.neck.rotateAngleX = f4 / (180F / (float)Math.PI); - this.neck.rotateAngleY = f3 / (180F / (float)Math.PI); - this.neck.rotateAngleZ = 0.0F; - this.body.rotateAngleX = 0.3f + MathHelper.cos(f2 * 0.1F) * 0.15F; - this.body.rotateAngleY = 0.0F; - this.tail.rotateAngleX = this.body.rotateAngleX * 1.1f; - this.tailFeathers.rotateAngleX = this.body.rotateAngleX * 1.2f; - this.rightWing.rotateAngleY = MathHelper.cos(f2 * 0.3F) * (float)Math.PI * 0.15F; - this.leftWing.rotateAngleY = -this.rightWing.rotateAngleY; - - body.render(f5); - neck.render(f5); - } - - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } - - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) - { - super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - } + + ModelRenderer body; + ModelRenderer rightWing; + ModelRenderer leftWing; + ModelRenderer tailFeathers; + ModelRenderer tail; + ModelRenderer head; + ModelRenderer neck; + ModelRenderer beak; + ModelRenderer plume; + + public ModelPhoenix(){ + textureWidth = 64; + textureHeight = 64; + + /* For future reference: - setRotationPoint sets the origin of a part relative to that of its parent. - The + * first 3 arguments of addBox set the position of a part relative to its rotation point, and the last 3 + * arguments are the size of the part. (This means that rotation point and position seem to be the wrong way + * round, since changing the rotation point will move the component without changing which point on the + * component it rotates about.) - The two integer arguments in the ModelRenderer constructor are the texture + * offset. - Mirror does nothing unless you set it before addBox. - Rotation is the usual pitch, yaw, roll. */ + + body = new ModelRenderer(this, 0, 34); + body.addBox(0F, 0F, -3F, 6, 15, 6); + body.setRotationPoint(-3F, 0F, -5F); + body.setTextureSize(64, 64); + body.mirror = true; + setRotation(body, 0.296706F, 0F, 0F); + + rightWing = new ModelRenderer(this, 0, 0); + rightWing.mirror = true; + rightWing.addBox(-27F, -27F, 0F, 27, 34, 0); + rightWing.setRotationPoint(0F, 5F, 0F); + rightWing.setTextureSize(64, 64); + setRotation(rightWing, 0.1745329F, 0F, 0F); + + leftWing = new ModelRenderer(this, 0, 0); + leftWing.addBox(0F, -27F, 0F, 27, 34, 0); + leftWing.setRotationPoint(6F, 5F, 0F); + leftWing.setTextureSize(64, 64); + setRotation(leftWing, 0.1745329F, 0F, 0F); + + tailFeathers = new ModelRenderer(this, 0, 57); + tailFeathers.addBox(-5F, 0F, 0F, 10, 7, 0); + tailFeathers.setRotationPoint(0F, 7F, 1F); + tailFeathers.setTextureSize(64, 64); + tailFeathers.mirror = true; + setRotation(tailFeathers, 0.5235988F, 0F, 0F); + + tail = new ModelRenderer(this, 20, 55); + tail.addBox(-1F, 0F, -1F, 2, 7, 2); + tail.setRotationPoint(3F, 15F, 2F); + tail.setTextureSize(64, 64); + tail.mirror = true; + setRotation(tail, 0.4014257F, 0F, 0F); + + head = new ModelRenderer(this, 24, 34); + head.addBox(-2F, -4F, -5F, 4, 4, 6); + head.setRotationPoint(0F, -4F, 0F); + head.setTextureSize(64, 64); + head.mirror = true; + setRotation(head, 0F, 0F, 0F); + + neck = new ModelRenderer(this, 24, 44); + neck.addBox(-1F, -4F, -1F, 2, 4, 2); + neck.setRotationPoint(0F, 0F, -4F); + neck.setTextureSize(64, 64); + neck.mirror = true; + setRotation(neck, 0.2443461F, 0F, 0F); + + beak = new ModelRenderer(this, 32, 44); + beak.addBox(-0.5F, 4F, -1F, 1, 2, 3); + beak.setRotationPoint(0F, -5F, -8F); + beak.setTextureSize(64, 64); + beak.mirror = true; + setRotation(beak, 0.2792527F, 0F, 0F); + + plume = new ModelRenderer(this, 28, 50); + plume.addBox(-0.03333334F, 1F, 0F, 0, 5, 5); + plume.setRotationPoint(0F, -7F, 0F); + plume.setTextureSize(64, 64); + plume.mirror = true; + setRotation(plume, 0F, 0F, 0F); + + neck.addChild(head); + head.addChild(plume); + head.addChild(beak); + tail.addChild(tailFeathers); + body.addChild(tail); + body.addChild(rightWing); + body.addChild(leftWing); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5){ + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + + // float f6 = (180F / (float)Math.PI); + this.neck.rotateAngleX = f4 / (180F / (float)Math.PI); + this.neck.rotateAngleY = f3 / (180F / (float)Math.PI); + this.neck.rotateAngleZ = 0.0F; + this.body.rotateAngleX = 0.3f + MathHelper.cos(f2 * 0.1F) * 0.15F; + this.body.rotateAngleY = 0.0F; + this.tail.rotateAngleX = this.body.rotateAngleX * 1.1f; + this.tailFeathers.rotateAngleX = this.body.rotateAngleX * 1.2f; + this.rightWing.rotateAngleY = MathHelper.cos(f2 * 0.3F) * (float)Math.PI * 0.15F; + this.leftWing.rotateAngleY = -this.rightWing.rotateAngleY; + + body.render(f5); + neck.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z){ + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity){ + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + } } diff --git a/src/main/java/electroblob/wizardry/client/model/ModelWizard.java b/src/main/java/electroblob/wizardry/client/model/ModelWizard.java index e10cf45e..0204c86a 100644 --- a/src/main/java/electroblob/wizardry/client/model/ModelWizard.java +++ b/src/main/java/electroblob/wizardry/client/model/ModelWizard.java @@ -3,172 +3,127 @@ package electroblob.wizardry.client.model; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; -public class ModelWizard extends ModelBiped -{ - //fields - ModelRenderer Shape5; - ModelRenderer Shape8; - ModelRenderer Shape9; - ModelRenderer Shape10; - ModelRenderer Shape7; - ModelRenderer Shape11; - ModelRenderer Shape12; - ModelRenderer beard; - ModelRenderer Shape13; - - public ModelWizard() - { - //super(0, 0, 64, 32); - /* - bipedRightLeg = new ModelRenderer(this, 32, 0); // 32 and 0 are the x and y texture offsets respectively. - bipedRightLeg.addBox(-2F, 0F, -2F, 4, 12, 4); // x, y, z, u, v, w. - bipedRightLeg.setRotationPoint(-2F, 12F, 0F); // Rotation point xyz (absolute, not relative) - bipedRightLeg.setTextureSize(64, 64); - bipedRightLeg.mirror = true; - setRotation(bipedRightLeg, 0F, 0F, 0F); - - bipedLeftLeg.mirror = true; - bipedLeftLeg = new ModelRenderer(this, 32, 0); - bipedLeftLeg.addBox(-2F, 0F, -2F, 4, 12, 4); - bipedLeftLeg.setRotationPoint(2F, 12F, 0F); - bipedLeftLeg.setTextureSize(64, 64); - bipedLeftLeg.mirror = true; - setRotation(bipedLeftLeg, 0F, 0F, 0F); - bipedLeftLeg.mirror = false; - - bipedBody = new ModelRenderer(this, 0, 16); - bipedBody.addBox(0F, 0F, 0F, 8, 12, 4); - bipedBody.setRotationPoint(-4F, 0F, -2F); - bipedBody.setTextureSize(64, 64); - bipedBody.mirror = true; - setRotation(bipedBody, 0F, 0F, 0F); - - bipedLeftArm.mirror = true; - bipedLeftArm = new ModelRenderer(this, 48, 0); - bipedLeftArm.addBox(-1F, 0F, -2F, 4, 12, 4); - bipedLeftArm.setRotationPoint(4F, 0F, 0F); - bipedLeftArm.setTextureSize(64, 64); - bipedLeftArm.mirror = true; - setRotation(bipedLeftArm, 0F, 0F, 0F); - bipedLeftArm.mirror = false; - - bipedRightArm = new ModelRenderer(this, 48, 0); - bipedRightArm.addBox(-3F, 0F, -2F, 4, 12, 4); - bipedRightArm.setRotationPoint(-4F, 0F, 0F); - bipedRightArm.setTextureSize(64, 64); - bipedRightArm.mirror = true; - setRotation(bipedRightArm, 0F, 0F, 0F); - - bipedHead = new ModelRenderer(this, 0, 0); - bipedHead.addBox(-4F, -8F, -4F, 8, 8, 8); - bipedHead.setRotationPoint(0F, 0F, 0F); - bipedHead.setTextureSize(64, 64); - bipedHead.mirror = true; - setRotation(bipedHead, 0F, 0F, 0F); - */ - Shape5 = new ModelRenderer(this, 0, 51); - Shape5.addBox(0F, 0F, 0F, 12, 1, 12); - Shape5.setRotationPoint(-6F, -7F, -6F); - Shape5.setTextureSize(64, 64); - Shape5.mirror = true; - setRotation(Shape5, 0F, 0F, 0F); - Shape8 = new ModelRenderer(this, 0, 32); - Shape8.addBox(0F, 0F, 0F, 6, 1, 6); - Shape8.setRotationPoint(-3F, -9F, -3F); - Shape8.setTextureSize(64, 64); - Shape8.mirror = true; - setRotation(Shape8, -0.0349066F, 0F, 0F); - Shape9 = new ModelRenderer(this, 24, 32); - Shape9.addBox(0F, 0F, 0F, 3, 3, 3); - Shape9.setRotationPoint(-1.5F, -13F, -0.5F); - Shape9.setTextureSize(64, 64); - Shape9.mirror = true; - setRotation(Shape9, -0.2511622F, 0F, 0F); - Shape10 = new ModelRenderer(this, 0, 39); - Shape10.addBox(0F, 0F, 0F, 5, 1, 5); - Shape10.setRotationPoint(-2.5F, -10F, -2.5F); - Shape10.setTextureSize(64, 64); - Shape10.mirror = true; - setRotation(Shape10, -0.0698132F, 0F, 0F); - Shape7 = new ModelRenderer(this, 0, 45); - Shape7.addBox(0F, 0F, 0F, 4, 2, 4); - Shape7.setRotationPoint(-2F, -11F, -1.5F); - Shape7.setTextureSize(64, 64); - Shape7.mirror = true; - setRotation(Shape7, -0.1396263F, 0F, 0F); - Shape11 = new ModelRenderer(this, 20, 39); - Shape11.addBox(0F, 0F, 0F, 2, 3, 2); - Shape11.setRotationPoint(-1F, -15F, 1F); - Shape11.setTextureSize(64, 64); - Shape11.mirror = true; - setRotation(Shape11, -0.4363323F, 0F, 0F); - Shape12 = new ModelRenderer(this, 28, 39); - Shape12.addBox(0F, 0F, 0F, 1, 2, 1); - Shape12.setRotationPoint(-0.5F, -16F, 2.5F); - Shape12.setTextureSize(64, 64); - Shape12.mirror = true; - setRotation(Shape12, -0.715585F, 0F, 0F); - beard = new ModelRenderer(this, 32, 0); - beard.addBox(0F, 0F, 0F, 8, 5, 0); - beard.setRotationPoint(-4F, 0F, -4F); - beard.setTextureSize(64, 64); - beard.mirror = true; - setRotation(beard, 0F, 0F, 0F); - Shape13 = new ModelRenderer(this, 36, 16); - Shape13.addBox(4F, 0F, 2F, 8, 20, 6); - Shape13.setRotationPoint(-4F, 0F, -3F); - Shape13.setTextureSize(64, 64); - Shape13.mirror = true; - setRotation(Shape13, 0F, 0F, 0F); - - // Makes head bits move with head - //bipedHead.addChild(Shape5); - bipedHead.addChild(beard); - //bipedHead.addChild(Shape7); - //bipedHead.addChild(Shape8); - //bipedHead.addChild(Shape9); - //bipedHead.addChild(Shape10); - //bipedHead.addChild(Shape11); - //bipedHead.addChild(Shape12); - - // Makes cloak attached to body - //bipedBody.addChild(Shape13); - - // No outer head layer - this.bipedHeadwear.isHidden = true; - } - /* - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - setRotationAngles(f, f1, f2, f3, f4, f5, entity); - bipedRightLeg.render(f5); - bipedLeftLeg.render(f5); - bipedBody.render(f5); - bipedLeftArm.render(f5); - bipedRightArm.render(f5); - bipedHead.render(f5); - Shape5.render(f5); - Shape8.render(f5); - Shape9.render(f5); - Shape10.render(f5); - Shape7.render(f5); - Shape11.render(f5); - Shape12.render(f5); - Shape6.render(f5); - Shape13.render(f5); - } - */ - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } - /* - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) - { - super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - } -*/ +public class ModelWizard extends ModelBiped { + // fields + ModelRenderer Shape5; + ModelRenderer Shape8; + ModelRenderer Shape9; + ModelRenderer Shape10; + ModelRenderer Shape7; + ModelRenderer Shape11; + ModelRenderer Shape12; + ModelRenderer beard; + ModelRenderer Shape13; + + public ModelWizard(){ + // super(0, 0, 64, 32); + /* bipedRightLeg = new ModelRenderer(this, 32, 0); // 32 and 0 are the x and y texture offsets respectively. + * bipedRightLeg.addBox(-2F, 0F, -2F, 4, 12, 4); // x, y, z, u, v, w. bipedRightLeg.setRotationPoint(-2F, 12F, + * 0F); // Rotation point xyz (absolute, not relative) bipedRightLeg.setTextureSize(64, 64); + * bipedRightLeg.mirror = true; setRotation(bipedRightLeg, 0F, 0F, 0F); + * + * bipedLeftLeg.mirror = true; bipedLeftLeg = new ModelRenderer(this, 32, 0); bipedLeftLeg.addBox(-2F, 0F, -2F, + * 4, 12, 4); bipedLeftLeg.setRotationPoint(2F, 12F, 0F); bipedLeftLeg.setTextureSize(64, 64); + * bipedLeftLeg.mirror = true; setRotation(bipedLeftLeg, 0F, 0F, 0F); bipedLeftLeg.mirror = false; + * + * bipedBody = new ModelRenderer(this, 0, 16); bipedBody.addBox(0F, 0F, 0F, 8, 12, 4); + * bipedBody.setRotationPoint(-4F, 0F, -2F); bipedBody.setTextureSize(64, 64); bipedBody.mirror = true; + * setRotation(bipedBody, 0F, 0F, 0F); + * + * bipedLeftArm.mirror = true; bipedLeftArm = new ModelRenderer(this, 48, 0); bipedLeftArm.addBox(-1F, 0F, -2F, + * 4, 12, 4); bipedLeftArm.setRotationPoint(4F, 0F, 0F); bipedLeftArm.setTextureSize(64, 64); + * bipedLeftArm.mirror = true; setRotation(bipedLeftArm, 0F, 0F, 0F); bipedLeftArm.mirror = false; + * + * bipedRightArm = new ModelRenderer(this, 48, 0); bipedRightArm.addBox(-3F, 0F, -2F, 4, 12, 4); + * bipedRightArm.setRotationPoint(-4F, 0F, 0F); bipedRightArm.setTextureSize(64, 64); bipedRightArm.mirror = + * true; setRotation(bipedRightArm, 0F, 0F, 0F); + * + * bipedHead = new ModelRenderer(this, 0, 0); bipedHead.addBox(-4F, -8F, -4F, 8, 8, 8); + * bipedHead.setRotationPoint(0F, 0F, 0F); bipedHead.setTextureSize(64, 64); bipedHead.mirror = true; + * setRotation(bipedHead, 0F, 0F, 0F); */ + Shape5 = new ModelRenderer(this, 0, 51); + Shape5.addBox(0F, 0F, 0F, 12, 1, 12); + Shape5.setRotationPoint(-6F, -7F, -6F); + Shape5.setTextureSize(64, 64); + Shape5.mirror = true; + setRotation(Shape5, 0F, 0F, 0F); + Shape8 = new ModelRenderer(this, 0, 32); + Shape8.addBox(0F, 0F, 0F, 6, 1, 6); + Shape8.setRotationPoint(-3F, -9F, -3F); + Shape8.setTextureSize(64, 64); + Shape8.mirror = true; + setRotation(Shape8, -0.0349066F, 0F, 0F); + Shape9 = new ModelRenderer(this, 24, 32); + Shape9.addBox(0F, 0F, 0F, 3, 3, 3); + Shape9.setRotationPoint(-1.5F, -13F, -0.5F); + Shape9.setTextureSize(64, 64); + Shape9.mirror = true; + setRotation(Shape9, -0.2511622F, 0F, 0F); + Shape10 = new ModelRenderer(this, 0, 39); + Shape10.addBox(0F, 0F, 0F, 5, 1, 5); + Shape10.setRotationPoint(-2.5F, -10F, -2.5F); + Shape10.setTextureSize(64, 64); + Shape10.mirror = true; + setRotation(Shape10, -0.0698132F, 0F, 0F); + Shape7 = new ModelRenderer(this, 0, 45); + Shape7.addBox(0F, 0F, 0F, 4, 2, 4); + Shape7.setRotationPoint(-2F, -11F, -1.5F); + Shape7.setTextureSize(64, 64); + Shape7.mirror = true; + setRotation(Shape7, -0.1396263F, 0F, 0F); + Shape11 = new ModelRenderer(this, 20, 39); + Shape11.addBox(0F, 0F, 0F, 2, 3, 2); + Shape11.setRotationPoint(-1F, -15F, 1F); + Shape11.setTextureSize(64, 64); + Shape11.mirror = true; + setRotation(Shape11, -0.4363323F, 0F, 0F); + Shape12 = new ModelRenderer(this, 28, 39); + Shape12.addBox(0F, 0F, 0F, 1, 2, 1); + Shape12.setRotationPoint(-0.5F, -16F, 2.5F); + Shape12.setTextureSize(64, 64); + Shape12.mirror = true; + setRotation(Shape12, -0.715585F, 0F, 0F); + beard = new ModelRenderer(this, 32, 0); + beard.addBox(0F, 0F, 0F, 8, 5, 0); + beard.setRotationPoint(-4F, 0F, -4F); + beard.setTextureSize(64, 64); + beard.mirror = true; + setRotation(beard, 0F, 0F, 0F); + Shape13 = new ModelRenderer(this, 36, 16); + Shape13.addBox(4F, 0F, 2F, 8, 20, 6); + Shape13.setRotationPoint(-4F, 0F, -3F); + Shape13.setTextureSize(64, 64); + Shape13.mirror = true; + setRotation(Shape13, 0F, 0F, 0F); + + // Makes head bits move with head + // bipedHead.addChild(Shape5); + bipedHead.addChild(beard); + // bipedHead.addChild(Shape7); + // bipedHead.addChild(Shape8); + // bipedHead.addChild(Shape9); + // bipedHead.addChild(Shape10); + // bipedHead.addChild(Shape11); + // bipedHead.addChild(Shape12); + + // Makes cloak attached to body + // bipedBody.addChild(Shape13); + + // No outer head layer + this.bipedHeadwear.isHidden = true; + } + + /* public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + * super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); + * bipedRightLeg.render(f5); bipedLeftLeg.render(f5); bipedBody.render(f5); bipedLeftArm.render(f5); + * bipedRightArm.render(f5); bipedHead.render(f5); Shape5.render(f5); Shape8.render(f5); Shape9.render(f5); + * Shape10.render(f5); Shape7.render(f5); Shape11.render(f5); Shape12.render(f5); Shape6.render(f5); + * Shape13.render(f5); } */ + private void setRotation(ModelRenderer model, float x, float y, float z){ + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + /* public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { + * super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } */ } diff --git a/src/main/java/electroblob/wizardry/client/model/ModelWizardArmour.java b/src/main/java/electroblob/wizardry/client/model/ModelWizardArmour.java index 3829f103..650f5d2c 100644 --- a/src/main/java/electroblob/wizardry/client/model/ModelWizardArmour.java +++ b/src/main/java/electroblob/wizardry/client/model/ModelWizardArmour.java @@ -4,8 +4,7 @@ import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -public class ModelWizardArmour extends ModelBiped -{ +public class ModelWizardArmour extends ModelBiped { ModelRenderer Shape1; ModelRenderer Shape2; ModelRenderer Shape3; @@ -90,7 +89,7 @@ public class ModelWizardArmour extends ModelBiped bipedHead.addChild(Shape6); bipedHead.addChild(Shape7); // Makes the robe move with the body - //bipedBody.addChild(robe); + // bipedBody.addChild(robe); } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5){ diff --git a/src/main/java/electroblob/wizardry/client/model/WizardryItemModels.java b/src/main/java/electroblob/wizardry/client/model/WizardryItemModels.java index a1d678ab..ecfac381 100644 --- a/src/main/java/electroblob/wizardry/client/model/WizardryItemModels.java +++ b/src/main/java/electroblob/wizardry/client/model/WizardryItemModels.java @@ -1,13 +1,11 @@ package electroblob.wizardry.client.model; -import java.util.ArrayList; -import java.util.List; - import electroblob.wizardry.registry.WizardryBlocks; import electroblob.wizardry.registry.WizardryItems; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.Mod; @@ -18,6 +16,7 @@ import net.minecraftforge.oredict.OreDictionary; /** * Class responsible for registering all of wizardry's item (and itemblock) models. + * * @author Electroblob * @since Wizardry 2.1 */ @@ -27,166 +26,173 @@ public final class WizardryItemModels { @SubscribeEvent public static void register(ModelRegistryEvent event){ - + // ItemBlocks - + registerItemModel(Item.getItemFromBlock(WizardryBlocks.arcane_workbench)); registerItemModel(Item.getItemFromBlock(WizardryBlocks.crystal_ore)); registerItemModel(Item.getItemFromBlock(WizardryBlocks.crystal_flower)); registerItemModel(Item.getItemFromBlock(WizardryBlocks.transportation_stone)); registerItemModel(Item.getItemFromBlock(WizardryBlocks.crystal_block)); - + // Items - + registerItemModel(WizardryItems.magic_crystal); - registerItemModel(WizardryItems.magic_wand); - registerItemModel(WizardryItems.apprentice_wand); - registerItemModel(WizardryItems.advanced_wand); - registerItemModel(WizardryItems.master_wand); + registerItemModel(WizardryItems.magic_wand); + registerItemModel(WizardryItems.apprentice_wand); + registerItemModel(WizardryItems.advanced_wand); + registerItemModel(WizardryItems.master_wand); - registerItemModel(WizardryItems.spell_book); - // Wildcard registered for wizard trades. - registerItemModel(WizardryItems.spell_book, OreDictionary.WILDCARD_VALUE, "normal"); - registerItemModel(WizardryItems.arcane_tome); - registerItemModel(WizardryItems.wizard_handbook); - - registerItemModel(WizardryItems.basic_fire_wand); - registerItemModel(WizardryItems.basic_ice_wand); - registerItemModel(WizardryItems.basic_lightning_wand); - registerItemModel(WizardryItems.basic_necromancy_wand); - registerItemModel(WizardryItems.basic_earth_wand); - registerItemModel(WizardryItems.basic_sorcery_wand); - registerItemModel(WizardryItems.basic_healing_wand); + registerItemModel(WizardryItems.spell_book); + // Wildcard registered for wizard trades. + registerItemModel(WizardryItems.spell_book, OreDictionary.WILDCARD_VALUE, "normal"); + registerItemModel(WizardryItems.arcane_tome); + registerItemModel(WizardryItems.wizard_handbook); - registerItemModel(WizardryItems.apprentice_fire_wand); - registerItemModel(WizardryItems.apprentice_ice_wand); - registerItemModel(WizardryItems.apprentice_lightning_wand); - registerItemModel(WizardryItems.apprentice_necromancy_wand); - registerItemModel(WizardryItems.apprentice_earth_wand); - registerItemModel(WizardryItems.apprentice_sorcery_wand); - registerItemModel(WizardryItems.apprentice_healing_wand); + registerItemModel(WizardryItems.basic_fire_wand); + registerItemModel(WizardryItems.basic_ice_wand); + registerItemModel(WizardryItems.basic_lightning_wand); + registerItemModel(WizardryItems.basic_necromancy_wand); + registerItemModel(WizardryItems.basic_earth_wand); + registerItemModel(WizardryItems.basic_sorcery_wand); + registerItemModel(WizardryItems.basic_healing_wand); - registerItemModel(WizardryItems.advanced_fire_wand); - registerItemModel(WizardryItems.advanced_ice_wand); - registerItemModel(WizardryItems.advanced_lightning_wand); - registerItemModel(WizardryItems.advanced_necromancy_wand); - registerItemModel(WizardryItems.advanced_earth_wand); - registerItemModel(WizardryItems.advanced_sorcery_wand); - registerItemModel(WizardryItems.advanced_healing_wand); + registerItemModel(WizardryItems.apprentice_fire_wand); + registerItemModel(WizardryItems.apprentice_ice_wand); + registerItemModel(WizardryItems.apprentice_lightning_wand); + registerItemModel(WizardryItems.apprentice_necromancy_wand); + registerItemModel(WizardryItems.apprentice_earth_wand); + registerItemModel(WizardryItems.apprentice_sorcery_wand); + registerItemModel(WizardryItems.apprentice_healing_wand); - registerItemModel(WizardryItems.master_fire_wand); - registerItemModel(WizardryItems.master_ice_wand); - registerItemModel(WizardryItems.master_lightning_wand); - registerItemModel(WizardryItems.master_necromancy_wand); - registerItemModel(WizardryItems.master_earth_wand); - registerItemModel(WizardryItems.master_sorcery_wand); - registerItemModel(WizardryItems.master_healing_wand); + registerItemModel(WizardryItems.advanced_fire_wand); + registerItemModel(WizardryItems.advanced_ice_wand); + registerItemModel(WizardryItems.advanced_lightning_wand); + registerItemModel(WizardryItems.advanced_necromancy_wand); + registerItemModel(WizardryItems.advanced_earth_wand); + registerItemModel(WizardryItems.advanced_sorcery_wand); + registerItemModel(WizardryItems.advanced_healing_wand); - registerItemModel(WizardryItems.spectral_sword); - registerItemModel(WizardryItems.spectral_pickaxe); - registerItemModel(WizardryItems.spectral_bow); + registerItemModel(WizardryItems.master_fire_wand); + registerItemModel(WizardryItems.master_ice_wand); + registerItemModel(WizardryItems.master_lightning_wand); + registerItemModel(WizardryItems.master_necromancy_wand); + registerItemModel(WizardryItems.master_earth_wand); + registerItemModel(WizardryItems.master_sorcery_wand); + registerItemModel(WizardryItems.master_healing_wand); - registerItemModel(WizardryItems.mana_flask); + registerItemModel(WizardryItems.spectral_sword); + registerItemModel(WizardryItems.spectral_pickaxe); + registerItemModel(WizardryItems.spectral_bow); - registerItemModel(WizardryItems.storage_upgrade); - registerItemModel(WizardryItems.siphon_upgrade); - registerItemModel(WizardryItems.condenser_upgrade); - registerItemModel(WizardryItems.range_upgrade); - registerItemModel(WizardryItems.duration_upgrade); - registerItemModel(WizardryItems.cooldown_upgrade); - registerItemModel(WizardryItems.blast_upgrade); - registerItemModel(WizardryItems.attunement_upgrade); + registerItemModel(WizardryItems.mana_flask); - registerItemModel(WizardryItems.flaming_axe); - registerItemModel(WizardryItems.frost_axe); + registerItemModel(WizardryItems.storage_upgrade); + registerItemModel(WizardryItems.siphon_upgrade); + registerItemModel(WizardryItems.condenser_upgrade); + registerItemModel(WizardryItems.range_upgrade); + registerItemModel(WizardryItems.duration_upgrade); + registerItemModel(WizardryItems.cooldown_upgrade); + registerItemModel(WizardryItems.blast_upgrade); + registerItemModel(WizardryItems.attunement_upgrade); - registerItemModel(WizardryItems.firebomb); - registerItemModel(WizardryItems.poison_bomb); - - registerItemModel(WizardryItems.blank_scroll); - registerItemModel(WizardryItems.scroll); + registerItemModel(WizardryItems.flaming_axe); + registerItemModel(WizardryItems.frost_axe); - registerItemModel(WizardryItems.armour_upgrade); - - registerItemModel(WizardryItems.magic_silk); - - registerItemModel(WizardryItems.wizard_hat); - registerItemModel(WizardryItems.wizard_robe); - registerItemModel(WizardryItems.wizard_leggings); - registerItemModel(WizardryItems.wizard_boots); + registerItemModel(WizardryItems.firebomb); + registerItemModel(WizardryItems.poison_bomb); - registerItemModel(WizardryItems.wizard_hat_fire); - registerItemModel(WizardryItems.wizard_robe_fire); - registerItemModel(WizardryItems.wizard_leggings_fire); - registerItemModel(WizardryItems.wizard_boots_fire); + registerItemModel(WizardryItems.blank_scroll); + registerItemModel(WizardryItems.scroll); - registerItemModel(WizardryItems.wizard_hat_ice); - registerItemModel(WizardryItems.wizard_robe_ice); - registerItemModel(WizardryItems.wizard_leggings_ice); - registerItemModel(WizardryItems.wizard_boots_ice); + registerItemModel(WizardryItems.armour_upgrade); - registerItemModel(WizardryItems.wizard_hat_lightning); - registerItemModel(WizardryItems.wizard_robe_lightning); - registerItemModel(WizardryItems.wizard_leggings_lightning); - registerItemModel(WizardryItems.wizard_boots_lightning); + registerItemModel(WizardryItems.magic_silk); - registerItemModel(WizardryItems.wizard_hat_necromancy); - registerItemModel(WizardryItems.wizard_robe_necromancy); - registerItemModel(WizardryItems.wizard_leggings_necromancy); - registerItemModel(WizardryItems.wizard_boots_necromancy); + registerItemModel(WizardryItems.wizard_hat); + registerItemModel(WizardryItems.wizard_robe); + registerItemModel(WizardryItems.wizard_leggings); + registerItemModel(WizardryItems.wizard_boots); - registerItemModel(WizardryItems.wizard_hat_earth); - registerItemModel(WizardryItems.wizard_robe_earth); - registerItemModel(WizardryItems.wizard_leggings_earth); - registerItemModel(WizardryItems.wizard_boots_earth); - - registerItemModel(WizardryItems.wizard_hat_sorcery); - registerItemModel(WizardryItems.wizard_robe_sorcery); - registerItemModel(WizardryItems.wizard_leggings_sorcery); - registerItemModel(WizardryItems.wizard_boots_sorcery); + registerItemModel(WizardryItems.wizard_hat_fire); + registerItemModel(WizardryItems.wizard_robe_fire); + registerItemModel(WizardryItems.wizard_leggings_fire); + registerItemModel(WizardryItems.wizard_boots_fire); - registerItemModel(WizardryItems.wizard_hat_healing); - registerItemModel(WizardryItems.wizard_robe_healing); - registerItemModel(WizardryItems.wizard_leggings_healing); - registerItemModel(WizardryItems.wizard_boots_healing); + registerItemModel(WizardryItems.wizard_hat_ice); + registerItemModel(WizardryItems.wizard_robe_ice); + registerItemModel(WizardryItems.wizard_leggings_ice); + registerItemModel(WizardryItems.wizard_boots_ice); - registerItemModel(WizardryItems.spectral_helmet); - registerItemModel(WizardryItems.spectral_chestplate); - registerItemModel(WizardryItems.spectral_leggings); - registerItemModel(WizardryItems.spectral_boots); - - registerItemModel(WizardryItems.smoke_bomb); - - registerItemModel(WizardryItems.identification_scroll); + registerItemModel(WizardryItems.wizard_hat_lightning); + registerItemModel(WizardryItems.wizard_robe_lightning); + registerItemModel(WizardryItems.wizard_leggings_lightning); + registerItemModel(WizardryItems.wizard_boots_lightning); + + registerItemModel(WizardryItems.wizard_hat_necromancy); + registerItemModel(WizardryItems.wizard_robe_necromancy); + registerItemModel(WizardryItems.wizard_leggings_necromancy); + registerItemModel(WizardryItems.wizard_boots_necromancy); + + registerItemModel(WizardryItems.wizard_hat_earth); + registerItemModel(WizardryItems.wizard_robe_earth); + registerItemModel(WizardryItems.wizard_leggings_earth); + registerItemModel(WizardryItems.wizard_boots_earth); + + registerItemModel(WizardryItems.wizard_hat_sorcery); + registerItemModel(WizardryItems.wizard_robe_sorcery); + registerItemModel(WizardryItems.wizard_leggings_sorcery); + registerItemModel(WizardryItems.wizard_boots_sorcery); + + registerItemModel(WizardryItems.wizard_hat_healing); + registerItemModel(WizardryItems.wizard_robe_healing); + registerItemModel(WizardryItems.wizard_leggings_healing); + registerItemModel(WizardryItems.wizard_boots_healing); + + registerItemModel(WizardryItems.spectral_helmet); + registerItemModel(WizardryItems.spectral_chestplate); + registerItemModel(WizardryItems.spectral_leggings); + registerItemModel(WizardryItems.spectral_boots); + + registerItemModel(WizardryItems.smoke_bomb); + + registerItemModel(WizardryItems.identification_scroll); } - + // Moved from the proxies - - /** Registers an item model, using the item's registry name as the model name (this - * convention makes it easier to keep track of everything). Variant defaults to "normal". Registers the model - * for metadata 0 automatically, plus all the other metadata values that the item can take, as defined in + + /** + * Registers an item model, using the item's registry name as the model name (this convention makes it easier to + * keep track of everything). Variant defaults to "normal". Registers the model for metadata 0 automatically, plus + * all the other metadata values that the item can take, as defined in * {@link Item#getSubItems(Item, net.minecraft.creativetab.CreativeTabs, java.util.List)}. The passed in item * must allow null to be passed in for the creative tab parameter in the aforementioned method, or a - * {@link NullPointerException} will result. */ + * {@link NullPointerException} will result. + */ private static void registerItemModel(Item item){ - + if(item.getHasSubtypes()){ - List items = new ArrayList(); + NonNullList items = NonNullList.create(); item.getSubItems(item, null, items); // Client-only method, but we're client-side so this is OK. for(ItemStack stack : items){ - ModelLoader.setCustomModelResourceLocation(item, stack.getMetadata(), new ModelResourceLocation(item.getRegistryName(), "inventory")); + ModelLoader.setCustomModelResourceLocation(item, stack.getMetadata(), + new ModelResourceLocation(item.getRegistryName(), "inventory")); } } // Changing the last parameter from null to "inventory" fixed the item/block model weirdness. No idea why! - ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); + ModelLoader.setCustomModelResourceLocation(item, 0, + new ModelResourceLocation(item.getRegistryName(), "inventory")); } - - /** Registers an item model for the given metadata, using the item's registry name as the model name (this - * convention makes it easier to keep track of everything). This is intended for registering additional metadata - * values which aren't displayed in the creative menu, for example the wildcard spell book used in wizard trades. */ - private static void registerItemModel(Item item, int metadata, String variant) { - ModelLoader.setCustomModelResourceLocation(item, metadata, new ModelResourceLocation(item.getRegistryName(), variant)); + + /** + * Registers an item model for the given metadata, using the item's registry name as the model name (this convention + * makes it easier to keep track of everything). This is intended for registering additional metadata values which + * aren't displayed in the creative menu, for example the wildcard spell book used in wizard trades. + */ + private static void registerItemModel(Item item, int metadata, String variant){ + ModelLoader.setCustomModelResourceLocation(item, metadata, + new ModelResourceLocation(item.getRegistryName(), variant)); } } diff --git a/src/main/java/electroblob/wizardry/client/particle/ParticleBlizzard.java b/src/main/java/electroblob/wizardry/client/particle/ParticleBlizzard.java index 4ea3114b..58e84e48 100644 --- a/src/main/java/electroblob/wizardry/client/particle/ParticleBlizzard.java +++ b/src/main/java/electroblob/wizardry/client/particle/ParticleBlizzard.java @@ -6,67 +6,69 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ParticleBlizzard extends ParticleSnow { - - private double angle; - private double radius; - private double speed; - public ParticleBlizzard(World world, int maxAge, double originX, double originZ, double radius, double yPos){ - super(world, 0, 0, 0, 0, 0, 0, maxAge); - this.angle = this.rand.nextDouble() * Math.PI * 2; - double x = originX - Math.cos(angle)*radius; - double z = originZ + radius*Math.sin(angle); - this.radius = radius; - this.setPosition(x, yPos, z); - this.prevPosX = x; - this.prevPosY = yPos; - this.prevPosZ = z; - if(rand.nextBoolean()){ - speed = rand.nextDouble()*2 + 1; - }else{ - speed = rand.nextDouble()*-2 - 1; - } - this.multipleParticleScaleBy(1.5f); - } - - @Override - public void init(){ - super.init(); - this.fullBrightness = true; - } + private double angle; + private double radius; + private double speed; -// @Override -// public void renderParticle(VertexBuffer buffer, Entity entity, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ){ -// if(this.particleAge < this.particleMaxAge / 3 || (this.particleAge + this.particleMaxAge) / 3 % 2 == 0){ -// super.renderParticle(buffer, entity, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ); -// } -// } + public ParticleBlizzard(World world, int maxAge, double originX, double originZ, double radius, double yPos){ + super(world, 0, 0, 0, 0, 0, 0, maxAge); + this.angle = this.rand.nextDouble() * Math.PI * 2; + double x = originX - Math.cos(angle) * radius; + double z = originZ + radius * Math.sin(angle); + this.radius = radius; + this.setPosition(x, yPos, z); + this.prevPosX = x; + this.prevPosY = yPos; + this.prevPosZ = z; + if(rand.nextBoolean()){ + speed = rand.nextDouble() * 2 + 1; + }else{ + speed = rand.nextDouble() * -2 - 1; + } + this.multipleParticleScaleBy(1.5f); + } - @Override - public void onUpdate(){ - - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + @Override + public void init(){ + super.init(); + this.fullBrightness = true; + } - if(this.particleAge++ >= this.particleMaxAge){ - this.setExpired(); - } - - // This is in radians per tick... - double omega = Math.signum(speed) * ((Math.PI*2)/20 - speed/(20*radius)); - - // v = r times omega; therefore the normalised velocity vector needs to be r times the angle increment / 2 pi. - this.angle += omega; + // @Override + // public void renderParticle(VertexBuffer buffer, Entity entity, float partialTicks, float rotationX, float + // rotationZ, float rotationYZ, float rotationXY, float rotationXZ){ + // if(this.particleAge < this.particleMaxAge / 3 || (this.particleAge + this.particleMaxAge) / 3 % 2 == 0){ + // super.renderParticle(buffer, entity, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ); + // } + // } - this.motionY -= 0.04D * (double)this.particleGravity; - this.motionZ = radius * omega * Math.cos(angle); - this.motionX = radius * omega * Math.sin(angle); - this.moveEntity(motionX, motionY, motionZ); + @Override + public void onUpdate(){ - if(this.particleAge > this.particleMaxAge / 2){ - this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge); - } - - } + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if(this.particleAge++ >= this.particleMaxAge){ + this.setExpired(); + } + + // This is in radians per tick... + double omega = Math.signum(speed) * ((Math.PI * 2) / 20 - speed / (20 * radius)); + + // v = r times omega; therefore the normalised velocity vector needs to be r times the angle increment / 2 pi. + this.angle += omega; + + this.motionY -= 0.04D * (double)this.particleGravity; + this.motionZ = radius * omega * Math.cos(angle); + this.motionX = radius * omega * Math.sin(angle); + this.move(motionX, motionY, motionZ); + + if(this.particleAge > this.particleMaxAge / 2){ + this.setAlphaF( + 1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge); + } + + } } diff --git a/src/main/java/electroblob/wizardry/client/particle/ParticleCustomTexture.java b/src/main/java/electroblob/wizardry/client/particle/ParticleCustomTexture.java index 3d5fa986..00e50b26 100644 --- a/src/main/java/electroblob/wizardry/client/particle/ParticleCustomTexture.java +++ b/src/main/java/electroblob/wizardry/client/particle/ParticleCustomTexture.java @@ -1,7 +1,5 @@ package electroblob.wizardry.client.particle; -import java.util.List; - import org.lwjgl.opengl.GL11; import net.minecraft.client.Minecraft; @@ -14,7 +12,6 @@ import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -23,6 +20,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; * Abstract superclass for all particles that use custom textures. This is intended to centralise as much code as * possible; all subclasses need to do is to define the texture to use, how the frames are arranged (and which to * choose), and any properties like gravity and collisions. + * * @author Electroblob * @since Wizardry 1.2 */ @@ -40,33 +38,41 @@ public abstract class ParticleCustomTexture extends Particle { this.init(); } - public ParticleCustomTexture(World world, double x, double y, double z, double vx, double vy, double vz, int maxAge){ + public ParticleCustomTexture(World world, double x, double y, double z, double vx, double vy, double vz, + int maxAge){ this(world, x, y, z, vx, vy, vz); this.particleMaxAge = maxAge; } - - /** Called from both constructors to set constants, avoiding duplicate code. Common fields to set here - * include: particleScale, particleGravity, canCollide, fullBrightness and setting the texture index. */ + + /** + * Called from both constructors to set constants, avoiding duplicate code. Common fields to set here include: + * particleScale, particleGravity, canCollide, fullBrightness and setting the texture index. + */ public abstract void init(); - /** Returns a ResourceLocation for the particle's texture sheet. Do not create a new ResourceLocation in this - * method, only return a constant. */ + + /** + * Returns a ResourceLocation for the particle's texture sheet. Do not create a new ResourceLocation in this method, + * only return a constant. + */ public abstract ResourceLocation getTexture(); + /** Returns how many 'frames' there are in the x direction on the texture. */ protected abstract int getXFrames(); + /** Returns how many 'frames' there are in the y direction on the texture. */ protected abstract int getYFrames(); - /* There are 4 layers of particles, specified as 0-3 by the method below. - * - Layer 0 causes the normal particles.png to be bound to the render engine for normal particles. - * - Layer 1 causes the block textures to be bound to the render engine for digging fx and falling fx. - * - Layer 2 causes the item textures to be bound to the render engine for tool breaking fx, snowballpoofs, slime particles, etc. - * - Layer 3 is not used in vanilla minecraft and was presumably added by forge for exactly this reason. - * This means no texture is bound by vanilla minecraft, meaning you are free to do as you wish without possibly - * overwriting vanilla particles. Mod particles won't be overwritten anyway since they bind their own textures. - * It is of course important to bind the texture every time you render a custom particle, but I don't see how - * you could do it any other way, since you don't have access to EffectRenderer. */ + /* There are 4 layers of particles, specified as 0-3 by the method below. - Layer 0 causes the normal particles.png + * to be bound to the render engine for normal particles. - Layer 1 causes the block textures to be bound to the + * render engine for digging fx and falling fx. - Layer 2 causes the item textures to be bound to the render engine + * for tool breaking fx, snowballpoofs, slime particles, etc. - Layer 3 is not used in vanilla minecraft and was + * presumably added by forge for exactly this reason. This means no texture is bound by vanilla minecraft, meaning + * you are free to do as you wish without possibly overwriting vanilla particles. Mod particles won't be overwritten + * anyway since they bind their own textures. It is of course important to bind the texture every time you render a + * custom particle, but I don't see how you could do it any other way, since you don't have access to + * EffectRenderer. */ @Override - public int getFXLayer() { + public int getFXLayer(){ // This can only be 0-3 or it will cause an ArrayIndexOutOfBoundsException in EffectRenderer. return 3; } @@ -78,73 +84,76 @@ public abstract class ParticleCustomTexture extends Particle { } // Overridden to fix the bug with vanilla that makes particles frictionless. (y != y... seriously, Mojang?) - @Override - public void moveEntity(double x, double y, double z){ - - double d0 = y; - - if (this.canCollide) - { - List list = this.worldObj.getCollisionBoxes((Entity)null, this.getEntityBoundingBox().addCoord(x, y, z)); - - for (AxisAlignedBB axisalignedbb : list) - { - y = axisalignedbb.calculateYOffset(this.getEntityBoundingBox(), y); - } - - this.setEntityBoundingBox(this.getEntityBoundingBox().offset(0.0D, y, 0.0D)); - - for (AxisAlignedBB axisalignedbb1 : list) - { - x = axisalignedbb1.calculateXOffset(this.getEntityBoundingBox(), x); - } - - this.setEntityBoundingBox(this.getEntityBoundingBox().offset(x, 0.0D, 0.0D)); - - for (AxisAlignedBB axisalignedbb2 : list) - { - z = axisalignedbb2.calculateZOffset(this.getEntityBoundingBox(), z); - } - - this.setEntityBoundingBox(this.getEntityBoundingBox().offset(0.0D, 0.0D, z)); - } - else - { - this.setEntityBoundingBox(this.getEntityBoundingBox().offset(x, y, z)); - } - - this.resetPositionToBB(); - this.isCollided = d0 != y && d0 < 0.0D; - - /* Can never be true! - But this doesn't seem to make any difference anyway. - if (x != x) - { - this.motionX = 0.0D; - } - - if (z != z) - { - this.motionZ = 0.0D; - } - */ - } + // TESTME: Probably no longer necessary. + // @Override + // public void move(double x, double y, double z){ + // + // double d0 = y; + // + // if (this.canCollide) + // { + // List list = this.world.getCollisionBoxes((Entity)null, this.getBoundingBox().addCoord(x, y, z)); + // + // for (AxisAlignedBB axisalignedbb : list) + // { + // y = axisalignedbb.calculateYOffset(this.getBoundingBox(), y); + // } + // + // this.setBoundingBox(this.getBoundingBox().offset(0.0D, y, 0.0D)); + // + // for (AxisAlignedBB axisalignedbb1 : list) + // { + // x = axisalignedbb1.calculateXOffset(this.getBoundingBox(), x); + // } + // + // this.setBoundingBox(this.getBoundingBox().offset(x, 0.0D, 0.0D)); + // + // for (AxisAlignedBB axisalignedbb2 : list) + // { + // z = axisalignedbb2.calculateZOffset(this.getBoundingBox(), z); + // } + // + // this.setBoundingBox(this.getBoundingBox().offset(0.0D, 0.0D, z)); + // } + // else + // { + // this.setBoundingBox(this.getBoundingBox().offset(x, y, z)); + // } + // + // this.resetPositionToBB(); + // this.onGround = d0 != y && d0 < 0.0D; + // + // /* Can never be true! - But this doesn't seem to make any difference anyway. + // if (x != x) + // { + // this.motionX = 0.0D; + // } + // + // if (z != z) + // { + // this.motionZ = 0.0D; + // } + // */ + // } // Overridden to bind the new texture. I think this can be done with TextureAtlasSprite, but this works as it is // so I'm not changing it for the time being. @Override - public void renderParticle(VertexBuffer buffer, Entity viewer, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ){ - + public void renderParticle(VertexBuffer buffer, Entity viewer, float partialTicks, float rotationX, float rotationZ, + float rotationYZ, float rotationXY, float rotationXZ){ + GlStateManager.pushMatrix(); GlStateManager.pushAttrib(); - + this.applyGLStateChanges(); // This stuff does the shading. It vanilla does this later on for each point, but this also seems to work. int brightness = this.getBrightnessForRender(partialTicks); int lightmapX = brightness % 65536; int lightmapY = brightness / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)lightmapX / 1.0F, (float)lightmapY / 1.0F); - + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)lightmapX / 1.0F, + (float)lightmapY / 1.0F); + RenderHelper.disableStandardItemLighting(); Minecraft.getMinecraft().getTextureManager().bindTexture(getTexture()); @@ -152,9 +161,9 @@ public abstract class ParticleCustomTexture extends Particle { buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); float u1 = (float)this.particleTextureIndexX / (float)getXFrames(); - float u2 = u1 + 1.0f/getXFrames(); + float u2 = u1 + 1.0f / getXFrames(); float v1 = (float)this.particleTextureIndexY / (float)getYFrames(); - float v2 = v1 + 1.0f/getYFrames(); + float v2 = v1 + 1.0f / getYFrames(); float scale = 0.1F * this.particleScale; // I'm pretty sure these were always static. @@ -166,13 +175,22 @@ public abstract class ParticleCustomTexture extends Particle { float y = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTicks - interpPosY); float z = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTicks - interpPosZ); - buffer.pos((double)(x - rotationX * scale - rotationXY * scale), (double)(y - rotationZ * scale), (double)(z - rotationYZ * scale - rotationXZ * scale)).tex(u2, v2).color(particleRed, particleGreen, particleBlue, particleAlpha).endVertex(); - buffer.pos((double)(x - rotationX * scale + rotationXY * scale), (double)(y + rotationZ * scale), (double)(z - rotationYZ * scale + rotationXZ * scale)).tex(u2, v1).color(particleRed, particleGreen, particleBlue, particleAlpha).endVertex(); - buffer.pos((double)(x + rotationX * scale + rotationXY * scale), (double)(y + rotationZ * scale), (double)(z + rotationYZ * scale + rotationXZ * scale)).tex(u1, v1).color(particleRed, particleGreen, particleBlue, particleAlpha).endVertex(); - buffer.pos((double)(x + rotationX * scale - rotationXY * scale), (double)(y - rotationZ * scale), (double)(z + rotationYZ * scale - rotationXZ * scale)).tex(u1, v2).color(particleRed, particleGreen, particleBlue, particleAlpha).endVertex();; + buffer.pos((double)(x - rotationX * scale - rotationXY * scale), (double)(y - rotationZ * scale), + (double)(z - rotationYZ * scale - rotationXZ * scale)).tex(u2, v2) + .color(particleRed, particleGreen, particleBlue, particleAlpha).endVertex(); + buffer.pos((double)(x - rotationX * scale + rotationXY * scale), (double)(y + rotationZ * scale), + (double)(z - rotationYZ * scale + rotationXZ * scale)).tex(u2, v1) + .color(particleRed, particleGreen, particleBlue, particleAlpha).endVertex(); + buffer.pos((double)(x + rotationX * scale + rotationXY * scale), (double)(y + rotationZ * scale), + (double)(z + rotationYZ * scale + rotationXZ * scale)).tex(u1, v1) + .color(particleRed, particleGreen, particleBlue, particleAlpha).endVertex(); + buffer.pos((double)(x + rotationX * scale - rotationXY * scale), (double)(y - rotationZ * scale), + (double)(z + rotationYZ * scale - rotationXZ * scale)).tex(u1, v2) + .color(particleRed, particleGreen, particleBlue, particleAlpha).endVertex(); + ; Tessellator.getInstance().draw(); - + this.undoGLStateChanges(); GlStateManager.popAttrib(); @@ -180,13 +198,19 @@ public abstract class ParticleCustomTexture extends Particle { } - /** Override to add any GL state changes, like blending. Does nothing by default. State changes should be - * done using GLStateManager, not using GL11 directly (as is the case with all rendering code now). */ - public void applyGLStateChanges(){} - - /** Override to undo any GL state changes, like blending. Does nothing by default. State changes should be - * done using GLStateManager, not using GL11 directly (as is the case with all rendering code now). */ - public void undoGLStateChanges(){} + /** + * Override to add any GL state changes, like blending. Does nothing by default. State changes should be done + * using GLStateManager, not using GL11 directly (as is the case with all rendering code now). + */ + public void applyGLStateChanges(){ + } + + /** + * Override to undo any GL state changes, like blending. Does nothing by default. State changes should be done + * using GLStateManager, not using GL11 directly (as is the case with all rendering code now). + */ + public void undoGLStateChanges(){ + } @Override public int getBrightnessForRender(float partialTick){ diff --git a/src/main/java/electroblob/wizardry/client/particle/ParticleDarkMagic.java b/src/main/java/electroblob/wizardry/client/particle/ParticleDarkMagic.java index 986e3c7c..7532dd98 100644 --- a/src/main/java/electroblob/wizardry/client/particle/ParticleDarkMagic.java +++ b/src/main/java/electroblob/wizardry/client/particle/ParticleDarkMagic.java @@ -9,82 +9,70 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ParticleDarkMagic extends Particle { - - /** Base spell texture index */ - private int baseSpellTextureIndex = 128; - public ParticleDarkMagic(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, float r, float g, float b) - { - super(par1World, par2, par4, par6, par8, par10, par12); - this.motionY *= 0.20000000298023224D; - - this.particleRed = r; - this.particleGreen = g; - this.particleBlue = b; + /** Base spell texture index */ + private int baseSpellTextureIndex = 128; - this.particleScale *= 0.75F; - this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); - this.canCollide = true; - } + public ParticleDarkMagic(World par1World, double par2, double par4, double par6, double par8, double par10, + double par12, float r, float g, float b){ + super(par1World, par2, par4, par6, par8, par10, par12); + this.motionY *= 0.20000000298023224D; - @Override - public void renderParticle(VertexBuffer buffer, Entity entity, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) - { - float f6 = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F; + this.particleRed = r; + this.particleGreen = g; + this.particleBlue = b; - if (f6 < 0.0F) - { - f6 = 0.0F; - } + this.particleScale *= 0.75F; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + this.canCollide = true; + } - if (f6 > 1.0F) - { - f6 = 1.0F; - } + @Override + public void renderParticle(VertexBuffer buffer, Entity entity, float partialTicks, float rotationX, float rotationZ, + float rotationYZ, float rotationXY, float rotationXZ){ + float f6 = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F; - super.renderParticle(buffer, entity, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ); - } + if(f6 < 0.0F){ + f6 = 0.0F; + } - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() - { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + if(f6 > 1.0F){ + f6 = 1.0F; + } - if (this.particleAge++ >= this.particleMaxAge) - { - this.setExpired(); - } + super.renderParticle(buffer, entity, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ); + } - this.setParticleTextureIndex(this.baseSpellTextureIndex + (7 - this.particleAge * 8 / this.particleMaxAge)); - this.motionY += 0.004D; - this.moveEntity(this.motionX, this.motionY, this.motionZ); - /* - if (this.posY == this.prevPosY) - { - this.motionX *= 1.1D; - this.motionZ *= 1.1D; - } - */ - this.motionX *= 0.9599999785423279D; - this.motionY *= 0.9599999785423279D; - this.motionZ *= 0.9599999785423279D; + /** + * Called to update the entity's position/logic. + */ + public void onUpdate(){ + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; - if (this.isCollided) - { - this.motionX *= 0.699999988079071D; - this.motionZ *= 0.699999988079071D; - } - } + if(this.particleAge++ >= this.particleMaxAge){ + this.setExpired(); + } - /** - * Sets the base spell texture index - */ - public void setBaseSpellTextureIndex(int par1) - { - this.baseSpellTextureIndex = par1; - } + this.setParticleTextureIndex(this.baseSpellTextureIndex + (7 - this.particleAge * 8 / this.particleMaxAge)); + this.motionY += 0.004D; + this.move(this.motionX, this.motionY, this.motionZ); + /* if (this.posY == this.prevPosY) { this.motionX *= 1.1D; this.motionZ *= 1.1D; } */ + this.motionX *= 0.9599999785423279D; + this.motionY *= 0.9599999785423279D; + this.motionZ *= 0.9599999785423279D; + + if(this.onGround){ + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } + + /** + * Sets the base spell texture index + */ + public void setBaseSpellTextureIndex(int par1){ + this.baseSpellTextureIndex = par1; + } } diff --git a/src/main/java/electroblob/wizardry/client/particle/ParticleDust.java b/src/main/java/electroblob/wizardry/client/particle/ParticleDust.java index 6a121fa3..c37dbb51 100644 --- a/src/main/java/electroblob/wizardry/client/particle/ParticleDust.java +++ b/src/main/java/electroblob/wizardry/client/particle/ParticleDust.java @@ -7,51 +7,42 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ParticleDust extends Particle { - + private final boolean shaded; - - public ParticleDust(World par1World, double x, double y, double z, double par8, double par10, double par12, float r, float g, float b, boolean shaded) - { - super(par1World, x, y, z, par8, par10, par12); - this.particleRed = r; - this.particleGreen = g; - this.particleBlue = b; - this.setParticleTextureIndex(0); - this.setSize(0.01F, 0.01F); - this.particleScale *= this.rand.nextFloat() + 0.2F; - this.motionX = par8; - this.motionY = par10; - this.motionZ = par12; - this.particleMaxAge = (int)(16.0D / (Math.random() * 0.8D + 0.2D)); - this.shaded = shaded; - } - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() - { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - //this.moveEntity(this.motionX, this.motionY, this.motionZ); + public ParticleDust(World par1World, double x, double y, double z, double par8, double par10, double par12, float r, + float g, float b, boolean shaded){ + super(par1World, x, y, z, par8, par10, par12); + this.particleRed = r; + this.particleGreen = g; + this.particleBlue = b; + this.setParticleTextureIndex(0); + this.setSize(0.01F, 0.01F); + this.particleScale *= this.rand.nextFloat() + 0.2F; + this.motionX = par8; + this.motionY = par10; + this.motionZ = par12; + this.particleMaxAge = (int)(16.0D / (Math.random() * 0.8D + 0.2D)); + this.shaded = shaded; + } - if (this.particleMaxAge-- <= 0) - { - this.setExpired(); - } - } - - @Override - public int getBrightnessForRender(float par1) - { - return shaded ? super.getBrightnessForRender(par1) : 15728880; - } - /* - @Override - public float getBrightness(float par1) - { - return shaded ? super.getBrightness(par1) : 1.0F; - } - */ + /** + * Called to update the entity's position/logic. + */ + public void onUpdate(){ + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + // this.moveEntity(this.motionX, this.motionY, this.motionZ); + + if(this.particleMaxAge-- <= 0){ + this.setExpired(); + } + } + + @Override + public int getBrightnessForRender(float par1){ + return shaded ? super.getBrightnessForRender(par1) : 15728880; + } + /* @Override public float getBrightness(float par1) { return shaded ? super.getBrightness(par1) : 1.0F; } */ } diff --git a/src/main/java/electroblob/wizardry/client/particle/ParticleGiantBubble.java b/src/main/java/electroblob/wizardry/client/particle/ParticleGiantBubble.java index b469bcb2..b512aaba 100644 --- a/src/main/java/electroblob/wizardry/client/particle/ParticleGiantBubble.java +++ b/src/main/java/electroblob/wizardry/client/particle/ParticleGiantBubble.java @@ -7,44 +7,43 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class ParticleGiantBubble extends Particle -{ - /** The name used to identify this particle. Uses the mod id to avoid any possible conflicts (Not that there would - * be any, but I may as well.) */ +public class ParticleGiantBubble extends Particle { + /** + * The name used to identify this particle. Uses the mod id to avoid any possible conflicts (Not that there would be + * any, but I may as well.) + */ public static final String NAME = Wizardry.MODID + "magicbubble"; - - public ParticleGiantBubble(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) - { - super(par1World, par2, par4, par6, par8, par10, par12); - this.particleRed = 1.0F; - this.particleGreen = 1.0F; - this.particleBlue = 1.0F; - this.setParticleTextureIndex(32); - this.setSize(0.02F, 0.02F); - this.particleScale *= this.rand.nextFloat() * 0.6F + 0.2F; - this.motionX = par8 * 0.20000000298023224D + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.02F); - this.motionY = par10 * 0.20000000298023224D + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.02F); - this.motionZ = par12 * 0.20000000298023224D + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.02F); - this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); - } - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() - { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - this.motionY += 0.002D; - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.8500000238418579D; - this.motionY *= 0.8500000238418579D; - this.motionZ *= 0.8500000238418579D; + public ParticleGiantBubble(World par1World, double par2, double par4, double par6, double par8, double par10, + double par12){ + super(par1World, par2, par4, par6, par8, par10, par12); + this.particleRed = 1.0F; + this.particleGreen = 1.0F; + this.particleBlue = 1.0F; + this.setParticleTextureIndex(32); + this.setSize(0.02F, 0.02F); + this.particleScale *= this.rand.nextFloat() * 0.6F + 0.2F; + this.motionX = par8 * 0.20000000298023224D + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.02F); + this.motionY = par10 * 0.20000000298023224D + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.02F); + this.motionZ = par12 * 0.20000000298023224D + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.02F); + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + } - if (this.particleMaxAge-- <= 0) - { - this.setExpired(); - } - } + /** + * Called to update the entity's position/logic. + */ + public void onUpdate(){ + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY += 0.002D; + this.move(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.8500000238418579D; + this.motionY *= 0.8500000238418579D; + this.motionZ *= 0.8500000238418579D; + + if(this.particleMaxAge-- <= 0){ + this.setExpired(); + } + } } diff --git a/src/main/java/electroblob/wizardry/client/particle/ParticleIce.java b/src/main/java/electroblob/wizardry/client/particle/ParticleIce.java index 3332db15..dd548900 100644 --- a/src/main/java/electroblob/wizardry/client/particle/ParticleIce.java +++ b/src/main/java/electroblob/wizardry/client/particle/ParticleIce.java @@ -9,8 +9,9 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ParticleIce extends ParticleCustomTexture { - private static final ResourceLocation TEXTURE = new ResourceLocation(Wizardry.MODID, "textures/particle/ice_particles.png"); - + private static final ResourceLocation TEXTURE = new ResourceLocation(Wizardry.MODID, + "textures/particle/ice_particles.png"); + public ParticleIce(World world, double x, double y, double z, double vx, double vy, double vz){ super(world, x, y, z, vx, vy, vz); } @@ -18,7 +19,7 @@ public class ParticleIce extends ParticleCustomTexture { public ParticleIce(World world, double x, double y, double z, double vx, double vy, double vz, int maxAge){ super(world, x, y, z, vx, vy, vz, maxAge); } - + @Override public void init(){ this.setParticleTextureIndex(rand.nextInt(8)); @@ -28,7 +29,18 @@ public class ParticleIce extends ParticleCustomTexture { this.fullBrightness = true; } - @Override public ResourceLocation getTexture(){ return TEXTURE; } - @Override protected int getXFrames(){ return 4; } - @Override protected int getYFrames(){ return 4; } + @Override + public ResourceLocation getTexture(){ + return TEXTURE; + } + + @Override + protected int getXFrames(){ + return 4; + } + + @Override + protected int getYFrames(){ + return 4; + } } diff --git a/src/main/java/electroblob/wizardry/client/particle/ParticleLeaf.java b/src/main/java/electroblob/wizardry/client/particle/ParticleLeaf.java index 0292dddf..e2610a3d 100644 --- a/src/main/java/electroblob/wizardry/client/particle/ParticleLeaf.java +++ b/src/main/java/electroblob/wizardry/client/particle/ParticleLeaf.java @@ -8,9 +8,10 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ParticleLeaf extends ParticleCustomTexture { - - private static final ResourceLocation TEXTURE = new ResourceLocation(Wizardry.MODID, "textures/particle/leaf_particles.png"); - + + private static final ResourceLocation TEXTURE = new ResourceLocation(Wizardry.MODID, + "textures/particle/leaf_particles.png"); + public ParticleLeaf(World world, double x, double y, double z, double vx, double vy, double vz){ super(world, x, y, z, vx, vy, vz); } @@ -18,16 +19,27 @@ public class ParticleLeaf extends ParticleCustomTexture { public ParticleLeaf(World world, double x, double y, double z, double vx, double vy, double vz, int maxAge){ super(world, x, y, z, vx, vy, vz, maxAge); } - - @Override - public void init() { - this.setParticleTextureIndex(rand.nextInt(16)); - this.particleScale *= 1.4f; - this.particleGravity = 0; - this.canCollide = true; - } - @Override public ResourceLocation getTexture(){ return TEXTURE; } - @Override protected int getXFrames(){ return 4; } - @Override protected int getYFrames(){ return 4; } + @Override + public void init(){ + this.setParticleTextureIndex(rand.nextInt(16)); + this.particleScale *= 1.4f; + this.particleGravity = 0; + this.canCollide = true; + } + + @Override + public ResourceLocation getTexture(){ + return TEXTURE; + } + + @Override + protected int getXFrames(){ + return 4; + } + + @Override + protected int getYFrames(){ + return 4; + } } diff --git a/src/main/java/electroblob/wizardry/client/particle/ParticleMagicFlame.java b/src/main/java/electroblob/wizardry/client/particle/ParticleMagicFlame.java index 755fa4db..28e8fd1d 100644 --- a/src/main/java/electroblob/wizardry/client/particle/ParticleMagicFlame.java +++ b/src/main/java/electroblob/wizardry/client/particle/ParticleMagicFlame.java @@ -9,39 +9,38 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ParticleMagicFlame extends Particle { - - /** The scale of the flame particle */ - private float flameScale; - public ParticleMagicFlame(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, int maxAge, float scale) - { - super(par1World, par2, par4, par6, par8, par10, par12); - this.motionX = this.motionX * 0.009999999776482582D + par8; - this.motionY = this.motionY * 0.009999999776482582D + par10; - this.motionZ = this.motionZ * 0.009999999776482582D + par12; - this.flameScale = scale; - this.particleRed = this.particleGreen = this.particleBlue = 1.0F; - if(maxAge == 0){ - this.particleMaxAge = (int)(2.0D / (Math.random() * 0.8D + 0.2D)); - }else{ - this.particleMaxAge = maxAge; - } - // IDEA: Make the particles for ray spells collide properly and not spawn on the other side of stuff. - this.canCollide = false; - this.setParticleTextureIndex(48); - } + /** The scale of the flame particle */ + private float flameScale; - @Override - public void renderParticle(VertexBuffer buffer, Entity entity, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) - { - float f6 = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge; - this.particleScale = this.flameScale * (1.0F - f6 * f6 * 0.5F); - super.renderParticle(buffer, entity, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ); - } + public ParticleMagicFlame(World par1World, double par2, double par4, double par6, double par8, double par10, + double par12, int maxAge, float scale){ + super(par1World, par2, par4, par6, par8, par10, par12); + this.motionX = this.motionX * 0.009999999776482582D + par8; + this.motionY = this.motionY * 0.009999999776482582D + par10; + this.motionZ = this.motionZ * 0.009999999776482582D + par12; + this.flameScale = scale; + this.particleRed = this.particleGreen = this.particleBlue = 1.0F; + if(maxAge == 0){ + this.particleMaxAge = (int)(2.0D / (Math.random() * 0.8D + 0.2D)); + }else{ + this.particleMaxAge = maxAge; + } + // IDEA: Make the particles for ray spells collide properly and not spawn on the other side of stuff. + this.canCollide = false; + this.setParticleTextureIndex(48); + } - @Override - public int getBrightnessForRender(float par1) - { - return 256; - } + @Override + public void renderParticle(VertexBuffer buffer, Entity entity, float partialTicks, float rotationX, float rotationZ, + float rotationYZ, float rotationXY, float rotationXZ){ + float f6 = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge; + this.particleScale = this.flameScale * (1.0F - f6 * f6 * 0.5F); + super.renderParticle(buffer, entity, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ); + } + + @Override + public int getBrightnessForRender(float par1){ + return 256; + } } diff --git a/src/main/java/electroblob/wizardry/client/particle/ParticlePath.java b/src/main/java/electroblob/wizardry/client/particle/ParticlePath.java index cf7b2c6e..4db78d66 100644 --- a/src/main/java/electroblob/wizardry/client/particle/ParticlePath.java +++ b/src/main/java/electroblob/wizardry/client/particle/ParticlePath.java @@ -13,81 +13,95 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ParticlePath extends ParticleCustomTexture { - - private static final ResourceLocation TEXTURE = new ResourceLocation(Wizardry.MODID, "textures/particle/path_particles.png"); - - private final double originX, originY, originZ; - public ParticlePath(World world, double x, double y, double z, double vx, double vy, double vz, float r, float g, float b){ + private static final ResourceLocation TEXTURE = new ResourceLocation(Wizardry.MODID, + "textures/particle/path_particles.png"); + + private final double originX, originY, originZ; + + public ParticlePath(World world, double x, double y, double z, double vx, double vy, double vz, float r, float g, + float b){ super(world, x, y, z, vx, vy, vz); this.setRBGColorF(r, g, b); - this.originX = x; - this.originY = y; - this.originZ = z; + this.originX = x; + this.originY = y; + this.originZ = z; } - public ParticlePath(World world, double x, double y, double z, double vx, double vy, double vz, float r, float g, float b, int maxAge){ + public ParticlePath(World world, double x, double y, double z, double vx, double vy, double vz, float r, float g, + float b, int maxAge){ super(world, x, y, z, vx, vy, vz, maxAge); this.setRBGColorF(r, g, b); - this.originX = x; - this.originY = y; - this.originZ = z; + this.originX = x; + this.originY = y; + this.originZ = z; } - - @Override - public void init(){ - this.setParticleTextureIndex(0); - // Set to a constant to remove the randomness from Particle. - this.particleScale = 1.25f; - this.particleGravity = 0; - this.fullBrightness = true; - this.canCollide = false; - } - - @Override public ResourceLocation getTexture(){ return TEXTURE; } - @Override protected int getXFrames(){ return 1; } - @Override protected int getYFrames(){ return 1; } @Override - public void onUpdate(){ - + public void init(){ + this.setParticleTextureIndex(0); + // Set to a constant to remove the randomness from Particle. + this.particleScale = 1.25f; + this.particleGravity = 0; + this.fullBrightness = true; + this.canCollide = false; + } + + @Override + public ResourceLocation getTexture(){ + return TEXTURE; + } + + @Override + protected int getXFrames(){ + return 1; + } + + @Override + protected int getYFrames(){ + return 1; + } + + @Override + public void onUpdate(){ + this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; - if (this.particleAge++ >= this.particleMaxAge) - { - this.setExpired(); - } + if(this.particleAge++ >= this.particleMaxAge){ + this.setExpired(); + } - this.moveEntity(this.motionX, this.motionY, this.motionZ); - - // Fading - if(this.particleAge > this.particleMaxAge / 2){ - this.setAlphaF(1.0F - 2 * (((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge)); - } - - if(this.particleAge % Clairvoyance.PARTICLE_MOVEMENT_INTERVAL == 0){ - this.setPosition(this.originX, this.originY, this.originZ); - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - } - - } - - @Override - public void applyGLStateChanges(){ - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - // TESTME: Are these two actually necessary? - GlStateManager.disableLighting(); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); - } - - @Override - public void undoGLStateChanges(){ - GlStateManager.disableBlend(); - GlStateManager.enableLighting(); - } + this.move(this.motionX, this.motionY, this.motionZ); + + // Fading + if(this.particleAge > this.particleMaxAge / 2){ + this.setAlphaF(1.0F + - 2 * (((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge)); + } + + if(this.particleAge % Clairvoyance.PARTICLE_MOVEMENT_INTERVAL == 0){ + this.setPosition(this.originX, this.originY, this.originZ); + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + } + + } + + @Override + public void applyGLStateChanges(){ + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + // TESTME: Are these two actually necessary? + GlStateManager.disableLighting(); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); + } + + @Override + public void undoGLStateChanges(){ + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + } } diff --git a/src/main/java/electroblob/wizardry/client/particle/ParticleRotatingSparkle.java b/src/main/java/electroblob/wizardry/client/particle/ParticleRotatingSparkle.java index eadc09bb..498bb038 100644 --- a/src/main/java/electroblob/wizardry/client/particle/ParticleRotatingSparkle.java +++ b/src/main/java/electroblob/wizardry/client/particle/ParticleRotatingSparkle.java @@ -6,54 +6,56 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ParticleRotatingSparkle extends ParticleSparkle { - - private double angle; - private double radius; - private double speed; - public ParticleRotatingSparkle(World world, int maxAge, double originX, double originZ, double radius, double yPos, float r, float g , float b){ - super(world, 0, 0, 0, 0, 0, 0, r, g, b, maxAge); - this.angle = this.rand.nextDouble() * Math.PI * 2; - double x = originX - Math.cos(angle)*radius; - double z = originZ + radius*Math.sin(angle); - this.radius = radius; - this.setPosition(x, yPos, z); - this.prevPosX = x; - this.prevPosY = yPos; - this.prevPosZ = z; - if(rand.nextBoolean()){ - speed = rand.nextDouble()*2 + 1; - }else{ - speed = rand.nextDouble()*-2 - 1; - } - this.multipleParticleScaleBy(1.5f); - } + private double angle; + private double radius; + private double speed; - @Override - public void onUpdate(){ - - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + public ParticleRotatingSparkle(World world, int maxAge, double originX, double originZ, double radius, double yPos, + float r, float g, float b){ + super(world, 0, 0, 0, 0, 0, 0, r, g, b, maxAge); + this.angle = this.rand.nextDouble() * Math.PI * 2; + double x = originX - Math.cos(angle) * radius; + double z = originZ + radius * Math.sin(angle); + this.radius = radius; + this.setPosition(x, yPos, z); + this.prevPosX = x; + this.prevPosY = yPos; + this.prevPosZ = z; + if(rand.nextBoolean()){ + speed = rand.nextDouble() * 2 + 1; + }else{ + speed = rand.nextDouble() * -2 - 1; + } + this.multipleParticleScaleBy(1.5f); + } - if(this.particleAge++ >= this.particleMaxAge){ - this.setExpired(); - } - - // This is in radians per tick... - double omega = Math.signum(speed) * ((Math.PI*2)/20 - speed/(20*radius)); - - // v = r times omega; therefore the normalised velocity vector needs to be r times the angle increment / 2 pi. - this.angle += omega; + @Override + public void onUpdate(){ - this.motionY -= 0.04D * (double)this.particleGravity; - this.motionZ = radius * omega * Math.cos(angle); - this.motionX = radius * omega * Math.sin(angle); - this.moveEntity(motionX, motionY, motionZ); + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; - if(this.particleAge > this.particleMaxAge / 2){ - this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge); - } - - } + if(this.particleAge++ >= this.particleMaxAge){ + this.setExpired(); + } + + // This is in radians per tick... + double omega = Math.signum(speed) * ((Math.PI * 2) / 20 - speed / (20 * radius)); + + // v = r times omega; therefore the normalised velocity vector needs to be r times the angle increment / 2 pi. + this.angle += omega; + + this.motionY -= 0.04D * (double)this.particleGravity; + this.motionZ = radius * omega * Math.cos(angle); + this.motionX = radius * omega * Math.sin(angle); + this.move(motionX, motionY, motionZ); + + if(this.particleAge > this.particleMaxAge / 2){ + this.setAlphaF( + 1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge); + } + + } } diff --git a/src/main/java/electroblob/wizardry/client/particle/ParticleSnow.java b/src/main/java/electroblob/wizardry/client/particle/ParticleSnow.java index a1455c22..e0d5250d 100644 --- a/src/main/java/electroblob/wizardry/client/particle/ParticleSnow.java +++ b/src/main/java/electroblob/wizardry/client/particle/ParticleSnow.java @@ -8,9 +8,10 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ParticleSnow extends ParticleCustomTexture { - - private static final ResourceLocation TEXTURE = new ResourceLocation(Wizardry.MODID, "textures/particle/snow_particles.png"); - + + private static final ResourceLocation TEXTURE = new ResourceLocation(Wizardry.MODID, + "textures/particle/snow_particles.png"); + public ParticleSnow(World world, double x, double y, double z, double vx, double vy, double vz){ super(world, x, y, z, vx, vy, vz); } @@ -18,16 +19,27 @@ public class ParticleSnow extends ParticleCustomTexture { public ParticleSnow(World world, double x, double y, double z, double vx, double vy, double vz, int maxAge){ super(world, x, y, z, vx, vy, vz, maxAge); } - - @Override - public void init(){ - this.setParticleTextureIndex(rand.nextInt(8)); - this.particleScale *= 0.6f; - this.particleGravity = 0; - this.canCollide = true; - } - - @Override public ResourceLocation getTexture(){ return TEXTURE; } - @Override protected int getXFrames(){ return 4; } - @Override protected int getYFrames(){ return 4; } + + @Override + public void init(){ + this.setParticleTextureIndex(rand.nextInt(8)); + this.particleScale *= 0.6f; + this.particleGravity = 0; + this.canCollide = true; + } + + @Override + public ResourceLocation getTexture(){ + return TEXTURE; + } + + @Override + protected int getXFrames(){ + return 4; + } + + @Override + protected int getYFrames(){ + return 4; + } } diff --git a/src/main/java/electroblob/wizardry/client/particle/ParticleSpark.java b/src/main/java/electroblob/wizardry/client/particle/ParticleSpark.java index 57965ed2..201d2373 100644 --- a/src/main/java/electroblob/wizardry/client/particle/ParticleSpark.java +++ b/src/main/java/electroblob/wizardry/client/particle/ParticleSpark.java @@ -12,47 +12,59 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ParticleSpark extends ParticleCustomTexture { - - private static final ResourceLocation TEXTURE = new ResourceLocation(Wizardry.MODID, "textures/particle/lightning_particles.png"); - - public ParticleSpark(World world, double x, double y, double z, double vx, double vy, double vz){ - // Max age is always 3. - super(world, x, y, z, vx, vy, vz, 3); - } - - @Override - public void init(){ - // Multiplied by 4 because the index works slightly differently for spark particles. - this.setParticleTextureIndex(rand.nextInt(8)*4); - this.particleScale *= 1.4f; - this.fullBrightness = true; - this.canCollide = false; - } - @Override - public void onUpdate(){ - super.onUpdate(); - // Well this is handy! Looks like vanilla uses the texture index like this too. - this.nextTextureIndexX(); - } - - @Override public ResourceLocation getTexture(){ return TEXTURE; } - @Override protected int getXFrames(){ return 4; } - @Override protected int getYFrames(){ return 8; } - - @Override - public void applyGLStateChanges(){ - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - // TESTME: Are these two actually necessary? - GlStateManager.disableLighting(); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); - } - - @Override - public void undoGLStateChanges(){ - GlStateManager.disableBlend(); - GlStateManager.enableLighting(); - } - + private static final ResourceLocation TEXTURE = new ResourceLocation(Wizardry.MODID, + "textures/particle/lightning_particles.png"); + + public ParticleSpark(World world, double x, double y, double z, double vx, double vy, double vz){ + // Max age is always 3. + super(world, x, y, z, vx, vy, vz, 3); + } + + @Override + public void init(){ + // Multiplied by 4 because the index works slightly differently for spark particles. + this.setParticleTextureIndex(rand.nextInt(8) * 4); + this.particleScale *= 1.4f; + this.fullBrightness = true; + this.canCollide = false; + } + + @Override + public void onUpdate(){ + super.onUpdate(); + // Well this is handy! Looks like vanilla uses the texture index like this too. + this.nextTextureIndexX(); + } + + @Override + public ResourceLocation getTexture(){ + return TEXTURE; + } + + @Override + protected int getXFrames(){ + return 4; + } + + @Override + protected int getYFrames(){ + return 8; + } + + @Override + public void applyGLStateChanges(){ + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + // TESTME: Are these two actually necessary? + GlStateManager.disableLighting(); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); + } + + @Override + public void undoGLStateChanges(){ + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + } + } diff --git a/src/main/java/electroblob/wizardry/client/particle/ParticleSparkle.java b/src/main/java/electroblob/wizardry/client/particle/ParticleSparkle.java index fbe89146..e5dd0d2b 100644 --- a/src/main/java/electroblob/wizardry/client/particle/ParticleSparkle.java +++ b/src/main/java/electroblob/wizardry/client/particle/ParticleSparkle.java @@ -8,89 +8,104 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ParticleSparkle extends ParticleCustomTexture { - + /* I have now figured out what particle factories are for: they separate out the individual uses of the varargs * parameter in spawnParticle so they are kept with the particle class. For my purposes, it would be easier to do * that in the particle spawning method itself. */ - - private static final ResourceLocation TEXTURE = new ResourceLocation(Wizardry.MODID, "textures/particle/sparkle_particles.png"); + + private static final ResourceLocation TEXTURE = new ResourceLocation(Wizardry.MODID, + "textures/particle/sparkle_particles.png"); // NOTE: Uncomment once 2.1.0 is released - //private final float initialRed; - //private final float initialGreen; - //private final float initialBlue; - + // private final float initialRed; + // private final float initialGreen; + // private final float initialBlue; + // TODO: Assign these via the constructors, as part of the refactoring for particle parameters. // NOTE: Uncomment once 2.1.0 is released -// private final float fadeRed = 1; -// private final float fadeGreen = 1; -// private final float fadeBlue = 0; - - public ParticleSparkle(World world, double x, double y, double z, double vx, double vy, double vz, float r, float g, float b){ + // private final float fadeRed = 1; + // private final float fadeGreen = 1; + // private final float fadeBlue = 0; + + public ParticleSparkle(World world, double x, double y, double z, double vx, double vy, double vz, float r, float g, + float b){ super(world, x, y, z, vx, vy, vz); this.setRBGColorF(r, g, b); // NOTE: Uncomment once 2.1.0 is released - //initialRed = r; - //initialGreen = g; - //initialBlue = b; - this.particleMaxAge = 48 + this.rand.nextInt(12); - } + // initialRed = r; + // initialGreen = g; + // initialBlue = b; + this.particleMaxAge = 48 + this.rand.nextInt(12); + } - public ParticleSparkle(World world, double x, double y, double z, double vx, double vy, double vz, float r, float g, float b, int maxAge){ + public ParticleSparkle(World world, double x, double y, double z, double vx, double vy, double vz, float r, float g, + float b, int maxAge){ super(world, x, y, z, vx, vy, vz, maxAge); this.setRBGColorF(r, g, b); // NOTE: Uncomment once 2.1.0 is released - //initialRed = r; - //initialGreen = g; - //initialBlue = b; - } - - public ParticleSparkle(World world, double x, double y, double z, double vx, double vy, double vz, float r, float g, float b, boolean doGravity){ - this(world, x, y, z, vx, vy, vz, r, g, b); - this.particleGravity = doGravity ? 1 : 0; - } - - public ParticleSparkle(World world, double x, double y, double z, double vx, double vy, double vz, float r, float g, float b, int maxAge, boolean doGravity){ - this(world, x, y, z, vx, vy, vz, r, g, b, maxAge); - this.particleGravity = doGravity ? 1 : 0; - } - - @Override - public void init(){ - this.setParticleTextureIndex(rand.nextInt(16)); - this.particleScale *= 0.75f; - this.particleGravity = 0; - this.canCollide = false; - this.fullBrightness = true; - } - - @Override public ResourceLocation getTexture(){ return TEXTURE; } - @Override protected int getXFrames(){ return 4; } - @Override protected int getYFrames(){ return 4; } + // initialRed = r; + // initialGreen = g; + // initialBlue = b; + } - @Override - public void onUpdate(){ - - super.onUpdate(); - // Fading - if(this.particleAge > this.particleMaxAge / 2){ - this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge); - } - // Colour fading TODO Uncomment once 2.1.0 is released -// float ageFraction = (float)this.particleAge / (float)this.particleMaxAge; -// this.setRBGColorF(this.initialRed + (this.fadeRed - this.initialRed)*ageFraction, -// this.initialGreen + (this.fadeGreen - this.initialGreen)*ageFraction, -// this.initialBlue + (this.fadeBlue - this.initialBlue)*ageFraction); -// -// this.setParticleTextureIndex((this.particleAge * 11)/this.particleMaxAge); - } - - /* - * As a side note, I see a lot of magic mods with fancy-looking particle effects that really seem to 'glow'. It's - * actually not that hard - you simply create a reasonably high-res texture with translucency and then set the - * OpenGL blend function to something like SRC_ALPHA, SRC_ALPHA or ONE, ONE. The thing is... they're not very - * Minecraft-y. I still maintain that part of wizardry's appeal is that it stays true to the game's pixelated charm, - * rather than trying to make it something it's not. Still, the newer textures are much better than the defaults I - * used to use. - */ + public ParticleSparkle(World world, double x, double y, double z, double vx, double vy, double vz, float r, float g, + float b, boolean doGravity){ + this(world, x, y, z, vx, vy, vz, r, g, b); + this.particleGravity = doGravity ? 1 : 0; + } + + public ParticleSparkle(World world, double x, double y, double z, double vx, double vy, double vz, float r, float g, + float b, int maxAge, boolean doGravity){ + this(world, x, y, z, vx, vy, vz, r, g, b, maxAge); + this.particleGravity = doGravity ? 1 : 0; + } + + @Override + public void init(){ + this.setParticleTextureIndex(rand.nextInt(16)); + this.particleScale *= 0.75f; + this.particleGravity = 0; + this.canCollide = false; + this.fullBrightness = true; + } + + @Override + public ResourceLocation getTexture(){ + return TEXTURE; + } + + @Override + protected int getXFrames(){ + return 4; + } + + @Override + protected int getYFrames(){ + return 4; + } + + @Override + public void onUpdate(){ + + super.onUpdate(); + // Fading + if(this.particleAge > this.particleMaxAge / 2){ + this.setAlphaF( + 1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge); + } + // Colour fading TODO Uncomment once 2.1.0 is released + // float ageFraction = (float)this.particleAge / (float)this.particleMaxAge; + // this.setRBGColorF(this.initialRed + (this.fadeRed - this.initialRed)*ageFraction, + // this.initialGreen + (this.fadeGreen - this.initialGreen)*ageFraction, + // this.initialBlue + (this.fadeBlue - this.initialBlue)*ageFraction); + // + // this.setParticleTextureIndex((this.particleAge * 11)/this.particleMaxAge); + } + + /* As a side note, I see a lot of magic mods with fancy-looking particle effects that really seem to 'glow'. It's + * actually not that hard - you simply create a reasonably high-res texture with translucency and then set the + * OpenGL blend function to something like SRC_ALPHA, SRC_ALPHA or ONE, ONE. The thing is... they're not very + * Minecraft-y. I still maintain that part of wizardry's appeal is that it stays true to the game's pixelated charm, + * rather than trying to make it something it's not. Still, the newer textures are much better than the defaults I + * used to use. */ } diff --git a/src/main/java/electroblob/wizardry/client/particle/ParticleTornado.java b/src/main/java/electroblob/wizardry/client/particle/ParticleTornado.java index 1dd5635b..8887e503 100644 --- a/src/main/java/electroblob/wizardry/client/particle/ParticleTornado.java +++ b/src/main/java/electroblob/wizardry/client/particle/ParticleTornado.java @@ -9,75 +9,77 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ParticleTornado extends ParticleDigging { - - private double angle; - private double radius; - private double speed; - /** Velocity of the tornado itself; in other words the velocity of the point the particle circles around. */ - private double velX, velZ; - private boolean fullBrightness = false; - public ParticleTornado(World world, int maxAge, double originX, double originZ, double radius, double yPos, double velX, double velZ, IBlockState block){ - super(world, 0, 0, 0, 0, 0, 0, block); - this.angle = this.rand.nextDouble() * Math.PI * 2; - double x = originX - Math.cos(angle)*radius; - double z = originZ + radius*Math.sin(angle); - this.radius = radius; - this.setPosition(x, yPos, z); - this.prevPosX = x; - this.prevPosY = yPos; - this.prevPosZ = z; - //this.particleScale *= 0.75F; - this.particleMaxAge = maxAge; - this.canCollide = false; - // Grass has special treatment, since it has a colourised top but the rest is normal. - // Commented out for now since vanilla does something about this now, but I'm not sure what exactly - //if(block.getBlock() != Blocks.GRASS || side == 1) this.setColour(block.getRenderColor(side)); - - // Blocks that emit light are rendered with full brightness. - if(block.getLightValue(world, new BlockPos(this.posX, this.posY, this.posZ)) == 0){ - this.particleRed *= 0.75; - this.particleGreen *= 0.75; - this.particleBlue *= 0.75; - }else{ - this.fullBrightness = true; - } - - speed = rand.nextDouble()*2 + 1; - this.velX = velX; - this.velZ = velZ; - } + private double angle; + private double radius; + private double speed; + /** Velocity of the tornado itself; in other words the velocity of the point the particle circles around. */ + private double velX, velZ; + private boolean fullBrightness = false; - @Override - public void onUpdate(){ - - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + public ParticleTornado(World world, int maxAge, double originX, double originZ, double radius, double yPos, + double velX, double velZ, IBlockState block){ + super(world, 0, 0, 0, 0, 0, 0, block); + this.angle = this.rand.nextDouble() * Math.PI * 2; + double x = originX - Math.cos(angle) * radius; + double z = originZ + radius * Math.sin(angle); + this.radius = radius; + this.setPosition(x, yPos, z); + this.prevPosX = x; + this.prevPosY = yPos; + this.prevPosZ = z; + // this.particleScale *= 0.75F; + this.particleMaxAge = maxAge; + this.canCollide = false; + // Grass has special treatment, since it has a colourised top but the rest is normal. + // Commented out for now since vanilla does something about this now, but I'm not sure what exactly + // if(block.getBlock() != Blocks.GRASS || side == 1) this.setColour(block.getRenderColor(side)); - if(this.particleAge++ >= this.particleMaxAge){ - this.setExpired(); - } - - // This is in radians per tick... - double omega = Math.signum(speed) * ((Math.PI*2)/20 - speed/(20*radius)); + // Blocks that emit light are rendered with full brightness. + if(block.getLightValue(world, new BlockPos(this.posX, this.posY, this.posZ)) == 0){ + this.particleRed *= 0.75; + this.particleGreen *= 0.75; + this.particleBlue *= 0.75; + }else{ + this.fullBrightness = true; + } - // v = r times omega; therefore the normalised velocity vector needs to be r times the angle increment / 2 pi. - this.angle += omega; - - this.motionZ = radius * omega * Math.cos(angle); - this.motionX = radius * omega * Math.sin(angle); - this.moveEntity(motionX + velX, 0, motionZ + velZ); + speed = rand.nextDouble() * 2 + 1; + this.velX = velX; + this.velZ = velZ; + } + + @Override + public void onUpdate(){ + + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if(this.particleAge++ >= this.particleMaxAge){ + this.setExpired(); + } + + // This is in radians per tick... + double omega = Math.signum(speed) * ((Math.PI * 2) / 20 - speed / (20 * radius)); + + // v = r times omega; therefore the normalised velocity vector needs to be r times the angle increment / 2 pi. + this.angle += omega; + + this.motionZ = radius * omega * Math.cos(angle); + this.motionX = radius * omega * Math.sin(angle); + this.move(motionX + velX, 0, motionZ + velZ); + + if(this.particleAge > this.particleMaxAge / 2){ + this.setAlphaF( + 1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge); + } + + } + + @Override + public int getBrightnessForRender(float partialTicks){ + return fullBrightness ? 15728880 : super.getBrightnessForRender(partialTicks); + } - if(this.particleAge > this.particleMaxAge / 2){ - this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge); - } - - } - - @Override - public int getBrightnessForRender(float partialTicks){ - return fullBrightness ? 15728880 : super.getBrightnessForRender(partialTicks); - } - } diff --git a/src/main/java/electroblob/wizardry/client/renderer/LayerStone.java b/src/main/java/electroblob/wizardry/client/renderer/LayerStone.java index 4365a842..82f5950f 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/LayerStone.java +++ b/src/main/java/electroblob/wizardry/client/renderer/LayerStone.java @@ -1,14 +1,9 @@ package electroblob.wizardry.client.renderer; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.List; import java.util.Map.Entry; import org.lwjgl.opengl.GL11; -import electroblob.wizardry.Wizardry; import electroblob.wizardry.client.ClientProxy; import electroblob.wizardry.spell.Petrify; import net.minecraft.client.Minecraft; @@ -20,172 +15,140 @@ import net.minecraft.client.renderer.GlStateManager.SourceFactor; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderLivingBase; -import net.minecraft.client.renderer.entity.RenderZombie; import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.EntityZombie; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraftforge.fml.relauncher.ReflectionHelper; /** - * Layer used to render the stone texture on a petrified creature. Handles dynamic tiling of the stone texture and - * reflective access for classes that don't play nicely (looking at you, {@link RenderZombie}). + * Layer used to render the stone texture on a petrified creature. Handles dynamic tiling of the stone texture. + * * @author Electroblob * @since Wizardry 1.2 */ public class LayerStone implements LayerRenderer { - - protected ModelBase model; - private final RenderLivingBase renderer; + + protected ModelBase model; + private final RenderLivingBase renderer; private static final ResourceLocation texture = new ResourceLocation("textures/blocks/stone.png"); - private static final Field zombieLayers = ReflectionHelper.findField(RenderZombie.class, "defaultLayers", "field_177122_o"); - private static final Field zombieVillagerLayers = ReflectionHelper.findField(RenderZombie.class, "villagerLayers", "field_177121_n"); - private static final Method swapZombieModel = ReflectionHelper.findMethod(RenderZombie.class, null, - new String[]{"swapArmor", "func_82427_a"}, EntityZombie.class); // Second parameter (null) is unused - - @SuppressWarnings("unchecked") // The compiler is being annoying and I know that what I'm doing is type-safe. public static void initialiseLayers(){ - for(Entry, Render> entry : Minecraft.getMinecraft().getRenderManager().entityRenderMap.entrySet()){ - // Zombies don't play nicely because they have their own, private lists of layers for the regular zombie - // and the zombie villager, which are assigned within the constructor for RenderZombie and swapped out - // as necessary. However, Mojang, in their infinite wisdom, haven't bothered to override addLayer to - // modify those internal lists, so that method is useless. - if(entry.getValue() instanceof RenderZombie){ - try { - Object layers = zombieLayers.get(entry.getValue()); - if(layers instanceof List){ - // Nice as the layer renderer system is, it doesn't lend itself to reflective access. - // I KNOW that 'layers' (which was obtained using reflection) is of the type - // List>, because that's what it's declared as. However, if I cast - // 'layers' to List>, I can't add a LayerStone because it's only a - // LayerRenderer, not a LayerRenderer. - ((List>)layers).add(new LayerStone((RenderLivingBase)entry.getValue())); - } - layers = zombieVillagerLayers.get(entry.getValue()); - if(layers instanceof List){ - ((List>)layers).add(new LayerStone((RenderLivingBase)entry.getValue())); - } - } catch (IllegalArgumentException | IllegalAccessException e){ - Wizardry.logger.error("Error while reflectively accessing zombie render layers"); - e.printStackTrace(); - } - }else if(entry.getValue() instanceof RenderLivingBase){ + for(Entry, Render> entry : Minecraft.getMinecraft() + .getRenderManager().entityRenderMap.entrySet()){ + // Because the zombie classes are now split properly, their renderers play nicely like everything else. + if(entry.getValue() instanceof RenderLivingBase){ // Adds a stone layer to all the living entity renderers in the game. Whether it is actually rendered // is decided in doRenderLayer below on a per-entity basis. ((RenderLivingBase)entry.getValue()).addLayer(new LayerStone((RenderLivingBase)entry.getValue())); } - // NOTE: May have to do some special stuff for players if they are to be added; see Minecraft.getMinecraft().getRenderManager().getSkinMap() + // NOTE: May have to do some special stuff for players if they are to be added; see + // Minecraft.getMinecraft().getRenderManager().getSkinMap() } } - - public LayerStone(RenderLivingBase renderer){ - this.renderer = renderer; - this.model = renderer.getMainModel(); - } - @Override - public void doRenderLayer(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale){ - - if(entity.getEntityData().getBoolean(Petrify.NBT_KEY)){ + public LayerStone(RenderLivingBase renderer){ + this.renderer = renderer; + this.model = renderer.getMainModel(); + } + + @Override + public void doRenderLayer(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks, + float ageInTicks, float netHeadYaw, float headPitch, float scale){ + + if(entity.getEntityData().getBoolean(Petrify.NBT_KEY)){ GlStateManager.enableLighting(); - int i = this.getBlockBrightnessForEntity(entity, partialTicks); + int i = this.getBlockBrightnessForEntity(entity, partialTicks); int j = i % 65536; int k = i / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); - - ResourceLocation breakingTexture = ClientProxy.renderStatue.getBlockBreakingTexture(); - - if(breakingTexture != null){ - // Block breaking animation - // TODO: Spider eyes and enderman eyes (any others?) show through the stone when the block is being broken... - GlStateManager.enableBlend(); - GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); - this.renderer.bindTexture(breakingTexture); - this.renderEntityModel(entity, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); - GlStateManager.disableBlend(); - }else{ - // Stone texture - this.renderer.bindTexture(texture); - this.renderEntityModel(entity, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); - } - } - } - - private int getBlockBrightnessForEntity(Entity entity, float partialTicks){ - - BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(MathHelper.floor_double(entity.posX), 0, MathHelper.floor_double(entity.posZ)); - if(entity.worldObj.isBlockLoaded(pos)){ - pos.setY(MathHelper.floor_double(entity.posY + (double)entity.getEyeHeight())); - return entity.worldObj.getCombinedLight(pos, 0); - }else{ - return 0; - } - } + ResourceLocation breakingTexture = ClientProxy.renderStatue.getBlockBreakingTexture(); + + if(breakingTexture != null){ + // Block breaking animation + // TODO: Spider eyes and enderman eyes (any others?) show through the stone when the block is being + // broken... + GlStateManager.enableBlend(); + GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); + this.renderer.bindTexture(breakingTexture); + this.renderEntityModel(entity, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, + headPitch, scale); + GlStateManager.disableBlend(); + }else{ + // Stone texture + this.renderer.bindTexture(texture); + this.renderEntityModel(entity, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, + headPitch, scale); + } + } + } + + private int getBlockBrightnessForEntity(Entity entity, float partialTicks){ + + BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(MathHelper.floor(entity.posX), 0, + MathHelper.floor(entity.posZ)); + + if(entity.world.isBlockLoaded(pos)){ + pos.setY(MathHelper.floor(entity.posY + (double)entity.getEyeHeight())); + return entity.world.getCombinedLight(pos, 0); + }else{ + return 0; + } + } + + private void renderEntityModel(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks, + float ageInTicks, float netHeadYaw, float headPitch, float scale){ - private void renderEntityModel(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale){ - GlStateManager.pushMatrix(); // Enables tiling (Also used for guardian beam, beacon beam and ender crystal beam) // TODO: Backport this improvement GlStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GlStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); - + GlStateManager.depthMask(true); // Some entities set depth mask to false (i.e. no sorting of faces by depth) // In particular, LayerSpiderEyes sets it to false when the spider is invisible, for some reason. - + // Changes the scale at which the texture is applied to the model. See LayerCreeper for a similar example, // but with translation instead of scaling. + // NOTE: You can do all sorts of fun stuff with this, just by applying transformations in the 2D texture space. GlStateManager.matrixMode(GL11.GL_TEXTURE); GlStateManager.loadIdentity(); double scaleX = 1, scaleY = 1; // It's more logical to use the model's texture size, but some classes don't bother setting it properly // (e.g. ModelVillager), so to get the correct dimensions I'm getting them from the first box instead. if(model.boxList != null && model.boxList.get(0) != null){ - scaleX = (double)model.boxList.get(0).textureWidth/16d; - scaleY = (double)model.boxList.get(0).textureHeight/16d; + scaleX = (double)model.boxList.get(0).textureWidth / 16d; + scaleY = (double)model.boxList.get(0).textureHeight / 16d; }else{ // Fallback to model fields; should never be needed - scaleX = (double)model.textureWidth/16d; - scaleY = (double)model.textureHeight/16d; + scaleX = (double)model.textureWidth / 16d; + scaleY = (double)model.textureHeight / 16d; } GlStateManager.scale(scaleX, scaleY, 1); GlStateManager.matrixMode(GL11.GL_MODELVIEW); - - // Lets RenderZombie do its (stupid and inflexible) model switching thing - if(this.renderer instanceof RenderZombie && entity instanceof EntityZombie){ - try { - swapZombieModel.invoke(this.renderer, entity); - this.model = this.renderer.getMainModel(); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Wizardry.logger.error("Error while reflectively calling RenderZombie#swapArmor"); - e.printStackTrace(); - } - } - // Hides the hat layer for bipeds - if(this.model instanceof ModelBiped) ((ModelBiped) this.model).bipedHeadwear.isHidden = true; + // Hides the hat layer for bipeds + if(this.model instanceof ModelBiped) ((ModelBiped)this.model).bipedHeadwear.isHidden = true; + this.model.setLivingAnimations(entity, limbSwing, limbSwingAmount, partialTicks); this.model.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); - - if(this.model instanceof ModelBiped) ((ModelBiped) this.model).bipedHeadwear.isHidden = false; - + + if(this.model instanceof ModelBiped) ((ModelBiped)this.model).bipedHeadwear.isHidden = false; + // Undoes the texture scaling GlStateManager.matrixMode(GL11.GL_TEXTURE); GlStateManager.loadIdentity(); GlStateManager.matrixMode(GL11.GL_MODELVIEW); - + GlStateManager.popMatrix(); } - @Override - public boolean shouldCombineTextures(){ - return false; - } + @Override + public boolean shouldCombineTextures(){ + return false; + } } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/client/renderer/RayHelper.java b/src/main/java/electroblob/wizardry/client/renderer/RayHelper.java index 0fdd1e1e..1f5a979b 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RayHelper.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RayHelper.java @@ -7,8 +7,9 @@ class RayHelper implements Comparable { double x1, y1, z1; double x2, y2, z2; double offsetX, offsetY, offsetZ; - - RayHelper(int ordinal, double x1, double y1, double z1, double x2, double y2, double z2, double offsetX, double offsetY, double offsetZ){ + + RayHelper(int ordinal, double x1, double y1, double z1, double x2, double y2, double z2, double offsetX, + double offsetY, double offsetZ){ this.ordinal = ordinal; this.x1 = x1; this.y1 = y1; @@ -20,20 +21,20 @@ class RayHelper implements Comparable { this.offsetY = offsetY; this.offsetZ = offsetZ; } - + double getDistanceFromViewpoint(){ - - double midX = (x1+x2)/2; - double midY = (y1+y2)/2; - double midZ = (z1+z2)/2; - - double absoluteX = offsetX+midX; - double absoluteY = offsetY+midY; - double absoluteZ = offsetZ+midZ; - - return Math.sqrt(absoluteX*absoluteX + absoluteY*absoluteY + absoluteZ*absoluteZ); + + double midX = (x1 + x2) / 2; + double midY = (y1 + y2) / 2; + double midZ = (z1 + z2) / 2; + + double absoluteX = offsetX + midX; + double absoluteY = offsetY + midY; + double absoluteZ = offsetZ + midZ; + + return Math.sqrt(absoluteX * absoluteX + absoluteY * absoluteY + absoluteZ * absoluteZ); } - + @Override public int compareTo(RayHelper ray){ if(this.getDistanceFromViewpoint() > ray.getDistanceFromViewpoint()){ diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderArc.java b/src/main/java/electroblob/wizardry/client/renderer/RenderArc.java index 6bf600d1..26cf6cb9 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderArc.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderArc.java @@ -19,23 +19,23 @@ public class RenderArc extends Render { public RenderArc(RenderManager renderManager){ super(renderManager); - for(int i=0;i<16;i++){ + for(int i = 0; i < 16; i++){ textures[i] = new ResourceLocation(Wizardry.MODID, "textures/entity/arc_" + i + ".png"); } } @Override - public void doRender(EntityArc arc, double d0, double d1, double d2, - float fa, float fb) { + public void doRender(EntityArc arc, double d0, double d1, double d2, float fa, float fb){ GlStateManager.pushMatrix(); GlStateManager.translate((float)d0, (float)d1, (float)d2); GlStateManager.disableLighting(); GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); //This line fixes the weird brightness bug. + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // This line fixes the weird + // brightness bug. OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); - //System.out.println("Entity coords: " + entity.posX + ", " + entity.posY + ", " + entity.posZ); - //System.out.println("doRender parameters: " + d0 + ", " + d1 + ", " + d2 + ", " + fa + ", " + fb); + // System.out.println("Entity coords: " + entity.posX + ", " + entity.posY + ", " + entity.posZ); + // System.out.println("doRender parameters: " + d0 + ", " + d1 + ", " + d2 + ", " + fa + ", " + fb); Tessellator tessellator = Tessellator.getInstance(); VertexBuffer buffer = tessellator.getBuffer(); @@ -57,62 +57,66 @@ public class RenderArc extends Render { dy = arc.y1 - arc.posY + 0.3; dz = arc.z1 - arc.posZ;// + d0/lengthOffsetRatio; + // The distance from caster to target + double arcLength = Math.sqrt(dz * dz + dx * dx); - //The distance from caster to target - double arcLength = Math.sqrt(dz*dz+dx*dx); + // The ratio between the length of the arc and the offset of the start point from the player's centre (which + // is always 0.3). + // double lengthOffsetRatio = arcLength/0.3; - //The ratio between the length of the arc and the offset of the start point from the player's centre (which is always 0.3). - //double lengthOffsetRatio = arcLength/0.3; + // EntityClientPlayerMP player = Minecraft.getMinecraft().player; - //EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; + // double xViewDist = player.posX - d0; + // double yViewDist = player.posY + player.eyeHeight - d1; + // double zViewDist = player.posZ - d2; - //double xViewDist = player.posX - d0; - //double yViewDist = player.posY + player.eyeHeight - d1; - //double zViewDist = player.posZ - d2; + // double xzViewDist = Math.sqrt(xViewDist * xViewDist + zViewDist * zViewDist); - //double xzViewDist = Math.sqrt(xViewDist * xViewDist + zViewDist * zViewDist); + // The angle above the horizontal that this particular player is viewing the arc from + // double viewAngle = Math.atan(yViewDist/xzViewDist); - //The angle above the horizontal that this particular player is viewing the arc from - //double viewAngle = Math.atan(yViewDist/xzViewDist); - - //Half the width of the arc + // Half the width of the arc double arcWidth = 0.3d; - //Right hand side of vertical plane + // Right hand side of vertical plane buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - //Target end + // Target end buffer.pos(0, -0.5, 0).tex(1, 1).endVertex(); buffer.pos(0, 0.5, 0).tex(1, 0).endVertex(); - //Caster end + // Caster end buffer.pos(dx, dy, dz).tex(0, 0).endVertex(); - buffer.pos(dx, dy-1, dz).tex(0, 1).endVertex(); + buffer.pos(dx, dy - 1, dz).tex(0, 1).endVertex(); tessellator.draw(); - //Left + // Left buffer.begin(GL11.GL_QUADS, net.minecraft.client.renderer.vertex.DefaultVertexFormats.POSITION_TEX); - //Target end + // Target end buffer.pos(0, -0.5, 0).tex(1, 1).endVertex(); - //Caster end - buffer.pos(dx, dy-1, dz).tex(0, 1).endVertex(); + // Caster end + buffer.pos(dx, dy - 1, dz).tex(0, 1).endVertex(); buffer.pos(dx, dy, dz).tex(0, 0).endVertex(); - //Target end + // Target end buffer.pos(0, 0.5, 0).tex(1, 0).endVertex(); tessellator.draw(); - //Bottom of horizontal plane + // Bottom of horizontal plane buffer.begin(GL11.GL_QUADS, net.minecraft.client.renderer.vertex.DefaultVertexFormats.POSITION_TEX); - buffer.pos((arcWidth/arcLength)*dz, 0, (-arcWidth/arcLength)*dx).tex(1, 1).endVertex(); - buffer.pos(dx + (arcWidth/arcLength)*dz, dy-0.5, dz - (arcWidth/arcLength)*dx).tex(0, 1).endVertex(); - buffer.pos(dx - (arcWidth/arcLength)*dz, dy-0.5, dz + (arcWidth/arcLength)*dx).tex(0, 0).endVertex(); - buffer.pos((-arcWidth/arcLength)*dz, 0, (arcWidth/arcLength)*dx).tex(1, 0).endVertex(); + buffer.pos((arcWidth / arcLength) * dz, 0, (-arcWidth / arcLength) * dx).tex(1, 1).endVertex(); + buffer.pos(dx + (arcWidth / arcLength) * dz, dy - 0.5, dz - (arcWidth / arcLength) * dx).tex(0, 1) + .endVertex(); + buffer.pos(dx - (arcWidth / arcLength) * dz, dy - 0.5, dz + (arcWidth / arcLength) * dx).tex(0, 0) + .endVertex(); + buffer.pos((-arcWidth / arcLength) * dz, 0, (arcWidth / arcLength) * dx).tex(1, 0).endVertex(); tessellator.draw(); - //Top + // Top buffer.begin(GL11.GL_QUADS, net.minecraft.client.renderer.vertex.DefaultVertexFormats.POSITION_TEX); - buffer.pos((arcWidth/arcLength)*dz, 0, (-arcWidth/arcLength)*dx).tex(1, 1).endVertex(); - buffer.pos((-arcWidth/arcLength)*dz, 0, (arcWidth/arcLength)*dx).tex(1, 0).endVertex(); - buffer.pos(dx - (arcWidth/arcLength)*dz, dy-0.5, dz + (arcWidth/arcLength)*dx).tex(0, 0).endVertex(); - buffer.pos(dx + (arcWidth/arcLength)*dz, dy-0.5, dz - (arcWidth/arcLength)*dx).tex(0, 1).endVertex(); + buffer.pos((arcWidth / arcLength) * dz, 0, (-arcWidth / arcLength) * dx).tex(1, 1).endVertex(); + buffer.pos((-arcWidth / arcLength) * dz, 0, (arcWidth / arcLength) * dx).tex(1, 0).endVertex(); + buffer.pos(dx - (arcWidth / arcLength) * dz, dy - 0.5, dz + (arcWidth / arcLength) * dx).tex(0, 0) + .endVertex(); + buffer.pos(dx + (arcWidth / arcLength) * dz, dy - 0.5, dz - (arcWidth / arcLength) * dx).tex(0, 1) + .endVertex(); tessellator.draw(); } @@ -122,7 +126,7 @@ public class RenderArc extends Render { } @Override - protected ResourceLocation getEntityTexture(EntityArc entity) { + protected ResourceLocation getEntityTexture(EntityArc entity){ return textures[entity.textureIndex]; } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderArcaneWorkbench.java b/src/main/java/electroblob/wizardry/client/renderer/RenderArcaneWorkbench.java index 12203694..67ac553e 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderArcaneWorkbench.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderArcaneWorkbench.java @@ -18,82 +18,86 @@ import net.minecraft.util.ResourceLocation; public class RenderArcaneWorkbench extends TileEntitySpecialRenderer { - private static final ResourceLocation runeTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/rune.png"); - - public RenderArcaneWorkbench(){} - - @Override - public void renderTileEntityAt(TileEntityArcaneWorkbench tileentity, double x, double y, double z, float partialTicks, int destroyStage) { + private static final ResourceLocation runeTexture = new ResourceLocation(Wizardry.MODID, + "textures/entity/rune.png"); - GlStateManager.pushMatrix(); - // This line makes stuff render in the same place relative to the world wherever the player is. + public RenderArcaneWorkbench(){ + } + + @Override + public void renderTileEntityAt(TileEntityArcaneWorkbench tileentity, double x, double y, double z, + float partialTicks, int destroyStage){ + + GlStateManager.pushMatrix(); + // This line makes stuff render in the same place relative to the world wherever the player is. GlStateManager.translate((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); GlStateManager.rotate(180, 0F, 0F, 1F); - GlStateManager.pushMatrix(); - double angle = 0.0d; - if(x < -0.5){ - angle = Math.toDegrees(Math.atan((z+0.5)/(x+0.5))) + 180; - }else{ - angle = Math.toDegrees(Math.atan((z+0.5)/(x+0.5))); - } + GlStateManager.pushMatrix(); + double angle = 0.0d; + if(x < -0.5){ + angle = Math.toDegrees(Math.atan((z + 0.5) / (x + 0.5))) + 180; + }else{ + angle = Math.toDegrees(Math.atan((z + 0.5) / (x + 0.5))); + } this.renderEffect(tileentity); this.renderWand(tileentity, angle); - GlStateManager.popMatrix(); - GlStateManager.popMatrix(); + GlStateManager.popMatrix(); + GlStateManager.popMatrix(); } - - private void renderEffect(TileEntityArcaneWorkbench tileentity) { - ItemStack itemstack = tileentity.getStackInSlot(ContainerArcaneWorkbench.WAND_SLOT); - - if(itemstack != null){ - GlStateManager.pushMatrix(); - GlStateManager.disableLighting(); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); //This line fixes the weird brightness bug. - GlStateManager.rotate(tileentity.timer, 0.0f, 1.0f, 0.0f); - GlStateManager.translate(0.0f, 0.65f, 0.0f); + private void renderEffect(TileEntityArcaneWorkbench tileentity){ + + ItemStack itemstack = tileentity.getStackInSlot(ContainerArcaneWorkbench.WAND_SLOT); + + if(!itemstack.isEmpty()){ + GlStateManager.pushMatrix(); + GlStateManager.disableLighting(); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // This line fixes the weird + // brightness bug. + GlStateManager.rotate(tileentity.timer, 0.0f, 1.0f, 0.0f); + GlStateManager.translate(0.0f, 0.65f, 0.0f); Tessellator tessellator = Tessellator.getInstance(); VertexBuffer buffer = tessellator.getBuffer(); bindTexture(runeTexture); - + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.pos(-0.5f, 0, -0.5f).tex(0, 0).endVertex(); buffer.pos(0.5f, 0, -0.5f).tex(1, 0).endVertex(); buffer.pos(0.5f, 0, 0.5f).tex(1, 1).endVertex(); buffer.pos(-0.5f, 0, 0.5f).tex(0, 1).endVertex(); tessellator.draw(); - - GlStateManager.disableBlend(); - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - } + + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + } } /** * Renders the wand on the workbench as 3D on the model. Currently doesn't do much on 'fast' graphics! + * * @param tileentity The instance of the workbench tile entity */ - private void renderWand(TileEntityArcaneWorkbench tileentity, double viewAngle) - { - ItemStack stack = tileentity.getStackInSlot(ContainerArcaneWorkbench.WAND_SLOT); - - if(stack != null){ - - GlStateManager.pushMatrix(); - GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F); - GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); - - GlStateManager.rotate(180, 0, 1, 0); - // View angle is negated because of the 180 flip. - GlStateManager.rotate((float)(-viewAngle-90f), 0, 0, 1); - // Does the floaty thing - GlStateManager.translate(0.0F, 0.0F, (float)tileentity.yOffset/5000.0F - 0.55f); - GlStateManager.scale(0.75F, 0.75F, 0.75F); - // This is what the item frame uses so it's definitely what we want. - Minecraft.getMinecraft().getRenderItem().renderItem(stack, TransformType.FIXED); - GlStateManager.popMatrix(); - } - } + private void renderWand(TileEntityArcaneWorkbench tileentity, double viewAngle){ + ItemStack stack = tileentity.getStackInSlot(ContainerArcaneWorkbench.WAND_SLOT); + + if(!stack.isEmpty()){ + + GlStateManager.pushMatrix(); + GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F); + GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); + + GlStateManager.rotate(180, 0, 1, 0); + // View angle is negated because of the 180 flip. + GlStateManager.rotate((float)(-viewAngle - 90f), 0, 0, 1); + // Does the floaty thing + GlStateManager.translate(0.0F, 0.0F, (float)tileentity.yOffset / 5000.0F - 0.55f); + GlStateManager.scale(0.75F, 0.75F, 0.75F); + // This is what the item frame uses so it's definitely what we want. + Minecraft.getMinecraft().getRenderItem().renderItem(stack, TransformType.FIXED); + GlStateManager.popMatrix(); + } + } } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderBlackHole.java b/src/main/java/electroblob/wizardry/client/renderer/RenderBlackHole.java index 67cdd6e8..1ff255e5 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderBlackHole.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderBlackHole.java @@ -20,15 +20,17 @@ import net.minecraft.util.ResourceLocation; public class RenderBlackHole extends Render { - private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, "textures/entity/dark_ray.png"); - private static final ResourceLocation texture2 = new ResourceLocation(Wizardry.MODID, "textures/entity/black_hole.png"); + private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, + "textures/entity/dark_ray.png"); + private static final ResourceLocation texture2 = new ResourceLocation(Wizardry.MODID, + "textures/entity/black_hole.png"); - public RenderBlackHole(RenderManager renderManager) { + public RenderBlackHole(RenderManager renderManager){ super(renderManager); } @Override - public void doRender(EntityBlackHole blackhole, double x, double y, double z, float fa, float fb) { + public void doRender(EntityBlackHole blackhole, double x, double y, double z, float fa, float fb){ GlStateManager.pushMatrix(); @@ -42,8 +44,8 @@ public class RenderBlackHole extends Render { GlStateManager.translate(x, y, z); - //float pitch = (float) Math.toDegrees(Math.atan(y/(x*x+z*z))); - //float yaw = (float) Math.toDegrees(Math.atan(x/z)); + // float pitch = (float) Math.toDegrees(Math.atan(y/(x*x+z*z))); + // float yaw = (float) Math.toDegrees(Math.atan(x/z)); Tessellator tessellator = Tessellator.getInstance(); VertexBuffer buffer = tessellator.getBuffer(); @@ -51,10 +53,13 @@ public class RenderBlackHole extends Render { GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if(blackhole.ticksExisted < 10){ - GlStateManager.scale((float)blackhole.ticksExisted/10, (float)blackhole.ticksExisted/10, (float)blackhole.ticksExisted/10); + GlStateManager.scale((float)blackhole.ticksExisted / 10, (float)blackhole.ticksExisted / 10, + (float)blackhole.ticksExisted / 10); } if(blackhole.ticksExisted > blackhole.lifetime - 10){ - GlStateManager.scale((float)(blackhole.lifetime-blackhole.ticksExisted)/10, (float)(blackhole.lifetime-blackhole.ticksExisted)/10, (float)(blackhole.lifetime-blackhole.ticksExisted)/10); + GlStateManager.scale((float)(blackhole.lifetime - blackhole.ticksExisted) / 10, + (float)(blackhole.lifetime - blackhole.ticksExisted) / 10, + (float)(blackhole.lifetime - blackhole.ticksExisted) / 10); } this.bindTexture(texture); @@ -67,7 +72,7 @@ public class RenderBlackHole extends Render { ArrayList rays = new ArrayList(1); - for(int j=0; j<30; j++){ + for(int j = 0; j < 30; j++){ float scale = 3.0f; @@ -76,33 +81,29 @@ public class RenderBlackHole extends Render { int sliceAngle = 20 + a; - double x1 = scale*Math.sin((blackhole.ticksExisted + 40*j)*(Math.PI/180)); - //double y1 = 0.7*Math.cos((blackhole.timer - 40*j)*(Math.PI/180))*j/10; - double z1 = scale*Math.cos((blackhole.ticksExisted + 40*j)*(Math.PI/180)); + double x1 = scale * Math.sin((blackhole.ticksExisted + 40 * j) * (Math.PI / 180)); + // double y1 = 0.7*Math.cos((blackhole.timer - 40*j)*(Math.PI/180))*j/10; + double z1 = scale * Math.cos((blackhole.ticksExisted + 40 * j) * (Math.PI / 180)); - double x2 = scale*Math.sin((blackhole.ticksExisted + 40*j - sliceAngle)*(Math.PI/180)); - //double y2 = 0.7*Math.sin((blackhole.timer - 40*j)*(Math.PI/180))*j/10; - double z2 = scale*Math.cos((blackhole.ticksExisted + 40*j - sliceAngle)*(Math.PI/180)); + double x2 = scale * Math.sin((blackhole.ticksExisted + 40 * j - sliceAngle) * (Math.PI / 180)); + // double y2 = 0.7*Math.sin((blackhole.timer - 40*j)*(Math.PI/180))*j/10; + double z2 = scale * Math.cos((blackhole.ticksExisted + 40 * j - sliceAngle) * (Math.PI / 180)); - double absoluteX = x1*Math.cos(31*b); - double absoluteY = z1*Math.sin(31*a) + x1*Math.cos(31*a)*Math.sin(31*b); - double absoluteZ = z1*Math.cos(31*a); + double absoluteX = x1 * Math.cos(31 * b); + double absoluteY = z1 * Math.sin(31 * a) + x1 * Math.cos(31 * a) * Math.sin(31 * b); + double absoluteZ = z1 * Math.cos(31 * a); - double absoluteX2 = x2*Math.cos(31*b); - double absoluteY2 = z2*Math.sin(31*a) + x2*Math.cos(31*a)*Math.sin(31*b); - double absoluteZ2 = z2*Math.cos(31*a); - /* - buffer.begin(0, DefaultVertexFormats.POSITION_TEX); - - tessellator.setColorOpaque(255, 255, 255); - GL11.glPointSize(5); - - tessellator.addVertex(absoluteX-x, 0, 0); - tessellator.addVertex(0, absoluteY-y, 0); - tessellator.addVertex(0, 0, absoluteZ-z); - - tessellator.draw(); - */ + double absoluteX2 = x2 * Math.cos(31 * b); + double absoluteY2 = z2 * Math.sin(31 * a) + x2 * Math.cos(31 * a) * Math.sin(31 * b); + double absoluteZ2 = z2 * Math.cos(31 * a); + /* buffer.begin(0, DefaultVertexFormats.POSITION_TEX); + * + * tessellator.setColorOpaque(255, 255, 255); GL11.glPointSize(5); + * + * tessellator.addVertex(absoluteX-x, 0, 0); tessellator.addVertex(0, absoluteY-y, 0); + * tessellator.addVertex(0, 0, absoluteZ-z); + * + * tessellator.draw(); */ rays.add(new RayHelper(j, absoluteX, absoluteY, absoluteZ, absoluteX2, absoluteY2, absoluteZ2, x, y, z)); } @@ -112,16 +113,16 @@ public class RenderBlackHole extends Render { for(RayHelper ray : rays){ GlStateManager.pushMatrix(); - //GlStateManager.rotate(31*blackhole.randomiser[ray.ordinal], 1, 0, 0); - //GlStateManager.rotate(31*blackhole.randomiser2[ray.ordinal], 0, 0, 1); + // GlStateManager.rotate(31*blackhole.randomiser[ray.ordinal], 1, 0, 0); + // GlStateManager.rotate(31*blackhole.randomiser2[ray.ordinal], 0, 0, 1); buffer.begin(5, DefaultVertexFormats.POSITION_TEX); - //tessellator.setColorRGBA(255, 255, 255, 0); + // tessellator.setColorRGBA(255, 255, 255, 0); buffer.pos(0, 0, 0).tex(0, 0).endVertex(); buffer.pos(0, 0, 0).tex(0, 1).endVertex(); - //tessellator.setColorRGBA(0, 0, 0, 255); + // tessellator.setColorRGBA(0, 0, 0, 255); buffer.pos(ray.x1, ray.y1, ray.z1).tex(1, 0).endVertex(); buffer.pos(ray.x2, ray.y2, ray.z2).tex(1, 1).endVertex(); @@ -132,20 +133,15 @@ public class RenderBlackHole extends Render { GlStateManager.pushMatrix(); - /* Deprecated in favour of particle style method. - GlStateManager.rotate(yaw, 0, 1, 0); - // GL transformations are relative, hence only x rotation - if(z < 0){ - GlStateManager.rotate(pitch, 1, 0, 0); - }else{ - GlStateManager.rotate(-1*pitch, 1, 0, 0); - } - */ + /* Deprecated in favour of particle style method. GlStateManager.rotate(yaw, 0, 1, 0); // GL transformations are + * relative, hence only x rotation if(z < 0){ GlStateManager.rotate(pitch, 1, 0, 0); }else{ + * GlStateManager.rotate(-1*pitch, 1, 0, 0); } */ // Renders the aura effect // This counteracts the reverse rotation behaviour when in front f5 view. Vanilla now has this fix too. - float yaw = Minecraft.getMinecraft().gameSettings.thirdPersonView == 2 ? this.renderManager.playerViewX : -this.renderManager.playerViewX; + float yaw = Minecraft.getMinecraft().gameSettings.thirdPersonView == 2 ? this.renderManager.playerViewX + : -this.renderManager.playerViewX; GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(yaw, 1.0F, 0.0F, 0.0F); @@ -162,7 +158,6 @@ public class RenderBlackHole extends Render { GlStateManager.popMatrix(); - GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.enableCull(); GlStateManager.disableBlend(); @@ -173,7 +168,7 @@ public class RenderBlackHole extends Render { } @Override - protected ResourceLocation getEntityTexture(EntityBlackHole entity) { + protected ResourceLocation getEntityTexture(EntityBlackHole entity){ return texture; } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderBlank.java b/src/main/java/electroblob/wizardry/client/renderer/RenderBlank.java index 01926ccc..477b6092 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderBlank.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderBlank.java @@ -7,18 +7,17 @@ import net.minecraft.util.ResourceLocation; public class RenderBlank extends Render { - public RenderBlank(RenderManager renderManager) { + public RenderBlank(RenderManager renderManager){ super(renderManager); } @Override - public void doRender(Entity entity, double d0, double d1, double d2, - float f, float f1) { + public void doRender(Entity entity, double d0, double d1, double d2, float f, float f1){ } @Override - protected ResourceLocation getEntityTexture(Entity entity) { + protected ResourceLocation getEntityTexture(Entity entity){ return null; } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderBubble.java b/src/main/java/electroblob/wizardry/client/renderer/RenderBubble.java index d96a1020..107c4ecf 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderBubble.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderBubble.java @@ -18,9 +18,10 @@ import net.minecraft.util.ResourceLocation; public class RenderBubble extends Render { private static final ResourceLocation particleTextures = new ResourceLocation("textures/particle/particles.png"); - private static final ResourceLocation darkOrbTexture = new ResourceLocation(Wizardry.MODID, "textures/entity/dark_orb.png"); + private static final ResourceLocation darkOrbTexture = new ResourceLocation(Wizardry.MODID, + "textures/entity/dark_orb.png"); - public RenderBubble(RenderManager renderManager) { + public RenderBubble(RenderManager renderManager){ super(renderManager); } @@ -34,7 +35,7 @@ public class RenderBubble extends Render { float yOffset = 0; if(WizardryUtilities.getRider(entity) != null){ - yOffset = WizardryUtilities.getRider(entity).height/2; + yOffset = WizardryUtilities.getRider(entity).height / 2; } GlStateManager.translate((float)par2, (float)par4 + yOffset, (float)par6); @@ -58,20 +59,21 @@ public class RenderBubble extends Render { // This counteracts the reverse rotation behaviour when in front f5 view. // Fun fact: this is a bug with vanilla too! Look at a snowball in front f5 view, for example. - float yaw = Minecraft.getMinecraft().gameSettings.thirdPersonView == 2 ? this.renderManager.playerViewX : -this.renderManager.playerViewX; + float yaw = Minecraft.getMinecraft().gameSettings.thirdPersonView == 2 ? this.renderManager.playerViewX + : -this.renderManager.playerViewX; GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(yaw, 1.0F, 0.0F, 0.0F); float f11 = 3.0F; GlStateManager.scale(f11, f11, f11); - double pixelwidth = (1.0d/128); + double pixelwidth = (1.0d / 128); Tessellator tessellator = Tessellator.getInstance(); VertexBuffer buffer = tessellator.getBuffer(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - //tessellator.setColorRGBA_I(k1, 128); - //buffer.normal(0.0F, 1.0F, 0.0F); + // tessellator.setColorRGBA_I(k1, 128); + // buffer.normal(0.0F, 1.0F, 0.0F); if(((EntityBubble)entity).isDarkOrb){ buffer.pos((double)(0.0F - f7), (double)(0.0F - f8), 0.0D).tex(0, 1).endVertex(); @@ -80,8 +82,8 @@ public class RenderBubble extends Render { buffer.pos((double)(0.0F - f7), (double)(1.0F - f8), 0.0D).tex(0, 0).endVertex(); }else{ buffer.pos((double)(0.0F - f7), (double)(0.0F - f8), 0.0D).tex(pixelwidth, pixelwidth * 24).endVertex(); - buffer.pos((double)(f6 - f7), (double)(0.0F - f8), 0.0D).tex(pixelwidth*8, pixelwidth * 24).endVertex(); - buffer.pos((double)(f6 - f7), (double)(1.0F - f8), 0.0D).tex(pixelwidth*8, pixelwidth * 17).endVertex(); + buffer.pos((double)(f6 - f7), (double)(0.0F - f8), 0.0D).tex(pixelwidth * 8, pixelwidth * 24).endVertex(); + buffer.pos((double)(f6 - f7), (double)(1.0F - f8), 0.0D).tex(pixelwidth * 8, pixelwidth * 17).endVertex(); buffer.pos((double)(0.0F - f7), (double)(1.0F - f8), 0.0D).tex(pixelwidth, pixelwidth * 17).endVertex(); } @@ -97,7 +99,7 @@ public class RenderBubble extends Render { } @Override - protected ResourceLocation getEntityTexture(EntityBubble entity) { + protected ResourceLocation getEntityTexture(EntityBubble entity){ return null; } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderDecay.java b/src/main/java/electroblob/wizardry/client/renderer/RenderDecay.java index f849f967..f206b8f1 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderDecay.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderDecay.java @@ -16,58 +16,58 @@ import net.minecraft.util.ResourceLocation; public class RenderDecay extends Render { private static final ResourceLocation[] textures = new ResourceLocation[10]; - + public RenderDecay(RenderManager renderManager){ super(renderManager); - for(int i=0;i<10;i++){ + for(int i = 0; i < 10; i++){ textures[i] = new ResourceLocation(Wizardry.MODID, "textures/entity/decay_" + i + ".png"); } } @Override - public void doRender(EntityDecay entity, double par2, double par4, double par6, float par8, float par9){ - - GlStateManager.pushMatrix(); - GlStateManager.enableBlend(); - GlStateManager.disableLighting(); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - float yOffset = 0; - - GlStateManager.translate((float)par2, (float)par4 + yOffset, (float)par6); - - this.bindTexture(textures[((EntityDecay)entity).textureIndex]); - float f6 = 1.0F; - float f7 = 0.5F; - float f8 = 0.5F; - - GlStateManager.rotate(-90, 1, 0, 0); - - float scale = 2*Math.min(1, (float)(EntityDecay.LIFETIME - entity.ticksExisted)/50f); - - GlStateManager.scale(scale, scale, scale); - - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buffer = tessellator.getBuffer(); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - //tessellator.setColorRGBA_I(k1, 128); - //buffer.normal(0.0F, 1.0F, 0.0F); - buffer.pos((double)(0.0F - f7), (double)(0.0F - f8), 0.01).tex(0, 1).endVertex(); - buffer.pos((double)(f6 - f7), (double)(0.0F - f8), 0.01).tex(1, 1).endVertex(); - buffer.pos((double)(f6 - f7), (double)(1.0F - f8), 0.01).tex(1, 0).endVertex(); - buffer.pos((double)(0.0F - f7), (double)(1.0F - f8), 0.01).tex(0, 0).endVertex(); - - tessellator.draw(); - - GlStateManager.disableBlend(); - GlStateManager.enableLighting(); - GlStateManager.disableRescaleNormal(); - GlStateManager.popMatrix(); - } + public void doRender(EntityDecay entity, double par2, double par4, double par6, float par8, float par9){ + + GlStateManager.pushMatrix(); + GlStateManager.enableBlend(); + GlStateManager.disableLighting(); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + float yOffset = 0; + + GlStateManager.translate((float)par2, (float)par4 + yOffset, (float)par6); + + this.bindTexture(textures[((EntityDecay)entity).textureIndex]); + float f6 = 1.0F; + float f7 = 0.5F; + float f8 = 0.5F; + + GlStateManager.rotate(-90, 1, 0, 0); + + float scale = 2 * Math.min(1, (float)(EntityDecay.LIFETIME - entity.ticksExisted) / 50f); + + GlStateManager.scale(scale, scale, scale); + + Tessellator tessellator = Tessellator.getInstance(); + VertexBuffer buffer = tessellator.getBuffer(); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + // tessellator.setColorRGBA_I(k1, 128); + // buffer.normal(0.0F, 1.0F, 0.0F); + buffer.pos((double)(0.0F - f7), (double)(0.0F - f8), 0.01).tex(0, 1).endVertex(); + buffer.pos((double)(f6 - f7), (double)(0.0F - f8), 0.01).tex(1, 1).endVertex(); + buffer.pos((double)(f6 - f7), (double)(1.0F - f8), 0.01).tex(1, 0).endVertex(); + buffer.pos((double)(0.0F - f7), (double)(1.0F - f8), 0.01).tex(0, 0).endVertex(); + + tessellator.draw(); + + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + GlStateManager.disableRescaleNormal(); + GlStateManager.popMatrix(); + } @Override - protected ResourceLocation getEntityTexture(EntityDecay entity) { + protected ResourceLocation getEntityTexture(EntityDecay entity){ return null; } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderDecoy.java b/src/main/java/electroblob/wizardry/client/renderer/RenderDecoy.java index 8e373b04..4c421adc 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderDecoy.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderDecoy.java @@ -15,26 +15,25 @@ import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -// TODO: Backport the rewrite of this entire class. @SideOnly(Side.CLIENT) public class RenderDecoy extends RenderBiped { - + private static final ResourceLocation steveTextures = new ResourceLocation("textures/entity/steve.png"); - - private static final Method getEntityTexture = ReflectionHelper.findMethod(Render.class, null, - new String[]{"getEntityTexture", "func_110775_a"}, Entity.class); // Generic parameter T is erased to Entity at runtime. - + + private static final Method getEntityTexture = ReflectionHelper.findMethod(Render.class, "getEntityTexture", + "func_110775_a", Entity.class); // Generic parameter T is erased to Entity at runtime. + public RenderDecoy(RenderManager manager){ super(manager, new ModelBiped(0.0f), 0.5f); } - + @Override - public void doRender(EntityDecoy entity, double x, double y, double z, float entityYaw, float partialTicks) { - + public void doRender(EntityDecoy entity, double x, double y, double z, float entityYaw, float partialTicks){ + if(entity.getCaster() != null){ - + this.renderName(entity, x, y, z); - + // Save relevant animation fields from the caster to local variables float pitch = entity.getCaster().rotationPitch; float prevPitch = entity.getCaster().prevRotationPitch; @@ -50,7 +49,7 @@ public class RenderDecoy extends RenderBiped { int hurtTime = entity.getCaster().hurtTime; boolean sneak = entity.getCaster().isSneaking(); Entity mount = entity.getCaster().getRidingEntity(); - + // Assign decoy's animation fields to the caster entity.getCaster().rotationPitch = entity.rotationPitch; entity.getCaster().prevRotationPitch = entity.prevRotationPitch; @@ -66,10 +65,11 @@ public class RenderDecoy extends RenderBiped { entity.getCaster().hurtTime = entity.hurtTime; entity.getCaster().setSneaking(false); // Decoys can't sneak FIXME Not working! entity.getCaster().dismountRidingEntity(); // Decoys can't ride anything - + // Do the rendering - renderManager.getEntityRenderObject(entity.getCaster()).doRender(entity.getCaster(), x, y, z, entityYaw, partialTicks); - + renderManager.getEntityRenderObject(entity.getCaster()).doRender(entity.getCaster(), x, y, z, entityYaw, + partialTicks); + // Reset caster's animation fields to their original values entity.getCaster().rotationPitch = pitch; entity.getCaster().prevRotationPitch = prevPitch; @@ -85,19 +85,22 @@ public class RenderDecoy extends RenderBiped { entity.getCaster().hurtTime = hurtTime; entity.getCaster().setSneaking(sneak); if(mount != null) entity.getCaster().startRiding(mount); - + }else{ super.doRender(entity, x, y, z, entityYaw, partialTicks); } } - + @Override protected ResourceLocation getEntityTexture(EntityDecoy entity){ if(entity.getCaster() != null){ - try { - return (ResourceLocation)getEntityTexture.invoke(renderManager.getEntityRenderObject(entity.getCaster())); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | ClassCastException e){ - Wizardry.logger.error("Error while reflectively calling Render#getEntityTexture as part of decoy rendering"); + try{ + return (ResourceLocation)getEntityTexture + .invoke(renderManager.getEntityRenderObject(entity.getCaster())); + }catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException + | ClassCastException e){ + Wizardry.logger + .error("Error while reflectively calling Render#getEntityTexture as part of decoy rendering"); e.printStackTrace(); } } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderEvilWizard.java b/src/main/java/electroblob/wizardry/client/renderer/RenderEvilWizard.java index d61329f4..2828261f 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderEvilWizard.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderEvilWizard.java @@ -11,24 +11,23 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class RenderEvilWizard extends RenderBiped -{ - static final ResourceLocation[] textures = new ResourceLocation[6]; +public class RenderEvilWizard extends RenderBiped { + static final ResourceLocation[] textures = new ResourceLocation[6]; - public RenderEvilWizard(RenderManager renderManager){ - - super(renderManager, new ModelWizard(), 0.5F); - - for(int i=0;i<6;i++){ + public RenderEvilWizard(RenderManager renderManager){ + + super(renderManager, new ModelWizard(), 0.5F); + + for(int i = 0; i < 6; i++){ textures[i] = new ResourceLocation(Wizardry.MODID, "textures/entity/evil_wizard_" + i + ".png"); } - // Just using the default without overriding models, since the armour sets its own model anyway. - this.addLayer(new LayerBipedArmor(this)); - } - - @Override - protected ResourceLocation getEntityTexture(EntityEvilWizard wizard) { - return textures[wizard.textureIndex]; - } + // Just using the default without overriding models, since the armour sets its own model anyway. + this.addLayer(new LayerBipedArmor(this)); + } + + @Override + protected ResourceLocation getEntityTexture(EntityEvilWizard wizard){ + return textures[wizard.textureIndex]; + } } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderFireRing.java b/src/main/java/electroblob/wizardry/client/renderer/RenderFireRing.java index 1f70169f..db194bd6 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderFireRing.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderFireRing.java @@ -17,163 +17,170 @@ import net.minecraft.init.Blocks; import net.minecraft.util.ResourceLocation; public class RenderFireRing extends Render { - - private final ResourceLocation texture; - private float scale = 1.0f; - - public RenderFireRing(RenderManager renderManager, ResourceLocation texture, float scale) { + + private final ResourceLocation texture; + private float scale = 1.0f; + + public RenderFireRing(RenderManager renderManager, ResourceLocation texture, float scale){ super(renderManager); this.texture = texture; this.scale = scale; } @Override - public void doRender(EntityFireRing entity, double par2, double par4, double par6, float par8, float par9){ - - GlStateManager.pushMatrix(); - GlStateManager.enableBlend(); - GlStateManager.disableLighting(); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - float yOffset = 0; - - GlStateManager.translate((float)par2, (float)par4 + yOffset, (float)par6); - - this.bindTexture(texture); - float f6 = 1.0F; - float f7 = 0.5F; - float f8 = 0.5F; - - GlStateManager.rotate(-90, 1, 0, 0); - - GlStateManager.scale(scale, scale, scale); - - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buffer = tessellator.getBuffer(); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - buffer.pos((double)(0.0F - f7), (double)(0.0F - f8), 0.01).tex(0, 1).endVertex(); - buffer.pos((double)(f6 - f7), (double)(0.0F - f8), 0.01).tex(1, 1).endVertex(); - buffer.pos((double)(f6 - f7), (double)(1.0F - f8), 0.01).tex(1, 0).endVertex(); - buffer.pos((double)(0.0F - f7), (double)(1.0F - f8), 0.01).tex(0, 0).endVertex(); - - tessellator.draw(); - - GlStateManager.disableBlend(); - GlStateManager.enableLighting(); - GlStateManager.disableRescaleNormal(); - GlStateManager.popMatrix(); - - // Fire - - GlStateManager.disableLighting(); - TextureAtlasSprite icon = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(Blocks.FIRE.getDefaultState()).getParticleTexture(); - int sides = 16; - float height = 1.0f; - - for(int k=0; k 0.0F){ - - this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - float f71 = icon.getMinU(); - float f81 = icon.getMinV(); - float f9 = icon.getMaxU(); - float f10 = icon.getMaxV(); - - if (i / 2 % 2 == 0) - { - float f11 = f9; - f9 = f71; - f71 = f11; - } - - buffer.pos((double)(f2 - f3), (double)(0.0F - f5), (double)f61).tex((double)f9, (double)f10).endVertex(); - buffer.pos((double)(-f2 - f3), (double)(0.0F - f5), (double)f61).tex((double)f71, (double)f10).endVertex(); - buffer.pos((double)(-f2 - f3), (double)(height - f5), (double)f61).tex((double)f71, (double)f81).endVertex(); - buffer.pos((double)(f2 - f3), (double)(height - f5), (double)f61).tex((double)f9, (double)f81).endVertex(); - f4 -= 0.45F; - f5 -= 0.45F; - f2 *= 0.9F; - f61 += 0.03F; - ++i; - } - - tessellator.draw(); - GlStateManager.popMatrix(); - } + public void doRender(EntityFireRing entity, double par2, double par4, double par6, float par8, float par9){ - for(int k=0; k 0.0F){ - - this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - float f71 = icon.getMinU(); - float f81 = icon.getMinV(); - float f9 = icon.getMaxU(); - float f10 = icon.getMaxV(); - - if (i / 2 % 2 == 0) - { - float f11 = f9; - f9 = f71; - f71 = f11; - } - - buffer.pos((double)(f2 - f3), (double)(0.0F - f5), (double)f61).tex((double)f9, (double)f10).endVertex(); - buffer.pos((double)(-f2 - f3), (double)(0.0F - f5), (double)f61).tex((double)f71, (double)f10).endVertex(); - buffer.pos((double)(-f2 - f3), (double)(height - f5), (double)f61).tex((double)f71, (double)f81).endVertex(); - buffer.pos((double)(f2 - f3), (double)(height - f5), (double)f61).tex((double)f9, (double)f81).endVertex(); - f4 -= 0.45F; - f5 -= 0.45F; - f2 *= 0.9F; - f61 += 0.03F; - ++i; - } - - tessellator.draw(); - GlStateManager.popMatrix(); - } - - GlStateManager.enableLighting(); - } + GlStateManager.pushMatrix(); + GlStateManager.enableBlend(); + GlStateManager.disableLighting(); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + float yOffset = 0; + + GlStateManager.translate((float)par2, (float)par4 + yOffset, (float)par6); + + this.bindTexture(texture); + float f6 = 1.0F; + float f7 = 0.5F; + float f8 = 0.5F; + + GlStateManager.rotate(-90, 1, 0, 0); + + GlStateManager.scale(scale, scale, scale); + + Tessellator tessellator = Tessellator.getInstance(); + VertexBuffer buffer = tessellator.getBuffer(); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + buffer.pos((double)(0.0F - f7), (double)(0.0F - f8), 0.01).tex(0, 1).endVertex(); + buffer.pos((double)(f6 - f7), (double)(0.0F - f8), 0.01).tex(1, 1).endVertex(); + buffer.pos((double)(f6 - f7), (double)(1.0F - f8), 0.01).tex(1, 0).endVertex(); + buffer.pos((double)(0.0F - f7), (double)(1.0F - f8), 0.01).tex(0, 0).endVertex(); + + tessellator.draw(); + + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + GlStateManager.disableRescaleNormal(); + GlStateManager.popMatrix(); + + // Fire + + GlStateManager.disableLighting(); + TextureAtlasSprite icon = Minecraft.getMinecraft().getBlockRendererDispatcher() + .getModelForState(Blocks.FIRE.getDefaultState()).getParticleTexture(); + int sides = 16; + float height = 1.0f; + + for(int k = 0; k < sides; k++){ + + GlStateManager.pushMatrix(); + GlStateManager.translate((float)par2, (float)par4 + 0.05f, (float)par6); + float f1 = 1.0f; + GlStateManager.scale(f1, f1, f1); + float f2 = 0.5F; + float f3 = 0.0F; + float f4 = 0.2f; + float f5 = (float)(entity.posY - entity.getEntityBoundingBox().minY); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + float f61 = 0.0F; + int i = 0; + + GlStateManager.rotate((360f / (float)sides) * k, 0, 1, 0); + GlStateManager.translate(0, 0, -2.3f); + + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + + while(f4 > 0.0F){ + + this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + float f71 = icon.getMinU(); + float f81 = icon.getMinV(); + float f9 = icon.getMaxU(); + float f10 = icon.getMaxV(); + + if(i / 2 % 2 == 0){ + float f11 = f9; + f9 = f71; + f71 = f11; + } + + buffer.pos((double)(f2 - f3), (double)(0.0F - f5), (double)f61).tex((double)f9, (double)f10) + .endVertex(); + buffer.pos((double)(-f2 - f3), (double)(0.0F - f5), (double)f61).tex((double)f71, (double)f10) + .endVertex(); + buffer.pos((double)(-f2 - f3), (double)(height - f5), (double)f61).tex((double)f71, (double)f81) + .endVertex(); + buffer.pos((double)(f2 - f3), (double)(height - f5), (double)f61).tex((double)f9, (double)f81) + .endVertex(); + f4 -= 0.45F; + f5 -= 0.45F; + f2 *= 0.9F; + f61 += 0.03F; + ++i; + } + + tessellator.draw(); + GlStateManager.popMatrix(); + } + + for(int k = 0; k < sides; k++){ + + GlStateManager.pushMatrix(); + GlStateManager.translate((float)par2, (float)par4 + 0.05f, (float)par6); + float f1 = 1.0f; + GlStateManager.scale(f1, f1, f1); + float f2 = 0.5F; + float f3 = 0.0F; + float f4 = 0.2f; + float f5 = (float)(entity.posY - entity.getEntityBoundingBox().minY); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + float f61 = 0.0F; + int i = 0; + + GlStateManager.rotate((360f / (float)sides) * k, 0, 1, 0); + GlStateManager.translate(0, 0, 2.3f); + + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + + while(f4 > 0.0F){ + + this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + float f71 = icon.getMinU(); + float f81 = icon.getMinV(); + float f9 = icon.getMaxU(); + float f10 = icon.getMaxV(); + + if(i / 2 % 2 == 0){ + float f11 = f9; + f9 = f71; + f71 = f11; + } + + buffer.pos((double)(f2 - f3), (double)(0.0F - f5), (double)f61).tex((double)f9, (double)f10) + .endVertex(); + buffer.pos((double)(-f2 - f3), (double)(0.0F - f5), (double)f61).tex((double)f71, (double)f10) + .endVertex(); + buffer.pos((double)(-f2 - f3), (double)(height - f5), (double)f61).tex((double)f71, (double)f81) + .endVertex(); + buffer.pos((double)(f2 - f3), (double)(height - f5), (double)f61).tex((double)f9, (double)f81) + .endVertex(); + f4 -= 0.45F; + f5 -= 0.45F; + f2 *= 0.9F; + f61 += 0.03F; + ++i; + } + + tessellator.draw(); + GlStateManager.popMatrix(); + } + + GlStateManager.enableLighting(); + } @Override - protected ResourceLocation getEntityTexture(EntityFireRing entity) { + protected ResourceLocation getEntityTexture(EntityFireRing entity){ return null; } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderForceArrow.java b/src/main/java/electroblob/wizardry/client/renderer/RenderForceArrow.java index db37b23d..2be1669a 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderForceArrow.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderForceArrow.java @@ -17,111 +17,111 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class RenderForceArrow extends Render{ +public class RenderForceArrow extends Render { - private static final ResourceLocation arrowTextures = new ResourceLocation(Wizardry.MODID, "textures/entity/force_arrow.png"); + private static final ResourceLocation arrowTextures = new ResourceLocation(Wizardry.MODID, + "textures/entity/force_arrow.png"); - public RenderForceArrow(RenderManager renderManager){ + public RenderForceArrow(RenderManager renderManager){ super(renderManager); - } - - @Override - public void doRender(EntityForceArrow arrow, double par2, double par4, double par6, float par8, float par9){ - - this.bindEntityTexture(arrow); - GlStateManager.pushMatrix(); - GlStateManager.disableLighting(); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); - - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - GlStateManager.translate((float)par2, (float)par4, (float)par6); - GlStateManager.rotate(arrow.prevRotationYaw + (arrow.rotationYaw - arrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F); - GlStateManager.rotate(arrow.prevRotationPitch + (arrow.rotationPitch - arrow.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F); - GlStateManager.rotate(180, 0, 1, 0); - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buffer = tessellator.getBuffer(); - float pixel = 1.0f/32.0f; - float u1 = 0.0f; - float u2 = pixel*14; - float v1 = 0.0f; - float v2 = pixel*7; - float u3 = pixel*16; - float u4 = 1.0f; - float v3 = 0.0f; - float v4 = pixel*16; - float u5 = 0.0f; - float u6 = pixel*7; - float v5 = pixel*25; - float v6 = 1.0f; - float scale = 0.05625F; - float f11 = 0.0f; - GlStateManager.enableRescaleNormal(); - //f11 = (float)par1EntityArrow.arrowShake - par9; - if (f11 > 0.0F) - { - float f12 = -MathHelper.sin(f11 * 3.0F) * f11; - GlStateManager.rotate(f12, 0.0F, 0.0F, 1.0F); - } - - scale*=0.8f; + } - GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F); - GlStateManager.scale(scale, scale, scale); - GlStateManager.translate(-4.0F, 0.0F, 0.0F); + @Override + public void doRender(EntityForceArrow arrow, double par2, double par4, double par6, float par8, float par9){ - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - buffer.pos(-5, 3.5, -3.5).tex((double)u5, (double)v5).endVertex(); - buffer.pos(-5, 3.5, 3.5).tex((double)u6, (double)v5).endVertex(); - buffer.pos(-5, -3.5, 3.5).tex((double)u6, (double)v6).endVertex(); - buffer.pos(-5, -3.5, -3.5).tex((double)u5, (double)v6); - tessellator.draw(); - - for(int i=0; i<5; i++){ - GlStateManager.color(1, 1, 1, 1 - i*0.2f); - double j = i + ((double)arrow.ticksExisted%3)/3; - double width = 2.0d + (Math.sqrt(j*2)-0.6)*2; - GL11.glNormal3f(scale, 0.0F, 0.0F); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - buffer.pos(-10 + j*4, -width, -width).tex((double)u3, (double)v3).endVertex(); - buffer.pos(-10 + j*4, -width, width).tex((double)u4, (double)v3).endVertex(); - buffer.pos(-10 + j*4, width, width).tex((double)u4, (double)v4).endVertex(); - buffer.pos(-10 + j*4, width, -width).tex((double)u3, (double)v4).endVertex(); - tessellator.draw(); - GL11.glNormal3f(-scale, 0.0F, 0.0F); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - buffer.pos(-10 + j*4, width, -width).tex((double)u3, (double)v3).endVertex(); - buffer.pos(-10 + j*4, width, width).tex((double)u4, (double)v3).endVertex(); - buffer.pos(-10 + j*4, -width, width).tex((double)u4, (double)v4).endVertex(); - buffer.pos(-10 + j*4, -width, -width).tex((double)u3, (double)v4).endVertex(); - tessellator.draw(); - } + this.bindEntityTexture(arrow); + GlStateManager.pushMatrix(); + GlStateManager.disableLighting(); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); - GlStateManager.color(1, 1, 1, 1); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - for (int i = 0; i < 4; ++i) - { - GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); - GL11.glNormal3f(0.0F, 0.0F, scale); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - buffer.pos(-10.0D, -4.0D, 0.0D).tex((double)u1, (double)v1).endVertex(); - buffer.pos(10.0D, -4.0D, 0.0D).tex((double)u2, (double)v1).endVertex(); - buffer.pos(10.0D, 4.0D, 0.0D).tex((double)u2, (double)v2).endVertex(); - buffer.pos(-10.0D, 4.0D, 0.0D).tex((double)u1, (double)v2).endVertex(); - tessellator.draw(); - } + GlStateManager.translate((float)par2, (float)par4, (float)par6); + GlStateManager.rotate(arrow.prevRotationYaw + (arrow.rotationYaw - arrow.prevRotationYaw) * par9 - 90.0F, 0.0F, + 1.0F, 0.0F); + GlStateManager.rotate(arrow.prevRotationPitch + (arrow.rotationPitch - arrow.prevRotationPitch) * par9, 0.0F, + 0.0F, 1.0F); + GlStateManager.rotate(180, 0, 1, 0); + Tessellator tessellator = Tessellator.getInstance(); + VertexBuffer buffer = tessellator.getBuffer(); + float pixel = 1.0f / 32.0f; + float u1 = 0.0f; + float u2 = pixel * 14; + float v1 = 0.0f; + float v2 = pixel * 7; + float u3 = pixel * 16; + float u4 = 1.0f; + float v3 = 0.0f; + float v4 = pixel * 16; + float u5 = 0.0f; + float u6 = pixel * 7; + float v5 = pixel * 25; + float v6 = 1.0f; + float scale = 0.05625F; + float f11 = 0.0f; + GlStateManager.enableRescaleNormal(); + // f11 = (float)par1EntityArrow.arrowShake - par9; + if(f11 > 0.0F){ + float f12 = -MathHelper.sin(f11 * 3.0F) * f11; + GlStateManager.rotate(f12, 0.0F, 0.0F, 1.0F); + } - GlStateManager.disableBlend(); - - GlStateManager.disableRescaleNormal(); - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - } + scale *= 0.8f; - @Override - protected ResourceLocation getEntityTexture(EntityForceArrow par1Entity) - { - return arrowTextures; - } + GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F); + GlStateManager.scale(scale, scale, scale); + GlStateManager.translate(-4.0F, 0.0F, 0.0F); + + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + buffer.pos(-5, 3.5, -3.5).tex((double)u5, (double)v5).endVertex(); + buffer.pos(-5, 3.5, 3.5).tex((double)u6, (double)v5).endVertex(); + buffer.pos(-5, -3.5, 3.5).tex((double)u6, (double)v6).endVertex(); + buffer.pos(-5, -3.5, -3.5).tex((double)u5, (double)v6); + tessellator.draw(); + + for(int i = 0; i < 5; i++){ + GlStateManager.color(1, 1, 1, 1 - i * 0.2f); + double j = i + ((double)arrow.ticksExisted % 3) / 3; + double width = 2.0d + (Math.sqrt(j * 2) - 0.6) * 2; + GL11.glNormal3f(scale, 0.0F, 0.0F); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + buffer.pos(-10 + j * 4, -width, -width).tex((double)u3, (double)v3).endVertex(); + buffer.pos(-10 + j * 4, -width, width).tex((double)u4, (double)v3).endVertex(); + buffer.pos(-10 + j * 4, width, width).tex((double)u4, (double)v4).endVertex(); + buffer.pos(-10 + j * 4, width, -width).tex((double)u3, (double)v4).endVertex(); + tessellator.draw(); + GL11.glNormal3f(-scale, 0.0F, 0.0F); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + buffer.pos(-10 + j * 4, width, -width).tex((double)u3, (double)v3).endVertex(); + buffer.pos(-10 + j * 4, width, width).tex((double)u4, (double)v3).endVertex(); + buffer.pos(-10 + j * 4, -width, width).tex((double)u4, (double)v4).endVertex(); + buffer.pos(-10 + j * 4, -width, -width).tex((double)u3, (double)v4).endVertex(); + tessellator.draw(); + } + + GlStateManager.color(1, 1, 1, 1); + + for(int i = 0; i < 4; ++i){ + GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); + GL11.glNormal3f(0.0F, 0.0F, scale); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + buffer.pos(-10.0D, -4.0D, 0.0D).tex((double)u1, (double)v1).endVertex(); + buffer.pos(10.0D, -4.0D, 0.0D).tex((double)u2, (double)v1).endVertex(); + buffer.pos(10.0D, 4.0D, 0.0D).tex((double)u2, (double)v2).endVertex(); + buffer.pos(-10.0D, 4.0D, 0.0D).tex((double)u1, (double)v2).endVertex(); + tessellator.draw(); + } + + GlStateManager.disableBlend(); + + GlStateManager.disableRescaleNormal(); + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + } + + @Override + protected ResourceLocation getEntityTexture(EntityForceArrow par1Entity){ + return arrowTextures; + } } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderHammer.java b/src/main/java/electroblob/wizardry/client/renderer/RenderHammer.java index b93fe9d2..8f448603 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderHammer.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderHammer.java @@ -9,30 +9,31 @@ import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.util.ResourceLocation; public class RenderHammer extends Render { - - private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, "textures/entity/lightning_hammer.png"); + + private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, + "textures/entity/lightning_hammer.png"); private ModelHammer model = new ModelHammer(); - + public RenderHammer(RenderManager renderManager){ super(renderManager); } @Override - public void doRender(EntityHammer entity, double x, double y, double z, float f, float f1) { - + public void doRender(EntityHammer entity, double x, double y, double z, float f, float f1){ + GlStateManager.pushMatrix(); - GlStateManager.translate(x, y+1.5, z); + GlStateManager.translate(x, y + 1.5, z); GlStateManager.rotate(180, 0F, 0F, 1F); - + this.bindTexture(texture); - + model.render(entity, 0, 0, 0, 0, 0, 0.0625f); - + GlStateManager.popMatrix(); } @Override - protected ResourceLocation getEntityTexture(EntityHammer entity) { + protected ResourceLocation getEntityTexture(EntityHammer entity){ return texture; } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderIceGiant.java b/src/main/java/electroblob/wizardry/client/renderer/RenderIceGiant.java index 4ee0812e..b78c6888 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderIceGiant.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderIceGiant.java @@ -12,28 +12,29 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderIceGiant extends RenderLiving { - - private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, "textures/entity/ice_giant.png"); - public RenderIceGiant(RenderManager renderManager){ - super(renderManager, new ModelIceGiant(), 0.5F); - } + private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, + "textures/entity/ice_giant.png"); + + public RenderIceGiant(RenderManager renderManager){ + super(renderManager, new ModelIceGiant(), 0.5F); + } @Override protected ResourceLocation getEntityTexture(EntityIceGiant entity){ return texture; } - - @Override - protected void rotateCorpse(EntityIceGiant entityLiving, float pitch, float yaw, float partialTicks){ - - super.rotateCorpse(entityLiving, pitch, yaw, partialTicks); - - if ((double)entityLiving.limbSwingAmount >= 0.01D){ - float f3 = 13.0F; - float f4 = entityLiving.limbSwing - entityLiving.limbSwingAmount * (1.0F - partialTicks) + 6.0F; - float f5 = (Math.abs(f4 % f3 - f3 * 0.5F) - f3 * 0.25F) / (f3 * 0.25F); - GlStateManager.rotate(6.5F * f5, 0.0F, 0.0F, 1.0F); - } - } + + @Override + protected void applyRotations(EntityIceGiant entityLiving, float pitch, float yaw, float partialTicks){ + + super.applyRotations(entityLiving, pitch, yaw, partialTicks); + + if((double)entityLiving.limbSwingAmount >= 0.01D){ + float f3 = 13.0F; + float f4 = entityLiving.limbSwing - entityLiving.limbSwingAmount * (1.0F - partialTicks) + 6.0F; + float f5 = (Math.abs(f4 % f3 - f3 * 0.5F) - f3 * 0.25F) / (f3 * 0.25F); + GlStateManager.rotate(6.5F * f5, 0.0F, 0.0F, 1.0F); + } + } } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderIceSpike.java b/src/main/java/electroblob/wizardry/client/renderer/RenderIceSpike.java index 0c4db9ef..fdd64803 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderIceSpike.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderIceSpike.java @@ -15,28 +15,29 @@ import net.minecraft.util.ResourceLocation; public class RenderIceSpike extends Render { - private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, "textures/entity/ice_spike.png"); + private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, + "textures/entity/ice_spike.png"); public RenderIceSpike(RenderManager renderManager){ super(renderManager); } @Override - public void doRender(EntityIceSpike entity, double x, double y, double z, float fa, float partialTickTime) { + public void doRender(EntityIceSpike entity, double x, double y, double z, float fa, float partialTickTime){ GlStateManager.pushMatrix(); - + GlStateManager.translate((float)x, (float)y, (float)z); // Apparently, disabling lighting... doesn't disable lighting. Or at least, you can still set the brightness // with setLightmapTextureCoords. - GlStateManager.disableLighting(); - + GlStateManager.disableLighting(); + int j = entity.getBrightnessForRender(partialTickTime); - int k = j % 65536; - int l = j / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)k / 1.0F, (float)l / 1.0F); - - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + int k = j % 65536; + int l = j / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)k / 1.0F, (float)l / 1.0F); + + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); Tessellator tessellator = Tessellator.getInstance(); VertexBuffer buffer = tessellator.getBuffer(); @@ -45,15 +46,15 @@ public class RenderIceSpike extends Render { // West face buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - buffer.pos(0, 0, 0.5).tex(1, 1).endVertex(); - buffer.pos(0, 1, 0.5).tex(1, 0).endVertex(); + buffer.pos(0, 0, 0.5).tex(1, 1).endVertex(); + buffer.pos(0, 1, 0.5).tex(1, 0).endVertex(); buffer.pos(0, 1, -0.5).tex(0, 0).endVertex(); buffer.pos(0, 0, -0.5).tex(0, 1).endVertex(); tessellator.draw(); // South face buffer.begin(GL11.GL_QUADS, net.minecraft.client.renderer.vertex.DefaultVertexFormats.POSITION_TEX); - buffer.pos( 0.5, 0, 0).tex(1, 1).endVertex(); - buffer.pos( 0.5, 1, 0).tex(1, 0).endVertex(); + buffer.pos(0.5, 0, 0).tex(1, 1).endVertex(); + buffer.pos(0.5, 1, 0).tex(1, 0).endVertex(); buffer.pos(-0.5, 1, 0).tex(0, 0).endVertex(); buffer.pos(-0.5, 0, 0).tex(0, 1).endVertex(); tessellator.draw(); @@ -61,23 +62,23 @@ public class RenderIceSpike extends Render { buffer.begin(GL11.GL_QUADS, net.minecraft.client.renderer.vertex.DefaultVertexFormats.POSITION_TEX); buffer.pos(0, 0, -0.5).tex(0, 1).endVertex(); buffer.pos(0, 1, -0.5).tex(0, 0).endVertex(); - buffer.pos(0, 1, 0.5).tex(1, 0).endVertex(); - buffer.pos(0, 0, 0.5).tex(1, 1).endVertex(); + buffer.pos(0, 1, 0.5).tex(1, 0).endVertex(); + buffer.pos(0, 0, 0.5).tex(1, 1).endVertex(); tessellator.draw(); // North face buffer.begin(GL11.GL_QUADS, net.minecraft.client.renderer.vertex.DefaultVertexFormats.POSITION_TEX); buffer.pos(-0.5, 0, 0).tex(0, 1).endVertex(); buffer.pos(-0.5, 1, 0).tex(0, 0).endVertex(); - buffer.pos( 0.5, 1, 0).tex(1, 0).endVertex(); - buffer.pos( 0.5, 0, 0).tex(1, 1).endVertex(); + buffer.pos(0.5, 1, 0).tex(1, 0).endVertex(); + buffer.pos(0.5, 0, 0).tex(1, 1).endVertex(); tessellator.draw(); - GlStateManager.enableLighting(); + GlStateManager.enableLighting(); GlStateManager.popMatrix(); } @Override - protected ResourceLocation getEntityTexture(EntityIceSpike entity) { + protected ResourceLocation getEntityTexture(EntityIceSpike entity){ return texture; } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderLightningDisc.java b/src/main/java/electroblob/wizardry/client/renderer/RenderLightningDisc.java index a9b620fa..304a4ed8 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderLightningDisc.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderLightningDisc.java @@ -13,69 +13,69 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.ResourceLocation; public class RenderLightningDisc extends Render { - - private final ResourceLocation texture; - private float scale = 1.0f; - - public RenderLightningDisc(RenderManager renderManager, ResourceLocation texture, float scale) { + + private final ResourceLocation texture; + private float scale = 1.0f; + + public RenderLightningDisc(RenderManager renderManager, ResourceLocation texture, float scale){ super(renderManager); this.texture = texture; this.scale = scale; } @Override - public void doRender(EntityLightningDisc entity, double par2, double par4, double par6, float par8, float par9){ - - GlStateManager.pushMatrix(); - GlStateManager.enableBlend(); - GlStateManager.disableLighting(); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - float yOffset = 0; - - GlStateManager.translate((float)par2, (float)par4 + yOffset, (float)par6); - - this.bindTexture(texture); - float f6 = 1.0F; - float f7 = 0.5F; - float f8 = 0.5F; - - GlStateManager.rotate(-90, 1, 0, 0); - - GlStateManager.rotate(entity.ticksExisted*8, 0, 0, 1); - - GlStateManager.scale(scale, scale, scale); - - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buffer = tessellator.getBuffer(); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - //tessellator.setColorRGBA_I(k1, 128); - //buffer.normal(0.0F, 1.0F, 0.0F); - buffer.pos((double)(0.0F - f7), (double)(0.0F - f8), 0.01).tex(0, 1).endVertex(); - buffer.pos((double)(f6 - f7), (double)(0.0F - f8), 0.01).tex(1, 1).endVertex(); - buffer.pos((double)(f6 - f7), (double)(1.0F - f8), 0.01).tex(1, 0).endVertex(); - buffer.pos((double)(0.0F - f7), (double)(1.0F - f8), 0.01).tex(0, 0).endVertex(); - - tessellator.draw(); - - buffer.begin(GL11.GL_QUADS, net.minecraft.client.renderer.vertex.DefaultVertexFormats.POSITION_TEX); - //buffer.normal(0.0F, 1.0F, 0.0F); - buffer.pos((double)(0.0F - f7), (double)(1.0F - f8), 0.01).tex(0, 0).endVertex(); - buffer.pos((double)(f6 - f7), (double)(1.0F - f8), 0.01).tex(1, 0).endVertex(); - buffer.pos((double)(f6 - f7), (double)(0.0F - f8), 0.01).tex(1, 1).endVertex(); - buffer.pos((double)(0.0F - f7), (double)(0.0F - f8), 0.01).tex(0, 1).endVertex(); - - tessellator.draw(); - - GlStateManager.disableBlend(); - GlStateManager.enableLighting(); - GlStateManager.disableRescaleNormal(); - GlStateManager.popMatrix(); - } + public void doRender(EntityLightningDisc entity, double par2, double par4, double par6, float par8, float par9){ + + GlStateManager.pushMatrix(); + GlStateManager.enableBlend(); + GlStateManager.disableLighting(); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + float yOffset = 0; + + GlStateManager.translate((float)par2, (float)par4 + yOffset, (float)par6); + + this.bindTexture(texture); + float f6 = 1.0F; + float f7 = 0.5F; + float f8 = 0.5F; + + GlStateManager.rotate(-90, 1, 0, 0); + + GlStateManager.rotate(entity.ticksExisted * 8, 0, 0, 1); + + GlStateManager.scale(scale, scale, scale); + + Tessellator tessellator = Tessellator.getInstance(); + VertexBuffer buffer = tessellator.getBuffer(); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + // tessellator.setColorRGBA_I(k1, 128); + // buffer.normal(0.0F, 1.0F, 0.0F); + buffer.pos((double)(0.0F - f7), (double)(0.0F - f8), 0.01).tex(0, 1).endVertex(); + buffer.pos((double)(f6 - f7), (double)(0.0F - f8), 0.01).tex(1, 1).endVertex(); + buffer.pos((double)(f6 - f7), (double)(1.0F - f8), 0.01).tex(1, 0).endVertex(); + buffer.pos((double)(0.0F - f7), (double)(1.0F - f8), 0.01).tex(0, 0).endVertex(); + + tessellator.draw(); + + buffer.begin(GL11.GL_QUADS, net.minecraft.client.renderer.vertex.DefaultVertexFormats.POSITION_TEX); + // buffer.normal(0.0F, 1.0F, 0.0F); + buffer.pos((double)(0.0F - f7), (double)(1.0F - f8), 0.01).tex(0, 0).endVertex(); + buffer.pos((double)(f6 - f7), (double)(1.0F - f8), 0.01).tex(1, 0).endVertex(); + buffer.pos((double)(f6 - f7), (double)(0.0F - f8), 0.01).tex(1, 1).endVertex(); + buffer.pos((double)(0.0F - f7), (double)(0.0F - f8), 0.01).tex(0, 1).endVertex(); + + tessellator.draw(); + + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + GlStateManager.disableRescaleNormal(); + GlStateManager.popMatrix(); + } @Override - protected ResourceLocation getEntityTexture(EntityLightningDisc entity) { + protected ResourceLocation getEntityTexture(EntityLightningDisc entity){ return null; } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderLightningPulse.java b/src/main/java/electroblob/wizardry/client/renderer/RenderLightningPulse.java index 2190011a..8ae50b27 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderLightningPulse.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderLightningPulse.java @@ -14,58 +14,58 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.ResourceLocation; public class RenderLightningPulse extends Render { - - private final ResourceLocation[] textures = new ResourceLocation[8]; - private float scale = 1.0f; - - public RenderLightningPulse(RenderManager renderManager, float scale) { + + private final ResourceLocation[] textures = new ResourceLocation[8]; + private float scale = 1.0f; + + public RenderLightningPulse(RenderManager renderManager, float scale){ super(renderManager); - for(int i=0; i { - private final ResourceLocation texture; - private boolean blend; - private boolean renderEnds; - private double length = 8.0, width = 2.0; - private int pixelsLong = 16, pixelsWide = 5; + private final ResourceLocation texture; + private boolean blend; + private boolean renderEnds; + private double length = 8.0, width = 2.0; + private int pixelsLong = 16, pixelsWide = 5; - public RenderMagicArrow(RenderManager renderManager, ResourceLocation texture, boolean blend, double length, double width, int pixelsLong, int pixelsWide, boolean renderEnds){ - super(renderManager); - this.texture = texture; - this.blend = blend; - this.renderEnds = renderEnds; - this.length = length; - this.width = width; - this.pixelsLong = pixelsLong; - this.pixelsWide = pixelsWide; - } - - @Override - public void doRender(EntityMagicArrow entity, double par2, double par4, double par6, float par8, float par9){ - - this.bindEntityTexture(entity); - GlStateManager.pushMatrix(); - GlStateManager.disableLighting(); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); - - if(this.blend){ - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } - - GlStateManager.translate((float)par2, (float)par4, (float)par6); - GlStateManager.rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F); - GlStateManager.rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F); - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buffer = tessellator.getBuffer(); - float f2 = 0.0F; - float f3 = pixelsLong / 32.0F; - float f4 = 0.0F; - float f5 = pixelsWide / 32.0F; - float f6 = 0.0F; - float f7 = 0.15625F; - float f8 = (float)5 / 32.0F; - float f9 = (float)10 / 32.0F; - float f10 = 0.05625F; - float f11 = 0.0f; - GlStateManager.enableRescaleNormal(); - //f11 = (float)par1EntityArrow.arrowShake - par9; - if (f11 > 0.0F) - { - float f12 = -MathHelper.sin(f11 * 3.0F) * f11; - GlStateManager.rotate(f12, 0.0F, 0.0F, 1.0F); - } + public RenderMagicArrow(RenderManager renderManager, ResourceLocation texture, boolean blend, double length, + double width, int pixelsLong, int pixelsWide, boolean renderEnds){ + super(renderManager); + this.texture = texture; + this.blend = blend; + this.renderEnds = renderEnds; + this.length = length; + this.width = width; + this.pixelsLong = pixelsLong; + this.pixelsWide = pixelsWide; + } - GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F); - GlStateManager.scale(f10, f10, f10); - GlStateManager.translate(-4.0F, 0.0F, 0.0F); - GL11.glNormal3f(f10, 0.0F, 0.0F); + @Override + public void doRender(EntityMagicArrow entity, double par2, double par4, double par6, float par8, float par9){ - if(renderEnds){ - // Ends - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - buffer.pos(-7.0D, -width, -width).tex((double)f6, (double)f8).endVertex(); - buffer.pos(-7.0D, -width, width).tex((double)f7, (double)f8).endVertex(); - buffer.pos(-7.0D, width, width).tex((double)f7, (double)f9).endVertex(); - buffer.pos(-7.0D, width, -width).tex((double)f6, (double)f9).endVertex(); - tessellator.draw(); - GL11.glNormal3f(-f10, 0.0F, 0.0F); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - buffer.pos(-7.0D, width, -width).tex((double)f6, (double)f8).endVertex(); - buffer.pos(-7.0D, width, width).tex((double)f7, (double)f8).endVertex(); - buffer.pos(-7.0D, -width, width).tex((double)f7, (double)f9).endVertex(); - buffer.pos(-7.0D, -width, -width).tex((double)f6, (double)f9).endVertex(); - tessellator.draw(); - } + this.bindEntityTexture(entity); + GlStateManager.pushMatrix(); + GlStateManager.disableLighting(); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); - for (int i = 0; i < 4; ++i){ - // Sides - GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); - GL11.glNormal3f(0.0F, 0.0F, f10); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - buffer.pos(-length, -width, 0.0D).tex((double)f2, (double)f4).endVertex(); - buffer.pos(length, -width, 0.0D).tex((double)f3, (double)f4).endVertex(); - buffer.pos(length, width, 0.0D).tex((double)f3, (double)f5).endVertex(); - buffer.pos(-length, width, 0.0D).tex((double)f2, (double)f5).endVertex(); - tessellator.draw(); - } + if(this.blend){ + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } - if(this.blend){ - GlStateManager.disableBlend(); - } - - GlStateManager.disableRescaleNormal(); - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - } + GlStateManager.translate((float)par2, (float)par4, (float)par6); + GlStateManager.rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * par9 - 90.0F, + 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * par9, 0.0F, + 0.0F, 1.0F); + Tessellator tessellator = Tessellator.getInstance(); + VertexBuffer buffer = tessellator.getBuffer(); + float f2 = 0.0F; + float f3 = pixelsLong / 32.0F; + float f4 = 0.0F; + float f5 = pixelsWide / 32.0F; + float f6 = 0.0F; + float f7 = 0.15625F; + float f8 = (float)5 / 32.0F; + float f9 = (float)10 / 32.0F; + float f10 = 0.05625F; + float f11 = 0.0f; + GlStateManager.enableRescaleNormal(); + // f11 = (float)par1EntityArrow.arrowShake - par9; + if(f11 > 0.0F){ + float f12 = -MathHelper.sin(f11 * 3.0F) * f11; + GlStateManager.rotate(f12, 0.0F, 0.0F, 1.0F); + } - @Override - protected ResourceLocation getEntityTexture(EntityMagicArrow arrow) - { - return texture; - } + GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F); + GlStateManager.scale(f10, f10, f10); + GlStateManager.translate(-4.0F, 0.0F, 0.0F); + GL11.glNormal3f(f10, 0.0F, 0.0F); + + if(renderEnds){ + // Ends + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + buffer.pos(-7.0D, -width, -width).tex((double)f6, (double)f8).endVertex(); + buffer.pos(-7.0D, -width, width).tex((double)f7, (double)f8).endVertex(); + buffer.pos(-7.0D, width, width).tex((double)f7, (double)f9).endVertex(); + buffer.pos(-7.0D, width, -width).tex((double)f6, (double)f9).endVertex(); + tessellator.draw(); + GL11.glNormal3f(-f10, 0.0F, 0.0F); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + buffer.pos(-7.0D, width, -width).tex((double)f6, (double)f8).endVertex(); + buffer.pos(-7.0D, width, width).tex((double)f7, (double)f8).endVertex(); + buffer.pos(-7.0D, -width, width).tex((double)f7, (double)f9).endVertex(); + buffer.pos(-7.0D, -width, -width).tex((double)f6, (double)f9).endVertex(); + tessellator.draw(); + } + + for(int i = 0; i < 4; ++i){ + // Sides + GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); + GL11.glNormal3f(0.0F, 0.0F, f10); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + buffer.pos(-length, -width, 0.0D).tex((double)f2, (double)f4).endVertex(); + buffer.pos(length, -width, 0.0D).tex((double)f3, (double)f4).endVertex(); + buffer.pos(length, width, 0.0D).tex((double)f3, (double)f5).endVertex(); + buffer.pos(-length, width, 0.0D).tex((double)f2, (double)f5).endVertex(); + tessellator.draw(); + } + + if(this.blend){ + GlStateManager.disableBlend(); + } + + GlStateManager.disableRescaleNormal(); + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + } + + @Override + protected ResourceLocation getEntityTexture(EntityMagicArrow arrow){ + return texture; + } } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderMagicLight.java b/src/main/java/electroblob/wizardry/client/renderer/RenderMagicLight.java index 1d49c546..8c04cf5b 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderMagicLight.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderMagicLight.java @@ -16,11 +16,14 @@ import net.minecraft.util.ResourceLocation; public class RenderMagicLight extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, "textures/entity/light_ray.png"); - private static final ResourceLocation texture2 = new ResourceLocation(Wizardry.MODID, "textures/entity/light_aura.png"); + private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, + "textures/entity/light_ray.png"); + private static final ResourceLocation texture2 = new ResourceLocation(Wizardry.MODID, + "textures/entity/light_aura.png"); @Override - public void renderTileEntityAt(TileEntityMagicLight tileentity, double x, double y, double z, float f, int destroyStage){ + public void renderTileEntityAt(TileEntityMagicLight tileentity, double x, double y, double z, float f, + int destroyStage){ GlStateManager.pushMatrix(); @@ -34,10 +37,13 @@ public class RenderMagicLight extends TileEntitySpecialRenderer tileentity.maxTimer-10){ - GlStateManager.scale((float)(tileentity.maxTimer-tileentity.timer)/10, (float)(tileentity.maxTimer-tileentity.timer)/10, (float)(tileentity.maxTimer-tileentity.timer)/10); + if(tileentity.timer > tileentity.maxTimer - 10){ + GlStateManager.scale((float)(tileentity.maxTimer - tileentity.timer) / 10, + (float)(tileentity.maxTimer - tileentity.timer) / 10, + (float)(tileentity.maxTimer - tileentity.timer) / 10); } // Renders the aura effect @@ -51,7 +57,9 @@ public class RenderMagicLight extends TileEntitySpecialRenderer= 30){ - for(int j=0; j<30; j++){ - + for(int j = 0; j < 30; j++){ + int sliceAngle = 20 + tileentity.randomiser[j]; float scale = 0.5f; - + GlStateManager.pushMatrix(); - - GlStateManager.rotate(31*tileentity.randomiser[j], 1, 0, 0); - GlStateManager.rotate(31*tileentity.randomiser2[j], 0, 0, 1); - - /* - * OK, so here are the changes to rendering as far as I know: - * Vertex formats specify how the methods are arranged - * Color has to be called for every vertex, I think. - * The new methods thing is a bit weird, because other than the number of arguments there is - * essentially no difference between pos, tex, color, normal and lightmap. At least they make - * the code more readable. - */ - + + GlStateManager.rotate(31 * tileentity.randomiser[j], 1, 0, 0); + GlStateManager.rotate(31 * tileentity.randomiser2[j], 0, 0, 1); + + /* OK, so here are the changes to rendering as far as I know: Vertex formats specify how the methods are + * arranged Color has to be called for every vertex, I think. The new methods thing is a bit weird, + * because other than the number of arguments there is essentially no difference between pos, tex, + * color, normal and lightmap. At least they make the code more readable. */ + buffer.begin(5, DefaultVertexFormats.POSITION_TEX_COLOR); - + buffer.pos(0, 0, 0).tex(0, 0).color(255, 255, 255, 0).endVertex(); buffer.pos(0, 0, 0).tex(0, 1).color(255, 255, 255, 0).endVertex(); - - double x1 = scale*Math.sin((tileentity.timer + 40*j)*(Math.PI/180)); - //double y1 = 0.7*Math.cos((timerentity.timer - 40*j)*(Math.PI/180))*j/10; - double z1 = scale*Math.cos((tileentity.timer + 40*j)*(Math.PI/180)); - - double x2 = scale*Math.sin((tileentity.timer + 40*j - sliceAngle)*(Math.PI/180)); - //double y2 = 0.7*Math.sin((timerentity.timer - 40*j)*(Math.PI/180))*j/10; - double z2 = scale*Math.cos((tileentity.timer + 40*j - sliceAngle)*(Math.PI/180)); - + + double x1 = scale * Math.sin((tileentity.timer + 40 * j) * (Math.PI / 180)); + // double y1 = 0.7*Math.cos((timerentity.timer - 40*j)*(Math.PI/180))*j/10; + double z1 = scale * Math.cos((tileentity.timer + 40 * j) * (Math.PI / 180)); + + double x2 = scale * Math.sin((tileentity.timer + 40 * j - sliceAngle) * (Math.PI / 180)); + // double y2 = 0.7*Math.sin((timerentity.timer - 40*j)*(Math.PI/180))*j/10; + double z2 = scale * Math.cos((tileentity.timer + 40 * j - sliceAngle) * (Math.PI / 180)); + buffer.pos(x1, 0, z1).tex(1, 0).color(0, 0, 0, 255).endVertex(); buffer.pos(x2, 0, z2).tex(1, 1).color(0, 0, 0, 255).endVertex(); - + tessellator.draw(); - + GlStateManager.popMatrix(); } } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderPhoenix.java b/src/main/java/electroblob/wizardry/client/renderer/RenderPhoenix.java index bd070796..071e3408 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderPhoenix.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderPhoenix.java @@ -16,37 +16,37 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderPhoenix extends RenderLiving { - private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, "textures/entity/phoenix.png"); + private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, "textures/entity/phoenix.png"); - public RenderPhoenix(RenderManager renderManager){ - super(renderManager, new ModelPhoenix(), 1.0f); - } + public RenderPhoenix(RenderManager renderManager){ + super(renderManager, new ModelPhoenix(), 1.0f); + } - @Override - protected ResourceLocation getEntityTexture(EntityPhoenix entity){ - return texture; - } + @Override + protected ResourceLocation getEntityTexture(EntityPhoenix entity){ + return texture; + } - @Override - protected void rotateCorpse(EntityPhoenix par1EntityPhoenix, float par2, float par3, float par4){ - GlStateManager.translate(0.0F, -0.1F, 0.0F); - super.rotateCorpse(par1EntityPhoenix, par2, par3, par4); - } + @Override + protected void applyRotations(EntityPhoenix par1EntityPhoenix, float par2, float par3, float par4){ + GlStateManager.translate(0.0F, -0.1F, 0.0F); + super.applyRotations(par1EntityPhoenix, par2, par3, par4); + } - @Override - public void doRender(EntityPhoenix phoenix, double par2, double par4, double par6, float par8, float par9){ - - GlStateManager.pushMatrix(); - - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); - - super.doRender(phoenix, par2, par4, par6, par8, par9); + @Override + public void doRender(EntityPhoenix phoenix, double par2, double par4, double par6, float par8, float par9){ - GlStateManager.enableLighting(); - GlStateManager.disableBlend(); - GlStateManager.popMatrix(); - } + GlStateManager.pushMatrix(); + + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); + + super.doRender(phoenix, par2, par4, par6, par8, par9); + + GlStateManager.enableLighting(); + GlStateManager.disableBlend(); + GlStateManager.popMatrix(); + } } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderProjectile.java b/src/main/java/electroblob/wizardry/client/renderer/RenderProjectile.java index dc00bf41..38e397e7 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderProjectile.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderProjectile.java @@ -18,71 +18,71 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderProjectile extends Render { - private float scale; - private boolean blend = false; - - private final ResourceLocation texture; + private float scale; + private boolean blend = false; - public RenderProjectile(RenderManager renderManager, float scale, ResourceLocation texture, boolean doBlending) - { - super(renderManager); - this.scale = scale; - this.texture = texture; - this.blend = doBlending; - } + private final ResourceLocation texture; - @Override - public void doRender(EntityMagicProjectile entity, double par2, double par4, double par6, float par8, float par9){ - - GlStateManager.pushMatrix(); - this.bindTexture(texture); - GlStateManager.translate((float)par2, (float)par4, (float)par6); - GlStateManager.enableRescaleNormal(); - if(blend){ - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } - GlStateManager.disableLighting(); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); - - float f2 = this.scale; - GlStateManager.scale(f2 / 1.0F, f2 / 1.0F, f2 / 1.0F); - - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buffer = tessellator.getBuffer(); - - float f3 = 0.0f; - float f4 = 1.0f; - float f5 = 0.0f; - float f6 = 1.0f; - float f7 = 1.0F; - float f8 = 0.5F; - float f9 = 0.25F; - - // This counteracts the reverse rotation behaviour when in front f5 view. - // Fun fact: this is a bug with vanilla too! Look at a snowball in front f5 view, for example. - float yaw = Minecraft.getMinecraft().gameSettings.thirdPersonView == 2 ? this.renderManager.playerViewX : -this.renderManager.playerViewX; - GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); - GlStateManager.rotate(yaw, 1.0F, 0.0F, 0.0F); - - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - //buffer.normal(0.0F, 1.0F, 0.0F); - buffer.pos((double)(0.0F - f8), (double)(0.0F - f9), 0.0D).tex((double)f3, (double)f6).endVertex(); - buffer.pos((double)(f7 - f8), (double)(0.0F - f9), 0.0D).tex((double)f4, (double)f6).endVertex(); - buffer.pos((double)(f7 - f8), (double)(1.0F - f9), 0.0D).tex((double)f4, (double)f5).endVertex(); - buffer.pos((double)(0.0F - f8), (double)(1.0F - f9), 0.0D).tex((double)f3, (double)f5).endVertex(); - tessellator.draw(); - - GlStateManager.disableRescaleNormal(); - if(blend){ - GlStateManager.disableBlend(); - } - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - } - - @Override - protected ResourceLocation getEntityTexture(EntityMagicProjectile par1Entity){ - return texture; - } + public RenderProjectile(RenderManager renderManager, float scale, ResourceLocation texture, boolean doBlending){ + super(renderManager); + this.scale = scale; + this.texture = texture; + this.blend = doBlending; + } + + @Override + public void doRender(EntityMagicProjectile entity, double par2, double par4, double par6, float par8, float par9){ + + GlStateManager.pushMatrix(); + this.bindTexture(texture); + GlStateManager.translate((float)par2, (float)par4, (float)par6); + GlStateManager.enableRescaleNormal(); + if(blend){ + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } + GlStateManager.disableLighting(); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); + + float f2 = this.scale; + GlStateManager.scale(f2 / 1.0F, f2 / 1.0F, f2 / 1.0F); + + Tessellator tessellator = Tessellator.getInstance(); + VertexBuffer buffer = tessellator.getBuffer(); + + float f3 = 0.0f; + float f4 = 1.0f; + float f5 = 0.0f; + float f6 = 1.0f; + float f7 = 1.0F; + float f8 = 0.5F; + float f9 = 0.25F; + + // This counteracts the reverse rotation behaviour when in front f5 view. + // Fun fact: this is a bug with vanilla too! Look at a snowball in front f5 view, for example. + float yaw = Minecraft.getMinecraft().gameSettings.thirdPersonView == 2 ? this.renderManager.playerViewX + : -this.renderManager.playerViewX; + GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(yaw, 1.0F, 0.0F, 0.0F); + + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + // buffer.normal(0.0F, 1.0F, 0.0F); + buffer.pos((double)(0.0F - f8), (double)(0.0F - f9), 0.0D).tex((double)f3, (double)f6).endVertex(); + buffer.pos((double)(f7 - f8), (double)(0.0F - f9), 0.0D).tex((double)f4, (double)f6).endVertex(); + buffer.pos((double)(f7 - f8), (double)(1.0F - f9), 0.0D).tex((double)f4, (double)f5).endVertex(); + buffer.pos((double)(0.0F - f8), (double)(1.0F - f9), 0.0D).tex((double)f3, (double)f5).endVertex(); + tessellator.draw(); + + GlStateManager.disableRescaleNormal(); + if(blend){ + GlStateManager.disableBlend(); + } + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); + } + + @Override + protected ResourceLocation getEntityTexture(EntityMagicProjectile par1Entity){ + return texture; + } } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderSigil.java b/src/main/java/electroblob/wizardry/client/renderer/RenderSigil.java index bb33b60d..876a7172 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderSigil.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderSigil.java @@ -17,12 +17,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; public class RenderSigil extends Render { - - private final ResourceLocation texture; - private float scale = 1.0f; - private boolean invisibleToEnemies; - - public RenderSigil(RenderManager renderManager, ResourceLocation texture, float scale, boolean invisibleToEnemies) { + + private final ResourceLocation texture; + private float scale = 1.0f; + private boolean invisibleToEnemies; + + public RenderSigil(RenderManager renderManager, ResourceLocation texture, float scale, boolean invisibleToEnemies){ super(renderManager); this.texture = texture; this.scale = scale; @@ -30,59 +30,59 @@ public class RenderSigil extends Render { } @Override - public void doRender(EntityMagicConstruct entity, double par2, double par4, double par6, float par8, float par9){ - + public void doRender(EntityMagicConstruct entity, double par2, double par4, double par6, float par8, float par9){ + // Makes the sigil invisible to enemies of the player that created it if(this.invisibleToEnemies){ - - if(entity.getCaster() instanceof EntityPlayer - && !WizardryUtilities.isPlayerAlly((EntityPlayer)entity.getCaster(), Minecraft.getMinecraft().thePlayer)){ + + if(entity.getCaster() instanceof EntityPlayer && !WizardryUtilities + .isPlayerAlly((EntityPlayer)entity.getCaster(), Minecraft.getMinecraft().player)){ return; } } - - GlStateManager.pushMatrix(); - GlStateManager.enableBlend(); - GlStateManager.disableLighting(); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - float yOffset = 0; - - GlStateManager.translate((float)par2, (float)par4 + yOffset, (float)par6); - - this.bindTexture(texture); - float f6 = 1.0F; - float f7 = 0.5F; - float f8 = 0.5F; - - GlStateManager.rotate(-90, 1, 0, 0); - - // Healing aura rotates slowly - if(entity instanceof EntityHealAura) GlStateManager.rotate(entity.ticksExisted/3.0f, 0, 0, 1); - - GlStateManager.scale(scale, scale, scale); - - Tessellator tessellator = Tessellator.getInstance(); - VertexBuffer buffer = tessellator.getBuffer(); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - //tessellator.setColorRGBA_I(k1, 128); - //buffer.normal(0.0F, 1.0F, 0.0F); - buffer.pos((double)(0.0F - f7), (double)(0.0F - f8), 0.01).tex(0, 1).endVertex(); - buffer.pos((double)(f6 - f7), (double)(0.0F - f8), 0.01).tex(1, 1).endVertex(); - buffer.pos((double)(f6 - f7), (double)(1.0F - f8), 0.01).tex(1, 0).endVertex(); - buffer.pos((double)(0.0F - f7), (double)(1.0F - f8), 0.01).tex(0, 0).endVertex(); - - tessellator.draw(); - - GlStateManager.disableBlend(); - GlStateManager.enableLighting(); - GlStateManager.disableRescaleNormal(); - GlStateManager.popMatrix(); - } + + GlStateManager.pushMatrix(); + GlStateManager.enableBlend(); + GlStateManager.disableLighting(); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + float yOffset = 0; + + GlStateManager.translate((float)par2, (float)par4 + yOffset, (float)par6); + + this.bindTexture(texture); + float f6 = 1.0F; + float f7 = 0.5F; + float f8 = 0.5F; + + GlStateManager.rotate(-90, 1, 0, 0); + + // Healing aura rotates slowly + if(entity instanceof EntityHealAura) GlStateManager.rotate(entity.ticksExisted / 3.0f, 0, 0, 1); + + GlStateManager.scale(scale, scale, scale); + + Tessellator tessellator = Tessellator.getInstance(); + VertexBuffer buffer = tessellator.getBuffer(); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + // tessellator.setColorRGBA_I(k1, 128); + // buffer.normal(0.0F, 1.0F, 0.0F); + buffer.pos((double)(0.0F - f7), (double)(0.0F - f8), 0.01).tex(0, 1).endVertex(); + buffer.pos((double)(f6 - f7), (double)(0.0F - f8), 0.01).tex(1, 1).endVertex(); + buffer.pos((double)(f6 - f7), (double)(1.0F - f8), 0.01).tex(1, 0).endVertex(); + buffer.pos((double)(0.0F - f7), (double)(1.0F - f8), 0.01).tex(0, 0).endVertex(); + + tessellator.draw(); + + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + GlStateManager.disableRescaleNormal(); + GlStateManager.popMatrix(); + } @Override - protected ResourceLocation getEntityTexture(EntityMagicConstruct entity) { + protected ResourceLocation getEntityTexture(EntityMagicConstruct entity){ return null; } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderSpiritHorse.java b/src/main/java/electroblob/wizardry/client/renderer/RenderSpiritHorse.java index dda80293..c3452e38 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderSpiritHorse.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderSpiritHorse.java @@ -3,7 +3,6 @@ package electroblob.wizardry.client.renderer; import org.lwjgl.opengl.GL11; import electroblob.wizardry.Wizardry; -import net.minecraft.client.model.ModelHorse; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderHorse; import net.minecraft.client.renderer.entity.RenderManager; @@ -14,23 +13,24 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderSpiritHorse extends RenderHorse { - - private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, "textures/entity/spirit_horse.png"); - public RenderSpiritHorse(RenderManager renderManager, float par2){ - super(renderManager, new ModelHorse(), par2); - } - - @Override - protected ResourceLocation getEntityTexture(EntityHorse entity) { - return texture; - } + private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, + "textures/entity/spirit_horse.png"); - @Override - protected void preRenderCallback(EntityHorse entitylivingbaseIn, float partialTickTime){ - super.preRenderCallback(entitylivingbaseIn, partialTickTime); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } + public RenderSpiritHorse(RenderManager renderManager){ + super(renderManager); + } + + @Override + protected ResourceLocation getEntityTexture(EntityHorse entity){ + return texture; + } + + @Override + protected void preRenderCallback(EntityHorse entitylivingbaseIn, float partialTickTime){ + super.preRenderCallback(entitylivingbaseIn, partialTickTime); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderSpiritWolf.java b/src/main/java/electroblob/wizardry/client/renderer/RenderSpiritWolf.java index e1ffe797..a3f4fadc 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderSpiritWolf.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderSpiritWolf.java @@ -3,7 +3,6 @@ package electroblob.wizardry.client.renderer; import org.lwjgl.opengl.GL11; import electroblob.wizardry.Wizardry; -import net.minecraft.client.model.ModelWolf; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderWolf; @@ -14,22 +13,23 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderSpiritWolf extends RenderWolf { - - private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, "textures/entity/spirit_wolf.png"); - public RenderSpiritWolf(RenderManager renderManager, float par3){ - super(renderManager, new ModelWolf(), par3); - } + private static final ResourceLocation texture = new ResourceLocation(Wizardry.MODID, + "textures/entity/spirit_wolf.png"); - @Override - protected ResourceLocation getEntityTexture(EntityWolf entity) { - return texture; - } + public RenderSpiritWolf(RenderManager renderManager){ + super(renderManager); + } - @Override - protected void preRenderCallback(EntityWolf entity, float partialTickTime){ - super.preRenderCallback(entity, partialTickTime); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } + @Override + protected ResourceLocation getEntityTexture(EntityWolf entity){ + return texture; + } + + @Override + protected void preRenderCallback(EntityWolf entity, float partialTickTime){ + super.preRenderCallback(entity, partialTickTime); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderStatue.java b/src/main/java/electroblob/wizardry/client/renderer/RenderStatue.java index 33301d84..c65cb05e 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderStatue.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderStatue.java @@ -9,33 +9,35 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; public class RenderStatue extends TileEntitySpecialRenderer { - + private int destroyStage = 0; // Gets set each time a statue is rendered to allow access from the layer renderer @Override - public void renderTileEntityAt(TileEntityStatue statue, double x, double y, double z, float partialTicks, int destroyStage){ + public void renderTileEntityAt(TileEntityStatue statue, double x, double y, double z, float partialTicks, + int destroyStage){ // Multiblock support for the breaking animation. The chest has its own way of doing this in // TileEntityRendererDispatcher, but I don't have access to that. if(statue.position != 1 && destroyStage >= 0){ - TileEntity tileentity = statue.getWorld().getTileEntity(statue.getPos().down(statue.position-1)); - //System.out.println(tileentity); + TileEntity tileentity = statue.getWorld().getTileEntity(statue.getPos().down(statue.position - 1)); + // System.out.println(tileentity); if(tileentity instanceof TileEntityStatue){ // If this is the block breaking animation pass and this isn't the bottom block, divert the call to // the bottom block. - this.renderTileEntityAt((TileEntityStatue)tileentity, x, y - (statue.position-1), z, partialTicks, destroyStage); + this.renderTileEntityAt((TileEntityStatue)tileentity, x, y - (statue.position - 1), z, partialTicks, + destroyStage); } } if(statue.creature != null && statue.position == 1){ - + this.destroyStage = destroyStage; - + GlStateManager.pushMatrix(); // The next line makes stuff render in the same place relative to the world wherever the player is. GlStateManager.translate((float)x + 0.5F, (float)y, (float)z + 0.5F); GlStateManager.enableLighting(); - + float yaw = statue.creature.prevRotationYaw; int i = statue.creature.getBrightnessForRender(0); @@ -51,12 +53,12 @@ public class RenderStatue extends TileEntitySpecialRenderer { // For some reason, passing in the partialTicks causes the entity to spin round really fast Minecraft.getMinecraft().getRenderManager().doRenderEntity(statue.creature, 0, 0, 0, 0, 0, true); if(!statue.isIce) statue.creature.setInvisible(false); - + GlStateManager.popMatrix(); } } - + public ResourceLocation getBlockBreakingTexture(){ return destroyStage < 0 ? null : DESTROY_STAGES[destroyStage]; } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderWizard.java b/src/main/java/electroblob/wizardry/client/renderer/RenderWizard.java index e2043d5b..baa322ee 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderWizard.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderWizard.java @@ -13,22 +13,22 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderWizard extends RenderBiped { - static final ResourceLocation[] textures = new ResourceLocation[6]; + static final ResourceLocation[] textures = new ResourceLocation[6]; - public RenderWizard(RenderManager renderManager){ - - super(renderManager, new ModelWizard(), 0.5F); - - for(int i=0;i<6;i++){ + public RenderWizard(RenderManager renderManager){ + + super(renderManager, new ModelWizard(), 0.5F); + + for(int i = 0; i < 6; i++){ textures[i] = new ResourceLocation(Wizardry.MODID, "textures/entity/wizard_" + i + ".png"); } - // Just using the default without overriding models, since the armour sets its own model anyway. - this.addLayer(new LayerBipedArmor(this)); - } - - @Override - protected ResourceLocation getEntityTexture(EntityWizard wizard) { - return textures[wizard.textureIndex]; - } + // Just using the default without overriding models, since the armour sets its own model anyway. + this.addLayer(new LayerBipedArmor(this)); + } + + @Override + protected ResourceLocation getEntityTexture(EntityWizard wizard){ + return textures[wizard.textureIndex]; + } } diff --git a/src/main/java/electroblob/wizardry/client/renderer/RenderWraithMinion.java b/src/main/java/electroblob/wizardry/client/renderer/RenderWraithMinion.java index 2c31a7cb..da691189 100644 --- a/src/main/java/electroblob/wizardry/client/renderer/RenderWraithMinion.java +++ b/src/main/java/electroblob/wizardry/client/renderer/RenderWraithMinion.java @@ -9,18 +9,15 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class RenderWraithMinion extends RenderLiving -{ +public class RenderWraithMinion extends RenderLiving { private ResourceLocation texture = new ResourceLocation("textures/entity/blaze.png"); - public RenderWraithMinion(RenderManager renderManagerIn) - { - super(renderManagerIn, new ModelBlaze(), 0.5F); - } + public RenderWraithMinion(RenderManager renderManagerIn){ + super(renderManagerIn, new ModelBlaze(), 0.5F); + } - @Override - protected ResourceLocation getEntityTexture(EntityBlazeMinion entity) - { - return texture; - } + @Override + protected ResourceLocation getEntityTexture(EntityBlazeMinion entity){ + return texture; + } } diff --git a/src/main/java/electroblob/wizardry/command/CommandCastSpell.java b/src/main/java/electroblob/wizardry/command/CommandCastSpell.java index 7d9810ec..c5a6ad94 100644 --- a/src/main/java/electroblob/wizardry/command/CommandCastSpell.java +++ b/src/main/java/electroblob/wizardry/command/CommandCastSpell.java @@ -32,165 +32,177 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; public class CommandCastSpell extends CommandBase { @Override - public String getCommandName(){ + public String getName(){ return Wizardry.settings.castCommandName; } - + @Override public int getRequiredPermissionLevel(){ // I *think* it's something like 0 = everyone, 1 = moderator, 2 = op/admin, 3 = op/console... return 2; } - + @Override - public String getCommandUsage(ICommandSender p_71518_1_){ + public String getUsage(ICommandSender sender){ // Not ideal, but the way this is implemented means I have no choice. Only used in the help command, so in there // the custom command name will not display. return "commands.wizardry:cast.usage"; - //return I18n.format("commands.wizardry:cast.usage", Wizardry.settings.castCommandName); + // return I18n.format("commands.wizardry:cast.usage", Wizardry.settings.castCommandName); } - + @Override - public List getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] arguments, BlockPos pos) { + public List getTabCompletions(MinecraftServer server, ICommandSender sender, String[] arguments, + BlockPos pos){ switch(arguments.length){ - case 1: return getListOfStringsMatchingLastWord(arguments, Spell.getSpellNames()); - case 2: return getListOfStringsMatchingLastWord(arguments, server.getAllUsernames()); + case 1: + return getListOfStringsMatchingLastWord(arguments, Spell.getSpellNames()); + case 2: + return getListOfStringsMatchingLastWord(arguments, server.getOnlinePlayerNames()); } - return super.getTabCompletionOptions(server, sender, arguments, pos); + return super.getTabCompletions(server, sender, arguments, pos); } @Override - public void execute(MinecraftServer server, ICommandSender sender, String[] arguments) throws CommandException { - + public void execute(MinecraftServer server, ICommandSender sender, String[] arguments) throws CommandException{ + if(arguments.length < 1){ - throw new WrongUsageException("commands.wizardry:cast.usage", Wizardry.settings.castCommandName); - }else{ - - // ===== Parameter retrieval ===== - - int i=0; - - EntityPlayerMP caster = null; - - try{ - caster = getCommandSenderAsPlayer(sender); - }catch(PlayerNotFoundException exception){ - // Nothing here since the player specifying is done later, I just don't want it to throw an exception here. - } - - Spell spell = Spell.get(arguments[i++]); - - if(spell == null){ - throw new NumberInvalidException("commands.wizardry:cast.not_found", new Object[]{arguments[i-1]}); - } - - boolean castAsOtherPlayer = false; - - if(i < arguments.length){ - try{ - // If the second argument is a player and is not the player that gave the command, the spell is cast - // as the given player rather than the command sender, and there is a different chat readout. - EntityPlayerMP entityplayermp = getPlayer(server, sender, arguments[i++]); - if(caster != entityplayermp){ - castAsOtherPlayer = true; - caster = entityplayermp; - } - }catch(PlayerNotFoundException exception){ - // If no player was found, rather than give an error it simply assumes the player was unspecified. - i--; - } - } - - // If, after this point, the player is still null, the sender must be a command block or the console and the - // player must not have been specified, meaning an exception should be thrown. - if(caster == null) throw new PlayerNotFoundException("You must specify which player you wish to perform this action on."); - - SpellModifiers modifiers = new SpellModifiers(); - - if(i < arguments.length){ - - // Copied from CommandGive. Why it doesn't just use arguments[i] itself I don't know. - String nbt = getChatComponentFromNthArg(sender, arguments, i++).getUnformattedText(); + throw new WrongUsageException("commands.wizardry:cast.usage", Wizardry.settings.castCommandName); + }else{ - try{ - modifiers = SpellModifiers.fromNBT(JsonToNBT.getTagFromJson(nbt)); - }catch(NBTException nbtexception){ - throw new CommandException("commands.wizardry:cast.tag_error", nbtexception.getMessage()); - } - - for(float multiplier : modifiers.getModifiers().values()){ - if(multiplier < 0){ - throw new NumberInvalidException("commands.generic.double.tooSmall", multiplier, 0); - }else if(multiplier > Wizardry.settings.maxSpellCommandMultiplier){ - throw new NumberInvalidException("commands.generic.double.tooBig", multiplier, Wizardry.settings.maxSpellCommandMultiplier); - } - } - - } - - // ===== Spell casting ===== - - // If anything stops the spell working at this point, nothing else happens. - if(MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Pre(caster, spell, modifiers, Source.COMMAND))){ - displayFailMessage(sender, spell); - return; - } - - WizardData data = WizardData.get((EntityPlayer)caster); - - if(spell.isContinuous){ - - // Events for continuous spell casting via commands are dealt with in WizardData. - - if(data != null){ - if(data.isCasting()){ - data.stopCastingContinuousSpell(); - }else{ - - data.startCastingContinuousSpell(spell, modifiers); - - if(castAsOtherPlayer){ - sender.addChatMessage(new TextComponentTranslation("commands.wizardry:cast.success_remote_continuous", spell.getNameForTranslationFormatted(), caster.getName())); - }else{ - sender.addChatMessage(new TextComponentTranslation("commands.wizardry:cast.success_continuous", spell.getNameForTranslationFormatted())); - } - } - - return; - } - - }else{ + // ===== Parameter retrieval ===== - if(spell.cast(caster.worldObj, caster, EnumHand.MAIN_HAND, 0, modifiers)){ - - MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Post(caster, spell, modifiers, Source.COMMAND)); - - if(spell.doesSpellRequirePacket()){ + int i = 0; + + EntityPlayerMP caster = null; + + try{ + caster = getCommandSenderAsPlayer(sender); + }catch (PlayerNotFoundException exception){ + // Nothing here since the player specifying is done later, I just don't want it to throw an exception + // here. + } + + Spell spell = Spell.get(arguments[i++]); + + if(spell == null){ + throw new NumberInvalidException("commands.wizardry:cast.not_found", new Object[]{arguments[i - 1]}); + } + + boolean castAsOtherPlayer = false; + + if(i < arguments.length){ + try{ + // If the second argument is a player and is not the player that gave the command, the spell is cast + // as the given player rather than the command sender, and there is a different chat readout. + EntityPlayerMP entityplayermp = getPlayer(server, sender, arguments[i++]); + if(caster != entityplayermp){ + castAsOtherPlayer = true; + caster = entityplayermp; + } + }catch (PlayerNotFoundException exception){ + // If no player was found, rather than give an error it simply assumes the player was unspecified. + i--; + } + } + + // If, after this point, the player is still null, the sender must be a command block or the console and the + // player must not have been specified, meaning an exception should be thrown. + if(caster == null) + throw new PlayerNotFoundException("You must specify which player you wish to perform this action on."); + + SpellModifiers modifiers = new SpellModifiers(); + + if(i < arguments.length){ + + // Copied from CommandGive. Why it doesn't just use arguments[i] itself I don't know. + String nbt = getChatComponentFromNthArg(sender, arguments, i++).getUnformattedText(); + + try{ + modifiers = SpellModifiers.fromNBT(JsonToNBT.getTagFromJson(nbt)); + }catch (NBTException nbtexception){ + throw new CommandException("commands.wizardry:cast.tag_error", nbtexception.getMessage()); + } + + for(float multiplier : modifiers.getModifiers().values()){ + if(multiplier < 0){ + throw new NumberInvalidException("commands.generic.double.tooSmall", multiplier, 0); + }else if(multiplier > Wizardry.settings.maxSpellCommandMultiplier){ + throw new NumberInvalidException("commands.generic.double.tooBig", multiplier, + Wizardry.settings.maxSpellCommandMultiplier); + } + } + + } + + // ===== Spell casting ===== + + // If anything stops the spell working at this point, nothing else happens. + if(MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Pre(caster, spell, modifiers, Source.COMMAND))){ + displayFailMessage(sender, spell); + return; + } + + WizardData data = WizardData.get((EntityPlayer)caster); + + if(spell.isContinuous){ + + // Events for continuous spell casting via commands are dealt with in WizardData. + + if(data != null){ + if(data.isCasting()){ + data.stopCastingContinuousSpell(); + }else{ + + data.startCastingContinuousSpell(spell, modifiers); + + if(castAsOtherPlayer){ + sender.sendMessage( + new TextComponentTranslation("commands.wizardry:cast.success_remote_continuous", + spell.getNameForTranslationFormatted(), caster.getName())); + }else{ + sender.sendMessage(new TextComponentTranslation("commands.wizardry:cast.success_continuous", + spell.getNameForTranslationFormatted())); + } + } + + return; + } + + }else{ + + if(spell.cast(caster.world, caster, EnumHand.MAIN_HAND, 0, modifiers)){ + + MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Post(caster, spell, modifiers, Source.COMMAND)); + + if(spell.doesSpellRequirePacket()){ // Sends a packet to all players in dimension to tell them to spawn particles. // Only sent if the spell succeeded, because if the spell failed, you wouldn't // need to spawn any particles! IMessage msg = new PacketCastSpell.Message(caster.getEntityId(), null, spell.id(), modifiers); - WizardryPacketHandler.net.sendToDimension(msg, caster.worldObj.provider.getDimension()); + WizardryPacketHandler.net.sendToDimension(msg, caster.world.provider.getDimension()); } - - if(castAsOtherPlayer){ - sender.addChatMessage(new TextComponentTranslation("commands.wizardry:cast.success_remote", spell.getNameForTranslationFormatted(), caster.getName())); - }else{ - sender.addChatMessage(new TextComponentTranslation("commands.wizardry:cast.success", spell.getNameForTranslationFormatted())); - } - return; - } - } - - displayFailMessage(sender, spell); - } + + if(castAsOtherPlayer){ + sender.sendMessage(new TextComponentTranslation("commands.wizardry:cast.success_remote", + spell.getNameForTranslationFormatted(), caster.getName())); + }else{ + sender.sendMessage(new TextComponentTranslation("commands.wizardry:cast.success", + spell.getNameForTranslationFormatted())); + } + return; + } + } + + displayFailMessage(sender, spell); + } } - + /** Displays the "Unable to cast [spell]" message in the chat. */ private void displayFailMessage(ICommandSender sender, Spell spell){ - ITextComponent message = new TextComponentTranslation("commands.wizardry:cast.fail", spell.getNameForTranslationFormatted()); - message.getStyle().setColor(TextFormatting.RED); - sender.addChatMessage(message); + ITextComponent message = new TextComponentTranslation("commands.wizardry:cast.fail", + spell.getNameForTranslationFormatted()); + message.getStyle().setColor(TextFormatting.RED); + sender.sendMessage(message); } } diff --git a/src/main/java/electroblob/wizardry/command/CommandDiscoverSpell.java b/src/main/java/electroblob/wizardry/command/CommandDiscoverSpell.java index 85a292fa..a50e408b 100644 --- a/src/main/java/electroblob/wizardry/command/CommandDiscoverSpell.java +++ b/src/main/java/electroblob/wizardry/command/CommandDiscoverSpell.java @@ -22,7 +22,7 @@ import net.minecraftforge.common.MinecraftForge; public class CommandDiscoverSpell extends CommandBase { @Override - public String getCommandName(){ + public String getName(){ return Wizardry.settings.discoverspellCommandName; } @@ -32,39 +32,40 @@ public class CommandDiscoverSpell extends CommandBase { return 2; } - /* - @Override - public boolean checkPermission(MinecraftServer server, ICommandSender sender){ - // Only ops (multiplayer) or players with cheats enabled (singleplayer/LAN) can use /discoverspell. - return !(sender instanceof EntityPlayer) || server.getServer().getConfigurationManager().func_152596_g(((EntityPlayer)sender).getGameProfile()); - } - */ + /* @Override public boolean checkPermission(MinecraftServer server, ICommandSender sender){ // Only ops + * (multiplayer) or players with cheats enabled (singleplayer/LAN) can use /discoverspell. return !(sender + * instanceof EntityPlayer) || + * server.getServer().getConfigurationManager().func_152596_g(((EntityPlayer)sender).getGameProfile()); } */ @Override - public String getCommandUsage(ICommandSender p_71518_1_){ + public String getUsage(ICommandSender sender){ // Not ideal, but the way this is implemented means I have no choice. Only used in the help command, so in there // the custom command name will not display. return "commands.wizardry:discoverspell.usage"; - //return I18n.format("commands.wizardry:discoverspell.usage", Wizardry.settings.discoverspellCommandName); + // return I18n.format("commands.wizardry:discoverspell.usage", Wizardry.settings.discoverspellCommandName); } @Override - public List getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] arguments, BlockPos pos) { + public List getTabCompletions(MinecraftServer server, ICommandSender sender, String[] arguments, + BlockPos pos){ switch(arguments.length){ - case 1: return getListOfStringsMatchingLastWord(arguments, Spell.getSpellNames()); - case 2: return getListOfStringsMatchingLastWord(arguments, server.getAllUsernames()); + case 1: + return getListOfStringsMatchingLastWord(arguments, Spell.getSpellNames()); + case 2: + return getListOfStringsMatchingLastWord(arguments, server.getOnlinePlayerNames()); } - return super.getTabCompletionOptions(server, sender, arguments, pos); + return super.getTabCompletions(server, sender, arguments, pos); } @Override - public void execute(MinecraftServer server, ICommandSender sender, String[] arguments) throws CommandException { + public void execute(MinecraftServer server, ICommandSender sender, String[] arguments) throws CommandException{ if(arguments.length < 1){ - throw new WrongUsageException("commands.wizardry:discoverspell.usage", Wizardry.settings.discoverspellCommandName); + throw new WrongUsageException("commands.wizardry:discoverspell.usage", + Wizardry.settings.discoverspellCommandName); }else{ - int i=0; + int i = 0; boolean clear = false; boolean all = false; @@ -72,8 +73,9 @@ public class CommandDiscoverSpell extends CommandBase { try{ player = getCommandSenderAsPlayer(sender); - }catch(PlayerNotFoundException exception){ - // Nothing here since the player specifying is done later, I just don't want it to throw an exception here. + }catch (PlayerNotFoundException exception){ + // Nothing here since the player specifying is done later, I just don't want it to throw an exception + // here. } Spell spell = Spells.none; @@ -89,7 +91,8 @@ public class CommandDiscoverSpell extends CommandBase { spell = Spell.get(arguments[i++]); if(spell == null){ - throw new NumberInvalidException("commands.wizardry:discoverspell.not_found", new Object[]{arguments[i-1]}); + throw new NumberInvalidException("commands.wizardry:discoverspell.not_found", + new Object[]{arguments[i - 1]}); } } @@ -104,25 +107,31 @@ public class CommandDiscoverSpell extends CommandBase { // If, after this point, the player is still null, the sender must be a command block or the console and the // player must not have been specified, meaning an exception should be thrown. - if(player == null) throw new PlayerNotFoundException("You must specify which player you wish to perform this action on."); + if(player == null) + throw new PlayerNotFoundException("You must specify which player you wish to perform this action on."); WizardData properties = WizardData.get(player); if(properties != null){ if(clear){ properties.spellsDiscovered.clear(); - sender.addChatMessage(new TextComponentTranslation("commands.wizardry:discoverspell.clear", player.getName())); + sender.sendMessage( + new TextComponentTranslation("commands.wizardry:discoverspell.clear", player.getName())); }else if(all){ properties.spellsDiscovered.addAll(Spell.getSpells(Spell.allSpells)); - sender.addChatMessage(new TextComponentTranslation("commands.wizardry:discoverspell.all", player.getName())); + sender.sendMessage( + new TextComponentTranslation("commands.wizardry:discoverspell.all", player.getName())); }else{ if(properties.hasSpellBeenDiscovered(spell)){ properties.spellsDiscovered.remove(spell); - sender.addChatMessage(new TextComponentTranslation("commands.wizardry:discoverspell.removespell", spell.getNameForTranslationFormatted(), player.getName())); + sender.sendMessage(new TextComponentTranslation("commands.wizardry:discoverspell.removespell", + spell.getNameForTranslationFormatted(), player.getName())); }else{ - if(!MinecraftForge.EVENT_BUS.post(new DiscoverSpellEvent(player, spell, DiscoverSpellEvent.Source.COMMAND))){ + if(!MinecraftForge.EVENT_BUS + .post(new DiscoverSpellEvent(player, spell, DiscoverSpellEvent.Source.COMMAND))){ properties.discoverSpell(spell); - sender.addChatMessage(new TextComponentTranslation("commands.wizardry:discoverspell.addspell", spell.getNameForTranslationFormatted(), player.getName())); + sender.sendMessage(new TextComponentTranslation("commands.wizardry:discoverspell.addspell", + spell.getNameForTranslationFormatted(), player.getName())); } } } diff --git a/src/main/java/electroblob/wizardry/command/CommandSetAlly.java b/src/main/java/electroblob/wizardry/command/CommandSetAlly.java index b566306c..d45fe222 100644 --- a/src/main/java/electroblob/wizardry/command/CommandSetAlly.java +++ b/src/main/java/electroblob/wizardry/command/CommandSetAlly.java @@ -21,7 +21,7 @@ import net.minecraft.util.text.TextFormatting; public class CommandSetAlly extends CommandBase { @Override - public String getCommandName(){ + public String getName(){ return Wizardry.settings.allyCommandName; } @@ -32,30 +32,32 @@ public class CommandSetAlly extends CommandBase { } @Override - public boolean checkPermission(MinecraftServer server, ICommandSender p_71519_1_) - { + public boolean checkPermission(MinecraftServer server, ICommandSender p_71519_1_){ return true; } @Override - public String getCommandUsage(ICommandSender p_71518_1_){ + public String getUsage(ICommandSender p_71518_1_){ // Not ideal, but the way this is implemented means I have no choice. Only used in the help command, so in there // the custom command name will not display. return "commands.wizardry:ally.usage"; - //return I18n.format("commands.wizardry:ally.usage", Wizardry.settings.allyCommandName); + // return I18n.format("commands.wizardry:ally.usage", Wizardry.settings.allyCommandName); } @Override - public List getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] arguments, BlockPos pos) { + public List getTabCompletions(MinecraftServer server, ICommandSender sender, String[] arguments, + BlockPos pos){ switch(arguments.length){ - case 1: return getListOfStringsMatchingLastWord(arguments, server.getAllUsernames()); - case 2: return getListOfStringsMatchingLastWord(arguments, server.getAllUsernames()); + case 1: + return getListOfStringsMatchingLastWord(arguments, server.getOnlinePlayerNames()); + case 2: + return getListOfStringsMatchingLastWord(arguments, server.getOnlinePlayerNames()); } - return super.getTabCompletionOptions(server, sender, arguments, pos); + return super.getTabCompletions(server, sender, arguments, pos); } @Override - public void execute(MinecraftServer server, ICommandSender sender, String[] arguments) throws CommandException { + public void execute(MinecraftServer server, ICommandSender sender, String[] arguments) throws CommandException{ if(arguments.length < 1){ throw new WrongUsageException("commands.wizardry:ally.usage", Wizardry.settings.allyCommandName); @@ -65,8 +67,9 @@ public class CommandSetAlly extends CommandBase { try{ allyOf = getCommandSenderAsPlayer(sender); - }catch(PlayerNotFoundException exception){ - // Nothing here since the player specifying is done later, I just don't want it to throw an exception here. + }catch (PlayerNotFoundException exception){ + // Nothing here since the player specifying is done later, I just don't want it to throw an exception + // here. } boolean executeAsOtherPlayer = false; @@ -79,11 +82,13 @@ public class CommandSetAlly extends CommandBase { allyOf = getPlayer(server, sender, arguments[1]); // Don't want to catch the exception here either, because there can be no other second argument. - if(allyOf != sender && sender instanceof EntityPlayer && !WizardryUtilities.isPlayerOp((EntityPlayer)sender, server)){ + if(allyOf != sender && sender instanceof EntityPlayer + && !WizardryUtilities.isPlayerOp((EntityPlayer)sender, server)){ // Displays a chat message if a non-op tries to modify another player's allies. - TextComponentTranslation TextComponentTranslation2 = new TextComponentTranslation("commands.wizardry:ally.permission"); + TextComponentTranslation TextComponentTranslation2 = new TextComponentTranslation( + "commands.wizardry:ally.permission"); TextComponentTranslation2.getStyle().setColor(TextFormatting.RED); - allyOf.addChatMessage(TextComponentTranslation2); + allyOf.sendMessage(TextComponentTranslation2); return; } @@ -92,18 +97,20 @@ public class CommandSetAlly extends CommandBase { // If, after this point, allyOf is still null, the sender must be a command block or the console and two // players must not have been specified, meaning an exception should be thrown. - if(allyOf == null) throw new PlayerNotFoundException("You must specify which player you wish to perform this action on."); + if(allyOf == null) + throw new PlayerNotFoundException("You must specify which player you wish to perform this action on."); if(allyOf == ally) throw new NumberInvalidException("commands.wizardry:ally.self"); if(WizardData.get(allyOf) != null){ String string = WizardData.get(allyOf).toggleAlly(ally) ? "add" : "remove"; if(executeAsOtherPlayer){ - sender.addChatMessage(new TextComponentTranslation("commands.wizardry:ally." + string + "ally", ally.getName(), allyOf.getName())); + sender.sendMessage(new TextComponentTranslation("commands.wizardry:ally." + string + "ally", + ally.getName(), allyOf.getName())); // In this case, the player whose allies have been modified is also notified. - allyOf.addChatMessage(new TextComponentTranslation("item.wand." + string + "ally", ally.getName())); + allyOf.sendMessage(new TextComponentTranslation("item.wand." + string + "ally", ally.getName())); }else{ - sender.addChatMessage(new TextComponentTranslation("item.wand." + string + "ally", ally.getName())); + sender.sendMessage(new TextComponentTranslation("item.wand." + string + "ally", ally.getName())); } } diff --git a/src/main/java/electroblob/wizardry/command/CommandViewAllies.java b/src/main/java/electroblob/wizardry/command/CommandViewAllies.java index 257b4b85..0942e088 100644 --- a/src/main/java/electroblob/wizardry/command/CommandViewAllies.java +++ b/src/main/java/electroblob/wizardry/command/CommandViewAllies.java @@ -21,7 +21,7 @@ import net.minecraft.util.text.TextFormatting; public class CommandViewAllies extends CommandBase { @Override - public String getCommandName(){ + public String getName(){ return Wizardry.settings.alliesCommandName; } @@ -30,37 +30,38 @@ public class CommandViewAllies extends CommandBase { // I *think* it's something like 0 = everyone, 1 = moderator, 2 = op/admin, 3 = op/console... return 0; } - - @Override - public boolean checkPermission(MinecraftServer server, ICommandSender p_71519_1_) - { - return true; - } @Override - public String getCommandUsage(ICommandSender p_71518_1_){ + public boolean checkPermission(MinecraftServer server, ICommandSender p_71519_1_){ + return true; + } + + @Override + public String getUsage(ICommandSender p_71518_1_){ // Not ideal, but the way this is implemented means I have no choice. Only used in the help command, so in there // the custom command name will not display. return "commands.wizardry:allies.usage"; - //return I18n.format("commands.wizardry:allies.usage", Wizardry.settings.alliesCommandName); + // return I18n.format("commands.wizardry:allies.usage", Wizardry.settings.alliesCommandName); } @Override - public List getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] arguments, BlockPos pos) { + public List getTabCompletions(MinecraftServer server, ICommandSender sender, String[] arguments, + BlockPos pos){ switch(arguments.length){ - case 1: return getListOfStringsMatchingLastWord(arguments, server.getAllUsernames()); + case 1: + return getListOfStringsMatchingLastWord(arguments, server.getOnlinePlayerNames()); } - return super.getTabCompletionOptions(server, sender, arguments, pos); + return super.getTabCompletions(server, sender, arguments, pos); } @Override - public void execute(MinecraftServer server, ICommandSender sender, String[] arguments) throws CommandException { + public void execute(MinecraftServer server, ICommandSender sender, String[] arguments) throws CommandException{ EntityPlayerMP player = null; try{ player = getCommandSenderAsPlayer(sender); - }catch(PlayerNotFoundException exception){ + }catch (PlayerNotFoundException exception){ // Nothing here since the player specifying is done later, I just don't want it to throw an exception here. } @@ -70,12 +71,14 @@ public class CommandViewAllies extends CommandBase { player = getPlayer(server, sender, arguments[0]); // Don't want to catch the exception here either, because there can be no other first argument. - - if(player != sender && sender instanceof EntityPlayer && !WizardryUtilities.isPlayerOp((EntityPlayer)sender, server)){ - // Displays a chat message if a non-op tries to view another player's allies. - TextComponentTranslation TextComponentTranslation2 = new TextComponentTranslation("commands.wizardry:allies.permission"); + + if(player != sender && sender instanceof EntityPlayer + && !WizardryUtilities.isPlayerOp((EntityPlayer)sender, server)){ + // Displays a chat message if a non-op tries to view another player's allies. + TextComponentTranslation TextComponentTranslation2 = new TextComponentTranslation( + "commands.wizardry:allies.permission"); TextComponentTranslation2.getStyle().setColor(TextFormatting.RED); - player.addChatMessage(TextComponentTranslation2); + player.sendMessage(TextComponentTranslation2); return; } @@ -84,7 +87,8 @@ public class CommandViewAllies extends CommandBase { // If, after this point, player is still null, the sender must be a command block or the console and the // player must not have been specified, meaning an exception should be thrown. - if(player == null) throw new PlayerNotFoundException("You must specify which player you wish to perform this action on."); + if(player == null) + throw new PlayerNotFoundException("You must specify which player you wish to perform this action on."); if(WizardData.get(player) != null){ @@ -102,9 +106,10 @@ public class CommandViewAllies extends CommandBase { } if(executeAsOtherPlayer){ - sender.addChatMessage(new TextComponentTranslation("commands.wizardry:allies.list_other", player.getName(), string)); + sender.sendMessage( + new TextComponentTranslation("commands.wizardry:allies.list_other", player.getName(), string)); }else{ - sender.addChatMessage(new TextComponentTranslation("commands.wizardry:allies.list", string)); + sender.sendMessage(new TextComponentTranslation("commands.wizardry:allies.list", string)); } } } diff --git a/src/main/java/electroblob/wizardry/constants/Constants.java b/src/main/java/electroblob/wizardry/constants/Constants.java index 95b79b9c..28bba9a9 100644 --- a/src/main/java/electroblob/wizardry/constants/Constants.java +++ b/src/main/java/electroblob/wizardry/constants/Constants.java @@ -15,10 +15,12 @@ public final class Constants { public static final float COOLDOWN_REDUCTION_PER_LEVEL = 0.15f; /** The fraction by which maximum charge is increased for each level of storage upgrade. */ public static final float STORAGE_INCREASE_PER_LEVEL = 0.15f; - /** The fraction by which damage is increased for each tier of matching wand. */ + /** The fraction by which damage is increased for each tier of matching wand. */ public static final float DAMAGE_INCREASE_PER_TIER = 0.15f; - /** The fraction by which costs are reduced for each piece of matching armour. Note that changing this value will not - * affect continuous spells, since they are handled differently. */ + /** + * The fraction by which costs are reduced for each piece of matching armour. Note that changing this value will not + * affect continuous spells, since they are handled differently. + */ public static final float COST_REDUCTION_PER_ARMOUR = 0.2f; /** The fraction by which spell duration is increased for each level of duration upgrade. */ public static final float DURATION_INCREASE_PER_LEVEL = 0.25f; @@ -34,11 +36,15 @@ public final class Constants { public static final float FROST_FATIGUE_PER_LEVEL = 0.45f; /** The number of ticks between each mana increase for wands with the condenser upgrade. */ public static final int CONDENSER_TICK_INTERVAL = 50; - /** The amount of mana given for a kill for each level of siphon upgrade. A random amount from 0 to this number - 1 - * is also added. See {@link WizardryEventHandler#onLivingDeathEvent} for more details. */ + /** + * The amount of mana given for a kill for each level of siphon upgrade. A random amount from 0 to this number - 1 + * is also added. See {@link WizardryEventHandler#onLivingDeathEvent} for more details. + */ public static final int SIPHON_MANA_PER_LEVEL = 3; - /** The number of ticks between the spawning of patches of decay when an entity has the decay effect. - * Note that decay won't spawn again if something is already standing in it. */ + /** + * The number of ticks between the spawning of patches of decay when an entity has the decay effect. Note that decay + * won't spawn again if something is already standing in it. + */ public static final int DECAY_SPREAD_INTERVAL = 8; } diff --git a/src/main/java/electroblob/wizardry/constants/Element.java b/src/main/java/electroblob/wizardry/constants/Element.java index 48dd01f4..5d310c39 100644 --- a/src/main/java/electroblob/wizardry/constants/Element.java +++ b/src/main/java/electroblob/wizardry/constants/Element.java @@ -10,24 +10,27 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public enum Element { - - /** The 'default' element, with {@link electroblob.wizardry.spell.MagicMissile MagicMissile} being its only spell. */ - MAGIC(new Style().setColor(TextFormatting.GRAY), "simple", Wizardry.MODID), - FIRE(new Style().setColor(TextFormatting.DARK_RED), "fire", Wizardry.MODID), - ICE(new Style().setColor(TextFormatting.AQUA), "ice", Wizardry.MODID), - LIGHTNING(new Style().setColor(TextFormatting.DARK_AQUA), "lightning", Wizardry.MODID), - NECROMANCY(new Style().setColor(TextFormatting.DARK_PURPLE), "necromancy", Wizardry.MODID), - EARTH(new Style().setColor(TextFormatting.DARK_GREEN), "earth", Wizardry.MODID), - SORCERY(new Style().setColor(TextFormatting.GREEN), "sorcery", Wizardry.MODID), - HEALING(new Style().setColor(TextFormatting.YELLOW), "healing", Wizardry.MODID); - + + /** + * The 'default' element, with {@link electroblob.wizardry.spell.MagicMissile MagicMissile} being its only spell. + */ + MAGIC(new Style().setColor(TextFormatting.GRAY), "simple", Wizardry.MODID), FIRE( + new Style().setColor(TextFormatting.DARK_RED), "fire", + Wizardry.MODID), ICE(new Style().setColor(TextFormatting.AQUA), "ice", Wizardry.MODID), LIGHTNING( + new Style().setColor(TextFormatting.DARK_AQUA), "lightning", + Wizardry.MODID), NECROMANCY(new Style().setColor(TextFormatting.DARK_PURPLE), "necromancy", + Wizardry.MODID), EARTH(new Style().setColor(TextFormatting.DARK_GREEN), "earth", + Wizardry.MODID), SORCERY(new Style().setColor(TextFormatting.GREEN), "sorcery", + Wizardry.MODID), HEALING(new Style().setColor(TextFormatting.YELLOW), + "healing", Wizardry.MODID); + /** Display colour for this element */ private final Style colour; /** Unlocalised name for this element */ private final String unlocalisedName; /** The {@link ResourceLocation} for this element's 8x8 icon (displayed in the arcane workbench GUI) */ private final ResourceLocation icon; - + private Element(Style colour, String name, String modid){ this.colour = colour; this.unlocalisedName = name; @@ -39,7 +42,7 @@ public enum Element { public String getDisplayName(){ return net.minecraft.client.resources.I18n.format("element." + getUnlocalisedName()); } - + /** Returns the {@link Style} object representing the colour of this element. */ public Style getColour(){ return colour; diff --git a/src/main/java/electroblob/wizardry/constants/SpellType.java b/src/main/java/electroblob/wizardry/constants/SpellType.java index 807d878c..cd48eac7 100644 --- a/src/main/java/electroblob/wizardry/constants/SpellType.java +++ b/src/main/java/electroblob/wizardry/constants/SpellType.java @@ -4,14 +4,11 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public enum SpellType { - - ATTACK("attack"), - DEFENCE("defence"), - UTILITY("utility"), - MINION("minion"); + + ATTACK("attack"), DEFENCE("defence"), UTILITY("utility"), MINION("minion"); private final String unlocalisedName; - + SpellType(String name){ this.unlocalisedName = name; } diff --git a/src/main/java/electroblob/wizardry/constants/Tier.java b/src/main/java/electroblob/wizardry/constants/Tier.java index f989b82b..20d94016 100644 --- a/src/main/java/electroblob/wizardry/constants/Tier.java +++ b/src/main/java/electroblob/wizardry/constants/Tier.java @@ -8,12 +8,12 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public enum Tier { - - BASIC(700, 3, 12, new Style().setColor(TextFormatting.WHITE), "basic"), - APPRENTICE(1000, 4, 5, new Style().setColor(TextFormatting.AQUA), "apprentice"), - ADVANCED(1500, 5, 2, new Style().setColor(TextFormatting.DARK_BLUE), "advanced"), - MASTER(2500, 6, 1, new Style().setColor(TextFormatting.DARK_PURPLE), "master"); - + + BASIC(700, 3, 12, new Style().setColor(TextFormatting.WHITE), "basic"), APPRENTICE(1000, 4, 5, + new Style().setColor(TextFormatting.AQUA), "apprentice"), ADVANCED(1500, 5, 2, + new Style().setColor(TextFormatting.DARK_BLUE), + "advanced"), MASTER(2500, 6, 1, new Style().setColor(TextFormatting.DARK_PURPLE), "master"); + /** Maximum mana a wand of this tier can store. */ public final int maxCharge; /** Just an ordinal. Shouldn't really be needed but no point changing it now. */ @@ -25,9 +25,9 @@ public enum Tier { /** The colour of text associated with this tier. */ // Changed to a Style object for consistency. private final Style colour; - + private final String unlocalisedName; - + private Tier(int maxCharge, int upgradeLimit, int weight, Style colour, String name){ this.maxCharge = maxCharge; this.level = ordinal(); @@ -38,15 +38,15 @@ public enum Tier { } @SideOnly(Side.CLIENT) - public String getDisplayName() { + public String getDisplayName(){ return net.minecraft.client.resources.I18n.format("tier." + unlocalisedName); } - + @SideOnly(Side.CLIENT) - public String getDisplayNameWithFormatting() { + public String getDisplayNameWithFormatting(){ return this.getFormattingCode() + net.minecraft.client.resources.I18n.format("tier." + unlocalisedName); } - + public String getUnlocalisedName(){ return unlocalisedName; } @@ -54,28 +54,31 @@ public enum Tier { public String getFormattingCode(){ return colour.getFormattingCode(); } - - /** Returns a random tier based on the standard weighting. Currently, the standard weighting is: Basic (Novice) 60%, + + /** + * Returns a random tier based on the standard weighting. Currently, the standard weighting is: Basic (Novice) 60%, * Apprentice 25%, Advanced 10%, Master 5%. If an array of tiers is given, it picks a tier from the array, with the * same relative weights for each. For example, if the array contains APPRENTICE and MASTER, then the weighting will - * become: Apprentice 83.3%, Master 16.7%. */ + * become: Apprentice 83.3%, Master 16.7%. + */ public static Tier getWeightedRandomTier(Random random, Tier... tiers){ - + if(tiers.length == 0) tiers = values(); - + int totalWeight = 0; - - for(Tier tier : tiers) totalWeight += tier.weight; - + + for(Tier tier : tiers) + totalWeight += tier.weight; + int randomiser = random.nextInt(totalWeight); int cumulativeWeight = 0; - + for(Tier tier : tiers){ cumulativeWeight += tier.weight; if(randomiser < cumulativeWeight) return tier; } - + // This will never happen, but it might as well be a sensible result. - return tiers[tiers.length-1]; + return tiers[tiers.length - 1]; } } diff --git a/src/main/java/electroblob/wizardry/enchantment/EnchantmentMagicSword.java b/src/main/java/electroblob/wizardry/enchantment/EnchantmentMagicSword.java index 0aca94ba..f3be13e3 100644 --- a/src/main/java/electroblob/wizardry/enchantment/EnchantmentMagicSword.java +++ b/src/main/java/electroblob/wizardry/enchantment/EnchantmentMagicSword.java @@ -10,50 +10,48 @@ import net.minecraft.item.ItemStack; // into the damage increase for melee weapons, meaning I don't have to use events - always handy! public class EnchantmentMagicSword extends EnchantmentDamage implements Imbuement { - public EnchantmentMagicSword() { + public EnchantmentMagicSword(){ super(Enchantment.Rarity.COMMON, 0, EntityEquipmentSlot.MAINHAND); // Setting this to null stops the book appearing in the creative inventory this.type = null; } - + @Override public boolean canApply(ItemStack p_92089_1_){ - return false; - } + return false; + } - /** - * Returns the maximum level that the enchantment can have. - */ + /** + * Returns the maximum level that the enchantment can have. + */ // Here, enchantment level is the damage multiplier of the spell used to apply the enchantment, i.e. with an - // non-sorcerer wand it is level 1, a basic sorcerer wand is level 2, and so on. Note that basic sorcerer wands can't + // non-sorcerer wand it is level 1, a basic sorcerer wand is level 2, and so on. Note that basic sorcerer wands + // can't // cast the imbue weapon spell, so level 2 is actually for apprentice wands. - @Override - public int getMaxLevel() - { - return 4; - } + @Override + public int getMaxLevel(){ + return 4; + } - // Returns the number by which the damage should be increased (or something) - @Override - public float calcDamageByCreature(int p_152376_1_, EnumCreatureAttribute p_152376_2_) - { - return (float)p_152376_1_ * 1.25F; - } + // Returns the number by which the damage should be increased (or something) + @Override + public float calcDamageByCreature(int p_152376_1_, EnumCreatureAttribute p_152376_2_){ + return (float)p_152376_1_ * 1.25F; + } + + @Override + public String getName(){ + return "enchantment." + this.getRegistryName(); + } + + @Override + public boolean isAllowedOnBooks(){ + return false; + } + + @Override + public boolean canApplyAtEnchantingTable(ItemStack stack){ + return false; + } - @Override - public String getName() - { - return "enchantment." + this.getRegistryName(); - } - - @Override - public boolean isAllowedOnBooks(){ - return false; - } - - @Override - public boolean canApplyAtEnchantingTable(ItemStack stack) { - return false; - } - } diff --git a/src/main/java/electroblob/wizardry/enchantment/EnchantmentTimed.java b/src/main/java/electroblob/wizardry/enchantment/EnchantmentTimed.java index d30252d1..4f5338e3 100644 --- a/src/main/java/electroblob/wizardry/enchantment/EnchantmentTimed.java +++ b/src/main/java/electroblob/wizardry/enchantment/EnchantmentTimed.java @@ -6,43 +6,42 @@ import net.minecraft.item.ItemStack; // This one is for everything other than imbued swords. public class EnchantmentTimed extends Enchantment implements Imbuement { - - public EnchantmentTimed() { + + public EnchantmentTimed(){ // Setting enchantment type to null stops the book appearing in the creative inventory super(Enchantment.Rarity.COMMON, null, new EntityEquipmentSlot[]{EntityEquipmentSlot.MAINHAND}); } - + @Override public boolean canApply(ItemStack p_92089_1_){ - return false; - } - - @Override - public String getName() - { - return "enchantment." + this.getRegistryName(); - } + return false; + } - /** - * Returns the maximum level that the enchantment can have. - */ + @Override + public String getName(){ + return "enchantment." + this.getRegistryName(); + } + + /** + * Returns the maximum level that the enchantment can have. + */ // Here, enchantment level is the damage multiplier of the spell used to apply the enchantment, i.e. with an - // non-sorcerer wand it is level 1, an apprentice sorcerer wand is level 2, and so on. Note that basic sorcerer wands can't + // non-sorcerer wand it is level 1, an apprentice sorcerer wand is level 2, and so on. Note that basic sorcerer + // wands can't // cast the imbue weapon spell, so level 2 is actually for apprentice wands. - @Override - public int getMaxLevel() - { - return 4; - } - - @Override - public boolean isAllowedOnBooks(){ - return false; - } - - @Override - public boolean canApplyAtEnchantingTable(ItemStack stack) { - return false; - } - + @Override + public int getMaxLevel(){ + return 4; + } + + @Override + public boolean isAllowedOnBooks(){ + return false; + } + + @Override + public boolean canApplyAtEnchantingTable(ItemStack stack){ + return false; + } + } diff --git a/src/main/java/electroblob/wizardry/enchantment/Imbuement.java b/src/main/java/electroblob/wizardry/enchantment/Imbuement.java index ac443d9a..67e70fd3 100644 --- a/src/main/java/electroblob/wizardry/enchantment/Imbuement.java +++ b/src/main/java/electroblob/wizardry/enchantment/Imbuement.java @@ -22,12 +22,15 @@ import net.minecraftforge.event.entity.player.PlayerContainerEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -/** Interface for temporary enchantments that last for a certain duration ('imbuements'). This interface allows - * {@link EnchantmentMagicSword} and {@link EnchantmentTimed} to both be treated as instances of a - * single type, rather than having to deal with each of them separately, - * which would be inefficient and cumbersome (the former of those classes cannot extend the latter because they both - * need to extend different subclasses of {@link net.minecraft.enchantment.Enchantment}). - * @since Wizardry 1.2 */ +/** + * Interface for temporary enchantments that last for a certain duration ('imbuements'). This interface allows + * {@link EnchantmentMagicSword} and {@link EnchantmentTimed} to both be treated as instances of a single type, rather + * than having to deal with each of them separately, which would be inefficient and cumbersome (the former of those + * classes cannot extend the latter because they both need to extend different subclasses of + * {@link net.minecraft.enchantment.Enchantment}). + * + * @since Wizardry 1.2 + */ @Mod.EventBusSubscriber public interface Imbuement { @@ -46,11 +49,12 @@ public interface Imbuement { // Instantly disenchants an imbued weapon if it is thrown on the ground. removeImbuements(event.getEntityItem().getEntityItem()); } - + /** Removes all imbuements from the given itemstack. */ static void removeImbuements(ItemStack stack){ if(stack.isItemEnchanted()){ - // No need to check what enchantments the item has, since remove() does nothing if the element does not exist. + // No need to check what enchantments the item has, since remove() does nothing if the element does not + // exist. Map enchantments = EnchantmentHelper.getEnchantments(stack); // Removes the magic weapon enchantments from the enchantment map enchantments.entrySet().removeIf(entry -> entry.getKey() instanceof Imbuement); @@ -58,7 +62,7 @@ public interface Imbuement { EnchantmentHelper.setEnchantments(enchantments, stack); } } - + @SubscribeEvent public static void onPlayerOpenContainerEvent(PlayerContainerEvent event){ // Brute-force fix to stop enchanted books in dungeon chests from having imbuements on them. @@ -74,7 +78,7 @@ public interface Imbuement { // If any imbuements were removed, replaces the enchantments on the book with the new ones, or // deletes the book entirely if there are none left. if(enchantments.isEmpty()){ - slot.putStack(null); // NOTE: Will need changing in 1.11 + slot.putStack(ItemStack.EMPTY); // NOTE: Will need changing in 1.11 Wizardry.logger.info("Deleted enchanted book with illegal enchantments"); }else{ EnchantmentHelper.setEnchantments(enchantments, slot.getStack()); @@ -90,7 +94,7 @@ public interface Imbuement { public static void onEntityJoinWorld(EntityJoinWorldEvent event){ // Rather long-winded (but necessary) way of getting an arrow just after it has been fired, checking if the bow // that fired it has the imbuement enchantment, and applying extra damage accordingly. - if(!event.getEntity().worldObj.isRemote && event.getEntity() instanceof EntityArrow){ + if(!event.getEntity().world.isRemote && event.getEntity() instanceof EntityArrow){ EntityArrow arrow = (EntityArrow)event.getEntity(); diff --git a/src/main/java/electroblob/wizardry/entity/EntityArc.java b/src/main/java/electroblob/wizardry/entity/EntityArc.java index dc68f0eb..695de2cd 100644 --- a/src/main/java/electroblob/wizardry/entity/EntityArc.java +++ b/src/main/java/electroblob/wizardry/entity/EntityArc.java @@ -7,19 +7,19 @@ import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; public class EntityArc extends Entity implements IEntityAdditionalSpawnData { - + public int textureIndex = 0; public double x1, y1, z1, x2, y2, z2; // The number of ticks the arc lasts for before disappearing public int lifetime = 3; public double offsetX, offsetZ; - public EntityArc(World par1World) { + public EntityArc(World par1World){ super(par1World); textureIndex = this.rand.nextInt(16); this.ignoreFrustumCheck = true; } - + public void setEndpointCoords(double x1, double y1, double z1, double x2, double y2, double z2){ this.x1 = x1; this.y1 = y1; @@ -27,7 +27,7 @@ public class EntityArc extends Entity implements IEntityAdditionalSpawnData { this.x2 = x2; this.y2 = y2; this.z2 = z2; - this.setPosition(x2, y2, z2); + this.setPosition(x2, y2, z2); } @Override @@ -36,38 +36,38 @@ public class EntityArc extends Entity implements IEntityAdditionalSpawnData { this.setDead(); } } - - protected void entityInit() - { - } - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - + protected void entityInit(){ } @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - // Nothing needed here; arc is merely a graphic effect that only exists for a few ticks; as such there is no need to save it. + protected void readEntityFromNBT(NBTTagCompound nbttagcompound){ + } - + @Override - public boolean isInRangeToRenderDist(double distance) { + protected void writeEntityToNBT(NBTTagCompound nbttagcompound){ + // Nothing needed here; arc is merely a graphic effect that only exists for a few ticks; as such there is no + // need to save it. + } + + @Override + public boolean isInRangeToRenderDist(double distance){ return true; } @Override - public void writeSpawnData(ByteBuf data) { + public void writeSpawnData(ByteBuf data){ data.writeDouble(this.x1); - data.writeDouble(this.y1); - data.writeDouble(this.z1); + data.writeDouble(this.y1); + data.writeDouble(this.z1); } @Override - public void readSpawnData(ByteBuf data) { + public void readSpawnData(ByteBuf data){ this.x1 = data.readDouble(); this.y1 = data.readDouble(); this.z1 = data.readDouble(); } - + } diff --git a/src/main/java/electroblob/wizardry/entity/EntityMeteor.java b/src/main/java/electroblob/wizardry/entity/EntityMeteor.java index fce647ce..89140ca1 100644 --- a/src/main/java/electroblob/wizardry/entity/EntityMeteor.java +++ b/src/main/java/electroblob/wizardry/entity/EntityMeteor.java @@ -5,6 +5,7 @@ import electroblob.wizardry.registry.WizardryBlocks; import electroblob.wizardry.registry.WizardrySounds; import electroblob.wizardry.util.WizardryUtilities; import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.MoverType; import net.minecraft.entity.item.EntityFallingBlock; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; @@ -14,99 +15,106 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class EntityMeteor extends EntityFallingBlock { - - /** The entity blast multiplier. Only some projectiles cause a blast, which is why this isn't in EntityMagicProjectile. */ + + /** + * The entity blast multiplier. Only some projectiles cause a blast, which is why this isn't in + * EntityMagicProjectile. + */ public float blastMultiplier; - public EntityMeteor(World world){ - super(world); - // Superconstructor doesn't call this. - this.setSize(0.98F, 0.98F); - } + public EntityMeteor(World world){ + super(world); + // Superconstructor doesn't call this. + this.setSize(0.98F, 0.98F); + } - public EntityMeteor(World world, double x, double y, double z, float blastMultiplier){ - super(world, x, y, z, WizardryBlocks.meteor.getDefaultState()); - this.motionY = -1.0D; - this.setFire(200); - this.blastMultiplier = blastMultiplier; - } - - @Override - public double getYOffset() { - return this.height / 2.0F; - } + public EntityMeteor(World world, double x, double y, double z, float blastMultiplier){ + super(world, x, y, z, WizardryBlocks.meteor.getDefaultState()); + this.motionY = -1.0D; + this.setFire(200); + this.blastMultiplier = blastMultiplier; + } - @Override - public void onUpdate(){ - - if(this.ticksExisted % 16 == 1 && worldObj.isRemote){ - Wizardry.proxy.playMovingSound(this, WizardrySounds.SPELL_LOOP_FIRE, 3.0f, 1.0f, false); + @Override + public double getYOffset(){ + return this.height / 2.0F; + } + + @Override + public void onUpdate(){ + + if(this.ticksExisted % 16 == 1 && world.isRemote){ + Wizardry.proxy.playMovingSound(this, WizardrySounds.SPELL_LOOP_FIRE, 3.0f, 1.0f, false); } - - // You'd think the best way to do this would be to call super and do all the exploding stuff in fall() instead. - // However, for some reason, fallTile is null on the client side, causing an NPE in super.onUpdate() - - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - ++this.fallTime; - this.motionY -= 0.1d; //0.03999999910593033D; - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.9800000190734863D; - this.motionY *= 0.9800000190734863D; - this.motionZ *= 0.9800000190734863D; - if(!this.worldObj.isRemote){ - - if(this.onGround){ - - this.motionX *= 0.699999988079071D; - this.motionZ *= 0.699999988079071D; - this.motionY *= -0.5D; - this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 2.0f*blastMultiplier, true); - for(int i1=-3; i1<4; i1++){ - for(int j1=-3; j1<4; j1++){ - int y = WizardryUtilities.getNearestFloorLevelB(this.worldObj, new BlockPos(this.posX + i1, this.posY, this.posZ + j1), 7); - //System.out.println(y); + // You'd think the best way to do this would be to call super and do all the exploding stuff in fall() instead. + // However, for some reason, fallTile is null on the client side, causing an NPE in super.onUpdate() + + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + ++this.fallTime; + this.motionY -= 0.1d; // 0.03999999910593033D; + this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if(!this.world.isRemote){ + + if(this.onGround){ + + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + this.motionY *= -0.5D; + this.world.createExplosion(this, this.posX, this.posY, this.posZ, 2.0f * blastMultiplier, true); + for(int i1 = -3; i1 < 4; i1++){ + for(int j1 = -3; j1 < 4; j1++){ + int y = WizardryUtilities.getNearestFloorLevelB(this.world, + new BlockPos(this.posX + i1, this.posY, this.posZ + j1), 7); + // System.out.println(y); double dist = this.getDistance((int)this.posX + i1, y, (int)this.posZ + j1); - // Randomised with weighting so that the nearer the block the more likely it is to be set on fire. - if(y != -1 && rand.nextInt((int)dist*2 + 1) < 3 && dist < 4){ - this.worldObj.setBlockState(new BlockPos(this.posX + i1, y, this.posZ + j1), Blocks.FIRE.getDefaultState()); + // Randomised with weighting so that the nearer the block the more likely it is to be set on + // fire. + if(y != -1 && rand.nextInt((int)dist * 2 + 1) < 3 && dist < 4){ + this.world.setBlockState(new BlockPos(this.posX + i1, y, this.posZ + j1), + Blocks.FIRE.getDefaultState()); } } } - this.setDead(); - } - } - } + this.setDead(); + } + } + } - @Override - public void fall(float distance, float damageMultiplier){ - // Don't need to do anything here, the meteor should have already exploded. - } - - @SideOnly(Side.CLIENT) - @Override - public boolean canRenderOnFire(){ - return true; - } + @Override + public void fall(float distance, float damageMultiplier){ + // Don't need to do anything here, the meteor should have already exploded. + } - @Override - public IBlockState getBlock(){ - return WizardryBlocks.meteor.getDefaultState(); // For some reason the superclass version returns null on the client - } - - @SideOnly(Side.CLIENT) - @Override - public int getBrightnessForRender(float partialTicks){ - return 15728880; - } + @SideOnly(Side.CLIENT) + @Override + public boolean canRenderOnFire(){ + return true; + } + + @Override + public IBlockState getBlock(){ + return WizardryBlocks.meteor.getDefaultState(); // For some reason the superclass version returns null on the + // client + } + + @SideOnly(Side.CLIENT) + @Override + public int getBrightnessForRender(float partialTicks){ + return 15728880; + } + + @Override + public float getBrightness(float partialTicks){ + return 1.0F; + } - @Override - public float getBrightness(float partialTicks){ - return 1.0F; - } - @Override public boolean isInRangeToRenderDist(double distance){ return true; @@ -114,8 +122,8 @@ public class EntityMeteor extends EntityFallingBlock { @Override public void readEntityFromNBT(NBTTagCompound nbttagcompound){ - super.readEntityFromNBT(nbttagcompound); - blastMultiplier = nbttagcompound.getFloat("blastMultiplier"); + super.readEntityFromNBT(nbttagcompound); + blastMultiplier = nbttagcompound.getFloat("blastMultiplier"); } @Override @@ -123,5 +131,5 @@ public class EntityMeteor extends EntityFallingBlock { super.writeEntityToNBT(nbttagcompound); nbttagcompound.setFloat("blastMultiplier", blastMultiplier); } - + } diff --git a/src/main/java/electroblob/wizardry/entity/EntityShield.java b/src/main/java/electroblob/wizardry/entity/EntityShield.java index c884ea07..1ca7df78 100644 --- a/src/main/java/electroblob/wizardry/entity/EntityShield.java +++ b/src/main/java/electroblob/wizardry/entity/EntityShield.java @@ -14,9 +14,9 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.World; public class EntityShield extends Entity { - + public WeakReference player; - + public EntityShield(World world){ super(world); this.noClip = true; @@ -24,70 +24,73 @@ public class EntityShield extends Entity { this.height = 1.4f; } - public EntityShield(World par1World, EntityPlayer player) { + public EntityShield(World par1World, EntityPlayer player){ super(par1World); this.width = 1.2f; this.height = 1.4f; this.player = new WeakReference(player); this.noClip = true; - this.setPositionAndRotation(player.posX + player.getLookVec().xCoord, player.posY + 1 + player.getLookVec().yCoord, player.posZ + player.getLookVec().zCoord, player.rotationYawHead, player.rotationPitch); - this.setEntityBoundingBox(new AxisAlignedBB(this.posX - 0.6f, this.posY - 0.7f, this.posZ - 0.6f, this.posX + 0.6f, this.posY + 0.7f, this.posZ + 0.6f)); + this.setPositionAndRotation(player.posX + player.getLookVec().xCoord, + player.posY + 1 + player.getLookVec().yCoord, player.posZ + player.getLookVec().zCoord, + player.rotationYawHead, player.rotationPitch); + this.setEntityBoundingBox(new AxisAlignedBB(this.posX - 0.6f, this.posY - 0.7f, this.posZ - 0.6f, + this.posX + 0.6f, this.posY + 0.7f, this.posZ + 0.6f)); } @Override public void onUpdate(){ - //System.out.println("Shield exists, ID: " + this.getUniqueID().toString()); + // System.out.println("Shield exists, ID: " + this.getUniqueID().toString()); EntityPlayer entityplayer = player != null ? player.get() : null; if(entityplayer != null){ - this.setPositionAndRotation(entityplayer.posX + entityplayer.getLookVec().xCoord*0.3, entityplayer.posY + 1 + entityplayer.getLookVec().yCoord*0.3, entityplayer.posZ + entityplayer.getLookVec().zCoord*0.3, entityplayer.rotationYawHead, entityplayer.rotationPitch); - if(!entityplayer.isHandActive() || entityplayer.getHeldItem(entityplayer.getActiveHand()) == null || !(entityplayer.getHeldItem(entityplayer.getActiveHand()).getItem() instanceof ItemWand)){ + this.setPositionAndRotation(entityplayer.posX + entityplayer.getLookVec().xCoord * 0.3, + entityplayer.posY + 1 + entityplayer.getLookVec().yCoord * 0.3, + entityplayer.posZ + entityplayer.getLookVec().zCoord * 0.3, entityplayer.rotationYawHead, + entityplayer.rotationPitch); + if(!entityplayer.isHandActive() || entityplayer.getHeldItem(entityplayer.getActiveHand()) == null + || !(entityplayer.getHeldItem(entityplayer.getActiveHand()).getItem() instanceof ItemWand)){ WizardData.get(entityplayer).shield = null; this.setDead(); } - }else if(!worldObj.isRemote){ + }else if(!world.isRemote){ this.setDead(); } } - + // Overrides the original to stop the entity moving when it intersects stuff. The default arrow does this to allow - // it to stick in blocks. - public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) - { - this.setPosition(par1, par3, par5); - this.setRotation(par7, par8); - } - - public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) - { + // it to stick in blocks. + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9){ + this.setPosition(par1, par3, par5); + this.setRotation(par7, par8); + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2){ if(par1DamageSource != null && par1DamageSource.getSourceOfDamage() instanceof IProjectile){ par1DamageSource.getSourceOfDamage().playSound(WizardrySounds.SPELL_DEFLECTION, 0.3f, 1.3f); } super.attackEntityFrom(par1DamageSource, par2); return false; - } - - public boolean canBeCollidedWith() - { - return !this.isDead; - } - - public AxisAlignedBB getCollisionBox(Entity par1Entity) - { - return par1Entity.getEntityBoundingBox(); - } - - @Override - protected void entityInit() { - + } + + public boolean canBeCollidedWith(){ + return !this.isDead; + } + + public AxisAlignedBB getCollisionBox(Entity par1Entity){ + return par1Entity.getEntityBoundingBox(); } @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { + protected void entityInit(){ } @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { + protected void readEntityFromNBT(NBTTagCompound nbttagcompound){ + + } + + @Override + protected void writeEntityToNBT(NBTTagCompound nbttagcompound){ } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityArrowRain.java b/src/main/java/electroblob/wizardry/entity/construct/EntityArrowRain.java index ddee05da..1ad7632d 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityArrowRain.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityArrowRain.java @@ -7,32 +7,34 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class EntityArrowRain extends EntityMagicConstruct { - - public EntityArrowRain(World par1World) { + + public EntityArrowRain(World par1World){ super(par1World); this.height = 3.0f; this.width = 5.0f; } - - public EntityArrowRain(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, float damageMultiplier) { + + public EntityArrowRain(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, + float damageMultiplier){ super(world, x, y, z, caster, lifetime, damageMultiplier); this.height = 3.0f; this.width = 5.0f; } - + public void onUpdate(){ - + super.onUpdate(); - - if(!this.worldObj.isRemote){ - EntityTippedArrow arrow = new EntityTippedArrow(worldObj, this.posX + rand.nextDouble()*6 - 3, this.posY + rand.nextDouble()*4 - 2, this.posZ + rand.nextDouble()*6 - 3); + + if(!this.world.isRemote){ + EntityTippedArrow arrow = new EntityTippedArrow(world, this.posX + rand.nextDouble() * 6 - 3, + this.posY + rand.nextDouble() * 4 - 2, this.posZ + rand.nextDouble() * 6 - 3); arrow.motionX = Math.cos(Math.toRadians(this.rotationYaw + 90)); arrow.motionY = -0.6; arrow.motionZ = Math.sin(Math.toRadians(this.rotationYaw + 90)); arrow.shootingEntity = this.getCaster(); - arrow.setDamage(7.0d*damageMultiplier); + arrow.setDamage(7.0d * damageMultiplier); arrow.setPotionEffect(new ItemStack(Items.ARROW)); - this.worldObj.spawnEntityInWorld(arrow); + this.world.spawnEntity(arrow); } } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityBlackHole.java b/src/main/java/electroblob/wizardry/entity/construct/EntityBlackHole.java index 56f85762..75f550e8 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityBlackHole.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityBlackHole.java @@ -25,38 +25,39 @@ public class EntityBlackHole extends EntityMagicConstruct { this.width = 6.0f; this.height = 3.0f; randomiser = new int[30]; - for(int i=0; i targets = WizardryUtilities.getEntitiesWithinRadius(6.0d, this.posX, this.posY, this.posZ, this.worldObj); + List targets = WizardryUtilities.getEntitiesWithinRadius(6.0d, this.posX, this.posY, + this.posZ, this.world); - if(!this.worldObj.isRemote){ + if(!this.world.isRemote){ for(EntityLivingBase target : targets){ @@ -92,21 +99,21 @@ public class EntityBlackHole extends EntityMagicConstruct { // Sucks the target in if(this.posX > target.posX && target.motionX < 1){ - target.motionX+=0.1; + target.motionX += 0.1; }else if(this.posX < target.posX && target.motionX > -1){ - target.motionX-=0.1; + target.motionX -= 0.1; } if(this.posY > target.posY && target.motionY < 1){ - target.motionY+=0.1; + target.motionY += 0.1; }else if(this.posY < target.posY && target.motionY > -1){ - target.motionY-=0.1; + target.motionY -= 0.1; } if(this.posZ > target.posZ && target.motionZ < 1){ - target.motionZ+=0.1; + target.motionZ += 0.1; }else if(this.posZ < target.posZ && target.motionZ > -1){ - target.motionZ-=0.1; + target.motionZ -= 0.1; } // Player motion is handled on that player's client so needs packets @@ -117,9 +124,11 @@ public class EntityBlackHole extends EntityMagicConstruct { if(this.getDistanceToEntity(target) <= 2){ // Damages the target if it is close enough if(this.getCaster() != null){ - target.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.MAGIC), 2*damageMultiplier); + target.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.MAGIC), + 2 * damageMultiplier); }else{ - target.attackEntityFrom(DamageSource.magic, 2*damageMultiplier); + target.attackEntityFrom(DamageSource.MAGIC, 2 * damageMultiplier); } } } @@ -130,8 +139,7 @@ public class EntityBlackHole extends EntityMagicConstruct { /** * Checks using a Vec3dd to determine if this entity is within range of that vector to be rendered. Args: Vec3dD */ - public boolean isInRangeToRenderVec3dD(Vec3d par1Vec3d) - { + public boolean isInRangeToRenderVec3dD(Vec3d par1Vec3d){ return true; } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityBlizzard.java b/src/main/java/electroblob/wizardry/entity/construct/EntityBlizzard.java index 342ad185..50ecabd4 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityBlizzard.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityBlizzard.java @@ -16,13 +16,14 @@ import net.minecraft.world.World; public class EntityBlizzard extends EntityMagicConstruct { - public EntityBlizzard(World par1World) { + public EntityBlizzard(World par1World){ super(par1World); this.height = 1.0f; this.width = 1.0f; } - public EntityBlizzard(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, float damageMultiplier) { + public EntityBlizzard(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, + float damageMultiplier){ super(world, x, y, z, caster, lifetime, damageMultiplier); this.height = 1.0f; this.width = 1.0f; @@ -36,21 +37,25 @@ public class EntityBlizzard extends EntityMagicConstruct { super.onUpdate(); - if(!this.worldObj.isRemote){ + if(!this.world.isRemote){ - List targets = WizardryUtilities.getEntitiesWithinRadius(3.0d, this.posX, this.posY, this.posZ, this.worldObj); + List targets = WizardryUtilities.getEntitiesWithinRadius(3.0d, this.posX, this.posY, + this.posZ, this.world); for(EntityLivingBase target : targets){ if(this.isValidTarget(target)){ if(this.getCaster() != null){ - WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.FROST), 1*damageMultiplier); + WizardryUtilities.attackEntityWithoutKnockback(target, + MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.FROST), + 1 * damageMultiplier); }else{ - WizardryUtilities.attackEntityWithoutKnockback(target, DamageSource.magic, 1*damageMultiplier); + WizardryUtilities.attackEntityWithoutKnockback(target, DamageSource.MAGIC, + 1 * damageMultiplier); } } - + // All entities are slowed, even the caster (except those immune to frost effects) if(!MagicDamage.isEntityImmune(DamageType.FROST, target)) target.addPotionEffect(new PotionEffect(WizardryPotions.frost, 20, 0)); @@ -58,10 +63,14 @@ public class EntityBlizzard extends EntityMagicConstruct { }else{ // For some reason this number of particles now causes the game to lag significantly, despite it being fine // in 1.7.10. I thought particles were supposed to be LESS laggy now... - for(int i=1; i<6; i++){ - float brightness = 0.5f + (rand.nextFloat()/2); - Wizardry.proxy.spawnParticle(WizardryParticleType.BLIZZARD, worldObj, this.posX, this.posY + rand.nextDouble()*3, this.posZ, 0, 0, 0, 100, brightness, brightness + 0.1f, 1.0f, false, rand.nextDouble() * 2.5d + 0.5d); - Wizardry.proxy.spawnParticle(WizardryParticleType.BLIZZARD, worldObj, this.posX, this.posY + rand.nextDouble()*3, this.posZ, 0, 0, 0, 100, 1.0f, 1.0f, 1.0f, false, rand.nextDouble() * 2.5d + 0.5d); + for(int i = 1; i < 6; i++){ + float brightness = 0.5f + (rand.nextFloat() / 2); + Wizardry.proxy.spawnParticle(WizardryParticleType.BLIZZARD, world, this.posX, + this.posY + rand.nextDouble() * 3, this.posZ, 0, 0, 0, 100, brightness, brightness + 0.1f, 1.0f, + false, rand.nextDouble() * 2.5d + 0.5d); + Wizardry.proxy.spawnParticle(WizardryParticleType.BLIZZARD, world, this.posX, + this.posY + rand.nextDouble() * 3, this.posZ, 0, 0, 0, 100, 1.0f, 1.0f, 1.0f, false, + rand.nextDouble() * 2.5d + 0.5d); } } } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityBubble.java b/src/main/java/electroblob/wizardry/entity/construct/EntityBubble.java index 620fb9ee..a864526b 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityBubble.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityBubble.java @@ -7,6 +7,7 @@ import electroblob.wizardry.util.MagicDamage.DamageType; import electroblob.wizardry.util.WizardryUtilities; import io.netty.buffer.ByteBuf; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.MoverType; import net.minecraft.init.SoundEvents; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; @@ -18,79 +19,89 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @Mod.EventBusSubscriber public class EntityBubble extends EntityMagicConstruct { - + public boolean isDarkOrb; - + private WeakReference rider; - + public EntityBubble(World world){ super(world); } - public EntityBubble(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, boolean isDarkOrb, float damageMultiplier) { + public EntityBubble(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, + boolean isDarkOrb, float damageMultiplier){ super(world, x, y, z, caster, lifetime, damageMultiplier); - //this.setSize(0.1f, 0.1f); + // this.setSize(0.1f, 0.1f); this.isDarkOrb = isDarkOrb; } - + @Override - public double getMountedYOffset() - { - return 0.1; - } - + public double getMountedYOffset(){ + return 0.1; + } + @Override public boolean shouldRiderSit(){ return false; } - + public void onUpdate(){ - + super.onUpdate(); - + // Synchronises the rider field - if((this.rider == null || this.rider.get() == null) && WizardryUtilities.getRider(this) instanceof EntityLivingBase + if((this.rider == null || this.rider.get() == null) + && WizardryUtilities.getRider(this) instanceof EntityLivingBase && !WizardryUtilities.getRider(this).isDead){ - this.rider = new WeakReference((EntityLivingBase) WizardryUtilities.getRider(this)); + this.rider = new WeakReference((EntityLivingBase)WizardryUtilities.getRider(this)); } - + // Prevents dismounting - if(WizardryUtilities.getRider(this) == null && this.rider != null && this.rider.get() != null && !this.rider.get().isDead){ + if(WizardryUtilities.getRider(this) == null && this.rider != null && this.rider.get() != null + && !this.rider.get().isDead){ this.rider.get().startRiding(this); } - + // Stops the bubble bursting instantly. if(this.ticksExisted < 1 && !isDarkOrb) ((EntityLivingBase)WizardryUtilities.getRider(this)).hurtTime = 0; - - this.moveEntity(0, 0.03, 0); - + + this.move(MoverType.SELF, 0, 0.03, 0); + if(isDarkOrb){ - + if(WizardryUtilities.getRider(this) != null && this.ticksExisted % 30 == 0){ if(this.getCaster() != null){ - WizardryUtilities.getRider(this).attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.MAGIC), 1*damageMultiplier); + WizardryUtilities.getRider(this).attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.MAGIC), + 1 * damageMultiplier); }else{ - WizardryUtilities.getRider(this).attackEntityFrom(DamageSource.magic, 1*damageMultiplier); + WizardryUtilities.getRider(this).attackEntityFrom(DamageSource.MAGIC, 1 * damageMultiplier); } } - - for(int i=0; i<5; i++){ - this.worldObj.spawnParticle(EnumParticleTypes.PORTAL, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height + 0.5d, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (this.rand.nextDouble() - 0.5D) * 2.0D); - } + + for(int i = 0; i < 5; i++){ + this.world.spawnParticle(EnumParticleTypes.PORTAL, + this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, + this.posY + this.rand.nextDouble() * (double)this.height + 0.5d, + this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, + (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), + (this.rand.nextDouble() - 0.5D) * 2.0D); + } if(lifetime - this.ticksExisted == 75){ this.playSound(SoundEvents.BLOCK_PORTAL_TRIGGER, 1.5f, 1.0f); }else if(this.ticksExisted % 100 == 1 && this.ticksExisted < 150){ this.playSound(SoundEvents.BLOCK_PORTAL_AMBIENT, 1.5f, 1.0f); } } - - // Bubble bursts if the entity is hurt (see event handler) or killed, or if the bubble has existed for more than 10 seconds. + + // Bubble bursts if the entity is hurt (see event handler) or killed, or if the bubble has existed for more than + // 10 seconds. if(WizardryUtilities.getRider(this) == null && this.ticksExisted > 1){ if(!this.isDarkOrb) this.playSound(SoundEvents.ENTITY_ITEM_PICKUP, 1.5f, 1.0f); this.setDead(); } } - + @Override public void despawn(){ if(WizardryUtilities.getRider(this) != null){ @@ -101,34 +112,34 @@ public class EntityBubble extends EntityMagicConstruct { } @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { + protected void readEntityFromNBT(NBTTagCompound nbttagcompound){ super.readEntityFromNBT(nbttagcompound); isDarkOrb = nbttagcompound.getBoolean("isDarkOrb"); } @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { + protected void writeEntityToNBT(NBTTagCompound nbttagcompound){ super.writeEntityToNBT(nbttagcompound); nbttagcompound.setBoolean("isDarkOrb", isDarkOrb); } @Override - public void writeSpawnData(ByteBuf data) { + public void writeSpawnData(ByteBuf data){ super.writeSpawnData(data); data.writeBoolean(this.isDarkOrb); } @Override - public void readSpawnData(ByteBuf data) { + public void readSpawnData(ByteBuf data){ super.readSpawnData(data); this.isDarkOrb = data.readBoolean(); } - + @SubscribeEvent public static void onLivingAttackEvent(LivingAttackEvent event){ // Bursts bubble when the creature inside takes damage - if(event.getEntityLiving().getRidingEntity() instanceof EntityBubble && - !((EntityBubble)event.getEntityLiving().getRidingEntity()).isDarkOrb){ + if(event.getEntityLiving().getRidingEntity() instanceof EntityBubble + && !((EntityBubble)event.getEntityLiving().getRidingEntity()).isDarkOrb){ event.getEntityLiving().getRidingEntity().playSound(SoundEvents.ENTITY_ITEM_PICKUP, 1.5f, 1.0f); event.getEntityLiving().getRidingEntity().setDead(); } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityDecay.java b/src/main/java/electroblob/wizardry/entity/construct/EntityDecay.java index f8d33151..a2835764 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityDecay.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityDecay.java @@ -14,18 +14,18 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; public class EntityDecay extends EntityMagicConstruct { - + public int textureIndex = 0; public static final int LIFETIME = 400; - - public EntityDecay(World par1World) { + + public EntityDecay(World par1World){ super(par1World); textureIndex = this.rand.nextInt(10); this.height = 0.2f; this.width = 2.0f; } - - public EntityDecay(World par1World, double x, double y, double z, EntityLivingBase caster) { + + public EntityDecay(World par1World, double x, double y, double z, EntityLivingBase caster){ super(par1World, x, y, z, caster, LIFETIME, 1); textureIndex = this.rand.nextInt(10); this.height = 0.2f; @@ -34,45 +34,51 @@ public class EntityDecay extends EntityMagicConstruct { @Override public void onUpdate(){ - + super.onUpdate(); - - if(this.rand.nextInt(700) == 0 && this.ticksExisted+100 < LIFETIME) this.playSound(SoundEvents.BLOCK_LAVA_AMBIENT, 0.2F + rand.nextFloat() * 0.2F, 0.6F + rand.nextFloat() * 0.15F); - - if(!this.worldObj.isRemote){ - List targets = WizardryUtilities.getEntitiesWithinRadius(1.0d, this.posX, this.posY, this.posZ, this.worldObj); + + if(this.rand.nextInt(700) == 0 && this.ticksExisted + 100 < LIFETIME) + this.playSound(SoundEvents.BLOCK_LAVA_AMBIENT, 0.2F + rand.nextFloat() * 0.2F, + 0.6F + rand.nextFloat() * 0.15F); + + if(!this.world.isRemote){ + List targets = WizardryUtilities.getEntitiesWithinRadius(1.0d, this.posX, this.posY, + this.posZ, this.world); for(EntityLivingBase target : targets){ if(target != this.getCaster()){ - // If this check wasn't here the potion would be reapplied every tick and hence the entity would be damaged each tick. + // If this check wasn't here the potion would be reapplied every tick and hence the entity would be + // damaged each tick. // In this case, we do want particles to be shown. - if(!target.isPotionActive(WizardryPotions.decay)) target.addPotionEffect(new PotionEffect(WizardryPotions.decay, LIFETIME, 0)); + if(!target.isPotionActive(WizardryPotions.decay)) + target.addPotionEffect(new PotionEffect(WizardryPotions.decay, LIFETIME, 0)); } } }else if(this.rand.nextInt(15) == 0){ - double radius = rand.nextDouble()*0.8; - double angle = rand.nextDouble()*Math.PI*2; - float brightness = rand.nextFloat()*0.4f; - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, worldObj, this.posX + radius*Math.cos(angle), this.posY, this.posZ + radius*Math.sin(angle), 0, 0, 0, 0, brightness, 0, brightness+0.1f); + double radius = rand.nextDouble() * 0.8; + double angle = rand.nextDouble() * Math.PI * 2; + float brightness = rand.nextFloat() * 0.4f; + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, this.posX + radius * Math.cos(angle), + this.posY, this.posZ + radius * Math.sin(angle), 0, 0, 0, 0, brightness, 0, brightness + 0.1f); } } - - protected void entityInit(){} - @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - + protected void entityInit(){ } @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { + protected void readEntityFromNBT(NBTTagCompound nbttagcompound){ + + } + + @Override + protected void writeEntityToNBT(NBTTagCompound nbttagcompound){ } /** - * Checks using a Vec3dd to determine if this entity is within range of that vector to be rendered. Args: Vec3dD - */ - public boolean isInRangeToRenderVec3dD(Vec3d par1Vec3d) - { - return true; - } + * Checks using a Vec3dd to determine if this entity is within range of that vector to be rendered. Args: Vec3dD + */ + public boolean isInRangeToRenderVec3dD(Vec3d par1Vec3d){ + return true; + } } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityEarthquake.java b/src/main/java/electroblob/wizardry/entity/construct/EntityEarthquake.java index 10d32231..82a46b9f 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityEarthquake.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityEarthquake.java @@ -23,7 +23,7 @@ public class EntityEarthquake extends EntityMagicConstruct { } public EntityEarthquake(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, - float damageMultiplier) { + float damageMultiplier){ super(world, x, y, z, caster, lifetime, damageMultiplier); this.height = 1.0f; this.width = 1.0f; @@ -33,48 +33,58 @@ public class EntityEarthquake extends EntityMagicConstruct { super.onUpdate(); - if(!worldObj.isRemote){ + if(!world.isRemote){ double speed = 0.4; // The further the earthquake is going to spread, the finer the angle increments. - for(double angle=0; angle < 2*Math.PI; angle+=Math.PI/(lifetime*1.5)){ + for(double angle = 0; angle < 2 * Math.PI; angle += Math.PI / (lifetime * 1.5)){ - // Calculates coordinates for the block to be moved. The radius increases with time. The +1.5 is to leave + // Calculates coordinates for the block to be moved. The radius increases with time. The +1.5 is to + // leave // blocks in the centre untouched. - int x = this.posX < 0 ? (int)(this.posX + ((this.ticksExisted*speed)+1.5)*Math.sin(angle) - 1) : (int)(this.posX + ((this.ticksExisted*speed)+1.5)*Math.sin(angle)); + int x = this.posX < 0 ? (int)(this.posX + ((this.ticksExisted * speed) + 1.5) * Math.sin(angle) - 1) + : (int)(this.posX + ((this.ticksExisted * speed) + 1.5) * Math.sin(angle)); int y = (int)(this.posY - 0.5); - int z = this.posZ < 0 ? (int)(this.posZ + ((this.ticksExisted*speed)+1.5)*Math.cos(angle) - 1) : (int)(this.posZ + ((this.ticksExisted*speed)+1.5)*Math.cos(angle)); + int z = this.posZ < 0 ? (int)(this.posZ + ((this.ticksExisted * speed) + 1.5) * Math.cos(angle) - 1) + : (int)(this.posZ + ((this.ticksExisted * speed) + 1.5) * Math.cos(angle)); BlockPos pos = new BlockPos(x, y, z); - if(!WizardryUtilities.isBlockUnbreakable(worldObj, pos) && !worldObj.isAirBlock(pos) && worldObj.isBlockNormalCube(pos, false) + if(!WizardryUtilities.isBlockUnbreakable(world, pos) && !world.isAirBlock(pos) + && world.isBlockNormalCube(pos, false) // Checks that the block above is not solid, since this causes the falling sand to vanish. - && !worldObj.isBlockNormalCube(pos.up(), false)){ + && !world.isBlockNormalCube(pos.up(), false)){ // Falling blocks do the setting block to air themselves. - EntityFallingBlock fallingblock = new EntityFallingBlock(worldObj, x+0.5, y+0.5, z+0.5, worldObj.getBlockState(new BlockPos(x, y, z))); + EntityFallingBlock fallingblock = new EntityFallingBlock(world, x + 0.5, y + 0.5, z + 0.5, + world.getBlockState(new BlockPos(x, y, z))); fallingblock.motionY = 0.3; - worldObj.spawnEntityInWorld(fallingblock); + world.spawnEntity(fallingblock); } } - List targets = WizardryUtilities.getEntitiesWithinRadius((this.ticksExisted*speed)+1.5, this.posX, this.posY, this.posZ, worldObj); + List targets = WizardryUtilities + .getEntitiesWithinRadius((this.ticksExisted * speed) + 1.5, this.posX, this.posY, this.posZ, world); - // In this particular instance, the caster is completely unaffected because they will always be in the centre. + // In this particular instance, the caster is completely unaffected because they will always be in the + // centre. targets.remove(this.getCaster()); for(EntityLivingBase target : targets){ // Searches in a 1 wide ring. - if(this.getDistanceToEntity(target) > (this.ticksExisted*speed)+0.5 && target.posY < this.posY + 1 && target.posY > this.posY - 1){ + if(this.getDistanceToEntity(target) > (this.ticksExisted * speed) + 0.5 && target.posY < this.posY + 1 + && target.posY > this.posY - 1){ // Knockback must be removed in this instance, or the target will fall into the floor. double motionX = target.motionX; double motionZ = target.motionZ; if(this.isValidTarget(target)){ - target.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getCaster(), DamageType.BLAST), 10*this.damageMultiplier); + target.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, this.getCaster(), DamageType.BLAST), + 10 * this.damageMultiplier); target.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 400, 1)); } @@ -89,18 +99,19 @@ public class EntityEarthquake extends EntityMagicConstruct { } } } - // TODO: Uncomment once 2.1.0 is released -// }else{ -// -// // Constant 15 blocks for now -// List targets = WizardryUtilities.getEntitiesWithinRadius(15, this.posX, this.posY, this.posZ, worldObj, EntityPlayer.class); -// -// float magnitude = 6f * ((float)(this.lifetime - this.ticksExisted))/(float)this.lifetime; -// -// // Makes the screen shake -// for(EntityLivingBase target : targets){ -// target.setAngles(0, this.ticksExisted % 4 < 2 ? magnitude : -magnitude); -// } + // TODO: Uncomment once 2.1.0 is released + // }else{ + // + // // Constant 15 blocks for now + // List targets = WizardryUtilities.getEntitiesWithinRadius(15, this.posX, this.posY, + // this.posZ, world, EntityPlayer.class); + // + // float magnitude = 6f * ((float)(this.lifetime - this.ticksExisted))/(float)this.lifetime; + // + // // Makes the screen shake + // for(EntityLivingBase target : targets){ + // target.setAngles(0, this.ticksExisted % 4 < 2 ? magnitude : -magnitude); + // } } } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityFireRing.java b/src/main/java/electroblob/wizardry/entity/construct/EntityFireRing.java index e2055da5..97ed7876 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityFireRing.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityFireRing.java @@ -11,50 +11,54 @@ import net.minecraft.util.DamageSource; import net.minecraft.world.World; public class EntityFireRing extends EntityMagicConstruct { - - public EntityFireRing(World par1World) { + + public EntityFireRing(World par1World){ super(par1World); this.height = 1.0f; this.width = 5.0f; } - - public EntityFireRing(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, float damageMultiplier) { + + public EntityFireRing(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, + float damageMultiplier){ super(world, x, y, z, caster, lifetime, damageMultiplier); this.height = 1.0f; this.width = 5.0f; } - + public void onUpdate(){ - + if(this.ticksExisted % 40 == 1){ this.playSound(SoundEvents.BLOCK_FIRE_AMBIENT, 4.0f, 0.7f); } - + super.onUpdate(); - - if(!this.worldObj.isRemote){ - - List targets = WizardryUtilities.getEntitiesWithinRadius(2.5d, this.posX, this.posY, this.posZ, this.worldObj); - + + if(!this.world.isRemote){ + + List targets = WizardryUtilities.getEntitiesWithinRadius(2.5d, this.posX, this.posY, + this.posZ, this.world); + for(EntityLivingBase target : targets){ - + if(this.isValidTarget(target)){ double velX = target.motionX; double velY = target.motionY; double velZ = target.motionZ; - + if(!MagicDamage.isEntityImmune(DamageType.FIRE, target)){ - + target.setFire(10); - + if(this.getCaster() != null){ - target.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.FIRE), 1*damageMultiplier); + target.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.FIRE), + 1 * damageMultiplier); }else{ - target.attackEntityFrom(DamageSource.magic, 1*damageMultiplier); + target.attackEntityFrom(DamageSource.MAGIC, 1 * damageMultiplier); } } - + // Removes knockback target.motionX = velX; target.motionY = velY; diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityFireSigil.java b/src/main/java/electroblob/wizardry/entity/construct/EntityFireSigil.java index 9913006e..ecf45f74 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityFireSigil.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityFireSigil.java @@ -13,13 +13,14 @@ import net.minecraft.world.World; public class EntityFireSigil extends EntityMagicConstruct { - public EntityFireSigil(World par1World) { + public EntityFireSigil(World par1World){ super(par1World); this.height = 0.2f; this.width = 2.0f; } - public EntityFireSigil(World par1World, double x, double y, double z, EntityLivingBase caster, float damageMultiplier) { + public EntityFireSigil(World par1World, double x, double y, double z, EntityLivingBase caster, + float damageMultiplier){ super(par1World, x, y, z, caster, -1, damageMultiplier); this.height = 0.2f; this.width = 2.0f; @@ -27,8 +28,7 @@ public class EntityFireSigil extends EntityMagicConstruct { // Overrides the original to stop the entity moving when it intersects stuff. The default arrow does this to allow // it to stick in blocks. - public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) - { + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9){ this.setPosition(par1, par3, par5); this.setRotation(par7, par8); } @@ -37,9 +37,10 @@ public class EntityFireSigil extends EntityMagicConstruct { super.onUpdate(); - if(!this.worldObj.isRemote){ + if(!this.world.isRemote){ - List targets = WizardryUtilities.getEntitiesWithinRadius(1.0d, this.posX, this.posY, this.posZ, this.worldObj); + List targets = WizardryUtilities.getEntitiesWithinRadius(1.0d, this.posX, this.posY, + this.posZ, this.world); for(EntityLivingBase target : targets){ @@ -48,8 +49,10 @@ public class EntityFireSigil extends EntityMagicConstruct { double velX = target.motionX; double velY = target.motionY; double velZ = target.motionZ; - - target.attackEntityFrom(this.getCaster() != null ? MagicDamage.causeIndirectMagicDamage(this, this.getCaster(), DamageType.FIRE) : DamageSource.magic, 6); + + target.attackEntityFrom(this.getCaster() != null + ? MagicDamage.causeIndirectMagicDamage(this, this.getCaster(), DamageType.FIRE) + : DamageSource.MAGIC, 6); // Removes knockback target.motionX = velX; @@ -59,28 +62,28 @@ public class EntityFireSigil extends EntityMagicConstruct { if(!MagicDamage.isEntityImmune(DamageType.FIRE, target)) target.setFire(10); this.playSound(SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1); - + // The trap is destroyed once triggered. this.setDead(); } } }else if(this.rand.nextInt(15) == 0){ - double radius = 0.5 + rand.nextDouble()*0.3; - double angle = rand.nextDouble()*Math.PI*2; - worldObj.spawnParticle(EnumParticleTypes.FLAME, this.posX + radius*Math.cos(angle), this.posY + 0.1, this.posZ + radius*Math.sin(angle), 0, 0, 0); + double radius = 0.5 + rand.nextDouble() * 0.3; + double angle = rand.nextDouble() * Math.PI * 2; + world.spawnParticle(EnumParticleTypes.FLAME, this.posX + radius * Math.cos(angle), this.posY + 0.1, + this.posZ + radius * Math.sin(angle), 0, 0, 0); } } @Override - protected void entityInit() { + protected void entityInit(){ } /** * Return whether this entity should be rendered as on fire. */ - public boolean canRenderOnFire() - { + public boolean canRenderOnFire(){ return false; } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityForcefield.java b/src/main/java/electroblob/wizardry/entity/construct/EntityForcefield.java index f0f817eb..3e4e2a25 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityForcefield.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityForcefield.java @@ -16,42 +16,44 @@ import net.minecraft.world.World; public class EntityForcefield extends EntityMagicConstruct { - public EntityForcefield(World world) { + public EntityForcefield(World world){ super(world); this.height = 6; this.width = 6; - this.setEntityBoundingBox(new AxisAlignedBB(this.posX - 3, this.posY - 3, this.posZ - 3, this.posX + 3, this.posY + 3, this.posZ + 3)); + this.setEntityBoundingBox(new AxisAlignedBB(this.posX - 3, this.posY - 3, this.posZ - 3, this.posX + 3, + this.posY + 3, this.posZ + 3)); } - - public EntityForcefield(World world, double x, double y, double z, EntityLivingBase caster, int lifetime) { + + public EntityForcefield(World world, double x, double y, double z, EntityLivingBase caster, int lifetime){ // y-3 because it needs to be centred on the given position // Damage multiplier is 1 because forcefields do no damage! - super(world, x, y-3, z, caster, lifetime, 1.0f); + super(world, x, y - 3, z, caster, lifetime, 1.0f); this.height = 6; this.width = 6; - this.setEntityBoundingBox(new AxisAlignedBB(this.posX - 3, this.posY - 3, this.posZ - 3, this.posX + 3, this.posY + 3, this.posZ + 3)); + this.setEntityBoundingBox(new AxisAlignedBB(this.posX - 3, this.posY - 3, this.posZ - 3, this.posX + 3, + this.posY + 3, this.posZ + 3)); } - - public boolean canBeCollidedWith() - { - return !this.isDead; - } - - public AxisAlignedBB getCollisionBox(Entity par1Entity) - { - return par1Entity.getEntityBoundingBox(); - } - + + public boolean canBeCollidedWith(){ + return !this.isDead; + } + + public AxisAlignedBB getCollisionBox(Entity par1Entity){ + return par1Entity.getEntityBoundingBox(); + } + public void onUpdate(){ - + super.onUpdate(); - - if(!this.worldObj.isRemote){ - List targets = WizardryUtilities.getEntitiesWithinRadius(3.5, this.posX, this.posY + 3, this.posZ, this.worldObj); + + if(!this.world.isRemote){ + List targets = WizardryUtilities.getEntitiesWithinRadius(3.5, this.posX, this.posY + 3, + this.posZ, this.world); for(EntityLivingBase target : targets){ if(this.isValidTarget(target)){ - double multiplier = (3.5 - target.getDistance(this.posX, this.posY+3, this.posZ))*0.1; - target.addVelocity((target.posX - this.posX)*multiplier, (target.posY - (this.posY + 3))*multiplier, (target.posZ - this.posZ)*multiplier); + double multiplier = (3.5 - target.getDistance(this.posX, this.posY + 3, this.posZ)) * 0.1; + target.addVelocity((target.posX - this.posX) * multiplier, + (target.posY - (this.posY + 3)) * multiplier, (target.posZ - this.posZ) * multiplier); // Player motion is handled on that player's client so needs packets if(target instanceof EntityPlayerMP){ ((EntityPlayerMP)target).connection.sendPacket(new SPacketEntityVelocity(target)); @@ -59,33 +61,35 @@ public class EntityForcefield extends EntityMagicConstruct { } } }else{ - for(int i=1; i<40; i++){ - float brightness = 0.5f + (rand.nextFloat()*0.5f); - double radius = 3; - double yaw = rand.nextDouble()*Math.PI*2; - double pitch = (rand.nextDouble()-0.5)*Math.PI; - // Generates a spherical pattern of particles - Wizardry.proxy.spawnParticle(WizardryParticleType.BRIGHT_DUST, worldObj, this.posX + radius*Math.cos(yaw)*Math.cos(pitch), this.posY + 3 + radius*Math.sin(pitch), this.posZ + radius*Math.sin(yaw)*Math.cos(pitch), 0, 0, 0, 48 + this.rand.nextInt(12), brightness, brightness, 1.0f); + for(int i = 1; i < 40; i++){ + float brightness = 0.5f + (rand.nextFloat() * 0.5f); + double radius = 3; + double yaw = rand.nextDouble() * Math.PI * 2; + double pitch = (rand.nextDouble() - 0.5) * Math.PI; + // Generates a spherical pattern of particles + Wizardry.proxy.spawnParticle(WizardryParticleType.BRIGHT_DUST, world, + this.posX + radius * Math.cos(yaw) * Math.cos(pitch), this.posY + 3 + radius * Math.sin(pitch), + this.posZ + radius * Math.sin(yaw) * Math.cos(pitch), 0, 0, 0, 48 + this.rand.nextInt(12), + brightness, brightness, 1.0f); } } } - + public boolean attackEntityFrom(DamageSource source, float par2){ - + if(source != null && source.getSourceOfDamage() != null){ // Now works for any source of damage. source.getSourceOfDamage().playSound(WizardrySounds.SPELL_DEFLECTION, 0.3f, 1.3f); } super.attackEntityFrom(source, par2); return false; - } - + } + /** - * Return whether this entity should be rendered as on fire. - */ - public boolean canRenderOnFire() - { - return false; - } + * Return whether this entity should be rendered as on fire. + */ + public boolean canRenderOnFire(){ + return false; + } } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityFrostSigil.java b/src/main/java/electroblob/wizardry/entity/construct/EntityFrostSigil.java index f2cb3ffe..7812ca96 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityFrostSigil.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityFrostSigil.java @@ -15,77 +15,80 @@ import net.minecraft.util.DamageSource; import net.minecraft.world.World; public class EntityFrostSigil extends EntityMagicConstruct { - - public EntityFrostSigil(World par1World) { + + public EntityFrostSigil(World par1World){ super(par1World); this.height = 0.2f; this.width = 2.0f; } - - public EntityFrostSigil(World par1World, double x, double y, double z, EntityLivingBase caster, float damageMultiplier) { + + public EntityFrostSigil(World par1World, double x, double y, double z, EntityLivingBase caster, + float damageMultiplier){ super(par1World, x, y, z, caster, -1, damageMultiplier); this.height = 0.2f; this.width = 2.0f; } - + // Overrides the original to stop the entity moving when it intersects stuff. The default arrow does this to allow - // it to stick in blocks. - public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) - { - this.setPosition(par1, par3, par5); - this.setRotation(par7, par8); - } - + // it to stick in blocks. + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9){ + this.setPosition(par1, par3, par5); + this.setRotation(par7, par8); + } + public void onUpdate(){ - + super.onUpdate(); - - if(!this.worldObj.isRemote){ - - List targets = WizardryUtilities.getEntitiesWithinRadius(1.0d, this.posX, this.posY, this.posZ, this.worldObj); - + + if(!this.world.isRemote){ + + List targets = WizardryUtilities.getEntitiesWithinRadius(1.0d, this.posX, this.posY, + this.posZ, this.world); + for(EntityLivingBase target : targets){ - + if(this.isValidTarget(target)){ double velX = target.motionX; double velY = target.motionY; double velZ = target.motionZ; - - target.attackEntityFrom(this.getCaster() != null ? MagicDamage.causeIndirectMagicDamage(this, this.getCaster(), DamageType.FROST) : DamageSource.magic, 8); - + + target.attackEntityFrom(this.getCaster() != null + ? MagicDamage.causeIndirectMagicDamage(this, this.getCaster(), DamageType.FROST) + : DamageSource.MAGIC, 8); + // Removes knockback target.motionX = velX; target.motionY = velY; target.motionZ = velZ; - + if(!MagicDamage.isEntityImmune(DamageType.FROST, target)) target.addPotionEffect(new PotionEffect(WizardryPotions.frost, 200, 1)); - + this.playSound(WizardrySounds.SPELL_FREEZE, 1.0f, 1.0f); - + // The trap is destroyed once triggered. this.setDead(); } } }else if(this.rand.nextInt(15) == 0){ - double radius = 0.5 + rand.nextDouble()*0.3; - double angle = rand.nextDouble()*Math.PI*2; - Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, worldObj, this.posX + radius*Math.cos(angle), this.posY + 0.1, this.posZ + radius*Math.sin(angle), 0, 0, 0, 40 + rand.nextInt(10)); + double radius = 0.5 + rand.nextDouble() * 0.3; + double angle = rand.nextDouble() * Math.PI * 2; + Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, this.posX + radius * Math.cos(angle), + this.posY + 0.1, this.posZ + radius * Math.sin(angle), 0, 0, 0, 40 + rand.nextInt(10)); } } @Override - protected void entityInit() { - + protected void entityInit(){ + } - + /** - * Return whether this entity should be rendered as on fire. - */ - public boolean canRenderOnFire() - { - return false; - } + * Return whether this entity should be rendered as on fire. + */ + public boolean canRenderOnFire(){ + return false; + } } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityHailstorm.java b/src/main/java/electroblob/wizardry/entity/construct/EntityHailstorm.java index 6b627bdd..5bb73e18 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityHailstorm.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityHailstorm.java @@ -5,32 +5,34 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.world.World; public class EntityHailstorm extends EntityMagicConstruct { - - public EntityHailstorm(World par1World) { + + public EntityHailstorm(World par1World){ super(par1World); this.height = 3.0f; this.width = 5.0f; } - - public EntityHailstorm(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, float damageMultiplier) { + + public EntityHailstorm(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, + float damageMultiplier){ super(world, x, y, z, caster, lifetime, damageMultiplier); this.height = 3.0f; this.width = 5.0f; } - + public void onUpdate(){ - + super.onUpdate(); - - if(!this.worldObj.isRemote){ - //System.out.println(this.rotationYaw); - EntityIceShard iceshard = new EntityIceShard(worldObj, this.posX + rand.nextDouble()*6 - 3, this.posY + rand.nextDouble()*4 - 2, this.posZ + rand.nextDouble()*6 - 3); + + if(!this.world.isRemote){ + // System.out.println(this.rotationYaw); + EntityIceShard iceshard = new EntityIceShard(world, this.posX + rand.nextDouble() * 6 - 3, + this.posY + rand.nextDouble() * 4 - 2, this.posZ + rand.nextDouble() * 6 - 3); iceshard.motionX = Math.cos(Math.toRadians(this.rotationYaw + 90)); iceshard.motionY = -0.6; iceshard.motionZ = Math.sin(Math.toRadians(this.rotationYaw + 90)); iceshard.setShootingEntity(this.getCaster()); iceshard.damageMultiplier = this.damageMultiplier; - this.worldObj.spawnEntityInWorld(iceshard); + this.world.spawnEntity(iceshard); } } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityHammer.java b/src/main/java/electroblob/wizardry/entity/construct/EntityHammer.java index 67950d41..13225ca7 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityHammer.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityHammer.java @@ -12,6 +12,7 @@ import electroblob.wizardry.util.WizardryUtilities; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.MoverType; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.init.SoundEvents; import net.minecraft.nbt.NBTTagCompound; @@ -23,161 +24,171 @@ import net.minecraft.world.World; public class EntityHammer extends EntityMagicConstruct { - /** How long the hammer has been falling for. */ - public int fallTime; + /** How long the hammer has been falling for. */ + public int fallTime; - public EntityHammer(World par1World){ - super(par1World); - this.setSize(1.0f, 1.9F); - this.noClip = false; - } + public EntityHammer(World par1World){ + super(par1World); + this.setSize(1.0f, 1.9F); + this.noClip = false; + } - public EntityHammer(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, float damageMultiplier){ - super(world, x, y, z, caster, lifetime, damageMultiplier); - this.setSize(1.0f, 1.9F); - this.motionX = 0.0D; - this.motionY = 0.0D; - this.motionZ = 0.0D; - this.noClip = false; - } - - @Override - public boolean isBurning(){ - return false; - } + public EntityHammer(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, + float damageMultiplier){ + super(world, x, y, z, caster, lifetime, damageMultiplier); + this.setSize(1.0f, 1.9F); + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + this.noClip = false; + } - @Override - public boolean canBeCollidedWith(){ - return true; - } - - @Override - public AxisAlignedBB getCollisionBoundingBox(){ - return this.getEntityBoundingBox(); - } + @Override + public boolean isBurning(){ + return false; + } - @Override - public void onUpdate(){ - - super.onUpdate(); - - if(this.ticksExisted % 20 == 1 && !this.onGround && worldObj.isRemote){ - // Though this sound does repeat, it stops when it hits the ground. - Wizardry.proxy.playMovingSound(this, WizardrySounds.SPELL_LOOP_LIGHTNING, 3.0f, 1.0f, false); + @Override + public boolean canBeCollidedWith(){ + return true; + } + + @Override + public AxisAlignedBB getCollisionBoundingBox(){ + return this.getEntityBoundingBox(); + } + + @Override + public void onUpdate(){ + + super.onUpdate(); + + if(this.ticksExisted % 20 == 1 && !this.onGround && world.isRemote){ + // Though this sound does repeat, it stops when it hits the ground. + Wizardry.proxy.playMovingSound(this, WizardrySounds.SPELL_LOOP_LIGHTNING, 3.0f, 1.0f, false); } - - if(this.worldObj.isRemote && this.ticksExisted % 3 == 0){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, worldObj, this.posX - 0.5d + rand.nextDouble(), this.posY + 2*rand.nextDouble(), this.posZ - 0.5d + rand.nextDouble(), 0, 0, 0, 3); - } - - if(!this.worldObj.isRemote){ - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - ++this.fallTime; - this.motionY -= 0.03999999910593033D; - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.9800000190734863D; - this.motionY *= 0.9800000190734863D; - this.motionZ *= 0.9800000190734863D; - - if(this.onGround){ - - this.motionX *= 0.699999988079071D; - this.motionZ *= 0.699999988079071D; - this.motionY *= -0.5D; - - if(this.ticksExisted % 40 == 0){ - - double seekerRange = 10.0d; - - List targets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, this.posX, this.posY+1, this.posZ, worldObj); - + if(this.world.isRemote && this.ticksExisted % 3 == 0){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, this.posX - 0.5d + rand.nextDouble(), + this.posY + 2 * rand.nextDouble(), this.posZ - 0.5d + rand.nextDouble(), 0, 0, 0, 3); + } + + if(!this.world.isRemote){ + + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + ++this.fallTime; + this.motionY -= 0.03999999910593033D; + this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if(this.onGround){ + + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + this.motionY *= -0.5D; + + if(this.ticksExisted % 40 == 0){ + + double seekerRange = 10.0d; + + List targets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, this.posX, + this.posY + 1, this.posZ, world); + // For this spell there is no limit to the amount of secondary targets! for(EntityLivingBase target : targets){ - + if(this.isValidTarget(target)){ - - if(!worldObj.isRemote){ - EntityArc arc = new EntityArc(worldObj); - arc.setEndpointCoords(this.posX, this.posY + this.height - 0.1, this.posZ, - target.posX, target.posY + target.height/2, target.posZ); - worldObj.spawnEntityInWorld(arc); + + if(!world.isRemote){ + EntityArc arc = new EntityArc(world); + arc.setEndpointCoords(this.posX, this.posY + this.height - 0.1, this.posZ, target.posX, + target.posY + target.height / 2, target.posZ); + world.spawnEntity(arc); }else{ - for(int j=0;j<8;j++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, worldObj, target.posX + worldObj.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + worldObj.rand.nextFloat()*2 - 1, target.posZ + worldObj.rand.nextFloat() - 0.5, 0, 0, 0, 3); - worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + rand.nextFloat(), target.getEntityBoundingBox().minY + target.height/2 + rand.nextFloat(), target.posZ + rand.nextFloat(), 0, 0, 0); - } + for(int j = 0; j < 8; j++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + target.posX + world.rand.nextFloat() - 0.5, + target.getEntityBoundingBox().minY + target.height / 2 + + world.rand.nextFloat() * 2 - 1, + target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); + world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + rand.nextFloat(), + target.getEntityBoundingBox().minY + target.height / 2 + rand.nextFloat(), + target.posZ + rand.nextFloat(), 0, 0, 0); + } } - + target.playSound(WizardrySounds.SPELL_SPARK, 1.0F, rand.nextFloat() * 0.4F + 1.5F); - + if(this.getCaster() != null){ - WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.SHOCK), 6*damageMultiplier); + WizardryUtilities.attackEntityWithoutKnockback(target, + MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.SHOCK), + 6 * damageMultiplier); WizardryUtilities.applyStandardKnockback(this, target); }else{ - target.attackEntityFrom(DamageSource.magic, 6*damageMultiplier); + target.attackEntityFrom(DamageSource.MAGIC, 6 * damageMultiplier); } } } - } - } - } - } - - @Override - public void despawn(){ - - this.playSound(SoundEvents.ENTITY_GENERIC_EXPLODE, 1.0F, 1.0f); - - if(this.worldObj.isRemote){ - this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 0, 0, 0); + } + } } - + } + + @Override + public void despawn(){ + + this.playSound(SoundEvents.ENTITY_GENERIC_EXPLODE, 1.0F, 1.0f); + + if(this.world.isRemote){ + this.world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 0, 0, 0); + } + super.despawn(); - } - - @Override - public void fall(float distance, float damageMultiplier) { - - if(worldObj.isRemote){ - for(int i=0; i<40; i++){ - double particleX = this.posX - 1.0d + 2*rand.nextDouble(); - double particleZ = this.posZ - 1.0d + 2*rand.nextDouble(); - // Roundabout way of getting a block instance for the block the hammer is standing on (if any). - IBlockState block = worldObj.getBlockState(new BlockPos(this.posX, this.posY-2, this.posZ)); + } + + @Override + public void fall(float distance, float damageMultiplier){ + + if(world.isRemote){ + for(int i = 0; i < 40; i++){ + double particleX = this.posX - 1.0d + 2 * rand.nextDouble(); + double particleZ = this.posZ - 1.0d + 2 * rand.nextDouble(); + // Roundabout way of getting a block instance for the block the hammer is standing on (if any). + IBlockState block = world.getBlockState(new BlockPos(this.posX, this.posY - 2, this.posZ)); if(block != null){ - worldObj.spawnParticle(EnumParticleTypes.BLOCK_DUST, particleX, this.posY, particleZ, + world.spawnParticle(EnumParticleTypes.BLOCK_DUST, particleX, this.posY, particleZ, particleX - this.posX, 0, particleZ - this.posZ, Block.getStateId(block)); } - } - }else{ + } + }else{ // Just to check the hammer has actually fallen from the sky, rather than the block under it being broken. - if(this.fallDistance > 10){ - EntityLightningBolt entitylightning = new EntityLightningBolt(worldObj, this.posX, this.posY, this.posZ, false); - worldObj.addWeatherEffect(entitylightning); - } - } - } + if(this.fallDistance > 10){ + EntityLightningBolt entitylightning = new EntityLightningBolt(world, this.posX, this.posY, this.posZ, + false); + world.addWeatherEffect(entitylightning); + } + } + } - @Override - public void writeEntityToNBT(NBTTagCompound nbttagcompound) - { - super.writeEntityToNBT(nbttagcompound); - nbttagcompound.setByte("Time", (byte)this.fallTime); - } + @Override + public void writeEntityToNBT(NBTTagCompound nbttagcompound){ + super.writeEntityToNBT(nbttagcompound); + nbttagcompound.setByte("Time", (byte)this.fallTime); + } - @Override - public void readEntityFromNBT(NBTTagCompound nbttagcompound) - { - super.readEntityFromNBT(nbttagcompound); - this.fallTime = nbttagcompound.getByte("Time") & 255; - } + @Override + public void readEntityFromNBT(NBTTagCompound nbttagcompound){ + super.readEntityFromNBT(nbttagcompound); + this.fallTime = nbttagcompound.getByte("Time") & 255; + } - @Override - public boolean isInRangeToRenderDist(double distance) { - return true; - } + @Override + public boolean isInRangeToRenderDist(double distance){ + return true; + } } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityHealAura.java b/src/main/java/electroblob/wizardry/entity/construct/EntityHealAura.java index 34a96dd8..25f93849 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityHealAura.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityHealAura.java @@ -14,13 +14,14 @@ import net.minecraft.world.World; public class EntityHealAura extends EntityMagicConstruct { - public EntityHealAura(World world) { + public EntityHealAura(World world){ super(world); this.height = 1.0f; this.width = 5.0f; } - public EntityHealAura(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, float damageMultiplier) { + public EntityHealAura(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, + float damageMultiplier){ super(world, x, y, z, caster, lifetime, damageMultiplier); this.height = 1.0f; this.width = 5.0f; @@ -34,9 +35,10 @@ public class EntityHealAura extends EntityMagicConstruct { super.onUpdate(); - if(!this.worldObj.isRemote){ + if(!this.world.isRemote){ - List targets = WizardryUtilities.getEntitiesWithinRadius(2.5d, this.posX, this.posY, this.posZ, this.worldObj); + List targets = WizardryUtilities.getEntitiesWithinRadius(2.5d, this.posX, this.posY, + this.posZ, this.world); for(EntityLivingBase target : targets){ @@ -49,9 +51,11 @@ public class EntityHealAura extends EntityMagicConstruct { double velZ = target.motionZ; if(this.getCaster() != null){ - target.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.RADIANT), 1*damageMultiplier); + target.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.RADIANT), + 1 * damageMultiplier); }else{ - target.attackEntityFrom(DamageSource.magic, 1*damageMultiplier); + target.attackEntityFrom(DamageSource.MAGIC, 1 * damageMultiplier); } // Removes knockback @@ -61,15 +65,17 @@ public class EntityHealAura extends EntityMagicConstruct { } }else if(target.getHealth() < target.getMaxHealth() && this.ticksExisted % 5 == 0){ - target.heal(1*damageMultiplier); + target.heal(1 * damageMultiplier); } } }else{ - for(int i=1; i<3; i++){ - float brightness = 0.5f + (rand.nextFloat()*0.5f); - double radius = rand.nextDouble()*2.0; - double angle = rand.nextDouble()*Math.PI*2; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, this.posX + radius*Math.cos(angle), this.posY, this.posZ + radius*Math.sin(angle), 0, 0.05f, 0, 48 + this.rand.nextInt(12), 1.0f, 1.0f, brightness); + for(int i = 1; i < 3; i++){ + float brightness = 0.5f + (rand.nextFloat() * 0.5f); + double radius = rand.nextDouble() * 2.0; + double angle = rand.nextDouble() * Math.PI * 2; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, this.posX + radius * Math.cos(angle), + this.posY, this.posZ + radius * Math.sin(angle), 0, 0.05f, 0, 48 + this.rand.nextInt(12), 1.0f, + 1.0f, brightness); } } } @@ -77,8 +83,7 @@ public class EntityHealAura extends EntityMagicConstruct { /** * Return whether this entity should be rendered as on fire. */ - public boolean canRenderOnFire() - { + public boolean canRenderOnFire(){ return false; } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityIceSpike.java b/src/main/java/electroblob/wizardry/entity/construct/EntityIceSpike.java index b314a2cf..d415480e 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityIceSpike.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityIceSpike.java @@ -5,45 +5,49 @@ import electroblob.wizardry.registry.WizardrySounds; import electroblob.wizardry.util.MagicDamage; import electroblob.wizardry.util.MagicDamage.DamageType; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.MoverType; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; public class EntityIceSpike extends EntityMagicConstruct { - public EntityIceSpike(World world) { + public EntityIceSpike(World world){ super(world); this.setSize(0.5f, 1.0f); } - - public EntityIceSpike(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, float damageMultiplier){ + + public EntityIceSpike(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, + float damageMultiplier){ super(world, x, y, z, caster, lifetime, damageMultiplier); this.setSize(0.5f, 1.0f); } - + public void onUpdate(){ - + if(lifetime - this.ticksExisted < 15){ - this.motionY = -0.01*(this.ticksExisted-(lifetime-15)); + this.motionY = -0.01 * (this.ticksExisted - (lifetime - 15)); }else if(lifetime - this.ticksExisted < 25){ this.motionY = 0; }else if(lifetime - this.ticksExisted < 28){ this.motionY = 0.25; } - - this.moveEntity(this.motionX, this.motionY, this.motionZ); - + + this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ); + if(lifetime - this.ticksExisted == 30) this.playSound(WizardrySounds.SPELL_ICE, 1, 2); - - if(!this.worldObj.isRemote){ - for(Object entity : this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox())){ + + if(!this.world.isRemote){ + for(Object entity : this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox())){ if(entity instanceof EntityLivingBase && this.isValidTarget((EntityLivingBase)entity)){ // Potion effect only gets added if the damage succeeded. - if(((EntityLivingBase)entity).attackEntityFrom(MagicDamage.causeDirectMagicDamage(this.getCaster(), DamageType.FROST), 5*this.damageMultiplier)) + if(((EntityLivingBase)entity).attackEntityFrom( + MagicDamage.causeDirectMagicDamage(this.getCaster(), DamageType.FROST), + 5 * this.damageMultiplier)) ((EntityLivingBase)entity).addPotionEffect(new PotionEffect(WizardryPotions.frost, 100, 0)); } } } - + super.onUpdate(); } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityLightningPulse.java b/src/main/java/electroblob/wizardry/entity/construct/EntityLightningPulse.java index 59653c0b..edab4346 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityLightningPulse.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityLightningPulse.java @@ -5,12 +5,13 @@ import net.minecraft.world.World; public class EntityLightningPulse extends EntityMagicConstruct { - public EntityLightningPulse(World world) { + public EntityLightningPulse(World world){ super(world); this.setSize(6, 0.2f); } - public EntityLightningPulse(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, float damageMultiplier) { + public EntityLightningPulse(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, + float damageMultiplier){ super(world, x, y, z, caster, lifetime, damageMultiplier); this.setSize(6, 0.2f); } @@ -18,8 +19,7 @@ public class EntityLightningPulse extends EntityMagicConstruct { /** * Return whether this entity should be rendered as on fire. */ - public boolean canRenderOnFire() - { + public boolean canRenderOnFire(){ return false; } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityLightningSigil.java b/src/main/java/electroblob/wizardry/entity/construct/EntityLightningSigil.java index 8ecb646d..7e427637 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityLightningSigil.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityLightningSigil.java @@ -15,111 +15,127 @@ import net.minecraft.util.EnumParticleTypes; import net.minecraft.world.World; public class EntityLightningSigil extends EntityMagicConstruct { - - public EntityLightningSigil(World par1World) { + + public EntityLightningSigil(World par1World){ super(par1World); this.height = 0.2f; this.width = 2.0f; } - - public EntityLightningSigil(World par1World, double x, double y, double z, EntityLivingBase caster, float damageMultiplier) { + + public EntityLightningSigil(World par1World, double x, double y, double z, EntityLivingBase caster, + float damageMultiplier){ super(par1World, x, y, z, caster, -1, damageMultiplier); this.height = 0.2f; this.width = 2.0f; } - + // Overrides the original to stop the entity moving when it intersects stuff. The default arrow does this to allow - // it to stick in blocks. - public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) - { - this.setPosition(par1, par3, par5); - this.setRotation(par7, par8); - } - + // it to stick in blocks. + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9){ + this.setPosition(par1, par3, par5); + this.setRotation(par7, par8); + } + public void onUpdate(){ - + super.onUpdate(); - - if(this.ticksExisted > 600 && this.getCaster() == null && !this.worldObj.isRemote){ + + if(this.ticksExisted > 600 && this.getCaster() == null && !this.world.isRemote){ this.setDead(); } - - //if(!this.worldObj.isRemote){ - - List targets = WizardryUtilities.getEntitiesWithinRadius(1.0d, this.posX, this.posY, this.posZ, this.worldObj); - - for(EntityLivingBase target : targets){ - - if(this.isValidTarget(target)){ - - double velX = target.motionX; - double velY = target.motionY; - double velZ = target.motionZ; - - // Only works if target is actually damaged to account for hurtResistantTime - if(target.attackEntityFrom(getCaster() != null ? MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.SHOCK) : DamageSource.magic, 6)){ - - // Removes knockback - target.motionX = velX; - target.motionY = velY; - target.motionZ = velZ; - - this.playSound(WizardrySounds.SPELL_SPARK, 1.0f, 1.0f); - - // Secondary chaining effect - double seekerRange = 5.0d; - List secondaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, target.posX, target.posY + target.height/2, target.posZ, worldObj); + // if(!this.world.isRemote){ - for(int j=0;j targets = WizardryUtilities.getEntitiesWithinRadius(1.0d, this.posX, this.posY, + this.posZ, this.world); - if(secondaryTarget != target && this.isValidTarget(secondaryTarget)){ - - if(!worldObj.isRemote){ - EntityArc arc = new EntityArc(worldObj); - arc.setEndpointCoords(target.posX, target.posY + target.height/2, target.posZ, - secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height/2, secondaryTarget.posZ); - worldObj.spawnEntityInWorld(arc); - }else{ - for(int k=0;k<8;k++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, worldObj, secondaryTarget.posX + worldObj.rand.nextFloat() - 0.5, secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height/2 + worldObj.rand.nextFloat()*2 - 1, secondaryTarget.posZ + worldObj.rand.nextFloat() - 0.5, 0, 0, 0, 3); - worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, secondaryTarget.posX + worldObj.rand.nextFloat() - 0.5, secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height/2 + worldObj.rand.nextFloat()*2 - 1, secondaryTarget.posZ + worldObj.rand.nextFloat() - 0.5, 0, 0, 0); - } + for(EntityLivingBase target : targets){ + + if(this.isValidTarget(target)){ + + double velX = target.motionX; + double velY = target.motionY; + double velZ = target.motionZ; + + // Only works if target is actually damaged to account for hurtResistantTime + if(target.attackEntityFrom( + getCaster() != null ? MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.SHOCK) + : DamageSource.MAGIC, + 6)){ + + // Removes knockback + target.motionX = velX; + target.motionY = velY; + target.motionZ = velZ; + + this.playSound(WizardrySounds.SPELL_SPARK, 1.0f, 1.0f); + + // Secondary chaining effect + double seekerRange = 5.0d; + + List secondaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, + target.posX, target.posY + target.height / 2, target.posZ, world); + + for(int j = 0; j < Math.min(secondaryTargets.size(), 3); j++){ + + EntityLivingBase secondaryTarget = secondaryTargets.get(j); + + if(secondaryTarget != target && this.isValidTarget(secondaryTarget)){ + + if(!world.isRemote){ + EntityArc arc = new EntityArc(world); + arc.setEndpointCoords(target.posX, target.posY + target.height / 2, target.posZ, + secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height / 2, + secondaryTarget.posZ); + world.spawnEntity(arc); + }else{ + for(int k = 0; k < 8; k++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + secondaryTarget.posX + world.rand.nextFloat() - 0.5, + secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height / 2 + + world.rand.nextFloat() * 2 - 1, + secondaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); + world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, + secondaryTarget.posX + world.rand.nextFloat() - 0.5, + secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height / 2 + + world.rand.nextFloat() * 2 - 1, + secondaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0); } - - secondaryTarget.playSound(WizardrySounds.SPELL_SPARK, 1.0F, worldObj.rand.nextFloat() * 0.4F + 1.5F); - - secondaryTarget.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.SHOCK), 4); } - + + secondaryTarget.playSound(WizardrySounds.SPELL_SPARK, 1.0F, + world.rand.nextFloat() * 0.4F + 1.5F); + + secondaryTarget.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.SHOCK), 4); } - // The trap is destroyed once triggered. - this.setDead(); + } + // The trap is destroyed once triggered. + this.setDead(); } } - //} - - if(this.worldObj.isRemote && this.rand.nextInt(15) == 0){ - double radius = 0.5 + rand.nextDouble()*0.3; - double angle = rand.nextDouble()*Math.PI*2; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, worldObj, this.posX + radius*Math.cos(angle), this.posY + 0.1, this.posZ + radius*Math.sin(angle), 0, 0, 0, 3); + } + // } + + if(this.world.isRemote && this.rand.nextInt(15) == 0){ + double radius = 0.5 + rand.nextDouble() * 0.3; + double angle = rand.nextDouble() * Math.PI * 2; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, this.posX + radius * Math.cos(angle), + this.posY + 0.1, this.posZ + radius * Math.sin(angle), 0, 0, 0, 3); } } @Override - protected void entityInit() { - + protected void entityInit(){ + } - + /** - * Return whether this entity should be rendered as on fire. - */ - public boolean canRenderOnFire() - { - return false; - } + * Return whether this entity should be rendered as on fire. + */ + public boolean canRenderOnFire(){ + return false; + } } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityMagicConstruct.java b/src/main/java/electroblob/wizardry/entity/construct/EntityMagicConstruct.java index e477f9d5..36e93b46 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityMagicConstruct.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityMagicConstruct.java @@ -12,40 +12,45 @@ import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; /** - * This class is for all inanimate magical constructs which are not projectiles. It was made from scratch - * to provide a unifying superclass for black hole, blizzard, tornado and a few others which all share some - * characteristics. The EntityPlayer instance of the caster, the lifetime and the damage multiplier are stored - * and synced here. + * This class is for all inanimate magical constructs which are not projectiles. It was made from scratch to provide a + * unifying superclass for black hole, blizzard, tornado and a few others which all share some characteristics. The + * EntityPlayer instance of the caster, the lifetime and the damage multiplier are stored and synced here. *

    - * When extending this class, override both constructors. Generally speaking, subclasses of this class are areas - * of effect which deal damage or apply effects over time. + * When extending this class, override both constructors. Generally speaking, subclasses of this class are areas of + * effect which deal damage or apply effects over time. + * * @since Wizardry 1.0 */ public abstract class EntityMagicConstruct extends Entity implements IEntityAdditionalSpawnData { - + /** The entity that created this construct */ private WeakReference caster; - - /** The UUID of the caster. Note that this is only for loading purposes; during normal updates - * the actual entity instance is stored (so that getEntityByUUID is not called constantly), - * so this will not always be synced (this is why it is private). */ + + /** + * The UUID of the caster. Note that this is only for loading purposes; during normal updates the actual entity + * instance is stored (so that getEntityByUUID is not called constantly), so this will not always be synced (this is + * why it is private). + */ private UUID casterUUID; - - /** The time in ticks this magical construct lasts for; defaults to 600 (30 seconds). If this is -1 the construct - * doesn't despawn. */ + + /** + * The time in ticks this magical construct lasts for; defaults to 600 (30 seconds). If this is -1 the construct + * doesn't despawn. + */ public int lifetime = 600; - + /** The damage multiplier for this construct, determined by the wand with which it was cast. */ public float damageMultiplier = 1.0f; - - public EntityMagicConstruct(World par1World) { + + public EntityMagicConstruct(World par1World){ super(par1World); this.height = 1.0f; this.width = 1.0f; this.noClip = true; } - - public EntityMagicConstruct(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, float damageMultiplier) { + + public EntityMagicConstruct(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, + float damageMultiplier){ super(world); this.height = 1.0f; this.width = 1.0f; @@ -55,64 +60,64 @@ public abstract class EntityMagicConstruct extends Entity implements IEntityAddi this.lifetime = lifetime; this.damageMultiplier = damageMultiplier; } - + // Overrides the original to stop the entity moving when it intersects stuff. The default arrow does this to allow - // it to stick in blocks. + // it to stick in blocks. @Override - public void setPositionAndRotationDirect(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean teleport) - { - this.setPosition(x, y, z); - this.setRotation(yaw, pitch); - } - + public void setPositionAndRotationDirect(double x, double y, double z, float yaw, float pitch, + int posRotationIncrements, boolean teleport){ + this.setPosition(x, y, z); + this.setRotation(yaw, pitch); + } + public void onUpdate(){ - + if(this.getCaster() == null && this.casterUUID != null){ - Entity entity = WizardryUtilities.getEntityByUUID(worldObj, casterUUID); + Entity entity = WizardryUtilities.getEntityByUUID(world, casterUUID); if(entity instanceof EntityLivingBase){ this.caster = new WeakReference((EntityLivingBase)entity); } } - + if(this.ticksExisted > lifetime && lifetime != -1){ this.despawn(); } - + super.onUpdate(); - + } - + /** - * Defaults to just setDead() in EntityMagicConstruct, but is provided to allow subclasses to override this - * e.g. bubble uses it to dismount the entity inside it and play the 'pop' sound before calling super(). You - * should always call super() when overriding this method, in case it changes. There is no need, therefore, to - * call setDead() when overriding. + * Defaults to just setDead() in EntityMagicConstruct, but is provided to allow subclasses to override this e.g. + * bubble uses it to dismount the entity inside it and play the 'pop' sound before calling super(). You should + * always call super() when overriding this method, in case it changes. There is no need, therefore, to call + * setDead() when overriding. */ public void despawn(){ this.setDead(); } @Override - protected void entityInit() { - + protected void entityInit(){ + } @Override protected void readEntityFromNBT(NBTTagCompound nbttagcompound){ casterUUID = nbttagcompound.getUniqueId("casterUUID"); - lifetime = nbttagcompound.getInteger("lifetime"); - damageMultiplier = nbttagcompound.getFloat("damageMultiplier"); + lifetime = nbttagcompound.getInteger("lifetime"); + damageMultiplier = nbttagcompound.getFloat("damageMultiplier"); } @Override protected void writeEntityToNBT(NBTTagCompound nbttagcompound){ if(this.getCaster() != null){ - nbttagcompound.setUniqueId("casterUUID", this.getCaster().getUniqueID()); - } + nbttagcompound.setUniqueId("casterUUID", this.getCaster().getUniqueID()); + } nbttagcompound.setInteger("lifetime", lifetime); nbttagcompound.setFloat("damageMultiplier", damageMultiplier); } - + @Override public void writeSpawnData(ByteBuf data){ data.writeInt(lifetime); @@ -124,14 +129,14 @@ public abstract class EntityMagicConstruct extends Entity implements IEntityAddi } /** - * Returns the EntityLivingBase that created this construct, or null if it no longer exists. Cases where the - * entity may no longer exist are: entity died or was deleted, mob despawned, player logged out, entity teleported - * to another dimension, or this construct simply had no caster in the first place. + * Returns the EntityLivingBase that created this construct, or null if it no longer exists. Cases where the entity + * may no longer exist are: entity died or was deleted, mob despawned, player logged out, entity teleported to + * another dimension, or this construct simply had no caster in the first place. */ - public EntityLivingBase getCaster() { + public EntityLivingBase getCaster(){ return caster == null ? null : caster.get(); } - + /** * Shorthand for {@link WizardryUtilities#isValidTarget(Entity, Entity)}, with the owner of this construct as the * attacker. Also allows subclasses to override it if they wish to do so. @@ -139,15 +144,14 @@ public abstract class EntityMagicConstruct extends Entity implements IEntityAddi public boolean isValidTarget(Entity target){ return WizardryUtilities.isValidTarget(this.getCaster(), target); } - + @Override - public boolean canRenderOnFire() - { - return false; - } - + public boolean canRenderOnFire(){ + return false; + } + @Override - public boolean isPushedByWater() { + public boolean isPushedByWater(){ return false; } } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityTornado.java b/src/main/java/electroblob/wizardry/entity/construct/EntityTornado.java index 2e1625a9..ed3b3159 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityTornado.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityTornado.java @@ -13,6 +13,7 @@ import io.netty.buffer.ByteBuf; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.MoverType; import net.minecraft.entity.passive.EntityPig; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -26,14 +27,15 @@ public class EntityTornado extends EntityMagicConstruct { private double velX, velZ; - public EntityTornado(World world) { + public EntityTornado(World world){ super(world); this.height = 8.0f; this.width = 5.0f; this.isImmuneToFire = false; } - public EntityTornado(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, double velX, double velZ, float damageMultiplier) { + public EntityTornado(World world, double x, double y, double z, EntityLivingBase caster, int lifetime, double velX, + double velZ, float damageMultiplier){ super(world, x, y, z, caster, lifetime, damageMultiplier); this.height = 8.0f; this.width = 5.0f; @@ -46,25 +48,26 @@ public class EntityTornado extends EntityMagicConstruct { super.onUpdate(); - if(this.ticksExisted % 120 == 1 && worldObj.isRemote){ + if(this.ticksExisted % 120 == 1 && world.isRemote){ // Repeat is false so that the sound fades out when the tornado does rather than stopping suddenly Wizardry.proxy.playMovingSound(this, WizardrySounds.SPELL_LOOP_WIND, 1.0f, 1.0f, false); } - - this.moveEntity(velX, motionY, velZ); - + + this.move(MoverType.SELF, velX, motionY, velZ); + BlockPos pos = new BlockPos(this); - int y = WizardryUtilities.getNearestFloorLevelC(worldObj, pos.up(3), 5); + int y = WizardryUtilities.getNearestFloorLevelC(world, pos.up(3), 5); pos = new BlockPos(pos.getX(), y, pos.getZ()); - - if(this.worldObj.getBlockState(pos).getMaterial() == Material.LAVA){ + + if(this.world.getBlockState(pos).getMaterial() == Material.LAVA){ // Fire tornado! this.setFire(5); } - if(!this.worldObj.isRemote){ + if(!this.world.isRemote){ - List targets = WizardryUtilities.getEntitiesWithinRadius(4.0d, this.posX, this.posY, this.posZ, this.worldObj); + List targets = WizardryUtilities.getEntitiesWithinRadius(4.0d, this.posX, this.posY, + this.posZ, this.world); for(EntityLivingBase target : targets){ @@ -72,23 +75,27 @@ public class EntityTornado extends EntityMagicConstruct { double velY = target.motionY; - double dx = this.posX-target.posX > 0? 0.5 - (this.posX-target.posX)/8 : -0.5 - (this.posX-target.posX)/8; - double dz = this.posZ-target.posZ > 0? 0.5 - (this.posZ-target.posZ)/8 : -0.5 - (this.posZ-target.posZ)/8; - + double dx = this.posX - target.posX > 0 ? 0.5 - (this.posX - target.posX) / 8 + : -0.5 - (this.posX - target.posX) / 8; + double dz = this.posZ - target.posZ > 0 ? 0.5 - (this.posZ - target.posZ) / 8 + : -0.5 - (this.posZ - target.posZ) / 8; + if(this.isBurning()){ target.setFire(4); } - + if(this.getCaster() != null){ - target.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.MAGIC), 1*damageMultiplier); + target.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.MAGIC), + 1 * damageMultiplier); }else{ - target.attackEntityFrom(DamageSource.magic, 1*damageMultiplier); + target.attackEntityFrom(DamageSource.MAGIC, 1 * damageMultiplier); } target.motionX = dx; - target.motionY = velY+0.2; + target.motionY = velY + 0.2; target.motionZ = dz; - + // Player motion is handled on that player's client so needs packets if(target instanceof EntityPlayerMP){ ((EntityPlayerMP)target).connection.sendPacket(new SPacketEntityVelocity(target)); @@ -101,81 +108,85 @@ public class EntityTornado extends EntityMagicConstruct { } } }else{ - for(int i=1; i<10; i++){ - - double yPos = rand.nextDouble()*8; - + for(int i = 1; i < 10; i++){ + + double yPos = rand.nextDouble() * 8; + int blockX = (int)this.posX - 2 + this.rand.nextInt(4); int blockZ = (int)this.posZ - 2 + this.rand.nextInt(4); - - BlockPos pos1 = new BlockPos(blockX, this.posY+3, blockZ); - - int blockY = WizardryUtilities.getNearestFloorLevelC(worldObj, pos1, 5) - 1; - + + BlockPos pos1 = new BlockPos(blockX, this.posY + 3, blockZ); + + int blockY = WizardryUtilities.getNearestFloorLevelC(world, pos1, 5) - 1; + pos1 = new BlockPos(pos1.getX(), blockY, pos1.getZ()); - - IBlockState block = this.worldObj.getBlockState(pos1); - - // If the block it found was air or something it can't pick up, it makes a best guess based on the biome. + + IBlockState block = this.world.getBlockState(pos1); + + // If the block it found was air or something it can't pick up, it makes a best guess based on the + // biome. if(!canTornadoPickUpBitsOf(block)){ - block = worldObj.getBiome(pos1).topBlock; + block = world.getBiome(pos1).topBlock; } - - Wizardry.proxy.spawnTornadoParticle(worldObj, this.posX, this.posY + yPos, this.posZ, this.velX, this.velZ, yPos/3 + 0.5d, 100, block, pos1); - Wizardry.proxy.spawnTornadoParticle(worldObj, this.posX, this.posY + yPos, this.posZ, this.velX, this.velZ, yPos/3 + 0.5d, 100, block, pos1); - + + Wizardry.proxy.spawnTornadoParticle(world, this.posX, this.posY + yPos, this.posZ, this.velX, this.velZ, + yPos / 3 + 0.5d, 100, block, pos1); + Wizardry.proxy.spawnTornadoParticle(world, this.posX, this.posY + yPos, this.posZ, this.velX, this.velZ, + yPos / 3 + 0.5d, 100, block, pos1); + // Sometimes spawns leaf particles if the block is leaves if(block.getMaterial() == Material.LEAVES && this.rand.nextInt(3) == 0){ - double yPos1 = rand.nextDouble()*8; - Wizardry.proxy.spawnParticle(WizardryParticleType.LEAF, worldObj, this.posX + (rand.nextDouble()*2-1)*(yPos1/3 + 0.5d), this.posY + yPos1, this.posZ + (rand.nextDouble()*2-1)*(yPos1/3 + 0.5d), 0, -0.05, 0, 40 + rand.nextInt(10)); + double yPos1 = rand.nextDouble() * 8; + Wizardry.proxy.spawnParticle(WizardryParticleType.LEAF, world, + this.posX + (rand.nextDouble() * 2 - 1) * (yPos1 / 3 + 0.5d), this.posY + yPos1, + this.posZ + (rand.nextDouble() * 2 - 1) * (yPos1 / 3 + 0.5d), 0, -0.05, 0, + 40 + rand.nextInt(10)); } - + // Sometimes spawns snow particles if the block is snow - if(block.getMaterial() == Material.SNOW || block.getMaterial() == Material.CRAFTED_SNOW && this.rand.nextInt(3) == 0){ - double yPos1 = rand.nextDouble()*8; - Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, worldObj, this.posX + (rand.nextDouble()*2-1)*(yPos1/3 + 0.5d), this.posY + yPos1, this.posZ + (rand.nextDouble()*2-1)*(yPos1/3 + 0.5d), 0, -0.02, 0, 40 + rand.nextInt(10)); + if(block.getMaterial() == Material.SNOW + || block.getMaterial() == Material.CRAFTED_SNOW && this.rand.nextInt(3) == 0){ + double yPos1 = rand.nextDouble() * 8; + Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, + this.posX + (rand.nextDouble() * 2 - 1) * (yPos1 / 3 + 0.5d), this.posY + yPos1, + this.posZ + (rand.nextDouble() * 2 - 1) * (yPos1 / 3 + 0.5d), 0, -0.02, 0, + 40 + rand.nextInt(10)); } } } } - + private static boolean canTornadoPickUpBitsOf(IBlockState block){ Material material = block.getMaterial(); - return material == Material.CRAFTED_SNOW - || material == Material.GROUND - || material == Material.GRASS - || material == Material.LAVA - || material == Material.SAND - || material == Material.SNOW - || material == Material.WATER - || material == Material.PLANTS - || material == Material.LEAVES + return material == Material.CRAFTED_SNOW || material == Material.GROUND || material == Material.GRASS + || material == Material.LAVA || material == Material.SAND || material == Material.SNOW + || material == Material.WATER || material == Material.PLANTS || material == Material.LEAVES || material == Material.VINE; } @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { + protected void readEntityFromNBT(NBTTagCompound nbttagcompound){ super.readEntityFromNBT(nbttagcompound); velX = nbttagcompound.getDouble("velX"); velZ = nbttagcompound.getDouble("velZ"); } @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { + protected void writeEntityToNBT(NBTTagCompound nbttagcompound){ super.writeEntityToNBT(nbttagcompound); nbttagcompound.setDouble("velX", velX); nbttagcompound.setDouble("velZ", velZ); } @Override - public void writeSpawnData(ByteBuf data) { + public void writeSpawnData(ByteBuf data){ super.writeSpawnData(data); data.writeDouble(velX); data.writeDouble(velZ); } @Override - public void readSpawnData(ByteBuf data) { + public void readSpawnData(ByteBuf data){ super.readSpawnData(data); this.velX = data.readDouble(); this.velZ = data.readDouble(); diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityAIAttackSpell.java b/src/main/java/electroblob/wizardry/entity/living/EntityAIAttackSpell.java index d6843a66..49cdae91 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntityAIAttackSpell.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntityAIAttackSpell.java @@ -18,9 +18,11 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; -/** Entity AI class for use by instances of {@link ISpellCaster}. This deals with pathing, the spell casting itself - * and the attack cooldown. Also provides an automatic implementation of continuous spell casting using the methods - * specified in {@code ISpellCaster}; all the entity class needs to do is implement those methods. */ +/** + * Entity AI class for use by instances of {@link ISpellCaster}. This deals with pathing, the spell casting itself and + * the attack cooldown. Also provides an automatic implementation of continuous spell casting using the methods + * specified in {@code ISpellCaster}; all the entity class needs to do is implement those methods. + */ public class EntityAIAttackSpell extends EntityAIBase { /** The entity the AI instance has been applied to. */ @@ -29,14 +31,20 @@ public class EntityAIAttackSpell extends EntityAIBase { private final ISpellCaster caster; /** The tagret to be attacked. */ private EntityLivingBase target; - /** Decremented each tick while greater than 0. When a spell is cast, this is set to that spell's cooldown plus - * the base cooldown. */ + /** + * Decremented each tick while greater than 0. When a spell is cast, this is set to that spell's cooldown plus the + * base cooldown. + */ private int cooldown; - /** The number of ticks between the entity finding a new target and when it first starts attacking, and also the - * amount that is added to the spell's cooldown between casting spells. */ + /** + * The number of ticks between the entity finding a new target and when it first starts attacking, and also the + * amount that is added to the spell's cooldown between casting spells. + */ private final int baseCooldown; - /** Decremented each tick while greater than 0. When a continuous spell is first cast, this is set to - * the value of {@link EntityAIAttackSpell#continuousSpellDuration}. */ + /** + * Decremented each tick while greater than 0. When a continuous spell is first cast, this is set to the value of + * {@link EntityAIAttackSpell#continuousSpellDuration}. + */ // I think that in this case this is only necessary on the server side. If any inconsistent behaviour // occurs, look into syncing this as well. private int continuousSpellTimer; @@ -49,19 +57,22 @@ public class EntityAIAttackSpell extends EntityAIBase { /** * Creates a new spell attack AI with the given parameters. + * * @param attacker The entity that that uses this AI. * @param speed The speed that the entity should move when attacking. Only used when passed into the navigator. * @param maxDistance The maximum distance the entity should be from its target. - * @param baseCooldown The number of ticks between the entity finding a new target and when it first starts attacking, - * and also the amount that is added to the cooldown of the spell that has just been cast. + * @param baseCooldown The number of ticks between the entity finding a new target and when it first starts + * attacking, and also the amount that is added to the cooldown of the spell that has just been cast. * @param continuousSpellDuration The number of ticks that continuous spells will be cast for before cooling down. */ - public EntityAIAttackSpell(ISpellCaster attacker, double speed, float maxDistance, int baseCooldown, int continuousSpellDuration){ + public EntityAIAttackSpell(ISpellCaster attacker, double speed, float maxDistance, int baseCooldown, + int continuousSpellDuration){ this.cooldown = -1; if(!(attacker instanceof EntityLiving)){ - throw new IllegalArgumentException("Tried to create an EntityAICastSpell for an entity that isn't an EntityLiving"); + throw new IllegalArgumentException( + "Tried to create an EntityAICastSpell for an entity that isn't an EntityLiving"); }else{ this.caster = attacker; this.attacker = (EntityLiving)attacker; @@ -102,8 +113,9 @@ public class EntityAIAttackSpell extends EntityAIBase { private void setContinuousSpellAndNotify(Spell spell, SpellModifiers modifiers){ caster.setContinuousSpell(spell); - WizardryPacketHandler.net.sendToAllAround(new PacketNPCCastSpell.Message(attacker.getEntityId(), - target == null ? -1 : target.getEntityId(), EnumHand.MAIN_HAND, spell.id(), modifiers), + WizardryPacketHandler.net.sendToAllAround( + new PacketNPCCastSpell.Message(attacker.getEntityId(), target == null ? -1 : target.getEntityId(), + EnumHand.MAIN_HAND, spell.id(), modifiers), // Particles are usually only visible from 16 blocks away, so 128 is more than far enough. new TargetPoint(attacker.dimension, attacker.posX, attacker.posY, attacker.posZ, 128)); } @@ -113,7 +125,8 @@ public class EntityAIAttackSpell extends EntityAIBase { // Only executed server side. - double distanceSq = this.attacker.getDistanceSq(this.target.posX, this.target.getEntityBoundingBox().minY, this.target.posZ); + double distanceSq = this.attacker.getDistanceSq(this.target.posX, this.target.getEntityBoundingBox().minY, + this.target.posZ); boolean targetIsVisible = this.attacker.getEntitySenses().canSee(this.target); if(targetIsVisible){ @@ -133,24 +146,25 @@ public class EntityAIAttackSpell extends EntityAIBase { if(this.continuousSpellTimer > 0){ this.continuousSpellTimer--; - + // If the target goes out of range or out of sight... if(distanceSq > (double)this.maxAttackDistance || !targetIsVisible - // ...or the spell is cancelled via events... - || MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Tick(attacker, caster.getContinuousSpell(), - caster.getModifiers(), Source.NPC, this.continuousSpellDuration - this.continuousSpellTimer)) + // ...or the spell is cancelled via events... + || MinecraftForge.EVENT_BUS + .post(new SpellCastEvent.Tick(attacker, caster.getContinuousSpell(), caster.getModifiers(), + Source.NPC, this.continuousSpellDuration - this.continuousSpellTimer)) // ...or the spell no longer succeeds... - || !caster.getContinuousSpell().cast(attacker.worldObj, attacker, EnumHand.MAIN_HAND, + || !caster.getContinuousSpell().cast(attacker.world, attacker, EnumHand.MAIN_HAND, this.continuousSpellDuration - this.continuousSpellTimer, target, caster.getModifiers()) // ...or the time has elapsed... || this.continuousSpellTimer == 0){ - + // ...reset the continuous spell timer and start the cooldown. this.continuousSpellTimer = 0; setContinuousSpellAndNotify(Spells.none, new SpellModifiers()); this.cooldown = this.baseCooldown; return; - + }else if(this.continuousSpellDuration - this.continuousSpellTimer == 1){ // On the first tick, if the spell did succeed, fire SpellCastEvent.Post. MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Post(attacker, caster.getContinuousSpell(), @@ -170,7 +184,7 @@ public class EntityAIAttackSpell extends EntityAIBase { if(spells.size() > 0){ - if(!attacker.worldObj.isRemote){ + if(!attacker.world.isRemote){ // New way of choosing a spell; keeps trying until one works or all have been tried @@ -178,7 +192,7 @@ public class EntityAIAttackSpell extends EntityAIBase { while(!spells.isEmpty()){ - spell = spells.get(attacker.worldObj.rand.nextInt(spells.size())); + spell = spells.get(attacker.world.rand.nextInt(spells.size())); SpellModifiers modifiers = caster.getModifiers(); @@ -198,16 +212,16 @@ public class EntityAIAttackSpell extends EntityAIBase { this.cooldown = this.baseCooldown; } } - + /** Attempts to cast the given spell (including event firing) and returns true if it succeeded. */ private boolean attemptCastSpell(Spell spell, SpellModifiers modifiers){ - + // If anything stops the spell working at this point, nothing else happens. if(MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Pre(attacker, spell, modifiers, Source.NPC))){ return false; } - - if(spell.cast(attacker.worldObj, attacker, EnumHand.MAIN_HAND, 0, target, modifiers)){ + + if(spell.cast(attacker.world, attacker, EnumHand.MAIN_HAND, 0, target, modifiers)){ if(spell.isContinuous){ // -1 because the spell has been cast once already! @@ -215,24 +229,24 @@ public class EntityAIAttackSpell extends EntityAIBase { setContinuousSpellAndNotify(spell, modifiers); }else{ - + MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Post(attacker, spell, modifiers, Source.NPC)); - + // For now, the cooldown is just added to the constant base cooldown. I think this // is a reasonable way of doing things; it's certainly better than before. this.cooldown = this.baseCooldown + spell.cooldown; if(spell.doesSpellRequirePacket()){ // Sends a packet to all players in dimension to tell them to spawn particles. - IMessage msg = new PacketNPCCastSpell.Message(attacker.getEntityId(), - target.getEntityId(), EnumHand.MAIN_HAND, spell.id(), modifiers); - WizardryPacketHandler.net.sendToDimension(msg, attacker.worldObj.provider.getDimension()); + IMessage msg = new PacketNPCCastSpell.Message(attacker.getEntityId(), target.getEntityId(), + EnumHand.MAIN_HAND, spell.id(), modifiers); + WizardryPacketHandler.net.sendToDimension(msg, attacker.world.provider.getDimension()); } } return true; } - + return false; } } diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityAISelectSpell.java b/src/main/java/electroblob/wizardry/entity/living/EntityAISelectSpell.java index 286dc93c..8c2186ae 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntityAISelectSpell.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntityAISelectSpell.java @@ -5,7 +5,7 @@ import net.minecraft.entity.ai.EntityAIBase; public class EntityAISelectSpell extends EntityAIBase { // TODO: Write this class - + @Override public boolean shouldExecute(){ return false; diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityBlazeMinion.java b/src/main/java/electroblob/wizardry/entity/living/EntityBlazeMinion.java index 473f30b7..9dafa8fc 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntityBlazeMinion.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntityBlazeMinion.java @@ -10,7 +10,6 @@ import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.monster.EntityBlaze; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; @@ -27,18 +26,41 @@ public class EntityBlazeMinion extends EntityBlaze implements ISummonedCreature private UUID casterUUID; // Setter + getter implementations - @Override public int getLifetime(){ return lifetime; } - @Override public void setLifetime(int lifetime){ this.lifetime = lifetime; } - @Override public WeakReference getCasterReference(){ return casterReference; } - @Override public void setCasterReference(WeakReference reference){ casterReference = reference; } - @Override public UUID getCasterUUID() { return casterUUID; } - @Override public void setCasterUUID(UUID uuid) { this.casterUUID = uuid; } + @Override + public int getLifetime(){ + return lifetime; + } + + @Override + public void setLifetime(int lifetime){ + this.lifetime = lifetime; + } + + @Override + public WeakReference getCasterReference(){ + return casterReference; + } + + @Override + public void setCasterReference(WeakReference reference){ + casterReference = reference; + } + + @Override + public UUID getCasterUUID(){ + return casterUUID; + } + + @Override + public void setCasterUUID(UUID uuid){ + this.casterUUID = uuid; + } /** - * Default shell constructor, only used by client. Lifetime defaults arbitrarily to 600, but this doesn't - * matter because the client side entity immediately gets the lifetime value copied over to it by this class - * anyway. When extending this class, you must override this constructor or Minecraft won't like it, but there's - * no need to do anything inside it other than call super(). + * Default shell constructor, only used by client. Lifetime defaults arbitrarily to 600, but this doesn't matter + * because the client side entity immediately gets the lifetime value copied over to it by this class anyway. When + * extending this class, you must override this constructor or Minecraft won't like it, but there's no need to do + * anything inside it other than call super(). */ public EntityBlazeMinion(World world){ super(world); @@ -46,8 +68,8 @@ public class EntityBlazeMinion extends EntityBlaze implements ISummonedCreature } /** - * Set lifetime to -1 to allow this creature to last forever. This constructor should be overridden when - * extending this class (be sure to call super()) so that AI and other things can be added. + * Set lifetime to -1 to allow this creature to last forever. This constructor should be overridden when extending + * this class (be sure to call super()) so that AI and other things can be added. */ public EntityBlazeMinion(World world, double x, double y, double z, EntityLivingBase caster, int lifetime){ super(world); @@ -56,21 +78,20 @@ public class EntityBlazeMinion extends EntityBlaze implements ISummonedCreature this.experienceValue = 0; this.lifetime = lifetime; } - + // EntityBlaze overrides - + // This particular override is pretty standard: let the superclass handle basic AI like swimming, but replace its // targeting system with one that targets hostile mobs and takes the ADS into account. @Override - protected void initEntityAI() - { + protected void initEntityAI(){ super.initEntityAI(); this.targetTasks.taskEntries.clear(); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); - this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, - 0, false, true, this.getTargetSelector())); - } - + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, + 0, false, true, this.getTargetSelector())); + } + // Implementations @Override @@ -93,27 +114,30 @@ public class EntityBlazeMinion extends EntityBlaze implements ISummonedCreature public void onDespawn(){ this.spawnParticleEffect(); } - - /** Normally this would be private, but since this class has subclasses with different spawn/despawn particle - * effects, it makes sense to have them override this rather than both onSpawn() and onDespawn(). */ + + /** + * Normally this would be private, but since this class has subclasses with different spawn/despawn particle + * effects, it makes sense to have them override this rather than both onSpawn() and onDespawn(). + */ protected void spawnParticleEffect(){ - if(this.worldObj.isRemote){ - for(int i=0;i<15;i++){ - this.worldObj.spawnParticle(EnumParticleTypes.FLAME, this.posX + this.rand.nextFloat(), this.posY + 1 + this.rand.nextFloat(), this.posZ + this.rand.nextFloat(), 0, 0, 0); + if(this.world.isRemote){ + for(int i = 0; i < 15; i++){ + this.world.spawnParticle(EnumParticleTypes.FLAME, this.posX + this.rand.nextFloat(), + this.posY + 1 + this.rand.nextFloat(), this.posZ + this.rand.nextFloat(), 0, 0, 0); } - } + } } @Override - public boolean hasParticleEffect() { + public boolean hasParticleEffect(){ return false; } @Override - protected boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack) { + protected boolean processInteract(EntityPlayer player, EnumHand hand){ // In this case, the delegate method determines whether super is called. // Rather handily, we can make use of Java's 'stop as soon as you find true' method of evaluating OR statements. - return this.interactDelegate(player, hand, stack) || super.processInteract(player, hand, stack); + return this.interactDelegate(player, hand) || super.processInteract(player, hand); } @Override @@ -130,12 +154,31 @@ public class EntityBlazeMinion extends EntityBlaze implements ISummonedCreature // Recommended overrides - @Override protected int getExperiencePoints(EntityPlayer player){ return 0; } - @Override protected boolean canDropLoot(){ return false; } - @Override protected Item getDropItem(){ return null; } - @Override protected ResourceLocation getLootTable(){ return null; } + @Override + protected int getExperiencePoints(EntityPlayer player){ + return 0; + } + + @Override + protected boolean canDropLoot(){ + return false; + } + + @Override + protected Item getDropItem(){ + return null; + } + + @Override + protected ResourceLocation getLootTable(){ + return null; + } + // This vanilla method has nothing to do with the custom despawn() method. - @Override protected boolean canDespawn(){ return false; } + @Override + protected boolean canDespawn(){ + return false; + } @Override public boolean canAttackClass(Class entityType){ @@ -145,7 +188,7 @@ public class EntityBlazeMinion extends EntityBlaze implements ISummonedCreature @Override public ITextComponent getDisplayName(){ if(getCaster() != null){ - return new TextComponentTranslation(NAMEPLATE_TRANSLATION_KEY, getCaster().getName(), + return new TextComponentTranslation(NAMEPLATE_TRANSLATION_KEY, getCaster().getName(), new TextComponentTranslation("entity." + this.getEntityString() + ".name")); }else{ return super.getDisplayName(); diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityDecoy.java b/src/main/java/electroblob/wizardry/entity/living/EntityDecoy.java index f4d9a423..dfe9c44f 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntityDecoy.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntityDecoy.java @@ -17,61 +17,61 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; public class EntityDecoy extends EntitySummonedCreature { - + public EntityDecoy(World world){ super(world); } - public EntityDecoy(World world, double x, double y, double z, EntityLivingBase caster, int lifetime) { + public EntityDecoy(World world, double x, double y, double z, EntityLivingBase caster, int lifetime){ super(world, x, y, z, caster, lifetime); - this.setAlwaysRenderNameTag(caster instanceof EntityPlayer); + this.setAlwaysRenderNameTag(caster instanceof EntityPlayer); } - + @Override - protected void initEntityAI() { + protected void initEntityAI(){ // Decoys just wander around aimlessly, watching anything living. this.tasks.addTask(0, new EntityAISwimming(this)); - this.tasks.addTask(1, new EntityAIWander(this, 1.0D)); - this.tasks.addTask(2, new EntityAIWatchClosest(this, EntityLivingBase.class, 6.0F)); - this.tasks.addTask(3, new EntityAILookIdle(this)); + this.tasks.addTask(1, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(2, new EntityAIWatchClosest(this, EntityLivingBase.class, 6.0F)); + this.tasks.addTask(3, new EntityAILookIdle(this)); } - + @Override public void onDespawn(){ super.onDespawn(); - for(int i=0; i<20; i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.DUST, worldObj, this.posX + (this.rand.nextDouble()-0.5)*this.width, - this.getEntityBoundingBox().minY + this.rand.nextDouble()*this.height, this.posZ + (this.rand.nextDouble()-0.5)*this.width, - 0, 0, 0, 40, 0.2f, 1.0f, 0.8f); + for(int i = 0; i < 20; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.DUST, world, + this.posX + (this.rand.nextDouble() - 0.5) * this.width, + this.getEntityBoundingBox().minY + this.rand.nextDouble() * this.height, + this.posZ + (this.rand.nextDouble() - 0.5) * this.width, 0, 0, 0, 40, 0.2f, 1.0f, 0.8f); } } - + @Override public boolean isEntityInvulnerable(DamageSource source){ return true; } - + @Override public boolean isSneaking(){ return false; } - + @Override - public void onUpdate() { + public void onUpdate(){ super.onUpdate(); if(this.getCaster() == null || this.getCaster().isDead){ this.setDead(); this.onDespawn(); } } - + @Override - protected void applyEntityAttributes() - { + protected void applyEntityAttributes(){ super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D); } - + @Override public ITextComponent getDisplayName(){ if(getCaster() instanceof EntityPlayer){ @@ -87,7 +87,7 @@ public class EntityDecoy extends EntitySummonedCreature { } @Override - public boolean hasRangedAttack() { + public boolean hasRangedAttack(){ return false; } @@ -101,7 +101,8 @@ public class EntityDecoy extends EntitySummonedCreature { public void readSpawnData(ByteBuf data){ super.readSpawnData(data); if(!data.isReadable()) return; - this.setCasterReference(new WeakReference((EntityLivingBase)this.worldObj.getEntityByID(data.readInt()))); + this.setCasterReference( + new WeakReference((EntityLivingBase)this.world.getEntityByID(data.readInt()))); } } diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityEvilWizard.java b/src/main/java/electroblob/wizardry/entity/living/EntityEvilWizard.java index a6fe6eb5..dcd5675c 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntityEvilWizard.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntityEvilWizard.java @@ -66,9 +66,11 @@ public class EntityEvilWizard extends EntityMob implements ISpellCaster, IEntity protected Predicate targetSelector; /** Data parameter for the cooldown time for wizards healing themselves. */ - private static final DataParameter HEAL_COOLDOWN = EntityDataManager.createKey(EntityEvilWizard.class, DataSerializers.VARINT); + private static final DataParameter HEAL_COOLDOWN = EntityDataManager.createKey(EntityEvilWizard.class, + DataSerializers.VARINT); /** Data parameter for the wizard's element. */ - private static final DataParameter ELEMENT = EntityDataManager.createKey(EntityEvilWizard.class, DataSerializers.VARINT); + private static final DataParameter ELEMENT = EntityDataManager.createKey(EntityEvilWizard.class, + DataSerializers.VARINT); /** The resource location for the evil wizard's loot table. */ private static final ResourceLocation LOOT_TABLE = new ResourceLocation(Wizardry.MODID, "entities/evil_wizard"); @@ -109,14 +111,18 @@ public class EntityEvilWizard extends EntityMob implements ISpellCaster, IEntity public boolean apply(Entity entity){ // If the target is valid and not invisible... - if(entity != null && !entity.isInvisible() && WizardryUtilities.isValidTarget(EntityEvilWizard.this, entity)){ + if(entity != null && !entity.isInvisible() + && WizardryUtilities.isValidTarget(EntityEvilWizard.this, entity)){ - //... and is a player, a summoned creature, another (non-evil) wizard ... - if(entity instanceof EntityPlayer || (entity instanceof ISummonedCreature || entity instanceof EntityWizard - // ... or in the whitelist ... - || Arrays.asList(Wizardry.settings.summonedCreatureTargetsWhitelist).contains(EntityList.getEntityString(entity).toLowerCase(Locale.ROOT))) - // ... and isn't in the blacklist ... - && !Arrays.asList(Wizardry.settings.summonedCreatureTargetsBlacklist).contains(EntityList.getEntityString(entity).toLowerCase(Locale.ROOT))){ + // ... and is a player, a summoned creature, another (non-evil) wizard ... + if(entity instanceof EntityPlayer + || (entity instanceof ISummonedCreature || entity instanceof EntityWizard + // ... or in the whitelist ... + || Arrays.asList(Wizardry.settings.summonedCreatureTargetsWhitelist) + .contains(EntityList.getEntityString(entity).toLowerCase(Locale.ROOT))) + // ... and isn't in the blacklist ... + && !Arrays.asList(Wizardry.settings.summonedCreatureTargetsBlacklist) + .contains(EntityList.getEntityString(entity).toLowerCase(Locale.ROOT))){ // ... it can be attacked. return true; } @@ -125,15 +131,14 @@ public class EntityEvilWizard extends EntityMob implements ISpellCaster, IEntity return false; } }; - + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, 0, false, true, this.targetSelector)); } @Override - protected void applyEntityAttributes() - { + protected void applyEntityAttributes(){ super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5D); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(30); @@ -186,7 +191,8 @@ public class EntityEvilWizard extends EntityMob implements ISpellCaster, IEntity // affected with arcane jammer and healCooldown == 0, whilst the wizard didn't actually heal or play the sound, // the particles still spawned, and since healCooldown wasn't reset they spawned every tick until the arcane // jammer wore off. - if(healCooldown == 0 && this.getHealth() < this.getMaxHealth() && this.getHealth() > 0 && !this.isPotionActive(WizardryPotions.arcane_jammer)){ + if(healCooldown == 0 && this.getHealth() < this.getMaxHealth() && this.getHealth() > 0 + && !this.isPotionActive(WizardryPotions.arcane_jammer)){ // Healer wizards use greater heal. this.heal(this.getElement() == Element.HEALING ? 8 : 4); @@ -196,13 +202,15 @@ public class EntityEvilWizard extends EntityMob implements ISpellCaster, IEntity }else if(healCooldown == -1 && this.deathTime == 0){ // Heal particles - if(worldObj.isRemote){ - for(int i=0; i<10; i++){ - double d0 = (double)((float)this.posX + rand.nextFloat()*2 - 1.0F); - // Apparently the client side spawns the particles 1 block higher than it should... hence the - 0.5F. + if(world.isRemote){ + for(int i = 0; i < 10; i++){ + double d0 = (double)((float)this.posX + rand.nextFloat() * 2 - 1.0F); + // Apparently the client side spawns the particles 1 block higher than it should... hence the - + // 0.5F. double d1 = (double)((float)this.posY - 0.5F + rand.nextFloat()); - double d2 = (double)((float)this.posZ + rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, d0, d1, d2, 0, 0.1F, 0, 48 + rand.nextInt(12), 1.0f, 1.0f, 0.3f); + double d2 = (double)((float)this.posZ + rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, 0, + 48 + rand.nextInt(12), 1.0f, 1.0f, 0.3f); } }else{ if(this.getHealth() < 10){ @@ -221,15 +229,19 @@ public class EntityEvilWizard extends EntityMob implements ISpellCaster, IEntity } @Override - protected boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack){ + protected boolean processInteract(EntityPlayer player, EnumHand hand){ + + ItemStack stack = player.getHeldItem(hand); // Debugging - //player.addChatComponentMessage(new TextComponentTranslation("wizard.debug", Spell.get(spells[1]).getDisplayName(), Spell.get(spells[2]).getDisplayName(), Spell.get(spells[3]).getDisplayName())); + // player.addChatComponentMessage(new TextComponentTranslation("wizard.debug", + // Spell.get(spells[1]).getDisplayName(), Spell.get(spells[2]).getDisplayName(), + // Spell.get(spells[3]).getDisplayName())); // When right-clicked with a spell book in creative, sets one of the spells to that spell - if(player.capabilities.isCreativeMode && stack != null && stack.getItem() instanceof ItemSpellBook){ + if(player.capabilities.isCreativeMode && stack.getItem() instanceof ItemSpellBook){ if(this.spells.size() >= 4 && Spell.get(stack.getItemDamage()).canBeCastByNPCs()){ - this.spells.set(rand.nextInt(3)+1, Spell.get(stack.getItemDamage())); + this.spells.set(rand.nextInt(3) + 1, Spell.get(stack.getItemDamage())); return true; } } @@ -251,7 +263,7 @@ public class EntityEvilWizard extends EntityMob implements ISpellCaster, IEntity super.readEntityFromNBT(nbt); this.setElement(Element.values()[nbt.getInteger("element")]); this.textureIndex = nbt.getInteger("skin"); - this.spells = (List) WizardryUtilities.NBTToList(nbt.getTagList("spells", NBT.TAG_INT), + this.spells = (List)WizardryUtilities.NBTToList(nbt.getTagList("spells", NBT.TAG_INT), (NBTTagInt tag) -> Spell.get(tag.getInt())); this.hasTower = nbt.getBoolean("hasTower"); } @@ -261,26 +273,24 @@ public class EntityEvilWizard extends EntityMob implements ISpellCaster, IEntity // Evil wizards can only despawn if they don't have a tower (i.e. if they spawned naturally at night) return !this.hasTower; } - + @Override protected float getSoundPitch(){ return (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 0.6F; } @Override - protected SoundEvent getAmbientSound() { + protected SoundEvent getAmbientSound(){ return SoundEvents.ENTITY_WITCH_AMBIENT; } @Override - protected SoundEvent getHurtSound() - { + protected SoundEvent getHurtSound(){ return SoundEvents.ENTITY_WITCH_HURT; } @Override - protected SoundEvent getDeathSound() - { + protected SoundEvent getDeathSound(){ return SoundEvents.ENTITY_WITCH_DEATH; } @@ -292,15 +302,17 @@ public class EntityEvilWizard extends EntityMob implements ISpellCaster, IEntity // Drops 3-5 crystals without looting bonuses int j = 3 + this.rand.nextInt(3) + this.rand.nextInt(1 + lootingLevel); - for(int k=0; k 0 && rand.nextInt(100) - lootingLevel < 5) this.entityDropItem(new ItemStack(WizardryItems.spell_book, 1, this.spells.get(1 + rand.nextInt(this.spells.size() - 1)).id()), 0); + if(this.spells.size() > 0 && rand.nextInt(100) - lootingLevel < 5) + this.entityDropItem(new ItemStack(WizardryItems.spell_book, 1, + this.spells.get(1 + rand.nextInt(this.spells.size() - 1)).id()), 0); } - + @Override protected ResourceLocation getLootTable(){ return LOOT_TABLE; @@ -336,11 +348,12 @@ public class EntityEvilWizard extends EntityMob implements ISpellCaster, IEntity } // Default chance is 0.085f, for reference. - for(EntityEquipmentSlot slot : EntityEquipmentSlot.values()) this.setDropChance(slot, 0.0f); + for(EntityEquipmentSlot slot : EntityEquipmentSlot.values()) + this.setDropChance(slot, 0.0f); // All wizards know magic missile, even if it is disabled. spells.add(Spells.magic_missile); - + Tier maxTier = EntityWizard.populateSpells(spells, element, 3, rand); // Now done after the spells so it can take the tier into account. For evil wizards this is slightly different; diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityIceGiant.java b/src/main/java/electroblob/wizardry/entity/living/EntityIceGiant.java index 18d18e39..a3a44856 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntityIceGiant.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntityIceGiant.java @@ -19,7 +19,6 @@ import net.minecraft.entity.monster.EntityIronGolem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.util.EnumHand; @@ -37,58 +36,91 @@ public class EntityIceGiant extends EntityIronGolem implements ISummonedCreature private UUID casterUUID; // Setter + getter implementations - @Override public int getLifetime(){ return lifetime; } - @Override public void setLifetime(int lifetime){ this.lifetime = lifetime; } - @Override public WeakReference getCasterReference(){ return casterReference; } - @Override public void setCasterReference(WeakReference reference){ casterReference = reference; } - @Override public UUID getCasterUUID() { return casterUUID; } - @Override public void setCasterUUID(UUID uuid) { this.casterUUID = uuid; } + @Override + public int getLifetime(){ + return lifetime; + } + + @Override + public void setLifetime(int lifetime){ + this.lifetime = lifetime; + } + + @Override + public WeakReference getCasterReference(){ + return casterReference; + } + + @Override + public void setCasterReference(WeakReference reference){ + casterReference = reference; + } + + @Override + public UUID getCasterUUID(){ + return casterUUID; + } + + @Override + public void setCasterUUID(UUID uuid){ + this.casterUUID = uuid; + } /** - * Default shell constructor, only used by client. Lifetime defaults arbitrarily to 600, but this doesn't - * matter because the client side entity immediately gets the lifetime value copied over to it by this class - * anyway. When extending this class, you must override this constructor or Minecraft won't like it, but there's - * no need to do anything inside it other than call super(). + * Default shell constructor, only used by client. Lifetime defaults arbitrarily to 600, but this doesn't matter + * because the client side entity immediately gets the lifetime value copied over to it by this class anyway. When + * extending this class, you must override this constructor or Minecraft won't like it, but there's no need to do + * anything inside it other than call super(). */ public EntityIceGiant(World world){ super(world); - this.setSize(1.4F, 2.9F); + this.setSize(1.4F, 2.9F); this.experienceValue = 0; } /** - * Set lifetime to -1 to allow this creature to last forever. This constructor should be overridden when - * extending this class (be sure to call super()) so that AI and other things can be added. + * Set lifetime to -1 to allow this creature to last forever. This constructor should be overridden when extending + * this class (be sure to call super()) so that AI and other things can be added. */ public EntityIceGiant(World world, double x, double y, double z, EntityLivingBase caster, int lifetime){ super(world); - this.setSize(1.4F, 2.9F); + this.setSize(1.4F, 2.9F); this.setPosition(x, y, z); this.casterReference = new WeakReference(caster); this.experienceValue = 0; this.lifetime = lifetime; } - + @Override protected void initEntityAI(){ this.getNavigator().getNodeProcessor().setCanSwim(false); - this.tasks.addTask(1, new EntityAIAttackMelee(this, 1.0D, true)); - this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.9D, 32.0F)); - //this.tasks.addTask(4, new EntityAIMoveTowardsRestriction(this, 1.0D)); - //this.tasks.addTask(5, new EntityAIWander(this, 0.6D)); - this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); - this.tasks.addTask(7, new EntityAILookIdle(this)); - this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); - this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, - 0, false, true, this.getTargetSelector())); + this.tasks.addTask(1, new EntityAIAttackMelee(this, 1.0D, true)); + this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.9D, 32.0F)); + // this.tasks.addTask(4, new EntityAIMoveTowardsRestriction(this, 1.0D)); + // this.tasks.addTask(5, new EntityAIWander(this, 0.6D)); + this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); + this.tasks.addTask(7, new EntityAILookIdle(this)); + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, + 0, false, true, this.getTargetSelector())); } - + // EntityIronGolem overrides - - @Override protected void updateAITasks(){} // Disables home-checking - @Override public Village getVillage(){ return null; } - @Override public int getHoldRoseTick(){ return 0; } - + + @Override + protected void updateAITasks(){ + } // Disables home-checking + + @Override + public Village getVillage(){ + return null; + } + + @Override + public int getHoldRoseTick(){ + return 0; + } + // Implementations @Override @@ -103,53 +135,59 @@ public class EntityIceGiant extends EntityIronGolem implements ISummonedCreature } @Override - public void onSpawn(){} + public void onSpawn(){ + } @Override public void onDespawn(){ this.playSound(WizardrySounds.SPELL_FREEZE, 1.0f, 1.0f); - if(this.worldObj.isRemote){ - for(int i=0; i<30; i++){ - float brightness = 0.5f + (rand.nextFloat()/2); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, this.worldObj, this.posX-1 + rand.nextDouble()*2, this.posY+ rand.nextDouble()*3, this.posZ-1 + rand.nextDouble()*2, 0, -0.02, 0, 12 + rand.nextInt(8), brightness, brightness + 0.1f, 1.0f); - } - } + if(this.world.isRemote){ + for(int i = 0; i < 30; i++){ + float brightness = 0.5f + (rand.nextFloat() / 2); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, this.world, + this.posX - 1 + rand.nextDouble() * 2, this.posY + rand.nextDouble() * 3, + this.posZ - 1 + rand.nextDouble() * 2, 0, -0.02, 0, 12 + rand.nextInt(8), brightness, + brightness + 0.1f, 1.0f); + } + } + } + + @Override + public void onLivingUpdate(){ + + super.onLivingUpdate(); + + if(this.world.isRemote){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, this.world, this.posX - 1 + rand.nextDouble() * 2, + this.posY + rand.nextDouble() * 3, this.posZ - 1 + rand.nextDouble() * 2, 0, -0.02, 0, + 40 + rand.nextInt(10)); + } } - @Override - public void onLivingUpdate(){ - - super.onLivingUpdate(); - - if(this.worldObj.isRemote){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, this.worldObj, this.posX-1 + rand.nextDouble()*2, this.posY+ rand.nextDouble()*3, this.posZ-1 + rand.nextDouble()*2, 0, -0.02, 0, 40 + rand.nextInt(10)); - } - } - @Override public void onSuccessfulAttack(EntityLivingBase target){ - - target.motionY += 0.2; - target.motionX += this.getLookVec().xCoord*0.2; - target.motionZ += this.getLookVec().xCoord*0.2; - - target.addPotionEffect(new PotionEffect(WizardryPotions.frost, 300, 0)); - - this.applyEnchantments(this, target); - this.playSound(SoundEvents.ENTITY_IRONGOLEM_ATTACK, 1.0F, 1.0F); + target.motionY += 0.2; + target.motionX += this.getLookVec().xCoord * 0.2; + target.motionZ += this.getLookVec().xCoord * 0.2; + + target.addPotionEffect(new PotionEffect(WizardryPotions.frost, 300, 0)); + + this.applyEnchantments(this, target); + + this.playSound(SoundEvents.ENTITY_IRONGOLEM_ATTACK, 1.0F, 1.0F); } @Override - public boolean hasParticleEffect() { + public boolean hasParticleEffect(){ return false; } @Override - protected boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack) { + protected boolean processInteract(EntityPlayer player, EnumHand hand){ // In this case, the delegate method determines whether super is called. // Rather handily, we can make use of Java's short-circuiting method of evaluating OR statements. - return this.interactDelegate(player, hand, stack) || super.processInteract(player, hand, stack); + return this.interactDelegate(player, hand) || super.processInteract(player, hand); } @Override @@ -166,13 +204,36 @@ public class EntityIceGiant extends EntityIronGolem implements ISummonedCreature // Recommended overrides - @Override protected int getExperiencePoints(EntityPlayer player){ return 0; } - @Override protected boolean canDropLoot(){ return false; } - @Override protected Item getDropItem(){ return null; } - @Override protected ResourceLocation getLootTable(){ return null; } - @Override public boolean canPickUpLoot(){ return false; } + @Override + protected int getExperiencePoints(EntityPlayer player){ + return 0; + } + + @Override + protected boolean canDropLoot(){ + return false; + } + + @Override + protected Item getDropItem(){ + return null; + } + + @Override + protected ResourceLocation getLootTable(){ + return null; + } + + @Override + public boolean canPickUpLoot(){ + return false; + } + // This vanilla method has nothing to do with the custom onDespawn() method. - @Override protected boolean canDespawn(){ return false; } + @Override + protected boolean canDespawn(){ + return false; + } @Override public boolean canAttackClass(Class entityType){ @@ -183,7 +244,7 @@ public class EntityIceGiant extends EntityIronGolem implements ISummonedCreature @Override public ITextComponent getDisplayName(){ if(getCaster() != null){ - return new TextComponentTranslation(NAMEPLATE_TRANSLATION_KEY, getCaster().getName(), + return new TextComponentTranslation(NAMEPLATE_TRANSLATION_KEY, getCaster().getName(), new TextComponentTranslation("entity." + this.getEntityString() + ".name")); }else{ return super.getDisplayName(); diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityIceWraith.java b/src/main/java/electroblob/wizardry/entity/living/EntityIceWraith.java index fa89a1d0..e9f61732 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntityIceWraith.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntityIceWraith.java @@ -33,264 +33,243 @@ public class EntityIceWraith extends EntityBlazeMinion { super(world, x, y, z, caster, lifetime); this.isImmuneToFire = false; } - + @Override protected void initEntityAI(){ super.initEntityAI(); this.tasks.taskEntries.clear(); this.tasks.addTask(4, new AIIceShardAttack(this)); - this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); - this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); - this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); - this.tasks.addTask(8, new EntityAILookIdle(this)); + this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); + this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); + this.tasks.addTask(8, new EntityAILookIdle(this)); } @Override - protected void spawnParticleEffect() { - if(this.worldObj.isRemote){ - for(int i=0;i<15;i++){ - float brightness = 0.5f + (rand.nextFloat()/2); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, this.posX - 0.5d + rand.nextDouble(), this.posY + this.height/2 - 0.5d + rand.nextDouble(), this.posZ - 0.5d + rand.nextDouble(), 0, 0.05f, 0, 20 + rand.nextInt(10), brightness, brightness + 0.1f, 1.0f); + protected void spawnParticleEffect(){ + if(this.world.isRemote){ + for(int i = 0; i < 15; i++){ + float brightness = 0.5f + (rand.nextFloat() / 2); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, this.posX - 0.5d + rand.nextDouble(), + this.posY + this.height / 2 - 0.5d + rand.nextDouble(), this.posZ - 0.5d + rand.nextDouble(), 0, + 0.05f, 0, 20 + rand.nextInt(10), brightness, brightness + 0.1f, 1.0f); } } } @Override public void onLivingUpdate(){ - + if(!this.onGround && this.motionY < 0.0D){ - this.motionY *= 0.6D; - } - - if(this.rand.nextInt(24) == 0){ - this.playSound(WizardrySounds.SPELL_LOOP_WIND, 0.3F + this.rand.nextFloat()/4, this.rand.nextFloat() * 0.7F + 1.4F); + this.motionY *= 0.6D; } - if(this.worldObj.isRemote){ + if(this.rand.nextInt(24) == 0){ + this.playSound(WizardrySounds.SPELL_LOOP_WIND, 0.3F + this.rand.nextFloat() / 4, + this.rand.nextFloat() * 0.7F + 1.4F); + } + + if(this.world.isRemote){ for(int i = 0; i < 2; ++i){ - this.worldObj.spawnParticle(EnumParticleTypes.CLOUD, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0D, 0.0D, 0.0D); + this.world.spawnParticle(EnumParticleTypes.CLOUD, + this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, + this.posY + this.rand.nextDouble() * (double)this.height, + this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0D, 0.0D, 0.0D); } } // Replaces super call. this.livingBaseUpdate(); } - - /** Copied from {@link EntityLivingBase#onLivingUpdate()}. The only change is removal of the updateElytra() call - * since that's irrelevant here. In actual fact, neither EntityMob nor EntityLiving has any code in its version - * of this method that is of use. This isn't exactly ideal, but it's the lesser of two evils since the - * alternative is copying the entire EntityBlaze class and its renderer. All to remove one particle effect... */ + + /** + * Copied from {@link EntityLivingBase#onLivingUpdate()}. The only change is removal of the updateElytra() call + * since that's irrelevant here. In actual fact, neither EntityMob nor EntityLiving has any code in its version of + * this method that is of use. This isn't exactly ideal, but it's the lesser of two evils since the alternative is + * copying the entire EntityBlaze class and its renderer. All to remove one particle effect... + */ // ... demonstrating why critical methods should delegate any non-critical functionality (like particles) to // separate protected methods. private void livingBaseUpdate(){ - - if (this.jumpTicks > 0) - { - --this.jumpTicks; - } - if (this.newPosRotationIncrements > 0 && !this.canPassengerSteer()) - { - double d0 = this.posX + (this.interpTargetX - this.posX) / (double)this.newPosRotationIncrements; - double d1 = this.posY + (this.interpTargetY - this.posY) / (double)this.newPosRotationIncrements; - double d2 = this.posZ + (this.interpTargetZ - this.posZ) / (double)this.newPosRotationIncrements; - double d3 = MathHelper.wrapDegrees(this.interpTargetYaw - (double)this.rotationYaw); - this.rotationYaw = (float)((double)this.rotationYaw + d3 / (double)this.newPosRotationIncrements); - this.rotationPitch = (float)((double)this.rotationPitch + (this.interpTargetPitch - (double)this.rotationPitch) / (double)this.newPosRotationIncrements); - --this.newPosRotationIncrements; - this.setPosition(d0, d1, d2); - this.setRotation(this.rotationYaw, this.rotationPitch); - } - else if (!this.isServerWorld()) - { - this.motionX *= 0.98D; - this.motionY *= 0.98D; - this.motionZ *= 0.98D; - } + if(this.jumpTicks > 0){ + --this.jumpTicks; + } - if (Math.abs(this.motionX) < 0.003D) - { - this.motionX = 0.0D; - } + if(this.newPosRotationIncrements > 0 && !this.canPassengerSteer()){ + double d0 = this.posX + (this.interpTargetX - this.posX) / (double)this.newPosRotationIncrements; + double d1 = this.posY + (this.interpTargetY - this.posY) / (double)this.newPosRotationIncrements; + double d2 = this.posZ + (this.interpTargetZ - this.posZ) / (double)this.newPosRotationIncrements; + double d3 = MathHelper.wrapDegrees(this.interpTargetYaw - (double)this.rotationYaw); + this.rotationYaw = (float)((double)this.rotationYaw + d3 / (double)this.newPosRotationIncrements); + this.rotationPitch = (float)((double)this.rotationPitch + + (this.interpTargetPitch - (double)this.rotationPitch) / (double)this.newPosRotationIncrements); + --this.newPosRotationIncrements; + this.setPosition(d0, d1, d2); + this.setRotation(this.rotationYaw, this.rotationPitch); + }else if(!this.isServerWorld()){ + this.motionX *= 0.98D; + this.motionY *= 0.98D; + this.motionZ *= 0.98D; + } - if (Math.abs(this.motionY) < 0.003D) - { - this.motionY = 0.0D; - } + if(Math.abs(this.motionX) < 0.003D){ + this.motionX = 0.0D; + } - if (Math.abs(this.motionZ) < 0.003D) - { - this.motionZ = 0.0D; - } + if(Math.abs(this.motionY) < 0.003D){ + this.motionY = 0.0D; + } - this.worldObj.theProfiler.startSection("ai"); + if(Math.abs(this.motionZ) < 0.003D){ + this.motionZ = 0.0D; + } - if (this.isMovementBlocked()) - { - this.isJumping = false; - this.moveStrafing = 0.0F; - this.moveForward = 0.0F; - this.randomYawVelocity = 0.0F; - } - else if (this.isServerWorld()) - { - this.worldObj.theProfiler.startSection("newAi"); - this.updateEntityActionState(); - this.worldObj.theProfiler.endSection(); - } + this.world.theProfiler.startSection("ai"); - this.worldObj.theProfiler.endSection(); - this.worldObj.theProfiler.startSection("jump"); + if(this.isMovementBlocked()){ + this.isJumping = false; + this.moveStrafing = 0.0F; + this.moveForward = 0.0F; + this.randomYawVelocity = 0.0F; + }else if(this.isServerWorld()){ + this.world.theProfiler.startSection("newAi"); + this.updateEntityActionState(); + this.world.theProfiler.endSection(); + } - if (this.isJumping) - { - if (this.isInWater()) - { - this.handleJumpWater(); - } - else if (this.isInLava()) - { - this.handleJumpLava(); - } - else if (this.onGround && this.jumpTicks == 0) - { - this.jump(); - this.jumpTicks = 10; - } - } - else - { - this.jumpTicks = 0; - } + this.world.theProfiler.endSection(); + this.world.theProfiler.startSection("jump"); - this.worldObj.theProfiler.endSection(); - this.worldObj.theProfiler.startSection("travel"); - this.moveStrafing *= 0.98F; - this.moveForward *= 0.98F; - this.randomYawVelocity *= 0.9F; - this.moveEntityWithHeading(this.moveStrafing, this.moveForward); - this.worldObj.theProfiler.endSection(); - this.worldObj.theProfiler.startSection("push"); - this.collideWithNearbyEntities(); - this.worldObj.theProfiler.endSection(); + if(this.isJumping){ + if(this.isInWater()){ + this.handleJumpWater(); + }else if(this.isInLava()){ + this.handleJumpLava(); + }else if(this.onGround && this.jumpTicks == 0){ + this.jump(); + this.jumpTicks = 10; + } + }else{ + this.jumpTicks = 0; + } + + this.world.theProfiler.endSection(); + this.world.theProfiler.startSection("travel"); + this.moveStrafing *= 0.98F; + this.moveForward *= 0.98F; + this.randomYawVelocity *= 0.9F; + this.moveEntityWithHeading(this.moveStrafing, this.moveForward); + this.world.theProfiler.endSection(); + this.world.theProfiler.startSection("push"); + this.collideWithNearbyEntities(); + this.world.theProfiler.endSection(); } @Override public boolean attackEntityFrom(DamageSource source, float amount){ // Removes the damage from being wet that applies to blazes by checking if the mob is actually drowning. - if(source == DamageSource.drown && (this.getAir() > 0 || this.isPotionActive(MobEffects.WATER_BREATHING))){ + if(source == DamageSource.DROWN && (this.getAir() > 0 || this.isPotionActive(MobEffects.WATER_BREATHING))){ // In this case, the ice wraith is not actually drowning, so cancel the damage. return false; }else{ return super.attackEntityFrom(source, amount); } } - + @Override public boolean isBurning(){ // Uses the datawatcher on both sides because fire is private to Entity (and I'm not using reflection here). - // TESTME: This should work, but there may be some issues with updating, so if it doesn't work, copy the + // TESTME: This should work, but there may be some issues with updating, so if it doesn't work, copy the // version from Entity and use reflection to access the fire field. return this.getFlag(0); - } + } - /** Copied straight from EntityBlaze.AIFireballAttack, with the only changes being replacement of fireball - * spawning with a one-liner call to WizardryRegistry.iceShard.cast(...) and the removal of redundant local variables. */ + /** + * Copied straight from EntityBlaze.AIFireballAttack, with the only changes being replacement of fireball spawning + * with a one-liner call to WizardryRegistry.iceShard.cast(...) and the removal of redundant local variables. + */ static class AIIceShardAttack extends EntityAIBase { - - private final EntityBlaze blaze; - private int attackStep; - private int attackTime; - public AIIceShardAttack(EntityBlaze blazeIn) - { - this.blaze = blazeIn; - this.setMutexBits(3); - } + private final EntityBlaze blaze; + private int attackStep; + private int attackTime; - /** - * Returns whether the EntityAIBase should begin execution. - */ - public boolean shouldExecute() - { - EntityLivingBase entitylivingbase = this.blaze.getAttackTarget(); - return entitylivingbase != null && entitylivingbase.isEntityAlive(); - } + public AIIceShardAttack(EntityBlaze blazeIn){ + this.blaze = blazeIn; + this.setMutexBits(3); + } - /** - * Execute a one shot task or start executing a continuous task - */ - public void startExecuting() - { - this.attackStep = 0; - } + /** + * Returns whether the EntityAIBase should begin execution. + */ + public boolean shouldExecute(){ + EntityLivingBase entitylivingbase = this.blaze.getAttackTarget(); + return entitylivingbase != null && entitylivingbase.isEntityAlive(); + } - /** - * Resets the task - */ - public void resetTask() - { - // This might be called setOnFire, but what it really controls is whether the wraith is in attack mode. - this.blaze.setOnFire(false); - } + /** + * Execute a one shot task or start executing a continuous task + */ + public void startExecuting(){ + this.attackStep = 0; + } - /** - * Updates the task - */ - public void updateTask() - { - --this.attackTime; - EntityLivingBase entitylivingbase = this.blaze.getAttackTarget(); - double d0 = this.blaze.getDistanceSqToEntity(entitylivingbase); + /** + * Resets the task + */ + public void resetTask(){ + // This might be called setOnFire, but what it really controls is whether the wraith is in attack mode. + this.blaze.setOnFire(false); + } - if (d0 < 4.0D) - { - if (this.attackTime <= 0) - { - this.attackTime = 20; - this.blaze.attackEntityAsMob(entitylivingbase); - } + /** + * Updates the task + */ + public void updateTask(){ + --this.attackTime; + EntityLivingBase entitylivingbase = this.blaze.getAttackTarget(); + double d0 = this.blaze.getDistanceSqToEntity(entitylivingbase); - this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, 1.0D); - } - else if (d0 < 256.0D) - { - if (this.attackTime <= 0) - { - ++this.attackStep; + if(d0 < 4.0D){ + if(this.attackTime <= 0){ + this.attackTime = 20; + this.blaze.attackEntityAsMob(entitylivingbase); + } - if (this.attackStep == 1) - { - this.attackTime = 60; - this.blaze.setOnFire(true); - } - else if (this.attackStep <= 4) - { - this.attackTime = 6; - } - else - { - this.attackTime = 100; - this.attackStep = 0; - this.blaze.setOnFire(false); - } + this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, + entitylivingbase.posZ, 1.0D); + }else if(d0 < 256.0D){ + if(this.attackTime <= 0){ + ++this.attackStep; - if(this.attackStep > 1){ - // Proof, if it were at all needed, of the elegance and versatility of the spell system. - Spells.ice_shard.cast(this.blaze.worldObj, this.blaze, EnumHand.MAIN_HAND, 0, entitylivingbase, new SpellModifiers()); - // TODO: Decide if an event should be fired here. I'm guessing no. - } - } + if(this.attackStep == 1){ + this.attackTime = 60; + this.blaze.setOnFire(true); + }else if(this.attackStep <= 4){ + this.attackTime = 6; + }else{ + this.attackTime = 100; + this.attackStep = 0; + this.blaze.setOnFire(false); + } - this.blaze.getLookHelper().setLookPositionWithEntity(entitylivingbase, 10.0F, 10.0F); - } - else - { - this.blaze.getNavigator().clearPathEntity(); - this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, 1.0D); - } + if(this.attackStep > 1){ + // Proof, if it were at all needed, of the elegance and versatility of the spell system. + Spells.ice_shard.cast(this.blaze.world, this.blaze, EnumHand.MAIN_HAND, 0, entitylivingbase, + new SpellModifiers()); + // TODO: Decide if an event should be fired here. I'm guessing no. + } + } - super.updateTask(); - } - } + this.blaze.getLookHelper().setLookPositionWithEntity(entitylivingbase, 10.0F, 10.0F); + }else{ + this.blaze.getNavigator().clearPathEntity(); + this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, + entitylivingbase.posZ, 1.0D); + } + + super.updateTask(); + } + } } diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityLightningWraith.java b/src/main/java/electroblob/wizardry/entity/living/EntityLightningWraith.java index d2287d17..d69b28f7 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntityLightningWraith.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntityLightningWraith.java @@ -27,24 +27,26 @@ public class EntityLightningWraith extends EntityBlazeMinion { super(world, x, y, z, caster, lifetime); this.isImmuneToFire = false; } - + @Override protected void initEntityAI(){ super.initEntityAI(); this.tasks.taskEntries.clear(); this.tasks.addTask(4, new AILightningAttack(this)); - this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); - this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); - this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); - this.tasks.addTask(8, new EntityAILookIdle(this)); + this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); + this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); + this.tasks.addTask(8, new EntityAILookIdle(this)); } @Override protected void spawnParticleEffect(){ - if(this.worldObj.isRemote){ - for(int i=0;i<15;i++){ - float brightness = 0.3f + (rand.nextFloat()/2); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, this.posX - 0.5d + rand.nextDouble(), this.posY + this.height/2 - 0.5d + rand.nextDouble(), this.posZ - 0.5d + rand.nextDouble(), 0, 0.05f, 0, 20 + rand.nextInt(10), brightness, brightness + 0.2f, 1.0f); + if(this.world.isRemote){ + for(int i = 0; i < 15; i++){ + float brightness = 0.3f + (rand.nextFloat() / 2); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, this.posX - 0.5d + rand.nextDouble(), + this.posY + this.height / 2 - 0.5d + rand.nextDouble(), this.posZ - 0.5d + rand.nextDouble(), 0, + 0.05f, 0, 20 + rand.nextInt(10), brightness, brightness + 0.2f, 1.0f); } } } @@ -53,128 +55,119 @@ public class EntityLightningWraith extends EntityBlazeMinion { public void onLivingUpdate(){ // Fortunately, lightning wraiths don't replace any of blazes' particle effects or the fire sound, they only // add the sparks, so it's fine to call super here. - if(worldObj.isRemote){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, worldObj, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0, 0, 0, 3); + if(world.isRemote){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, + this.posY + this.rand.nextDouble() * (double)this.height, + this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0, 0, 0, 3); } super.onLivingUpdate(); } - + @Override public boolean attackEntityFrom(DamageSource source, float amount){ // Removes the damage from being wet that applies to blazes by checking if the mob is actually drowning. - if(source == DamageSource.drown && (this.getAir() > 0 || this.isPotionActive(MobEffects.WATER_BREATHING))){ + if(source == DamageSource.DROWN && (this.getAir() > 0 || this.isPotionActive(MobEffects.WATER_BREATHING))){ // In this case, the lightning wraith is not actually drowning, so cancel the damage. return false; }else{ return super.attackEntityFrom(source, amount); } } - + @Override public boolean isBurning(){ // Uses the datawatcher on both sides because fire is private to Entity (and I'm not using reflection here). - // TESTME: This should work, but there may be some issues with updating, so if it doesn't work, copy the + // TESTME: This should work, but there may be some issues with updating, so if it doesn't work, copy the // version from Entity and use reflection to access the fire field. return this.getFlag(0); - } - - /** Copied straight from EntityBlaze.AIFireballAttack, with the only changes being replacement of fireball - * spawning with a one-liner call to WizardryRegistry.arc.cast(...) and the removal of redundant local variables. */ + } + + /** + * Copied straight from EntityBlaze.AIFireballAttack, with the only changes being replacement of fireball spawning + * with a one-liner call to WizardryRegistry.arc.cast(...) and the removal of redundant local variables. + */ static class AILightningAttack extends EntityAIBase { - - private final EntityBlaze blaze; - private int attackStep; - private int attackTime; - public AILightningAttack(EntityBlaze blazeIn) - { - this.blaze = blazeIn; - this.setMutexBits(3); - } + private final EntityBlaze blaze; + private int attackStep; + private int attackTime; - /** - * Returns whether the EntityAIBase should begin execution. - */ - public boolean shouldExecute() - { - EntityLivingBase entitylivingbase = this.blaze.getAttackTarget(); - return entitylivingbase != null && entitylivingbase.isEntityAlive(); - } + public AILightningAttack(EntityBlaze blazeIn){ + this.blaze = blazeIn; + this.setMutexBits(3); + } - /** - * Execute a one shot task or start executing a continuous task - */ - public void startExecuting() - { - this.attackStep = 0; - } + /** + * Returns whether the EntityAIBase should begin execution. + */ + public boolean shouldExecute(){ + EntityLivingBase entitylivingbase = this.blaze.getAttackTarget(); + return entitylivingbase != null && entitylivingbase.isEntityAlive(); + } - /** - * Resets the task - */ - public void resetTask() - { - // This might be called setOnFire, but what it really controls is whether the wraith is in attack mode. - this.blaze.setOnFire(false); - } + /** + * Execute a one shot task or start executing a continuous task + */ + public void startExecuting(){ + this.attackStep = 0; + } - /** - * Updates the task - */ - public void updateTask() - { - --this.attackTime; - EntityLivingBase entitylivingbase = this.blaze.getAttackTarget(); - double d0 = this.blaze.getDistanceSqToEntity(entitylivingbase); + /** + * Resets the task + */ + public void resetTask(){ + // This might be called setOnFire, but what it really controls is whether the wraith is in attack mode. + this.blaze.setOnFire(false); + } - if (d0 < 4.0D) - { - if (this.attackTime <= 0) - { - this.attackTime = 20; - this.blaze.attackEntityAsMob(entitylivingbase); - } + /** + * Updates the task + */ + public void updateTask(){ + --this.attackTime; + EntityLivingBase entitylivingbase = this.blaze.getAttackTarget(); + double d0 = this.blaze.getDistanceSqToEntity(entitylivingbase); - this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, 1.0D); - } - else if (d0 < 256.0D) - { - if (this.attackTime <= 0) - { - ++this.attackStep; + if(d0 < 4.0D){ + if(this.attackTime <= 0){ + this.attackTime = 20; + this.blaze.attackEntityAsMob(entitylivingbase); + } - if (this.attackStep == 1) - { - this.attackTime = 60; - this.blaze.setOnFire(true); - } - else if (this.attackStep <= 4) - { - this.attackTime = 6; - } - else - { - this.attackTime = 100; - this.attackStep = 0; - this.blaze.setOnFire(false); - } + this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, + entitylivingbase.posZ, 1.0D); + }else if(d0 < 256.0D){ + if(this.attackTime <= 0){ + ++this.attackStep; - if(this.attackStep > 1){ - // Proof, if it were at all needed, of the elegance and versatility of the spell system. - Spells.arc.cast(this.blaze.worldObj, this.blaze, EnumHand.MAIN_HAND, 0, entitylivingbase, new SpellModifiers()); - // TODO: Decide if an event should be fired here. I'm guessing no. - } - } + if(this.attackStep == 1){ + this.attackTime = 60; + this.blaze.setOnFire(true); + }else if(this.attackStep <= 4){ + this.attackTime = 6; + }else{ + this.attackTime = 100; + this.attackStep = 0; + this.blaze.setOnFire(false); + } - this.blaze.getLookHelper().setLookPositionWithEntity(entitylivingbase, 10.0F, 10.0F); - } - else - { - this.blaze.getNavigator().clearPathEntity(); - this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, 1.0D); - } + if(this.attackStep > 1){ + // Proof, if it were at all needed, of the elegance and versatility of the spell system. + Spells.arc.cast(this.blaze.world, this.blaze, EnumHand.MAIN_HAND, 0, entitylivingbase, + new SpellModifiers()); + // TODO: Decide if an event should be fired here. I'm guessing no. + } + } - super.updateTask(); - } - } + this.blaze.getLookHelper().setLookPositionWithEntity(entitylivingbase, 10.0F, 10.0F); + }else{ + this.blaze.getNavigator().clearPathEntity(); + this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, + entitylivingbase.posZ, 1.0D); + } + + super.updateTask(); + } + } } diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityMagicSlime.java b/src/main/java/electroblob/wizardry/entity/living/EntityMagicSlime.java index c6799fcf..88fe2b71 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntityMagicSlime.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntityMagicSlime.java @@ -12,7 +12,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; @@ -32,21 +31,46 @@ public class EntityMagicSlime extends EntitySlime implements ISummonedCreature { private UUID casterUUID; // Setter + getter implementations - @Override public int getLifetime(){ return lifetime; } - @Override public void setLifetime(int lifetime){ this.lifetime = lifetime; } - @Override public WeakReference getCasterReference(){ return casterReference; } - @Override public void setCasterReference(WeakReference reference){ casterReference = reference; } - @Override public UUID getCasterUUID() { return casterUUID; } - @Override public void setCasterUUID(UUID uuid) { this.casterUUID = uuid; } + @Override + public int getLifetime(){ + return lifetime; + } + + @Override + public void setLifetime(int lifetime){ + this.lifetime = lifetime; + } + + @Override + public WeakReference getCasterReference(){ + return casterReference; + } + + @Override + public void setCasterReference(WeakReference reference){ + casterReference = reference; + } + + @Override + public UUID getCasterUUID(){ + return casterUUID; + } + + @Override + public void setCasterUUID(UUID uuid){ + this.casterUUID = uuid; + } public EntityMagicSlime(World world){ super(world); - this.setSlimeSize(2); // Needs to be called before setting the experience value to 0 + // TESTME: Should this be true or false? Has something to do with health. + this.setSlimeSize(2, false); // Needs to be called before setting the experience value to 0 this.experienceValue = 0; } /** * Creates a new magic slime with the given caster and lifetime, riding the given target. + * * @param world The world that the slime is in. * @param caster The entity that created the slime. * @param target The slime's victim. The slime will automatically start riding this entity. @@ -57,49 +81,52 @@ public class EntityMagicSlime extends EntitySlime implements ISummonedCreature { this.setPosition(target.posX, target.posY, target.posZ); this.startRiding(target); this.casterReference = new WeakReference(caster); - this.setSlimeSize(2); // Needs to be called before setting the experience value to 0 + this.setSlimeSize(2, false); // Needs to be called before setting the experience value to 0 this.experienceValue = 0; this.lifetime = lifetime; } - + // EntitySlime overrides - + @Override - protected void initEntityAI(){} // Has no AI! - + protected void initEntityAI(){ + } // Has no AI! + @Override - protected void dealDamage(EntityLivingBase entity){} // Handles damage itself - + protected void dealDamage(EntityLivingBase entity){ + } // Handles damage itself + @Override public void setDead(){ // Restores behaviour from Entity, replacing slime splitting behaviour. - this.isDead = true; - // Makes sure that the undoing in onUpdate won't undo this. For some reason, EntitySlime sets isDead directly - // to do the peaceful despawning, which seems odd but is actually rather handy! - this.setHealth(0); - // Bursting effect - for(int i=0; i<30; i++){ + this.isDead = true; + // Makes sure that the undoing in onUpdate won't undo this. For some reason, EntitySlime sets isDead directly + // to do the peaceful despawning, which seems odd but is actually rather handy! + this.setHealth(0); + // Bursting effect + for(int i = 0; i < 30; i++){ double x = this.posX - 0.5 + rand.nextDouble(); double y = this.posY - 0.5 + rand.nextDouble(); double z = this.posZ - 0.5 + rand.nextDouble(); - this.worldObj.spawnParticle(EnumParticleTypes.SLIME, x, y, z, (x - this.posX)*2, (y - this.posY)*2, (z - this.posZ)*2); + this.world.spawnParticle(EnumParticleTypes.SLIME, x, y, z, (x - this.posX) * 2, (y - this.posY) * 2, + (z - this.posZ) * 2); } this.playSound(SoundEvents.ENTITY_SLIME_ATTACK, 2.5f, 0.6f); this.playSound(SoundEvents.ENTITY_FIREWORK_BLAST_FAR, 1.0f, 0.5f); - } - + } + @Override public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata){ // Removes size randomisation IEntityLivingData data = super.onInitialSpawn(difficulty, livingdata); - this.setSlimeSize(2); - return data; - } - + this.setSlimeSize(2, false); + return data; + } + @Override public boolean attackEntityFrom(DamageSource source, float amount){ // Immune to suffocation - return source == DamageSource.inWall ? false : super.attackEntityFrom(source, amount); + return source == DamageSource.IN_WALL ? false : super.attackEntityFrom(source, amount); } // Implementations @@ -111,45 +138,49 @@ public class EntityMagicSlime extends EntitySlime implements ISummonedCreature { @Override public void onUpdate(){ - + super.onUpdate(); // Undoes the despawning on peaceful behaviour. I don't think there's anything in super.onUpdate that sets // isDead other than that, but it's better to do a quick sanity check just to be sure. - if(this.isDead && worldObj.getDifficulty() == EnumDifficulty.PEACEFUL && this.getHealth() > 0) this.isDead = false; + if(this.isDead && world.getDifficulty() == EnumDifficulty.PEACEFUL && this.getHealth() > 0) this.isDead = false; // Bursts instantly rather than doing the falling over animation. if(this.getHealth() <= 0) this.setDead(); - + this.updateDelegate(); - + // Damages and slows the slime's victim or makes the slime explode if the victim is dead. - if(this.getRidingEntity() != null && this.getRidingEntity() instanceof EntityLivingBase && ((EntityLivingBase)this.getRidingEntity()).getHealth() > 0){ - if(this.ticksExisted % 16 == 1){ - this.getRidingEntity().attackEntityFrom(DamageSource.magic, 1); - ((EntityLivingBase)this.getRidingEntity()).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 20, 2)); - this.playSound(SoundEvents.ENTITY_SLIME_ATTACK, 1.0f, 1.0f); - this.squishAmount = 0.5F; - } - }else{ - this.setDead(); - } + if(this.getRidingEntity() != null && this.getRidingEntity() instanceof EntityLivingBase + && ((EntityLivingBase)this.getRidingEntity()).getHealth() > 0){ + if(this.ticksExisted % 16 == 1){ + this.getRidingEntity().attackEntityFrom(DamageSource.MAGIC, 1); + ((EntityLivingBase)this.getRidingEntity()) + .addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 20, 2)); + this.playSound(SoundEvents.ENTITY_SLIME_ATTACK, 1.0f, 1.0f); + this.squishAmount = 0.5F; + } + }else{ + this.setDead(); + } } @Override - public void onSpawn(){} + public void onSpawn(){ + } @Override - public void onDespawn(){} + public void onDespawn(){ + } @Override - public boolean hasParticleEffect() { + public boolean hasParticleEffect(){ return false; } @Override - protected boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack) { + protected boolean processInteract(EntityPlayer player, EnumHand hand){ // In this case, the delegate method determines whether super is called. // Rather handily, we can make use of Java's short-circuiting method of evaluating OR statements. - return this.interactDelegate(player, hand, stack) || super.processInteract(player, hand, stack); + return this.interactDelegate(player, hand) || super.processInteract(player, hand); } @Override @@ -166,12 +197,35 @@ public class EntityMagicSlime extends EntitySlime implements ISummonedCreature { // Recommended overrides - @Override protected int getExperiencePoints(EntityPlayer player){ return 0; } - @Override protected boolean canDropLoot(){ return false; } - @Override protected Item getDropItem(){ return null; } - @Override protected ResourceLocation getLootTable(){ return null; } - @Override public boolean canPickUpLoot(){ return false; } + @Override + protected int getExperiencePoints(EntityPlayer player){ + return 0; + } + + @Override + protected boolean canDropLoot(){ + return false; + } + + @Override + protected Item getDropItem(){ + return null; + } + + @Override + protected ResourceLocation getLootTable(){ + return null; + } + + @Override + public boolean canPickUpLoot(){ + return false; + } + // This vanilla method has nothing to do with the custom onDespawn() method. - @Override protected boolean canDespawn(){ return false; } + @Override + protected boolean canDespawn(){ + return false; + } } diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityPhoenix.java b/src/main/java/electroblob/wizardry/entity/living/EntityPhoenix.java index 5d72f26e..32aa3622 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntityPhoenix.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntityPhoenix.java @@ -22,42 +22,42 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class EntityPhoenix extends EntitySummonedCreature implements ISpellCaster { - - private double AISpeed = 0.5; + + private double AISpeed = 0.5; // Can attack for 7 seconds, then must cool down for 3. - private EntityAIAttackSpell spellAttackAI = new EntityAIAttackSpell(this, AISpeed, 15f, 60, 140); + private EntityAIAttackSpell spellAttackAI = new EntityAIAttackSpell(this, AISpeed, 15f, 60, 140); private Spell continuousSpell; private static final List attack = Collections.singletonList(Spells.flame_ray); public EntityPhoenix(World world){ - super(world); - } - - public EntityPhoenix(World world, double x, double y, double z, EntityLivingBase caster, int lifetime){ - super(world, x, y, z, caster, lifetime); - this.isImmuneToFire = true; - this.height = 2.0f; + super(world); + } + + public EntityPhoenix(World world, double x, double y, double z, EntityLivingBase caster, int lifetime){ + super(world, x, y, z, caster, lifetime); + this.isImmuneToFire = true; + this.height = 2.0f; // For some reason this can't be in initEntityAI - this.tasks.addTask(1, this.spellAttackAI); - } - - @Override - protected void initEntityAI(){ + this.tasks.addTask(1, this.spellAttackAI); + } - this.tasks.addTask(0, new EntityAIWatchClosest(this, EntityLivingBase.class, 0)); - //this.tasks.addTask(2, new EntityAIWander(this, AISpeed)); - this.tasks.addTask(3, new EntityAILookIdle(this)); - //this.targetTasks.addTask(0, new EntityAIMoveTowardsTarget(this, 1, 10)); - this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); - this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, - 0, false, true, this.getTargetSelector())); + @Override + protected void initEntityAI(){ + + this.tasks.addTask(0, new EntityAIWatchClosest(this, EntityLivingBase.class, 0)); + // this.tasks.addTask(2, new EntityAIWander(this, AISpeed)); + this.tasks.addTask(3, new EntityAILookIdle(this)); + // this.targetTasks.addTask(0, new EntityAIMoveTowardsTarget(this, 1, 10)); + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, + 0, false, true, this.getTargetSelector())); + + this.setAIMoveSpeed((float)AISpeed); + } - this.setAIMoveSpeed((float)AISpeed); - } - @Override public List getSpells(){ return attack; @@ -77,113 +77,118 @@ public class EntityPhoenix extends EntitySummonedCreature implements ISpellCaste public void setContinuousSpell(Spell spell){ continuousSpell = spell; } - - @Override - public boolean hasRangedAttack() { + + @Override + public boolean hasRangedAttack(){ return true; } - - @Override - // Makes the flames come from the phoenix's head rather than its body - public float getEyeHeight(){ - return 2.1f; - } @Override - protected void applyEntityAttributes(){ - super.applyEntityAttributes(); - this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D); - this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(30.0D); - this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(30.0D); - } - - @Override - protected SoundEvent getAmbientSound(){ - return SoundEvents.ENTITY_BLAZE_AMBIENT; - } - - @Override - protected SoundEvent getHurtSound(){ - return SoundEvents.ENTITY_BLAZE_HURT; - } - - @Override - protected SoundEvent getDeathSound(){ - return SoundEvents.ENTITY_BLAZE_DEATH; - } - - @Override - @SideOnly(Side.CLIENT) - public int getBrightnessForRender(float par1){ - return 15728880; - } - - @Override - public float getBrightness(float par1){ - return 1.0F; - } - - @Override - public void onSpawn(){ - this.spawnParticleEffect(); - } - - @Override - public void onDespawn(){ - this.spawnParticleEffect(); + // Makes the flames come from the phoenix's head rather than its body + public float getEyeHeight(){ + return 2.1f; } - - private void spawnParticleEffect(){ - if(this.worldObj.isRemote){ - for(int i=0;i<15;i++){ - this.worldObj.spawnParticle(EnumParticleTypes.FLAME, this.posX + this.rand.nextFloat(), this.posY + 1 + this.rand.nextFloat(), this.posZ + this.rand.nextFloat(), 0, 0, 0); - } - } - } @Override - public void onLivingUpdate(){ - - // Makes the phoenix hover. - int floorLevel = WizardryUtilities.getNearestFloorLevel(worldObj, new BlockPos(this), 4); - - if(this.posY - floorLevel > 3){ - this.motionY = -0.1; - }else if(this.posY - floorLevel < 2){ - this.motionY = 0.1; - }else{ - this.motionY = 0.0; - } + protected void applyEntityAttributes(){ + super.applyEntityAttributes(); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D); + this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(30.0D); + this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(30.0D); + } - // Living sound - if(this.rand.nextInt(24) == 0){ - this.playSound(SoundEvents.BLOCK_FIRE_AMBIENT, 1.0F + this.rand.nextFloat(), this.rand.nextFloat() * 0.7F + 0.3F); - } + @Override + protected SoundEvent getAmbientSound(){ + return SoundEvents.ENTITY_BLAZE_AMBIENT; + } - // Flapping sound effect + @Override + protected SoundEvent getHurtSound(){ + return SoundEvents.ENTITY_BLAZE_HURT; + } + + @Override + protected SoundEvent getDeathSound(){ + return SoundEvents.ENTITY_BLAZE_DEATH; + } + + @Override + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float par1){ + return 15728880; + } + + @Override + public float getBrightness(float par1){ + return 1.0F; + } + + @Override + public void onSpawn(){ + this.spawnParticleEffect(); + } + + @Override + public void onDespawn(){ + this.spawnParticleEffect(); + } + + private void spawnParticleEffect(){ + if(this.world.isRemote){ + for(int i = 0; i < 15; i++){ + this.world.spawnParticle(EnumParticleTypes.FLAME, this.posX + this.rand.nextFloat(), + this.posY + 1 + this.rand.nextFloat(), this.posZ + this.rand.nextFloat(), 0, 0, 0); + } + } + } + + @Override + public void onLivingUpdate(){ + + // Makes the phoenix hover. + int floorLevel = WizardryUtilities.getNearestFloorLevel(world, new BlockPos(this), 4); + + if(this.posY - floorLevel > 3){ + this.motionY = -0.1; + }else if(this.posY - floorLevel < 2){ + this.motionY = 0.1; + }else{ + this.motionY = 0.0; + } + + // Living sound + if(this.rand.nextInt(24) == 0){ + this.playSound(SoundEvents.BLOCK_FIRE_AMBIENT, 1.0F + this.rand.nextFloat(), + this.rand.nextFloat() * 0.7F + 0.3F); + } + + // Flapping sound effect if(this.ticksExisted % 22 == 0){ this.playSound(SoundEvents.ENTITY_ENDERDRAGON_FLAP, 1.0F, 1.0f); } - for(int i=0; i<2; i++){ - this.worldObj.spawnParticle(EnumParticleTypes.FLAME, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.height/2 + this.rand.nextDouble() * (double)this.height/2, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0D, -0.1D, 0.0D); - } - - // Adding this allows the phoenix to attack despite being in the air. However, for some strange reason - // it will only attack when within about 3 blocks of the ground. Any higher and it just sits there, not even - // attempting to find targets. - - this.onGround = true; + for(int i = 0; i < 2; i++){ + this.world.spawnParticle(EnumParticleTypes.FLAME, + this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, + this.posY + this.height / 2 + this.rand.nextDouble() * (double)this.height / 2, + this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0D, -0.1D, 0.0D); + } - super.onLivingUpdate(); - } - - @Override - public void fall(float distance, float damageMultiplier){} // Immune to fall damage + // Adding this allows the phoenix to attack despite being in the air. However, for some strange reason + // it will only attack when within about 3 blocks of the ground. Any higher and it just sits there, not even + // attempting to find targets. + + this.onGround = true; + + super.onLivingUpdate(); + } @Override - public boolean isBurning() - { - return false; - } + public void fall(float distance, float damageMultiplier){ + } // Immune to fall damage + + @Override + public boolean isBurning(){ + return false; + } } diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityShadowWraith.java b/src/main/java/electroblob/wizardry/entity/living/EntityShadowWraith.java index 000ba391..fbe3e0dc 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntityShadowWraith.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntityShadowWraith.java @@ -25,13 +25,13 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class EntityShadowWraith extends EntitySummonedCreature implements ISpellCaster { - + // TODO: This currently doesn't fly like it used to. Should it, or does it not matter? - - private double AISpeed = 1.0; - - private EntityAIAttackSpell spellAttackAI = new EntityAIAttackSpell(this, AISpeed, 15f, 30, 0); - + + private double AISpeed = 1.0; + + private EntityAIAttackSpell spellAttackAI = new EntityAIAttackSpell(this, AISpeed, 15f, 30, 0); + private static final List attack = Collections.singletonList(Spells.darkness_orb); public EntityShadowWraith(World world){ @@ -41,24 +41,24 @@ public class EntityShadowWraith extends EntitySummonedCreature implements ISpell public EntityShadowWraith(World world, double x, double y, double z, EntityLivingBase caster, int lifetime){ super(world, x, y, z, caster, lifetime); // For some reason this can't be in initEntityAI - this.tasks.addTask(0, this.spellAttackAI); + this.tasks.addTask(0, this.spellAttackAI); } - + @Override protected void initEntityAI(){ - this.tasks.addTask(1, new EntityAIAttackMelee(this, AISpeed, false)); + this.tasks.addTask(1, new EntityAIAttackMelee(this, AISpeed, false)); this.tasks.addTask(2, new EntityAIWander(this, AISpeed)); this.tasks.addTask(3, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); - this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, - 0, false, true, this.getTargetSelector())); + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, + 0, false, true, this.getTargetSelector())); - this.setAIMoveSpeed((float)AISpeed); + this.setAIMoveSpeed((float)AISpeed); } @Override - public boolean hasRangedAttack() { + public boolean hasRangedAttack(){ return true; } @@ -85,32 +85,32 @@ public class EntityShadowWraith extends EntitySummonedCreature implements ISpell @Override protected void applyEntityAttributes(){ super.applyEntityAttributes(); - this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(AISpeed); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(30.0D); this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(16.0D); } - + @Override public boolean isPotionApplicable(PotionEffect potion){ return potion.getPotion() == MobEffects.WITHER ? false : super.isPotionApplicable(potion); } - @Override - protected SoundEvent getAmbientSound(){ - return SoundEvents.ENTITY_BLAZE_AMBIENT; - } + @Override + protected SoundEvent getAmbientSound(){ + return SoundEvents.ENTITY_BLAZE_AMBIENT; + } - @Override - protected SoundEvent getHurtSound(){ - return SoundEvents.ENTITY_BLAZE_HURT; - } + @Override + protected SoundEvent getHurtSound(){ + return SoundEvents.ENTITY_BLAZE_HURT; + } + + @Override + protected SoundEvent getDeathSound(){ + return SoundEvents.ENTITY_BLAZE_DEATH; + } - @Override - protected SoundEvent getDeathSound(){ - return SoundEvents.ENTITY_BLAZE_DEATH; - } - @Override @SideOnly(Side.CLIENT) public int getBrightnessForRender(float partialTicks){ @@ -124,10 +124,12 @@ public class EntityShadowWraith extends EntitySummonedCreature implements ISpell @Override public void onSpawn(){ - if(this.worldObj.isRemote){ - for(int i=0;i<15;i++){ - float brightness = rand.nextFloat()*0.4f; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, this.posX - 0.5d + rand.nextDouble(), this.posY + this.height/2 - 0.5d + rand.nextDouble(), this.posZ - 0.5d + rand.nextDouble(), 0, 0.05f, 0, 20 + rand.nextInt(10), brightness, 0.0f, brightness); + if(this.world.isRemote){ + for(int i = 0; i < 15; i++){ + float brightness = rand.nextFloat() * 0.4f; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, this.posX - 0.5d + rand.nextDouble(), + this.posY + this.height / 2 - 0.5d + rand.nextDouble(), this.posZ - 0.5d + rand.nextDouble(), 0, + 0.05f, 0, 20 + rand.nextInt(10), brightness, 0.0f, brightness); } } } @@ -136,7 +138,8 @@ public class EntityShadowWraith extends EntitySummonedCreature implements ISpell public void onLivingUpdate(){ if(this.rand.nextInt(24) == 0){ - this.playSound(SoundEvents.BLOCK_PORTAL_AMBIENT, 1.0F + this.rand.nextFloat(), this.rand.nextFloat() * 0.7F + 0.3F); + this.playSound(SoundEvents.BLOCK_PORTAL_AMBIENT, 1.0F + this.rand.nextFloat(), + this.rand.nextFloat() * 0.7F + 0.3F); } // Slow fall @@ -144,22 +147,36 @@ public class EntityShadowWraith extends EntitySummonedCreature implements ISpell this.motionY *= 0.6D; } - if(worldObj.isRemote){ - for(int i=0; i<2; i++){ - worldObj.spawnParticle(EnumParticleTypes.PORTAL, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0, 0, 0); - worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0, 0, 0); - float brightness = rand.nextFloat()*0.2f; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0, 0.05f, 0, 20 + rand.nextInt(10), brightness, 0.0f, brightness); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, worldObj, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f); + if(world.isRemote){ + for(int i = 0; i < 2; i++){ + world.spawnParticle(EnumParticleTypes.PORTAL, + this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, + this.posY + this.rand.nextDouble() * (double)this.height, + this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0, 0, 0); + world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, + this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, + this.posY + this.rand.nextDouble() * (double)this.height, + this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0, 0, 0); + float brightness = rand.nextFloat() * 0.2f; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, + this.posY + this.rand.nextDouble() * (double)this.height, + this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0, 0.05f, 0, + 20 + rand.nextInt(10), brightness, 0.0f, brightness); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, + this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, + this.posY + this.rand.nextDouble() * (double)this.height, + this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0d, 0.0d, 0.0d, 0, 0.1f, + 0.0f, 0.0f); } } super.onLivingUpdate(); } - + @Override public void fall(float distance, float damageMultiplier){ // Immune to fall damage. } - + } diff --git a/src/main/java/electroblob/wizardry/entity/living/EntitySilverfishMinion.java b/src/main/java/electroblob/wizardry/entity/living/EntitySilverfishMinion.java index 2a8f237e..5663b86e 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntitySilverfishMinion.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntitySilverfishMinion.java @@ -14,7 +14,6 @@ import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.monster.EntitySilverfish; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; @@ -30,18 +29,41 @@ public class EntitySilverfishMinion extends EntitySilverfish implements ISummone private UUID casterUUID; // Setter + getter implementations - @Override public int getLifetime(){ return lifetime; } - @Override public void setLifetime(int lifetime){ this.lifetime = lifetime; } - @Override public WeakReference getCasterReference(){ return casterReference; } - @Override public void setCasterReference(WeakReference reference){ casterReference = reference; } - @Override public UUID getCasterUUID() { return casterUUID; } - @Override public void setCasterUUID(UUID uuid) { this.casterUUID = uuid; } + @Override + public int getLifetime(){ + return lifetime; + } + + @Override + public void setLifetime(int lifetime){ + this.lifetime = lifetime; + } + + @Override + public WeakReference getCasterReference(){ + return casterReference; + } + + @Override + public void setCasterReference(WeakReference reference){ + casterReference = reference; + } + + @Override + public UUID getCasterUUID(){ + return casterUUID; + } + + @Override + public void setCasterUUID(UUID uuid){ + this.casterUUID = uuid; + } /** - * Default shell constructor, only used by client. Lifetime defaults arbitrarily to 600, but this doesn't - * matter because the client side entity immediately gets the lifetime value copied over to it by this class - * anyway. When extending this class, you must override this constructor or Minecraft won't like it, but there's - * no need to do anything inside it other than call super(). + * Default shell constructor, only used by client. Lifetime defaults arbitrarily to 600, but this doesn't matter + * because the client side entity immediately gets the lifetime value copied over to it by this class anyway. When + * extending this class, you must override this constructor or Minecraft won't like it, but there's no need to do + * anything inside it other than call super(). */ public EntitySilverfishMinion(World world){ super(world); @@ -49,8 +71,8 @@ public class EntitySilverfishMinion extends EntitySilverfish implements ISummone } /** - * Set lifetime to -1 to allow this creature to last forever. This constructor should be overridden when - * extending this class (be sure to call super()) so that AI and other things can be added. + * Set lifetime to -1 to allow this creature to last forever. This constructor should be overridden when extending + * this class (be sure to call super()) so that AI and other things can be added. */ public EntitySilverfishMinion(World world, double x, double y, double z, EntityLivingBase caster, int lifetime){ super(world); @@ -62,8 +84,7 @@ public class EntitySilverfishMinion extends EntitySilverfish implements ISummone // EntitySilverfish overrides @Override - protected void initEntityAI() - { + protected void initEntityAI(){ // Super not called because we don't want AISummonSilverfish or AIHideInStone this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false)); @@ -71,7 +92,7 @@ public class EntitySilverfishMinion extends EntitySilverfish implements ISummone this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, 0, false, true, this.getTargetSelector())); } - + // Implementations @Override @@ -96,13 +117,15 @@ public class EntitySilverfishMinion extends EntitySilverfish implements ISummone } private void spawnParticleEffect(){ - if(this.worldObj.isRemote){ - for(int i=0;i<15;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, worldObj, this.posX + this.rand.nextFloat(), this.posY + this.rand.nextFloat(), this.posZ + this.rand.nextFloat(), 0.0d, 0.0d, 0.0d, 0, 0.3f, 0.3f, 0.3f); + if(this.world.isRemote){ + for(int i = 0; i < 15; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, this.posX + this.rand.nextFloat(), + this.posY + this.rand.nextFloat(), this.posZ + this.rand.nextFloat(), 0.0d, 0.0d, 0.0d, 0, 0.3f, + 0.3f, 0.3f); } } } - + @Override public void onSuccessfulAttack(EntityLivingBase target){ if(!target.isEntityAlive()){ @@ -111,30 +134,31 @@ public class EntitySilverfishMinion extends EntitySilverfish implements ISummone } @Override - public void onKillEntity(EntityLivingBase victim) { + public void onKillEntity(EntityLivingBase victim){ // If the silverfish has a summoner, this is actually called from Wizardry's event handler rather than by // Minecraft itself, because the damagesource being changed causes it not to get called. - if(!this.worldObj.isRemote){ + if(!this.world.isRemote){ // Summons 1-4 more silverfish int alliesToSummon = rand.nextInt(4) + 1; - - for(int i=0; i entityType){ @@ -168,7 +215,7 @@ public class EntitySilverfishMinion extends EntitySilverfish implements ISummone @Override public ITextComponent getDisplayName(){ if(getCaster() != null){ - return new TextComponentTranslation(NAMEPLATE_TRANSLATION_KEY, getCaster().getName(), + return new TextComponentTranslation(NAMEPLATE_TRANSLATION_KEY, getCaster().getName(), new TextComponentTranslation("entity." + this.getEntityString() + ".name")); }else{ return super.getDisplayName(); diff --git a/src/main/java/electroblob/wizardry/entity/living/EntitySkeletonMinion.java b/src/main/java/electroblob/wizardry/entity/living/EntitySkeletonMinion.java index e62435f3..504f5b4b 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntitySkeletonMinion.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntitySkeletonMinion.java @@ -14,16 +14,13 @@ import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.monster.EntitySkeleton; -import net.minecraft.entity.monster.SkeletonType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; -import net.minecraft.init.MobEffects; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.PotionEffect; import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.ResourceLocation; @@ -40,18 +37,41 @@ public class EntitySkeletonMinion extends EntitySkeleton implements ISummonedCre private UUID casterUUID; // Setter + getter implementations - @Override public int getLifetime(){ return lifetime; } - @Override public void setLifetime(int lifetime){ this.lifetime = lifetime; } - @Override public WeakReference getCasterReference(){ return casterReference; } - @Override public void setCasterReference(WeakReference reference){ casterReference = reference; } - @Override public UUID getCasterUUID() { return casterUUID; } - @Override public void setCasterUUID(UUID uuid) { this.casterUUID = uuid; } + @Override + public int getLifetime(){ + return lifetime; + } + + @Override + public void setLifetime(int lifetime){ + this.lifetime = lifetime; + } + + @Override + public WeakReference getCasterReference(){ + return casterReference; + } + + @Override + public void setCasterReference(WeakReference reference){ + casterReference = reference; + } + + @Override + public UUID getCasterUUID(){ + return casterUUID; + } + + @Override + public void setCasterUUID(UUID uuid){ + this.casterUUID = uuid; + } /** - * Default shell constructor, only used by client. Lifetime defaults arbitrarily to 600, but this doesn't - * matter because the client side entity immediately gets the lifetime value copied over to it by this class - * anyway. When extending this class, you must override this constructor or Minecraft won't like it, but there's - * no need to do anything inside it other than call super(). + * Default shell constructor, only used by client. Lifetime defaults arbitrarily to 600, but this doesn't matter + * because the client side entity immediately gets the lifetime value copied over to it by this class anyway. When + * extending this class, you must override this constructor or Minecraft won't like it, but there's no need to do + * anything inside it other than call super(). */ public EntitySkeletonMinion(World world){ super(world); @@ -59,8 +79,8 @@ public class EntitySkeletonMinion extends EntitySkeleton implements ISummonedCre } /** - * Set lifetime to -1 to allow this creature to last forever. This constructor should be overridden when - * extending this class (be sure to call super()) so that AI and other things can be added. + * Set lifetime to -1 to allow this creature to last forever. This constructor should be overridden when extending + * this class (be sure to call super()) so that AI and other things can be added. */ public EntitySkeletonMinion(World world, double x, double y, double z, EntityLivingBase caster, int lifetime){ super(world); @@ -69,57 +89,52 @@ public class EntitySkeletonMinion extends EntitySkeleton implements ISummonedCre this.experienceValue = 0; this.lifetime = lifetime; } - + // EntitySkeleton overrides // This particular override is pretty standard: let the superclass handle basic AI like swimming, but replace its // targeting system with one that targets hostile mobs and takes the ADS into account. @Override - protected void initEntityAI() - { + protected void initEntityAI(){ super.initEntityAI(); this.targetTasks.taskEntries.clear(); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, 0, false, true, this.getTargetSelector())); } - + // Shouldn't have randomised armour, but does still need a bow! @Override - protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty) { - this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.BOW)); + protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty){ + this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.BOW)); } - + // Where the skeleton minion is summoned does not affect its type. @Override - public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) - { + public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata){ // Can't call super, so the code from the next level up (EntityLiving) had to be copied as well. - this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, 1)); + this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE) + .applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, 1)); - if (this.rand.nextFloat() < 0.05F) - { - this.setLeftHanded(true); - } - else - { - this.setLeftHanded(false); - } + if(this.rand.nextFloat() < 0.05F){ + this.setLeftHanded(true); + }else{ + this.setLeftHanded(false); + } - // Halloween pumpkin heads! Why not? - if (this.getItemStackFromSlot(EntityEquipmentSlot.HEAD) == null) - { - Calendar calendar = this.worldObj.getCurrentDate(); + // Halloween pumpkin heads! Why not? + if(this.getItemStackFromSlot(EntityEquipmentSlot.HEAD) == null){ + Calendar calendar = this.world.getCurrentDate(); - if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.rand.nextFloat() < 0.25F) - { - this.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.LIT_PUMPKIN : Blocks.PUMPKIN)); - this.inventoryArmorDropChances[EntityEquipmentSlot.HEAD.getIndex()] = 0.0F; - } - } + if(calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.rand.nextFloat() < 0.25F){ + this.setItemStackToSlot(EntityEquipmentSlot.HEAD, + new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.LIT_PUMPKIN : Blocks.PUMPKIN)); + this.inventoryArmorDropChances[EntityEquipmentSlot.HEAD.getIndex()] = 0.0F; + } + } - return livingdata; - } + return livingdata; + } // Implementations @@ -143,32 +158,26 @@ public class EntitySkeletonMinion extends EntitySkeleton implements ISummonedCre public void onDespawn(){ this.spawnParticleEffect(); } - + private void spawnParticleEffect(){ - if(this.worldObj.isRemote){ - for(int i=0;i<15;i++){ - this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX + this.rand.nextFloat(), this.posY + 1 + this.rand.nextFloat(), this.posZ + this.rand.nextFloat(), 0, 0, 0); + if(this.world.isRemote){ + for(int i = 0; i < 15; i++){ + this.world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX + this.rand.nextFloat(), + this.posY + 1 + this.rand.nextFloat(), this.posZ + this.rand.nextFloat(), 0, 0, 0); } } } @Override - public boolean hasParticleEffect() { + public boolean hasParticleEffect(){ return true; } - - @Override - public void onSuccessfulAttack(EntityLivingBase target) { - if(this.getSkeletonType() == SkeletonType.WITHER){ - target.addPotionEffect(new PotionEffect(MobEffects.WITHER, 200)); - } - } @Override - protected boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack) { + protected boolean processInteract(EntityPlayer player, EnumHand hand){ // In this case, the delegate method determines whether super is called. - // Rather handily, we can make use of Java's 'stop as soon as you find true' method of evaluating OR statements. - return this.interactDelegate(player, hand, stack) || super.processInteract(player, hand, stack); + // Rather handily, we can make use of Java's short-circuiting method of evaluating OR statements. + return this.interactDelegate(player, hand) || super.processInteract(player, hand); } @Override @@ -185,13 +194,36 @@ public class EntitySkeletonMinion extends EntitySkeleton implements ISummonedCre // Recommended overrides - @Override protected int getExperiencePoints(EntityPlayer player){ return 0; } - @Override protected boolean canDropLoot(){ return false; } - @Override protected Item getDropItem(){ return null; } - @Override protected ResourceLocation getLootTable(){ return null; } - @Override public boolean canPickUpLoot(){ return false; } + @Override + protected int getExperiencePoints(EntityPlayer player){ + return 0; + } + + @Override + protected boolean canDropLoot(){ + return false; + } + + @Override + protected Item getDropItem(){ + return null; + } + + @Override + protected ResourceLocation getLootTable(){ + return null; + } + + @Override + public boolean canPickUpLoot(){ + return false; + } + // This vanilla method has nothing to do with the custom despawn() method. - @Override protected boolean canDespawn(){ return false; } + @Override + protected boolean canDespawn(){ + return false; + } @Override public boolean canAttackClass(Class entityType){ @@ -201,7 +233,7 @@ public class EntitySkeletonMinion extends EntitySkeleton implements ISummonedCre @Override public ITextComponent getDisplayName(){ if(getCaster() != null){ - return new TextComponentTranslation(NAMEPLATE_TRANSLATION_KEY, getCaster().getName(), + return new TextComponentTranslation(NAMEPLATE_TRANSLATION_KEY, getCaster().getName(), new TextComponentTranslation("entity." + this.getEntityString() + ".name")); }else{ return super.getDisplayName(); diff --git a/src/main/java/electroblob/wizardry/entity/living/EntitySpiderMinion.java b/src/main/java/electroblob/wizardry/entity/living/EntitySpiderMinion.java index f5714361..9140874f 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntitySpiderMinion.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntitySpiderMinion.java @@ -16,7 +16,6 @@ import net.minecraft.entity.monster.EntityCaveSpider; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.util.EnumHand; @@ -35,18 +34,41 @@ public class EntitySpiderMinion extends EntityCaveSpider implements ISummonedCre private UUID casterUUID; // Setter + getter implementations - @Override public int getLifetime(){ return lifetime; } - @Override public void setLifetime(int lifetime){ this.lifetime = lifetime; } - @Override public WeakReference getCasterReference(){ return casterReference; } - @Override public void setCasterReference(WeakReference reference){ casterReference = reference; } - @Override public UUID getCasterUUID() { return casterUUID; } - @Override public void setCasterUUID(UUID uuid) { this.casterUUID = uuid; } + @Override + public int getLifetime(){ + return lifetime; + } + + @Override + public void setLifetime(int lifetime){ + this.lifetime = lifetime; + } + + @Override + public WeakReference getCasterReference(){ + return casterReference; + } + + @Override + public void setCasterReference(WeakReference reference){ + casterReference = reference; + } + + @Override + public UUID getCasterUUID(){ + return casterUUID; + } + + @Override + public void setCasterUUID(UUID uuid){ + this.casterUUID = uuid; + } /** - * Default shell constructor, only used by client. Lifetime defaults arbitrarily to 600, but this doesn't - * matter because the client side entity immediately gets the lifetime value copied over to it by this class - * anyway. When extending this class, you must override this constructor or Minecraft won't like it, but there's - * no need to do anything inside it other than call super(). + * Default shell constructor, only used by client. Lifetime defaults arbitrarily to 600, but this doesn't matter + * because the client side entity immediately gets the lifetime value copied over to it by this class anyway. When + * extending this class, you must override this constructor or Minecraft won't like it, but there's no need to do + * anything inside it other than call super(). */ public EntitySpiderMinion(World world){ super(world); @@ -54,8 +76,8 @@ public class EntitySpiderMinion extends EntityCaveSpider implements ISummonedCre } /** - * Set lifetime to -1 to allow this creature to last forever. This constructor should be overridden when - * extending this class (be sure to call super()) so that AI and other things can be added. + * Set lifetime to -1 to allow this creature to last forever. This constructor should be overridden when extending + * this class (be sure to call super()) so that AI and other things can be added. */ public EntitySpiderMinion(World world, double x, double y, double z, EntityLivingBase caster, int lifetime){ super(world); @@ -66,12 +88,11 @@ public class EntitySpiderMinion extends EntityCaveSpider implements ISummonedCre } // EntitySpider overrides - + // This particular override is pretty standard: let the superclass handle basic AI like swimming, but replace its // targeting system with one that targets hostile mobs and takes the ADS into account. @Override - protected void initEntityAI() - { + protected void initEntityAI(){ super.initEntityAI(); this.targetTasks.taskEntries.clear(); // Spiders use a custom AI type specific to spiders which I can't access, but it's just an extension of @@ -81,25 +102,23 @@ public class EntitySpiderMinion extends EntityCaveSpider implements ISummonedCre this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, 0, false, true, this.getTargetSelector())); } - + // No spider jockeys! @Override - public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) { - - // Can't call super, so the code from the next level up (EntityLiving) had to be copied as well. - this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, 1)); + public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata){ - if (this.rand.nextFloat() < 0.05F) - { - this.setLeftHanded(true); - } - else - { - this.setLeftHanded(false); - } - - // Don't need anything from EntitySpider, since neither spider jockeys nor group data is relevant. - return livingdata; + // Can't call super, so the code from the next level up (EntityLiving) had to be copied as well. + this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE) + .applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, 1)); + + if(this.rand.nextFloat() < 0.05F){ + this.setLeftHanded(true); + }else{ + this.setLeftHanded(false); + } + + // Don't need anything from EntitySpider, since neither spider jockeys nor group data is relevant. + return livingdata; } // Implementations @@ -124,41 +143,43 @@ public class EntitySpiderMinion extends EntityCaveSpider implements ISummonedCre public void onDespawn(){ this.spawnParticleEffect(); } - + private void spawnParticleEffect(){ - if(this.worldObj.isRemote){ - for(int i=0;i<15;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, worldObj, this.posX + this.rand.nextFloat(), this.posY + this.rand.nextFloat(), this.posZ + this.rand.nextFloat(), 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.2f, 0.0f); - } + if(this.world.isRemote){ + for(int i = 0; i < 15; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, this.posX + this.rand.nextFloat(), + this.posY + this.rand.nextFloat(), this.posZ + this.rand.nextFloat(), 0.0d, 0.0d, 0.0d, 0, 0.1f, + 0.2f, 0.0f); + } } } @Override - public boolean hasParticleEffect() { + public boolean hasParticleEffect(){ return true; } - + @Override public void onSuccessfulAttack(EntityLivingBase target){ - + int seconds = 0; - if(this.worldObj.getDifficulty() == EnumDifficulty.NORMAL){ - seconds = 7; - }else if(this.worldObj.getDifficulty() == EnumDifficulty.HARD){ - seconds = 15; - } + if(this.world.getDifficulty() == EnumDifficulty.NORMAL){ + seconds = 7; + }else if(this.world.getDifficulty() == EnumDifficulty.HARD){ + seconds = 15; + } - if(seconds > 0){ - target.addPotionEffect(new PotionEffect(MobEffects.POISON, seconds * 20, 0)); - } + if(seconds > 0){ + target.addPotionEffect(new PotionEffect(MobEffects.POISON, seconds * 20, 0)); + } } @Override - protected boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack) { + protected boolean processInteract(EntityPlayer player, EnumHand hand){ // In this case, the delegate method determines whether super is called. - // Rather handily, we can make use of Java's 'stop as soon as you find true' method of evaluating OR statements. - return this.interactDelegate(player, hand, stack) || super.processInteract(player, hand, stack); + // Rather handily, we can make use of Java's short-circuiting method of evaluating OR statements. + return this.interactDelegate(player, hand) || super.processInteract(player, hand); } @Override @@ -175,13 +196,36 @@ public class EntitySpiderMinion extends EntityCaveSpider implements ISummonedCre // Recommended overrides - @Override protected int getExperiencePoints(EntityPlayer player){ return 0; } - @Override protected boolean canDropLoot(){ return false; } - @Override protected Item getDropItem(){ return null; } - @Override protected ResourceLocation getLootTable(){ return null; } - @Override public boolean canPickUpLoot(){ return false; } + @Override + protected int getExperiencePoints(EntityPlayer player){ + return 0; + } + + @Override + protected boolean canDropLoot(){ + return false; + } + + @Override + protected Item getDropItem(){ + return null; + } + + @Override + protected ResourceLocation getLootTable(){ + return null; + } + + @Override + public boolean canPickUpLoot(){ + return false; + } + // This vanilla method has nothing to do with the custom despawn() method. - @Override protected boolean canDespawn(){ return false; } + @Override + protected boolean canDespawn(){ + return false; + } @Override public boolean canAttackClass(Class entityType){ @@ -192,7 +236,7 @@ public class EntitySpiderMinion extends EntityCaveSpider implements ISummonedCre @Override public ITextComponent getDisplayName(){ if(getCaster() != null){ - return new TextComponentTranslation(NAMEPLATE_TRANSLATION_KEY, getCaster().getName(), + return new TextComponentTranslation(NAMEPLATE_TRANSLATION_KEY, getCaster().getName(), new TextComponentTranslation("entity." + this.getEntityString() + ".name")); }else{ return super.getDisplayName(); diff --git a/src/main/java/electroblob/wizardry/entity/living/EntitySpiritHorse.java b/src/main/java/electroblob/wizardry/entity/living/EntitySpiritHorse.java index 47be717e..227b713a 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntitySpiritHorse.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntitySpiritHorse.java @@ -23,78 +23,74 @@ import net.minecraft.util.text.translation.I18n; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.World; -/** Does not implement ISummonedCreature because it has different despawning rules and because EntityHorse already - * has an owner system. */ +/** + * Does not implement ISummonedCreature because it has different despawning rules and because EntityHorse already has an + * owner system. + */ @SuppressWarnings("deprecation") // It's what Entity does, so... public class EntitySpiritHorse extends EntityHorse { - + private int idleTimer = 0; - public EntitySpiritHorse(World par1World) - { + public EntitySpiritHorse(World par1World){ super(par1World); } @Override - public String getName() - { - if (this.hasCustomName()) - { + public String getName(){ + if(this.hasCustomName()){ return this.getCustomNameTag(); - } - else - { + }else{ return I18n.translateToLocal("entity.wizardry.Spirit Horse.name"); } } @Override - public boolean isChested() - { - return false; - } - - @Override - public int getTotalArmorValue() - { + public int getTotalArmorValue(){ return 0; } - + @Override - protected int getExperiencePoints(EntityPlayer p_70693_1_){ - return 0; - } - + protected int getExperiencePoints(EntityPlayer p_70693_1_){ + return 0; + } + @Override protected Item getDropItem(){ - - return null; - } + + return null; + } @Override - protected void dropFewItems(boolean par1, int par2){} + protected void dropFewItems(boolean par1, int par2){ + } @Override - protected void applyEntityAttributes() - { - super.applyEntityAttributes(); - this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(24.0D); - } - - @Override - public void openGUI(EntityPlayer p_110199_1_){} + protected void applyEntityAttributes(){ + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(24.0D); + } @Override - public boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack){ - - ItemStack itemstack = player.inventory.getCurrentItem(); - - // Allows the owner (but not other players) to dispel the spirit horse using a wand (shift-clicking, because clicking mounts the horse in this case). - if(itemstack != null && itemstack.getItem() instanceof ItemWand && this.getOwner() == player && player.isSneaking()){ + public void openGUI(EntityPlayer p_110199_1_){ + } + + @Override + public boolean processInteract(EntityPlayer player, EnumHand hand){ + + ItemStack itemstack = player.getHeldItem(hand); + + // Allows the owner (but not other players) to dispel the spirit horse using a wand (shift-clicking, because + // clicking mounts the horse in this case). + if(itemstack.getItem() instanceof ItemWand && this.getOwner() == player && player.isSneaking()){ // Prevents accidental double clicking. if(this.ticksExisted > 20){ - for(int i=0;i<15;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, this.posX - this.width/2 + this.rand.nextFloat()*width, this.posY + this.height*this.rand.nextFloat() + 0.2f, this.posZ - this.width/2 + this.rand.nextFloat()*width, 0, 0, 0, 48 + this.rand.nextInt(12), 0.8f, 0.8f, 1.0f); + for(int i = 0; i < 15; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + this.posX - this.width / 2 + this.rand.nextFloat() * width, + this.posY + this.height * this.rand.nextFloat() + 0.2f, + this.posZ - this.width / 2 + this.rand.nextFloat() * width, 0, 0, 0, + 48 + this.rand.nextInt(12), 0.8f, 0.8f, 1.0f); } this.setDead(); if(WizardData.get(player) != null){ @@ -106,15 +102,15 @@ public class EntitySpiritHorse extends EntityHorse { } return false; } - - return super.processInteract(player, hand, itemstack); + + return super.processInteract(player, hand); } - + @Override public void onDeath(DamageSource par1DamageSource){ - + super.onDeath(par1DamageSource); - + // Allows player to summon another spirit horse once this one has died. if(this.getOwner() instanceof EntityPlayer && WizardData.get((EntityPlayer)this.getOwner()) != null){ WizardData.get((EntityPlayer)this.getOwner()).hasSpiritHorse = false; @@ -123,10 +119,10 @@ public class EntitySpiritHorse extends EntityHorse { // I wrote this one! private EntityLivingBase getOwner(){ - + // I think the DataManager stores any objects, so it now stores the UUID instead of its string representation. - Entity owner = WizardryUtilities.getEntityByUUID(worldObj, this.getOwnerUniqueId()); - + Entity owner = WizardryUtilities.getEntityByUUID(world, this.getOwnerUniqueId()); + if(owner instanceof EntityLivingBase){ return (EntityLivingBase)owner; }else{ @@ -136,12 +132,15 @@ public class EntitySpiritHorse extends EntityHorse { @Override public void onUpdate(){ - + super.onUpdate(); // Adds a dust particle effect - if(this.worldObj.isRemote){ - Wizardry.proxy.spawnParticle(WizardryParticleType.DUST, worldObj, this.posX - this.width/2 + this.rand.nextFloat()*width, this.posY + this.height*this.rand.nextFloat() + 0.2f, this.posZ - this.width/2 + this.rand.nextFloat()*width, 0, 0, 0, 0, 0.8f, 0.8f, 1.0f); + if(this.world.isRemote){ + Wizardry.proxy.spawnParticle(WizardryParticleType.DUST, world, + this.posX - this.width / 2 + this.rand.nextFloat() * width, + this.posY + this.height * this.rand.nextFloat() + 0.2f, + this.posZ - this.width / 2 + this.rand.nextFloat() * width, 0, 0, 0, 0, 0.8f, 0.8f, 1.0f); } // Spirit horse disappears a short time after being dismounted. @@ -152,9 +151,13 @@ public class EntitySpiritHorse extends EntityHorse { } if(this.idleTimer > 200){ - if(this.worldObj.isRemote){ - for(int i=0;i<15;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, this.posX - this.width/2 + this.rand.nextFloat()*width, this.posY + this.height*this.rand.nextFloat() + 0.2f, this.posZ - this.width/2 + this.rand.nextFloat()*width, 0, 0, 0, 48 + this.rand.nextInt(12), 0.8f, 0.8f, 1.0f); + if(this.world.isRemote){ + for(int i = 0; i < 15; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + this.posX - this.width / 2 + this.rand.nextFloat() * width, + this.posY + this.height * this.rand.nextFloat() + 0.2f, + this.posZ - this.width / 2 + this.rand.nextFloat() * width, 0, 0, 0, + 48 + this.rand.nextInt(12), 0.8f, 0.8f, 1.0f); } } this.playSound(WizardrySounds.SPELL_HEAL, 0.7F, rand.nextFloat() * 0.4F + 1.0F); @@ -170,24 +173,28 @@ public class EntitySpiritHorse extends EntityHorse { public boolean canMateWith(EntityAnimal par1EntityAnimal){ return false; } - + @Override public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData data){ - + // Adds Particles on spawn. Due to client/server differences this cannot be done in the item. - if(this.worldObj.isRemote){ - for(int i=0;i<15;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, this.posX - this.width/2 + this.rand.nextFloat()*width, this.posY + this.height*this.rand.nextFloat() + 0.2f, this.posZ - this.width/2 + this.rand.nextFloat()*width, 0, 0, 0, 48 + this.rand.nextInt(12), 0.8f, 0.8f, 1.0f); + if(this.world.isRemote){ + for(int i = 0; i < 15; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + this.posX - this.width / 2 + this.rand.nextFloat() * width, + this.posY + this.height * this.rand.nextFloat() + 0.2f, + this.posZ - this.width / 2 + this.rand.nextFloat() * width, 0, 0, 0, 48 + this.rand.nextInt(12), + 0.8f, 0.8f, 1.0f); } } - + return super.onInitialSpawn(difficulty, data); } - + @Override public ITextComponent getDisplayName(){ if(getOwner() != null){ - return new TextComponentTranslation(ISummonedCreature.NAMEPLATE_TRANSLATION_KEY, getOwner().getName(), + return new TextComponentTranslation(ISummonedCreature.NAMEPLATE_TRANSLATION_KEY, getOwner().getName(), new TextComponentTranslation("entity." + this.getEntityString() + ".name")); }else{ return super.getDisplayName(); diff --git a/src/main/java/electroblob/wizardry/entity/living/EntitySpiritWolf.java b/src/main/java/electroblob/wizardry/entity/living/EntitySpiritWolf.java index 6de76c7b..9fd953d3 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntitySpiritWolf.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntitySpiritWolf.java @@ -29,119 +29,133 @@ import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.World; -/** Does not implement ISummonedCreature because it has different despawning rules and because EntityWolf already - * has an owner system. */ +/** + * Does not implement ISummonedCreature because it has different despawning rules and because EntityWolf already has an + * owner system. + */ public class EntitySpiritWolf extends EntityWolf { - public EntitySpiritWolf(World par1World){ - - super(par1World); - this.experienceValue = 0; - } - - @Override - protected void initEntityAI(){ - - this.aiSit = new EntityAISit(this); - this.tasks.addTask(1, new EntityAISwimming(this)); - this.tasks.addTask(2, this.aiSit); - this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); - this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, true)); - this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F)); - this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); - this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); - this.tasks.addTask(9, new EntityAILookIdle(this)); - this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); - this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); - this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true, new Class[0])); - } + public EntitySpiritWolf(World par1World){ - @Override - public void onDeath(DamageSource source){ - - // Allows player to summon another spirit wolf once this one has died. - // NOTE: This has been known to work incorrectly. + super(par1World); + this.experienceValue = 0; + } + + @Override + protected void initEntityAI(){ + + this.aiSit = new EntityAISit(this); + this.tasks.addTask(1, new EntityAISwimming(this)); + this.tasks.addTask(2, this.aiSit); + this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); + this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, true)); + this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F)); + this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); + this.tasks.addTask(9, new EntityAILookIdle(this)); + this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); + this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); + this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true, new Class[0])); + } + + @Override + public void onDeath(DamageSource source){ + + // Allows player to summon another spirit wolf once this one has died. + // NOTE: This has been known to work incorrectly. if(this.getOwner() instanceof EntityPlayer && WizardData.get((EntityPlayer)this.getOwner()) != null){ WizardData.get((EntityPlayer)this.getOwner()).hasSpiritWolf = false; } - - super.onDeath(source); - } - - @Override - protected int getExperiencePoints(EntityPlayer p_70693_1_){ - return 0; - } - - @Override - public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) { - // Adds Particles on spawn. Due to client/server differences this cannot be done in the item. - if(this.worldObj.isRemote){ - for(int i=0;i<15;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, worldObj, this.posX - this.width/2 + this.rand.nextFloat()*width, this.posY + this.height*this.rand.nextFloat() + 0.2f, this.posZ - this.width/2 + this.rand.nextFloat()*width, 0, 0, 0, 48 + this.rand.nextInt(12), 0.8f, 0.8f, 1.0f); - } - } - + super.onDeath(source); + } + + @Override + protected int getExperiencePoints(EntityPlayer p_70693_1_){ + return 0; + } + + @Override + public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata){ + + // Adds Particles on spawn. Due to client/server differences this cannot be done + // in the item. + if(this.world.isRemote){ + for(int i = 0; i < 15; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + this.posX - this.width / 2 + this.rand.nextFloat() * width, + this.posY + this.height * this.rand.nextFloat() + 0.2f, + this.posZ - this.width / 2 + this.rand.nextFloat() * width, 0, 0, 0, 48 + this.rand.nextInt(12), + 0.8f, 0.8f, 1.0f); + } + } + return livingdata; - } - - @Override - public void onUpdate(){ - - super.onUpdate(); - - // Adds a dust particle effect - if(this.worldObj.isRemote){ - Wizardry.proxy.spawnParticle(WizardryParticleType.DUST, worldObj, this.posX - this.width/2 + this.rand.nextFloat()*width, this.posY + this.height*this.rand.nextFloat() + 0.2f, this.posZ - this.width/2 + this.rand.nextFloat()*width, 0, 0, 0, 0, 0.8f, 0.8f, 1.0f); - } - } - - @Override - public boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack) { + } - if (this.isTamed()) - { - if (stack != null){ - - // Allows the owner (but not other players) to dispel the spirit wolf using a wand. - if(stack != null && stack.getItem() instanceof ItemWand && this.getOwner() == player && player.isSneaking()){ - // Prevents accidental double clicking. - if(this.ticksExisted > 20){ - for(int i=0;i<10;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, this.posX - this.width/2 + this.rand.nextFloat()*width, this.posY + this.height*this.rand.nextFloat() + 0.2f, this.posZ - this.width/2 + this.rand.nextFloat()*width, 0, 0, 0, 48 + this.rand.nextInt(12), 0.8f, 0.8f, 1.0f); - } - this.setDead(); - if(WizardData.get(player) != null){ - WizardData.get(player).hasSpiritWolf = false; - } - this.playSound(WizardrySounds.SPELL_HEAL, 0.7F, rand.nextFloat() * 0.4F + 1.0F); - // This is necessary to prevent the wand's spell being cast when performing this action. - return true; - } - } - } - } + @Override + public void onUpdate(){ - return super.processInteract(player, hand, stack); - } + super.onUpdate(); - @Override - public EntityWolf createChild(EntityAgeable par1EntityAgeable) - { - return null; - } + // Adds a dust particle effect + if(this.world.isRemote){ + Wizardry.proxy.spawnParticle(WizardryParticleType.DUST, world, + this.posX - this.width / 2 + this.rand.nextFloat() * width, + this.posY + this.height * this.rand.nextFloat() + 0.2f, + this.posZ - this.width / 2 + this.rand.nextFloat() * width, 0, 0, 0, 0, 0.8f, 0.8f, 1.0f); + } + } - @Override - protected Item getDropItem() - { - return null; - } - - @Override + @Override + public boolean processInteract(EntityPlayer player, EnumHand hand){ + + ItemStack stack = player.getHeldItem(hand); + + if(this.isTamed()){ + + // Allows the owner (but not other players) to dispel the spirit wolf using a + // wand. + if(stack.getItem() instanceof ItemWand && this.getOwner() == player && player.isSneaking()){ + // Prevents accidental double clicking. + if(this.ticksExisted > 20){ + for(int i = 0; i < 10; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + this.posX - this.width / 2 + this.rand.nextFloat() * width, + this.posY + this.height * this.rand.nextFloat() + 0.2f, + this.posZ - this.width / 2 + this.rand.nextFloat() * width, 0, 0, 0, + 48 + this.rand.nextInt(12), 0.8f, 0.8f, 1.0f); + } + this.setDead(); + if(WizardData.get(player) != null){ + WizardData.get(player).hasSpiritWolf = false; + } + this.playSound(WizardrySounds.SPELL_HEAL, 0.7F, rand.nextFloat() * 0.4F + 1.0F); + // This is necessary to prevent the wand's spell being cast when performing this + // action. + return true; + } + } + } + + return super.processInteract(player, hand); + + } + + @Override + public EntityWolf createChild(EntityAgeable par1EntityAgeable){ + return null; + } + + @Override + protected Item getDropItem(){ + return null; + } + + @Override public ITextComponent getDisplayName(){ if(getOwner() != null){ - return new TextComponentTranslation(ISummonedCreature.NAMEPLATE_TRANSLATION_KEY, getOwner().getName(), + return new TextComponentTranslation(ISummonedCreature.NAMEPLATE_TRANSLATION_KEY, getOwner().getName(), new TextComponentTranslation("entity." + this.getEntityString() + ".name")); }else{ return super.getDisplayName(); @@ -150,7 +164,8 @@ public class EntitySpiritWolf extends EntityWolf { @Override public boolean hasCustomName(){ - // If this returns true, the renderer will show the nameplate when looking directly at the entity + // If this returns true, the renderer will show the nameplate when looking + // directly at the entity return Wizardry.settings.showSummonedCreatureNames && getOwner() != null; } diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityStormElemental.java b/src/main/java/electroblob/wizardry/entity/living/EntityStormElemental.java index 204d95a0..5eb74cd9 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntityStormElemental.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntityStormElemental.java @@ -25,11 +25,11 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class EntityStormElemental extends EntitySummonedCreature implements ISpellCaster { - + private double AISpeed = 1.0; - - private EntityAIAttackSpell spellAttackAI = new EntityAIAttackSpell(this, AISpeed, 15f, 30, 0); - + + private EntityAIAttackSpell spellAttackAI = new EntityAIAttackSpell(this, AISpeed, 15f, 30, 0); + private static final List attack = Collections.singletonList(Spells.lightning_disc); public EntityStormElemental(World world){ @@ -39,24 +39,24 @@ public class EntityStormElemental extends EntitySummonedCreature implements ISpe public EntityStormElemental(World world, double x, double y, double z, EntityLivingBase caster, int lifetime){ super(world, x, y, z, caster, lifetime); // For some reason this can't be in initEntityAI - this.tasks.addTask(0, this.spellAttackAI); + this.tasks.addTask(0, this.spellAttackAI); } - + @Override protected void initEntityAI(){ - this.tasks.addTask(1, new EntityAIAttackMelee(this, AISpeed, false)); + this.tasks.addTask(1, new EntityAIAttackMelee(this, AISpeed, false)); this.tasks.addTask(2, new EntityAIWander(this, AISpeed)); this.tasks.addTask(3, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); - this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, - 0, false, true, this.getTargetSelector())); + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, + 0, false, true, this.getTargetSelector())); - this.setAIMoveSpeed((float)AISpeed); + this.setAIMoveSpeed((float)AISpeed); } @Override - public boolean hasRangedAttack() { + public boolean hasRangedAttack(){ return true; } @@ -83,27 +83,27 @@ public class EntityStormElemental extends EntitySummonedCreature implements ISpe @Override protected void applyEntityAttributes(){ super.applyEntityAttributes(); - this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(AISpeed); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(30.0D); this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(16.0D); } - @Override - protected SoundEvent getAmbientSound(){ - return SoundEvents.ENTITY_BLAZE_AMBIENT; - } + @Override + protected SoundEvent getAmbientSound(){ + return SoundEvents.ENTITY_BLAZE_AMBIENT; + } - @Override - protected SoundEvent getHurtSound(){ - return SoundEvents.ENTITY_BLAZE_HURT; - } + @Override + protected SoundEvent getHurtSound(){ + return SoundEvents.ENTITY_BLAZE_HURT; + } + + @Override + protected SoundEvent getDeathSound(){ + return SoundEvents.ENTITY_BLAZE_DEATH; + } - @Override - protected SoundEvent getDeathSound(){ - return SoundEvents.ENTITY_BLAZE_DEATH; - } - @Override @SideOnly(Side.CLIENT) public int getBrightnessForRender(float partialTicks){ @@ -122,8 +122,9 @@ public class EntityStormElemental extends EntitySummonedCreature implements ISpe this.playSound(WizardrySounds.SPELL_LOOP_WIND, 1.0f, 1.0f); } - if (this.rand.nextInt(24) == 0){ - this.playSound(SoundEvents.ENTITY_BLAZE_BURN, 1.0F + this.rand.nextFloat(), this.rand.nextFloat() * 0.7F + 0.3F); + if(this.rand.nextInt(24) == 0){ + this.playSound(SoundEvents.ENTITY_BLAZE_BURN, 1.0F + this.rand.nextFloat(), + this.rand.nextFloat() * 0.7F + 0.3F); } // Slow fall @@ -131,28 +132,35 @@ public class EntityStormElemental extends EntitySummonedCreature implements ISpe this.motionY *= 0.6D; } - if(worldObj.isRemote){ - - for(int i=0; i<2; ++i){ - worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0, 0, 0); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, worldObj, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0d, 0.0d, 0.0d, 0, 0, 0, 0); + if(world.isRemote){ + + for(int i = 0; i < 2; ++i){ + world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, + this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, + this.posY + this.rand.nextDouble() * (double)this.height, + this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0, 0, 0); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, + this.posY + this.rand.nextDouble() * (double)this.height, + this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0d, 0.0d, 0.0d, 0, 0, 0, 0); } - for(int i=0; i<10; i++){ - float brightness = rand.nextFloat()*0.2f; + for(int i = 0; i < 10; i++){ + float brightness = rand.nextFloat() * 0.2f; double dy = this.rand.nextDouble() * (double)this.height; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE_ROTATING, worldObj, this.posX, this.posY + dy, this.posZ, 0, 0, 0, 20 + rand.nextInt(10), 0, brightness, brightness, false, 0.2f + 0.5f*dy); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE_ROTATING, world, this.posX, this.posY + dy, + this.posZ, 0, 0, 0, 20 + rand.nextInt(10), 0, brightness, brightness, false, 0.2f + 0.5f * dy); } } super.onLivingUpdate(); } - + @Override public void fall(float distance, float damageMultiplier){ // Immune to fall damage. } - + @Override public void onStruckByLightning(EntityLightningBolt lightning){ // Immune to lightning. diff --git a/src/main/java/electroblob/wizardry/entity/living/EntitySummonedCreature.java b/src/main/java/electroblob/wizardry/entity/living/EntitySummonedCreature.java index 9ed6d48f..e3cd7d50 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntitySummonedCreature.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntitySummonedCreature.java @@ -9,7 +9,6 @@ import net.minecraft.entity.EntityFlying; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; @@ -17,12 +16,16 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; -/** Abstract base implementation of {@link ISummonedCreature} which is the superclass to all custom summoned entities - * (i.e. entities that don't extend vanilla/mod creatures). Also serves as an example of how to correctly implement - * the above interface, and includes some non-critical method overrides which should be used for best results (xp, drops, - * and such like). Not to be confused with the old version of EntitySummonedCreature; that system has been replaced. +/** + * Abstract base implementation of {@link ISummonedCreature} which is the superclass to all custom summoned entities + * (i.e. entities that don't extend vanilla/mod creatures). Also serves as an example of how to correctly implement the + * above interface, and includes some non-critical method overrides which should be used for best results (xp, drops, + * and such like). Not to be confused with the old version of EntitySummonedCreature; that system has been + * replaced. + * * @since Wizardry 1.2 - * @author Electroblob */ + * @author Electroblob + */ public abstract class EntitySummonedCreature extends EntityCreature implements ISummonedCreature { // Field implementations @@ -31,18 +34,41 @@ public abstract class EntitySummonedCreature extends EntityCreature implements I private UUID casterUUID; // Setter + getter implementations - @Override public int getLifetime(){ return lifetime; } - @Override public void setLifetime(int lifetime){ this.lifetime = lifetime; } - @Override public WeakReference getCasterReference(){ return casterReference; } - @Override public void setCasterReference(WeakReference reference){ casterReference = reference; } - @Override public UUID getCasterUUID() { return casterUUID; } - @Override public void setCasterUUID(UUID uuid) { this.casterUUID = uuid; } + @Override + public int getLifetime(){ + return lifetime; + } + + @Override + public void setLifetime(int lifetime){ + this.lifetime = lifetime; + } + + @Override + public WeakReference getCasterReference(){ + return casterReference; + } + + @Override + public void setCasterReference(WeakReference reference){ + casterReference = reference; + } + + @Override + public UUID getCasterUUID(){ + return casterUUID; + } + + @Override + public void setCasterUUID(UUID uuid){ + this.casterUUID = uuid; + } /** - * Default shell constructor, only used by client. Lifetime defaults arbitrarily to 600, but this doesn't - * matter because the client side entity immediately gets the lifetime value copied over to it by this class - * anyway. When extending this class, you must override this constructor or Minecraft won't like it, but there's - * no need to do anything inside it other than call super(). + * Default shell constructor, only used by client. Lifetime defaults arbitrarily to 600, but this doesn't matter + * because the client side entity immediately gets the lifetime value copied over to it by this class anyway. When + * extending this class, you must override this constructor or Minecraft won't like it, but there's no need to do + * anything inside it other than call super(). */ public EntitySummonedCreature(World world){ super(world); @@ -50,8 +76,8 @@ public abstract class EntitySummonedCreature extends EntityCreature implements I } /** - * Set lifetime to -1 to allow this creature to last forever. This constructor should be overridden when - * extending this class (be sure to call super()) so that AI and other things can be added. + * Set lifetime to -1 to allow this creature to last forever. This constructor should be overridden when extending + * this class (be sure to call super()) so that AI and other things can be added. */ public EntitySummonedCreature(World world, double x, double y, double z, EntityLivingBase caster, int lifetime){ super(world); @@ -60,7 +86,7 @@ public abstract class EntitySummonedCreature extends EntityCreature implements I this.experienceValue = 0; this.lifetime = lifetime; } - + // Implementations @Override @@ -75,21 +101,23 @@ public abstract class EntitySummonedCreature extends EntityCreature implements I } @Override - public void onSpawn(){} + public void onSpawn(){ + } @Override - public void onDespawn(){} + public void onDespawn(){ + } @Override - public boolean hasParticleEffect() { + public boolean hasParticleEffect(){ return false; } @Override - protected boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack) { + protected boolean processInteract(EntityPlayer player, EnumHand hand){ // In this case, the delegate method determines whether super is called. // Rather handily, we can make use of Java's short-circuiting method of evaluating OR statements. - return this.interactDelegate(player, hand, stack) || super.processInteract(player, hand, stack); + return this.interactDelegate(player, hand) || super.processInteract(player, hand); } @Override @@ -106,13 +134,36 @@ public abstract class EntitySummonedCreature extends EntityCreature implements I // Recommended overrides - @Override protected int getExperiencePoints(EntityPlayer player){ return 0; } - @Override protected boolean canDropLoot(){ return false; } - @Override protected Item getDropItem(){ return null; } - @Override protected ResourceLocation getLootTable(){ return null; } - @Override public boolean canPickUpLoot(){ return false; } + @Override + protected int getExperiencePoints(EntityPlayer player){ + return 0; + } + + @Override + protected boolean canDropLoot(){ + return false; + } + + @Override + protected Item getDropItem(){ + return null; + } + + @Override + protected ResourceLocation getLootTable(){ + return null; + } + + @Override + public boolean canPickUpLoot(){ + return false; + } + // This vanilla method has nothing to do with the custom onDespawn() method. - @Override protected boolean canDespawn(){ return false; } + @Override + protected boolean canDespawn(){ + return false; + } @Override public boolean canAttackClass(Class entityType){ @@ -124,7 +175,7 @@ public abstract class EntitySummonedCreature extends EntityCreature implements I @Override public ITextComponent getDisplayName(){ if(getCaster() != null){ - return new TextComponentTranslation(NAMEPLATE_TRANSLATION_KEY, getCaster().getName(), + return new TextComponentTranslation(NAMEPLATE_TRANSLATION_KEY, getCaster().getName(), new TextComponentTranslation("entity." + this.getEntityString() + ".name")); }else{ return super.getDisplayName(); diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityWitherSkeletonMinion.java b/src/main/java/electroblob/wizardry/entity/living/EntityWitherSkeletonMinion.java new file mode 100644 index 00000000..c19aad97 --- /dev/null +++ b/src/main/java/electroblob/wizardry/entity/living/EntityWitherSkeletonMinion.java @@ -0,0 +1,255 @@ +package electroblob.wizardry.entity.living; + +import java.lang.ref.WeakReference; +import java.util.Calendar; +import java.util.UUID; + +import javax.annotation.Nullable; + +import electroblob.wizardry.Wizardry; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIHurtByTarget; +import net.minecraft.entity.ai.EntityAINearestAttackableTarget; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.monster.EntityWitherSkeleton; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.init.MobEffects; +import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.EnumHand; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.world.DifficultyInstance; +import net.minecraft.world.World; + +public class EntityWitherSkeletonMinion extends EntityWitherSkeleton implements ISummonedCreature { + + // Field implementations + private int lifetime = 600; + private WeakReference casterReference; + private UUID casterUUID; + + // Setter + getter implementations + @Override + public int getLifetime(){ + return lifetime; + } + + @Override + public void setLifetime(int lifetime){ + this.lifetime = lifetime; + } + + @Override + public WeakReference getCasterReference(){ + return casterReference; + } + + @Override + public void setCasterReference(WeakReference reference){ + casterReference = reference; + } + + @Override + public UUID getCasterUUID(){ + return casterUUID; + } + + @Override + public void setCasterUUID(UUID uuid){ + this.casterUUID = uuid; + } + + /** + * Default shell constructor, only used by client. Lifetime defaults arbitrarily to 600, but this doesn't matter + * because the client side entity immediately gets the lifetime value copied over to it by this class anyway. When + * extending this class, you must override this constructor or Minecraft won't like it, but there's no need to do + * anything inside it other than call super(). + */ + public EntityWitherSkeletonMinion(World world){ + super(world); + this.experienceValue = 0; + } + + /** + * Set lifetime to -1 to allow this creature to last forever. This constructor should be overridden when extending + * this class (be sure to call super()) so that AI and other things can be added. + */ + public EntityWitherSkeletonMinion(World world, double x, double y, double z, EntityLivingBase caster, int lifetime){ + super(world); + this.setPosition(x, y, z); + this.casterReference = new WeakReference(caster); + this.experienceValue = 0; + this.lifetime = lifetime; + } + + // EntitySkeleton overrides + + // This particular override is pretty standard: let the superclass handle basic AI like swimming, but replace its + // targeting system with one that targets hostile mobs and takes the ADS into account. + @Override + protected void initEntityAI(){ + super.initEntityAI(); + this.targetTasks.taskEntries.clear(); + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, + 0, false, true, this.getTargetSelector())); + } + + // Shouldn't have randomised armour, but does still need a bow! + @Override + protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty){ + this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.BOW)); + } + + // Where the skeleton minion is summoned does not affect its type. + @Override + public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata){ + // Can't call super, so the code from the next level up (EntityLiving) had to be copied as well. + this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE) + .applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, 1)); + + if(this.rand.nextFloat() < 0.05F){ + this.setLeftHanded(true); + }else{ + this.setLeftHanded(false); + } + + // Halloween pumpkin heads! Why not? + if(this.getItemStackFromSlot(EntityEquipmentSlot.HEAD) == null){ + Calendar calendar = this.world.getCurrentDate(); + + if(calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.rand.nextFloat() < 0.25F){ + this.setItemStackToSlot(EntityEquipmentSlot.HEAD, + new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.LIT_PUMPKIN : Blocks.PUMPKIN)); + this.inventoryArmorDropChances[EntityEquipmentSlot.HEAD.getIndex()] = 0.0F; + } + } + + return livingdata; + } + + // Implementations + + @Override + public void setRevengeTarget(EntityLivingBase entity){ + if(this.shouldRevengeTarget(entity)) super.setRevengeTarget(entity); + } + + @Override + public void onUpdate(){ + super.onUpdate(); + this.updateDelegate(); + } + + @Override + public void onSpawn(){ + this.spawnParticleEffect(); + } + + @Override + public void onDespawn(){ + this.spawnParticleEffect(); + } + + private void spawnParticleEffect(){ + if(this.world.isRemote){ + for(int i = 0; i < 15; i++){ + this.world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX + this.rand.nextFloat(), + this.posY + 1 + this.rand.nextFloat(), this.posZ + this.rand.nextFloat(), 0, 0, 0); + } + } + } + + @Override + public boolean hasParticleEffect(){ + return true; + } + + @Override + public void onSuccessfulAttack(EntityLivingBase target){ + target.addPotionEffect(new PotionEffect(MobEffects.WITHER, 200)); + } + + @Override + protected boolean processInteract(EntityPlayer player, EnumHand hand){ + // In this case, the delegate method determines whether super is called. + // Rather handily, we can make use of Java's short-circuiting method of evaluating OR statements. + return this.interactDelegate(player, hand) || super.processInteract(player, hand); + } + + @Override + public void writeEntityToNBT(NBTTagCompound nbttagcompound){ + super.writeEntityToNBT(nbttagcompound); + this.writeNBTDelegate(nbttagcompound); + } + + @Override + public void readEntityFromNBT(NBTTagCompound nbttagcompound){ + super.readEntityFromNBT(nbttagcompound); + this.writeNBTDelegate(nbttagcompound); + } + + // Recommended overrides + + @Override + protected int getExperiencePoints(EntityPlayer player){ + return 0; + } + + @Override + protected boolean canDropLoot(){ + return false; + } + + @Override + protected Item getDropItem(){ + return null; + } + + @Override + protected ResourceLocation getLootTable(){ + return null; + } + + @Override + public boolean canPickUpLoot(){ + return false; + } + + // This vanilla method has nothing to do with the custom despawn() method. + @Override + protected boolean canDespawn(){ + return false; + } + + @Override + public boolean canAttackClass(Class entityType){ + return true; + } + + @Override + public ITextComponent getDisplayName(){ + if(getCaster() != null){ + return new TextComponentTranslation(NAMEPLATE_TRANSLATION_KEY, getCaster().getName(), + new TextComponentTranslation("entity." + this.getEntityString() + ".name")); + }else{ + return super.getDisplayName(); + } + } + + @Override + public boolean hasCustomName(){ + // If this returns true, the renderer will show the nameplate when looking directly at the entity + return Wizardry.settings.showSummonedCreatureNames && getCaster() != null; + } +} diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityWizard.java b/src/main/java/electroblob/wizardry/entity/living/EntityWizard.java index 7123ed28..01f8665c 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntityWizard.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntityWizard.java @@ -69,8 +69,8 @@ import net.minecraft.village.MerchantRecipe; import net.minecraft.village.MerchantRecipeList; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.World; -import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.Constants.NBT; +import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -83,14 +83,12 @@ import net.minecraftforge.oredict.OreDictionary; @Mod.EventBusSubscriber public class EntityWizard extends EntityVillager implements ISpellCaster, IEntityAdditionalSpawnData { - /* - * After much debugging, the error in the compiled mod (outside of eclipse) was traced back to this class, + /* After much debugging, the error in the compiled mod (outside of eclipse) was traced back to this class, * specifically the methods copied in from EntityVillager when I changed this class to extend it. This figures, - * since I had 1.2.1 working just fine before I did that, and it was the only thing I changed. Apparently, - * methods and fields with obfuscated names like func_129090_a can cause problems when compiled. One of the - * ones here was renamed and the other deleted since it was never called. Watch out for this in future (unless, - * of course, they are overriding something, in which case it should be fine). - */ + * since I had 1.2.1 working just fine before I did that, and it was the only thing I changed. Apparently, methods + * and fields with obfuscated names like func_129090_a can cause problems when compiled. One of the ones here was + * renamed and the other deleted since it was never called. Watch out for this in future (unless, of course, they + * are overriding something, in which case it should be fine). */ // Extending EntityVillager turned out to be a pretty neat thing to do, since now zombies will attack wizards @@ -109,11 +107,13 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit private boolean updateRecipes; /** Data parameter for the cooldown time for wizards healing themselves. */ - private static final DataParameter HEAL_COOLDOWN = EntityDataManager.createKey(EntityWizard.class, DataSerializers.VARINT); + private static final DataParameter HEAL_COOLDOWN = EntityDataManager.createKey(EntityWizard.class, + DataSerializers.VARINT); /** Data parameter for the wizard's element. */ - private static final DataParameter ELEMENT = EntityDataManager.createKey(EntityWizard.class, DataSerializers.VARINT); + private static final DataParameter ELEMENT = EntityDataManager.createKey(EntityWizard.class, + DataSerializers.VARINT); - // Field implementations + // Field implementations private List spells = new ArrayList(4); private Spell continuousSpell; @@ -126,14 +126,14 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit // For some reason this can't be in initEntityAI this.tasks.addTask(3, this.spellCastingAI); } - + @Override protected void entityInit(){ super.entityInit(); this.dataManager.register(HEAL_COOLDOWN, -1); this.dataManager.register(ELEMENT, 0); } - + @Override protected void initEntityAI(){ @@ -153,14 +153,17 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit public boolean apply(Entity entity){ // If the target is valid and not invisible... - if(entity != null && !entity.isInvisible() && WizardryUtilities.isValidTarget(EntityWizard.this, entity)){ + if(entity != null && !entity.isInvisible() + && WizardryUtilities.isValidTarget(EntityWizard.this, entity)){ - //... and is a mob, a summoned creature ... + // ... and is a mob, a summoned creature ... if((entity instanceof IMob || entity instanceof ISummonedCreature - // ... or in the whitelist ... - || Arrays.asList(Wizardry.settings.summonedCreatureTargetsWhitelist).contains(EntityList.getEntityString(entity).toLowerCase(Locale.ROOT))) + // ... or in the whitelist ... + || Arrays.asList(Wizardry.settings.summonedCreatureTargetsWhitelist) + .contains(EntityList.getEntityString(entity).toLowerCase(Locale.ROOT))) // ... and isn't in the blacklist ... - && !Arrays.asList(Wizardry.settings.summonedCreatureTargetsBlacklist).contains(EntityList.getEntityString(entity).toLowerCase(Locale.ROOT))){ + && !Arrays.asList(Wizardry.settings.summonedCreatureTargetsBlacklist) + .contains(EntityList.getEntityString(entity).toLowerCase(Locale.ROOT))){ // ... it can be attacked. return true; } @@ -172,7 +175,8 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); // By default, wizards don't attack players unless the player has attacked them. - this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, false, true, this.targetSelector)); + this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, + false, true, this.targetSelector)); } @Override @@ -180,11 +184,11 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5); } - + private int getHealCooldown(){ return this.dataManager.get(HEAL_COOLDOWN); } - + private void setHealCooldown(int cooldown){ this.dataManager.set(HEAL_COOLDOWN, cooldown); } @@ -206,12 +210,12 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit public SpellModifiers getModifiers(){ return new SpellModifiers(); } - + @Override public void setContinuousSpell(Spell spell){ this.continuousSpell = spell; } - + @Override public Spell getContinuousSpell(){ return this.continuousSpell; @@ -229,23 +233,26 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit // affected with arcane jammer and healCooldown == 0, whilst the wizard didn't actually heal or play the sound, // the particles still spawned, and since healCooldown wasn't reset they spawned every tick until the arcane // jammer wore off. - if(healCooldown == 0 && this.getHealth() < this.getMaxHealth() && this.getHealth() > 0 && !this.isPotionActive(WizardryPotions.arcane_jammer)){ + if(healCooldown == 0 && this.getHealth() < this.getMaxHealth() && this.getHealth() > 0 + && !this.isPotionActive(WizardryPotions.arcane_jammer)){ // Healer wizards use greater heal. this.heal(this.getElement() == Element.HEALING ? 8 : 4); this.setHealCooldown(-1); - // deathTime == 0 checks the wizard isn't currently dying + // deathTime == 0 checks the wizard isn't currently dying }else if(healCooldown == -1 && this.deathTime == 0){ // Heal particles - if(worldObj.isRemote){ - for(int i=0; i<10; i++){ - double d0 = (double)((float)this.posX + rand.nextFloat()*2 - 1.0F); - // Apparently the client side spawns the particles 1 block higher than it should... hence the - 0.5F. + if(world.isRemote){ + for(int i = 0; i < 10; i++){ + double d0 = (double)((float)this.posX + rand.nextFloat() * 2 - 1.0F); + // Apparently the client side spawns the particles 1 block higher than it should... hence the - + // 0.5F. double d1 = (double)((float)this.posY - 0.5F + rand.nextFloat()); - double d2 = (double)((float)this.posZ + rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, d0, d1, d2, 0, 0.1F, 0, 48 + rand.nextInt(12), 1.0f, 1.0f, 0.3f); + double d2 = (double)((float)this.posZ + rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, 0, + 48 + rand.nextInt(12), 1.0f, 1.0f, 0.3f); } }else{ if(this.getHealth() < 10){ @@ -258,9 +265,9 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit this.playSound(WizardrySounds.SPELL_HEAL, 0.7F, rand.nextFloat() * 0.4F + 1.0F); } } - + if(healCooldown > 0){ - this.setHealCooldown(healCooldown-1); + this.setHealCooldown(healCooldown - 1); } } @@ -299,77 +306,79 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit } @Override - public boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack) { + public boolean processInteract(EntityPlayer player, EnumHand hand){ + + ItemStack stack = player.getHeldItem(hand); // Debugging - //player.addChatComponentMessage(new TextComponentTranslation("wizard.debug", Spell.get(spells[1]).getDisplayName(), Spell.get(spells[2]).getDisplayName(), Spell.get(spells[3]).getDisplayName())); + // player.addChatComponentMessage(new TextComponentTranslation("wizard.debug", + // Spell.get(spells[1]).getDisplayName(), Spell.get(spells[2]).getDisplayName(), + // Spell.get(spells[3]).getDisplayName())); // When right-clicked with a spell book in creative, sets one of the spells to that spell - if(player.capabilities.isCreativeMode && stack != null && stack.getItem() instanceof ItemSpellBook){ + if(player.capabilities.isCreativeMode && stack.getItem() instanceof ItemSpellBook){ if(this.spells.size() >= 4 && Spell.get(stack.getItemDamage()).canBeCastByNPCs()){ - this.spells.set(rand.nextInt(3)+1, Spell.get(stack.getItemDamage())); + this.spells.set(rand.nextInt(3) + 1, Spell.get(stack.getItemDamage())); return true; } } // Won't trade with a player that has attacked them. - if (this.isEntityAlive() && !this.isTrading() && !this.isChild() && !player.isSneaking() && this.getAttackTarget() != player) - { - if (!this.worldObj.isRemote) - { + if(this.isEntityAlive() && !this.isTrading() && !this.isChild() && !player.isSneaking() + && this.getAttackTarget() != player){ + if(!this.world.isRemote){ this.setCustomer(player); player.displayVillagerTradeGui(this); - //player.displayGUIMerchant(this, this.getElement().getWizardName()); + // player.displayGUIMerchant(this, this.getElement().getWizardName()); } return true; - } - else - { + }else{ return false; } } @Override - public ITextComponent getDisplayName() { + public ITextComponent getDisplayName(){ return this.getElement().getWizardName(); } @Override public void writeEntityToNBT(NBTTagCompound nbt){ - + super.writeEntityToNBT(nbt); - - if (this.trades != null){ - nbt.setTag("trades", this.trades.getRecipiesAsTags()); - } + + if(this.trades != null){ + nbt.setTag("trades", this.trades.getRecipiesAsTags()); + } nbt.setInteger("element", this.getElement().ordinal()); nbt.setInteger("skin", this.textureIndex); nbt.setTag("spells", WizardryUtilities.listToNBT(spells, spell -> new NBTTagInt(spell.id()))); if(this.towerBlocks != null && this.towerBlocks.size() > 0){ - nbt.setTag("towerBlocks", WizardryUtilities.listToNBT(this.towerBlocks, pos -> new NBTTagLong(pos.toLong()))); + nbt.setTag("towerBlocks", + WizardryUtilities.listToNBT(this.towerBlocks, pos -> new NBTTagLong(pos.toLong()))); } } @Override public void readEntityFromNBT(NBTTagCompound nbt){ - + super.readEntityFromNBT(nbt); - + if(nbt.hasKey("trades")){ - NBTTagCompound nbttagcompound1 = nbt.getCompoundTag("trades"); - this.trades = new MerchantRecipeList(nbttagcompound1); - } + NBTTagCompound nbttagcompound1 = nbt.getCompoundTag("trades"); + this.trades = new MerchantRecipeList(nbttagcompound1); + } this.setElement(Element.values()[nbt.getInteger("element")]); this.textureIndex = nbt.getInteger("skin"); - this.spells = (List) WizardryUtilities.NBTToList(nbt.getTagList("spells", NBT.TAG_INT), + this.spells = (List)WizardryUtilities.NBTToList(nbt.getTagList("spells", NBT.TAG_INT), (NBTTagInt tag) -> Spell.get(tag.getInt())); - this.towerBlocks = new HashSet(WizardryUtilities.NBTToList(nbt.getTagList("towerBlocks", - NBT.TAG_LONG), (NBTTagLong tag) -> BlockPos.fromLong(tag.getLong()))); + this.towerBlocks = new HashSet(WizardryUtilities.NBTToList( + nbt.getTagList("towerBlocks", NBT.TAG_LONG), (NBTTagLong tag) -> BlockPos.fromLong(tag.getLong()))); } @Override @@ -378,8 +387,7 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit } @Override - public boolean isTrading() - { + public boolean isTrading(){ return this.getCustomer() != null; } @@ -391,8 +399,7 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit this.playSound(SoundEvents.ENTITY_VILLAGER_YES, this.getSoundVolume(), this.getSoundPitch()); // Achievements - if (this.getCustomer() != null) - { + if(this.getCustomer() != null){ this.getCustomer().addStat(WizardryAchievements.wizard_trade); if(merchantrecipe.getItemToSell().getItem() instanceof ItemSpellBook @@ -406,12 +413,9 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit this.timeUntilReset = 40; this.updateRecipes = true; - if (this.getCustomer() != null) - { + if(this.getCustomer() != null){ this.getCustomer().getName(); - } - else - { + }else{ } } } @@ -447,9 +451,9 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit MerchantRecipeList merchantrecipelist; merchantrecipelist = new MerchantRecipeList(); - for(int i=0; i 0 && !specialismSpells.isEmpty()){ - // This means it is more likely for spell books sold to be of the same element as the wizard if the wizard has an element. - return new ItemStack(WizardryItems.spell_book, 1, specialismSpells.get(rand.nextInt(specialismSpells.size())).id()); + // This means it is more likely for spell books sold to be of the same element as the wizard if the + // wizard has an element. + return new ItemStack(WizardryItems.spell_book, 1, + specialismSpells.get(rand.nextInt(specialismSpells.size())).id()); }else{ return new ItemStack(WizardryItems.spell_book, 1, spells.get(rand.nextInt(spells.size())).id()); } }else{ if(this.getElement() != Element.MAGIC && rand.nextInt(4) > 0){ - // This means it is more likely for wands sold to be of the same element as the wizard if the wizard has an element. + // This means it is more likely for wands sold to be of the same element as the wizard if the wizard + // has an element. return new ItemStack(WizardryUtilities.getWand(tier, this.getElement())); }else{ - return new ItemStack(WizardryUtilities.getWand(tier, Element.values()[rand.nextInt(Element.values().length)])); + return new ItemStack( + WizardryUtilities.getWand(tier, Element.values()[rand.nextInt(Element.values().length)])); } } @@ -570,27 +573,34 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit randomiser = rand.nextInt(Wizardry.settings.discoveryMode ? 12 : 10); if(randomiser < 5 && !spells.isEmpty()){ if(this.getElement() != Element.MAGIC && rand.nextInt(4) > 0 && !specialismSpells.isEmpty()){ - // This means it is more likely for spell books sold to be of the same element as the wizard if the wizard has an element. - return new ItemStack(WizardryItems.spell_book, 1, specialismSpells.get(rand.nextInt(specialismSpells.size())).id()); + // This means it is more likely for spell books sold to be of the same element as the wizard if the + // wizard has an element. + return new ItemStack(WizardryItems.spell_book, 1, + specialismSpells.get(rand.nextInt(specialismSpells.size())).id()); }else{ return new ItemStack(WizardryItems.spell_book, 1, spells.get(rand.nextInt(spells.size())).id()); } }else if(randomiser < 6){ if(this.getElement() != Element.MAGIC && rand.nextInt(4) > 0){ - // This means it is more likely for wands sold to be of the same element as the wizard if the wizard has an element. + // This means it is more likely for wands sold to be of the same element as the wizard if the wizard + // has an element. return new ItemStack(WizardryUtilities.getWand(tier, this.getElement())); }else{ - return new ItemStack(WizardryUtilities.getWand(tier, Element.values()[rand.nextInt(Element.values().length)])); + return new ItemStack( + WizardryUtilities.getWand(tier, Element.values()[rand.nextInt(Element.values().length)])); } }else if(randomiser < 8){ return new ItemStack(WizardryItems.arcane_tome, 1, 1); }else if(randomiser < 10){ - EntityEquipmentSlot slot = WizardryUtilities.ARMOUR_SLOTS[rand.nextInt(WizardryUtilities.ARMOUR_SLOTS.length)]; + EntityEquipmentSlot slot = WizardryUtilities.ARMOUR_SLOTS[rand + .nextInt(WizardryUtilities.ARMOUR_SLOTS.length)]; if(this.getElement() != Element.MAGIC && rand.nextInt(4) > 0){ - // This means it is more likely for armour sold to be of the same element as the wizard if the wizard has an element. + // This means it is more likely for armour sold to be of the same element as the wizard if the + // wizard has an element. return new ItemStack(WizardryUtilities.getArmour(this.getElement(), slot)); }else{ - return new ItemStack(WizardryUtilities.getArmour(Element.values()[rand.nextInt(Element.values().length)], slot)); + return new ItemStack( + WizardryUtilities.getArmour(Element.values()[rand.nextInt(Element.values().length)], slot)); } }else{ // Don't need to check for discovery mode here since it is done above @@ -601,17 +611,21 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit randomiser = rand.nextInt(12); if(randomiser < 5 && !spells.isEmpty()){ if(this.getElement() != Element.MAGIC && rand.nextInt(4) > 0 && !specialismSpells.isEmpty()){ - // This means it is more likely for spell books sold to be of the same element as the wizard if the wizard has an element. - return new ItemStack(WizardryItems.spell_book, 1, specialismSpells.get(rand.nextInt(specialismSpells.size())).id()); + // This means it is more likely for spell books sold to be of the same element as the wizard if the + // wizard has an element. + return new ItemStack(WizardryItems.spell_book, 1, + specialismSpells.get(rand.nextInt(specialismSpells.size())).id()); }else{ return new ItemStack(WizardryItems.spell_book, 1, spells.get(rand.nextInt(spells.size())).id()); } }else if(randomiser < 6){ if(this.getElement() != Element.MAGIC && rand.nextInt(4) > 0){ - // This means it is more likely for wands sold to be of the same element as the wizard if the wizard has an element. + // This means it is more likely for wands sold to be of the same element as the wizard if the wizard + // has an element. return new ItemStack(WizardryUtilities.getWand(tier, this.getElement())); }else{ - return new ItemStack(WizardryUtilities.getWand(tier, Element.values()[rand.nextInt(Element.values().length)])); + return new ItemStack( + WizardryUtilities.getWand(tier, Element.values()[rand.nextInt(Element.values().length)])); } }else if(randomiser < 8){ return new ItemStack(WizardryItems.arcane_tome, 1, 2); @@ -627,7 +641,8 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit if(randomiser < 5 && this.getElement() != Element.MAGIC && !specialismSpells.isEmpty()){ // Master spells can only be sold by a specialist in that element. - return new ItemStack(WizardryItems.spell_book, 1, specialismSpells.get(rand.nextInt(specialismSpells.size())).id()); + return new ItemStack(WizardryItems.spell_book, 1, + specialismSpells.get(rand.nextInt(specialismSpells.size())).id()); }else if(randomiser < 6){ if(this.getElement() != Element.MAGIC && rand.nextInt(4) > 0){ @@ -643,9 +658,9 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit return new ItemStack(Blocks.STONE); } - + @Override - public void setProfession(VillagerProfession prof) { + public void setProfession(VillagerProfession prof){ // Disables Forge's stuff. } @@ -670,22 +685,25 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit } // Default chance is 0.085f, for reference. - for(EntityEquipmentSlot slot : EntityEquipmentSlot.values()) this.setDropChance(slot, 0.0f); + for(EntityEquipmentSlot slot : EntityEquipmentSlot.values()) + this.setDropChance(slot, 0.0f); // All wizards know magic missile, even if it is disabled. spells.add(Spells.magic_missile); - + Tier maxTier = populateSpells(spells, element, 3, rand); // Now done after the spells so it can take the tier into account. - this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(WizardryUtilities.getWand(maxTier, element))); + this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, + new ItemStack(WizardryUtilities.getWand(maxTier, element))); return livingdata; } - + /** * Adds n random spells to the given list. The spells will be of the given element if possible. Extracted as a * separate function since it was the same in both EntityWizard and EntityEvilWizard. + * * @param spells The spell list to be populated. * @param e The element that the spells should belong to, or {@link Element#MAGIC} for a random element each time. * @param n The number of spells to add. @@ -696,10 +714,10 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit // This is the tier of the highest tier spell added. Tier maxTier = Tier.BASIC; - + List npcSpells = Spell.getSpells(Spell.npcSpells); - for(int i=0; i<3; i++){ + for(int i = 0; i < 3; i++){ Tier tier; // If the wizard has no element, it picks a random one each time. @@ -739,7 +757,7 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit if(!list.isEmpty()) spells.add(list.get(random.nextInt(list.size()))); } - + return maxTier; } @@ -763,9 +781,10 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit return super.attackEntityFrom(source, damage); } - /** + /** * Sets the list of blocks that are part of this wizard's tower. If a player breaks any of these blocks, the wizard * will get angry and attack them. + * * @param blocks A Set of BlockPos objects representing the blocks in the tower. */ public void setTowerBlocks(Set blocks){ @@ -774,6 +793,7 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit /** * Tests whether the block at the given coordinates is part of this wizard's tower. + * * @param x * @param y * @param z @@ -784,7 +804,7 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit // Uses .equals() rather than == so this will work fine. return this.towerBlocks.contains(pos); } - + @SubscribeEvent public static void onBlockBreakEvent(BlockEvent.BreakEvent event){ // Makes wizards angry if a player breaks a block in their tower @@ -806,22 +826,46 @@ public class EntityWizard extends EntityVillager implements ISpellCaster, IEntit // EntityVillager overrides (that don't add features) - @Override public boolean isMating(){ return false; } - @Override public void setMating(boolean p_70947_1_){} - @Override public void setPlaying(boolean p_70939_1_){} - @Override public boolean isPlaying(){ return false; } - @Override public void setLookingForHome(){} + @Override + public boolean isMating(){ + return false; + } + + @Override + public void setMating(boolean p_70947_1_){ + } + + @Override + public void setPlaying(boolean p_70939_1_){ + } + + @Override + public boolean isPlaying(){ + return false; + } + + @Override + public void setLookingForHome(){ + } + // Doesn't say it, but this is in fact nullable. - @Override public EntityVillager createChild(EntityAgeable par1EntityAgeable){ return null; } + @Override + public EntityVillager createChild(EntityAgeable par1EntityAgeable){ + return null; + } + @SideOnly(Side.CLIENT) - @Override public void setRecipes(MerchantRecipeList par1MerchantRecipeList){} + @Override + public void setRecipes(MerchantRecipeList par1MerchantRecipeList){ + } + @Override public void onStruckByLightning(EntityLightningBolt lightningBolt){ // Restores the normal behaviour, replacing EntityVillager's witch conversion. - this.attackEntityFrom(DamageSource.lightningBolt, 5.0F); + this.attackEntityFrom(DamageSource.LIGHTNING_BOLT, 5.0F); // Entity's version does something strange with the private fire variable, but since I don't have access this // will probably be fine. - this.setFire(8); + this.setFire(8); } } diff --git a/src/main/java/electroblob/wizardry/entity/living/EntityZombieMinion.java b/src/main/java/electroblob/wizardry/entity/living/EntityZombieMinion.java index c1ac3a7a..2275e199 100644 --- a/src/main/java/electroblob/wizardry/entity/living/EntityZombieMinion.java +++ b/src/main/java/electroblob/wizardry/entity/living/EntityZombieMinion.java @@ -10,10 +10,8 @@ import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAIMoveThroughVillage; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.monster.EntityZombie; -import net.minecraft.entity.monster.ZombieType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; @@ -31,27 +29,50 @@ public class EntityZombieMinion extends EntityZombie implements ISummonedCreatur private UUID casterUUID; // Setter + getter implementations - @Override public int getLifetime(){ return lifetime; } - @Override public void setLifetime(int lifetime){ this.lifetime = lifetime; } - @Override public WeakReference getCasterReference(){ return casterReference; } - @Override public void setCasterReference(WeakReference reference){ casterReference = reference; } - @Override public UUID getCasterUUID() { return casterUUID; } - @Override public void setCasterUUID(UUID uuid) { this.casterUUID = uuid; } + @Override + public int getLifetime(){ + return lifetime; + } + + @Override + public void setLifetime(int lifetime){ + this.lifetime = lifetime; + } + + @Override + public WeakReference getCasterReference(){ + return casterReference; + } + + @Override + public void setCasterReference(WeakReference reference){ + casterReference = reference; + } + + @Override + public UUID getCasterUUID(){ + return casterUUID; + } + + @Override + public void setCasterUUID(UUID uuid){ + this.casterUUID = uuid; + } /** - * Default shell constructor, only used by client. Lifetime defaults arbitrarily to 600, but this doesn't - * matter because the client side entity immediately gets the lifetime value copied over to it by this class - * anyway. When extending this class, you must override this constructor or Minecraft won't like it, but there's - * no need to do anything inside it other than call super(). + * Default shell constructor, only used by client. Lifetime defaults arbitrarily to 600, but this doesn't matter + * because the client side entity immediately gets the lifetime value copied over to it by this class anyway. When + * extending this class, you must override this constructor or Minecraft won't like it, but there's no need to do + * anything inside it other than call super(). */ public EntityZombieMinion(World world){ super(world); this.experienceValue = 0; } - + /** - * Set lifetime to -1 to allow this creature to last forever. This constructor should be overridden when - * extending this class (be sure to call super()) so that AI and other things can be added. + * Set lifetime to -1 to allow this creature to last forever. This constructor should be overridden when extending + * this class (be sure to call super()) so that AI and other things can be added. */ public EntityZombieMinion(World world, double x, double y, double z, EntityLivingBase caster, int lifetime){ super(world); @@ -60,31 +81,38 @@ public class EntityZombieMinion extends EntityZombie implements ISummonedCreatur this.experienceValue = 0; this.lifetime = lifetime; } - + // EntityZombie overrides (EntityZombie is a long class so there are lots of these) - + @Override - protected void applyEntityAI() - { - this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false)); - this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); - this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, - 0, false, true, this.getTargetSelector())); - } - - @Override public boolean isChild(){ return false; } - @Override public void setChild(boolean childZombie){} - @Override public ZombieType getZombieType(){ return ZombieType.NORMAL; } - @Override public boolean isVillager(){ return false; } - @Override public net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession getVillagerTypeForge(){ return null; } - @Override protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty){} // They don't have equipment! - @Override public void onKillEntity(EntityLivingBase entityLivingIn){} // Turns villagers to zombies in EntityZombie - @Override protected void startConversion(int ticks){} - @Override public boolean isConverting(){ return false; } - @Override protected void convertToVillager(){} - @Override protected int getConversionTimeBoost(){ return 0; } - @Override public void setChildSize(boolean isChild){} - + protected void applyEntityAI(){ + this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false)); + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, + 0, false, true, this.getTargetSelector())); + } + + @Override + public boolean isChild(){ + return false; + } + + @Override + public void setChild(boolean childZombie){ + } // Can't be a child + + @Override + protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty){ + } // They don't have equipment! + + @Override + public void onKillEntity(EntityLivingBase entityLivingIn){ + } // Turns villagers to zombies in EntityZombie + + @Override + public void setChildSize(boolean isChild){ + } + // Implementations @Override @@ -107,25 +135,26 @@ public class EntityZombieMinion extends EntityZombie implements ISummonedCreatur public void onDespawn(){ this.spawnParticleEffect(); } - + private void spawnParticleEffect(){ - if(this.worldObj.isRemote){ - for(int i=0;i<15;i++){ - this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX + this.rand.nextFloat(), this.posY + 1 + this.rand.nextFloat(), this.posZ + this.rand.nextFloat(), 0, 0, 0); + if(this.world.isRemote){ + for(int i = 0; i < 15; i++){ + this.world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX + this.rand.nextFloat(), + this.posY + 1 + this.rand.nextFloat(), this.posZ + this.rand.nextFloat(), 0, 0, 0); } } } @Override - public boolean hasParticleEffect() { + public boolean hasParticleEffect(){ return true; } @Override - public boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack) { + protected boolean processInteract(EntityPlayer player, EnumHand hand){ // In this case, the delegate method determines whether super is called. - // Rather handily, we can make use of Java's 'stop as soon as you find true' method of evaluating OR statements. - return this.interactDelegate(player, hand, stack) || super.processInteract(player, hand, stack); + // Rather handily, we can make use of Java's short-circuiting method of evaluating OR statements. + return this.interactDelegate(player, hand) || super.processInteract(player, hand); } @Override @@ -142,24 +171,47 @@ public class EntityZombieMinion extends EntityZombie implements ISummonedCreatur // Recommended overrides - @Override protected int getExperiencePoints(EntityPlayer player){ return 0; } - @Override protected boolean canDropLoot(){ return false; } - @Override protected Item getDropItem(){ return null; } - @Override protected ResourceLocation getLootTable(){ return null; } - @Override public boolean canPickUpLoot(){ return false; } + @Override + protected int getExperiencePoints(EntityPlayer player){ + return 0; + } + + @Override + protected boolean canDropLoot(){ + return false; + } + + @Override + protected Item getDropItem(){ + return null; + } + + @Override + protected ResourceLocation getLootTable(){ + return null; + } + + @Override + public boolean canPickUpLoot(){ + return false; + } + // This vanilla method has nothing to do with the custom despawn() method. - @Override protected boolean canDespawn(){ return false; } + @Override + protected boolean canDespawn(){ + return false; + } @Override public boolean canAttackClass(Class entityType){ // Returns true unless the given entity type is a flying entity. return !EntityFlying.class.isAssignableFrom(entityType); } - + @Override public ITextComponent getDisplayName(){ if(getCaster() != null){ - return new TextComponentTranslation(NAMEPLATE_TRANSLATION_KEY, getCaster().getName(), + return new TextComponentTranslation(NAMEPLATE_TRANSLATION_KEY, getCaster().getName(), new TextComponentTranslation("entity." + this.getEntityString() + ".name")); }else{ return super.getDisplayName(); diff --git a/src/main/java/electroblob/wizardry/entity/living/IIntelligentSpellCaster.java b/src/main/java/electroblob/wizardry/entity/living/IIntelligentSpellCaster.java index 1bcb7c86..978f5457 100644 --- a/src/main/java/electroblob/wizardry/entity/living/IIntelligentSpellCaster.java +++ b/src/main/java/electroblob/wizardry/entity/living/IIntelligentSpellCaster.java @@ -4,17 +4,23 @@ import java.util.List; import electroblob.wizardry.spell.Spell; -/** [NYI] Interface for entities that can select between spells based on their current circumstances, to be used in - * conjunction with {@link EntityAISelectSpell}. */ +/** + * [NYI] Interface for entities that can select between spells based on their current circumstances, to be used in + * conjunction with {@link EntityAISelectSpell}. + */ public interface IIntelligentSpellCaster extends ISpellCaster { - - /** Called from {@link EntityAISelectSpell} to set the spells that the entity can use in its current situation. + + /** + * Called from {@link EntityAISelectSpell} to set the spells that the entity can use in its current situation. * Implementors should assign the given list to some internal field and retrieve it when {@link #getSpells()} is - * called. */ + * called. + */ public void setCurrentSpells(List spells); - - /** Returns a list of spells that this entity 'knows'. The entity's current spell will be selected from this list + + /** + * Returns a list of spells that this entity 'knows'. The entity's current spell will be selected from this list * based on the current situation: whether it is attacking, its health, etc. Most likely, you will want to return a - * constant list, but it may change for some reason - perhaps if the entity 'learns' a new spell. */ + * constant list, but it may change for some reason - perhaps if the entity 'learns' a new spell. + */ public List getKnownSpells(); } diff --git a/src/main/java/electroblob/wizardry/entity/living/ISpellCaster.java b/src/main/java/electroblob/wizardry/entity/living/ISpellCaster.java index ce2733df..a43c0153 100644 --- a/src/main/java/electroblob/wizardry/entity/living/ISpellCaster.java +++ b/src/main/java/electroblob/wizardry/entity/living/ISpellCaster.java @@ -8,10 +8,11 @@ import electroblob.wizardry.registry.Spells; import electroblob.wizardry.spell.Spell; import electroblob.wizardry.util.SpellModifiers; -/** Interface for entities that can cast spells. Mainly intended for use by wizard-type entities, but can be - * implemented by any subclass of EntityLiving. Designed to be as flexible as possible - ranging from the simplest - * use of giving an entity a specific spell as an attack, to a complex AI which selects different spell types - * depending on the situation. The only restriction is that the spells must be castable by NPCs. +/** + * Interface for entities that can cast spells. Mainly intended for use by wizard-type entities, but can be implemented + * by any subclass of EntityLiving. Designed to be as flexible as possible - ranging from the simplest use of giving an + * entity a specific spell as an attack, to a complex AI which selects different spell types depending on the situation. + * The only restriction is that the spells must be castable by NPCs. *

    * This is intended for entities that use {@link EntityAIAttackSpell}. If so, all the spell casting code (including * packets) is handled by that class, and all the implementor needs to do is decide which spell(s) to select. @@ -20,42 +21,48 @@ import electroblob.wizardry.util.SpellModifiers; * needs to do is store the actual fields involved. */ /* Perhaps this should be a capability? Though I can't help thinking they're mainly for attaching data to vanilla - * classes, rather than custom ones. For now, the main purpose of this is to centralise code within wizardry itself, - * and I may as well make it an API feature - but I'm not writing a capability unless someone sees a reason to attach - * it to a class they don't own, and I don't see that happening anytime soon. */ + * classes, rather than custom ones. For now, the main purpose of this is to centralise code within wizardry itself, and + * I may as well make it an API feature - but I'm not writing a capability unless someone sees a reason to attach it to + * a class they don't own, and I don't see that happening anytime soon. */ // For even more fun, combine this with an ISummonedCreature and have skeletons that can cast spells! public interface ISpellCaster { /** - * Called each time the entity attacks to get the spells that can be cast. For simple implementations, just - * return a list of size one containing the spell that the entity uses as an attack, perhaps performing some - * simple logic within this method. For more intelligent implementations based on spell types, consider using + * Called each time the entity attacks to get the spells that can be cast. For simple implementations, just return a + * list of size one containing the spell that the entity uses as an attack, perhaps performing some simple logic + * within this method. For more intelligent implementations based on spell types, consider using * {@link IIntelligentSpellCaster} instead. + * * @return A list of {@link Spell} instances. A random spell from this list will be cast when the entity attacks. - * The list will not be modified by the AI class and can therefore be an immutable list. The spells in the list - * must be castable by NPCs (i.e. {@link Spell#canBeCastByNPCs()} returns true). + * The list will not be modified by the AI class and can therefore be an immutable list. The spells in the + * list must be castable by NPCs (i.e. {@link Spell#canBeCastByNPCs()} returns true). */ @Nonnull public List getSpells(); - + /** * Called each time the entity attacks to get the modifiers to apply to the spell. - * @return A {@link SpellModifiers} object representing the modifiers to apply to the spell. If no modifiers are required, - * pass in an empty {@code SpellModifiers} object. + * + * @return A {@link SpellModifiers} object representing the modifiers to apply to the spell. If no modifiers are + * required, pass in an empty {@code SpellModifiers} object. */ @Nonnull public SpellModifiers getModifiers(); - - /** Returns the continuous spell that is currently being cast, or the None spell if there is none. Implementors should simply - * store this as a private field and return it here. Will be synced by the AI class, but whether it is saved to NBT - * is up to you. If the implementing class does not deal with continuous spells, just return {@link Spells#none}. If the - * implementing class only ever uses one continuous spell, do not just return that spell; the field must still - * be stored. */ + + /** + * Returns the continuous spell that is currently being cast, or the None spell if there is none. Implementors + * should simply store this as a private field and return it here. Will be synced by the AI class, but whether it is + * saved to NBT is up to you. If the implementing class does not deal with continuous spells, just return + * {@link Spells#none}. If the implementing class only ever uses one continuous spell, do not just return + * that spell; the field must still be stored. + */ @Nonnull public Spell getContinuousSpell(); - - /** Sets the continuous spell that is currently being cast, or the None spell if there is none. Implementors should simply - * store this as a private field and assign it here. Will be synced by the AI class, but whether it is saved to NBT - * is up to you. If the implementing class does not deal with continuous spells, leave this method blank. */ + + /** + * Sets the continuous spell that is currently being cast, or the None spell if there is none. Implementors should + * simply store this as a private field and assign it here. Will be synced by the AI class, but whether it is saved + * to NBT is up to you. If the implementing class does not deal with continuous spells, leave this method blank. + */ public void setContinuousSpell(Spell spell); } diff --git a/src/main/java/electroblob/wizardry/entity/living/ISummonedCreature.java b/src/main/java/electroblob/wizardry/entity/living/ISummonedCreature.java index 39c68a28..4082708a 100644 --- a/src/main/java/electroblob/wizardry/entity/living/ISummonedCreature.java +++ b/src/main/java/electroblob/wizardry/entity/living/ISummonedCreature.java @@ -11,7 +11,6 @@ import com.google.common.base.Predicate; import electroblob.wizardry.WizardData; import electroblob.wizardry.Wizardry; -import electroblob.wizardry.WizardryEventHandler; import electroblob.wizardry.item.ItemWand; import electroblob.wizardry.util.IElementalDamage; import electroblob.wizardry.util.IndirectMinionDamage; @@ -36,23 +35,27 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; -/** Interface for all summoned creatures. The code for summoned creatures has been overhauled in Wizardry 2.1, and this - * interface allows summoned creatures to extend vanilla (or indeed modded) entity classes, so EntitySummonedZombie - * now extends EntityZombie, for example. This change has two major benefits: +/** + * Interface for all summoned creatures. The code for summoned creatures has been overhauled in Wizardry 2.1, and this + * interface allows summoned creatures to extend vanilla (or indeed modded) entity classes, so + * EntitySummonedZombie now extends EntityZombie, for example. This change has two major + * benefits: *

    * - There is no longer any need for separate render classes, because summoned creatures are now instances of vanilla - * types. You don't even need to assign a render class because the supertype should already be assigned the correct one.
    + * types. You don't even need to assign a render class because the supertype should already be assigned the + * correct one.
    * - Summoned creature classes are now much more robust when it comes to changes between Minecraft versions, since none * of the vanilla code needs to be copied. *

    - * Summoned creatures that do not emulate vanilla entities do not directly implement this interface. Instead, they - * should extend the abstract base implementation, {@link EntitySummonedCreature}. + * Summoned creatures that do not emulate vanilla entities do not directly implement this interface. Instead, + * they should extend the abstract base implementation, {@link EntitySummonedCreature}. *

    - * All damage dealt by ISummonedCreature instances is redirected via {@link WizardryEventHandler#onLivingAttackEvent( - * net.minecraftforge.event.entity.living.LivingAttackEvent) WizardryEventHandler.onLivingAttackEvent(LivingAttackEvent)} - * and replaced by an instance of {@link electroblob.wizardry.util.IElementalDamage IElementalDamage} with the summoner - * of that creature as the source rather than the creature itself. This means that kills by summoned creatures register - * as player kills, dropping xp and rare loot. + * All damage dealt by ISummonedCreature instances is redirected via + * {@link ISummonedCreature#onLivingAttackEvent(net.minecraftforge.event.entity.living.LivingAttackEvent) + * ISummonedCreature.onLivingAttackEvent(LivingAttackEvent)} and replaced by an instance of + * {@link electroblob.wizardry.util.IElementalDamage IElementalDamage} with the summoner of that creature as the source + * rather than the creature itself. This means that kills by summoned creatures register as kills for their owner, + * dropping xp and rare loot if that owner is a player. *

    * Though this system is a lot better than the previous system, it is not a perfect solution. The old * EntitySummonedCreature class overrode some methods from Entity in order to add shared functionality, but this cannot @@ -61,92 +64,102 @@ import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; * Implementing classes must override the corresponding methods from Entity, and within them, call the appropriate * delegate method in this interface. It is impossible to enforce this condition, but the summoned creature will not * work properly unless it is adhered to. The position of the delegate method call is unimportant, but by convention - * it is usually at the start of the calling method, which avoids it being unintentionally skipped by a return statement. + * it is usually at the start of the calling method, which avoids it being unintentionally skipped by a return + * statement (except for methods where the result of the delegate method should itself be returned). *

    - * It is recommended that when implementing this interface, you begin by copying {@link EntitySummonedCreature} to ensure - * all the relevant methods are duplicated. You can then change the superclass, override any additional methods and add - * functionality to any that are already overridden. You will always want to override the AI methods at the very least. + * It is recommended that when implementing this interface, you begin by copying {@link EntitySummonedCreature} to + * ensure all the relevant methods are duplicated. You can then change the superclass, override any additional methods + * and add functionality to any that are already overridden. You will always want to override the AI methods at the very + * least. *

    * Due to the limitations of interfaces, some methods that really ought to be protected are public. These are clearly * marked as 'Internal, DO NOT CALL'. Don't call them, only implement them. + * * @since Wizardry 2.1 - * @author Electroblob */ -/* - * Quite honestly, this is not what default methods are really for. However, this is modding, and in modding some - * sacrifices have to be made when it comes to Java style - because adding on to a pre-existing program is not a - * good way of doing this sort of thing anyway, but we have no choice about that! + * @author Electroblob */ +/* Quite honestly, this is not what default methods are really for. However, this is modding, and in modding some + * sacrifices have to be made when it comes to Java style - because adding on to a pre-existing program is not a good + * way of doing this sort of thing anyway, but we have no choice about that! */ @Mod.EventBusSubscriber public interface ISummonedCreature extends IEntityAdditionalSpawnData { // Remember that ALL fields are static and final in interfaces, even if they don't explicitly state that. String NAMEPLATE_TRANSLATION_KEY = "entity.wizardry.summonedcreature.nameplate"; - + // Setters and getters. The subclass fields that these access should be private. /** Sets the lifetime of the summoned creature in ticks. */ void setLifetime(int ticks); - - /** Returns the lifetime of the summoned creature in ticks. Allows primarily for duration multiplier support, but + + /** + * Returns the lifetime of the summoned creature in ticks. Allows primarily for duration multiplier support, but * also for example the skeleton legion spell which lasts for 60 seconds instead of the usual 30. Syncing and saving * is done automatically. As of Wizardry 2.1, despawning is handled in ISummonedCreature; see - * {@link ISummonedCreature#onDespawn()} for details. */ + * {@link ISummonedCreature#onDespawn()} for details. + */ int getLifetime(); - - /** Sets the WeakReference object which refers to the owner of this summoned creature. Internal, don't call - * unless you know what you are doing. */ + + /** + * Sets the WeakReference object which refers to the owner of this summoned creature. Internal, don't call unless + * you know what you are doing. + */ void setCasterReference(WeakReference reference); - - /** Returns a WeakReference object which refers to the owner of this summoned creature. Subclasses should store this - * as a private field. This may be null; as such it is preferable to use {@link ISummonedCreature#getCaster()} to get - * the caster object itself. */ + + /** + * Returns a WeakReference object which refers to the owner of this summoned creature. Subclasses should store this + * as a private field. This may be null; as such it is preferable to use {@link ISummonedCreature#getCaster()} to + * get the caster object itself. + */ @Nullable WeakReference getCasterReference(); - + /** Internal, DO NOT CALL. */ void setCasterUUID(UUID uuid); + /** Internal, DO NOT CALL. This is for loading purposes only and is not usually synchronised. */ UUID getCasterUUID(); - - /** Returns the EntityLivingBase that summoned this creature, or null if it no longer exists. Cases where the - * entity may no longer exist are: entity died or was deleted, mob despawned, player logged out, entity teleported - * to another dimension, or this creature simply had no caster in the first place. This is the correct method - * to use to get the owner of this summoned creature. */ + + /** + * Returns the EntityLivingBase that summoned this creature, or null if it no longer exists. Cases where the entity + * may no longer exist are: entity died or was deleted, mob despawned, player logged out, entity teleported to + * another dimension, or this creature simply had no caster in the first place. This is the correct method to use + * to get the owner of this summoned creature. + */ @Nullable default EntityLivingBase getCaster(){ return getCasterReference() == null ? null : getCasterReference().get(); } - + // Miscellaneous - + /** - * Called by the server when constructing the spawn packet. - * Data should be added to the provided stream. - * Implementors must call super when overriding. - * - * @param buffer The packet data stream - */ + * Called by the server when constructing the spawn packet. Data should be added to the provided stream. + * Implementors must call super when overriding. + * + * @param buffer The packet data stream + */ @Override - default void writeSpawnData(ByteBuf buffer) { + default void writeSpawnData(ByteBuf buffer){ buffer.writeInt(getCaster() != null ? getCaster().getEntityId() : -1); buffer.writeInt(getLifetime()); } - + /** - * Called by the client when it receives a Entity spawn packet. - * Data should be read out of the stream in the same way as it was written. - * Implementors must call super when overriding. - * - * @param additionalData The packet data stream - */ + * Called by the client when it receives a Entity spawn packet. Data should be read out of the stream in the same + * way as it was written. Implementors must call super when overriding. + * + * @param additionalData The packet data stream + */ @Override - default void readSpawnData(ByteBuf buffer) { + default void readSpawnData(ByteBuf buffer){ int id = buffer.readInt(); - // We're on the client side here, so we can safely use Minecraft.getMinecraft().theWorld via proxies. - if(id > -1) setCasterReference(new WeakReference((EntityLivingBase)Wizardry.proxy.getTheWorld().getEntityByID(id))); + // We're on the client side here, so we can safely use Minecraft.getMinecraft().world via proxies. + if(id > -1) setCasterReference( + new WeakReference((EntityLivingBase)Wizardry.proxy.getTheWorld().getEntityByID(id))); setLifetime(buffer.readInt()); } - + /** * Shorthand for {@link WizardryUtilities#isValidTarget(Entity, Entity)}, with the owner of this creature as the * attacker. Also allows implementors to override it if they wish to do so. @@ -154,11 +167,13 @@ public interface ISummonedCreature extends IEntityAdditionalSpawnData { default boolean isValidTarget(Entity target){ return WizardryUtilities.isValidTarget(this.getCaster(), target); } - - /** Returns a entity selector to be passed into AI methods. Normally, this should not be overridden, but it is - * possible for implementors to override this in order to do something special when selecting a target. */ + + /** + * Returns a entity selector to be passed into AI methods. Normally, this should not be overridden, but it is + * possible for implementors to override this in order to do something special when selecting a target. + */ default Predicate getTargetSelector(){ - + return new Predicate(){ public boolean apply(Entity entity){ @@ -166,15 +181,19 @@ public interface ISummonedCreature extends IEntityAdditionalSpawnData { // If the target is valid and not invisible... if(!entity.isInvisible() && isValidTarget(entity)){ - //... and is a player, they can be attacked, since players can't be in the whitelist or the blacklist. + // ... and is a player, they can be attacked, since players can't be in the whitelist or the + // blacklist. if(entity instanceof EntityPlayer) return true; - //... and is a mob, a summoned creature, a wizard ... - if((entity instanceof IMob || entity instanceof ISummonedCreature || (entity instanceof EntityWizard && !(getCaster() instanceof EntityWizard)) - // ... or in the whitelist ... - || Arrays.asList(Wizardry.settings.summonedCreatureTargetsWhitelist).contains(EntityList.getEntityString(entity).toLowerCase(Locale.ROOT))) + // ... and is a mob, a summoned creature, a wizard ... + if((entity instanceof IMob || entity instanceof ISummonedCreature + || (entity instanceof EntityWizard && !(getCaster() instanceof EntityWizard)) + // ... or in the whitelist ... + || Arrays.asList(Wizardry.settings.summonedCreatureTargetsWhitelist) + .contains(EntityList.getEntityString(entity).toLowerCase(Locale.ROOT))) // ... and isn't in the blacklist ... - && !Arrays.asList(Wizardry.settings.summonedCreatureTargetsBlacklist).contains(EntityList.getEntityString(entity).toLowerCase(Locale.ROOT))){ + && !Arrays.asList(Wizardry.settings.summonedCreatureTargetsBlacklist) + .contains(EntityList.getEntityString(entity).toLowerCase(Locale.ROOT))){ // ... it can be attacked. return true; } @@ -184,10 +203,10 @@ public interface ISummonedCreature extends IEntityAdditionalSpawnData { } }; } - + /** - * Called when this creature has existed for 1 tick, effectively when it has just been spawned. Normally used - * to add particles, sounds, etc. + * Called when this creature has existed for 1 tick, effectively when it has just been spawned. Normally used to add + * particles, sounds, etc. */ void onSpawn(); @@ -195,22 +214,27 @@ public interface ISummonedCreature extends IEntityAdditionalSpawnData { * Called when this summoned creature vanishes. Normally used to add particles, sounds, etc. */ void onDespawn(); - + /** Whether this creature should spawn a subtle black swirl particle effect while alive. */ boolean hasParticleEffect(); - - /** Called from the event handler after the damage change is applied. Does nothing by default, but can be overridden - * to do something when a successful attack is made. This was added because the event-based damage source system - * can cause parts of attackEntityAsMob not to fire, since attackEntityFrom is intercepted and canceled. + + /** + * Called from the event handler after the damage change is applied. Does nothing by default, but can be overridden + * to do something when a successful attack is made. This was added because the event-based damage source system can + * cause parts of attackEntityAsMob not to fire, since attackEntityFrom is intercepted and canceled. *

    * Usage examples: {@link EntitySliverfishMinion} uses this to summon more silverfish if the target is killed, - * {@link EntitySkeletonMinion} and {@link EntitySpiderMinion} use this to add potion effects to the target. */ - default void onSuccessfulAttack(EntityLivingBase target){}; + * {@link EntitySkeletonMinion} and {@link EntitySpiderMinion} use this to add potion effects to the target. + */ + default void onSuccessfulAttack(EntityLivingBase target){ + }; // Delegates - - /** Implementors should call this from writeEntityToNBT. Can be overridden as long as super is called, but there's - * very little point in doing that since anything extra could just be added to writeEntityToNBT anyway. */ + + /** + * Implementors should call this from writeEntityToNBT. Can be overridden as long as super is called, but there's + * very little point in doing that since anything extra could just be added to writeEntityToNBT anyway. + */ default void writeNBTDelegate(NBTTagCompound tagcompound){ if(this.getCaster() != null){ tagcompound.setUniqueId("casterUUID", this.getCaster().getUniqueID()); @@ -218,30 +242,37 @@ public interface ISummonedCreature extends IEntityAdditionalSpawnData { tagcompound.setInteger("lifetime", getLifetime()); } - /** Implementors should call this from readEntityFromNBT. Can be overridden as long as super is called, but there's - * very little point in doing that since anything extra could just be added to readEntityFromNBT anyway. */ + /** + * Implementors should call this from readEntityFromNBT. Can be overridden as long as super is called, but there's + * very little point in doing that since anything extra could just be added to readEntityFromNBT anyway. + */ default void readNBTDelegate(NBTTagCompound tagcompound){ this.setCasterUUID(tagcompound.getUniqueId("casterUUID")); this.setLifetime(tagcompound.getInteger("lifetime")); } - - /** Implementors should call this from setRevengeTarget, and call super.setRevengeTarget if and only if this method - * returns true. */ + + /** + * Implementors should call this from setRevengeTarget, and call super.setRevengeTarget if and only if this method + * returns true. + */ default boolean shouldRevengeTarget(EntityLivingBase entity){ // Allows the config to prevent minions from revenge-targeting their owners. return entity != this.getCaster() || Wizardry.settings.minionRevengeTargeting; } - - /** Implementors should call this from onUpdate. Can be overridden as long as super is called, but there's - * very little point in doing that since anything extra could just be added to onUpdate anyway. */ + + /** + * Implementors should call this from onUpdate. Can be overridden as long as super is called, but there's very + * little point in doing that since anything extra could just be added to onUpdate anyway. + */ default void updateDelegate(){ - - if(!(this instanceof Entity)) throw new ClassCastException("Implementations of ISummonedCreature must extend Entity!"); - + + if(!(this instanceof Entity)) + throw new ClassCastException("Implementations of ISummonedCreature must extend Entity!"); + Entity thisEntity = ((Entity)this); if(this.getCaster() == null && this.getCasterUUID() != null){ - Entity entity = WizardryUtilities.getEntityByUUID(thisEntity.worldObj, getCasterUUID()); + Entity entity = WizardryUtilities.getEntityByUUID(thisEntity.world, getCasterUUID()); if(entity instanceof EntityLivingBase){ this.setCasterReference(new WeakReference((EntityLivingBase)entity)); } @@ -255,22 +286,28 @@ public interface ISummonedCreature extends IEntityAdditionalSpawnData { this.onDespawn(); thisEntity.setDead(); } - - if(this.hasParticleEffect() && thisEntity.worldObj.isRemote && thisEntity.worldObj.rand.nextInt(8) == 0) - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, thisEntity.worldObj, thisEntity.posX, thisEntity.posY + thisEntity.worldObj.rand.nextDouble()*1.5, thisEntity.posZ, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f); + + if(this.hasParticleEffect() && thisEntity.world.isRemote && thisEntity.world.rand.nextInt(8) == 0) + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, thisEntity.world, thisEntity.posX, + thisEntity.posY + thisEntity.world.rand.nextDouble() * 1.5, thisEntity.posZ, 0.0d, 0.0d, 0.0d, 0, + 0.1f, 0.0f, 0.0f); } - /** Implementors should call this from processInteract, and call super.processInteract if and only if this method - * returns false. */ - default boolean interactDelegate(EntityPlayer player, EnumHand hand, ItemStack stack) { - + /** + * Implementors should call this from processInteract, and call super.processInteract if and only if this method + * returns false. + */ + default boolean interactDelegate(EntityPlayer player, EnumHand hand){ + + ItemStack stack = player.getHeldItem(hand); + WizardData properties = WizardData.get(player); // Selects one of the player's minions. - if(player.isSneaking() && stack != null && stack.getItem() instanceof ItemWand){ - - if(!player.worldObj.isRemote && properties != null && this.getCaster() == player){ - + if(player.isSneaking() && stack.getItem() instanceof ItemWand){ + + if(!player.world.isRemote && properties != null && this.getCaster() == player){ + if(properties.selectedMinion != null && properties.selectedMinion.get() == this){ // Deselects the selected minion if right-clicked again properties.selectedMinion = null; @@ -282,12 +319,12 @@ public interface ISummonedCreature extends IEntityAdditionalSpawnData { } return true; } - + return false; } - + // Damage system - + @SubscribeEvent public static void onLivingAttackEvent(LivingAttackEvent event){ @@ -302,16 +339,22 @@ public interface ISummonedCreature extends IEntityAdditionalSpawnData { event.setCanceled(true); DamageSource newSource = event.getSource(); // Copies over the original DamageType if appropriate. - DamageType type = event.getSource() instanceof IElementalDamage ? ((IElementalDamage)event.getSource()).getType() : DamageType.MAGIC; + DamageType type = event.getSource() instanceof IElementalDamage + ? ((IElementalDamage)event.getSource()).getType() + : DamageType.MAGIC; // Copies over the original isRetaliatory flag if appropriate. - boolean isRetaliatory = event.getSource() instanceof IElementalDamage && ((IElementalDamage)event.getSource()).isRetaliatory(); + boolean isRetaliatory = event.getSource() instanceof IElementalDamage + && ((IElementalDamage)event.getSource()).isRetaliatory(); // All summoned creatures are classified as magic, so it makes sense to do it this way. if(event.getSource() instanceof EntityDamageSourceIndirect){ - newSource = new IndirectMinionDamage(event.getSource().damageType, event.getSource().getSourceOfDamage(), event.getSource().getEntity(), summoner, type, isRetaliatory); + newSource = new IndirectMinionDamage(event.getSource().damageType, + event.getSource().getSourceOfDamage(), event.getSource().getEntity(), summoner, type, + isRetaliatory); }else if(event.getSource() instanceof EntityDamageSource){ // Name is copied over so it uses the appropriate vanilla death message - newSource = new MinionDamage(event.getSource().damageType, event.getSource().getEntity(), summoner, type, isRetaliatory); + newSource = new MinionDamage(event.getSource().damageType, event.getSource().getEntity(), summoner, + type, isRetaliatory); } // Copy over any relevant 'attributes' the original DamageSource might have had. @@ -325,7 +368,7 @@ public interface ISummonedCreature extends IEntityAdditionalSpawnData { WizardryUtilities.applyStandardKnockback(event.getSource().getEntity(), event.getEntityLiving()); ((ISummonedCreature)event.getSource().getEntity()).onSuccessfulAttack(event.getEntityLiving()); } - + } } } diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityBomb.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityBomb.java index f383ca21..a7f3c161 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityBomb.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityBomb.java @@ -9,6 +9,7 @@ import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; /** * Same as {@link EntityMagicProjectile}, but with an additional blast multiplier field which is synced and saved to * allow for the spread of particles to be changed depending on the blast area. + * * @author Electroblob * @since Wizardry 1.2 */ @@ -16,38 +17,38 @@ public abstract class EntityBomb extends EntityMagicProjectile implements IEntit /** The entity blast multiplier. This is now synced and saved centrally from {@link EntityBomb}. */ public float blastMultiplier = 1.0f; - - public EntityBomb(World world) { + + public EntityBomb(World world){ super(world); } - public EntityBomb(World world, EntityLivingBase thrower) { + public EntityBomb(World world, EntityLivingBase thrower){ super(world, thrower); } - public EntityBomb(World world, EntityLivingBase thrower, float damageMultiplier, float blastMultiplier) { + public EntityBomb(World world, EntityLivingBase thrower, float damageMultiplier, float blastMultiplier){ super(world, thrower, damageMultiplier); - this.blastMultiplier = blastMultiplier; + this.blastMultiplier = blastMultiplier; } - public EntityBomb(World par1World, double par2, double par4, double par6) { + public EntityBomb(World par1World, double par2, double par4, double par6){ super(par1World, par2, par4, par6); } @Override - public void writeSpawnData(ByteBuf buffer) { + public void writeSpawnData(ByteBuf buffer){ buffer.writeFloat(blastMultiplier); } @Override - public void readSpawnData(ByteBuf buffer) { + public void readSpawnData(ByteBuf buffer){ blastMultiplier = buffer.readFloat(); } @Override public void readEntityFromNBT(NBTTagCompound nbttagcompound){ - super.readEntityFromNBT(nbttagcompound); - blastMultiplier = nbttagcompound.getFloat("blastMultiplier"); + super.readEntityFromNBT(nbttagcompound); + blastMultiplier = nbttagcompound.getFloat("blastMultiplier"); } @Override diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityDarknessOrb.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityDarknessOrb.java index 1ba45a28..90292a5f 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityDarknessOrb.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityDarknessOrb.java @@ -12,77 +12,80 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; -public class EntityDarknessOrb extends EntityMagicProjectile -{ - public EntityDarknessOrb(World par1World) - { - super(par1World); - } +public class EntityDarknessOrb extends EntityMagicProjectile { + public EntityDarknessOrb(World par1World){ + super(par1World); + } - public EntityDarknessOrb(World par1World, EntityLivingBase par2EntityLivingBase) - { - super(par1World, par2EntityLivingBase); - } - - public EntityDarknessOrb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier) - { - super(par1World, par2EntityLivingBase, damageMultiplier); - } + public EntityDarknessOrb(World par1World, EntityLivingBase par2EntityLivingBase){ + super(par1World, par2EntityLivingBase); + } - public EntityDarknessOrb(World par1World, double par2, double par4, double par6) - { - super(par1World, par2, par4, par6); - } - - @Override - protected float getSpeed(){ - return 0.5F; - } + public EntityDarknessOrb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier){ + super(par1World, par2EntityLivingBase, damageMultiplier); + } - @Override - protected void onImpact(RayTraceResult RayTraceResult) - { - Entity target = RayTraceResult.entityHit; - - if (target != null && !MagicDamage.isEntityImmune(DamageType.WITHER, target)) - { - float damage = 8 * damageMultiplier; - - target.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.WITHER).setProjectile(), damage); - - if(target instanceof EntityLivingBase && !MagicDamage.isEntityImmune(DamageType.WITHER, target)) ((EntityLivingBase)target).addPotionEffect(new PotionEffect(MobEffects.WITHER, 150, 1)); + public EntityDarknessOrb(World par1World, double par2, double par4, double par6){ + super(par1World, par2, par4, par6); + } - this.playSound(SoundEvents.ENTITY_WITHER_HURT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); - } + @Override + protected float getSpeed(){ + return 0.5F; + } - this.setDead(); - } - - public void onUpdate(){ - - super.onUpdate(); - - if(worldObj.isRemote){ - float brightness = rand.nextFloat()*0.2f; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0, 0, 0, 20 + rand.nextInt(10), brightness, 0.0f, brightness); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, worldObj, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f); - } - - if(this.ticksExisted > 150){ - this.setDead(); - } - - // Cancels out the slowdown effect in EntityThrowable - this.motionX /= 0.99; - this.motionY /= 0.99; - this.motionZ /= 0.99; - } - - /** - * Gets the amount of gravity to apply to the thrown entity with each tick. - */ - protected float getGravityVelocity() - { - return 0.0F; - } + @Override + protected void onImpact(RayTraceResult RayTraceResult){ + Entity target = RayTraceResult.entityHit; + + if(target != null && !MagicDamage.isEntityImmune(DamageType.WITHER, target)){ + float damage = 8 * damageMultiplier; + + target.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.WITHER).setProjectile(), + damage); + + if(target instanceof EntityLivingBase && !MagicDamage.isEntityImmune(DamageType.WITHER, target)) + ((EntityLivingBase)target).addPotionEffect(new PotionEffect(MobEffects.WITHER, 150, 1)); + + this.playSound(SoundEvents.ENTITY_WITHER_HURT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + } + + this.setDead(); + } + + public void onUpdate(){ + + super.onUpdate(); + + if(world.isRemote){ + float brightness = rand.nextFloat() * 0.2f; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, + this.posY + this.rand.nextDouble() * (double)this.height, + this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0, 0, 0, 20 + rand.nextInt(10), + brightness, 0.0f, brightness); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, + this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, + this.posY + this.rand.nextDouble() * (double)this.height, + this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, + 0.0f); + } + + if(this.ticksExisted > 150){ + this.setDead(); + } + + // Cancels out the slowdown effect in EntityThrowable + this.motionX /= 0.99; + this.motionY /= 0.99; + this.motionZ /= 0.99; + } + + /** + * Gets the amount of gravity to apply to the thrown entity with each tick. + */ + protected float getGravityVelocity(){ + return 0.0F; + } } diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityDart.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityDart.java index 3625f995..0d51c5df 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityDart.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityDart.java @@ -10,86 +10,90 @@ import net.minecraft.init.SoundEvents; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; -public class EntityDart extends EntityMagicArrow -{ +public class EntityDart extends EntityMagicArrow { /** Basic shell constructor. Should only be used by the client. */ - public EntityDart(World world) { + public EntityDart(World world){ super(world); } - - /** Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this - * constructor and then call setVelocity() as that method is, bizarrely, client-side only. */ - public EntityDart(World world, double x, double y, double z) - { - super(world, x, y, z); - } - /** Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be altered - * slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on easy, 6 on - * normal and 2 on hard difficulty. */ - public EntityDart(World world, EntityLivingBase caster, Entity target, float speed, float aimingError, float damageMultiplier) - { - super(world, caster, target, speed, aimingError, damageMultiplier); - } + /** + * Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this constructor + * and then call setVelocity() as that method is, bizarrely, client-side only. + */ + public EntityDart(World world, double x, double y, double z){ + super(world, x, y, z); + } - /** Creates a projectile pointing in the direction the caster is looking, with the given speed. - * USE THIS CONSTRUCTOR FOR NORMAL SPELLS. */ - public EntityDart(World world, EntityLivingBase caster, float speed, float damageMultiplier) - { - super(world, caster, speed, damageMultiplier); - } + /** + * Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be + * altered slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on + * easy, 6 on normal and 2 on hard difficulty. + */ + public EntityDart(World world, EntityLivingBase caster, Entity target, float speed, float aimingError, + float damageMultiplier){ + super(world, caster, target, speed, aimingError, damageMultiplier); + } + + /** + * Creates a projectile pointing in the direction the caster is looking, with the given speed. USE THIS CONSTRUCTOR + * FOR NORMAL SPELLS. + */ + public EntityDart(World world, EntityLivingBase caster, float speed, float damageMultiplier){ + super(world, caster, speed, damageMultiplier); + } @Override public void onEntityHit(EntityLivingBase entityHit){ - //Adds a weakness effect to the target. - entityHit.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 200, 1, false, false)); + // Adds a weakness effect to the target. + entityHit.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 200, 1, false, false)); this.playSound(SoundEvents.ENTITY_GENERIC_HURT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); } - + @Override public void onBlockHit(){ this.playSound(SoundEvents.ENTITY_ARROW_HIT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); } - + @Override public void tickInAir(){ - - if(this.worldObj.isRemote){ - Wizardry.proxy.spawnParticle(WizardryParticleType.LEAF, worldObj, this.posX, this.posY, this.posZ, 0, -0.03, 0, 10 + rand.nextInt(5)); - } - } - + + if(this.world.isRemote){ + Wizardry.proxy.spawnParticle(WizardryParticleType.LEAF, world, this.posX, this.posY, this.posZ, 0, -0.03, 0, + 10 + rand.nextInt(5)); + } + } + // Replicates the original behaviour of staying stuck in block for a few seconds before disappearing. @Override public void tickInGround(){ if(this.ticksInGround > 60){ this.setDead(); } - } - + } + @Override - public double getDamage(){ - return 4.0d; - } - + public double getDamage(){ + return 4.0d; + } + @Override public DamageType getDamageType(){ return DamageType.MAGIC; } - - @Override - public boolean doGravity(){ - return true; - } - - @Override - public boolean doDeceleration(){ - return true; - } @Override - protected void entityInit() { - + public boolean doGravity(){ + return true; } - + + @Override + public boolean doDeceleration(){ + return true; + } + + @Override + protected void entityInit(){ + + } + } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityFirebolt.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityFirebolt.java index ed8c5c0f..268a15c2 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityFirebolt.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityFirebolt.java @@ -9,85 +9,82 @@ import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; -public class EntityFirebolt extends EntityMagicProjectile -{ - public EntityFirebolt(World par1World) - { - super(par1World); - } +public class EntityFirebolt extends EntityMagicProjectile { + public EntityFirebolt(World par1World){ + super(par1World); + } - public EntityFirebolt(World par1World, EntityLivingBase par2EntityLivingBase) - { - super(par1World, par2EntityLivingBase); - } - - public EntityFirebolt(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier) - { - super(par1World, par2EntityLivingBase, damageMultiplier); - } + public EntityFirebolt(World par1World, EntityLivingBase par2EntityLivingBase){ + super(par1World, par2EntityLivingBase); + } - public EntityFirebolt(World par1World, double par2, double par4, double par6) - { - super(par1World, par2, par4, par6); - } + public EntityFirebolt(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier){ + super(par1World, par2EntityLivingBase, damageMultiplier); + } - @Override - protected void onImpact(RayTraceResult rayTrace) - { - Entity entityHit = rayTrace.entityHit; - - if (entityHit != null) - { - float damage = 5 * damageMultiplier; - - entityHit.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.FIRE).setProjectile(), damage); - - if(!MagicDamage.isEntityImmune(DamageType.FIRE, entityHit)) entityHit.setFire(5); - } + public EntityFirebolt(World par1World, double par2, double par4, double par6){ + super(par1World, par2, par4, par6); + } - this.playSound(SoundEvents.BLOCK_LAVA_POP, 2, 0.8f + rand.nextFloat()*0.3f); + @Override + protected void onImpact(RayTraceResult rayTrace){ + Entity entityHit = rayTrace.entityHit; - // Particle effect - if(worldObj.isRemote){ - for(int i=0;i<8;i++){ - worldObj.spawnParticle(EnumParticleTypes.LAVA, this.posX + rand.nextFloat() - 0.5, this.posY + this.height/2 + rand.nextFloat() - 0.5, this.posZ + rand.nextFloat() - 0.5, 0, 0, 0); + if(entityHit != null){ + float damage = 5 * damageMultiplier; + + entityHit.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.FIRE).setProjectile(), + damage); + + if(!MagicDamage.isEntityImmune(DamageType.FIRE, entityHit)) entityHit.setFire(5); + } + + this.playSound(SoundEvents.BLOCK_LAVA_POP, 2, 0.8f + rand.nextFloat() * 0.3f); + + // Particle effect + if(world.isRemote){ + for(int i = 0; i < 8; i++){ + world.spawnParticle(EnumParticleTypes.LAVA, this.posX + rand.nextFloat() - 0.5, + this.posY + this.height / 2 + rand.nextFloat() - 0.5, this.posZ + rand.nextFloat() - 0.5, 0, 0, + 0); } - } + } - this.setDead(); - } - - @Override - public void onUpdate(){ - - super.onUpdate(); - - if(worldObj.isRemote){ - for(int i=0; i<4; i++){ - worldObj.spawnParticle(EnumParticleTypes.FLAME, this.posX + rand.nextFloat()*0.2 - 0.1, this.posY + this.height/2 + rand.nextFloat()*0.2 - 0.1, this.posZ + rand.nextFloat()*0.2 - 0.1, 0, 0, 0); - } - } - - if(this.ticksExisted > 8){ - this.setDead(); - } - } - - /** - * Gets the amount of gravity to apply to the thrown entity with each tick. - */ - @Override - protected float getGravityVelocity() - { - return 0.0F; - } - - /** - * Return whether this entity should be rendered as on fire. - */ - @Override - public boolean canRenderOnFire() - { - return false; - } + this.setDead(); + } + + @Override + public void onUpdate(){ + + super.onUpdate(); + + if(world.isRemote){ + for(int i = 0; i < 4; i++){ + world.spawnParticle(EnumParticleTypes.FLAME, this.posX + rand.nextFloat() * 0.2 - 0.1, + this.posY + this.height / 2 + rand.nextFloat() * 0.2 - 0.1, + this.posZ + rand.nextFloat() * 0.2 - 0.1, 0, 0, 0); + } + } + + if(this.ticksExisted > 8){ + this.setDead(); + } + } + + /** + * Gets the amount of gravity to apply to the thrown entity with each tick. + */ + @Override + protected float getGravityVelocity(){ + return 0.0F; + } + + /** + * Return whether this entity should be rendered as on fire. + */ + @Override + public boolean canRenderOnFire(){ + return false; + } } diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityFirebomb.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityFirebomb.java index 637fe5e8..296af6ff 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityFirebomb.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityFirebomb.java @@ -15,73 +15,84 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; public class EntityFirebomb extends EntityBomb { - - public EntityFirebomb(World par1World) - { - super(par1World); - } - public EntityFirebomb(World par1World, EntityLivingBase par2EntityLivingBase) - { - super(par1World, par2EntityLivingBase); - } - - public EntityFirebomb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier, float blastMultiplier) - { - super(par1World, par2EntityLivingBase, damageMultiplier, blastMultiplier); - } + public EntityFirebomb(World par1World){ + super(par1World); + } - public EntityFirebomb(World par1World, double par2, double par4, double par6) - { - super(par1World, par2, par4, par6); - } + public EntityFirebomb(World par1World, EntityLivingBase par2EntityLivingBase){ + super(par1World, par2EntityLivingBase); + } - /** - * Called when this EntityThrowable hits a block or entity. - */ - protected void onImpact(RayTraceResult par1RayTraceResult) - { - Entity entityHit = par1RayTraceResult.entityHit; - - if (entityHit != null) - { - // This is if the firebomb gets a direct hit - float damage = 5 * damageMultiplier; - - entityHit.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.FIRE).setProjectile(), damage); - - if(!MagicDamage.isEntityImmune(DamageType.FIRE, entityHit)) entityHit.setFire(10); - } + public EntityFirebomb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier, + float blastMultiplier){ + super(par1World, par2EntityLivingBase, damageMultiplier, blastMultiplier); + } - // Particle effect - if(worldObj.isRemote){ - this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 0, 0, 0); - for(int i=0;i<60*blastMultiplier;i++){ - //this.worldObj.spawnParticle(EnumParticleTypes.FLAME, this.posX + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posY + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posZ + (this.rand.nextDouble()*4 - 2)*blastMultiplier, 0, 0, 0); - Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, worldObj, this.posX + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posY + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posZ + (this.rand.nextDouble()*4 - 2)*blastMultiplier, 0, 0, 0, 15 + rand.nextInt(5), 2 + rand.nextFloat(), 0, 0); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, worldObj, this.posX + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posY + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posZ + (this.rand.nextDouble()*4 - 2)*blastMultiplier, 0.0d, 0.0d, 0.0d, 0, 1.0f, 0.2f + rand.nextFloat()*0.4f, 0.0f); + public EntityFirebomb(World par1World, double par2, double par4, double par6){ + super(par1World, par2, par4, par6); + } + + /** + * Called when this EntityThrowable hits a block or entity. + */ + protected void onImpact(RayTraceResult par1RayTraceResult){ + Entity entityHit = par1RayTraceResult.entityHit; + + if(entityHit != null){ + // This is if the firebomb gets a direct hit + float damage = 5 * damageMultiplier; + + entityHit.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.FIRE).setProjectile(), + damage); + + if(!MagicDamage.isEntityImmune(DamageType.FIRE, entityHit)) entityHit.setFire(10); + } + + // Particle effect + if(world.isRemote){ + this.world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 0, 0, 0); + for(int i = 0; i < 60 * blastMultiplier; i++){ + // this.world.spawnParticle(EnumParticleTypes.FLAME, this.posX + (this.rand.nextDouble()*4 - + // 2)*blastMultiplier, this.posY + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posZ + + // (this.rand.nextDouble()*4 - 2)*blastMultiplier, 0, 0, 0); + Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, + this.posX + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posY + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posZ + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, 0, 0, 0, 15 + rand.nextInt(5), + 2 + rand.nextFloat(), 0, 0); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, + this.posX + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posY + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posZ + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, 0.0d, 0.0d, 0.0d, 0, 1.0f, + 0.2f + rand.nextFloat() * 0.4f, 0.0f); } - } + } + + if(!this.world.isRemote){ + + this.playSound(SoundEvents.ENTITY_SPLASH_POTION_BREAK, 1.5F, rand.nextFloat() * 0.4F + 0.6F); + this.playSound(SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1); + + double range = 3.0d * blastMultiplier; + + List targets = WizardryUtilities.getEntitiesWithinRadius(range, this.posX, this.posY, + this.posZ, this.world); - if(!this.worldObj.isRemote){ - - this.playSound(SoundEvents.ENTITY_SPLASH_POTION_BREAK, 1.5F, rand.nextFloat() * 0.4F + 0.6F); - this.playSound(SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1); - - double range = 3.0d*blastMultiplier; - - List targets = WizardryUtilities.getEntitiesWithinRadius(range, this.posX, this.posY, this.posZ, this.worldObj); - for(EntityLivingBase target : targets){ - if(target != entityHit && target != this.getThrower() && !MagicDamage.isEntityImmune(DamageType.FIRE, target)){ + if(target != entityHit && target != this.getThrower() + && !MagicDamage.isEntityImmune(DamageType.FIRE, target)){ // Splash damage does not count as projectile damage - target.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.FIRE), 4.0f * damageMultiplier); + target.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.FIRE), + 4.0f * damageMultiplier); target.setFire(7); } } - - this.setDead(); - } - } - + + this.setDead(); + } + } + } diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityForceArrow.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityForceArrow.java index 0cf2ec6d..65d0606e 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityForceArrow.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityForceArrow.java @@ -7,79 +7,83 @@ import net.minecraft.init.SoundEvents; import net.minecraft.world.World; public class EntityForceArrow extends EntityMagicArrow { - - /** Basic shell constructor. Should only be used by the client. */ - public EntityForceArrow(World world) { + + /** Basic shell constructor. Should only be used by the client. */ + public EntityForceArrow(World world){ super(world); } - - /** Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this - * constructor and then call setVelocity() as that method is, bizarrely, client-side only. */ - public EntityForceArrow(World world, double x, double y, double z) - { - super(world, x, y, z); - } - /** Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be altered - * slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on easy, 6 on - * normal and 2 on hard difficulty. */ - public EntityForceArrow(World world, EntityLivingBase caster, Entity target, float speed, float aimingError, float damageMultiplier) - { - super(world, caster, target, speed, aimingError, damageMultiplier); - } + /** + * Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this constructor + * and then call setVelocity() as that method is, bizarrely, client-side only. + */ + public EntityForceArrow(World world, double x, double y, double z){ + super(world, x, y, z); + } - /** Creates a projectile pointing in the direction the caster is looking, with the given speed. - * USE THIS CONSTRUCTOR FOR NORMAL SPELLS. */ - public EntityForceArrow(World world, EntityLivingBase caster, float speed, float damageMultiplier) - { - super(world, caster, speed, damageMultiplier); - } + /** + * Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be + * altered slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on + * easy, 6 on normal and 2 on hard difficulty. + */ + public EntityForceArrow(World world, EntityLivingBase caster, Entity target, float speed, float aimingError, + float damageMultiplier){ + super(world, caster, target, speed, aimingError, damageMultiplier); + } + + /** + * Creates a projectile pointing in the direction the caster is looking, with the given speed. USE THIS CONSTRUCTOR + * FOR NORMAL SPELLS. + */ + public EntityForceArrow(World world, EntityLivingBase caster, float speed, float damageMultiplier){ + super(world, caster, speed, damageMultiplier); + } @Override public void onEntityHit(EntityLivingBase entityHit){ - this.playSound(SoundEvents.ENTITY_FIREWORK_BLAST, 1.0F, 1.0F); + this.playSound(SoundEvents.ENTITY_FIREWORK_BLAST, 1.0F, 1.0F); } - + @Override public void tickInGround(){ - this.setDead(); + this.setDead(); } - + @Override public void onBlockHit(){ - this.playSound(SoundEvents.ENTITY_FIREWORK_BLAST, 1.0F, 1.0F); + this.playSound(SoundEvents.ENTITY_FIREWORK_BLAST, 1.0F, 1.0F); } - + @Override public void tickInAir(){ - if (this.ticksExisted > 20){ - this.setDead(); - } - } - + if(this.ticksExisted > 20){ + this.setDead(); + } + } + @Override - public double getDamage(){ - return 7.0d; - } - + public double getDamage(){ + return 7.0d; + } + @Override public DamageType getDamageType(){ return DamageType.FORCE; } - - @Override - public boolean doGravity(){ - return false; - } - - @Override - public boolean doDeceleration(){ - return false; - } @Override - protected void entityInit() { - + public boolean doGravity(){ + return false; } - + + @Override + public boolean doDeceleration(){ + return false; + } + + @Override + protected void entityInit(){ + + } + } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityForceOrb.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityForceOrb.java index 9a4eaa7e..825db7fc 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityForceOrb.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityForceOrb.java @@ -15,92 +15,95 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; public class EntityForceOrb extends EntityMagicProjectile { - - /** The entity blast multiplier. In this particular case, it doesn't need syncing, so this class doesn't extend - * EntityBlastProjectile. */ + + /** + * The entity blast multiplier. In this particular case, it doesn't need syncing, so this class doesn't extend + * EntityBlastProjectile. + */ public float blastMultiplier; - - public EntityForceOrb(World par1World) - { - super(par1World); - } - public EntityForceOrb(World par1World, EntityLivingBase par2EntityLivingBase) - { - super(par1World, par2EntityLivingBase); - } - - public EntityForceOrb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier, float blastMultiplier) - { - super(par1World, par2EntityLivingBase, damageMultiplier); - this.blastMultiplier = blastMultiplier; - } + public EntityForceOrb(World par1World){ + super(par1World); + } - public EntityForceOrb(World par1World, double par2, double par4, double par6) - { - super(par1World, par2, par4, par6); - } + public EntityForceOrb(World par1World, EntityLivingBase par2EntityLivingBase){ + super(par1World, par2EntityLivingBase); + } - /** - * Called when this EntityThrowable hits a block or entity. - */ - protected void onImpact(RayTraceResult par1RayTraceResult){ - - if (par1RayTraceResult.entityHit != null) - { - // This is if the force orb gets a direct hit - this.playSound(SoundEvents.ENTITY_GENERIC_HURT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); - } - - // Particle effect - if(this.worldObj.isRemote){ - for(int j=0; j<20; j++){ - float brightness = 0.5f + (rand.nextFloat()/2); - double x = this.posX - 0.25d + (rand.nextDouble()/2); - double y = this.posY - 0.25d + (rand.nextDouble()/2); - double z = this.posZ - 0.25d + (rand.nextDouble()/2); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, x, y, z, (x - this.posX)*2, (y - this.posY)*2, (z - this.posZ)*2, 6, brightness, 1.0f, brightness + 0.2f); - } - this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 0, 0, 0); - } + public EntityForceOrb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier, + float blastMultiplier){ + super(par1World, par2EntityLivingBase, damageMultiplier); + this.blastMultiplier = blastMultiplier; + } + + public EntityForceOrb(World par1World, double par2, double par4, double par6){ + super(par1World, par2, par4, par6); + } + + /** + * Called when this EntityThrowable hits a block or entity. + */ + protected void onImpact(RayTraceResult par1RayTraceResult){ + + if(par1RayTraceResult.entityHit != null){ + // This is if the force orb gets a direct hit + this.playSound(SoundEvents.ENTITY_GENERIC_HURT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + } + + // Particle effect + if(this.world.isRemote){ + for(int j = 0; j < 20; j++){ + float brightness = 0.5f + (rand.nextFloat() / 2); + double x = this.posX - 0.25d + (rand.nextDouble() / 2); + double y = this.posY - 0.25d + (rand.nextDouble() / 2); + double z = this.posZ - 0.25d + (rand.nextDouble() / 2); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x, y, z, (x - this.posX) * 2, + (y - this.posY) * 2, (z - this.posZ) * 2, 6, brightness, 1.0f, brightness + 0.2f); + } + this.world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 0, 0, 0); + } + + if(!this.world.isRemote){ + + // 2 gives a cool flanging effect! + float pitch = this.rand.nextFloat() * 0.2F + 0.3F; + this.playSound(SoundEvents.ENTITY_FIREWORK_BLAST, 1.5F, pitch); + this.playSound(SoundEvents.ENTITY_FIREWORK_BLAST, 1.5F, pitch - 0.01f); + + double blastRadius = 4.0d * blastMultiplier; + + List targets = WizardryUtilities.getEntitiesWithinRadius(blastRadius, this.posX, + this.posY, this.posZ, this.world); - if(!this.worldObj.isRemote){ - - // 2 gives a cool flanging effect! - float pitch = this.rand.nextFloat() * 0.2F + 0.3F; - this.playSound(SoundEvents.ENTITY_FIREWORK_BLAST, 1.5F, pitch); - this.playSound(SoundEvents.ENTITY_FIREWORK_BLAST, 1.5F, pitch - 0.01f); - - double blastRadius = 4.0d*blastMultiplier; - - List targets = WizardryUtilities.getEntitiesWithinRadius(blastRadius, this.posX, this.posY, this.posZ, this.worldObj); - for(EntityLivingBase target : targets){ if(target != this.getThrower()){ - - double velY = target.motionY; - - double dx = this.posX-target.posX > 0? -0.5 - (this.posX-target.posX)/8 : 0.5 - (this.posX-target.posX)/8; - double dz = this.posZ-target.posZ > 0? -0.5 - (this.posZ-target.posZ)/8 : 0.5 - (this.posZ-target.posZ)/8; - - float damage = 4*damageMultiplier; - target.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.BLAST), damage); + double velY = target.motionY; + + double dx = this.posX - target.posX > 0 ? -0.5 - (this.posX - target.posX) / 8 + : 0.5 - (this.posX - target.posX) / 8; + double dz = this.posZ - target.posZ > 0 ? -0.5 - (this.posZ - target.posZ) / 8 + : 0.5 - (this.posZ - target.posZ) / 8; + + float damage = 4 * damageMultiplier; + + target.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.BLAST), damage); target.motionX = dx; target.motionY = velY + 0.4; target.motionZ = dz; } } - - this.setDead(); - } - } + + this.setDead(); + } + } @Override public void readEntityFromNBT(NBTTagCompound nbttagcompound){ - super.readEntityFromNBT(nbttagcompound); - blastMultiplier = nbttagcompound.getFloat("blastMultiplier"); + super.readEntityFromNBT(nbttagcompound); + blastMultiplier = nbttagcompound.getFloat("blastMultiplier"); } @Override diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityIceCharge.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityIceCharge.java index ce5c9907..3288e4fa 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityIceCharge.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityIceCharge.java @@ -20,116 +20,122 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; public class EntityIceCharge extends EntityBomb { - - public EntityIceCharge(World par1World) - { - super(par1World); - } - public EntityIceCharge(World par1World, EntityLivingBase par2EntityLivingBase) - { - super(par1World, par2EntityLivingBase); - } - - public EntityIceCharge(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier, float blastMultiplier) - { - super(par1World, par2EntityLivingBase, damageMultiplier, blastMultiplier); - } + public EntityIceCharge(World par1World){ + super(par1World); + } - public EntityIceCharge(World par1World, double par2, double par4, double par6) - { - super(par1World, par2, par4, par6); - } + public EntityIceCharge(World par1World, EntityLivingBase par2EntityLivingBase){ + super(par1World, par2EntityLivingBase); + } - /** - * Called when this EntityThrowable hits a block or entity. - */ - protected void onImpact(RayTraceResult par1RayTraceResult) - { - Entity entityHit = par1RayTraceResult.entityHit; - - if (entityHit != null) - { - // This is if the ice charge gets a direct hit - float damage = 4 * damageMultiplier; - - entityHit.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.FROST).setProjectile(), damage); - - if(entityHit instanceof EntityLivingBase && !MagicDamage.isEntityImmune(DamageType.FROST, entityHit)) - ((EntityLivingBase)entityHit).addPotionEffect(new PotionEffect(WizardryPotions.frost, 120, 1)); - } + public EntityIceCharge(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier, + float blastMultiplier){ + super(par1World, par2EntityLivingBase, damageMultiplier, blastMultiplier); + } - // Particle effect - if(worldObj.isRemote){ - this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 0, 0, 0); - for(int i=0;i<30*blastMultiplier;i++){ - float brightness = 0.4f + rand.nextFloat()*0.5f; - Wizardry.proxy.spawnParticle(WizardryParticleType.ICE, worldObj, this.posX + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posY + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posZ + (this.rand.nextDouble()*4 - 2)*blastMultiplier, 0.0d, 0.0d, 0.0d, 35); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, worldObj, this.posX + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posY + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posZ + (this.rand.nextDouble()*4 - 2)*blastMultiplier, 0.0d, 0.0d, 0.0d, 0, brightness, brightness+0.1f, 1.0f); + public EntityIceCharge(World par1World, double par2, double par4, double par6){ + super(par1World, par2, par4, par6); + } + + /** + * Called when this EntityThrowable hits a block or entity. + */ + protected void onImpact(RayTraceResult par1RayTraceResult){ + Entity entityHit = par1RayTraceResult.entityHit; + + if(entityHit != null){ + // This is if the ice charge gets a direct hit + float damage = 4 * damageMultiplier; + + entityHit.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.FROST).setProjectile(), + damage); + + if(entityHit instanceof EntityLivingBase && !MagicDamage.isEntityImmune(DamageType.FROST, entityHit)) + ((EntityLivingBase)entityHit).addPotionEffect(new PotionEffect(WizardryPotions.frost, 120, 1)); + } + + // Particle effect + if(world.isRemote){ + this.world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 0, 0, 0); + for(int i = 0; i < 30 * blastMultiplier; i++){ + float brightness = 0.4f + rand.nextFloat() * 0.5f; + Wizardry.proxy.spawnParticle(WizardryParticleType.ICE, world, + this.posX + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posY + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posZ + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, 0.0d, 0.0d, 0.0d, 35); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, + this.posX + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posY + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posZ + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, 0.0d, 0.0d, 0.0d, 0, brightness, + brightness + 0.1f, 1.0f); } - } + } + + if(!this.world.isRemote){ + + this.playSound(SoundEvents.ENTITY_SPLASH_POTION_BREAK, 1.5f, rand.nextFloat() * 0.4f + 0.6f); + this.playSound(WizardrySounds.SPELL_ICE, 1.2f, rand.nextFloat() * 0.4f + 1.2f); + + double radius = 3.0d * blastMultiplier; + + List targets = WizardryUtilities.getEntitiesWithinRadius(radius, this.posX, this.posY, + this.posZ, this.world); - if(!this.worldObj.isRemote){ - - this.playSound(SoundEvents.ENTITY_SPLASH_POTION_BREAK, 1.5f, rand.nextFloat() * 0.4f + 0.6f); - this.playSound(WizardrySounds.SPELL_ICE, 1.2f, rand.nextFloat() * 0.4f + 1.2f); - - double radius = 3.0d*blastMultiplier; - - List targets = WizardryUtilities.getEntitiesWithinRadius(radius, this.posX, this.posY, this.posZ, this.worldObj); - // Slows targets for(EntityLivingBase target : targets){ if(target != entityHit && target != this.getThrower()){ - if(!MagicDamage.isEntityImmune(DamageType.FROST, target)) target.addPotionEffect(new PotionEffect(WizardryPotions.frost, 100, 0)); + if(!MagicDamage.isEntityImmune(DamageType.FROST, target)) + target.addPotionEffect(new PotionEffect(WizardryPotions.frost, 100, 0)); } } - - // Places snow and ice on ground. - for(int i=-1; i<2; i++){ - for(int j=-1; j<2; j++){ - + + // Places snow and ice on ground. + for(int i = -1; i < 2; i++){ + for(int j = -1; j < 2; j++){ + BlockPos pos = new BlockPos(this.posX + i, this.posY, this.posZ + j); - - int y = WizardryUtilities.getNearestFloorLevelB(worldObj, pos, 7); - + + int y = WizardryUtilities.getNearestFloorLevelB(world, pos, 7); + pos = new BlockPos(pos.getX(), y, pos.getZ()); - + double dist = this.getDistance(pos.getX(), pos.getY(), pos.getZ()); - + // Randomised with weighting so that the nearer the block the more likely it is to be snowed. - if(y != -1 && rand.nextInt((int)dist*2 + 1) < 1 && dist < 2){ - if(worldObj.getBlockState(pos.down()).getBlock() == Blocks.WATER){ - worldObj.setBlockState(pos.down(), Blocks.ICE.getDefaultState()); + if(y != -1 && rand.nextInt((int)dist * 2 + 1) < 1 && dist < 2){ + if(world.getBlockState(pos.down()).getBlock() == Blocks.WATER){ + world.setBlockState(pos.down(), Blocks.ICE.getDefaultState()); }else{ // Don't need to check whether the block at pos can be replaced since getNearestFloorLevelB // only ever returns floors with air above them. - worldObj.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState()); + world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState()); } } } } - - // Releases shards - for(int i=0; i<10; i++){ - double dx = rand.nextDouble()-0.5; - double dy = rand.nextDouble()-0.5; - double dz = rand.nextDouble()-0.5; - EntityIceShard iceshard = new EntityIceShard(worldObj, this.posX + dx, this.posY + dy, this.posZ + dz); + + // Releases shards + for(int i = 0; i < 10; i++){ + double dx = rand.nextDouble() - 0.5; + double dy = rand.nextDouble() - 0.5; + double dz = rand.nextDouble() - 0.5; + EntityIceShard iceshard = new EntityIceShard(world, this.posX + dx, this.posY + dy, this.posZ + dz); iceshard.motionX = dx; iceshard.motionY = dy; iceshard.motionZ = dz; iceshard.setShootingEntity(this.getThrower()); iceshard.damageMultiplier = this.damageMultiplier; - worldObj.spawnEntityInWorld(iceshard); + world.spawnEntity(iceshard); } - - this.setDead(); - } - } - - @Override - public boolean canRenderOnFire() { + + this.setDead(); + } + } + + @Override + public boolean canRenderOnFire(){ return false; } } diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityIceLance.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityIceLance.java index ca4dd674..afbfa94c 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityIceLance.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityIceLance.java @@ -12,106 +12,112 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; public class EntityIceLance extends EntityMagicArrow { - - /** Basic shell constructor. Should only be used by the client. */ - public EntityIceLance(World world) { + + /** Basic shell constructor. Should only be used by the client. */ + public EntityIceLance(World world){ super(world); this.setKnockbackStrength(1); } - - /** Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this - * constructor and then call setVelocity() as that method is, bizarrely, client-side only. */ - public EntityIceLance(World world, double x, double y, double z) - { - super(world, x, y, z); - this.setKnockbackStrength(1); - } - /** Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be altered - * slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on easy, 6 on - * normal and 2 on hard difficulty. */ - public EntityIceLance(World world, EntityLivingBase caster, Entity target, float speed, float aimingError, float damageMultiplier) - { - super(world, caster, target, speed, aimingError, damageMultiplier); + /** + * Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this constructor + * and then call setVelocity() as that method is, bizarrely, client-side only. + */ + public EntityIceLance(World world, double x, double y, double z){ + super(world, x, y, z); this.setKnockbackStrength(1); - } + } - /** Creates a projectile pointing in the direction the caster is looking, with the given speed. - * USE THIS CONSTRUCTOR FOR NORMAL SPELLS. */ - public EntityIceLance(World world, EntityLivingBase caster, float speed, float damageMultiplier) - { - super(world, caster, speed, damageMultiplier); + /** + * Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be + * altered slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on + * easy, 6 on normal and 2 on hard difficulty. + */ + public EntityIceLance(World world, EntityLivingBase caster, Entity target, float speed, float aimingError, + float damageMultiplier){ + super(world, caster, target, speed, aimingError, damageMultiplier); this.setKnockbackStrength(1); - } + } + + /** + * Creates a projectile pointing in the direction the caster is looking, with the given speed. USE THIS CONSTRUCTOR + * FOR NORMAL SPELLS. + */ + public EntityIceLance(World world, EntityLivingBase caster, float speed, float damageMultiplier){ + super(world, caster, speed, damageMultiplier); + this.setKnockbackStrength(1); + } @Override public void onEntityHit(EntityLivingBase entityHit){ - - // Adds a freeze effect to the target. - if(!MagicDamage.isEntityImmune(DamageType.FROST, entityHit)) entityHit.addPotionEffect(new PotionEffect(WizardryPotions.frost, 300, 0)); - + + // Adds a freeze effect to the target. + if(!MagicDamage.isEntityImmune(DamageType.FROST, entityHit)) + entityHit.addPotionEffect(new PotionEffect(WizardryPotions.frost, 300, 0)); + this.playSound(SoundEvents.ENTITY_GENERIC_HURT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); } - + @Override public void tickInAir(){ - - } + + } @Override public void onBlockHit(){ // Adds a particle effect when the ice lance hits a block. - if(this.worldObj.isRemote){ - for(int j=0; j<10; j++){ - double x = this.posX - 0.25d + (rand.nextDouble()/2); - double y = this.posY - 0.25d + (rand.nextDouble()/2); - double z = this.posZ - 0.25d + (rand.nextDouble()/2); - Wizardry.proxy.spawnParticle(WizardryParticleType.ICE, worldObj, x, y, z, x - this.posX, y - this.posY, z - this.posZ, 20 + rand.nextInt(10)); - } - } - // Parameters for sound: sound event name, volume, pitch. - this.playSound(SoundEvents.ENTITY_SPLASH_POTION_BREAK, 1.0F, rand.nextFloat() * 0.4F + 1.2F); - + if(this.world.isRemote){ + for(int j = 0; j < 10; j++){ + double x = this.posX - 0.25d + (rand.nextDouble() / 2); + double y = this.posY - 0.25d + (rand.nextDouble() / 2); + double z = this.posZ - 0.25d + (rand.nextDouble() / 2); + Wizardry.proxy.spawnParticle(WizardryParticleType.ICE, world, x, y, z, x - this.posX, y - this.posY, + z - this.posZ, 20 + rand.nextInt(10)); + } + } + // Parameters for sound: sound event name, volume, pitch. + this.playSound(SoundEvents.ENTITY_SPLASH_POTION_BREAK, 1.0F, rand.nextFloat() * 0.4F + 1.2F); + } - + @Override public void tickInGround(){ - this.setDead(); + this.setDead(); } - + @Override - public double getDamage(){ - return 10.0d; - } - + public double getDamage(){ + return 10.0d; + } + @Override public DamageType getDamageType(){ return DamageType.FROST; } - - @Override - public boolean doGravity(){ - return true; - } - - @Override - public boolean doDeceleration(){ - return true; - } - - @Override - public boolean doOverpenetration(){ - return true; - } @Override - protected void entityInit() { - + public boolean doGravity(){ + return true; } - + @Override - public boolean canRenderOnFire() { + public boolean doDeceleration(){ + return true; + } + + @Override + public boolean doOverpenetration(){ + return true; + } + + @Override + protected void entityInit(){ + + } + + @Override + public boolean canRenderOnFire(){ return false; } - + } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityIceShard.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityIceShard.java index 0805c4e0..2d5e2f39 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityIceShard.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityIceShard.java @@ -12,92 +12,98 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; public class EntityIceShard extends EntityMagicArrow { - - /** Basic shell constructor. Should only be used by the client. */ - public EntityIceShard(World world) { + + /** Basic shell constructor. Should only be used by the client. */ + public EntityIceShard(World world){ super(world); } - - /** Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this - * constructor and then call setVelocity() as that method is, bizarrely, client-side only. */ - public EntityIceShard(World world, double x, double y, double z) - { - super(world, x, y, z); - } - /** Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be altered - * slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on easy, 6 on - * normal and 2 on hard difficulty. */ - public EntityIceShard(World world, EntityLivingBase caster, Entity target, float speed, float aimingError, float damageMultiplier) - { - super(world, caster, target, speed, aimingError, damageMultiplier); - } + /** + * Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this constructor + * and then call setVelocity() as that method is, bizarrely, client-side only. + */ + public EntityIceShard(World world, double x, double y, double z){ + super(world, x, y, z); + } - /** Creates a projectile pointing in the direction the caster is looking, with the given speed. - * USE THIS CONSTRUCTOR FOR NORMAL SPELLS. */ - public EntityIceShard(World world, EntityLivingBase caster, float speed, float damageMultiplier) - { - super(world, caster, speed, damageMultiplier); - } + /** + * Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be + * altered slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on + * easy, 6 on normal and 2 on hard difficulty. + */ + public EntityIceShard(World world, EntityLivingBase caster, Entity target, float speed, float aimingError, + float damageMultiplier){ + super(world, caster, target, speed, aimingError, damageMultiplier); + } + + /** + * Creates a projectile pointing in the direction the caster is looking, with the given speed. USE THIS CONSTRUCTOR + * FOR NORMAL SPELLS. + */ + public EntityIceShard(World world, EntityLivingBase caster, float speed, float damageMultiplier){ + super(world, caster, speed, damageMultiplier); + } @Override public void onEntityHit(EntityLivingBase entityHit){ - - // Adds a freeze effect to the target. - if(!MagicDamage.isEntityImmune(DamageType.FROST, entityHit)) entityHit.addPotionEffect(new PotionEffect(WizardryPotions.frost, 200, 0)); - + + // Adds a freeze effect to the target. + if(!MagicDamage.isEntityImmune(DamageType.FROST, entityHit)) + entityHit.addPotionEffect(new PotionEffect(WizardryPotions.frost, 200, 0)); + this.playSound(SoundEvents.ENTITY_GENERIC_HURT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); } - + @Override public void tickInAir(){ - - } + + } @Override public void onBlockHit(){ // Adds a particle effect when the ice shard hits a block. - if(this.worldObj.isRemote){ - for(int j=0; j<10; j++){ - double x = this.posX - 0.25d + (rand.nextDouble()/2); - double y = this.posY - 0.25d + (rand.nextDouble()/2); - double z = this.posZ - 0.25d + (rand.nextDouble()/2); - Wizardry.proxy.spawnParticle(WizardryParticleType.ICE, worldObj, x, y, z, x - this.posX, y - this.posY, z - this.posZ, 20 + rand.nextInt(10)); - } - } - // Parameters for sound: sound event name, volume, pitch. - this.playSound(SoundEvents.ENTITY_SPLASH_POTION_BREAK, 1.0F, rand.nextFloat() * 0.4F + 1.2F); - + if(this.world.isRemote){ + for(int j = 0; j < 10; j++){ + double x = this.posX - 0.25d + (rand.nextDouble() / 2); + double y = this.posY - 0.25d + (rand.nextDouble() / 2); + double z = this.posZ - 0.25d + (rand.nextDouble() / 2); + Wizardry.proxy.spawnParticle(WizardryParticleType.ICE, world, x, y, z, x - this.posX, y - this.posY, + z - this.posZ, 20 + rand.nextInt(10)); + } + } + // Parameters for sound: sound event name, volume, pitch. + this.playSound(SoundEvents.ENTITY_SPLASH_POTION_BREAK, 1.0F, rand.nextFloat() * 0.4F + 1.2F); + } - + @Override - public double getDamage(){ - return 6.0d; - } - + public double getDamage(){ + return 6.0d; + } + @Override public DamageType getDamageType(){ return DamageType.FROST; } - - @Override - public boolean doGravity(){ - return true; - } - - @Override - public boolean doDeceleration(){ - return true; - } @Override - protected void entityInit() { - + public boolean doGravity(){ + return true; } - + @Override - public boolean canRenderOnFire() { + public boolean doDeceleration(){ + return true; + } + + @Override + protected void entityInit(){ + + } + + @Override + public boolean canRenderOnFire(){ return false; } - + } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityLightningArrow.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityLightningArrow.java index e7f250ba..f19c4dc2 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityLightningArrow.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityLightningArrow.java @@ -10,86 +10,91 @@ import net.minecraft.world.World; public class EntityLightningArrow extends EntityMagicArrow { - /** Basic shell constructor. Should only be used by the client. */ - public EntityLightningArrow(World world) { + /** Basic shell constructor. Should only be used by the client. */ + public EntityLightningArrow(World world){ super(world); } - - /** Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this - * constructor and then call setVelocity() as that method is, bizarrely, client-side only. */ - public EntityLightningArrow(World world, double x, double y, double z) - { - super(world, x, y, z); - } - /** Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be altered - * slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on easy, 6 on - * normal and 2 on hard difficulty. */ - public EntityLightningArrow(World world, EntityLivingBase caster, Entity target, float speed, float aimingError, float damageMultiplier) - { - super(world, caster, target, speed, aimingError, damageMultiplier); - } + /** + * Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this constructor + * and then call setVelocity() as that method is, bizarrely, client-side only. + */ + public EntityLightningArrow(World world, double x, double y, double z){ + super(world, x, y, z); + } - /** Creates a projectile pointing in the direction the caster is looking, with the given speed. - * USE THIS CONSTRUCTOR FOR NORMAL SPELLS. */ - public EntityLightningArrow(World world, EntityLivingBase caster, float speed, float damageMultiplier) - { - super(world, caster, speed, damageMultiplier); - } + /** + * Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be + * altered slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on + * easy, 6 on normal and 2 on hard difficulty. + */ + public EntityLightningArrow(World world, EntityLivingBase caster, Entity target, float speed, float aimingError, + float damageMultiplier){ + super(world, caster, target, speed, aimingError, damageMultiplier); + } + + /** + * Creates a projectile pointing in the direction the caster is looking, with the given speed. USE THIS CONSTRUCTOR + * FOR NORMAL SPELLS. + */ + public EntityLightningArrow(World world, EntityLivingBase caster, float speed, float damageMultiplier){ + super(world, caster, speed, damageMultiplier); + } @Override public void onEntityHit(EntityLivingBase entityHit){ - - if(worldObj.isRemote){ - for(int j=0;j<8;j++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, worldObj, this.posX + rand.nextFloat() - 0.5, this.posY + this.height/2 + rand.nextFloat() - 0.5, this.posZ + rand.nextFloat() - 0.5, 0, 0, 0, 3); + + if(world.isRemote){ + for(int j = 0; j < 8; j++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, this.posX + rand.nextFloat() - 0.5, + this.posY + this.height / 2 + rand.nextFloat() - 0.5, this.posZ + rand.nextFloat() - 0.5, 0, 0, + 0, 3); } } - /* Pretty sure this needn't be here, probably missed it when I implemented the damage type system. - if(entityHit instanceof EntityCreeper && !((EntityCreeper)entityHit).getPowered()){ - entityHit.getDataWatcher().updateObject(17, Byte.valueOf((byte)1)); - if(this.getShootingEntity() instanceof EntityPlayer) ((EntityPlayer)this.getShootingEntity()).addStat(Wizardry.chargeCreeper); - } - */ - this.playSound(WizardrySounds.SPELL_SPARK, 1.0F, 1.0F); + /* Pretty sure this needn't be here, probably missed it when I implemented the damage type system. if(entityHit + * instanceof EntityCreeper && !((EntityCreeper)entityHit).getPowered()){ + * entityHit.getDataWatcher().updateObject(17, Byte.valueOf((byte)1)); if(this.getShootingEntity() instanceof + * EntityPlayer) ((EntityPlayer)this.getShootingEntity()).addStat(Wizardry.chargeCreeper); } */ + this.playSound(WizardrySounds.SPELL_SPARK, 1.0F, 1.0F); } - + @Override public void tickInAir(){ - if (this.ticksExisted > 20){ - this.setDead(); - } + if(this.ticksExisted > 20){ + this.setDead(); + } + + if(world.isRemote){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, this.posX, this.posY, this.posZ, 0, 0, 0, + 3); + } + + } - if(worldObj.isRemote){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, worldObj, this.posX, this.posY, this.posZ, 0, 0, 0, 3); - } - - } - @Override - public double getDamage(){ - return 7.0d; - } - + public double getDamage(){ + return 7.0d; + } + @Override public DamageType getDamageType(){ return DamageType.SHOCK; } - - @Override - public boolean doGravity(){ - return false; - } - - @Override - public boolean doDeceleration(){ - return false; - } @Override - protected void entityInit() { - + public boolean doGravity(){ + return false; } - + + @Override + public boolean doDeceleration(){ + return false; + } + + @Override + protected void entityInit(){ + + } + } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityLightningDisc.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityLightningDisc.java index e27e34d1..a487d0a7 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityLightningDisc.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityLightningDisc.java @@ -13,71 +13,67 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; -public class EntityLightningDisc extends EntityMagicProjectile -{ - public EntityLightningDisc(World par1World) - { - super(par1World); - } +public class EntityLightningDisc extends EntityMagicProjectile { + public EntityLightningDisc(World par1World){ + super(par1World); + } - public EntityLightningDisc(World par1World, EntityLivingBase par2EntityLivingBase) - { - super(par1World, par2EntityLivingBase); - } - - public EntityLightningDisc(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier) - { - super(par1World, par2EntityLivingBase, damageMultiplier); - } + public EntityLightningDisc(World par1World, EntityLivingBase par2EntityLivingBase){ + super(par1World, par2EntityLivingBase); + } - public EntityLightningDisc(World par1World, double par2, double par4, double par6) - { - super(par1World, par2, par4, par6); - this.width = 2.0f; - this.height = 0.5f; - } - - @Override - protected float getSpeed(){ - return 1.2f; - } + public EntityLightningDisc(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier){ + super(par1World, par2EntityLivingBase, damageMultiplier); + } + public EntityLightningDisc(World par1World, double par2, double par4, double par6){ + super(par1World, par2, par4, par6); + this.width = 2.0f; + this.height = 0.5f; + } - @Override - protected void onImpact(RayTraceResult mop) - { - Entity entityHit = mop.entityHit; - - if (entityHit != null) - { - float damage = 12 * damageMultiplier; - - entityHit.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.SHOCK), damage); - } + @Override + protected float getSpeed(){ + return 1.2f; + } - this.playSound(WizardrySounds.SPELL_SPARK, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + @Override + protected void onImpact(RayTraceResult mop){ + Entity entityHit = mop.entityHit; - if(mop.typeOfHit == RayTraceResult.Type.BLOCK) this.setDead(); - } + if(entityHit != null){ + float damage = 12 * damageMultiplier; - @Override - public void onUpdate(){ - - super.onUpdate(); + entityHit.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.SHOCK), + damage); + } - // Particle effect - if(worldObj.isRemote){ - for(int i=0;i<8;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, worldObj, this.posX + rand.nextFloat()*2 - 1, this.posY, this.posZ + rand.nextFloat() - 0.5, 0, 0, 0, 3); - //worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX + rand.nextFloat() - 0.5, this.posY + this.height/2 + rand.nextFloat() - 0.5, this.posZ + rand.nextFloat() - 0.5, 0, 0, 0); + this.playSound(WizardrySounds.SPELL_SPARK, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + + if(mop.typeOfHit == RayTraceResult.Type.BLOCK) this.setDead(); + } + + @Override + public void onUpdate(){ + + super.onUpdate(); + + // Particle effect + if(world.isRemote){ + for(int i = 0; i < 8; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, this.posX + rand.nextFloat() * 2 - 1, + this.posY, this.posZ + rand.nextFloat() - 0.5, 0, 0, 0, 3); + // world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX + rand.nextFloat() - 0.5, this.posY + + // this.height/2 + rand.nextFloat() - 0.5, this.posZ + rand.nextFloat() - 0.5, 0, 0, 0); } - } - - if(!this.isCollided && !worldObj.isRemote){ - - double seekingRange = 5.0d; - - List entities = WizardryUtilities.getEntitiesWithinRadius(seekingRange, this.posX, this.posY, this.posZ, this.worldObj); + } + + if(!this.isCollided && !world.isRemote){ + + double seekingRange = 5.0d; + + List entities = WizardryUtilities.getEntitiesWithinRadius(seekingRange, this.posX, + this.posY, this.posZ, this.world); Entity target = null; for(Entity possibleTarget : entities){ @@ -89,33 +85,31 @@ public class EntityLightningDisc extends EntityMagicProjectile } } } - - if(target != null && Math.abs(this.motionX) < 1 && Math.abs(this.motionY) < 1 && Math.abs(this.motionZ) < 1){ - this.addVelocity((target.posX - this.posX)/30, (target.posY + target.height/2 - this.posY)/30, (target.posZ - this.posZ)/30); + + if(target != null && Math.abs(this.motionX) < 1 && Math.abs(this.motionY) < 1 + && Math.abs(this.motionZ) < 1){ + this.addVelocity((target.posX - this.posX) / 30, (target.posY + target.height / 2 - this.posY) / 30, + (target.posZ - this.posZ) / 30); } - } - - if(this.ticksExisted > 50){ - this.setDead(); - } - - // Cancels out the slowdown effect in EntityThrowable - this.motionX /= 0.99; - this.motionY /= 0.99; - this.motionZ /= 0.99; - } - + } - @Override - protected float getGravityVelocity() - { - return 0.0F; - } - + if(this.ticksExisted > 50){ + this.setDead(); + } - @Override - public boolean canRenderOnFire() - { - return false; - } + // Cancels out the slowdown effect in EntityThrowable + this.motionX /= 0.99; + this.motionY /= 0.99; + this.motionZ /= 0.99; + } + + @Override + protected float getGravityVelocity(){ + return 0.0F; + } + + @Override + public boolean canRenderOnFire(){ + return false; + } } diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityMagicArrow.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityMagicArrow.java index fefa58cd..a683a3aa 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityMagicArrow.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityMagicArrow.java @@ -33,550 +33,550 @@ import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -/** This class was copied from EntityArrow in the 1.7.10 update as part of the overhaul and major cleanup - * of the code for the projectiles. It provides a unifying superclass for all directed projectiles (i.e. not - * spherical stuff like snowballs), namely magic missile, ice shard, force arrow, lightning arrow and dart. - * All spherical projectiles should extend {@link EntityMagicProjectile}. +/** + * This class was copied from EntityArrow in the 1.7.10 update as part of the overhaul and major cleanup of the code for + * the projectiles. It provides a unifying superclass for all directed projectiles (i.e. not spherical stuff like + * snowballs), namely magic missile, ice shard, force arrow, lightning arrow and dart. All spherical projectiles should + * extend {@link EntityMagicProjectile}. *

    - * This class handles saving of the damage multiplier and all shared logic. Methods are provided which are - * triggered at useful points during the entity update cycle as well as a few getters for various properties. - * Override any of these to change the behaviour (no need to call super for any of them). + * This class handles saving of the damage multiplier and all shared logic. Methods are provided which are triggered at + * useful points during the entity update cycle as well as a few getters for various properties. Override any of these + * to change the behaviour (no need to call super for any of them). + * * @since Wizardry 1.0 * @author Electroblob */ public abstract class EntityMagicArrow extends Entity implements IProjectile, IEntityAdditionalSpawnData { - private int blockX = -1; - private int blockY = -1; - private int blockZ = -1; - /** The block the arrow is stuck in */ - private IBlockState stuckInBlock; - /** The metadata of the block the arrow is stuck in */ - private int inData; - private boolean inGround; - /** Seems to be some sort of timer for animating an arrow. */ - public int arrowShake; - /** The owner of this arrow. */ - private WeakReference shootingEntity; - /** The UUID of the caster. Note that this is only for loading purposes; during normal updates - * the actual entity instance is stored (so that getEntityByUUID is not called constantly), - * so this will not always be synced (this is why it is private). */ + private int blockX = -1; + private int blockY = -1; + private int blockZ = -1; + /** The block the arrow is stuck in */ + private IBlockState stuckInBlock; + /** The metadata of the block the arrow is stuck in */ + private int inData; + private boolean inGround; + /** Seems to be some sort of timer for animating an arrow. */ + public int arrowShake; + /** The owner of this arrow. */ + private WeakReference shootingEntity; + /** + * The UUID of the caster. Note that this is only for loading purposes; during normal updates the actual entity + * instance is stored (so that getEntityByUUID is not called constantly), so this will not always be synced (this is + * why it is private). + */ private UUID casterUUID; - int ticksInGround; - int ticksInAir; - /** The amount of knockback an arrow applies when it hits a mob. */ - private int knockbackStrength; - /** The damage multiplier for the arrow. Normally this isn't set directly, since it can be done via the - * constructor. An exception is where other entities need to pass in their multipliers, e.g. ice charge. */ + int ticksInGround; + int ticksInAir; + /** The amount of knockback an arrow applies when it hits a mob. */ + private int knockbackStrength; + /** + * The damage multiplier for the arrow. Normally this isn't set directly, since it can be done via the constructor. + * An exception is where other entities need to pass in their multipliers, e.g. ice charge. + */ public float damageMultiplier = 1.0f; - /** Basic shell constructor. Should only be used by the client. */ - public EntityMagicArrow(World world) - { - super(world); - this.setSize(0.5F, 0.5F); - } + /** Basic shell constructor. Should only be used by the client. */ + public EntityMagicArrow(World world){ + super(world); + this.setSize(0.5F, 0.5F); + } - /** Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this - * constructor and then call setVelocity() as that method is, bizarrely, client-side only. */ - public EntityMagicArrow(World world, double x, double y, double z) - { - super(world); - this.setSize(0.5F, 0.5F); - this.setPosition(x, y, z); - // yOffset was set to 0 here, but that has been replaced by getYOffset(), which returns 0 in Entity anyway. - } + /** + * Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this constructor + * and then call setVelocity() as that method is, bizarrely, client-side only. + */ + public EntityMagicArrow(World world, double x, double y, double z){ + super(world); + this.setSize(0.5F, 0.5F); + this.setPosition(x, y, z); + // yOffset was set to 0 here, but that has been replaced by getYOffset(), which returns 0 in Entity anyway. + } - /** Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be altered - * slightly by a random amount determined by the aimingError parameter. For reference, skeletons set this to 10 on easy, 6 on - * normal and 2 on hard difficulty. */ - public EntityMagicArrow(World world, EntityLivingBase caster, Entity target, float speed, float aimingError, float damageMultiplier) - { - super(world); - this.shootingEntity = new WeakReference(caster); - this.damageMultiplier = damageMultiplier; + /** + * Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be + * altered slightly by a random amount determined by the aimingError parameter. For reference, skeletons set this to + * 10 on easy, 6 on normal and 2 on hard difficulty. + */ + public EntityMagicArrow(World world, EntityLivingBase caster, Entity target, float speed, float aimingError, + float damageMultiplier){ + super(world); + this.shootingEntity = new WeakReference(caster); + this.damageMultiplier = damageMultiplier; - this.posY = caster.posY + (double)caster.getEyeHeight() - 0.10000000149011612D; - double d0 = target.posX - caster.posX; - double d1 = this.doGravity() ? target.getEntityBoundingBox().minY + (double)(target.height / 3.0F) - this.posY - : target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) - this.posY; - double d2 = target.posZ - caster.posZ; - double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2); + this.posY = caster.posY + (double)caster.getEyeHeight() - 0.10000000149011612D; + double d0 = target.posX - caster.posX; + double d1 = this.doGravity() ? target.getEntityBoundingBox().minY + (double)(target.height / 3.0F) - this.posY + : target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) - this.posY; + double d2 = target.posZ - caster.posZ; + double d3 = (double)MathHelper.sqrt(d0 * d0 + d2 * d2); - if (d3 >= 1.0E-7D) - { - float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; - float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI)); - double d4 = d0 / d3; - double d5 = d2 / d3; - this.setLocationAndAngles(caster.posX + d4, this.posY, caster.posZ + d5, f2, f3); - // yOffset was set to 0 here, but that has been replaced by getYOffset(), which returns 0 in Entity anyway. + if(d3 >= 1.0E-7D){ + float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; + float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI)); + double d4 = d0 / d3; + double d5 = d2 / d3; + this.setLocationAndAngles(caster.posX + d4, this.posY, caster.posZ + d5, f2, f3); + // yOffset was set to 0 here, but that has been replaced by getYOffset(), which returns 0 in Entity anyway. - // f4 depends on the horizontal distance between the two entities and accounts for bullet drop, - // but of course if gravity is ignored this should be 0. - float bulletDropCompensation = this.doGravity() ? (float)d3 * 0.2F : 0; - this.setThrowableHeading(d0, d1 + (double)bulletDropCompensation, d2, speed, aimingError); - } - } + // f4 depends on the horizontal distance between the two entities and accounts for bullet drop, + // but of course if gravity is ignored this should be 0. + float bulletDropCompensation = this.doGravity() ? (float)d3 * 0.2F : 0; + this.setThrowableHeading(d0, d1 + (double)bulletDropCompensation, d2, speed, aimingError); + } + } - /** Creates a projectile pointing in the direction the caster is looking, with the given speed. - * Use this constructor for normal, player-cast spells. */ - public EntityMagicArrow(World world, EntityLivingBase caster, float speed, float damageMultiplier) - { - super(world); - this.shootingEntity = new WeakReference(caster); - this.damageMultiplier = damageMultiplier; + /** + * Creates a projectile pointing in the direction the caster is looking, with the given speed. Use this + * constructor for normal, player-cast spells. + */ + public EntityMagicArrow(World world, EntityLivingBase caster, float speed, float damageMultiplier){ + super(world); + this.shootingEntity = new WeakReference(caster); + this.damageMultiplier = damageMultiplier; - this.setSize(0.5F, 0.5F); - this.setLocationAndAngles(caster.posX, caster.posY + (double)caster.getEyeHeight(), caster.posZ, caster.rotationYaw, caster.rotationPitch); - this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); - this.posY -= 0.10000000149011612D; - this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); - this.setPosition(this.posX, this.posY, this.posZ); - // yOffset was set to 0 here, but that has been replaced by getYOffset(), which returns 0 in Entity anyway. - this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); - this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); - this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI)); - this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, speed * 1.5F, 1.0F); - } - - /** Subclasses must override this to set their own base damage. */ - public abstract double getDamage(); + this.setSize(0.5F, 0.5F); + this.setLocationAndAngles(caster.posX, caster.posY + (double)caster.getEyeHeight(), caster.posZ, + caster.rotationYaw, caster.rotationPitch); + this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); + this.posY -= 0.10000000149011612D; + this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); + this.setPosition(this.posX, this.posY, this.posZ); + // yOffset was set to 0 here, but that has been replaced by getYOffset(), which returns 0 in Entity anyway. + this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) + * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); + this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) + * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); + this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI)); + this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, speed * 1.5F, 1.0F); + } - /** Override this to specify the damage type dealt. Defaults to {@link DamageType#MAGIC}. */ - public DamageType getDamageType(){ + /** Subclasses must override this to set their own base damage. */ + public abstract double getDamage(); + + /** Override this to specify the damage type dealt. Defaults to {@link DamageType#MAGIC}. */ + public DamageType getDamageType(){ return DamageType.MAGIC; } - - /** Override this to disable gravity. Returns true by default. */ - public boolean doGravity(){ - return true; - } - - /** Override this to disable deceleration (generally speaking, this isn't noticeable unless gravity - * is turned off). Returns true by default. */ - public boolean doDeceleration(){ - return true; - } - - /** Override this to allow the projectile to pass through mobs intact (the onEntityHit method will - * still be called and damage will still be applied). Returns false by default. */ - public boolean doOverpenetration(){ - return false; - } - /** - * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. - */ - public void setThrowableHeading(double x, double y, double z, float speed, float randomness) - { - float f2 = MathHelper.sqrt_double(x * x + y * y + z * z); - x /= (double)f2; - y /= (double)f2; - z /= (double)f2; - x += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)randomness; - y += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)randomness; - z += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)randomness; - x *= (double)speed; - y *= (double)speed; - z *= (double)speed; - this.motionX = x; - this.motionY = y; - this.motionZ = z; - float f3 = MathHelper.sqrt_double(x * x + z * z); - this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f3) * 180.0D / Math.PI); - this.ticksInGround = 0; - } + /** Override this to disable gravity. Returns true by default. */ + public boolean doGravity(){ + return true; + } - // There was an override for setPositionAndRotationDirect here, but it was exactly the same as the superclass - // method (in Entity), so it was removed since it was redundant. + /** + * Override this to disable deceleration (generally speaking, this isn't noticeable unless gravity is turned off). + * Returns true by default. + */ + public boolean doDeceleration(){ + return true; + } - /** - * Sets the velocity to the args. Args: x, y, z. THIS IS CLIENT SIDE ONLY! DO NOT USE IN COMMON OR SERVER CODE! - */ - @Override - @SideOnly(Side.CLIENT) - public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_) - { - this.motionX = p_70016_1_; - this.motionY = p_70016_3_; - this.motionZ = p_70016_5_; + /** + * Override this to allow the projectile to pass through mobs intact (the onEntityHit method will still be called + * and damage will still be applied). Returns false by default. + */ + public boolean doOverpenetration(){ + return false; + } - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) - { - float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_); - this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70016_3_, (double)f) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch; - this.prevRotationYaw = this.rotationYaw; - this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); - this.ticksInGround = 0; - } - } - - /** Called each tick when the projectile is in a block. Defaults to setDead(), but can be overridden to - * change the behaviour. */ - public void tickInGround(){ - this.setDead(); - } - - /** Called each tick when the projectile is in the air. Override to add particles and such like. */ - public void tickInAir(){} - - /** Called when the projectile hits an entity. Override to add potion effects and such like. */ - public void onEntityHit(EntityLivingBase entityHit){} - - /** Called when the projectile hits a block. Override to add sound effects and such like. */ - public void onBlockHit(){} + /** + * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. + */ + public void setThrowableHeading(double x, double y, double z, float speed, float randomness){ + float f2 = MathHelper.sqrt(x * x + y * y + z * z); + x /= (double)f2; + y /= (double)f2; + z /= (double)f2; + x += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D + * (double)randomness; + y += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D + * (double)randomness; + z += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D + * (double)randomness; + x *= (double)speed; + y *= (double)speed; + z *= (double)speed; + this.motionX = x; + this.motionY = y; + this.motionZ = z; + float f3 = MathHelper.sqrt(x * x + z * z); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f3) * 180.0D / Math.PI); + this.ticksInGround = 0; + } - @Override - public void onUpdate(){ - - super.onUpdate(); + // There was an override for setPositionAndRotationDirect here, but it was exactly the same as the superclass + // method (in Entity), so it was removed since it was redundant. - if(this.getShootingEntity() == null && this.casterUUID != null){ - Entity entity = WizardryUtilities.getEntityByUUID(worldObj, casterUUID); + /** + * Sets the velocity to the args. Args: x, y, z. THIS IS CLIENT SIDE ONLY! DO NOT USE IN COMMON OR SERVER CODE! + */ + @Override + @SideOnly(Side.CLIENT) + public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_){ + this.motionX = p_70016_1_; + this.motionY = p_70016_3_; + this.motionZ = p_70016_5_; + + if(this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F){ + float f = MathHelper.sqrt(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70016_3_, (double)f) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch; + this.prevRotationYaw = this.rotationYaw; + this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); + this.ticksInGround = 0; + } + } + + /** + * Called each tick when the projectile is in a block. Defaults to setDead(), but can be overridden to change the + * behaviour. + */ + public void tickInGround(){ + this.setDead(); + } + + /** Called each tick when the projectile is in the air. Override to add particles and such like. */ + public void tickInAir(){ + } + + /** Called when the projectile hits an entity. Override to add potion effects and such like. */ + public void onEntityHit(EntityLivingBase entityHit){ + } + + /** Called when the projectile hits a block. Override to add sound effects and such like. */ + public void onBlockHit(){ + } + + @Override + public void onUpdate(){ + + super.onUpdate(); + + if(this.getShootingEntity() == null && this.casterUUID != null){ + Entity entity = WizardryUtilities.getEntityByUUID(world, casterUUID); if(entity instanceof EntityLivingBase){ this.shootingEntity = new WeakReference((EntityLivingBase)entity); } } - - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) - { - float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI); - } - BlockPos blockpos = new BlockPos(this.blockX, this.blockY, this.blockZ); - IBlockState iblockstate = this.worldObj.getBlockState(blockpos); + if(this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F){ + float f = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D + / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D + / Math.PI); + } - if (iblockstate.getMaterial() != Material.AIR) - { - AxisAlignedBB axisalignedbb = iblockstate.getCollisionBoundingBox(this.worldObj, blockpos); + BlockPos blockpos = new BlockPos(this.blockX, this.blockY, this.blockZ); + IBlockState iblockstate = this.world.getBlockState(blockpos); - if (axisalignedbb != Block.NULL_AABB && axisalignedbb.offset(blockpos).isVecInside(new Vec3d(this.posX, this.posY, this.posZ))) - { - this.inGround = true; - } - } + if(iblockstate.getMaterial() != Material.AIR){ + AxisAlignedBB axisalignedbb = iblockstate.getCollisionBoundingBox(this.world, blockpos); - if (this.arrowShake > 0) - { - --this.arrowShake; - } + if(axisalignedbb != Block.NULL_AABB + && axisalignedbb.offset(blockpos).isVecInside(new Vec3d(this.posX, this.posY, this.posZ))){ + this.inGround = true; + } + } - // When the arrow is in the ground - if (this.inGround) - { - ++this.ticksInGround; - this.tickInGround(); - } - // When the arrow is in the air - else{ - - this.tickInAir(); - - this.ticksInGround = 0; - ++this.ticksInAir; - Vec3d vec3d1 = new Vec3d(this.posX, this.posY, this.posZ); - Vec3d vec3d = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - RayTraceResult raytraceresult = this.worldObj.rayTraceBlocks(vec3d1, vec3d, false, true, false); - vec3d1 = new Vec3d(this.posX, this.posY, this.posZ); - vec3d = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + if(this.arrowShake > 0){ + --this.arrowShake; + } - if (raytraceresult != null) - { - vec3d = new Vec3d(raytraceresult.hitVec.xCoord, raytraceresult.hitVec.yCoord, raytraceresult.hitVec.zCoord); - } + // When the arrow is in the ground + if(this.inGround){ + ++this.ticksInGround; + this.tickInGround(); + } + // When the arrow is in the air + else{ - - Entity entity = null; - List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); - double d0 = 0.0D; - int i; - float f1; + this.tickInAir(); - for (i = 0; i < list.size(); ++i) - { - Entity entity1 = (Entity)list.get(i); + this.ticksInGround = 0; + ++this.ticksInAir; + Vec3d vec3d1 = new Vec3d(this.posX, this.posY, this.posZ); + Vec3d vec3d = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + RayTraceResult raytraceresult = this.world.rayTraceBlocks(vec3d1, vec3d, false, true, false); + vec3d1 = new Vec3d(this.posX, this.posY, this.posZ); + vec3d = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - if (entity1.canBeCollidedWith() && (entity1 != this.getShootingEntity() || this.ticksInAir >= 5)) - { - f1 = 0.3F; - AxisAlignedBB axisalignedbb1 = entity1.getEntityBoundingBox().expand((double)f1, (double)f1, (double)f1); - RayTraceResult RayTraceResult1 = axisalignedbb1.calculateIntercept(vec3d1, vec3d); + if(raytraceresult != null){ + vec3d = new Vec3d(raytraceresult.hitVec.xCoord, raytraceresult.hitVec.yCoord, + raytraceresult.hitVec.zCoord); + } - if (RayTraceResult1 != null) - { - double d1 = vec3d1.distanceTo(RayTraceResult1.hitVec); + Entity entity = null; + List list = this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox() + .addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + int i; + float f1; - if (d1 < d0 || d0 == 0.0D) - { - entity = entity1; - d0 = d1; - } - } - } - } + for(i = 0; i < list.size(); ++i){ + Entity entity1 = (Entity)list.get(i); - if (entity != null) - { - raytraceresult = new RayTraceResult(entity); - } + if(entity1.canBeCollidedWith() && (entity1 != this.getShootingEntity() || this.ticksInAir >= 5)){ + f1 = 0.3F; + AxisAlignedBB axisalignedbb1 = entity1.getEntityBoundingBox().expand((double)f1, (double)f1, + (double)f1); + RayTraceResult RayTraceResult1 = axisalignedbb1.calculateIntercept(vec3d1, vec3d); - // Players that are considered invulnerable to the caster allow the projectile to pass straight through them. - if (raytraceresult != null && raytraceresult.entityHit != null && raytraceresult.entityHit instanceof EntityPlayer) - { - EntityPlayer entityplayer = (EntityPlayer)raytraceresult.entityHit; + if(RayTraceResult1 != null){ + double d1 = vec3d1.distanceTo(RayTraceResult1.hitVec); - if (entityplayer.capabilities.disableDamage || this.getShootingEntity() instanceof EntityPlayer && !((EntityPlayer)this.getShootingEntity()).canAttackPlayer(entityplayer)) - { - raytraceresult = null; - } - } + if(d1 < d0 || d0 == 0.0D){ + entity = entity1; + d0 = d1; + } + } + } + } - // If the arrow hits something - if (raytraceresult != null) - { - // If the arrow hits an entity - if (raytraceresult.entityHit != null) - { - DamageSource damagesource = null; + if(entity != null){ + raytraceresult = new RayTraceResult(entity); + } - if (this.getShootingEntity() == null) - { - damagesource = DamageSource.causeThrownDamage(this, this); - } - else - { - damagesource = MagicDamage.causeIndirectMagicDamage(this, (EntityLivingBase)this.getShootingEntity(), this.getDamageType()).setProjectile(); - } + // Players that are considered invulnerable to the caster allow the projectile to pass straight through + // them. + if(raytraceresult != null && raytraceresult.entityHit != null + && raytraceresult.entityHit instanceof EntityPlayer){ + EntityPlayer entityplayer = (EntityPlayer)raytraceresult.entityHit; - if (raytraceresult.entityHit.attackEntityFrom(damagesource, (float)(this.getDamage()*this.damageMultiplier))) - { - if (raytraceresult.entityHit instanceof EntityLivingBase) - { - EntityLivingBase entityHit = (EntityLivingBase)raytraceresult.entityHit; - - this.onEntityHit(entityHit); + if(entityplayer.capabilities.disableDamage || this.getShootingEntity() instanceof EntityPlayer + && !((EntityPlayer)this.getShootingEntity()).canAttackPlayer(entityplayer)){ + raytraceresult = null; + } + } - if (this.knockbackStrength > 0) - { - float f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + // If the arrow hits something + if(raytraceresult != null){ + // If the arrow hits an entity + if(raytraceresult.entityHit != null){ + DamageSource damagesource = null; - if (f4 > 0.0F) - { - raytraceresult.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4); - } - } + if(this.getShootingEntity() == null){ + damagesource = DamageSource.causeThrownDamage(this, this); + }else{ + damagesource = MagicDamage.causeIndirectMagicDamage(this, + (EntityLivingBase)this.getShootingEntity(), this.getDamageType()).setProjectile(); + } - // Thorns enchantment - if (this.getShootingEntity() != null && this.getShootingEntity() instanceof EntityLivingBase) - { - EnchantmentHelper.applyThornEnchantments(entityHit, this.getShootingEntity()); - EnchantmentHelper.applyArthropodEnchantments((EntityLivingBase)this.getShootingEntity(), entityHit); - } + if(raytraceresult.entityHit.attackEntityFrom(damagesource, + (float)(this.getDamage() * this.damageMultiplier))){ + if(raytraceresult.entityHit instanceof EntityLivingBase){ + EntityLivingBase entityHit = (EntityLivingBase)raytraceresult.entityHit; - if (this.getShootingEntity() != null && raytraceresult.entityHit != this.getShootingEntity() && raytraceresult.entityHit instanceof EntityPlayer && this.getShootingEntity() instanceof EntityPlayerMP) - { - ((EntityPlayerMP)this.getShootingEntity()).connection.sendPacket(new SPacketChangeGameState(6, 0.0F)); - } - } + this.onEntityHit(entityHit); - if (!(raytraceresult.entityHit instanceof EntityEnderman) && !this.doOverpenetration()) - { - this.setDead(); - } - } - else - { - if(!this.doOverpenetration()) this.setDead(); + if(this.knockbackStrength > 0){ + float f4 = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); - // Was the 'rebound' that happened when entities were immune to damage - /* - this.motionX *= -0.10000000149011612D; - this.motionY *= -0.10000000149011612D; - this.motionZ *= -0.10000000149011612D; - this.rotationYaw += 180.0F; - this.prevRotationYaw += 180.0F; - this.ticksInAir = 0; - */ - } - } - // If the arrow hits a block - else - { - this.blockX = raytraceresult.getBlockPos().getX(); - this.blockY = raytraceresult.getBlockPos().getY(); - this.blockZ = raytraceresult.getBlockPos().getZ(); - this.stuckInBlock = this.worldObj.getBlockState(raytraceresult.getBlockPos()); - this.motionX = (double)((float)(raytraceresult.hitVec.xCoord - this.posX)); - this.motionY = (double)((float)(raytraceresult.hitVec.yCoord - this.posY)); - this.motionZ = (double)((float)(raytraceresult.hitVec.zCoord - this.posZ)); - //f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); - //this.posX -= this.motionX / (double)f2 * 0.05000000074505806D; - //this.posY -= this.motionY / (double)f2 * 0.05000000074505806D; - //this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D; - //this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); - this.inGround = true; - this.arrowShake = 7; - - this.onBlockHit(); + if(f4 > 0.0F){ + raytraceresult.entityHit.addVelocity( + this.motionX * (double)this.knockbackStrength * 0.6000000238418579D + / (double)f4, + 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D + / (double)f4); + } + } - if (this.stuckInBlock.getMaterial() != Material.AIR) - { - this.stuckInBlock.getBlock().onEntityCollidedWithBlock(this.worldObj, raytraceresult.getBlockPos(), this.stuckInBlock, this); - } - } - } + // Thorns enchantment + if(this.getShootingEntity() != null + && this.getShootingEntity() instanceof EntityLivingBase){ + EnchantmentHelper.applyThornEnchantments(entityHit, this.getShootingEntity()); + EnchantmentHelper.applyArthropodEnchantments((EntityLivingBase)this.getShootingEntity(), + entityHit); + } - this.posX += this.motionX; - this.posY += this.motionY; - this.posZ += this.motionZ; - //f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + if(this.getShootingEntity() != null && raytraceresult.entityHit != this.getShootingEntity() + && raytraceresult.entityHit instanceof EntityPlayer + && this.getShootingEntity() instanceof EntityPlayerMP){ + ((EntityPlayerMP)this.getShootingEntity()).connection + .sendPacket(new SPacketChangeGameState(6, 0.0F)); + } + } - //for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) - //{ - // ; - //} + if(!(raytraceresult.entityHit instanceof EntityEnderman) && !this.doOverpenetration()){ + this.setDead(); + } + }else{ + if(!this.doOverpenetration()) this.setDead(); - while (this.rotationPitch - this.prevRotationPitch >= 180.0F) - { - this.prevRotationPitch += 360.0F; - } + // Was the 'rebound' that happened when entities were immune to damage + /* this.motionX *= -0.10000000149011612D; this.motionY *= -0.10000000149011612D; this.motionZ *= + * -0.10000000149011612D; this.rotationYaw += 180.0F; this.prevRotationYaw += 180.0F; + * this.ticksInAir = 0; */ + } + } + // If the arrow hits a block + else{ + this.blockX = raytraceresult.getBlockPos().getX(); + this.blockY = raytraceresult.getBlockPos().getY(); + this.blockZ = raytraceresult.getBlockPos().getZ(); + this.stuckInBlock = this.world.getBlockState(raytraceresult.getBlockPos()); + this.motionX = (double)((float)(raytraceresult.hitVec.xCoord - this.posX)); + this.motionY = (double)((float)(raytraceresult.hitVec.yCoord - this.posY)); + this.motionZ = (double)((float)(raytraceresult.hitVec.zCoord - this.posZ)); + // f2 = MathHelper.sqrt(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * + // this.motionZ); + // this.posX -= this.motionX / (double)f2 * 0.05000000074505806D; + // this.posY -= this.motionY / (double)f2 * 0.05000000074505806D; + // this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D; + // this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + this.inGround = true; + this.arrowShake = 7; - while (this.rotationYaw - this.prevRotationYaw < -180.0F) - { - this.prevRotationYaw -= 360.0F; - } + this.onBlockHit(); - while (this.rotationYaw - this.prevRotationYaw >= 180.0F) - { - this.prevRotationYaw += 360.0F; - } + if(this.stuckInBlock.getMaterial() != Material.AIR){ + this.stuckInBlock.getBlock().onEntityCollidedWithBlock(this.world, raytraceresult.getBlockPos(), + this.stuckInBlock, this); + } + } + } - this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; - this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; - - float f3 = 0.99F; + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + // f2 = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - if (this.isInWater()) - { - for (int l = 0; l < 4; ++l) - { - float f4 = 0.25F; - this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ); - } + // for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f2) * 180.0D / Math.PI); + // this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) + // { + // ; + // } - f3 = 0.8F; - } + while(this.rotationPitch - this.prevRotationPitch >= 180.0F){ + this.prevRotationPitch += 360.0F; + } - if (this.isWet()) - { - this.extinguish(); - } + while(this.rotationYaw - this.prevRotationYaw < -180.0F){ + this.prevRotationYaw -= 360.0F; + } - if(this.doDeceleration()){ - this.motionX *= (double)f3; - this.motionY *= (double)f3; - this.motionZ *= (double)f3; - } - - if(this.doGravity()) this.motionY -= 0.05; - - this.setPosition(this.posX, this.posY, this.posZ); - this.doBlockCollisions(); - } - } + while(this.rotationYaw - this.prevRotationYaw >= 180.0F){ + this.prevRotationYaw += 360.0F; + } - @Override - public void writeEntityToNBT(NBTTagCompound tag) - { - tag.setShort("xTile", (short)this.blockX); - tag.setShort("yTile", (short)this.blockY); - tag.setShort("zTile", (short)this.blockZ); - tag.setShort("life", (short)this.ticksInGround); - if(this.stuckInBlock != null){ - ResourceLocation resourcelocation = (ResourceLocation)Block.REGISTRY.getNameForObject(this.stuckInBlock.getBlock()); - tag.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString()); - } - tag.setByte("inData", (byte)this.inData); - tag.setByte("shake", (byte)this.arrowShake); - tag.setByte("inGround", (byte)(this.inGround ? 1 : 0)); - tag.setFloat("damageMultiplier", this.damageMultiplier); + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + + float f3 = 0.99F; + + if(this.isInWater()){ + for(int l = 0; l < 4; ++l){ + float f4 = 0.25F; + this.world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double)f4, + this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, + this.motionY, this.motionZ); + } + + f3 = 0.8F; + } + + if(this.isWet()){ + this.extinguish(); + } + + if(this.doDeceleration()){ + this.motionX *= (double)f3; + this.motionY *= (double)f3; + this.motionZ *= (double)f3; + } + + if(this.doGravity()) this.motionY -= 0.05; + + this.setPosition(this.posX, this.posY, this.posZ); + this.doBlockCollisions(); + } + } + + @Override + public void writeEntityToNBT(NBTTagCompound tag){ + tag.setShort("xTile", (short)this.blockX); + tag.setShort("yTile", (short)this.blockY); + tag.setShort("zTile", (short)this.blockZ); + tag.setShort("life", (short)this.ticksInGround); + if(this.stuckInBlock != null){ + ResourceLocation resourcelocation = (ResourceLocation)Block.REGISTRY + .getNameForObject(this.stuckInBlock.getBlock()); + tag.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString()); + } + tag.setByte("inData", (byte)this.inData); + tag.setByte("shake", (byte)this.arrowShake); + tag.setByte("inGround", (byte)(this.inGround ? 1 : 0)); + tag.setFloat("damageMultiplier", this.damageMultiplier); if(this.getShootingEntity() != null){ - tag.setUniqueId("casterUUID", this.getShootingEntity().getUniqueID()); - } - } + tag.setUniqueId("casterUUID", this.getShootingEntity().getUniqueID()); + } + } - @Override - public void readEntityFromNBT(NBTTagCompound tag) - { - this.blockX = tag.getShort("xTile"); - this.blockY = tag.getShort("yTile"); - this.blockZ = tag.getShort("zTile"); - this.ticksInGround = tag.getShort("life"); - // Commented out for now because there's some funny stuff going on with blockstates and metadata. - //this.stuckInBlock = Block.getBlockById(tag.getByte("inTile") & 255); - this.inData = tag.getByte("inData") & 255; - this.arrowShake = tag.getByte("shake") & 255; - this.inGround = tag.getByte("inGround") == 1; - this.damageMultiplier = tag.getFloat("damageMultiplier"); + @Override + public void readEntityFromNBT(NBTTagCompound tag){ + this.blockX = tag.getShort("xTile"); + this.blockY = tag.getShort("yTile"); + this.blockZ = tag.getShort("zTile"); + this.ticksInGround = tag.getShort("life"); + // Commented out for now because there's some funny stuff going on with blockstates and metadata. + // this.stuckInBlock = Block.getBlockById(tag.getByte("inTile") & 255); + this.inData = tag.getByte("inData") & 255; + this.arrowShake = tag.getByte("shake") & 255; + this.inGround = tag.getByte("inGround") == 1; + this.damageMultiplier = tag.getFloat("damageMultiplier"); casterUUID = tag.getUniqueId("casterUUID"); - } - - /** - * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to - * prevent them from trampling crops - */ - protected boolean canTriggerWalking() - { - return false; - } - - @SideOnly(Side.CLIENT) - public float getShadowSize() - { - return 0.0F; - } - - /** - * Sets the amount of knockback the arrow applies when it hits a mob. - */ - public void setKnockbackStrength(int p_70240_1_) - { - this.knockbackStrength = p_70240_1_; - } - - /** - * If returns false, the item will not inflict any damage against entities. - */ - public boolean canAttackWithItem() - { - return false; - } - - public void writeSpawnData(ByteBuf buffer){ - if(this.getShootingEntity() != null) buffer.writeInt(this.getShootingEntity().getEntityId()); - } - - public void readSpawnData(ByteBuf buffer){ - if(buffer.isReadable()) this.shootingEntity = new WeakReference((EntityLivingBase)this.worldObj.getEntityByID(buffer.readInt())); - } + } /** - * Returns the EntityLivingBase that created this construct, or null if it no longer exists. Cases where the - * entity may no longer exist are: entity died or was deleted, mob despawned, player logged out, entity teleported - * to another dimension, or this construct simply had no caster in the first place. + * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to + * prevent them from trampling crops */ - public EntityLivingBase getShootingEntity() { + protected boolean canTriggerWalking(){ + return false; + } + + @SideOnly(Side.CLIENT) + public float getShadowSize(){ + return 0.0F; + } + + /** + * Sets the amount of knockback the arrow applies when it hits a mob. + */ + public void setKnockbackStrength(int p_70240_1_){ + this.knockbackStrength = p_70240_1_; + } + + /** + * If returns false, the item will not inflict any damage against entities. + */ + public boolean canAttackWithItem(){ + return false; + } + + public void writeSpawnData(ByteBuf buffer){ + if(this.getShootingEntity() != null) buffer.writeInt(this.getShootingEntity().getEntityId()); + } + + public void readSpawnData(ByteBuf buffer){ + if(buffer.isReadable()) this.shootingEntity = new WeakReference( + (EntityLivingBase)this.world.getEntityByID(buffer.readInt())); + } + + /** + * Returns the EntityLivingBase that created this construct, or null if it no longer exists. Cases where the entity + * may no longer exist are: entity died or was deleted, mob despawned, player logged out, entity teleported to + * another dimension, or this construct simply had no caster in the first place. + */ + public EntityLivingBase getShootingEntity(){ return shootingEntity == null ? null : shootingEntity.get(); } - - public void setShootingEntity(EntityLivingBase entity) { + + public void setShootingEntity(EntityLivingBase entity){ shootingEntity = new WeakReference(entity); } } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityMagicMissile.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityMagicMissile.java index 67c079d9..41351d98 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityMagicMissile.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityMagicMissile.java @@ -8,75 +8,82 @@ import net.minecraft.init.SoundEvents; import net.minecraft.world.World; public class EntityMagicMissile extends EntityMagicArrow { - - /** Basic shell constructor. Should only be used by the client. */ - public EntityMagicMissile(World world) { + + /** Basic shell constructor. Should only be used by the client. */ + public EntityMagicMissile(World world){ super(world); } - - /** Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this - * constructor and then call setVelocity() as that method is, bizarrely, client-side only. */ - public EntityMagicMissile(World world, double x, double y, double z) - { - super(world, x, y, z); - } - /** Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be altered - * slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on easy, 6 on - * normal and 2 on hard difficulty. */ - public EntityMagicMissile(World world, EntityLivingBase caster, Entity target, float speed, float aimingError, float damageMultiplier) - { - super(world, caster, target, speed, aimingError, damageMultiplier); - } + /** + * Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this constructor + * and then call setVelocity() as that method is, bizarrely, client-side only. + */ + public EntityMagicMissile(World world, double x, double y, double z){ + super(world, x, y, z); + } - /** Creates a projectile pointing in the direction the caster is looking, with the given speed. - * USE THIS CONSTRUCTOR FOR NORMAL SPELLS. */ - public EntityMagicMissile(World world, EntityLivingBase caster, float speed, float damageMultiplier) - { - super(world, caster, speed, damageMultiplier); - } + /** + * Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be + * altered slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on + * easy, 6 on normal and 2 on hard difficulty. + */ + public EntityMagicMissile(World world, EntityLivingBase caster, Entity target, float speed, float aimingError, + float damageMultiplier){ + super(world, caster, target, speed, aimingError, damageMultiplier); + } + + /** + * Creates a projectile pointing in the direction the caster is looking, with the given speed. USE THIS CONSTRUCTOR + * FOR NORMAL SPELLS. + */ + public EntityMagicMissile(World world, EntityLivingBase caster, float speed, float damageMultiplier){ + super(world, caster, speed, damageMultiplier); + } @Override public void onEntityHit(EntityLivingBase entityHit){ this.playSound(SoundEvents.ENTITY_GENERIC_HURT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); } - + @Override public void tickInAir(){ - if (this.ticksExisted > 20){ - this.setDead(); - } - - if(this.worldObj.isRemote){ - - if(this.ticksExisted % 2 == 1){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, this.posX, this.posY, this.posZ, 0, 0, 0, 20 + rand.nextInt(10), 0.5f + (rand.nextFloat()/2), 0.5f + (rand.nextFloat()/2), 0.5f + (rand.nextFloat()/2)); - } - else{ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, this.posX, this.posY, this.posZ, 0, 0, 0, 20 + rand.nextInt(10), 0.5f + (rand.nextFloat()/2), 0.5f + (rand.nextFloat()/2), 0.5f + (rand.nextFloat()/2)); - } - } - } - - @Override - public double getDamage(){ - return 4.0d; - } - - @Override - public boolean doGravity(){ - return false; - } - - @Override - public boolean doDeceleration(){ - return false; - } + if(this.ticksExisted > 20){ + this.setDead(); + } + + if(this.world.isRemote){ + + if(this.ticksExisted % 2 == 1){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, this.posX, this.posY, this.posZ, 0, 0, + 0, 20 + rand.nextInt(10), 0.5f + (rand.nextFloat() / 2), 0.5f + (rand.nextFloat() / 2), + 0.5f + (rand.nextFloat() / 2)); + }else{ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, this.posX, this.posY, this.posZ, 0, 0, + 0, 20 + rand.nextInt(10), 0.5f + (rand.nextFloat() / 2), 0.5f + (rand.nextFloat() / 2), + 0.5f + (rand.nextFloat() / 2)); + } + } + } @Override - protected void entityInit() { - + public double getDamage(){ + return 4.0d; } - + + @Override + public boolean doGravity(){ + return false; + } + + @Override + public boolean doDeceleration(){ + return false; + } + + @Override + protected void entityInit(){ + + } + } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityMagicProjectile.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityMagicProjectile.java index e37c45fa..2fc51736 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityMagicProjectile.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityMagicProjectile.java @@ -7,15 +7,18 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; -/** This class is a generic superclass for all non-directed projectiles, namely: darkness orb, firebolt, firebomb, - * force orb, ice charge, lightning disc, poison bomb, spark, spark bomb and thunderbolt. Directed (arrow-like) projectiles - * should instead extend {@link EntityMagicArrow}. +/** + * This class is a generic superclass for all non-directed projectiles, namely: darkness orb, firebolt, firebomb, + * force orb, ice charge, lightning disc, poison bomb, spark, spark bomb and thunderbolt. Directed (arrow-like) + * projectiles should instead extend {@link EntityMagicArrow}. *

    - * This class purely handles saving of the damage multiplier; EntityThrowable is pretty well suited to my purposes - * as it is. Range is done via the velocity when the constructor is called. Caster is already handled by EntityThrowable.getThrower(). + * This class purely handles saving of the damage multiplier; EntityThrowable is pretty well suited to my purposes as it + * is. Range is done via the velocity when the constructor is called. Caster is already handled by + * EntityThrowable.getThrower(). + * + * Note that this class does not implement {@link IEntityAdditionalSpawnData}; subclasses that need to transfer extra + * data to the client should implement that interface themselves. See {@link EntityBomb} for an example. * - * Note that this class does not implement {@link IEntityAdditionalSpawnData}; subclasses that need to transfer extra data - * to the client should implement that interface themselves. See {@link EntityBomb} for an example. * @since Wizardry 1.0 * @author Electroblob * @see EntityBomb @@ -23,51 +26,48 @@ import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; public abstract class EntityMagicProjectile extends EntityThrowable { public float damageMultiplier = 1.0f; - - public EntityMagicProjectile(World world) - { - super(world); - } - public EntityMagicProjectile(World world, EntityLivingBase thrower) - { - super(world, thrower); - } - - public EntityMagicProjectile(World world, EntityLivingBase thrower, float damageMultiplier) - { - super(world, thrower); - // This is the standard set of parameters for this method, used by snowballs and ender pearls amongst others. - this.setHeadingFromThrower(thrower, thrower.rotationPitch, thrower.rotationYaw, 0.0f, this.getSpeed(), 1.0f); - this.damageMultiplier = damageMultiplier; - } + public EntityMagicProjectile(World world){ + super(world); + } - public EntityMagicProjectile(World par1World, double par2, double par4, double par6) - { - super(par1World, par2, par4, par6); - } - - /** This got removed at some point since 1.7.10, but I liked it so I thought I'd add it back in again. */ - protected float getSpeed(){ - return 1.5f; - } - - /** Sets this projectile's velocity as a normalised vector towards the target. */ - public void directTowards(Entity target, float velocity){ + public EntityMagicProjectile(World world, EntityLivingBase thrower){ + super(world, thrower); + } - double dx = target.posX - this.posX; - double dy = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) - (this.posY + (double)(this.height / 2.0F)); - double dz = target.posZ - this.posZ; - - this.motionX = dx/this.getDistanceToEntity(target) * velocity; - this.motionY = dy/this.getDistanceToEntity(target) * velocity; - this.motionZ = dz/this.getDistanceToEntity(target) * velocity; - } - - @Override + public EntityMagicProjectile(World world, EntityLivingBase thrower, float damageMultiplier){ + super(world, thrower); + // This is the standard set of parameters for this method, used by snowballs and ender pearls amongst others. + this.setHeadingFromThrower(thrower, thrower.rotationPitch, thrower.rotationYaw, 0.0f, this.getSpeed(), 1.0f); + this.damageMultiplier = damageMultiplier; + } + + public EntityMagicProjectile(World par1World, double par2, double par4, double par6){ + super(par1World, par2, par4, par6); + } + + /** This got removed at some point since 1.7.10, but I liked it so I thought I'd add it back in again. */ + protected float getSpeed(){ + return 1.5f; + } + + /** Sets this projectile's velocity as a normalised vector towards the target. */ + public void directTowards(Entity target, float velocity){ + + double dx = target.posX - this.posX; + double dy = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) + - (this.posY + (double)(this.height / 2.0F)); + double dz = target.posZ - this.posZ; + + this.motionX = dx / this.getDistanceToEntity(target) * velocity; + this.motionY = dy / this.getDistanceToEntity(target) * velocity; + this.motionZ = dz / this.getDistanceToEntity(target) * velocity; + } + + @Override public void readEntityFromNBT(NBTTagCompound nbttagcompound){ - super.readEntityFromNBT(nbttagcompound); - damageMultiplier = nbttagcompound.getFloat("damageMultiplier"); + super.readEntityFromNBT(nbttagcompound); + damageMultiplier = nbttagcompound.getFloat("damageMultiplier"); } @Override @@ -75,5 +75,5 @@ public abstract class EntityMagicProjectile extends EntityThrowable { super.writeEntityToNBT(nbttagcompound); nbttagcompound.setFloat("damageMultiplier", damageMultiplier); } - + } diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityPoisonBomb.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityPoisonBomb.java index 717aa618..af033b37 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityPoisonBomb.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityPoisonBomb.java @@ -17,69 +17,80 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; public class EntityPoisonBomb extends EntityBomb { - - public EntityPoisonBomb(World par1World) - { - super(par1World); - } - public EntityPoisonBomb(World par1World, EntityLivingBase par2EntityLivingBase) - { - super(par1World, par2EntityLivingBase); - } - - public EntityPoisonBomb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier, float blastMultiplier) - { - super(par1World, par2EntityLivingBase, damageMultiplier, blastMultiplier); - } + public EntityPoisonBomb(World par1World){ + super(par1World); + } - public EntityPoisonBomb(World par1World, double par2, double par4, double par6) - { - super(par1World, par2, par4, par6); - } + public EntityPoisonBomb(World par1World, EntityLivingBase par2EntityLivingBase){ + super(par1World, par2EntityLivingBase); + } - @Override - protected void onImpact(RayTraceResult par1RayTraceResult) - { - Entity entityHit = par1RayTraceResult.entityHit; - - if (entityHit != null) - { - // This is if the poison bomb gets a direct hit - float damage = 5 * damageMultiplier; + public EntityPoisonBomb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier, + float blastMultiplier){ + super(par1World, par2EntityLivingBase, damageMultiplier, blastMultiplier); + } - entityHit.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.POISON).setProjectile(), damage); - - if(entityHit instanceof EntityLivingBase && !MagicDamage.isEntityImmune(DamageType.POISON, entityHit)) ((EntityLivingBase)entityHit).addPotionEffect(new PotionEffect(MobEffects.POISON, 120, 1)); - } + public EntityPoisonBomb(World par1World, double par2, double par4, double par6){ + super(par1World, par2, par4, par6); + } - // Particle effect - if(worldObj.isRemote){ - for(int i=0;i<60*blastMultiplier;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, worldObj, this.posX + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posY + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posZ + (this.rand.nextDouble()*4 - 2)*blastMultiplier, 0.0d, 0.0d, 0.0d, 35, 0.2f + rand.nextFloat()*0.3f, 0.6f, 0.0f); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, worldObj, this.posX + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posY + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posZ + (this.rand.nextDouble()*4 - 2)*blastMultiplier, 0.0d, 0.0d, 0.0d, 0, 0.2f + rand.nextFloat()*0.2f, 0.8f, 0.0f); + @Override + protected void onImpact(RayTraceResult par1RayTraceResult){ + Entity entityHit = par1RayTraceResult.entityHit; + + if(entityHit != null){ + // This is if the poison bomb gets a direct hit + float damage = 5 * damageMultiplier; + + entityHit.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.POISON).setProjectile(), + damage); + + if(entityHit instanceof EntityLivingBase && !MagicDamage.isEntityImmune(DamageType.POISON, entityHit)) + ((EntityLivingBase)entityHit).addPotionEffect(new PotionEffect(MobEffects.POISON, 120, 1)); + } + + // Particle effect + if(world.isRemote){ + for(int i = 0; i < 60 * blastMultiplier; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + this.posX + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posY + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posZ + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, 0.0d, 0.0d, 0.0d, 35, + 0.2f + rand.nextFloat() * 0.3f, 0.6f, 0.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, + this.posX + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posY + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posZ + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, 0.0d, 0.0d, 0.0d, 0, + 0.2f + rand.nextFloat() * 0.2f, 0.8f, 0.0f); } - // Spawning this after the other particles fixes the rendering colour bug. It's a bit of a cheat, but it works pretty well. - this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 0, 0, 0); - } + // Spawning this after the other particles fixes the rendering colour bug. It's a bit of a cheat, but it + // works pretty well. + this.world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 0, 0, 0); + } - if(!this.worldObj.isRemote){ - - this.playSound(SoundEvents.ENTITY_SPLASH_POTION_BREAK, 1.5F, rand.nextFloat() * 0.4F + 0.6F); - this.playSound(SoundEvents.BLOCK_FIRE_EXTINGUISH, 1.2F, 1.0f); + if(!this.world.isRemote){ + + this.playSound(SoundEvents.ENTITY_SPLASH_POTION_BREAK, 1.5F, rand.nextFloat() * 0.4F + 0.6F); + this.playSound(SoundEvents.BLOCK_FIRE_EXTINGUISH, 1.2F, 1.0f); + + double range = 3.0d * blastMultiplier; + + List targets = WizardryUtilities.getEntitiesWithinRadius(range, this.posX, this.posY, + this.posZ, this.world); - double range = 3.0d*blastMultiplier; - - List targets = WizardryUtilities.getEntitiesWithinRadius(range, this.posX, this.posY, this.posZ, this.worldObj); - for(EntityLivingBase target : targets){ - if(target != entityHit && target != this.getThrower() && !MagicDamage.isEntityImmune(DamageType.POISON, target)){ - target.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.POISON), 4.0f * damageMultiplier); - target.addPotionEffect(new PotionEffect(MobEffects.POISON, 100, 1)); + if(target != entityHit && target != this.getThrower() + && !MagicDamage.isEntityImmune(DamageType.POISON, target)){ + target.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.POISON), + 4.0f * damageMultiplier); + target.addPotionEffect(new PotionEffect(MobEffects.POISON, 100, 1)); } } - - this.setDead(); - } - } + + this.setDead(); + } + } } diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntitySmokeBomb.java b/src/main/java/electroblob/wizardry/entity/projectile/EntitySmokeBomb.java index 1ed5dea0..d2491481 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntitySmokeBomb.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntitySmokeBomb.java @@ -17,49 +17,54 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; public class EntitySmokeBomb extends EntityBomb { - - public EntitySmokeBomb(World par1World) - { - super(par1World); - } - public EntitySmokeBomb(World par1World, EntityLivingBase par2EntityLivingBase) - { - super(par1World, par2EntityLivingBase); - } - - public EntitySmokeBomb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier, float blastMultiplier) - { - super(par1World, par2EntityLivingBase, damageMultiplier, blastMultiplier); - } + public EntitySmokeBomb(World par1World){ + super(par1World); + } - public EntitySmokeBomb(World par1World, double par2, double par4, double par6) - { - super(par1World, par2, par4, par6); - } + public EntitySmokeBomb(World par1World, EntityLivingBase par2EntityLivingBase){ + super(par1World, par2EntityLivingBase); + } - @Override - protected void onImpact(RayTraceResult par1RayTraceResult){ + public EntitySmokeBomb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier, + float blastMultiplier){ + super(par1World, par2EntityLivingBase, damageMultiplier, blastMultiplier); + } - // Particle effect - if(worldObj.isRemote){ - this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 0, 0, 0); - for(int i=0;i<60*blastMultiplier;i++){ - this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posY + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posZ + (this.rand.nextDouble()*4 - 2)*blastMultiplier, 0, 0, 0); + public EntitySmokeBomb(World par1World, double par2, double par4, double par6){ + super(par1World, par2, par4, par6); + } + + @Override + protected void onImpact(RayTraceResult par1RayTraceResult){ + + // Particle effect + if(world.isRemote){ + this.world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 0, 0, 0); + for(int i = 0; i < 60 * blastMultiplier; i++){ + this.world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, + this.posX + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posY + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posZ + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, 0, 0, 0); float brightness = rand.nextFloat() * 0.3f; - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, worldObj, this.posX + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posY + (this.rand.nextDouble()*4 - 2)*blastMultiplier, this.posZ + (this.rand.nextDouble()*4 - 2)*blastMultiplier, 0.0d, 0.0d, 0.0d, 0, brightness, brightness, brightness); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, + this.posX + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posY + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, + this.posZ + (this.rand.nextDouble() * 4 - 2) * blastMultiplier, 0.0d, 0.0d, 0.0d, 0, brightness, + brightness, brightness); } - } + } - if(!this.worldObj.isRemote){ - - this.playSound(SoundEvents.ENTITY_SPLASH_POTION_BREAK, 1.5F, rand.nextFloat() * 0.4F + 0.6F); - this.playSound(SoundEvents.BLOCK_FIRE_EXTINGUISH, 1.2F, 1.0f); + if(!this.world.isRemote){ + + this.playSound(SoundEvents.ENTITY_SPLASH_POTION_BREAK, 1.5F, rand.nextFloat() * 0.4F + 0.6F); + this.playSound(SoundEvents.BLOCK_FIRE_EXTINGUISH, 1.2F, 1.0f); + + double range = 3.0d * blastMultiplier; + + List targets = WizardryUtilities.getEntitiesWithinRadius(range, this.posX, this.posY, + this.posZ, this.world); - double range = 3.0d * blastMultiplier; - - List targets = WizardryUtilities.getEntitiesWithinRadius(range, this.posX, this.posY, this.posZ, this.worldObj); - for(EntityLivingBase target : targets){ if(target != this.getThrower()){ // Gives the target blindness if it is a player, mind trick otherwise (since this has the desired @@ -69,13 +74,13 @@ public class EntitySmokeBomb extends EntityBomb { }else if(target instanceof EntityLiving){ // New AI ((EntityLiving)target).setAttackTarget(null); - + target.addPotionEffect(new PotionEffect(WizardryPotions.mind_trick, 120, 0)); } } } - - this.setDead(); - } - } + + this.setDead(); + } + } } diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntitySpark.java b/src/main/java/electroblob/wizardry/entity/projectile/EntitySpark.java index 4061b954..b6c7853b 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntitySpark.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntitySpark.java @@ -14,68 +14,66 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; public class EntitySpark extends EntityMagicProjectile { - - public EntitySpark(World par1World) - { - super(par1World); - } - public EntitySpark(World par1World, EntityLivingBase par2EntityLivingBase) - { - super(par1World, par2EntityLivingBase); - } - - public EntitySpark(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier) - { - super(par1World, par2EntityLivingBase, damageMultiplier); - } + public EntitySpark(World par1World){ + super(par1World); + } - public EntitySpark(World par1World, double par2, double par4, double par6) - { - super(par1World, par2, par4, par6); - } - - /** This is the speed */ - protected float getSpeed() - { - return 0.5F; - } + public EntitySpark(World par1World, EntityLivingBase par2EntityLivingBase){ + super(par1World, par2EntityLivingBase); + } - /** - * Called when this EntityThrowable hits a block or entity. - */ - protected void onImpact(RayTraceResult par1RayTraceResult) - { - Entity entityHit = par1RayTraceResult.entityHit; - - if (entityHit != null){ - - float damage = 6 * damageMultiplier; - entityHit.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.SHOCK), damage); - - } + public EntitySpark(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier){ + super(par1World, par2EntityLivingBase, damageMultiplier); + } - this.playSound(WizardrySounds.SPELL_SPARK, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + public EntitySpark(World par1World, double par2, double par4, double par6){ + super(par1World, par2, par4, par6); + } - // Particle effect - if(worldObj.isRemote){ - for(int i=0;i<8;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, worldObj, this.posX + rand.nextFloat() - 0.5, this.posY + this.height/2 + rand.nextFloat() - 0.5, this.posZ + rand.nextFloat() - 0.5, 0, 0, 0, 3); + /** This is the speed */ + protected float getSpeed(){ + return 0.5F; + } + + /** + * Called when this EntityThrowable hits a block or entity. + */ + protected void onImpact(RayTraceResult par1RayTraceResult){ + Entity entityHit = par1RayTraceResult.entityHit; + + if(entityHit != null){ + + float damage = 6 * damageMultiplier; + entityHit.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.SHOCK), + damage); + + } + + this.playSound(WizardrySounds.SPELL_SPARK, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + + // Particle effect + if(world.isRemote){ + for(int i = 0; i < 8; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, this.posX + rand.nextFloat() - 0.5, + this.posY + this.height / 2 + rand.nextFloat() - 0.5, this.posZ + rand.nextFloat() - 0.5, 0, 0, + 0, 3); } - } + } - this.setDead(); - } - - public void onUpdate(){ - - super.onUpdate(); - - if(!this.isCollided && !worldObj.isRemote){ - - double seekingRange = 5.0d; - - List entities = WizardryUtilities.getEntitiesWithinRadius(seekingRange, this.posX, this.posY, this.posZ, this.worldObj); + this.setDead(); + } + + public void onUpdate(){ + + super.onUpdate(); + + if(!this.isCollided && !world.isRemote){ + + double seekingRange = 5.0d; + + List entities = WizardryUtilities.getEntitiesWithinRadius(seekingRange, this.posX, + this.posY, this.posZ, this.world); Entity target = null; for(Entity possibleTarget : entities){ @@ -87,30 +85,30 @@ public class EntitySpark extends EntityMagicProjectile { } } } - - if(target != null && Math.abs(this.motionX) < 1 && Math.abs(this.motionY) < 1 && Math.abs(this.motionZ) < 1){ - this.addVelocity((target.posX - this.posX)/30, (target.posY + target.height/2 - this.posY)/30, (target.posZ - this.posZ)/30); + + if(target != null && Math.abs(this.motionX) < 1 && Math.abs(this.motionY) < 1 + && Math.abs(this.motionZ) < 1){ + this.addVelocity((target.posX - this.posX) / 30, (target.posY + target.height / 2 - this.posY) / 30, + (target.posZ - this.posZ) / 30); } - } - - if(this.ticksExisted > 100){ - this.setDead(); - } - } - - /** - * Gets the amount of gravity to apply to the thrown entity with each tick. - */ - protected float getGravityVelocity() - { - return 0.0F; - } - - /** - * Return whether this entity should be rendered as on fire. - */ - public boolean canRenderOnFire() - { - return false; - } + } + + if(this.ticksExisted > 100){ + this.setDead(); + } + } + + /** + * Gets the amount of gravity to apply to the thrown entity with each tick. + */ + protected float getGravityVelocity(){ + return 0.0F; + } + + /** + * Return whether this entity should be rendered as on fire. + */ + public boolean canRenderOnFire(){ + return false; + } } diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntitySparkBomb.java b/src/main/java/electroblob/wizardry/entity/projectile/EntitySparkBomb.java index 9ffedcdf..e854cea2 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntitySparkBomb.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntitySparkBomb.java @@ -19,96 +19,107 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; public class EntitySparkBomb extends EntityBomb { - - /** For client use, because thrower field is not visible. */ + + /** For client use, because thrower field is not visible. */ private int casterID; - - public EntitySparkBomb(World par1World) - { - super(par1World); - } - public EntitySparkBomb(World par1World, EntityLivingBase par2EntityLivingBase) - { - super(par1World, par2EntityLivingBase); - } - - public EntitySparkBomb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier, float blastMultiplier) - { - super(par1World, par2EntityLivingBase, damageMultiplier, blastMultiplier); - } + public EntitySparkBomb(World par1World){ + super(par1World); + } - public EntitySparkBomb(World par1World, double par2, double par4, double par6) - { - super(par1World, par2, par4, par6); - } + public EntitySparkBomb(World par1World, EntityLivingBase par2EntityLivingBase){ + super(par1World, par2EntityLivingBase); + } - /** - * Called when this EntityThrowable hits a block or entity. - */ - protected void onImpact(RayTraceResult par1RayTraceResult) - { - this.playSound(SoundEvents.ENTITY_FIREWORK_BLAST_FAR, 0.5f, 0.5f); + public EntitySparkBomb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier, + float blastMultiplier){ + super(par1World, par2EntityLivingBase, damageMultiplier, blastMultiplier); + } - Entity entityHit = par1RayTraceResult.entityHit; - - if (entityHit != null) - { - // This is if the spark bomb gets a direct hit - float damage = 6 * damageMultiplier; - - this.playSound(SoundEvents.ENTITY_GENERIC_HURT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + public EntitySparkBomb(World par1World, double par2, double par4, double par6){ + super(par1World, par2, par4, par6); + } - entityHit.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.SHOCK).setProjectile(), damage); - - } + /** + * Called when this EntityThrowable hits a block or entity. + */ + protected void onImpact(RayTraceResult par1RayTraceResult){ + this.playSound(SoundEvents.ENTITY_FIREWORK_BLAST_FAR, 0.5f, 0.5f); - // Particle effect - if(worldObj.isRemote){ - for(int i=0;i<8;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, worldObj, this.posX + rand.nextFloat() - 0.5, this.posY + this.height/2 + rand.nextFloat() - 0.5, this.posZ + rand.nextFloat() - 0.5, 0, 0, 0, 3); - worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX + rand.nextFloat() - 0.5, this.posY + this.height/2 + rand.nextFloat() - 0.5, this.posZ + rand.nextFloat() - 0.5, 0, 0, 0); + Entity entityHit = par1RayTraceResult.entityHit; + + if(entityHit != null){ + // This is if the spark bomb gets a direct hit + float damage = 6 * damageMultiplier; + + this.playSound(SoundEvents.ENTITY_GENERIC_HURT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + + entityHit.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.SHOCK).setProjectile(), + damage); + + } + + // Particle effect + if(world.isRemote){ + for(int i = 0; i < 8; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, this.posX + rand.nextFloat() - 0.5, + this.posY + this.height / 2 + rand.nextFloat() - 0.5, this.posZ + rand.nextFloat() - 0.5, 0, 0, + 0, 3); + world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX + rand.nextFloat() - 0.5, + this.posY + this.height / 2 + rand.nextFloat() - 0.5, this.posZ + rand.nextFloat() - 0.5, 0, 0, + 0); } - } - - double seekerRange = 5.0d * blastMultiplier; - - List targets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, this.posX, this.posY, this.posZ, this.worldObj); - - for(int i=0; i targets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, this.posX, this.posY, + this.posZ, this.world); + + for(int i = 0; i < Math.min(targets.size(), 4); i++){ + + boolean flag = targets.get(i) != entityHit && targets.get(i) != this.getThrower() + && !(targets.get(i) instanceof EntityPlayer + && ((EntityPlayer)targets.get(i)).capabilities.isCreativeMode); + // Detects (client side) if target is the thrower, to stop particles being spawned around them. - if(flag && worldObj.isRemote && targets.get(i).getEntityId() == this.casterID) flag = false; - + if(flag && world.isRemote && targets.get(i).getEntityId() == this.casterID) flag = false; + if(flag){ - + EntityLivingBase target = targets.get(i); - - if(!this.worldObj.isRemote){ - - EntityArc arc = new EntityArc(this.worldObj); - arc.setEndpointCoords(this.posX, this.posY, this.posZ, - target.posX, target.posY + target.height/2, target.posZ); - this.worldObj.spawnEntityInWorld(arc); - + + if(!this.world.isRemote){ + + EntityArc arc = new EntityArc(this.world); + arc.setEndpointCoords(this.posX, this.posY, this.posZ, target.posX, target.posY + target.height / 2, + target.posZ); + this.world.spawnEntity(arc); + target.playSound(WizardrySounds.SPELL_SPARK, 1.0F, rand.nextFloat() * 0.4F + 1.5F); - - target.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.SHOCK), 5.0f * damageMultiplier); - + + target.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.SHOCK), + 5.0f * damageMultiplier); + }else{ // Particle effect - for(int j=0;j<8;j++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, worldObj, target.posX + rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height*rand.nextFloat(), target.posZ + rand.nextFloat() - 0.5, 0, 0, 0, 3); - worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height*rand.nextFloat(), target.posZ + rand.nextFloat() - 0.5, 0, 0, 0); + for(int j = 0; j < 8; j++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + target.posX + rand.nextFloat() - 0.5, + target.getEntityBoundingBox().minY + target.height * rand.nextFloat(), + target.posZ + rand.nextFloat() - 0.5, 0, 0, 0, 3); + world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + rand.nextFloat() - 0.5, + target.getEntityBoundingBox().minY + target.height * rand.nextFloat(), + target.posZ + rand.nextFloat() - 0.5, 0, 0, 0); } } } } - this.setDead(); - } + this.setDead(); + } @Override public void writeSpawnData(ByteBuf data){ diff --git a/src/main/java/electroblob/wizardry/entity/projectile/EntityThunderbolt.java b/src/main/java/electroblob/wizardry/entity/projectile/EntityThunderbolt.java index 249dcae2..85624014 100644 --- a/src/main/java/electroblob/wizardry/entity/projectile/EntityThunderbolt.java +++ b/src/main/java/electroblob/wizardry/entity/projectile/EntityThunderbolt.java @@ -12,89 +12,87 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; public class EntityThunderbolt extends EntityMagicProjectile { - - public EntityThunderbolt(World par1World) - { - super(par1World); - } - public EntityThunderbolt(World par1World, EntityLivingBase par2EntityLivingBase) - { - super(par1World, par2EntityLivingBase); - } - - public EntityThunderbolt(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier) - { - super(par1World, par2EntityLivingBase, damageMultiplier); - } + public EntityThunderbolt(World par1World){ + super(par1World); + } - public EntityThunderbolt(World par1World, double par2, double par4, double par6) - { - super(par1World, par2, par4, par6); - } - - /** This is the speed */ - protected float getSpeed() - { - return 2.5F; - } + public EntityThunderbolt(World par1World, EntityLivingBase par2EntityLivingBase){ + super(par1World, par2EntityLivingBase); + } - /** - * Called when this EntityThrowable hits a block or entity. - */ - protected void onImpact(RayTraceResult par1RayTraceResult) - { - Entity entityHit = par1RayTraceResult.entityHit; - - if(entityHit != null){ - - float damage = 3 * damageMultiplier; - - entityHit.attackEntityFrom(MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.SHOCK).setProjectile(), damage); - - // Knockback - entityHit.addVelocity(this.motionX*0.2, this.motionY*0.2, this.motionZ*0.2); - } + public EntityThunderbolt(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier){ + super(par1World, par2EntityLivingBase, damageMultiplier); + } - this.playSound(SoundEvents.ENTITY_FIREWORK_LARGE_BLAST, 1.4F, 0.5f + this.rand.nextFloat() * 0.1F); + public EntityThunderbolt(World par1World, double par2, double par4, double par6){ + super(par1World, par2, par4, par6); + } - // Particle effect - if(worldObj.isRemote){ - worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 0, 0, 0); - } + /** This is the speed */ + protected float getSpeed(){ + return 2.5F; + } - this.setDead(); - } - - public void onUpdate(){ - - super.onUpdate(); - - if(worldObj.isRemote){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, worldObj, this.posX + rand.nextFloat()*0.2 - 0.1, this.posY + this.height/2 + rand.nextFloat()*0.2 - 0.1, this.posZ + rand.nextFloat()*0.2 - 0.1, 0, 0, 0, 3); - for(int i=0; i<4; i++){ - worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX + rand.nextFloat()*0.2 - 0.1, this.posY + this.height/2 + rand.nextFloat()*0.2 - 0.1, this.posZ + rand.nextFloat()*0.2 - 0.1, 0, 0, 0); - } - } - - if(this.ticksExisted > 8){ - this.setDead(); - } - } - - /** - * Gets the amount of gravity to apply to the thrown entity with each tick. - */ - protected float getGravityVelocity() - { - return 0.0F; - } - - /** - * Return whether this entity should be rendered as on fire. - */ - public boolean canRenderOnFire() - { - return false; - } + /** + * Called when this EntityThrowable hits a block or entity. + */ + protected void onImpact(RayTraceResult par1RayTraceResult){ + Entity entityHit = par1RayTraceResult.entityHit; + + if(entityHit != null){ + + float damage = 3 * damageMultiplier; + + entityHit.attackEntityFrom( + MagicDamage.causeIndirectMagicDamage(this, this.getThrower(), DamageType.SHOCK).setProjectile(), + damage); + + // Knockback + entityHit.addVelocity(this.motionX * 0.2, this.motionY * 0.2, this.motionZ * 0.2); + } + + this.playSound(SoundEvents.ENTITY_FIREWORK_LARGE_BLAST, 1.4F, 0.5f + this.rand.nextFloat() * 0.1F); + + // Particle effect + if(world.isRemote){ + world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 0, 0, 0); + } + + this.setDead(); + } + + public void onUpdate(){ + + super.onUpdate(); + + if(world.isRemote){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, this.posX + rand.nextFloat() * 0.2 - 0.1, + this.posY + this.height / 2 + rand.nextFloat() * 0.2 - 0.1, + this.posZ + rand.nextFloat() * 0.2 - 0.1, 0, 0, 0, 3); + for(int i = 0; i < 4; i++){ + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX + rand.nextFloat() * 0.2 - 0.1, + this.posY + this.height / 2 + rand.nextFloat() * 0.2 - 0.1, + this.posZ + rand.nextFloat() * 0.2 - 0.1, 0, 0, 0); + } + } + + if(this.ticksExisted > 8){ + this.setDead(); + } + } + + /** + * Gets the amount of gravity to apply to the thrown entity with each tick. + */ + protected float getGravityVelocity(){ + return 0.0F; + } + + /** + * Return whether this entity should be rendered as on fire. + */ + public boolean canRenderOnFire(){ + return false; + } } diff --git a/src/main/java/electroblob/wizardry/event/DiscoverSpellEvent.java b/src/main/java/electroblob/wizardry/event/DiscoverSpellEvent.java index 066ae73d..8e22c499 100644 --- a/src/main/java/electroblob/wizardry/event/DiscoverSpellEvent.java +++ b/src/main/java/electroblob/wizardry/event/DiscoverSpellEvent.java @@ -23,27 +23,31 @@ public class DiscoverSpellEvent extends PlayerEvent { private final Spell spell; private final Source source; - public DiscoverSpellEvent(EntityPlayer player, Spell spell, Source source) { + public DiscoverSpellEvent(EntityPlayer player, Spell spell, Source source){ super(player); this.spell = spell; this.source = source; } - + /** Returns the spell that is being discovered. */ public Spell getSpell(){ return spell; } - + /** Returns the method used to discover the spell. */ public Source getSource(){ return source; } - + public enum Source { - /** Signifies that the spell was discovered by trying to cast it. */ CASTING, - /** Signifies that the spell was discovered using a scroll of identification. */ IDENTIFICATION_SCROLL, - /** Signifies that the spell was discovered using commands. */ COMMAND, - /** Signifies that the spell was discovered by some other means. */ OTHER + /** Signifies that the spell was discovered by trying to cast it. */ + CASTING, + /** Signifies that the spell was discovered using a scroll of identification. */ + IDENTIFICATION_SCROLL, + /** Signifies that the spell was discovered using commands. */ + COMMAND, + /** Signifies that the spell was discovered by some other means. */ + OTHER } } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/event/SpellBindEvent.java b/src/main/java/electroblob/wizardry/event/SpellBindEvent.java index dd6cf322..2e2de430 100644 --- a/src/main/java/electroblob/wizardry/event/SpellBindEvent.java +++ b/src/main/java/electroblob/wizardry/event/SpellBindEvent.java @@ -5,11 +5,10 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerContainerEvent; import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event.HasResult; /** - * SpellBindEvent is fired when a player presses the apply button in the arcane workbench. Note that this - * event is only fired on the server side.
    + * SpellBindEvent is fired when a player presses the apply button in the arcane workbench. Note that this event is + * only fired on the server side.
    *
    * This event is {@link Cancelable}. If this event is canceled, no further processing takes place: spells are not bound, * upgrades are not applied and crystals are not consumed.
    @@ -24,7 +23,7 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult; @Cancelable public class SpellBindEvent extends PlayerContainerEvent { - public SpellBindEvent(EntityPlayer player, ContainerArcaneWorkbench container) { + public SpellBindEvent(EntityPlayer player, ContainerArcaneWorkbench container){ super(player, container); } diff --git a/src/main/java/electroblob/wizardry/event/SpellCastEvent.java b/src/main/java/electroblob/wizardry/event/SpellCastEvent.java index c1072eda..3cd0a88e 100644 --- a/src/main/java/electroblob/wizardry/event/SpellCastEvent.java +++ b/src/main/java/electroblob/wizardry/event/SpellCastEvent.java @@ -9,8 +9,8 @@ import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.fml.common.eventhandler.Cancelable; /** - * SpellCastEvent is the parent event class for all spell casting events. Methods which subscribe to this event - * will receive all three child events (it is recommended that you use {@link SpellCastEvent.Pre}, + * SpellCastEvent is the parent event class for all spell casting events. Methods which subscribe to this event will + * receive all three child events (it is recommended that you use {@link SpellCastEvent.Pre}, * {@link SpellCastEvent.Post} or {@link SpellCastEvent.Tick}, depending on the application).
    *
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}. @@ -19,39 +19,44 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable; * @since Wizardry 2.1 */ public abstract class SpellCastEvent extends LivingEvent { - + private final Spell spell; private final SpellModifiers modifiers; private final Source source; - public SpellCastEvent(EntityLivingBase caster, Spell spell, SpellModifiers modifiers, Source source) { + public SpellCastEvent(EntityLivingBase caster, Spell spell, SpellModifiers modifiers, Source source){ super(caster); this.spell = spell; this.modifiers = modifiers; this.source = source; } - + /** Returns the spell being cast. */ public Spell getSpell(){ return spell; } - + /** Returns the modifiers for the spell being cast. */ public SpellModifiers getModifiers(){ return modifiers; } - + /** Returns the source of the spell being cast. */ public Source getSource(){ return source; } - + public enum Source { - /** Signifies that the spell was cast using a wand. */ WAND, - /** Signifies that the spell was cast using a scroll. */ SCROLL, - /** Signifies that the spell was cast using commands. */ COMMAND, - /** Signifies that the spell was cast by an {@link ISpellCaster}. */ NPC, - /** Signifies that the spell was cast by some other means. */ OTHER + /** Signifies that the spell was cast using a wand. */ + WAND, + /** Signifies that the spell was cast using a scroll. */ + SCROLL, + /** Signifies that the spell was cast using commands. */ + COMMAND, + /** Signifies that the spell was cast by an {@link ISpellCaster}. */ + NPC, + /** Signifies that the spell was cast by some other means. */ + OTHER } /** @@ -75,18 +80,18 @@ public abstract class SpellCastEvent extends LivingEvent { @Cancelable public static class Pre extends SpellCastEvent { - public Pre(EntityLivingBase caster, Spell spell, SpellModifiers modifiers, Source source) { + public Pre(EntityLivingBase caster, Spell spell, SpellModifiers modifiers, Source source){ super(caster, spell, modifiers, source); } } - + /** - * SpellCastEvent.Post is fired just after a spell is cast. Use this event for any processing which depends - * on whether the spell succeeds, and does not affect the spell itself. For example, wizardry uses this event - * to keep track of spellcasting stats. Note that although this event is fired from both sides, it is not fired from - * common code; rather, both sides fire it separately, so timing is not guaranteed. Also note that this event is - * only fired once for continuous spells, after the first casting tick.
    + * SpellCastEvent.Post is fired just after a spell is cast. Use this event for any processing which depends on + * whether the spell succeeds, and does not affect the spell itself. For example, wizardry uses this event to keep + * track of spellcasting stats. Note that although this event is fired from both sides, it is not fired from common + * code; rather, both sides fire it separately, so timing is not guaranteed. Also note that this event is only fired + * once for continuous spells, after the first casting tick.
    *
    * This event is not {@link Cancelable}.
    *
    @@ -99,12 +104,12 @@ public abstract class SpellCastEvent extends LivingEvent { */ public static class Post extends SpellCastEvent { - public Post(EntityLivingBase caster, Spell spell, SpellModifiers modifiers, Source source) { + public Post(EntityLivingBase caster, Spell spell, SpellModifiers modifiers, Source source){ super(caster, spell, modifiers, source); } } - + /** * SpellCastEvent.Tick is fired each tick while a continuous spell is being cast.
    *
    @@ -123,17 +128,17 @@ public abstract class SpellCastEvent extends LivingEvent { public static class Tick extends SpellCastEvent { private final int count; - - public Tick(EntityLivingBase caster, Spell spell, SpellModifiers modifiers, Source source, int count) { + + public Tick(EntityLivingBase caster, Spell spell, SpellModifiers modifiers, Source source, int count){ super(caster, spell, modifiers, source); this.count = count; } - + /** Returns the number of ticks this (continuous) spell has already been cast for. */ public int getCount(){ return count; } } - + } diff --git a/src/main/java/electroblob/wizardry/item/IConjuredItem.java b/src/main/java/electroblob/wizardry/item/IConjuredItem.java index ee8a0845..c4393d99 100644 --- a/src/main/java/electroblob/wizardry/item/IConjuredItem.java +++ b/src/main/java/electroblob/wizardry/item/IConjuredItem.java @@ -9,11 +9,13 @@ import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -/** Allows wizardry to identify items that are conjured (and therefore need destroying if they leave the inventory) - * without explicitly referencing each, thereby allowing for better expandibility. */ +/** + * Allows wizardry to identify items that are conjured (and therefore need destroying if they leave the inventory) + * without explicitly referencing each, thereby allowing for better expandibility. + */ @Mod.EventBusSubscriber public interface IConjuredItem { - + /** The NBT tag key used to store the duration multiplier for conjured items. */ public static final String DURATION_MULTIPLIER_KEY = "durationMultiplier"; @@ -22,20 +24,24 @@ public interface IConjuredItem { if(!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound()); stack.getTagCompound().setFloat(DURATION_MULTIPLIER_KEY, multiplier); } - - /** Helper method for returning the max damage of a conjured item based on its NBT data. Centralises the code. - * Implementors will almost certainly want to call this from {@link Item#getMaxDamage(ItemStack stack)}. */ + + /** + * Helper method for returning the max damage of a conjured item based on its NBT data. Centralises the code. + * Implementors will almost certainly want to call this from {@link Item#getMaxDamage(ItemStack stack)}. + */ public default int getMaxDamageFromNBT(ItemStack stack){ if(stack.hasTagCompound() && stack.getTagCompound().hasKey(DURATION_MULTIPLIER_KEY)){ return (int)(this.getBaseDuration() * stack.getTagCompound().getFloat(DURATION_MULTIPLIER_KEY)); } return this.getBaseDuration(); } - - /** Returns the base duration in ticks for this conjured item. Should be a constant (commonly 600). - * Implementors may want to call this when setting an item's max damage in its constructor. */ + + /** + * Returns the base duration in ticks for this conjured item. Should be a constant (commonly 600). Implementors may + * want to call this when setting an item's max damage in its constructor. + */ public int getBaseDuration(); - + @SubscribeEvent public static void onLivingDropsEvent(LivingDropsEvent event){ // Destroys conjured items if their caster dies. @@ -45,7 +51,7 @@ public interface IConjuredItem { } } } - + @SubscribeEvent public static void onItemTossEvent(ItemTossEvent event){ // Prevents conjured items being thrown by dragging and dropping outside the inventory. diff --git a/src/main/java/electroblob/wizardry/item/ItemArcaneTome.java b/src/main/java/electroblob/wizardry/item/ItemArcaneTome.java index dd7688d7..b7a7e57f 100644 --- a/src/main/java/electroblob/wizardry/item/ItemArcaneTome.java +++ b/src/main/java/electroblob/wizardry/item/ItemArcaneTome.java @@ -9,51 +9,56 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemArcaneTome extends Item { - - public ItemArcaneTome() { + + public ItemArcaneTome(){ super(); this.setHasSubtypes(true); this.setMaxStackSize(1); this.setCreativeTab(WizardryTabs.WIZARDRY); } - + @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs tab, List list){ - for(int i=1; i list){ + for(int i = 1; i < Tier.values().length; i++){ + list.add(new ItemStack(item, 1, i)); + } } - + @Override @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack stack){ return true; } - - @Override - public EnumRarity getRarity(ItemStack stack) - { - switch(this.getDamage(stack)){ - case 1: return EnumRarity.UNCOMMON; - case 2: return EnumRarity.RARE; - case 3: return EnumRarity.EPIC; - } - return EnumRarity.COMMON; - } - @SideOnly(Side.CLIENT) + @Override + public EnumRarity getRarity(ItemStack stack){ + switch(this.getDamage(stack)){ + case 1: + return EnumRarity.UNCOMMON; + case 2: + return EnumRarity.RARE; + case 3: + return EnumRarity.EPIC; + } + return EnumRarity.COMMON; + } + + @SideOnly(Side.CLIENT) @Override public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean showAdvanced){ Tier tier = Tier.values()[stack.getItemDamage()]; - Tier tier2 = Tier.values()[stack.getItemDamage()-1]; + Tier tier2 = Tier.values()[stack.getItemDamage() - 1]; tooltip.add(tier.getDisplayNameWithFormatting()); - tooltip.add("\u00A77" + net.minecraft.client.resources.I18n.format("item.wizardry:arcane_tome.desc1", tier2.getDisplayNameWithFormatting())); - tooltip.add("\u00A77" + net.minecraft.client.resources.I18n.format("item.wizardry:arcane_tome.desc2", tier.getDisplayNameWithFormatting() + "\u00A77")); + tooltip.add("\u00A77" + net.minecraft.client.resources.I18n.format("item.wizardry:arcane_tome.desc1", + tier2.getDisplayNameWithFormatting())); + tooltip.add("\u00A77" + net.minecraft.client.resources.I18n.format("item.wizardry:arcane_tome.desc2", + tier.getDisplayNameWithFormatting() + "\u00A77")); } } diff --git a/src/main/java/electroblob/wizardry/item/ItemArmourUpgrade.java b/src/main/java/electroblob/wizardry/item/ItemArmourUpgrade.java index b7b96f10..f3c5ebcf 100644 --- a/src/main/java/electroblob/wizardry/item/ItemArmourUpgrade.java +++ b/src/main/java/electroblob/wizardry/item/ItemArmourUpgrade.java @@ -8,39 +8,41 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemArmourUpgrade extends Item { - - public ItemArmourUpgrade() { + + public ItemArmourUpgrade(){ super(); this.setMaxStackSize(1); this.setCreativeTab(WizardryTabs.WIZARDRY); } - + @Override public EnumRarity getRarity(ItemStack stack){ - return EnumRarity.EPIC; - } - + return EnumRarity.EPIC; + } + @Override @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack stack){ return true; } - + @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced){ tooltip.add(net.minecraft.client.resources.I18n.format("item.wizardry:armour_upgrade.desc1", "\u00A77")); - tooltip.add(net.minecraft.client.resources.I18n.format("item.wizardry:armour_upgrade.desc2", "\u00A77", "\u00A7d")); + tooltip.add( + net.minecraft.client.resources.I18n.format("item.wizardry:armour_upgrade.desc2", "\u00A77", "\u00A7d")); } - + @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs tab, List subItems){ + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tab, NonNullList subItems){ subItems.add(new ItemStack(this, 1)); - } + } } diff --git a/src/main/java/electroblob/wizardry/item/ItemFirebomb.java b/src/main/java/electroblob/wizardry/item/ItemFirebomb.java index add289ef..f9b1bf6d 100644 --- a/src/main/java/electroblob/wizardry/item/ItemFirebomb.java +++ b/src/main/java/electroblob/wizardry/item/ItemFirebomb.java @@ -1,7 +1,5 @@ package electroblob.wizardry.item; -import java.util.List; - import electroblob.wizardry.entity.projectile.EntityFirebomb; import electroblob.wizardry.registry.WizardryTabs; import net.minecraft.creativetab.CreativeTabs; @@ -12,39 +10,42 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemFirebomb extends Item { - public ItemFirebomb(){ - this.maxStackSize = 16; - this.setCreativeTab(WizardryTabs.WIZARDRY); - } + public ItemFirebomb(){ + this.maxStackSize = 16; + this.setCreativeTab(WizardryTabs.WIZARDRY); + } - @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand){ - - if(!player.capabilities.isCreativeMode){ - --stack.stackSize; - } + @Override + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ - player.playSound(SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + ItemStack stack = player.getHeldItem(hand); - if(!world.isRemote){ - EntityFirebomb firebomb = new EntityFirebomb(world, player); - // This is the standard set of parameters for this method, used by snowballs and ender pearls. - firebomb.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0f, 1.5f, 1.0f); - world.spawnEntityInWorld(firebomb); - } + if(!player.capabilities.isCreativeMode){ + stack.shrink(1); + } - return ActionResult.newResult(EnumActionResult.SUCCESS, stack); - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item parItem, CreativeTabs parTab, List parListSubItems){ - parListSubItems.add(new ItemStack(this, 1)); - } + player.playSound(SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + + if(!world.isRemote){ + EntityFirebomb firebomb = new EntityFirebomb(world, player); + // This is the standard set of parameters for this method, used by snowballs and ender pearls. + firebomb.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0f, 1.5f, 1.0f); + world.spawnEntity(firebomb); + } + + return ActionResult.newResult(EnumActionResult.SUCCESS, stack); + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item parItem, CreativeTabs parTab, NonNullList parListSubItems){ + parListSubItems.add(new ItemStack(this, 1)); + } } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/item/ItemFlamingAxe.java b/src/main/java/electroblob/wizardry/item/ItemFlamingAxe.java index 28e1400b..a65c2a8a 100644 --- a/src/main/java/electroblob/wizardry/item/ItemFlamingAxe.java +++ b/src/main/java/electroblob/wizardry/item/ItemFlamingAxe.java @@ -1,7 +1,5 @@ package electroblob.wizardry.item; -import java.util.List; - import electroblob.wizardry.util.MagicDamage; import electroblob.wizardry.util.MagicDamage.DamageType; import net.minecraft.creativetab.CreativeTabs; @@ -11,13 +9,14 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemAxe; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemFlamingAxe extends ItemAxe implements IConjuredItem { - public ItemFlamingAxe(ToolMaterial material) { + public ItemFlamingAxe(ToolMaterial material){ super(material, 8, -3); this.setMaxDamage(getBaseDuration()); this.setNoRepair(); @@ -28,65 +27,65 @@ public class ItemFlamingAxe extends ItemAxe implements IConjuredItem { public int getBaseDuration(){ return 600; } - + @Override public int getMaxDamage(ItemStack stack){ - return this.getMaxDamageFromNBT(stack); - } - + return this.getMaxDamageFromNBT(stack); + } + @Override // This method allows the code for the item's timer to be greatly simplified by damaging it directly from // onUpdate() and removing the workaround that involved WizardData and all sorts of crazy stuff. public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged){ - - if(oldStack != null || newStack != null){ + + if(!oldStack.isEmpty() || !newStack.isEmpty()){ // We only care about the situation where we specifically want the animation NOT to play. if(oldStack.getItem() == newStack.getItem() && !slotChanged) return false; } - + return super.shouldCauseReequipAnimation(oldStack, newStack, slotChanged); } - + @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean selected){ int damage = stack.getItemDamage(); if(damage > stack.getMaxDamage()) entity.replaceItemInInventory(slot, null); stack.setItemDamage(damage + 1); } - + @Override public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase wielder){ - if(!MagicDamage.isEntityImmune(DamageType.FIRE, target)) target.setFire(8); - return false; - } - + if(!MagicDamage.isEntityImmune(DamageType.FIRE, target)) target.setFire(8); + return false; + } + @Override @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack stack){ return true; } - + @Override public boolean getIsRepairable(ItemStack stack, ItemStack par2ItemStack){ - return false; - } - + return false; + } + @Override public int getItemEnchantability(){ - return 0; - } - + return 0; + } + // Cannot be dropped @Override public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player){ - return false; - } - + return false; + } + @Override - @SideOnly(Side.CLIENT) + @SideOnly(Side.CLIENT) // Why does this method pass in an item as an argument? It is always the same item the method is invoked on. - public void getSubItems(Item item, CreativeTabs tab, List items){ - items.add(new ItemStack(this, 1)); - } + public void getSubItems(Item item, CreativeTabs tab, NonNullList items){ + items.add(new ItemStack(this, 1)); + } } diff --git a/src/main/java/electroblob/wizardry/item/ItemFrostAxe.java b/src/main/java/electroblob/wizardry/item/ItemFrostAxe.java index 0e6100e1..a29e3247 100644 --- a/src/main/java/electroblob/wizardry/item/ItemFrostAxe.java +++ b/src/main/java/electroblob/wizardry/item/ItemFrostAxe.java @@ -1,7 +1,5 @@ package electroblob.wizardry.item; -import java.util.List; - import electroblob.wizardry.registry.WizardryPotions; import electroblob.wizardry.util.MagicDamage; import electroblob.wizardry.util.MagicDamage.DamageType; @@ -13,82 +11,83 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemAxe; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemFrostAxe extends ItemAxe implements IConjuredItem { - public ItemFrostAxe(ToolMaterial material) { + public ItemFrostAxe(ToolMaterial material){ super(material, 8, -3); this.setMaxDamage(getBaseDuration()); this.setNoRepair(); this.setCreativeTab(null); } - + @Override public int getBaseDuration(){ return 600; } - + @Override public int getMaxDamage(ItemStack stack){ - return this.getMaxDamageFromNBT(stack); - } - + return this.getMaxDamageFromNBT(stack); + } + @Override // This method allows the code for the item's timer to be greatly simplified by damaging it directly from // onUpdate() and removing the workaround that involved WizardData and all sorts of crazy stuff. public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged){ - - if(oldStack != null || newStack != null){ + + if(!oldStack.isEmpty() || !newStack.isEmpty()){ // We only care about the situation where we specifically want the animation NOT to play. if(oldStack.getItem() == newStack.getItem() && !slotChanged) return false; } - + return super.shouldCauseReequipAnimation(oldStack, newStack, slotChanged); } - + @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean selected){ int damage = stack.getItemDamage(); if(damage > stack.getMaxDamage()) entity.replaceItemInInventory(slot, null); stack.setItemDamage(damage + 1); } - + @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase wielder) - { - if(!MagicDamage.isEntityImmune(DamageType.FROST, target)) target.addPotionEffect(new PotionEffect(WizardryPotions.frost, 160, 1)); - return false; - } - + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase wielder){ + if(!MagicDamage.isEntityImmune(DamageType.FROST, target)) + target.addPotionEffect(new PotionEffect(WizardryPotions.frost, 160, 1)); + return false; + } + @Override @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack stack){ return true; } - + @Override public boolean getIsRepairable(ItemStack stack, ItemStack par2ItemStack){ - return false; - } - + return false; + } + @Override public int getItemEnchantability(){ - return 0; - } - + return 0; + } + // Cannot be dropped @Override public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player){ - return false; - } - + return false; + } + @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item parItem, CreativeTabs parTab, List parListSubItems){ - parListSubItems.add(new ItemStack(this, 1)); - } + @SideOnly(Side.CLIENT) + public void getSubItems(Item parItem, CreativeTabs parTab, NonNullList parListSubItems){ + parListSubItems.add(new ItemStack(this, 1)); + } } diff --git a/src/main/java/electroblob/wizardry/item/ItemIdentificationScroll.java b/src/main/java/electroblob/wizardry/item/ItemIdentificationScroll.java index 265bf225..0706f559 100644 --- a/src/main/java/electroblob/wizardry/item/ItemIdentificationScroll.java +++ b/src/main/java/electroblob/wizardry/item/ItemIdentificationScroll.java @@ -16,6 +16,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; @@ -24,7 +25,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class ItemIdentificationScroll extends Item { - public ItemIdentificationScroll() { + public ItemIdentificationScroll(){ super(); this.setCreativeTab(WizardryTabs.WIZARDRY); } @@ -43,7 +44,9 @@ public class ItemIdentificationScroll extends Item { } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand){ + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ + + ItemStack stack = player.getHeldItem(hand); if(WizardData.get(player) != null){ @@ -56,14 +59,16 @@ public class ItemIdentificationScroll extends Item { if((stack1.getItem() instanceof ItemSpellBook || stack1.getItem() instanceof ItemScroll) && !properties.hasSpellBeenDiscovered(spell)){ - if(!MinecraftForge.EVENT_BUS.post(new DiscoverSpellEvent(player, spell, DiscoverSpellEvent.Source.IDENTIFICATION_SCROLL))){ + if(!MinecraftForge.EVENT_BUS.post(new DiscoverSpellEvent(player, spell, + DiscoverSpellEvent.Source.IDENTIFICATION_SCROLL))){ // Identification scrolls give the chat readout in creative mode, otherwise it looks like // nothing happens! properties.discoverSpell(spell); player.addStat(WizardryAchievements.identify_spell); player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 1.25f, 1); - if(!player.capabilities.isCreativeMode) stack.stackSize--; - if(!world.isRemote) player.addChatMessage(new TextComponentTranslation("spell.discover", spell.getNameForTranslationFormatted())); + if(!player.capabilities.isCreativeMode) stack.shrink(1); + if(!world.isRemote) player.sendMessage(new TextComponentTranslation("spell.discover", + spell.getNameForTranslationFormatted())); return new ActionResult(EnumActionResult.SUCCESS, stack); } @@ -71,7 +76,8 @@ public class ItemIdentificationScroll extends Item { } } // If it found nothing to identify, it says so! - if(!world.isRemote) player.addChatMessage(new TextComponentTranslation("item.wizardry:identification_scroll.nothing_to_identify")); + if(!world.isRemote) player.sendMessage( + new TextComponentTranslation("item.wizardry:identification_scroll.nothing_to_identify")); } return new ActionResult(EnumActionResult.FAIL, stack); @@ -79,7 +85,7 @@ public class ItemIdentificationScroll extends Item { @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item parItem, CreativeTabs parTab, List parListSubItems){ + public void getSubItems(Item parItem, CreativeTabs parTab, NonNullList parListSubItems){ parListSubItems.add(new ItemStack(this, 1)); } } diff --git a/src/main/java/electroblob/wizardry/item/ItemPoisonBomb.java b/src/main/java/electroblob/wizardry/item/ItemPoisonBomb.java index 94261841..50bcdc43 100644 --- a/src/main/java/electroblob/wizardry/item/ItemPoisonBomb.java +++ b/src/main/java/electroblob/wizardry/item/ItemPoisonBomb.java @@ -1,7 +1,5 @@ package electroblob.wizardry.item; -import java.util.List; - import electroblob.wizardry.entity.projectile.EntityPoisonBomb; import electroblob.wizardry.registry.WizardryTabs; import net.minecraft.creativetab.CreativeTabs; @@ -12,40 +10,43 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemPoisonBomb extends Item { - public ItemPoisonBomb(){ - this.maxStackSize = 16; - this.setCreativeTab(WizardryTabs.WIZARDRY); - } + public ItemPoisonBomb(){ + this.maxStackSize = 16; + this.setCreativeTab(WizardryTabs.WIZARDRY); + } - @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand){ - - if(!player.capabilities.isCreativeMode){ - --stack.stackSize; - } + @Override + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ - player.playSound(SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + ItemStack stack = player.getHeldItem(hand); - if(!world.isRemote){ - EntityPoisonBomb poisonbomb = new EntityPoisonBomb(world, player); - // This is the standard set of parameters for this method, used by snowballs and ender pearls. - poisonbomb.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0f, 1.5f, 1.0f); - world.spawnEntityInWorld(poisonbomb); - } + if(!player.capabilities.isCreativeMode){ + stack.shrink(1); + } + + player.playSound(SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + + if(!world.isRemote){ + EntityPoisonBomb poisonbomb = new EntityPoisonBomb(world, player); + // This is the standard set of parameters for this method, used by snowballs and ender pearls. + poisonbomb.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0f, 1.5f, 1.0f); + world.spawnEntity(poisonbomb); + } + + return ActionResult.newResult(EnumActionResult.SUCCESS, stack); + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tab, NonNullList subItems){ + subItems.add(new ItemStack(this, 1)); + } - return ActionResult.newResult(EnumActionResult.SUCCESS, stack); - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs tab, List subItems){ - subItems.add(new ItemStack(this, 1)); - } - } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/item/ItemScroll.java b/src/main/java/electroblob/wizardry/item/ItemScroll.java index b77a95f6..1adaca3a 100644 --- a/src/main/java/electroblob/wizardry/item/ItemScroll.java +++ b/src/main/java/electroblob/wizardry/item/ItemScroll.java @@ -1,7 +1,5 @@ package electroblob.wizardry.item; -import java.util.List; - import electroblob.wizardry.Wizardry; import electroblob.wizardry.event.SpellCastEvent; import electroblob.wizardry.event.SpellCastEvent.Source; @@ -17,6 +15,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; @@ -34,7 +33,7 @@ public class ItemScroll extends Item { @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List list){ + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, NonNullList list){ for(Spell spell : Spell.getSpells(Spell.nonContinuousSpells)){ list.add(new ItemStack(item, 1, spell.id())); } @@ -50,39 +49,40 @@ public class ItemScroll extends Item { // Item's version of this method is, quite frankly, an abomination. Why is a deprecated method being used as such // an integral part of the code? And what's the point in getUnlocalisedNameInefficiently? public String getItemStackDisplayName(ItemStack stack){ - + /* Ok, so this method can be called from either the client or the server side. Obviously, on the client the * spell name is either translated or obfuscated, then it is put into the item name as part of that translation. * On the server side, however, there's a problem: on the one hand, the spell name shouldn't be obfuscated in - * case the server wants to do something with it, and in that case returning world-specific gobbledegook is - * not particularly helpful. On the other hand, something might happen that causes this method to be called on - * the server side, but the result to then be sent to the client, which means broken discovery system. - * Simply put, I can't predict that, and it's not my job to cater for other people's incorrect usage of code, - * especially when that might compromise some perfectly reasonable use (think Bibliocraft's 'best guess' book - * detection). */ + * case the server wants to do something with it, and in that case returning world-specific gobbledegook is not + * particularly helpful. On the other hand, something might happen that causes this method to be called on the + * server side, but the result to then be sent to the client, which means broken discovery system. Simply put, I + * can't predict that, and it's not my job to cater for other people's incorrect usage of code, especially when + * that might compromise some perfectly reasonable use (think Bibliocraft's 'best guess' book detection). */ // TODO: Backport this proxy-based fix. return Wizardry.proxy.getScrollDisplayName(stack); } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand){ + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ + + ItemStack stack = player.getHeldItem(hand); Spell spell = Spell.get(stack.getItemDamage()); // By default, scrolls have no modifiers - but with the event system, they could be added. SpellModifiers modifiers = new SpellModifiers(); - + // If anything stops the spell working at this point, nothing else happens. if(MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Pre(player, spell, modifiers, Source.SCROLL))){ return new ActionResult(EnumActionResult.FAIL, stack); } - + if(!spell.isContinuous){ if(!world.isRemote){ - + if(spell.cast(world, player, hand, 0, new SpellModifiers())){ - + MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Post(player, spell, modifiers, Source.SCROLL)); if(spell.doesSpellRequirePacket()){ @@ -92,12 +92,12 @@ public class ItemScroll extends Item { } // Scrolls are consumed upon successful use in survival mode - if(!player.capabilities.isCreativeMode) stack.stackSize--; + if(!player.capabilities.isCreativeMode) stack.shrink(1); return new ActionResult(EnumActionResult.SUCCESS, stack); } - // This else if check was bugging me for AGES! I can't believe I didn't compare to ItemWand before. + // This else if check was bugging me for AGES! I can't believe I didn't compare to ItemWand before. }else if(!spell.doesSpellRequirePacket()){ // Client-inconsistent spell casting. This code only runs client-side. if(spell.cast(world, player, hand, 0, modifiers)){ diff --git a/src/main/java/electroblob/wizardry/item/ItemSmokeBomb.java b/src/main/java/electroblob/wizardry/item/ItemSmokeBomb.java index a2180d97..cf7adbf4 100644 --- a/src/main/java/electroblob/wizardry/item/ItemSmokeBomb.java +++ b/src/main/java/electroblob/wizardry/item/ItemSmokeBomb.java @@ -1,7 +1,5 @@ package electroblob.wizardry.item; -import java.util.List; - import electroblob.wizardry.entity.projectile.EntitySmokeBomb; import electroblob.wizardry.registry.WizardryTabs; import net.minecraft.creativetab.CreativeTabs; @@ -12,39 +10,42 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemSmokeBomb extends Item { - public ItemSmokeBomb(){ - this.maxStackSize = 16; - this.setCreativeTab(WizardryTabs.WIZARDRY); - } + public ItemSmokeBomb(){ + this.maxStackSize = 16; + this.setCreativeTab(WizardryTabs.WIZARDRY); + } - @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand){ - - if(!player.capabilities.isCreativeMode){ - --stack.stackSize; - } + @Override + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ - player.playSound(SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + ItemStack stack = player.getHeldItem(hand); - if(!world.isRemote){ - EntitySmokeBomb smokebomb = new EntitySmokeBomb(world, player); - // This is the standard set of parameters for this method, used by snowballs and ender pearls. - smokebomb.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0f, 1.5f, 1.0f); - world.spawnEntityInWorld(smokebomb); - } + if(!player.capabilities.isCreativeMode){ + stack.shrink(1); + } - return ActionResult.newResult(EnumActionResult.SUCCESS, stack); - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs tab, List subItems){ - subItems.add(new ItemStack(this, 1)); - } + player.playSound(SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + + if(!world.isRemote){ + EntitySmokeBomb smokebomb = new EntitySmokeBomb(world, player); + // This is the standard set of parameters for this method, used by snowballs and ender pearls. + smokebomb.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0f, 1.5f, 1.0f); + world.spawnEntity(smokebomb); + } + + return ActionResult.newResult(EnumActionResult.SUCCESS, stack); + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tab, NonNullList subItems){ + subItems.add(new ItemStack(this, 1)); + } } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/item/ItemSpectralArmour.java b/src/main/java/electroblob/wizardry/item/ItemSpectralArmour.java index 951b69d9..54a2e9c5 100644 --- a/src/main/java/electroblob/wizardry/item/ItemSpectralArmour.java +++ b/src/main/java/electroblob/wizardry/item/ItemSpectralArmour.java @@ -1,7 +1,5 @@ package electroblob.wizardry.item; -import java.util.List; - import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -11,100 +9,104 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemSpectralArmour extends ItemArmor implements IConjuredItem { - public ItemSpectralArmour(ArmorMaterial material, int renderIndex, EntityEquipmentSlot armourType) { - + public ItemSpectralArmour(ArmorMaterial material, int renderIndex, EntityEquipmentSlot armourType){ + super(material, renderIndex, armourType); - + this.setCreativeTab(null); this.setMaxDamage(getBaseDuration()); } - + @Override public int getBaseDuration(){ return 1200; } - + @Override public int getMaxDamage(ItemStack stack){ - return this.getMaxDamageFromNBT(stack); - } - + return this.getMaxDamageFromNBT(stack); + } + // Overridden to stop the enchantment trick making the name turn blue. @Override public EnumRarity getRarity(ItemStack stack){ - return EnumRarity.COMMON; - } - + return EnumRarity.COMMON; + } + @Override // This method allows the code for the item's timer to be greatly simplified by damaging it directly from // onUpdate() and removing the workaround that involved WizardData and all sorts of crazy stuff. public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged){ - - if(oldStack != null || newStack != null){ + + if(!oldStack.isEmpty() || !newStack.isEmpty()){ // We only care about the situation where we specifically want the animation NOT to play. if(oldStack.getItem() == newStack.getItem() && !slotChanged) return false; } - + return super.shouldCauseReequipAnimation(oldStack, newStack, slotChanged); } - + @Override public void onArmorTick(World world, EntityPlayer player, ItemStack stack){ int damage = stack.getItemDamage(); if(damage > stack.getMaxDamage()) player.inventory.clearMatchingItems(this, -1, 1, null); stack.setItemDamage(damage + 1); } - + @Override @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack stack){ return true; } - + @Override public boolean getIsRepairable(ItemStack stack, ItemStack par2ItemStack){ - return false; - } - + return false; + } + @Override public int getItemEnchantability(){ - return 0; - } - + return 0; + } + // Cannot be dropped @Override public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player){ - return false; - } - + return false; + } + @Override - public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) { - + public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type){ + if(slot == EntityEquipmentSlot.LEGS) return "wizardry:textures/armour/spectral_armour_legs.png"; - + return "wizardry:textures/armour/spectral_armour.png"; } - + @Override @SideOnly(Side.CLIENT) - public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, - net.minecraft.client.model.ModelBiped _default) { + public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, + EntityEquipmentSlot armorSlot, net.minecraft.client.model.ModelBiped _default){ net.minecraft.client.renderer.GlStateManager.enableBlend(); - net.minecraft.client.renderer.GlStateManager.tryBlendFuncSeparate(net.minecraft.client.renderer.GlStateManager.SourceFactor.SRC_ALPHA, net.minecraft.client.renderer.GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, - net.minecraft.client.renderer.GlStateManager.SourceFactor.ONE, net.minecraft.client.renderer.GlStateManager.DestFactor.ZERO); + net.minecraft.client.renderer.GlStateManager.tryBlendFuncSeparate( + net.minecraft.client.renderer.GlStateManager.SourceFactor.SRC_ALPHA, + net.minecraft.client.renderer.GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, + net.minecraft.client.renderer.GlStateManager.SourceFactor.ONE, + net.minecraft.client.renderer.GlStateManager.DestFactor.ZERO); return super.getArmorModel(entityLiving, itemStack, armorSlot, _default); } - + @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item parItem, CreativeTabs parTab, List parListSubItems){ - parListSubItems.add(new ItemStack(this, 1)); - } + @SideOnly(Side.CLIENT) + public void getSubItems(Item parItem, CreativeTabs parTab, NonNullList parListSubItems){ + parListSubItems.add(new ItemStack(this, 1)); + } } diff --git a/src/main/java/electroblob/wizardry/item/ItemSpectralBow.java b/src/main/java/electroblob/wizardry/item/ItemSpectralBow.java index b25efc8d..42193594 100644 --- a/src/main/java/electroblob/wizardry/item/ItemSpectralBow.java +++ b/src/main/java/electroblob/wizardry/item/ItemSpectralBow.java @@ -1,7 +1,5 @@ package electroblob.wizardry.item; -import java.util.List; - import javax.annotation.Nullable; import electroblob.wizardry.Wizardry; @@ -24,6 +22,7 @@ import net.minecraft.stats.StatList; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; import net.minecraft.world.World; @@ -37,65 +36,64 @@ public class ItemSpectralBow extends ItemBow implements IConjuredItem { this.setMaxDamage(getBaseDuration()); this.setNoRepair(); this.setCreativeTab(null); - this.addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter() - { - @SideOnly(Side.CLIENT) - public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) - { - if (entityIn == null) - { - return 0.0F; - } - else - { - ItemStack itemstack = entityIn.getActiveItemStack(); - // Mojang, observe - hardcoding item references into their own classes is NOT good Java. - return itemstack != null && itemstack.getItem() == ItemSpectralBow.this ? (float)(stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F : 0.0F; - } - } - }); - this.addPropertyOverride(new ResourceLocation("pulling"), new IItemPropertyGetter() - { - @SideOnly(Side.CLIENT) - public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) - { - return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F; - } - }); + this.addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter(){ + @SideOnly(Side.CLIENT) + public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn){ + if(entityIn == null){ + return 0.0F; + }else{ + ItemStack itemstack = entityIn.getActiveItemStack(); + // Mojang, observe - hardcoding item references into their own classes is NOT good Java. + return itemstack.getItem() == ItemSpectralBow.this + ? (float)(stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F + : 0.0F; + } + } + }); + this.addPropertyOverride(new ResourceLocation("pulling"), new IItemPropertyGetter(){ + @SideOnly(Side.CLIENT) + public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn){ + return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F + : 0.0F; + } + }); } @Override - @SideOnly(Side.CLIENT) + @SideOnly(Side.CLIENT) // Why does this still exist? Item models deal with this now, right? public boolean isFull3D(){ return true; } - + @Override public int getBaseDuration(){ return 600; } - + @Override public int getMaxDamage(ItemStack stack){ - return this.getMaxDamageFromNBT(stack); - } - + return this.getMaxDamageFromNBT(stack); + } + @Override // This method allows the code for the item's timer to be greatly simplified by damaging it directly from // onUpdate() and removing the workaround that involved WizardData and all sorts of crazy stuff. public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged){ - - if(oldStack != null && newStack != null){ + + // TODO: For some reason there used to be an && here instead of an ||, which makes me wonder if there's a weird + // fix I did that needs removing. + if(!oldStack.isEmpty() || !newStack.isEmpty()){ // We only care about the situation where we specifically want the animation NOT to play. if(oldStack.getItem() == newStack.getItem() && !slotChanged - // This code should only run on the client side, so using Minecraft is ok. - && !Minecraft.getMinecraft().thePlayer.isHandActive()) return false; + // This code should only run on the client side, so using Minecraft is ok. + && !Minecraft.getMinecraft().player.isHandActive()) + return false; } - + return super.shouldCauseReequipAnimation(oldStack, newStack, slotChanged); } - + @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean selected){ int damage = stack.getItemDamage(); @@ -105,23 +103,26 @@ public class ItemSpectralBow extends ItemBow implements IConjuredItem { stack.setItemDamage(damage + 1); } } - + // The following two methods re-route the displayed durability through the proxies in order to override the pausing // of the item timer when the bow is being pulled. - + @Override public double getDurabilityForDisplay(ItemStack stack){ return Wizardry.proxy.getConjuredBowDurability(stack); } - + public double getDefaultDurabilityForDisplay(ItemStack stack){ return super.getDurabilityForDisplay(stack); } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand){ + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ - ActionResult ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(stack, world, player, hand, true); + ItemStack stack = player.getHeldItem(hand); + + ActionResult ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(stack, world, player, hand, + true); if(ret != null) return ret; @@ -132,7 +133,7 @@ public class ItemSpectralBow extends ItemBow implements IConjuredItem { } @Override - @SideOnly(Side.CLIENT) + @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack stack){ return true; } @@ -152,7 +153,7 @@ public class ItemSpectralBow extends ItemBow implements IConjuredItem { public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player){ return false; } - + @Override public void onUsingTick(ItemStack stack, EntityLivingBase player, int count){ // player.getItemInUseMaxCount() is named incorrectly; you only have to look at the method to see what it really @@ -165,55 +166,54 @@ public class ItemSpectralBow extends ItemBow implements IConjuredItem { public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entity, int timeLeft){ // Decreases the timer by the amount it should have been decreased while the bow was in use. if(!world.isRemote) stack.setItemDamage(stack.getItemDamage() + (this.getMaxItemUseDuration(stack) - timeLeft)); - - if (entity instanceof EntityPlayer){ - + + if(entity instanceof EntityPlayer){ + EntityPlayer entityplayer = (EntityPlayer)entity; int i = this.getMaxItemUseDuration(stack) - timeLeft; i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(stack, world, (EntityPlayer)entity, i, true); - if (i < 0) return; + if(i < 0) return; float f = getArrowVelocity(i); - if ((double)f >= 0.1D){ + if((double)f >= 0.1D){ + + if(!world.isRemote){ - if (!world.isRemote){ - ItemArrow itemarrow = (ItemArrow)Items.ARROW; EntityArrow entityarrow = itemarrow.createArrow(world, new ItemStack(itemarrow), entityplayer); - entityarrow.setAim(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F, f * 3.0F, 1.0F); + entityarrow.setAim(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F, + f * 3.0F, 1.0F); - if (f == 1.0F) - { + if(f == 1.0F){ entityarrow.setIsCritical(true); } int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack); - if (j > 0) - { + if(j > 0){ entityarrow.setDamage(entityarrow.getDamage() + (double)j * 0.5D + 0.5D); } int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack); - if (k > 0) - { + if(k > 0){ entityarrow.setKnockbackStrength(k); } - if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) - { + if(EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0){ entityarrow.setFire(100); } entityarrow.pickupStatus = EntityArrow.PickupStatus.DISALLOWED; - world.spawnEntityInWorld(entityarrow); + world.spawnEntity(entityarrow); } - world.playSound((EntityPlayer)null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + world.playSound((EntityPlayer)null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, + SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, + 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); entityplayer.addStat(StatList.getObjectUseStats(this)); } @@ -222,8 +222,8 @@ public class ItemSpectralBow extends ItemBow implements IConjuredItem { @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs tab, List subItems){ + public void getSubItems(Item item, CreativeTabs tab, NonNullList subItems){ subItems.add(new ItemStack(this, 1)); } - + } diff --git a/src/main/java/electroblob/wizardry/item/ItemSpectralPickaxe.java b/src/main/java/electroblob/wizardry/item/ItemSpectralPickaxe.java index a91c9000..40fa090e 100644 --- a/src/main/java/electroblob/wizardry/item/ItemSpectralPickaxe.java +++ b/src/main/java/electroblob/wizardry/item/ItemSpectralPickaxe.java @@ -1,13 +1,12 @@ package electroblob.wizardry.item; -import java.util.List; - import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -20,63 +19,63 @@ public class ItemSpectralPickaxe extends ItemPickaxe implements IConjuredItem { this.setNoRepair(); this.setCreativeTab(null); } - + @Override public int getBaseDuration(){ return 600; } - + @Override public int getMaxDamage(ItemStack stack){ - return this.getMaxDamageFromNBT(stack); - } - + return this.getMaxDamageFromNBT(stack); + } + @Override // This method allows the code for the item's timer to be greatly simplified by damaging it directly from // onUpdate() and removing the workaround that involved WizardData and all sorts of crazy stuff. public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged){ - - if(oldStack != null || newStack != null){ + + if(!oldStack.isEmpty() || !newStack.isEmpty()){ // We only care about the situation where we specifically want the animation NOT to play. if(oldStack.getItem() == newStack.getItem() && !slotChanged) return false; } - + return super.shouldCauseReequipAnimation(oldStack, newStack, slotChanged); } - + @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean selected){ int damage = stack.getItemDamage(); if(damage > stack.getMaxDamage()) entity.replaceItemInInventory(slot, null); stack.setItemDamage(damage + 1); } - + @Override - @SideOnly(Side.CLIENT) + @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack stack){ return true; } - + @Override public boolean getIsRepairable(ItemStack stack, ItemStack par2ItemStack){ - return false; - } - + return false; + } + @Override public int getItemEnchantability(){ - return 0; - } - + return 0; + } + // Cannot be dropped @Override public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player){ - return false; - } - + return false; + } + @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs tab, List subItems){ - subItems.add(new ItemStack(this, 1)); - } + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tab, NonNullList subItems){ + subItems.add(new ItemStack(this, 1)); + } } diff --git a/src/main/java/electroblob/wizardry/item/ItemSpectralSword.java b/src/main/java/electroblob/wizardry/item/ItemSpectralSword.java index b1db6b6e..0b1eb1e3 100644 --- a/src/main/java/electroblob/wizardry/item/ItemSpectralSword.java +++ b/src/main/java/electroblob/wizardry/item/ItemSpectralSword.java @@ -1,82 +1,81 @@ package electroblob.wizardry.item; -import java.util.List; - import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemSpectralSword extends ItemSword implements IConjuredItem { - public ItemSpectralSword(ToolMaterial material) { + public ItemSpectralSword(ToolMaterial material){ super(material); this.setMaxDamage(getBaseDuration()); this.setNoRepair(); this.setCreativeTab(null); } - + @Override public int getBaseDuration(){ return 600; } - + @Override public int getMaxDamage(ItemStack stack){ - return this.getMaxDamageFromNBT(stack); - } - + return this.getMaxDamageFromNBT(stack); + } + @Override // This method allows the code for the item's timer to be greatly simplified by damaging it directly from // onUpdate() and removing the workaround that involved WizardData and all sorts of crazy stuff. public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged){ - - if(oldStack != null || newStack != null){ + + if(!oldStack.isEmpty() || !newStack.isEmpty()){ // We only care about the situation where we specifically want the animation NOT to play. if(oldStack.getItem() == newStack.getItem() && !slotChanged) return false; } - + return super.shouldCauseReequipAnimation(oldStack, newStack, slotChanged); } - + @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean selected){ int damage = stack.getItemDamage(); if(damage > stack.getMaxDamage()) entity.replaceItemInInventory(slot, null); stack.setItemDamage(damage + 1); } - + @Override - @SideOnly(Side.CLIENT) + @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack stack){ return true; } - + @Override public boolean getIsRepairable(ItemStack stack, ItemStack par2ItemStack){ - return false; - } - + return false; + } + @Override public int getItemEnchantability(){ - return 0; - } - + return 0; + } + // Cannot be dropped @Override public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player){ - return false; - } - + return false; + } + @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs tab, List subItems){ - subItems.add(new ItemStack(this, 1)); - } + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tab, NonNullList subItems){ + subItems.add(new ItemStack(this, 1)); + } } diff --git a/src/main/java/electroblob/wizardry/item/ItemSpellBook.java b/src/main/java/electroblob/wizardry/item/ItemSpellBook.java index 742c660a..a9027455 100644 --- a/src/main/java/electroblob/wizardry/item/ItemSpellBook.java +++ b/src/main/java/electroblob/wizardry/item/ItemSpellBook.java @@ -15,64 +15,63 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.oredict.OreDictionary; public class ItemSpellBook extends Item { - - public ItemSpellBook() { + + public ItemSpellBook(){ super(); this.setHasSubtypes(true); this.setMaxStackSize(1); this.setCreativeTab(WizardryTabs.SPELLS); } - + @Override - public void getSubItems(Item item, CreativeTabs tab, List list){ + public void getSubItems(Item item, CreativeTabs tab, NonNullList list){ // In this particular case, getTotalSpellCount() is a more efficient way of doing this since the spell instance // is not required, only the id. - for(int i = 0; i < Spell.getTotalSpellCount(); i++){ - // i+1 is used so that the metadata ties up with the id() method. In other words, the none spell has id - // 0 and since this is not used as a spell book the metadata starts at 1. - list.add(new ItemStack(item, 1, i+1)); - } + for(int i = 0; i < Spell.getTotalSpellCount(); i++){ + // i+1 is used so that the metadata ties up with the id() method. In other words, the none spell has id + // 0 and since this is not used as a spell book the metadata starts at 1. + list.add(new ItemStack(item, 1, i + 1)); + } } - + @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand){ + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ + ItemStack stack = player.getHeldItem(hand); player.openGui(Wizardry.instance, WizardryGuiHandler.SPELL_BOOK, world, 0, 0, 0); return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } - + @Override - @SideOnly(Side.CLIENT) + @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer player, List tooltip, boolean advanced){ // Tooltip is left blank for wizards buying generic spell books. if(itemstack.getItemDamage() != OreDictionary.WILDCARD_VALUE){ - + Spell spell = Spell.get(itemstack.getItemDamage()); - + boolean discovered = true; if(Wizardry.settings.discoveryMode && !player.capabilities.isCreativeMode && WizardData.get(player) != null && !WizardData.get(player).hasSpellBeenDiscovered(spell)){ discovered = false; } - + // Element colour is not given for undiscovered spells - tooltip.add(discovered ? "\u00A77" + spell.getDisplayNameWithFormatting() : "#\u00A79" + SpellGlyphData.getGlyphName(spell, player.worldObj)); + tooltip.add(discovered ? "\u00A77" + spell.getDisplayNameWithFormatting() + : "#\u00A79" + SpellGlyphData.getGlyphName(spell, player.world)); tooltip.add(spell.tier.getDisplayNameWithFormatting()); } - /* Removed to streamline the tooltip a bit. Information is now within the book. - if(spell.isContinuous){ - tooltip.add("\u00A79Mana Cost: " + spell.cost + " per second"); - }else{ - tooltip.add("\u00A79Mana Cost: " + spell.cost); - } - */ + /* Removed to streamline the tooltip a bit. Information is now within the book. if(spell.isContinuous){ + * tooltip.add("\u00A79Mana Cost: " + spell.cost + " per second"); }else{ tooltip.add("\u00A79Mana Cost: " + + * spell.cost); } */ } - + @Override @SideOnly(Side.CLIENT) public net.minecraft.client.gui.FontRenderer getFontRenderer(ItemStack stack){ diff --git a/src/main/java/electroblob/wizardry/item/ItemWand.java b/src/main/java/electroblob/wizardry/item/ItemWand.java index 6f1f99b5..985d257a 100644 --- a/src/main/java/electroblob/wizardry/item/ItemWand.java +++ b/src/main/java/electroblob/wizardry/item/ItemWand.java @@ -33,6 +33,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; @@ -41,7 +42,8 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -/** This class is (literally) where the magic happens! All wand types are single instances of this class. There's a lot +/** + * This class is (literally) where the magic happens! All wand types are single instances of this class. There's a lot * of quite hard-to-read code in here, but unfortunately there's not much I can do about that. For this reason, I have * written the {@link WandHelper} class. I strongly recommend you use it for interacting with wand items wherever * possible. @@ -52,13 +54,15 @@ import net.minecraftforge.fml.relauncher.SideOnly; * - onItemRightClick is where non-continuous spells are cast, and it sets the item in use for continuous spells
    * - onUsingTick does the casting for continuous spells
    * - onUpdate deals with the cooldowns for the spells - * @since Wizardry 1.0 */ + * + * @since Wizardry 1.0 + */ public class ItemWand extends Item { public Tier tier; public Element element; - public ItemWand(Tier tier, Element element) { + public ItemWand(Tier tier, Element element){ super(); setMaxStackSize(1); if(element == null || tier == Tier.BASIC){ @@ -83,7 +87,7 @@ public class ItemWand extends Item { @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item parItem, CreativeTabs parTab, List parListSubItems){ + public void getSubItems(Item parItem, CreativeTabs parTab, NonNullList parListSubItems){ parListSubItems.add(new ItemStack(this, 1)); } @@ -91,7 +95,8 @@ public class ItemWand extends Item { @Override public int getMaxDamage(ItemStack itemstack){ // + 0.5f corrects small float errors rounding down - return (int)(super.getMaxDamage(itemstack)*(1.0f + Constants.STORAGE_INCREASE_PER_LEVEL * WandHelper.getUpgradeLevel(itemstack, WizardryItems.storage_upgrade)) + 0.5f); + return (int)(super.getMaxDamage(itemstack) * (1.0f + Constants.STORAGE_INCREASE_PER_LEVEL + * WandHelper.getUpgradeLevel(itemstack, WizardryItems.storage_upgrade)) + 0.5f); } @Override @@ -105,15 +110,18 @@ public class ItemWand extends Item { WandHelper.decrementCooldowns(itemstack); // Decrements wand damage (increases mana) every 1.5 seconds if it has a condenser upgrade - if(!world.isRemote && itemstack.isItemDamaged() && world.getWorldTime() % Constants.CONDENSER_TICK_INTERVAL == 0){ + if(!world.isRemote && itemstack.isItemDamaged() + && world.getWorldTime() % Constants.CONDENSER_TICK_INTERVAL == 0){ // If the upgrade level is 0, this does nothing anyway. - itemstack.setItemDamage(itemstack.getItemDamage() - WandHelper.getUpgradeLevel(itemstack, WizardryItems.condenser_upgrade)); + itemstack.setItemDamage( + itemstack.getItemDamage() - WandHelper.getUpgradeLevel(itemstack, WizardryItems.condenser_upgrade)); } if(entity instanceof EntityPlayer && this.element != null && this.element != Element.MAGIC){ // As it stands, this will trigger every tick. Not ideal, but I can't find a way to detect if a player // has a certain achievement. - // EDIT: There is a way to check, using StatFileWriter#hasAchievementUnlocked, but this ends up calling the same + // EDIT: There is a way to check, using StatFileWriter#hasAchievementUnlocked, but this ends up calling the + // same // thing as addStat anyway, meaning there's no point and it's probably not much of a problem anyway. ((EntityPlayer)entity).addStat(WizardryAchievements.elemental); } @@ -124,11 +132,12 @@ public class ItemWand extends Item { // This method does some VERY strange things! Despite its name, it also seems to affect the updating of NBT... - if(oldStack != null || newStack != null){ + if(!oldStack.isEmpty() || !newStack.isEmpty()){ // We only care about the situation where we specifically want the animation NOT to play. - if(oldStack.getItem() == newStack.getItem() && !slotChanged - && oldStack.getItem() instanceof ItemWand && newStack.getItem() instanceof ItemWand - && WandHelper.getCurrentSpell(oldStack) == WandHelper.getCurrentSpell(newStack)) return false; + if(oldStack.getItem() == newStack.getItem() && !slotChanged && oldStack.getItem() instanceof ItemWand + && newStack.getItem() instanceof ItemWand + && WandHelper.getCurrentSpell(oldStack) == WandHelper.getCurrentSpell(newStack)) + return false; } return super.shouldCauseReequipAnimation(oldStack, newStack, slotChanged); @@ -149,7 +158,9 @@ public class ItemWand extends Item { public void addInformation(ItemStack itemstack, EntityPlayer player, List text, boolean advanced){ // +0.5f is necessary due to the error in the way floats are calculated. - if(element != null) text.add("\u00A78" + net.minecraft.client.resources.I18n.format("item.wizardry:wand.buff", (int)((tier.level+1)*Constants.DAMAGE_INCREASE_PER_TIER*100 + 0.5f) + "%", element.getDisplayName())); + if(element != null) text.add("\u00A78" + net.minecraft.client.resources.I18n.format("item.wizardry:wand.buff", + (int)((tier.level + 1) * Constants.DAMAGE_INCREASE_PER_TIER * 100 + 0.5f) + "%", + element.getDisplayName())); Spell spell = WandHelper.getCurrentSpell(itemstack); @@ -159,29 +170,34 @@ public class ItemWand extends Item { discovered = false; } - text.add("\u00A77" + net.minecraft.client.resources.I18n.format("item.wizardry:wand.spell", discovered ? "\u00A77" + spell.getDisplayNameWithFormatting() : "#\u00A79" + SpellGlyphData.getGlyphName(spell, player.worldObj))); + text.add("\u00A77" + net.minecraft.client.resources.I18n.format("item.wizardry:wand.spell", + discovered ? "\u00A77" + spell.getDisplayNameWithFormatting() + : "#\u00A79" + SpellGlyphData.getGlyphName(spell, player.world))); - text.add("\u00A79" + net.minecraft.client.resources.I18n.format("item.wizardry:wand.mana", (this.getMaxDamage(itemstack) - this.getDamage(itemstack)), this.getMaxDamage(itemstack))); + text.add("\u00A79" + net.minecraft.client.resources.I18n.format("item.wizardry:wand.mana", + (this.getMaxDamage(itemstack) - this.getDamage(itemstack)), this.getMaxDamage(itemstack))); } @Override public String getItemStackDisplayName(ItemStack stack){ return (this.element == null ? "" : this.element.getFormattingCode()) + super.getItemStackDisplayName(stack); } - + // Continuous spells use the onUsingItemTick method instead of this one. /* An important thing to note about this method: it is only called on the server and the client of the player * holding the item (I call this client-inconsistency). This means if you spawn particles here they will not show up * on other players' screens. Instead, this must be done via packets. */ @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand){ + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ + + ItemStack stack = player.getHeldItem(hand); // Alternate right-click function; overrides spell casting. if(this.selectMinionTarget(player, world)) return new ActionResult(EnumActionResult.SUCCESS, stack); - + Spell spell = WandHelper.getCurrentSpell(stack); SpellModifiers modifiers = this.calculateModifiers(stack, spell); - + // If anything stops the spell working at this point, nothing else happens. if(MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Pre(player, spell, modifiers, Source.WAND))){ return new ActionResult(EnumActionResult.FAIL, stack); @@ -197,7 +213,7 @@ public class ItemWand extends Item { // Conditions for the spell to be attempted. The tier check is a failsafe; it should never be false unless the // NBT is modified directly. if(!spell.isContinuous && spell.tier.level <= this.tier.level - // Checks that the wand has enough mana to cast the spell + // Checks that the wand has enough mana to cast the spell && spell.cost <= (stack.getMaxDamage() - stack.getItemDamage()) // Checks that the spell is not in cooldown or that the player is in creative mode && (WandHelper.getCurrentCooldown(stack) == 0 || player.capabilities.isCreativeMode)){ @@ -207,7 +223,7 @@ public class ItemWand extends Item { if(!world.isRemote){ if(spell.cast(world, player, hand, 0, modifiers)){ - + MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Post(player, spell, modifiers, Source.WAND)); // = Packets = @@ -225,11 +241,15 @@ public class ItemWand extends Item { // Spells only have a cooldown in survival if(!player.capabilities.isCreativeMode){ - float cooldownMultiplier = 1.0f - WandHelper.getUpgradeLevel(stack, WizardryItems.cooldown_upgrade)*Constants.COOLDOWN_REDUCTION_PER_LEVEL; + float cooldownMultiplier = 1.0f + - WandHelper.getUpgradeLevel(stack, WizardryItems.cooldown_upgrade) + * Constants.COOLDOWN_REDUCTION_PER_LEVEL; if(player.isPotionActive(WizardryPotions.font_of_mana)){ - // Dividing by this rather than setting it takes upgrades and font of mana into account simultaneously - cooldownMultiplier /= 2 + player.getActivePotionEffect(WizardryPotions.font_of_mana).getAmplifier(); + // Dividing by this rather than setting it takes upgrades and font of mana into account + // simultaneously + cooldownMultiplier /= 2 + + player.getActivePotionEffect(WizardryPotions.font_of_mana).getAmplifier(); } WandHelper.setCurrentCooldown(stack, (int)(spell.cooldown * cooldownMultiplier)); @@ -239,7 +259,8 @@ public class ItemWand extends Item { // The spell costs 20% less for every armour piece of the matching element. int armourPieces = getMatchingArmourCount(player, spell); - stack.damageItem((int)(spell.cost * (1.0f - armourPieces*Constants.COST_REDUCTION_PER_ARMOUR)), player); + stack.damageItem((int)(spell.cost * (1.0f - armourPieces * Constants.COST_REDUCTION_PER_ARMOUR)), + player); return new ActionResult(EnumActionResult.SUCCESS, stack); } @@ -264,20 +285,23 @@ public class ItemWand extends Item { if(user instanceof EntityPlayer){ EntityPlayer player = (EntityPlayer)user; - + Spell spell = WandHelper.getCurrentSpell(stack); SpellModifiers modifiers = this.calculateModifiers(stack, spell); int castingTick = stack.getMaxItemUseDuration() - count; - - if(MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Tick(player, spell, modifiers, Source.WAND, castingTick))) return; + + if(MinecraftForge.EVENT_BUS + .post(new SpellCastEvent.Tick(player, spell, modifiers, Source.WAND, castingTick))) + return; // Continuous spells (these must check if they can be cast each tick since the mana changes) if(spell.isContinuous && spell.tier.level <= this.tier.level - && spell.cost/5 <= (stack.getMaxDamage() - stack.getItemDamage())){ + && spell.cost / 5 <= (stack.getMaxDamage() - stack.getItemDamage())){ - if(spell.cast(player.worldObj, player, player.getActiveHand(), castingTick, modifiers)){ + if(spell.cast(player.world, player, player.getActiveHand(), castingTick, modifiers)){ - if(castingTick == 0) MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Post(player, spell, modifiers, Source.WAND)); + if(castingTick == 0) + MinecraftForge.EVENT_BUS.post(new SpellCastEvent.Post(player, spell, modifiers, Source.WAND)); // = Mana cost = // Divides the mana cost over a second appropriately; since damage is an integer it cannot @@ -285,7 +309,8 @@ public class ItemWand extends Item { // Now does five times per second regardless of the spell cost, but each time it does 1/5 of the // cost per second. int tickNumber = (count % 20) + 1; - // Tests if the tick counter is a multiple of 4 plus 1, i.e. is true when tickNumber = 1, 5, 9, 13 or 17. + // Tests if the tick counter is a multiple of 4 plus 1, i.e. is true when tickNumber = 1, 5, 9, 13 + // or 17. // Made a slight adjustment since the counter starts on 1 and not 4. if(tickNumber % 4 == 1){ @@ -293,20 +318,26 @@ public class ItemWand extends Item { switch(armourPieces){ - case 0: stack.damageItem(spell.cost/5, player); - break; + case 0: + stack.damageItem(spell.cost / 5, player); + break; - case 1: if(tickNumber != 17) stack.damageItem(spell.cost/5, player); - break; + case 1: + if(tickNumber != 17) stack.damageItem(spell.cost / 5, player); + break; - case 2: if(tickNumber != 9 && tickNumber != 17) stack.damageItem(spell.cost/5, player); - break; + case 2: + if(tickNumber != 9 && tickNumber != 17) stack.damageItem(spell.cost / 5, player); + break; - case 3: if(tickNumber != 5 && tickNumber != 13 && tickNumber != 17) stack.damageItem(spell.cost/5, player); - break; + case 3: + if(tickNumber != 5 && tickNumber != 13 && tickNumber != 17) + stack.damageItem(spell.cost / 5, player); + break; - case 4: if(tickNumber == 1) stack.damageItem(spell.cost/5, player); - break; + case 4: + if(tickNumber == 1) stack.damageItem(spell.cost / 5, player); + break; } } @@ -316,13 +347,15 @@ public class ItemWand extends Item { } @Override - public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity, EnumHand hand){ + public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity, + EnumHand hand){ if(player.isSneaking() && entity instanceof EntityPlayer && WizardData.get(player) != null){ // This is one of those "the method doing the work looks as if it's just returning a value" situations. // ... I know, right?! I feel very programmer-y. But it's not too confusing here, and it looks neat. - String string = WizardData.get(player).toggleAlly((EntityPlayer)entity) ? "item.wizardry:wand.addally" : "item.wizardry:wand.removeally"; - if(!player.worldObj.isRemote) player.addChatMessage(new TextComponentTranslation(string, entity.getName())); + String string = WizardData.get(player).toggleAlly((EntityPlayer)entity) ? "item.wizardry:wand.addally" + : "item.wizardry:wand.removeally"; + if(!player.world.isRemote) player.sendMessage(new TextComponentTranslation(string, entity.getName())); return true; } @@ -336,19 +369,24 @@ public class ItemWand extends Item { // Now we only need to add multipliers if they are not 1. int level = WandHelper.getUpgradeLevel(stack, WizardryItems.range_upgrade); - if(level > 0) modifiers.set(WizardryItems.range_upgrade, 1.0f + level * Constants.RANGE_INCREASE_PER_LEVEL, true); + if(level > 0) + modifiers.set(WizardryItems.range_upgrade, 1.0f + level * Constants.RANGE_INCREASE_PER_LEVEL, true); level = WandHelper.getUpgradeLevel(stack, WizardryItems.duration_upgrade); - if(level > 0) modifiers.set(WizardryItems.duration_upgrade, 1.0f + level * Constants.DURATION_INCREASE_PER_LEVEL, false); + if(level > 0) + modifiers.set(WizardryItems.duration_upgrade, 1.0f + level * Constants.DURATION_INCREASE_PER_LEVEL, false); level = WandHelper.getUpgradeLevel(stack, WizardryItems.blast_upgrade); - if(level > 0) modifiers.set(WizardryItems.blast_upgrade, 1.0f + level * Constants.BLAST_RADIUS_INCREASE_PER_LEVEL, true); + if(level > 0) + modifiers.set(WizardryItems.blast_upgrade, 1.0f + level * Constants.BLAST_RADIUS_INCREASE_PER_LEVEL, true); // I would have liked to have made potion effects increase in strength according to the damage multiplier, // but the amplifier level is too discrete to make this work. For example, wither 3 for 10 seconds will kill a - // normal mob on full 20 health, but wither 2 for the same duration only deals about 6 hearts of damage in total. + // normal mob on full 20 health, but wither 2 for the same duration only deals about 6 hearts of damage in + // total. if(this.element == spell.element){ - modifiers.set(SpellModifiers.DAMAGE, 1.0f + (this.tier.level + 1) * Constants.DAMAGE_INCREASE_PER_TIER, true); + modifiers.set(SpellModifiers.DAMAGE, 1.0f + (this.tier.level + 1) * Constants.DAMAGE_INCREASE_PER_TIER, + true); } return modifiers; @@ -364,7 +402,8 @@ public class ItemWand extends Item { ItemStack armour = player.getItemStackFromSlot(slot); if(armour != null && armour.getItem() instanceof ItemWizardArmour - && ((ItemWizardArmour)armour.getItem()).element == spell.element) armourPieces++; + && ((ItemWizardArmour)armour.getItem()).element == spell.element) + armourPieces++; } return armourPieces; diff --git a/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java b/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java index 97a18fee..fc36af7c 100644 --- a/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java +++ b/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java @@ -5,6 +5,7 @@ import java.util.List; import electroblob.wizardry.Wizardry; import electroblob.wizardry.constants.Constants; import electroblob.wizardry.constants.Element; +import electroblob.wizardry.registry.WizardryAchievements; import electroblob.wizardry.registry.WizardryTabs; import electroblob.wizardry.spell.Petrify; import electroblob.wizardry.util.WizardryUtilities; @@ -19,154 +20,161 @@ import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumHandSide; +import net.minecraft.util.NonNullList; import net.minecraftforge.common.ISpecialArmor; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +@Mod.EventBusSubscriber public class ItemWizardArmour extends ItemArmor implements ISpecialArmor { public Element element; - public ItemWizardArmour(ArmorMaterial material, int renderIndex, EntityEquipmentSlot armourType, Element element) { + public ItemWizardArmour(ArmorMaterial material, int renderIndex, EntityEquipmentSlot armourType, Element element){ super(material, renderIndex, armourType); this.element = element; this.setCreativeTab(WizardryTabs.WIZARDRY); } - + @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced){ - - if(stack.hasTagCompound() && stack.getTagCompound().getBoolean("legendary")) tooltip.add("\u00A7d" + net.minecraft.client.resources.I18n.format("item.wizardry:wizard_armour.legendary")); - if(element != null) tooltip.add("\u00A78" + net.minecraft.client.resources.I18n.format("item.wizardry:wizard_armour.buff", (int)(Constants.COST_REDUCTION_PER_ARMOUR*100) + "%", element.getDisplayName())); - tooltip.add("\u00A79" + net.minecraft.client.resources.I18n.format("item.wizardry:wizard_armour.mana", (this.getMaxDamage(stack) - this.getDamage(stack)), this.getMaxDamage(stack))); + + if(stack.hasTagCompound() && stack.getTagCompound().getBoolean("legendary")) tooltip + .add("\u00A7d" + net.minecraft.client.resources.I18n.format("item.wizardry:wizard_armour.legendary")); + if(element != null) + tooltip.add("\u00A78" + net.minecraft.client.resources.I18n.format("item.wizardry:wizard_armour.buff", + (int)(Constants.COST_REDUCTION_PER_ARMOUR * 100) + "%", element.getDisplayName())); + tooltip.add("\u00A79" + net.minecraft.client.resources.I18n.format("item.wizardry:wizard_armour.mana", + (this.getMaxDamage(stack) - this.getDamage(stack)), this.getMaxDamage(stack))); } - + @Override public String getItemStackDisplayName(ItemStack stack){ - return ((this.element == null ? "" : this.element.getFormattingCode()) + super.getItemStackDisplayName(stack)); - } - + return ((this.element == null ? "" : this.element.getFormattingCode()) + super.getItemStackDisplayName(stack)); + } + @Override @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack stack){ return stack.hasTagCompound() && stack.getTagCompound().getBoolean("legendary"); } - + @Override @SideOnly(Side.CLIENT) - public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armourSlot, net.minecraft.client.model.ModelBiped _default){ - + public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, + EntityEquipmentSlot armourSlot, net.minecraft.client.model.ModelBiped _default){ + net.minecraft.client.model.ModelBiped model = Wizardry.proxy.getWizardArmourModel(); - + // Legs use modelBiped if(armourSlot == EntityEquipmentSlot.LEGS) return null; - + if(model != null){ - + model.bipedHead.showModel = armourSlot == EntityEquipmentSlot.HEAD; model.bipedHeadwear.showModel = false; - model.bipedBody.showModel = armourSlot == EntityEquipmentSlot.CHEST || armourSlot == EntityEquipmentSlot.LEGS; + model.bipedBody.showModel = armourSlot == EntityEquipmentSlot.CHEST + || armourSlot == EntityEquipmentSlot.LEGS; model.bipedRightArm.showModel = armourSlot == EntityEquipmentSlot.CHEST; model.bipedLeftArm.showModel = armourSlot == EntityEquipmentSlot.CHEST; - model.bipedRightLeg.showModel = armourSlot == EntityEquipmentSlot.LEGS || armourSlot == EntityEquipmentSlot.FEET; - model.bipedLeftLeg.showModel = armourSlot == EntityEquipmentSlot.LEGS || armourSlot == EntityEquipmentSlot.FEET; - + model.bipedRightLeg.showModel = armourSlot == EntityEquipmentSlot.LEGS + || armourSlot == EntityEquipmentSlot.FEET; + model.bipedLeftLeg.showModel = armourSlot == EntityEquipmentSlot.LEGS + || armourSlot == EntityEquipmentSlot.FEET; + model.isSneak = entityLiving.isSneaking(); model.isRiding = entityLiving.isRiding(); model.isChild = entityLiving.isChild(); - + boolean leftHanded = entityLiving.getPrimaryHand() == EnumHandSide.LEFT; - + ItemStack itemstackR = leftHanded ? entityLiving.getHeldItemOffhand() : entityLiving.getHeldItemMainhand(); ItemStack itemstackL = leftHanded ? entityLiving.getHeldItemMainhand() : entityLiving.getHeldItemOffhand(); - if (itemstackR != null) - { - model.rightArmPose = net.minecraft.client.model.ModelBiped.ArmPose.ITEM; + if(itemstackR != null){ + model.rightArmPose = net.minecraft.client.model.ModelBiped.ArmPose.ITEM; - if (entityLiving.getItemInUseCount() > 0) - { - EnumAction enumaction = itemstackR.getItemUseAction(); + if(entityLiving.getItemInUseCount() > 0){ + EnumAction enumaction = itemstackR.getItemUseAction(); - if (enumaction == EnumAction.BLOCK) - { - model.rightArmPose = net.minecraft.client.model.ModelBiped.ArmPose.BLOCK; - } - else if (enumaction == EnumAction.BOW) - { - model.rightArmPose = net.minecraft.client.model.ModelBiped.ArmPose.BOW_AND_ARROW; - } - } - } + if(enumaction == EnumAction.BLOCK){ + model.rightArmPose = net.minecraft.client.model.ModelBiped.ArmPose.BLOCK; + }else if(enumaction == EnumAction.BOW){ + model.rightArmPose = net.minecraft.client.model.ModelBiped.ArmPose.BOW_AND_ARROW; + } + } + } - if (itemstackL != null) - { - model.leftArmPose = net.minecraft.client.model.ModelBiped.ArmPose.ITEM; + if(itemstackL != null){ + model.leftArmPose = net.minecraft.client.model.ModelBiped.ArmPose.ITEM; - if (entityLiving.getItemInUseCount() > 0) - { - EnumAction enumaction1 = itemstackL.getItemUseAction(); + if(entityLiving.getItemInUseCount() > 0){ + EnumAction enumaction1 = itemstackL.getItemUseAction(); - if (enumaction1 == EnumAction.BLOCK) - { - model.leftArmPose = net.minecraft.client.model.ModelBiped.ArmPose.BLOCK; - } - else if (enumaction1 == EnumAction.BOW) - { - model.leftArmPose = net.minecraft.client.model.ModelBiped.ArmPose.BOW_AND_ARROW; - } - } - } + if(enumaction1 == EnumAction.BLOCK){ + model.leftArmPose = net.minecraft.client.model.ModelBiped.ArmPose.BLOCK; + }else if(enumaction1 == EnumAction.BOW){ + model.leftArmPose = net.minecraft.client.model.ModelBiped.ArmPose.BOW_AND_ARROW; + } + } + } } - - return model; - } - + + return model; + } + @Override - public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) { + public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type){ // Returns a completely transparent texture if the player is invisible. This is such an annoyingly easy // fix, considering how long I spent trying to do this before - a bit of lateral thinking was all it took. // Do note however that a texture pack could override this. if(entity instanceof EntityLivingBase && ((EntityLivingBase)entity).isInvisible() - && !entity.getEntityData().getBoolean(Petrify.NBT_KEY)) return "wizardry:textures/armour/invisible_armour.png"; - - if(slot == EntityEquipmentSlot.LEGS) return this.element == null ? "wizardry:textures/armour/wizard_armour_legs.png" : - "wizardry:textures/armour/wizard_armour_" + this.element.getUnlocalisedName() + "_legs.png"; - - return this.element == null ? "wizardry:textures/armour/wizard_armour.png" : - "wizardry:textures/armour/wizard_armour_" + this.element.getUnlocalisedName() + ".png"; + && !entity.getEntityData().getBoolean(Petrify.NBT_KEY)) + return "wizardry:textures/armour/invisible_armour.png"; + + if(slot == EntityEquipmentSlot.LEGS) + return this.element == null ? "wizardry:textures/armour/wizard_armour_legs.png" + : "wizardry:textures/armour/wizard_armour_" + this.element.getUnlocalisedName() + "_legs.png"; + + return this.element == null ? "wizardry:textures/armour/wizard_armour.png" + : "wizardry:textures/armour/wizard_armour_" + this.element.getUnlocalisedName() + ".png"; } - - @Override - public boolean getIsRepairable(ItemStack stack, ItemStack par2ItemStack) - { - return false; - } @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slotIndex){ - + public boolean getIsRepairable(ItemStack stack, ItemStack par2ItemStack){ + return false; + } + + @Override + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, + int slotIndex){ + EntityEquipmentSlot slot = getArmorSlotFromIndex(slotIndex); - - if (!source.isUnblockable() && armor.getItemDamage() < armor.getMaxDamage()){ + + if(!source.isUnblockable() && armor.getItemDamage() < armor.getMaxDamage()){ if(armor.hasTagCompound() && armor.getTagCompound().getBoolean("legendary")){ // Legendary armour gives full 10 shields, like diamond. - return new ArmorProperties(0, ArmorMaterial.DIAMOND.getDamageReductionAmount(slot) / 25D, armor.getMaxDamage() + 1 - armor.getItemDamage()); + return new ArmorProperties(0, ArmorMaterial.DIAMOND.getDamageReductionAmount(slot) / 25D, + armor.getMaxDamage() + 1 - armor.getItemDamage()); }else{ - return new ArmorProperties(0, this.damageReduceAmount / 25D, armor.getMaxDamage() + 1 - armor.getItemDamage()); + return new ArmorProperties(0, this.damageReduceAmount / 25D, + armor.getMaxDamage() + 1 - armor.getItemDamage()); } - }else{ - return new ArmorProperties(0, 0, 0); - } + }else{ + return new ArmorProperties(0, 0, 0); + } } @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slotIndex) { - + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slotIndex){ + EntityEquipmentSlot slot = getArmorSlotFromIndex(slotIndex); - + if(armor.getItemDamage() < armor.getMaxDamage()){ if(armor.hasTagCompound() && armor.getTagCompound().getBoolean("legendary")){ // Legendary armour gives full 10 shields, like diamond. @@ -191,21 +199,23 @@ public class ItemWizardArmour extends ItemArmor implements ISpecialArmor { } } } - + @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs tab, List subItems){ - subItems.add(new ItemStack(this, 1)); - } - - /** Returns the EntityEquipmentSlot for which index() returns an integer equal to the passed in slotIndex and - * which is an armour slot (not a hand slot). This only exists because the 1.10.2 version of Forge still uses - * an integer slot index in ISpecialArmor instead of an EntityEquipmentSlot. */ - // NOTE: Remove in 1.11.2 - private EntityEquipmentSlot getArmorSlotFromIndex(int slotIndex) { + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tab, NonNullList subItems){ + subItems.add(new ItemStack(this, 1)); + } + + /** + * Returns the EntityEquipmentSlot for which index() returns an integer equal to the passed in slotIndex and which + * is an armour slot (not a hand slot). This only exists because the 1.10.2/1.11.2 versions of Forge still uses an + * integer slot index in ISpecialArmor instead of an EntityEquipmentSlot. + */ + // NOTE: Remove in 1.12.2 + private EntityEquipmentSlot getArmorSlotFromIndex(int slotIndex){ // Had to pick something to begin with. EntityEquipmentSlot slot = EntityEquipmentSlot.HEAD; - + for(EntityEquipmentSlot s : WizardryUtilities.ARMOUR_SLOTS){ if(s.getIndex() == slotIndex){ slot = s; @@ -214,4 +224,21 @@ public class ItemWizardArmour extends ItemArmor implements ISpecialArmor { return slot; } + @SubscribeEvent + public static void onLivingUpdateEvent(LivingUpdateEvent event){ + + if(event.getEntityLiving() instanceof EntityPlayer){ + + EntityPlayer player = (EntityPlayer)event.getEntityLiving(); + + for(ItemStack stack : player.getArmorInventoryList()){ + if(stack == null || !(stack.getItem() instanceof ItemWizardArmour)){ + return; // If any of the armour slots doesn't contain wizard armour, don't trigger the achievement. + } + } + // If it gets this far, then all slots must be wizard armour, so trigger the achievement. + player.addStat(WizardryAchievements.armour_set); + } + } + } diff --git a/src/main/java/electroblob/wizardry/item/ItemWizardHandbook.java b/src/main/java/electroblob/wizardry/item/ItemWizardHandbook.java index 3b7060db..3eddb304 100644 --- a/src/main/java/electroblob/wizardry/item/ItemWizardHandbook.java +++ b/src/main/java/electroblob/wizardry/item/ItemWizardHandbook.java @@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -20,8 +21,8 @@ public class ItemWizardHandbook extends Item { // Yep, I hardcoded my own name into the mod. Don't want people changing it now, do I? private static final String AUTHOR = "Electroblob"; - - public ItemWizardHandbook() { + + public ItemWizardHandbook(){ super(); this.setMaxStackSize(1); this.setCreativeTab(WizardryTabs.WIZARDRY); @@ -29,18 +30,20 @@ public class ItemWizardHandbook extends Item { @Override public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced){ - tooltip.add("\u00A77" + net.minecraft.client.resources.I18n.format("item.wizardry:wizard_handbook.desc", AUTHOR)); + tooltip.add( + "\u00A77" + net.minecraft.client.resources.I18n.format("item.wizardry:wizard_handbook.desc", AUTHOR)); } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand){ + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ + ItemStack stack = player.getHeldItem(hand); player.openGui(Wizardry.instance, WizardryGuiHandler.WIZARD_HANDBOOK, world, 0, 0, 0); return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } - + @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs tab, List items){ - items.add(new ItemStack(this, 1)); - } + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tab, NonNullList items){ + items.add(new ItemStack(this, 1)); + } } diff --git a/src/main/java/electroblob/wizardry/loot/RandomSpell.java b/src/main/java/electroblob/wizardry/loot/RandomSpell.java index c068ccb7..15a92b91 100644 --- a/src/main/java/electroblob/wizardry/loot/RandomSpell.java +++ b/src/main/java/electroblob/wizardry/loot/RandomSpell.java @@ -28,7 +28,8 @@ import net.minecraft.world.storage.loot.LootContext; import net.minecraft.world.storage.loot.conditions.LootCondition; import net.minecraft.world.storage.loot.functions.LootFunction; -/** Loot function that allows spell books and scrolls to select a random spell based on the standard weighting. +/** + * Loot function that allows spell books and scrolls to select a random spell based on the standard weighting. * Automatically discounts continuous spells when the item in question is a scroll. Can be used as-is with no * parameters, but several optional parameters are available for those wishing to customise further: *

    @@ -44,28 +45,28 @@ import net.minecraft.world.storage.loot.functions.LootFunction; *

    * Since spells are stored as metadata, this could be done by having an entry for each tier and letting it pick a * random spell from that tier by setting the metadata to a random value in the range of values that correspond to that - * tier. However, this creates a two-fold problem: firstly, not all spells are in tier order, and secondly, if spells are - * added via addon mods the entries would have to be updated manually with the new numbers. + * tier. However, this creates a two-fold problem: firstly, not all spells are in tier order, and secondly, if spells + * are added via addon mods the entries would have to be updated manually with the new numbers. *

    * (This reasoning is similar to that for the enchant_randomly function in vanilla Minecraft, since you can specify NBT * data in loot tables, but using NBT in this way would be incredibly verbose and inflexible, hence the loot function.) + * * @see WizardryUtilities#getStandardWeightedRandomSpellId(Random, boolean) * @author Electroblob * @since Wizardry 1.2 */ -/* - * You could even use the yet more long-winded method of adding each spell as an individual entry, which would be - * stupidly long but would allow precise control over each individual spell... I'll leave that for pack makers to do - * if they have the patience! - * */ +/* You could even use the yet more long-winded method of adding each spell as an individual entry, which would be + * stupidly long but would allow precise control over each individual spell... I'll leave that for pack makers to do if + * they have the patience! */ public class RandomSpell extends LootFunction { - private final List spells; - private final boolean ignoreWeighting; - private final List tiers; - private final List elements; - - protected RandomSpell(LootCondition[] conditions, List spells, boolean ignoreWeighting, List tiers, List elements){ + private final List spells; + private final boolean ignoreWeighting; + private final List tiers; + private final List elements; + + protected RandomSpell(LootCondition[] conditions, List spells, boolean ignoreWeighting, List tiers, + List elements){ super(conditions); this.spells = spells; this.ignoreWeighting = ignoreWeighting; @@ -75,13 +76,13 @@ public class RandomSpell extends LootFunction { @Override public ItemStack apply(ItemStack stack, Random random, LootContext context){ - - if(!(stack.getItem() instanceof ItemSpellBook) && !(stack.getItem() instanceof ItemScroll)) - Wizardry.logger.warn("Applying the random_spell loot function to an item that isn't a spell book or scroll."); + + if(!(stack.getItem() instanceof ItemSpellBook) && !(stack.getItem() instanceof ItemScroll)) Wizardry.logger + .warn("Applying the random_spell loot function to an item that isn't a spell book or scroll."); Tier tier; Element element; - + if(ignoreWeighting){ if(tiers == null || tiers.isEmpty()){ tier = Tier.values()[random.nextInt(Tier.values().length)]; @@ -95,43 +96,40 @@ public class RandomSpell extends LootFunction { tier = Tier.getWeightedRandomTier(random, tiers.toArray(new Tier[0])); } } - + // Elements aren't weighted if(elements == null || elements.isEmpty()){ // Element can only be MAGIC if tier is BASIC if(tier == Tier.BASIC){ element = Element.values()[random.nextInt(Element.values().length)]; }else{ - Element[] elements = ArrayUtils.removeElement(Element.values(), Element.MAGIC); - element = elements[random.nextInt(elements.length)]; + element = ArrayUtils.removeElement(Element.values(), Element.MAGIC)[random + .nextInt(Element.values().length)]; } }else{ // In theory, swapping this line to the commented one should make absolutely no difference. element = elements.get(random.nextInt(tiers.size())); - //element = null; + // element = null; } - + // Here's a thought: does randomly selecting the element beforehand (as opposed to leaving it null and letting // the spell randomiser use any element) change the overall outcome at all? List spellsList = Spell.getSpells(new Spell.TierElementFilter(tier, element)); if(stack.getItem() instanceof ItemScroll) spellsList.retainAll(Spell.getSpells(Spell.nonContinuousSpells)); - + // Ensures the tier chosen actually has spells in it, and if not uses BASIC instead. BASIC always has at least // the NONE spell since this spell cannot be disabled. // NOTE: Commented out for now because it will interfere with the ability to specify tiers and elements. // To be honest, I may as well just say that if you disable enough spells to make this important, you deserve // less loot! - /* - if(spells.isEmpty()){ - spellsList = Spell.getSpells(new Spell.TierElementFilter(EnumTier.BASIC, null)); - if(stack.getItem() instanceof ItemScroll) spellsList.retainAll(Spell.getSpells(Spell.nonContinuousSpells)); - } - */ - + /* if(spells.isEmpty()){ spellsList = Spell.getSpells(new Spell.TierElementFilter(EnumTier.BASIC, null)); + * if(stack.getItem() instanceof ItemScroll) spellsList.retainAll(Spell.getSpells(Spell.nonContinuousSpells)); + * } */ + if(spells != null && !spells.isEmpty()){ spellsList.retainAll(spells); } - + if(spellsList.isEmpty()){ Wizardry.logger.warn("Tried to apply the random_spell loot function to an item, but no enabled spells" + "matched the criteria specified. Substituting placeholder (metadata 0) item."); @@ -139,129 +137,129 @@ public class RandomSpell extends LootFunction { }else{ stack.setItemDamage(spellsList.get(random.nextInt(spellsList.size())).id()); } - + return stack; } - - public static class Serializer extends LootFunction.Serializer{ - - public Serializer(){ - super(new ResourceLocation(Wizardry.MODID, "random_spell"), RandomSpell.class); - } - public void serialize(JsonObject object, RandomSpell function, JsonSerializationContext serializationContext){ - - if(function.spells != null && !function.spells.isEmpty()){ - - JsonArray jsonarray = new JsonArray(); + public static class Serializer extends LootFunction.Serializer { - for(Spell spell : function.spells){ - jsonarray.add(new JsonPrimitive(spell.getRegistryName().toString())); - } + public Serializer(){ + super(new ResourceLocation(Wizardry.MODID, "random_spell"), RandomSpell.class); + } - object.add("spells", jsonarray); - } - - object.addProperty("ignore_weighting", function.ignoreWeighting); - - if(function.tiers != null && !function.tiers.isEmpty()){ - - JsonArray jsonarray = new JsonArray(); + public void serialize(JsonObject object, RandomSpell function, JsonSerializationContext serializationContext){ - for(Tier tier : function.tiers){ - jsonarray.add(new JsonPrimitive(tier.getUnlocalisedName())); - } + if(function.spells != null && !function.spells.isEmpty()){ - object.add("tiers", jsonarray); - } - - if(function.elements != null && !function.elements.isEmpty()){ - - JsonArray jsonarray = new JsonArray(); + JsonArray jsonarray = new JsonArray(); - for(Element element : function.elements){ - jsonarray.add(new JsonPrimitive(element.getUnlocalisedName())); - } + for(Spell spell : function.spells){ + jsonarray.add(new JsonPrimitive(spell.getRegistryName().toString())); + } - object.add("elements", jsonarray); - } - } + object.add("spells", jsonarray); + } - public RandomSpell deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditions){ - - List spells = null; - List tiers = null; - List elements = null; + object.addProperty("ignore_weighting", function.ignoreWeighting); - if(object.has("spells")){ - - // Vanilla Minecraft calls Lists.newArrayList() here, which is completely pointless. - spells = new ArrayList(); + if(function.tiers != null && !function.tiers.isEmpty()){ - // Importantly, it is necessary to specify a default (the new JsonArray) here because otherwise the - // parameter will be mandatory, and the game will crash if it isn't present. - for (JsonElement element : JsonUtils.getJsonArray(object, "spells", new JsonArray())){ - - String string = JsonUtils.getString(element, "spell"); - - Spell spell = Spell.get(string); + JsonArray jsonarray = new JsonArray(); - if(spell == null){ - throw new JsonSyntaxException("Unknown spell \'" + string + "\'"); - } + for(Tier tier : function.tiers){ + jsonarray.add(new JsonPrimitive(tier.getUnlocalisedName())); + } - spells.add(spell); - } - } - - boolean ignoreWeighting = JsonUtils.getBoolean(object, "ignore_weighting", false); - - if(object.has("tiers")){ - - // Vanilla Minecraft calls Lists.newArrayList() here, which is completely pointless. - tiers = new ArrayList(); + object.add("tiers", jsonarray); + } - jsonarray: - for(JsonElement element : JsonUtils.getJsonArray(object, "tiers", new JsonArray())){ - - String string = JsonUtils.getString(element, "tier"); - - // IDEA: If it is necessary to get tiers by name elsewhere in the future, move this to EnumTier. - for(Tier tier : Tier.values()){ - if(tier.getUnlocalisedName().equals(string)){ - tiers.add(tier); - continue jsonarray; - } - } - // If the string does not match any of the tiers, throws an exception. - throw new JsonSyntaxException("Unknown tier \'" + string + "\'"); - } - } - - if(object.has("elements")){ - - // Vanilla Minecraft calls Lists.newArrayList() here, which is completely pointless. - elements = new ArrayList(); + if(function.elements != null && !function.elements.isEmpty()){ - jsonarray: - for(JsonElement jelement : JsonUtils.getJsonArray(object, "elements", new JsonArray())){ - - String string = JsonUtils.getString(jelement, "element"); - - // IDEA: If it is necessary to get elements by name elsewhere in the future, move this to EnumElement. - for(Element element : Element.values()){ - if(element.getUnlocalisedName().equals(string)){ - elements.add(element); - continue jsonarray; - } - } - // If the string does not match any of the elements, throws an exception. - throw new JsonSyntaxException("Unknown element \'" + string + "\'"); - } - } + JsonArray jsonarray = new JsonArray(); - return new RandomSpell(conditions, spells, ignoreWeighting, tiers, elements); - } - } + for(Element element : function.elements){ + jsonarray.add(new JsonPrimitive(element.getUnlocalisedName())); + } + + object.add("elements", jsonarray); + } + } + + public RandomSpell deserialize(JsonObject object, JsonDeserializationContext deserializationContext, + LootCondition[] conditions){ + + List spells = null; + List tiers = null; + List elements = null; + + if(object.has("spells")){ + + // Vanilla Minecraft calls Lists.newArrayList() here, which is completely pointless. + spells = new ArrayList(); + + // Importantly, it is necessary to specify a default (the new JsonArray) here because otherwise the + // parameter will be mandatory, and the game will crash if it isn't present. + for(JsonElement element : JsonUtils.getJsonArray(object, "spells", new JsonArray())){ + + String string = JsonUtils.getString(element, "spell"); + + Spell spell = Spell.get(string); + + if(spell == null){ + throw new JsonSyntaxException("Unknown spell \'" + string + "\'"); + } + + spells.add(spell); + } + } + + boolean ignoreWeighting = JsonUtils.getBoolean(object, "ignore_weighting", false); + + if(object.has("tiers")){ + + // Vanilla Minecraft calls Lists.newArrayList() here, which is completely pointless. + tiers = new ArrayList(); + + jsonarray: for(JsonElement element : JsonUtils.getJsonArray(object, "tiers", new JsonArray())){ + + String string = JsonUtils.getString(element, "tier"); + + // IDEA: If it is necessary to get tiers by name elsewhere in the future, move this to EnumTier. + for(Tier tier : Tier.values()){ + if(tier.getUnlocalisedName().equals(string)){ + tiers.add(tier); + continue jsonarray; + } + } + // If the string does not match any of the tiers, throws an exception. + throw new JsonSyntaxException("Unknown tier \'" + string + "\'"); + } + } + + if(object.has("elements")){ + + // Vanilla Minecraft calls Lists.newArrayList() here, which is completely pointless. + elements = new ArrayList(); + + jsonarray: for(JsonElement jelement : JsonUtils.getJsonArray(object, "elements", new JsonArray())){ + + String string = JsonUtils.getString(jelement, "element"); + + // IDEA: If it is necessary to get elements by name elsewhere in the future, move this to + // EnumElement. + for(Element element : Element.values()){ + if(element.getUnlocalisedName().equals(string)){ + elements.add(element); + continue jsonarray; + } + } + // If the string does not match any of the elements, throws an exception. + throw new JsonSyntaxException("Unknown element \'" + string + "\'"); + } + } + + return new RandomSpell(conditions, spells, ignoreWeighting, tiers, elements); + } + } } diff --git a/src/main/java/electroblob/wizardry/loot/WizardSpell.java b/src/main/java/electroblob/wizardry/loot/WizardSpell.java index c52898b5..3609926f 100644 --- a/src/main/java/electroblob/wizardry/loot/WizardSpell.java +++ b/src/main/java/electroblob/wizardry/loot/WizardSpell.java @@ -21,21 +21,22 @@ import net.minecraft.world.storage.loot.functions.LootFunction; /** * Loot function that allows spell books to select a random spell from the spells used by the ISpellCaster that dropped * them. + * * @author Electroblob * @since Wizardry 1.2 */ public class WizardSpell extends LootFunction { - + protected WizardSpell(LootCondition[] conditions){ super(conditions); } @Override public ItemStack apply(ItemStack stack, Random random, LootContext context){ - - if(!(stack.getItem() instanceof ItemSpellBook)) - Wizardry.logger.warn("Applying the wizard_spell loot function to an item that isn't a spell book or scroll."); - + + if(!(stack.getItem() instanceof ItemSpellBook)) Wizardry.logger + .warn("Applying the wizard_spell loot function to an item that isn't a spell book or scroll."); + if(context.getLootedEntity() instanceof ISpellCaster){ List spells = ((ISpellCaster)context.getLootedEntity()).getSpells(); spells.remove(Spells.magic_missile); // Can't drop magic missile @@ -43,23 +44,24 @@ public class WizardSpell extends LootFunction { }else{ Wizardry.logger.warn("Applying the wizard_spell loot function to an entity that isn't a spell caster."); } - + return stack; } - - public static class Serializer extends LootFunction.Serializer{ - - public Serializer(){ - super(new ResourceLocation(Wizardry.MODID, "wizard_spell"), WizardSpell.class); - } - public void serialize(JsonObject object, WizardSpell function, JsonSerializationContext serializationContext){ - - } + public static class Serializer extends LootFunction.Serializer { - public WizardSpell deserialize(JsonObject object, JsonDeserializationContext deserializationContext, LootCondition[] conditions){ - return new WizardSpell(conditions); - } - } + public Serializer(){ + super(new ResourceLocation(Wizardry.MODID, "wizard_spell"), WizardSpell.class); + } + + public void serialize(JsonObject object, WizardSpell function, JsonSerializationContext serializationContext){ + + } + + public WizardSpell deserialize(JsonObject object, JsonDeserializationContext deserializationContext, + LootCondition[] conditions){ + return new WizardSpell(conditions); + } + } } diff --git a/src/main/java/electroblob/wizardry/packet/PacketCastContinuousSpell.java b/src/main/java/electroblob/wizardry/packet/PacketCastContinuousSpell.java index 9ef22bae..35516b63 100644 --- a/src/main/java/electroblob/wizardry/packet/PacketCastContinuousSpell.java +++ b/src/main/java/electroblob/wizardry/packet/PacketCastContinuousSpell.java @@ -8,8 +8,10 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -/** [Server -> Client] This packet is sent when the /cast command is used with a continuous spell, in order to - * sync the relevant variables in {@link electroblob.wizardry.WizardData WizardData}. */ +/** + * [Server -> Client] This packet is sent when the /cast command is used with a continuous spell, in order to + * sync the relevant variables in {@link electroblob.wizardry.WizardData WizardData}. + */ public class PacketCastContinuousSpell implements IMessageHandler { @Override @@ -21,7 +23,7 @@ public class PacketCastContinuousSpell implements IMessageHandler[Server -> Client] This packet is sent when a spell is cast by a player and returns true, and is sent to other +/** + * [Server -> Client] This packet is sent when a spell is cast by a player and returns true, and is sent to other * clients so they can spawn the particles themselves. What sending this packet effectively does is make the * {@link Item#onItemRightClick} method client-consistent just for the item that sends it. Interestingly, * {@link Item#onUsingTick} is client-consistent already, so continuous spells don't need to send packets from there - * (this is probably something to do with eating particles or usage actions). */ + * (this is probably something to do with eating particles or usage actions). + */ public class PacketCastSpell implements IMessageHandler { @Override public IMessage onMessage(Message message, MessageContext ctx){ - + // Just to make sure that the side is correct if(ctx.side.isClient()){ // Using a fully qualified name is a good course of action here; we don't really want to clutter the proxy @@ -44,13 +46,14 @@ public class PacketCastSpell implements IMessageHandler { /** SpellModifiers for the spell */ public SpellModifiers modifiers; /** The hand that is holding the itemstack used to cast the spell. Defaults to MAIN_HAND. */ - public EnumHand hand; + public EnumHand hand; // This constructor is required otherwise you'll get errors (used somewhere in fml through reflection) - public Message(){} + public Message(){ + } public Message(int casterID, EnumHand hand, int spellID, SpellModifiers modifiers){ - + this.casterID = casterID; this.spellID = spellID; this.modifiers = modifiers; @@ -59,7 +62,7 @@ public class PacketCastSpell implements IMessageHandler { @Override public void fromBytes(ByteBuf buf){ - + // The order is important this.casterID = buf.readInt(); this.spellID = buf.readInt(); @@ -70,7 +73,7 @@ public class PacketCastSpell implements IMessageHandler { @Override public void toBytes(ByteBuf buf){ - + buf.writeInt(casterID); buf.writeInt(spellID); this.modifiers.write(buf); diff --git a/src/main/java/electroblob/wizardry/packet/PacketClairvoyance.java b/src/main/java/electroblob/wizardry/packet/PacketClairvoyance.java index f7f350bd..835c97dc 100644 --- a/src/main/java/electroblob/wizardry/packet/PacketClairvoyance.java +++ b/src/main/java/electroblob/wizardry/packet/PacketClairvoyance.java @@ -12,13 +12,14 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -/** [Server -> Client] This packet is sent when a player casts the clairvoyance spell to allow pathing to chunks - * outside the render distance. */ +/** + * [Server -> Client] This packet is sent when a player casts the clairvoyance spell to allow pathing to chunks + * outside the render distance. + */ public class PacketClairvoyance implements IMessageHandler { - + @Override - public IMessage onMessage(Message message, MessageContext ctx) - { + public IMessage onMessage(Message message, MessageContext ctx){ // Just to make sure that the side is correct if(ctx.side.isClient()){ // Using a fully qualified name is a good course of action here; we don't really want to clutter the proxy @@ -38,40 +39,41 @@ public class PacketClairvoyance implements IMessageHandler { public Path path; public float durationMultiplier; - + // This constructor is required otherwise you'll get errors (used somewhere in fml through reflection) - public Message() {} + public Message(){ + } public Message(Path path, float durationMultiplier){ - + this.path = path; this.durationMultiplier = durationMultiplier; } @Override public void fromBytes(ByteBuf buf){ - + // The order is important this.durationMultiplier = buf.readFloat(); - + List points = new ArrayList(); - + while(buf.isReadable()){ points.add(new PathPoint(buf.readInt(), buf.readInt(), buf.readInt())); } - + this.path = new Path(points.toArray(new PathPoint[0])); } @Override public void toBytes(ByteBuf buf){ - + buf.writeFloat(durationMultiplier); - - for(int i=0; i { player.getServerWorld().addScheduledTask(new Runnable(){ - public void run() { + public void run(){ ItemStack wand = player.getHeldItemMainhand(); @@ -62,17 +62,14 @@ public class PacketControlInput implements IMessageHandler { break; } } - } - ); + }); } return null; } public static enum ControlType { - APPLY_BUTTON, - NEXT_SPELL_KEY, - PREVIOUS_SPELL_KEY; + APPLY_BUTTON, NEXT_SPELL_KEY, PREVIOUS_SPELL_KEY; } public static class Message implements IMessage { @@ -80,7 +77,8 @@ public class PacketControlInput implements IMessageHandler { private ControlType controlType; // This constructor is required otherwise you'll get errors (used somewhere in fml through reflection) - public Message() {} + public Message(){ + } public Message(ControlType type){ this.controlType = type; diff --git a/src/main/java/electroblob/wizardry/packet/PacketGlyphData.java b/src/main/java/electroblob/wizardry/packet/PacketGlyphData.java index 7f7191e5..883794d1 100644 --- a/src/main/java/electroblob/wizardry/packet/PacketGlyphData.java +++ b/src/main/java/electroblob/wizardry/packet/PacketGlyphData.java @@ -11,13 +11,14 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -/** [Server -> Client] This packet is sent each time a player joins a world to synchronise the client-side spell - * glyph names with the server-side ones. */ +/** + * [Server -> Client] This packet is sent each time a player joins a world to synchronise the client-side spell + * glyph names with the server-side ones. + */ public class PacketGlyphData implements IMessageHandler { @Override - public IMessage onMessage(Message message, MessageContext ctx) - { + public IMessage onMessage(Message message, MessageContext ctx){ // Just to make sure that the side is correct if(ctx.side.isClient()){ // Using a fully qualified name is a good course of action here; we don't really want to clutter the proxy @@ -41,10 +42,10 @@ public class PacketGlyphData implements IMessageHandler { public List descriptions; // This constructor is required otherwise you'll get errors (used somewhere in fml through reflection) - public Message() {} + public Message(){ + } - public Message(List names, List descriptions) - { + public Message(List names, List descriptions){ this.names = names; this.descriptions = descriptions; } @@ -61,7 +62,7 @@ public class PacketGlyphData implements IMessageHandler { @Override public void toBytes(ByteBuf buf){ - for(int i=0; i[Server -> Client] This packet is sent when an {@link ISpellCaster} casts a spell which returns true, and is +/** + * [Server -> Client] This packet is sent when an {@link ISpellCaster} casts a spell which returns true, and is * sent to clients so they can spawn the particles. Unlike the player packets, this is for both continuous and - * non-continuous spells. */ + * non-continuous spells. + */ public class PacketNPCCastSpell implements IMessageHandler { @Override public IMessage onMessage(Message message, MessageContext ctx){ - + // Just to make sure that the side is correct if(ctx.side.isClient()){ // Using a fully qualified name is a good course of action here; we don't really want to clutter the proxy @@ -47,7 +49,8 @@ public class PacketNPCCastSpell implements IMessageHandler { public EnumHand hand; // This constructor is required otherwise you'll get errors (used somewhere in fml through reflection) - public Message(){} + public Message(){ + } public Message(int casterID, int targetID, EnumHand hand, int spellID, SpellModifiers modifiers){ this.casterID = casterID; diff --git a/src/main/java/electroblob/wizardry/packet/PacketPlayerSync.java b/src/main/java/electroblob/wizardry/packet/PacketPlayerSync.java index d58dfbe4..879db01e 100644 --- a/src/main/java/electroblob/wizardry/packet/PacketPlayerSync.java +++ b/src/main/java/electroblob/wizardry/packet/PacketPlayerSync.java @@ -11,14 +11,15 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -/** [Server -> Client] This packet is sent to synchronise any fields that need synchronising in +/** + * [Server -> Client] This packet is sent to synchronise any fields that need synchronising in * {@link electroblob.wizardry.WizardData WizardData}. This packet is not sent often enough and is too small to warrant - * having separate packets for each field that needs synchronising. */ + * having separate packets for each field that needs synchronising. + */ public class PacketPlayerSync implements IMessageHandler { @Override - public IMessage onMessage(Message message, MessageContext ctx) - { + public IMessage onMessage(Message message, MessageContext ctx){ // Just to make sure that the side is correct if(ctx.side.isClient()){ // Using a fully qualified name is a good course of action here; we don't really want to clutter the proxy @@ -40,7 +41,8 @@ public class PacketPlayerSync implements IMessageHandler { public int selectedMinionID; // This constructor is required otherwise you'll get errors (used somewhere in fml through reflection) - public Message() {} + public Message(){ + } public Message(Set spellsDiscovered2, int selectedMinionID){ this.spellsDiscovered = spellsDiscovered2; diff --git a/src/main/java/electroblob/wizardry/packet/PacketSyncSettings.java b/src/main/java/electroblob/wizardry/packet/PacketSyncSettings.java index bed891c6..7dba0811 100644 --- a/src/main/java/electroblob/wizardry/packet/PacketSyncSettings.java +++ b/src/main/java/electroblob/wizardry/packet/PacketSyncSettings.java @@ -8,8 +8,11 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -/** [Server -> Client] This packet is sent to synchronise the config settings with clients on player login. - * @see Settings */ +/** + * [Server -> Client] This packet is sent to synchronise the config settings with clients on player login. + * + * @see Settings + */ public class PacketSyncSettings implements IMessageHandler { @Override @@ -29,18 +32,18 @@ public class PacketSyncSettings implements IMessageHandler { return null; } - + private static void copySettings(Message message){ Wizardry.settings.firebombIsCraftable = message.settings.firebombIsCraftable; Wizardry.settings.poisonBombIsCraftable = message.settings.poisonBombIsCraftable; Wizardry.settings.smokeBombIsCraftable = message.settings.smokeBombIsCraftable; Wizardry.settings.useAlternateScrollRecipe = message.settings.useAlternateScrollRecipe; Wizardry.settings.discoveryMode = message.settings.discoveryMode; -// Wizardry.settings.maxSpellCommandMultiplier = message.settings.maxSpellCommandMultiplier; -// Wizardry.settings.castCommandName = message.settings.castCommandName; -// Wizardry.settings.discoverspellCommandName = message.settings.discoverspellCommandName; -// Wizardry.settings.allyCommandName = message.settings.allyCommandName; -// Wizardry.settings.alliesCommandName = message.settings.alliesCommandName; + // Wizardry.settings.maxSpellCommandMultiplier = message.settings.maxSpellCommandMultiplier; + // Wizardry.settings.castCommandName = message.settings.castCommandName; + // Wizardry.settings.discoverspellCommandName = message.settings.discoverspellCommandName; + // Wizardry.settings.allyCommandName = message.settings.allyCommandName; + // Wizardry.settings.alliesCommandName = message.settings.alliesCommandName; } public static class Message implements IMessage { @@ -49,7 +52,8 @@ public class PacketSyncSettings implements IMessageHandler { public Settings settings; // This constructor is required otherwise you'll get errors (used somewhere in fml through reflection) - public Message(){} + public Message(){ + } public Message(Settings settings){ this.settings = settings; @@ -66,11 +70,11 @@ public class PacketSyncSettings implements IMessageHandler { settings.smokeBombIsCraftable = buf.readBoolean(); settings.useAlternateScrollRecipe = buf.readBoolean(); settings.discoveryMode = buf.readBoolean(); -// settings.maxSpellCommandMultiplier = buf.readDouble(); -// settings.castCommandName = ByteBufUtils.readUTF8String(buf); -// settings.discoverspellCommandName = ByteBufUtils.readUTF8String(buf); -// settings.allyCommandName = ByteBufUtils.readUTF8String(buf); -// settings.alliesCommandName = ByteBufUtils.readUTF8String(buf); + // settings.maxSpellCommandMultiplier = buf.readDouble(); + // settings.castCommandName = ByteBufUtils.readUTF8String(buf); + // settings.discoverspellCommandName = ByteBufUtils.readUTF8String(buf); + // settings.allyCommandName = ByteBufUtils.readUTF8String(buf); + // settings.alliesCommandName = ByteBufUtils.readUTF8String(buf); } @Override @@ -80,11 +84,11 @@ public class PacketSyncSettings implements IMessageHandler { buf.writeBoolean(settings.smokeBombIsCraftable); buf.writeBoolean(settings.useAlternateScrollRecipe); buf.writeBoolean(settings.discoveryMode); -// buf.writeDouble(settings.maxSpellCommandMultiplier); -// ByteBufUtils.writeUTF8String(buf, settings.castCommandName); -// ByteBufUtils.writeUTF8String(buf, settings.discoverspellCommandName); -// ByteBufUtils.writeUTF8String(buf, settings.allyCommandName); -// ByteBufUtils.writeUTF8String(buf, settings.alliesCommandName); + // buf.writeDouble(settings.maxSpellCommandMultiplier); + // ByteBufUtils.writeUTF8String(buf, settings.castCommandName); + // ByteBufUtils.writeUTF8String(buf, settings.discoverspellCommandName); + // ByteBufUtils.writeUTF8String(buf, settings.allyCommandName); + // ByteBufUtils.writeUTF8String(buf, settings.alliesCommandName); } } } diff --git a/src/main/java/electroblob/wizardry/packet/PacketTransportation.java b/src/main/java/electroblob/wizardry/packet/PacketTransportation.java index 7a7085c8..8f6e5a0e 100644 --- a/src/main/java/electroblob/wizardry/packet/PacketTransportation.java +++ b/src/main/java/electroblob/wizardry/packet/PacketTransportation.java @@ -7,13 +7,14 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -/** [Server -> Client] This packet is sent when a player is teleported due to the transportation spell to spawn - * the particles. */ +/** + * [Server -> Client] This packet is sent when a player is teleported due to the transportation spell to spawn + * the particles. + */ public class PacketTransportation implements IMessageHandler { @Override - public IMessage onMessage(Message message, MessageContext ctx) - { + public IMessage onMessage(Message message, MessageContext ctx){ // Just to make sure that the side is correct if(ctx.side.isClient()){ // Using a fully qualified name is a good course of action here; we don't really want to clutter the proxy @@ -29,29 +30,26 @@ public class PacketTransportation implements IMessageHandler return null; } - public static class Message implements IMessage - { + public static class Message implements IMessage { /** EntityID of the caster */ public int casterID; // This constructor is required otherwise you'll get errors (used somewhere in fml through reflection) - public Message() {} + public Message(){ + } - public Message(int casterID) - { + public Message(int casterID){ this.casterID = casterID; } @Override - public void fromBytes(ByteBuf buf) - { + public void fromBytes(ByteBuf buf){ // The order is important this.casterID = buf.readInt(); } @Override - public void toBytes(ByteBuf buf) - { + public void toBytes(ByteBuf buf){ buf.writeInt(casterID); } } diff --git a/src/main/java/electroblob/wizardry/packet/WizardryPacketHandler.java b/src/main/java/electroblob/wizardry/packet/WizardryPacketHandler.java index dedaead6..ed40e136 100644 --- a/src/main/java/electroblob/wizardry/packet/WizardryPacketHandler.java +++ b/src/main/java/electroblob/wizardry/packet/WizardryPacketHandler.java @@ -8,11 +8,10 @@ import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.relauncher.Side; public class WizardryPacketHandler { - + public static SimpleNetworkWrapper net; - - public static void initPackets() - { + + public static void initPackets(){ net = NetworkRegistry.INSTANCE.newSimpleChannel(Wizardry.MODID.toUpperCase()); registerMessage(PacketControlInput.class, PacketControlInput.Message.class); registerMessage(PacketCastSpell.class, PacketCastSpell.Message.class); @@ -24,11 +23,11 @@ public class WizardryPacketHandler { registerMessage(PacketSyncSettings.class, PacketSyncSettings.Message.class); registerMessage(PacketNPCCastSpell.class, PacketNPCCastSpell.Message.class); } - + private static int nextPacketId = 0; - - private static void registerMessage(Class> packet, Class message) - { + + private static void registerMessage( + Class> packet, Class message){ net.registerMessage(packet, message, nextPacketId, Side.CLIENT); net.registerMessage(packet, message, nextPacketId, Side.SERVER); nextPacketId++; diff --git a/src/main/java/electroblob/wizardry/potion/ICustomPotionParticles.java b/src/main/java/electroblob/wizardry/potion/ICustomPotionParticles.java index dcb19997..8bc4a30c 100644 --- a/src/main/java/electroblob/wizardry/potion/ICustomPotionParticles.java +++ b/src/main/java/electroblob/wizardry/potion/ICustomPotionParticles.java @@ -8,16 +8,18 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; /** * Interface for potion effects that spawn custom particles instead of (or as well as) the vanilla 'swirly' particles. + * * @author Electroblob * @since Wizardry 1.2 */ // TODO: Backport. @Mod.EventBusSubscriber public interface ICustomPotionParticles { - + /** * Called from the event handler to spawn a single custom potion particle. To get an instance of * Random inside this method, use world.rand. + * * @param world The world to spawn the particle in. * @param x The x coordinate of the particle, already set to a random value within the entity's bounding box. * @param y The y coordinate of the particle, already set to a random value within the entity's bounding box. @@ -27,17 +29,21 @@ public interface ICustomPotionParticles { @SubscribeEvent public static void onLivingUpdateEvent(LivingUpdateEvent event){ - if(event.getEntityLiving().worldObj.isRemote){ + if(event.getEntityLiving().world.isRemote){ // Behold the power of interfaces! for(PotionEffect effect : event.getEntityLiving().getActivePotionEffects()){ if(effect.getPotion() instanceof ICustomPotionParticles && effect.doesShowParticles()){ - double x = event.getEntityLiving().posX + (event.getEntityLiving().worldObj.rand.nextDouble() - 0.5)*event.getEntityLiving().width; - double y = event.getEntityLiving().getEntityBoundingBox().minY + event.getEntityLiving().worldObj.rand.nextDouble()*event.getEntityLiving().height; - double z = event.getEntityLiving().posZ + (event.getEntityLiving().worldObj.rand.nextDouble() - 0.5)*event.getEntityLiving().width; + double x = event.getEntityLiving().posX + + (event.getEntityLiving().world.rand.nextDouble() - 0.5) * event.getEntityLiving().width; + double y = event.getEntityLiving().getEntityBoundingBox().minY + + event.getEntityLiving().world.rand.nextDouble() * event.getEntityLiving().height; + double z = event.getEntityLiving().posZ + + (event.getEntityLiving().world.rand.nextDouble() - 0.5) * event.getEntityLiving().width; - ((ICustomPotionParticles)effect.getPotion()).spawnCustomParticle(event.getEntityLiving().worldObj, x, y, z); + ((ICustomPotionParticles)effect.getPotion()).spawnCustomParticle(event.getEntityLiving().world, x, + y, z); } } } diff --git a/src/main/java/electroblob/wizardry/potion/PotionDecay.java b/src/main/java/electroblob/wizardry/potion/PotionDecay.java index 6e767866..ee6b9e96 100644 --- a/src/main/java/electroblob/wizardry/potion/PotionDecay.java +++ b/src/main/java/electroblob/wizardry/potion/PotionDecay.java @@ -17,32 +17,34 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class PotionDecay extends Potion { - + private static final ResourceLocation ICON = new ResourceLocation(Wizardry.MODID, "textures/gui/decay_icon.png"); - public PotionDecay(boolean isBadEffect, int liquidColour) { + public PotionDecay(boolean isBadEffect, int liquidColour){ super(isBadEffect, liquidColour); // This needs to be here because registerPotionAttributeModifier doesn't like it if the potion has no name yet. this.setPotionName("potion.wizardry:decay"); - this.registerPotionAttributeModifier(SharedMonsterAttributes.MOVEMENT_SPEED, "85602e0b-4801-4a87-94f3-bf617c97014e", -Constants.DECAY_SLOWNESS_PER_LEVEL, 2); + this.registerPotionAttributeModifier(SharedMonsterAttributes.MOVEMENT_SPEED, + "85602e0b-4801-4a87-94f3-bf617c97014e", -Constants.DECAY_SLOWNESS_PER_LEVEL, 2); } - + @Override - public boolean isReady(int p_76397_1_, int p_76397_2_) { + public boolean isReady(int p_76397_1_, int p_76397_2_){ // Copied from the vanilla wither effect. It does the timing stuff. 25 is the number of ticks between hits at // amplifier 0 int k = 25 >> p_76397_2_; return k > 0 ? p_76397_1_ % k == 0 : true; } - + @Override - public void performEffect(EntityLivingBase target, int strength) { - - target.attackEntityFrom(DamageSource.wither, 1); - + public void performEffect(EntityLivingBase target, int strength){ + + target.attackEntityFrom(DamageSource.WITHER, 1); + if(target.onGround && target.ticksExisted % Constants.DECAY_SPREAD_INTERVAL == 0){ - List entities = target.worldObj.getEntitiesWithinAABBExcludingEntity(target, target.getEntityBoundingBox()); + List entities = target.world.getEntitiesWithinAABBExcludingEntity(target, + target.getEntityBoundingBox()); boolean flag = true; @@ -51,22 +53,23 @@ public class PotionDecay extends Potion { } if(flag){ - // The victim spreading the decay is the 'caster' here, so that it can actually wear off, otherwise it just gets infected with its own decay and the effect lasts forever. - target.worldObj.spawnEntityInWorld(new EntityDecay(target.worldObj, target.posX, target.posY, target.posZ, target)); + // The victim spreading the decay is the 'caster' here, so that it can actually wear off, otherwise it + // just gets infected with its own decay and the effect lasts forever. + target.world.spawnEntity(new EntityDecay(target.world, target.posX, target.posY, target.posZ, target)); } } - } - + } + @Override @SideOnly(Side.CLIENT) - public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc) { - mc.renderEngine.bindTexture(ICON); - WizardryUtilities.drawTexturedRect(x + 6, y + 7, 0, 0, 18, 18, 18, 18); - } - + public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc){ + mc.renderEngine.bindTexture(ICON); + WizardryUtilities.drawTexturedRect(x + 6, y + 7, 0, 0, 18, 18, 18, 18); + } + @Override @SideOnly(Side.CLIENT) - public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha) { + public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha){ mc.renderEngine.bindTexture(ICON); WizardryUtilities.drawTexturedRect(x + 3, y + 3, 0, 0, 18, 18, 18, 18); } diff --git a/src/main/java/electroblob/wizardry/potion/PotionFrost.java b/src/main/java/electroblob/wizardry/potion/PotionFrost.java index 152adfab..7dc4bf92 100644 --- a/src/main/java/electroblob/wizardry/potion/PotionFrost.java +++ b/src/main/java/electroblob/wizardry/potion/PotionFrost.java @@ -19,38 +19,40 @@ import net.minecraftforge.fml.relauncher.SideOnly; @Mod.EventBusSubscriber public class PotionFrost extends Potion implements ICustomPotionParticles { - + private static final ResourceLocation ICON = new ResourceLocation(Wizardry.MODID, "textures/gui/frost_icon.png"); - public PotionFrost(boolean isBadEffect, int liquidColour) { + public PotionFrost(boolean isBadEffect, int liquidColour){ super(isBadEffect, liquidColour); // This needs to be here because registerPotionAttributeModifier doesn't like it if the potion has no name yet. this.setPotionName("potion.wizardry:frost"); // With -0.5 as the 'amount', frost 1 slows the entity down by a half and frost 2 roots it to the spot - this.registerPotionAttributeModifier(SharedMonsterAttributes.MOVEMENT_SPEED, "35dded48-2f19-4541-8510-b29e2dc2cd51", -Constants.FROST_SLOWNESS_PER_LEVEL, 2); + this.registerPotionAttributeModifier(SharedMonsterAttributes.MOVEMENT_SPEED, + "35dded48-2f19-4541-8510-b29e2dc2cd51", -Constants.FROST_SLOWNESS_PER_LEVEL, 2); // More UUIDs: 85602e0b-4801-4a87-94f3-bf617c97014e } @Override - public void performEffect(EntityLivingBase entitylivingbase, int strength) { + public void performEffect(EntityLivingBase entitylivingbase, int strength){ // Nothing here because this potion works on attribute modifiers. - } + } @Override - public void spawnCustomParticle(World world, double x, double y, double z) { - Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, x, y, z, 0, -0.02, 0, 15 + world.rand.nextInt(5)); + public void spawnCustomParticle(World world, double x, double y, double z){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, x, y, z, 0, -0.02, 0, + 15 + world.rand.nextInt(5)); } - + @Override @SideOnly(Side.CLIENT) - public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc) { - mc.renderEngine.bindTexture(ICON); - WizardryUtilities.drawTexturedRect(x + 6, y + 7, 0, 0, 18, 18, 18, 18); - } - + public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc){ + mc.renderEngine.bindTexture(ICON); + WizardryUtilities.drawTexturedRect(x + 6, y + 7, 0, 0, 18, 18, 18, 18); + } + @Override @SideOnly(Side.CLIENT) - public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha) { + public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha){ mc.renderEngine.bindTexture(ICON); WizardryUtilities.drawTexturedRect(x + 3, y + 3, 0, 0, 18, 18, 18, 18); } @@ -59,7 +61,8 @@ public class PotionFrost extends Potion implements ICustomPotionParticles { public static void onBreakSpeedEvent(BreakSpeed event){ if(event.getEntityPlayer().isPotionActive(WizardryPotions.frost)){ // Amplifier + 1 because it starts at 0 - event.setNewSpeed(event.getOriginalSpeed() * (1 - Constants.FROST_FATIGUE_PER_LEVEL*(event.getEntityPlayer().getActivePotionEffect(WizardryPotions.frost).getAmplifier() + 1))); + event.setNewSpeed(event.getOriginalSpeed() * (1 - Constants.FROST_FATIGUE_PER_LEVEL + * (event.getEntityPlayer().getActivePotionEffect(WizardryPotions.frost).getAmplifier() + 1))); } } diff --git a/src/main/java/electroblob/wizardry/potion/PotionMagicEffect.java b/src/main/java/electroblob/wizardry/potion/PotionMagicEffect.java index bba9a646..02e6bc7a 100644 --- a/src/main/java/electroblob/wizardry/potion/PotionMagicEffect.java +++ b/src/main/java/electroblob/wizardry/potion/PotionMagicEffect.java @@ -11,32 +11,34 @@ import net.minecraftforge.fml.relauncher.SideOnly; /** Class for all potions that work on events only. */ public class PotionMagicEffect extends Potion { - + private static final ResourceLocation ICONS = new ResourceLocation(Wizardry.MODID, "textures/gui/potion_icons.png"); private final int textureIndex; - - public PotionMagicEffect(boolean isBadEffect, int liquidColour, int textureIndex) { + + public PotionMagicEffect(boolean isBadEffect, int liquidColour, int textureIndex){ super(isBadEffect, liquidColour); this.textureIndex = textureIndex; } @Override - public void performEffect(EntityLivingBase entitylivingbase, int strength) { + public void performEffect(EntityLivingBase entitylivingbase, int strength){ // Nothing here because this potion works on events. - } - + } + @Override @SideOnly(Side.CLIENT) - public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc){ - mc.renderEngine.bindTexture(ICONS); - WizardryUtilities.drawTexturedRect(x + 6, y + 7, 18*(textureIndex%4), 18*(textureIndex/4), 18, 18, 72, 72); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha) { + public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc){ mc.renderEngine.bindTexture(ICONS); - WizardryUtilities.drawTexturedRect(x + 3, y + 3, 18*(textureIndex%4), 18*(textureIndex/4), 18, 18, 72, 72); + WizardryUtilities.drawTexturedRect(x + 6, y + 7, 18 * (textureIndex % 4), 18 * (textureIndex / 4), 18, 18, 72, + 72); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha){ + mc.renderEngine.bindTexture(ICONS); + WizardryUtilities.drawTexturedRect(x + 3, y + 3, 18 * (textureIndex % 4), 18 * (textureIndex / 4), 18, 18, 72, + 72); } } diff --git a/src/main/java/electroblob/wizardry/potion/PotionMagicEffectParticles.java b/src/main/java/electroblob/wizardry/potion/PotionMagicEffectParticles.java index b9eac023..8112a43b 100644 --- a/src/main/java/electroblob/wizardry/potion/PotionMagicEffectParticles.java +++ b/src/main/java/electroblob/wizardry/potion/PotionMagicEffectParticles.java @@ -1,7 +1,9 @@ package electroblob.wizardry.potion; -/** Same as {@link PotionMagicEffect}, but also implements {@link ICustomPotionParticles} to allow anonymous classes - * to extend it and add their own particles. */ +/** + * Same as {@link PotionMagicEffect}, but also implements {@link ICustomPotionParticles} to allow anonymous classes to + * extend it and add their own particles. + */ public abstract class PotionMagicEffectParticles extends PotionMagicEffect implements ICustomPotionParticles { public PotionMagicEffectParticles(boolean isBadEffect, int liquidColour, int textureIndex){ diff --git a/src/main/java/electroblob/wizardry/registry/Spells.java b/src/main/java/electroblob/wizardry/registry/Spells.java index a59e7538..4356d65a 100644 --- a/src/main/java/electroblob/wizardry/registry/Spells.java +++ b/src/main/java/electroblob/wizardry/registry/Spells.java @@ -12,6 +12,7 @@ import net.minecraftforge.fml.common.registry.RegistryBuilder; /** * Class responsible for defining, storing and registering all of wizardry's spells. + * * @author Electroblob * @since Wizardry 2.1 */ @@ -20,7 +21,7 @@ import net.minecraftforge.fml.common.registry.RegistryBuilder; // because it makes the text go bold, but also because it stops anyone fiddling with your fields). "Why would I want to // initialise things within the registry events?", I hear you ask - well, for one, custom registries don't like it if // you haven't created the registry before you start calling constructors of classes extending IForgeRegistryEntry.Impl, -// and secondly, +// and secondly, @ObjectHolder(Wizardry.MODID) @Mod.EventBusSubscriber public final class Spells { @@ -28,16 +29,16 @@ public final class Spells { // This is here because this class is already an event handler. @SubscribeEvent public static void createRegistry(RegistryEvent.NewRegistry event){ - + // Beats me why we need both of these. Surely the type parameter means it already knows? RegistryBuilder builder = new RegistryBuilder(); builder.setType(Spell.class); builder.setName(new ResourceLocation(Wizardry.MODID, "spells")); builder.setIDRange(0, 5000); // Is there any penalty for using a larger number? - + Spell.registry = builder.create(); } - + // Wizardry 1.0 spells public static final Spell none = null; @@ -53,7 +54,7 @@ public final class Spells { public static final Spell light = null; public static final Spell telekinesis = null; public static final Spell heal = null; - + public static final Spell fireball = null; public static final Spell flame_ray = null; public static final Spell firebomb = null; @@ -160,7 +161,7 @@ public final class Spells { public static final Spell smoke_bomb = null; public static final Spell mind_trick = null; public static final Spell leap = null; - + public static final Spell pocket_furnace = null; public static final Spell intimidate = null; public static final Spell banish = null; @@ -171,7 +172,7 @@ public final class Spells { public static final Spell imbue_weapon = null; public static final Spell invigorating_presence = null; public static final Spell oakflesh = null; - + public static final Spell greater_fireball = null; public static final Spell flaming_weapon = null; public static final Spell ice_lance = null; @@ -190,12 +191,12 @@ public final class Spells { public static final Spell summon_storm_elemental = null; public static final Spell earthquake = null; public static final Spell font_of_mana = null; - + @SubscribeEvent public static void register(RegistryEvent.Register event){ - + IForgeRegistry registry = event.getRegistry(); - + // event.getRegistry should always equal Spell.registry. registry.register(new None()); registry.register(new MagicMissile()); @@ -210,7 +211,7 @@ public final class Spells { registry.register(new Light()); registry.register(new Telekinesis()); registry.register(new Heal()); - + registry.register(new Fireball()); registry.register(new FlameRay()); registry.register(new Firebomb()); @@ -317,7 +318,7 @@ public final class Spells { registry.register(new SmokeBomb()); registry.register(new MindTrick()); registry.register(new Leap()); - + registry.register(new PocketFurnace()); registry.register(new Intimidate()); registry.register(new Banish()); @@ -328,7 +329,7 @@ public final class Spells { registry.register(new ImbueWeapon()); registry.register(new InvigoratingPresence()); registry.register(new Oakflesh()); - + registry.register(new GreaterFireball()); registry.register(new FlamingWeapon()); registry.register(new IceLance()); diff --git a/src/main/java/electroblob/wizardry/registry/WizardryAchievements.java b/src/main/java/electroblob/wizardry/registry/WizardryAchievements.java index 2e3ab165..f5a5ed46 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardryAchievements.java +++ b/src/main/java/electroblob/wizardry/registry/WizardryAchievements.java @@ -8,40 +8,66 @@ import net.minecraftforge.common.AchievementPage; /** * Class responsible for defining, storing and registering all of wizardry's achievements (achievements don't have a * registry, but it make sense to do them the same way as everything else). + * * @author Electroblob * @since Wizardry 2.1 */ public final class WizardryAchievements { - public static final Achievement crystal = new Achievement("crystal", "crystal", -1, -1, WizardryItems.magic_crystal, null).registerStat(); - public static final Achievement arcane_initiate = new Achievement("arcane_initiate", "arcane_initiate", 2, -1, WizardryItems.magic_wand, crystal).registerStat(); - public static final Achievement apprentice = new Achievement("apprentice", "apprentice", 2, 3, WizardryItems.apprentice_wand, arcane_initiate).registerStat(); - public static final Achievement master = new Achievement("master", "master", 3, 6, WizardryItems.master_wand, apprentice).registerStat(); - public static final Achievement all_spells = new Achievement("all_spells", "all_spells", 5, 7, WizardryItems.wizard_handbook, master).registerStat().setSpecial(); - public static final Achievement wizard_trade = new Achievement("wizard_trade", "wizard_trade", 2, -5, Items.EMERALD, arcane_initiate).registerStat(); - public static final Achievement buy_master_spell = new Achievement("buy_master_spell", "buy_master_spell", 5, -5, WizardryItems.spell_book, wizard_trade).registerStat().setSpecial(); - public static final Achievement freeze_blaze = new Achievement("freeze_blaze", "freeze_blaze", -1, 3, Blocks.ICE, apprentice).registerStat(); - public static final Achievement charge_creeper = new Achievement("charge_creeper", "charge_creeper", -1, 1, Items.GUNPOWDER, arcane_initiate).registerStat(); - public static final Achievement frankenstein = new Achievement("frankenstein", "frankenstein", -3, 1, WizardryItems.advanced_lightning_wand, charge_creeper).registerStat().setSpecial(); - public static final Achievement special_upgrade = new Achievement("special_upgrade", "special_upgrade", 4, 1, WizardryItems.condenser_upgrade, arcane_initiate).registerStat(); - public static final Achievement craft_flask = new Achievement("craft_flask", "craft_flask", 4, -2, WizardryItems.mana_flask, arcane_initiate).registerStat(); - public static final Achievement elemental = new Achievement("elemental", "elemental", 6, -1, WizardryItems.basic_fire_wand, arcane_initiate).registerStat(); - public static final Achievement armour_set = new Achievement("armour_set", "armour_set", 0, -4, WizardryItems.wizard_hat, arcane_initiate).registerStat(); - public static final Achievement legendary = new Achievement("legendary", "legendary", -2, -5, WizardryItems.armour_upgrade, armour_set).registerStat().setSpecial(); - public static final Achievement self_destruct = new Achievement("self_destruct", "self_destruct", 1, 0, Blocks.PUMPKIN, arcane_initiate).registerStat(); - public static final Achievement pig_tornado = new Achievement("pig_tornado", "pig_tornado", 6, 3, Items.SADDLE, apprentice).registerStat().setSpecial(); - public static final Achievement jam_wizard = new Achievement("jam_wizard", "jam_wizard", 4, 4, Blocks.WEB, apprentice).registerStat(); - public static final Achievement slime_skeleton = new Achievement("slime_skeleton", "slime_skeleton", 1, 5, Items.SLIME_BALL, apprentice).registerStat(); - public static final Achievement anger_wizard = new Achievement("anger_wizard", "anger_wizard", 1, -7, Items.IRON_SWORD, wizard_trade).registerStat(); - public static final Achievement defeat_evil_wizard = new Achievement("defeat_evil_wizard", "defeat_evil_wizard", 4, -7, WizardryItems.wizard_boots_necromancy, wizard_trade).registerStat(); - public static final Achievement max_out_wand = new Achievement("max_out_wand", "max_out_wand", 7, 1, WizardryItems.arcane_tome, special_upgrade).registerStat().setSpecial(); - public static final Achievement element_master = new Achievement("element_master", "element_master", 7, -3, WizardryItems.master_ice_wand, elemental).registerStat().setSpecial(); - public static final Achievement identify_spell = new Achievement("identify_spell", "identify_spell", -2, -3, WizardryItems.identification_scroll, arcane_initiate).registerStat(); - - private static final Achievement[] ACHIEVEMENTS_LIST = {crystal, arcane_initiate, apprentice, master, all_spells, wizard_trade, buy_master_spell, freeze_blaze, charge_creeper, - frankenstein, special_upgrade, craft_flask, elemental, armour_set, legendary, self_destruct, pig_tornado, jam_wizard, slime_skeleton, anger_wizard, defeat_evil_wizard, - max_out_wand, element_master, identify_spell}; - + public static final Achievement crystal = new Achievement("crystal", "crystal", -1, -1, WizardryItems.magic_crystal, + null).registerStat(); + public static final Achievement arcane_initiate = new Achievement("arcane_initiate", "arcane_initiate", 2, -1, + WizardryItems.magic_wand, crystal).registerStat(); + public static final Achievement apprentice = new Achievement("apprentice", "apprentice", 2, 3, + WizardryItems.apprentice_wand, arcane_initiate).registerStat(); + public static final Achievement master = new Achievement("master", "master", 3, 6, WizardryItems.master_wand, + apprentice).registerStat(); + public static final Achievement all_spells = new Achievement("all_spells", "all_spells", 5, 7, + WizardryItems.wizard_handbook, master).registerStat().setSpecial(); + public static final Achievement wizard_trade = new Achievement("wizard_trade", "wizard_trade", 2, -5, Items.EMERALD, + arcane_initiate).registerStat(); + public static final Achievement buy_master_spell = new Achievement("buy_master_spell", "buy_master_spell", 5, -5, + WizardryItems.spell_book, wizard_trade).registerStat().setSpecial(); + public static final Achievement freeze_blaze = new Achievement("freeze_blaze", "freeze_blaze", -1, 3, Blocks.ICE, + apprentice).registerStat(); + public static final Achievement charge_creeper = new Achievement("charge_creeper", "charge_creeper", -1, 1, + Items.GUNPOWDER, arcane_initiate).registerStat(); + public static final Achievement frankenstein = new Achievement("frankenstein", "frankenstein", -3, 1, + WizardryItems.advanced_lightning_wand, charge_creeper).registerStat().setSpecial(); + public static final Achievement special_upgrade = new Achievement("special_upgrade", "special_upgrade", 4, 1, + WizardryItems.condenser_upgrade, arcane_initiate).registerStat(); + public static final Achievement craft_flask = new Achievement("craft_flask", "craft_flask", 4, -2, + WizardryItems.mana_flask, arcane_initiate).registerStat(); + public static final Achievement elemental = new Achievement("elemental", "elemental", 6, -1, + WizardryItems.basic_fire_wand, arcane_initiate).registerStat(); + public static final Achievement armour_set = new Achievement("armour_set", "armour_set", 0, -4, + WizardryItems.wizard_hat, arcane_initiate).registerStat(); + public static final Achievement legendary = new Achievement("legendary", "legendary", -2, -5, + WizardryItems.armour_upgrade, armour_set).registerStat().setSpecial(); + public static final Achievement self_destruct = new Achievement("self_destruct", "self_destruct", 1, 0, + Blocks.PUMPKIN, arcane_initiate).registerStat(); + public static final Achievement pig_tornado = new Achievement("pig_tornado", "pig_tornado", 6, 3, Items.SADDLE, + apprentice).registerStat().setSpecial(); + public static final Achievement jam_wizard = new Achievement("jam_wizard", "jam_wizard", 4, 4, Blocks.WEB, + apprentice).registerStat(); + public static final Achievement slime_skeleton = new Achievement("slime_skeleton", "slime_skeleton", 1, 5, + Items.SLIME_BALL, apprentice).registerStat(); + public static final Achievement anger_wizard = new Achievement("anger_wizard", "anger_wizard", 1, -7, + Items.IRON_SWORD, wizard_trade).registerStat(); + public static final Achievement defeat_evil_wizard = new Achievement("defeat_evil_wizard", "defeat_evil_wizard", 4, + -7, WizardryItems.wizard_boots_necromancy, wizard_trade).registerStat(); + public static final Achievement max_out_wand = new Achievement("max_out_wand", "max_out_wand", 7, 1, + WizardryItems.arcane_tome, special_upgrade).registerStat().setSpecial(); + public static final Achievement element_master = new Achievement("element_master", "element_master", 7, -3, + WizardryItems.master_ice_wand, elemental).registerStat().setSpecial(); + public static final Achievement identify_spell = new Achievement("identify_spell", "identify_spell", -2, -3, + WizardryItems.identification_scroll, arcane_initiate).registerStat(); + + private static final Achievement[] ACHIEVEMENTS_LIST = {crystal, arcane_initiate, apprentice, master, all_spells, + wizard_trade, buy_master_spell, freeze_blaze, charge_creeper, frankenstein, special_upgrade, craft_flask, + elemental, armour_set, legendary, self_destruct, pig_tornado, jam_wizard, slime_skeleton, anger_wizard, + defeat_evil_wizard, max_out_wand, element_master, identify_spell}; + public static final AchievementPage WIZARDRY_ACHIEVEMENT_PAGE = new AchievementPage("Wizardry", ACHIEVEMENTS_LIST); - + } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/registry/WizardryBlocks.java b/src/main/java/electroblob/wizardry/registry/WizardryBlocks.java index b1efa21a..275f4fd1 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardryBlocks.java +++ b/src/main/java/electroblob/wizardry/registry/WizardryBlocks.java @@ -19,63 +19,73 @@ import net.minecraftforge.fml.common.registry.IForgeRegistry; /** * Class responsible for defining, storing and registering all of wizardry's blocks. + * * @author Electroblob * @since Wizardry 2.1 */ @Mod.EventBusSubscriber public final class WizardryBlocks { - - // I get registry events, they make sense - even I doubted myself with when to do various things in the load process, + + // I get registry events, they make sense - even I doubted myself with when to do various things in the load + // process, // so I can see why the folks at Forge wanted to save us having to think about it. // What I do not understand is why you would use @ObjectHolder for your own blocks and items. What's the point in // making your code longer and more complicated, when you can just define the blocks as constants and register them // later? - + // Found a very nice way of registering things using arrays, which might make @ObjectHolder actually useful. // http://www.minecraftforge.net/forum/topic/49497-1112-is-using-registryevent-this-way-ok/ // Anything set to use the material 'air' will not render, even with a TESR! // setSoundType should be public, but in this particular version it isn't... which is a bit of a pain. - - public static final Block arcane_workbench = new BlockArcaneWorkbench().setHardness(1.0F).setCreativeTab(WizardryTabs.WIZARDRY); - public static final Block crystal_ore = new BlockCrystalOre(Material.ROCK).setHardness(3.0F).setCreativeTab(WizardryTabs.WIZARDRY); + + public static final Block arcane_workbench = new BlockArcaneWorkbench().setHardness(1.0F) + .setCreativeTab(WizardryTabs.WIZARDRY); + public static final Block crystal_ore = new BlockCrystalOre(Material.ROCK).setHardness(3.0F) + .setCreativeTab(WizardryTabs.WIZARDRY); public static final Block petrified_stone = new BlockStatue(Material.ROCK).setHardness(1.5F).setResistance(10.0F); public static final Block ice_statue = new BlockStatue(Material.ICE).setHardness(0.5F).setLightOpacity(3); public static final Block magic_light = new BlockMagicLight(Material.CIRCUITS); - public static final Block crystal_flower = new BlockCrystalFlower(Material.PLANTS).setHardness(0.0F).setCreativeTab(WizardryTabs.WIZARDRY); + public static final Block crystal_flower = new BlockCrystalFlower(Material.PLANTS).setHardness(0.0F) + .setCreativeTab(WizardryTabs.WIZARDRY); public static final Block snare = new BlockSnare(Material.PLANTS).setHardness(0.0F); - public static final Block transportation_stone = new BlockTransportationStone(Material.ROCK).setHardness(0.0F).setLightLevel(0.5f).setLightOpacity(0).setCreativeTab(WizardryTabs.WIZARDRY); - public static final Block spectral_block = new BlockSpectral(Material.GLASS).setLightLevel(0.7f).setLightOpacity(0).setBlockUnbreakable().setResistance(6000000.0F); - public static final Block crystal_block = new Block(Material.IRON).setHardness(5.0F).setResistance(10.0F).setCreativeTab(WizardryTabs.WIZARDRY); + public static final Block transportation_stone = new BlockTransportationStone(Material.ROCK).setHardness(0.0F) + .setLightLevel(0.5f).setLightOpacity(0).setCreativeTab(WizardryTabs.WIZARDRY); + public static final Block spectral_block = new BlockSpectral(Material.GLASS).setLightLevel(0.7f).setLightOpacity(0) + .setBlockUnbreakable().setResistance(6000000.0F); + public static final Block crystal_block = new Block(Material.IRON).setHardness(5.0F).setResistance(10.0F) + .setCreativeTab(WizardryTabs.WIZARDRY); public static final Block meteor = new Block(Material.ROCK).setLightLevel(1); - public static final Block vanishing_cobweb = new BlockVanishingCobweb(Material.WEB).setLightOpacity(1).setHardness(4.0F); + public static final Block vanishing_cobweb = new BlockVanishingCobweb(Material.WEB).setLightOpacity(1) + .setHardness(4.0F); - static { + static{ // This is here because Block#setHarvestLevel isn't chainable. crystal_block.setHarvestLevel("pickaxe", 2); } - + /** * Sets both the registry and unlocalised names of the given block, then registers it with the given registry. Use * this instead of {@link Block#setRegistryName(String)} and {@link Block#setUnlocalizedName(String)} during * construction, for convenience and consistency. + * * @param registry The registry to register the given block to. * @param item The block to register. * @param name The name of the block, without the mod ID or the .name stuff. The registry name will be - * {@code wizardry:[name]}. The unlocalised name will be {@code tile.wizardry:[name].name}. + * {@code wizardry:[name]}. The unlocalised name will be {@code tile.wizardry:[name].name}. */ public static void registerBlock(IForgeRegistry registry, Block block, String name){ block.setRegistryName(Wizardry.MODID, name); block.setUnlocalizedName(block.getRegistryName().toString()); registry.register(block); } - + @SubscribeEvent public static void register(RegistryEvent.Register event){ - + IForgeRegistry registry = event.getRegistry(); - + registerBlock(registry, arcane_workbench, "arcane_workbench"); registerBlock(registry, crystal_ore, "crystal_ore"); registerBlock(registry, petrified_stone, "petrified_stone"); diff --git a/src/main/java/electroblob/wizardry/registry/WizardryEnchantments.java b/src/main/java/electroblob/wizardry/registry/WizardryEnchantments.java index e34ca427..09288bb2 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardryEnchantments.java +++ b/src/main/java/electroblob/wizardry/registry/WizardryEnchantments.java @@ -10,25 +10,30 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; /** * Class responsible for defining, storing and registering all of wizardry's enchantments. + * * @author Electroblob * @since Wizardry 2.1 */ @Mod.EventBusSubscriber public final class WizardryEnchantments { - - // At the moment these enchantments generate on books in dungeon chests due to a bad bit of code (EnchantRandomly:50). + + // At the moment these enchantments generate on books in dungeon chests due to a bad bit of code + // (EnchantRandomly:50). // No idea how to fix this because I have no way of hooking into that code... removing the enchantments from the // registry works, but breaks everything else! - + // TODO: For the time being, a dynamic solution will have to do, i.e. intercept the book when it is generated and // reassign its enchantment. - + // All of these have custom classes, so the unlocalised name (referred to simply as 'name' for enchantments) is // dealt with inside those classes. - public static final Enchantment magic_sword = new EnchantmentMagicSword().setRegistryName(Wizardry.MODID, "magic_sword"); + public static final Enchantment magic_sword = new EnchantmentMagicSword().setRegistryName(Wizardry.MODID, + "magic_sword"); public static final Enchantment magic_bow = new EnchantmentTimed().setRegistryName(Wizardry.MODID, "magic_bow"); - public static final Enchantment flaming_weapon = new EnchantmentTimed().setRegistryName(Wizardry.MODID, "flaming_weapon"); - public static final Enchantment freezing_weapon = new EnchantmentTimed().setRegistryName(Wizardry.MODID, "freezing_weapon"); + public static final Enchantment flaming_weapon = new EnchantmentTimed().setRegistryName(Wizardry.MODID, + "flaming_weapon"); + public static final Enchantment freezing_weapon = new EnchantmentTimed().setRegistryName(Wizardry.MODID, + "freezing_weapon"); @SubscribeEvent public static void register(RegistryEvent.Register event){ @@ -37,5 +42,5 @@ public final class WizardryEnchantments { event.getRegistry().register(flaming_weapon); event.getRegistry().register(freezing_weapon); } - + } diff --git a/src/main/java/electroblob/wizardry/registry/WizardryItems.java b/src/main/java/electroblob/wizardry/registry/WizardryItems.java index 89b053dd..4490070e 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardryItems.java +++ b/src/main/java/electroblob/wizardry/registry/WizardryItems.java @@ -6,6 +6,8 @@ import java.util.Map; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; +import com.google.common.collect.ImmutableMap; + import electroblob.wizardry.Wizardry; import electroblob.wizardry.constants.Element; import electroblob.wizardry.constants.Tier; @@ -45,6 +47,7 @@ import net.minecraftforge.fml.common.registry.IForgeRegistry; /** * Class responsible for defining, storing and registering all of wizardry's items. Also registers the ItemBlocks for * wizardry's blocks. + * * @author Electroblob * @since Wizardry 2.1 */ @@ -131,8 +134,10 @@ public final class WizardryItems { // Also if they were sold you could buy four from the same wizard - and that's no fun at all!) public static final Item armour_upgrade = new ItemArmourUpgrade(); - public static final ArmorMaterial SILK = EnumHelper.addArmorMaterial("SILK", "wizardry/textures/armour/wizard_armour", - 15, new int[]{2, 5, 4, 2}, 0, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0.0F); + public static final ArmorMaterial SILK = EnumHelper.addArmorMaterial("SILK", + "wizardry/textures/armour/wizard_armour", 15, new int[]{2, 5, 4, 2}, 0, + SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0.0F); + // Saw a post somewhere that said you have to put these in the init methods rather than defining them as constants. // I *think* that's because the post was for a newer Minecraft version, where custom armour has its own renderer or // something, meaning it would be done a lot like the entity rendering registry in ClientProxy. This is all working @@ -182,6 +187,10 @@ public final class WizardryItems { public static final Item spectral_leggings = new ItemSpectralArmour(ArmorMaterial.IRON, 1, EntityEquipmentSlot.LEGS); public static final Item spectral_boots = new ItemSpectralArmour(ArmorMaterial.IRON, 1, EntityEquipmentSlot.FEET); + public static final Map SPECTRAL_ARMOUR_MAP = ImmutableMap.of( + EntityEquipmentSlot.HEAD, spectral_helmet, EntityEquipmentSlot.CHEST, spectral_chestplate, + EntityEquipmentSlot.LEGS, spectral_leggings, EntityEquipmentSlot.FEET, spectral_boots); + public static final Item smoke_bomb = new ItemSmokeBomb(); public static final Item identification_scroll = new ItemIdentificationScroll(); @@ -189,8 +198,8 @@ public final class WizardryItems { public static final Map, Item> WAND_MAP = new HashMap<>(); public static final Map, Item> ARMOUR_MAP = new HashMap<>(); - static { - + static{ + WAND_MAP.put(ImmutablePair.of(Tier.BASIC, Element.MAGIC), magic_wand); WAND_MAP.put(ImmutablePair.of(Tier.BASIC, Element.FIRE), basic_fire_wand); WAND_MAP.put(ImmutablePair.of(Tier.BASIC, Element.ICE), basic_ice_wand); @@ -223,7 +232,7 @@ public final class WizardryItems { WAND_MAP.put(ImmutablePair.of(Tier.MASTER, Element.EARTH), master_earth_wand); WAND_MAP.put(ImmutablePair.of(Tier.MASTER, Element.SORCERY), master_sorcery_wand); WAND_MAP.put(ImmutablePair.of(Tier.MASTER, Element.HEALING), master_healing_wand); - + ARMOUR_MAP.put(ImmutablePair.of(EntityEquipmentSlot.HEAD, Element.MAGIC), wizard_hat); ARMOUR_MAP.put(ImmutablePair.of(EntityEquipmentSlot.HEAD, Element.FIRE), wizard_hat_fire); ARMOUR_MAP.put(ImmutablePair.of(EntityEquipmentSlot.HEAD, Element.ICE), wizard_hat_ice); @@ -262,10 +271,11 @@ public final class WizardryItems { * Sets both the registry and unlocalised names of the given item, then registers it with the given registry. Use * this instead of {@link Item#setRegistryName(String)} and {@link Item#setUnlocalizedName(String)} during * construction, for convenience and consistency. + * * @param registry The registry to register the given item to. * @param item The item to register. * @param name The name of the item, without the mod ID or the .name stuff. The registry name will be - * {@code wizardry:[name]}. The unlocalised name will be {@code item.wizardry:[name].name}. + * {@code wizardry:[name]}. The unlocalised name will be {@code item.wizardry:[name].name}. */ public static void registerItem(IForgeRegistry registry, Item item, String name){ item.setRegistryName(Wizardry.MODID, name); diff --git a/src/main/java/electroblob/wizardry/registry/WizardryPotions.java b/src/main/java/electroblob/wizardry/registry/WizardryPotions.java index 4b51a675..7c8590ea 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardryPotions.java +++ b/src/main/java/electroblob/wizardry/registry/WizardryPotions.java @@ -17,6 +17,7 @@ import net.minecraftforge.fml.common.registry.IForgeRegistry; /** * Class responsible for defining, storing and registering all of wizardry's potion effects. + * * @author Electroblob * @since Wizardry 2.1 */ @@ -25,48 +26,52 @@ public final class WizardryPotions { /* Interestingly, setting the colour to black stops the particles from rendering. This is great, however, the black * colour then 'mixes' with other potions that are applied. Whilst this is a bit annoying, for the amount it is - * likely to get noticed it is certainly preferable to always making showParticles false, because now I can give - * the user the option (via commands) of having one of my potion effects without particles, and more importantly - * the potion effect HUD still gets displayed. TODO: Backport to 1.7.10, assuming it also works in that version. - * This means also changing whenever the potion effect is added such that it is NOT ambient. */ - + * likely to get noticed it is certainly preferable to always making showParticles false, because now I can give the + * user the option (via commands) of having one of my potion effects without particles, and more importantly the + * potion effect HUD still gets displayed. TODO: Backport to 1.7.10, assuming it also works in that version. This + * means also changing whenever the potion effect is added such that it is NOT ambient. */ + public static final Potion frost = new PotionFrost(true, 0); // Colour was 0x38ddec (was arbitrary anyway) - + public static final Potion transience = new PotionMagicEffectParticles(false, 0, 0){ @Override public void spawnCustomParticle(World world, double x, double y, double z){ - Wizardry.proxy.spawnParticle(WizardryParticleType.DUST, world, x, y, z, 0, 0, 0, (int)(16.0D / (Math.random() * 0.8D + 0.2D)), 0.8f, 0.8f, 1.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.DUST, world, x, y, z, 0, 0, 0, + (int)(16.0D / (Math.random() * 0.8D + 0.2D)), 0.8f, 0.8f, 1.0f); } - }.setBeneficial(); //0xffe89b - + }.setBeneficial(); // 0xffe89b + public static final Potion fireskin = new PotionMagicEffectParticles(false, 0, 1){ @Override public void spawnCustomParticle(World world, double x, double y, double z){ world.spawnParticle(EnumParticleTypes.FLAME, x, y, z, 0, 0, 0); } + @Override public void performEffect(EntityLivingBase entitylivingbase, int strength){ entitylivingbase.extinguish(); // Stops melee mobs that are on fire from setting the player on fire, // without allowing the player to actually stand in fire or swim in lava without taking damage. }; - }.setBeneficial(); //0xff2f02 - + }.setBeneficial(); // 0xff2f02 + public static final Potion ice_shroud = new PotionMagicEffectParticles(false, 0, 2){ @Override public void spawnCustomParticle(World world, double x, double y, double z){ - float brightness = 0.5f + (world.rand.nextFloat()/2); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x, y, z, 0, 0, 0, 48 + world.rand.nextInt(12), brightness, brightness + 0.1f, 1.0f, true, 0); - Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, x, y, z, 0, -0.02, 0, 40 + world.rand.nextInt(10)); + float brightness = 0.5f + (world.rand.nextFloat() / 2); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x, y, z, 0, 0, 0, + 48 + world.rand.nextInt(12), brightness, brightness + 0.1f, 1.0f, true, 0); + Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, x, y, z, 0, -0.02, 0, + 40 + world.rand.nextInt(10)); } - }.setBeneficial(); //0x52f1ff - + }.setBeneficial(); // 0x52f1ff + public static final Potion static_aura = new PotionMagicEffectParticles(false, 0, 3){ @Override public void spawnCustomParticle(World world, double x, double y, double z){ Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, x, y, z, 0, 0, 0, 3); } - }.setBeneficial(); //0x0070ff - + }.setBeneficial(); // 0x0070ff + public static final Potion decay = new PotionDecay(true, 0x3c006c); public static final Potion sixth_sense = new PotionMagicEffect(false, 0xc6ff01, 4).setBeneficial(); public static final Potion arcane_jammer = new PotionMagicEffect(false, 0xcf4aa2, 5); @@ -79,10 +84,11 @@ public final class WizardryPotions { * Sets both the registry and unlocalised names of the given potion, then registers it with the given registry. Use * this instead of {@link potion#setRegistryName(String)} and {@link potion#setUnlocalizedName(String)} during * construction, for convenience and consistency. + * * @param registry The registry to register the given potion to. * @param potion The potion to register. * @param name The name of the potion, without the mod ID or the .name stuff. The registry name will be - * {@code wizardry:[name]}. The unlocalised name will be {@code potion.wizardry:[name].name}. + * {@code wizardry:[name]}. The unlocalised name will be {@code potion.wizardry:[name].name}. */ public static void registerPotion(IForgeRegistry registry, Potion potion, String name){ potion.setRegistryName(Wizardry.MODID, name); @@ -90,12 +96,12 @@ public final class WizardryPotions { potion.setPotionName("potion." + potion.getRegistryName().toString()); registry.register(potion); } - + @SubscribeEvent public static void register(RegistryEvent.Register event){ IForgeRegistry registry = event.getRegistry(); - + registerPotion(registry, frost, "frost"); registerPotion(registry, transience, "transience"); registerPotion(registry, fireskin, "fireskin"); diff --git a/src/main/java/electroblob/wizardry/registry/WizardryRegistry.java b/src/main/java/electroblob/wizardry/registry/WizardryRegistry.java index f8103bf1..64872f01 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardryRegistry.java +++ b/src/main/java/electroblob/wizardry/registry/WizardryRegistry.java @@ -83,47 +83,43 @@ import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.oredict.OreDictionary; /** - * Class responsible for registering all the things that don't have (or need) instances: entities, loot tables, - * recipes, etc. + * Class responsible for registering all the things that don't have (or need) instances: entities, loot tables, recipes, + * etc. + * * @author Electroblob * @since Wizardry 1.0 */ public final class WizardryRegistry { - + // NOTE: In 1.12, recipes have a registry (they can still stay here though since we don't keep references to them) - + /** Called from the preInit method in the main mod class to register the custom dungeon loot. */ public static void registerLoot(){ - - /* Loot tables work as follows: - * Minecraft goes through each pool in turn. For each pool, it does a certain number or rolls, which can either - * be set to always be one number or a random number from a range. Each roll, it generates one stack of a single - * random entry in that pool, weighted according to the weights of the entries. Functions allow properties of - * that stack (stack size, damage, nbt) to be set, and even allow it to be replaced dynamically with a - * completely different item (though there's very little point in doing that as it could be achieved just as - * easily with more entries, which makes me think it would be bad practice). - * You can also use conditions to control whether an entry or pool is used at all, which is mostly for mob drops + + /* Loot tables work as follows: Minecraft goes through each pool in turn. For each pool, it does a certain + * number or rolls, which can either be set to always be one number or a random number from a range. Each roll, + * it generates one stack of a single random entry in that pool, weighted according to the weights of the + * entries. Functions allow properties of that stack (stack size, damage, nbt) to be set, and even allow it to + * be replaced dynamically with a completely different item (though there's very little point in doing that as + * it could be achieved just as easily with more entries, which makes me think it would be bad practice). You + * can also use conditions to control whether an entry or pool is used at all, which is mostly for mob drops * under specific conditions, but one of them is simply a random chance, meaning you could use it to make a pool - * that only gets rolled sometimes. - * All in all, this can get rather confusing, because stackable items can have 5 stages of randomness applied - * to them at once: a random chance for the pool, a random number of rolls for the pool, the weighted random - * chance of choosing that particular entry, a random chance for that entry, and a random stack size, and that's - * before you take functions into account. + * that only gets rolled sometimes. All in all, this can get rather confusing, because stackable items can have + * 5 stages of randomness applied to them at once: a random chance for the pool, a random number of rolls for + * the pool, the weighted random chance of choosing that particular entry, a random chance for that entry, and a + * random stack size, and that's before you take functions into account. * * ...oh, and entries can be entire loot tables in themselves, allowing for potentially infinite levels of * randomness. Yeah. * - * Translating to the new system: - * ChestGenHooks.SOME_NAME -> loot table json file - * ??? -> loot pool (I don't think it was split up like this before) - * ChestGenHooks.addItem() -> entry in a loot pool - * Stack sizes in WeightedRandomChestContent -> set_count function for entries - * Weight in WeightedRandomChestContent -> weight of entries - * Custom WeightedRandomChestContent implementations -> custom loot functions, but only for complex/dynamic - * stuff - things that serve to allow the chance for a category of items (like armour) to be specified but still - * have a random chance for which exact item you get should be done with nested loot tables. - */ - + * Translating to the new system: ChestGenHooks.SOME_NAME -> loot table json file ??? -> loot pool (I don't + * think it was split up like this before) ChestGenHooks.addItem() -> entry in a loot pool Stack sizes in + * WeightedRandomChestContent -> set_count function for entries Weight in WeightedRandomChestContent -> weight + * of entries Custom WeightedRandomChestContent implementations -> custom loot functions, but only for + * complex/dynamic stuff - things that serve to allow the chance for a category of items (like armour) to be + * specified but still have a random chance for which exact item you get should be done with nested loot + * tables. */ + // Always registers the loot tables, but only injects the additions into vanilla if the appropriate option is // enabled in the config (see WizardryEventHandler). LootFunctionManager.registerFunction(new RandomSpell.Serializer()); @@ -136,185 +132,250 @@ public final class WizardryRegistry { LootTableList.register(new ResourceLocation(Wizardry.MODID, "subsets/wand_upgrades")); LootTableList.register(new ResourceLocation(Wizardry.MODID, "entities/evil_wizard")); // TODO: At the moment this is not used anywhere because I can't find a way to add it to all mobs. - //LootTableList.register(new ResourceLocation(Wizardry.MODID, "entities/mob_additions")); - + // LootTableList.register(new ResourceLocation(Wizardry.MODID, "entities/mob_additions")); + } - + /** Called from the preInit method in the main mod class to register all the tile entities. */ public static void registerTileEntities(){ - GameRegistry.registerTileEntity(TileEntityArcaneWorkbench.class, Wizardry.MODID + "ArcaneWorkbenchTileEntity"); - GameRegistry.registerTileEntity(TileEntityStatue.class, Wizardry.MODID + "PetrifiedStoneTileEntity"); - GameRegistry.registerTileEntity(TileEntityMagicLight.class, Wizardry.MODID + "MagicLightTileEntity"); - GameRegistry.registerTileEntity(TileEntityTimer.class, Wizardry.MODID + "TimerTileEntity"); - GameRegistry.registerTileEntity(TileEntityPlayerSave.class, Wizardry.MODID + "TileEntityPlayerSave"); + GameRegistry.registerTileEntity(TileEntityArcaneWorkbench.class, Wizardry.MODID + "ArcaneWorkbenchTileEntity"); + GameRegistry.registerTileEntity(TileEntityStatue.class, Wizardry.MODID + "PetrifiedStoneTileEntity"); + GameRegistry.registerTileEntity(TileEntityMagicLight.class, Wizardry.MODID + "MagicLightTileEntity"); + GameRegistry.registerTileEntity(TileEntityTimer.class, Wizardry.MODID + "TimerTileEntity"); + GameRegistry.registerTileEntity(TileEntityPlayerSave.class, Wizardry.MODID + "TileEntityPlayerSave"); } - + /** Not actually the frequency at all; smaller numbers are more frequent. Vanilla uses 3 I think. */ private static final int LIVING_UPDATE_INTERVAL = 3; /** Not actually the frequency at all; smaller numbers are more frequent. */ private static final int PROJECTILE_UPDATE_INTERVAL = 10; - + /** Called from the preInit method in the main mod class to register all the entities. */ public static void registerEntities(Wizardry wizardry){ - - int id = 0; // Incrementable index for the mod specific entity id. - - EntityRegistry.registerModEntity(EntityZombieMinion.class, "zombie_minion", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityMagicMissile.class, "magic_missile", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - // TODO: This should be a particle - EntityRegistry.registerModEntity(EntityArc.class, "arc", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); - EntityRegistry.registerModEntity(EntitySkeletonMinion.class, "skeleton_minion", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntitySparkBomb.class, "spark_bomb", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntitySpiritWolf.class, "spirit_wolf", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityIceShard.class, "ice_shard", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityBlazeMinion.class, "blaze_minion", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityIceWraith.class, "ice_wraith", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityLightningWraith.class, "lightning_wraith", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityBlackHole.class, "black_hole", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); - EntityRegistry.registerModEntity(EntityShield.class, "shield", id++, wizardry, 128, 1, true); - EntityRegistry.registerModEntity(EntityMeteor.class, "meteor", id++, wizardry, 128, 5, true); - EntityRegistry.registerModEntity(EntityBlizzard.class, "blizzard", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); - EntityRegistry.registerModEntity(EntityWizard.class, "wizard", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityBubble.class, "bubble", id++, wizardry, 128, 3, false); - EntityRegistry.registerModEntity(EntityTornado.class, "tornado", id++, wizardry, 128, 1, false); - EntityRegistry.registerModEntity(EntityHammer.class, "lightning_hammer", id++, wizardry, 128, 1, true); - EntityRegistry.registerModEntity(EntityFirebomb.class, "firebomb", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityForceOrb.class, "force_orb", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityArrowRain.class, "arrow_rain", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); - EntityRegistry.registerModEntity(EntitySpark.class, "spark", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityShadowWraith.class, "shadow_wraith", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityDarknessOrb.class, "darkness_orb", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntitySpiderMinion.class, "spider_minion", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityHealAura.class, "healing_aura", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); - EntityRegistry.registerModEntity(EntityFireSigil.class, "fire_sigil", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); - EntityRegistry.registerModEntity(EntityFrostSigil.class, "frost_sigil", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); - EntityRegistry.registerModEntity(EntityLightningSigil.class, "lightning_sigil", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); - EntityRegistry.registerModEntity(EntityLightningArrow.class, "lightning_arrow", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityFirebolt.class, "firebolt", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityPoisonBomb.class, "poison_bomb", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityIceCharge.class, "ice_charge", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityForceArrow.class, "force_arrow", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityDart.class, "dart", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityMagicSlime.class, "magic_slime", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityForcefield.class, "forcefield", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); - EntityRegistry.registerModEntity(EntityFireRing.class, "ring_of_fire", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); - EntityRegistry.registerModEntity(EntityLightningDisc.class, "lightning_disc", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityThunderbolt.class, "thunderbolt", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityIceGiant.class, "ice_giant", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntitySpiritHorse.class, "spirit_horse", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityPhoenix.class, "phoenix", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntitySilverfishMinion.class, "silverfish_minion", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityDecay.class, "decay", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); - EntityRegistry.registerModEntity(EntityStormElemental.class, "storm_elemental", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityEarthquake.class, "earthquake", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); - EntityRegistry.registerModEntity(EntityIceLance.class, "ice_lance", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityHailstorm.class, "hailstorm", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); - EntityRegistry.registerModEntity(EntitySmokeBomb.class, "smoke_bomb", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityEvilWizard.class, "evil_wizard", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityDecoy.class, "decoy", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); - EntityRegistry.registerModEntity(EntityIceSpike.class, "ice_spike", id++, wizardry, 128, 1, true); - // TODO: This should be a particle. - EntityRegistry.registerModEntity(EntityLightningPulse.class, "lightning_pulse", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); - EntityRegistry.registerEgg(EntityWizard.class, 0x19295e, 0xee9312); - EntityRegistry.registerEgg(EntityEvilWizard.class, 0x290404, 0xee9312); - - // TODO: May need fixing - List biomes = new ArrayList(); - for(Biome biome : Biome.EXPLORATION_BIOMES_LIST){ - if(biome != null){ - biomes.add(biome); - } - } - biomes.remove(Biomes.MUSHROOM_ISLAND); - biomes.remove(Biomes.MUSHROOM_ISLAND_SHORE); - // For reference: 5, 1, 1 are the parameters for the witch in vanilla. - EntityRegistry.addSpawn(EntityEvilWizard.class, 3, 1, 1, EnumCreatureType.MONSTER, biomes.toArray(new Biome[biomes.size()])); + ResourceLocation wizardID = new ResourceLocation(Wizardry.MODID, "wizard"); + ResourceLocation evilWizardID = new ResourceLocation(Wizardry.MODID, "evil_wizard"); + + int id = 0; // Incrementable index for the mod specific entity id. + + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "zombie_minion"), + EntityZombieMinion.class, "zombie_minion", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "magic_missile"), + EntityMagicMissile.class, "magic_missile", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + // TODO: This should be a particle + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "arc"), EntityArc.class, "arc", id++, + wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "skeleton_minion"), + EntitySkeletonMinion.class, "skeleton_minion", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "spark_bomb"), EntitySparkBomb.class, + "spark_bomb", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "spirit_wolf"), EntitySpiritWolf.class, + "spirit_wolf", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "ice_shard"), EntityIceShard.class, + "ice_shard", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "blaze_minion"), EntityBlazeMinion.class, + "blaze_minion", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "ice_wraith"), EntityIceWraith.class, + "ice_wraith", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "lightning_wraith"), + EntityLightningWraith.class, "lightning_wraith", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "black_hole"), EntityBlackHole.class, + "black_hole", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "shield"), EntityShield.class, "shield", + id++, wizardry, 128, 1, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "meteor"), EntityMeteor.class, "meteor", + id++, wizardry, 128, 5, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "blizzard"), EntityBlizzard.class, + "blizzard", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); + EntityRegistry.registerModEntity(wizardID, EntityWizard.class, "wizard", id++, wizardry, 128, + LIVING_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "bubble"), EntityBubble.class, "bubble", + id++, wizardry, 128, 3, false); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "tornado"), EntityTornado.class, + "tornado", id++, wizardry, 128, 1, false); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "lightning_hammer"), EntityHammer.class, + "lightning_hammer", id++, wizardry, 128, 1, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "firebomb"), EntityFirebomb.class, + "firebomb", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "force_orb"), EntityForceOrb.class, + "force_orb", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "arrow_rain"), EntityArrowRain.class, + "arrow_rain", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "spark"), EntitySpark.class, "spark", + id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "shadow_wraith"), + EntityShadowWraith.class, "shadow_wraith", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "darkness_orb"), EntityDarknessOrb.class, + "darkness_orb", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "spider_minion"), + EntitySpiderMinion.class, "spider_minion", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "healing_aura"), EntityHealAura.class, + "healing_aura", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "fire_sigil"), EntityFireSigil.class, + "fire_sigil", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "frost_sigil"), EntityFrostSigil.class, + "frost_sigil", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "lightning_sigil"), + EntityLightningSigil.class, "lightning_sigil", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "lightning_arrow"), + EntityLightningArrow.class, "lightning_arrow", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "firebolt"), EntityFirebolt.class, + "firebolt", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "poison_bomb"), EntityPoisonBomb.class, + "poison_bomb", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "ice_charge"), EntityIceCharge.class, + "ice_charge", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "force_arrow"), EntityForceArrow.class, + "force_arrow", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "dart"), EntityDart.class, "dart", id++, + wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "magic_slime"), EntityMagicSlime.class, + "magic_slime", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "forcefield"), EntityForcefield.class, + "forcefield", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "ring_of_fire"), EntityFireRing.class, + "ring_of_fire", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "lightning_disc"), + EntityLightningDisc.class, "lightning_disc", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "thunderbolt"), EntityThunderbolt.class, + "thunderbolt", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "ice_giant"), EntityIceGiant.class, + "ice_giant", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "spirit_horse"), EntitySpiritHorse.class, + "spirit_horse", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "phoenix"), EntityPhoenix.class, + "phoenix", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "silverfish_minion"), + EntitySilverfishMinion.class, "silverfish_minion", id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "decay"), EntityDecay.class, "decay", + id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "storm_elemental"), + EntityStormElemental.class, "storm_elemental", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "earthquake"), EntityEarthquake.class, + "earthquake", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "ice_lance"), EntityIceLance.class, + "ice_lance", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "hailstorm"), EntityHailstorm.class, + "hailstorm", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "smoke_bomb"), EntitySmokeBomb.class, + "smoke_bomb", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(evilWizardID, EntityEvilWizard.class, "evil_wizard", id++, wizardry, 128, + LIVING_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "decoy"), EntityDecoy.class, "decoy", + id++, wizardry, 128, LIVING_UPDATE_INTERVAL, true); + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "ice_spike"), EntityIceSpike.class, + "ice_spike", id++, wizardry, 128, 1, true); + // TODO: This should be a particle. + EntityRegistry.registerModEntity(new ResourceLocation(Wizardry.MODID, "lightning_pulse"), + EntityLightningPulse.class, "lightning_pulse", id++, wizardry, 128, PROJECTILE_UPDATE_INTERVAL, false); + + EntityRegistry.registerEgg(wizardID, 0x19295e, 0xee9312); + EntityRegistry.registerEgg(evilWizardID, 0x290404, 0xee9312); + + // TODO: May need fixing + List biomes = new ArrayList(); + for(Biome biome : Biome.EXPLORATION_BIOMES_LIST){ + if(biome != null){ + biomes.add(biome); + } + } + biomes.remove(Biomes.MUSHROOM_ISLAND); + biomes.remove(Biomes.MUSHROOM_ISLAND_SHORE); + // For reference: 5, 1, 1 are the parameters for the witch in vanilla. + EntityRegistry.addSpawn(EntityEvilWizard.class, 3, 1, 1, EnumCreatureType.MONSTER, + biomes.toArray(new Biome[biomes.size()])); } /** Called from the init method in the main mod class to register all the recipes. */ public static void registerRecipes(){ - ItemStack magicCrystalStack = new ItemStack(WizardryItems.magic_crystal); - ItemStack magicWandStack = new ItemStack(WizardryItems.magic_wand, 1, Tier.BASIC.maxCharge); - ItemStack goldNuggetStack = new ItemStack(Items.GOLD_NUGGET); - ItemStack stickStack = new ItemStack(Items.STICK); - ItemStack bookStack = new ItemStack(Items.BOOK); - ItemStack stringStack = new ItemStack(Items.STRING); - ItemStack spellBookStack = new ItemStack(WizardryItems.spell_book, 1, Spells.magic_missile.id()); - ItemStack arcaneWorkbenchStack = new ItemStack(WizardryBlocks.arcane_workbench); - ItemStack stoneStack = new ItemStack(Blocks.STONE); - ItemStack lapisBlockStack = new ItemStack(Blocks.LAPIS_BLOCK); - ItemStack purpleCarpetStack = new ItemStack(Blocks.CARPET, 1, 10); - ItemStack wizardHandbookStack = new ItemStack(WizardryItems.wizard_handbook); - ItemStack crystalFlowerStack = new ItemStack(WizardryBlocks.crystal_flower); - ItemStack magicCrystalStack1 = new ItemStack(WizardryItems.magic_crystal, 2); - ItemStack magicCrystalStack2 = new ItemStack(WizardryItems.magic_crystal, 9); - ItemStack crystalBlockStack = new ItemStack(WizardryBlocks.crystal_block); - ItemStack manaFlaskStack = new ItemStack(WizardryItems.mana_flask); - ItemStack bottleStack = new ItemStack(Items.GLASS_BOTTLE); - ItemStack gunpowderStack = new ItemStack(Items.GUNPOWDER); - ItemStack blazePowderStack = new ItemStack(Items.BLAZE_POWDER); - ItemStack spiderEyeStack = new ItemStack(Items.SPIDER_EYE); - // Coal or charcoal is equally fine, hence the wildcard value - ItemStack coalStack = new ItemStack(Items.COAL, 1, OreDictionary.WILDCARD_VALUE); - ItemStack firebombStack = new ItemStack(WizardryItems.firebomb, 3); - ItemStack poisonBombStack = new ItemStack(WizardryItems.poison_bomb, 3); - ItemStack smokeBombStack = new ItemStack(WizardryItems.smoke_bomb, 3); - ItemStack transportationStoneStack = new ItemStack(WizardryBlocks.transportation_stone, 2); - ItemStack silkStack = new ItemStack(WizardryItems.magic_silk); - ItemStack silkStack1 = new ItemStack(WizardryItems.magic_silk, 2); - ItemStack hatStack = new ItemStack(WizardryItems.wizard_hat); - ItemStack robeStack = new ItemStack(WizardryItems.wizard_robe); - ItemStack leggingsStack = new ItemStack(WizardryItems.wizard_leggings); - ItemStack bootsStack = new ItemStack(WizardryItems.wizard_boots); - ItemStack scrollStack = new ItemStack(WizardryItems.blank_scroll); - ItemStack paperStack = new ItemStack(Items.PAPER); - - GameRegistry.addRecipe(magicWandStack, " x", " y ", "z ", 'x', magicCrystalStack, 'y', stickStack, 'z', goldNuggetStack); - GameRegistry.addRecipe(spellBookStack, " x ", "xyx", " x ", 'x', magicCrystalStack, 'y', bookStack); - GameRegistry.addRecipe(arcaneWorkbenchStack, "vwv", "xyx", "zzz", 'v', goldNuggetStack, 'w', purpleCarpetStack, 'x', magicCrystalStack, 'y', lapisBlockStack, 'z', stoneStack); - GameRegistry.addRecipe(manaFlaskStack, "yyy", "yxy", "yyy", 'x', bottleStack, 'y', magicCrystalStack); - GameRegistry.addRecipe(transportationStoneStack, " x ", "xyx", " x ", 'x', stoneStack, 'y', magicCrystalStack); - GameRegistry.addRecipe(hatStack, "yyy", "y y", 'y', silkStack); - GameRegistry.addRecipe(robeStack, "y y", "yyy", "yyy", 'y', silkStack); - GameRegistry.addRecipe(leggingsStack, "yyy", "y y", "y y", 'y', silkStack); - GameRegistry.addRecipe(bootsStack, "y y", "y y", 'y', silkStack); - GameRegistry.addRecipe(silkStack1, " x ", "xyx", " x ", 'x', stringStack, 'y', magicCrystalStack); - GameRegistry.addRecipe(crystalBlockStack, "zzz", "zzz", "zzz", 'z', magicCrystalStack); + ItemStack magicCrystalStack = new ItemStack(WizardryItems.magic_crystal); + ItemStack magicWandStack = new ItemStack(WizardryItems.magic_wand, 1, Tier.BASIC.maxCharge); + ItemStack goldNuggetStack = new ItemStack(Items.GOLD_NUGGET); + ItemStack stickStack = new ItemStack(Items.STICK); + ItemStack bookStack = new ItemStack(Items.BOOK); + ItemStack stringStack = new ItemStack(Items.STRING); + ItemStack spellBookStack = new ItemStack(WizardryItems.spell_book, 1, Spells.magic_missile.id()); + ItemStack arcaneWorkbenchStack = new ItemStack(WizardryBlocks.arcane_workbench); + ItemStack stoneStack = new ItemStack(Blocks.STONE); + ItemStack lapisBlockStack = new ItemStack(Blocks.LAPIS_BLOCK); + ItemStack purpleCarpetStack = new ItemStack(Blocks.CARPET, 1, 10); + ItemStack wizardHandbookStack = new ItemStack(WizardryItems.wizard_handbook); + ItemStack crystalFlowerStack = new ItemStack(WizardryBlocks.crystal_flower); + ItemStack magicCrystalStack1 = new ItemStack(WizardryItems.magic_crystal, 2); + ItemStack magicCrystalStack2 = new ItemStack(WizardryItems.magic_crystal, 9); + ItemStack crystalBlockStack = new ItemStack(WizardryBlocks.crystal_block); + ItemStack manaFlaskStack = new ItemStack(WizardryItems.mana_flask); + ItemStack bottleStack = new ItemStack(Items.GLASS_BOTTLE); + ItemStack gunpowderStack = new ItemStack(Items.GUNPOWDER); + ItemStack blazePowderStack = new ItemStack(Items.BLAZE_POWDER); + ItemStack spiderEyeStack = new ItemStack(Items.SPIDER_EYE); + // Coal or charcoal is equally fine, hence the wildcard value + ItemStack coalStack = new ItemStack(Items.COAL, 1, OreDictionary.WILDCARD_VALUE); + ItemStack firebombStack = new ItemStack(WizardryItems.firebomb, 3); + ItemStack poisonBombStack = new ItemStack(WizardryItems.poison_bomb, 3); + ItemStack smokeBombStack = new ItemStack(WizardryItems.smoke_bomb, 3); + ItemStack transportationStoneStack = new ItemStack(WizardryBlocks.transportation_stone, 2); + ItemStack silkStack = new ItemStack(WizardryItems.magic_silk); + ItemStack silkStack1 = new ItemStack(WizardryItems.magic_silk, 2); + ItemStack hatStack = new ItemStack(WizardryItems.wizard_hat); + ItemStack robeStack = new ItemStack(WizardryItems.wizard_robe); + ItemStack leggingsStack = new ItemStack(WizardryItems.wizard_leggings); + ItemStack bootsStack = new ItemStack(WizardryItems.wizard_boots); + ItemStack scrollStack = new ItemStack(WizardryItems.blank_scroll); + ItemStack paperStack = new ItemStack(Items.PAPER); - GameRegistry.addShapelessRecipe(wizardHandbookStack, bookStack, magicCrystalStack); - GameRegistry.addShapelessRecipe(magicCrystalStack1, crystalFlowerStack); - GameRegistry.addShapelessRecipe(magicCrystalStack2, crystalBlockStack); - if(Wizardry.settings.firebombIsCraftable) GameRegistry.addShapelessRecipe(firebombStack, bottleStack, gunpowderStack, blazePowderStack, blazePowderStack); - if(Wizardry.settings.poisonBombIsCraftable) GameRegistry.addShapelessRecipe(poisonBombStack, bottleStack, gunpowderStack, spiderEyeStack, spiderEyeStack); - if(Wizardry.settings.smokeBombIsCraftable) GameRegistry.addShapelessRecipe(smokeBombStack, bottleStack, gunpowderStack, coalStack, coalStack); - if(Wizardry.settings.useAlternateScrollRecipe){ - GameRegistry.addShapelessRecipe(scrollStack, paperStack, stringStack, magicCrystalStack); - }else{ - GameRegistry.addShapelessRecipe(scrollStack, paperStack, stringStack); - } - - // Mana flask recipes - ItemStack miscWandStack; - - for(Element element : Element.values()){ - for(Tier tier : Tier.values()){ - miscWandStack = new ItemStack(WizardryUtilities.getWand(tier, element), 1, OreDictionary.WILDCARD_VALUE); - GameRegistry.addShapelessRecipe(miscWandStack, miscWandStack, manaFlaskStack); - } - } - - ItemStack miscArmourStack; - - for(Element element : Element.values()){ - for(EntityEquipmentSlot slot : WizardryUtilities.ARMOUR_SLOTS){ - miscArmourStack = new ItemStack(WizardryUtilities.getArmour(element, slot), 1, OreDictionary.WILDCARD_VALUE); - GameRegistry.addShapelessRecipe(miscArmourStack, miscArmourStack, manaFlaskStack); - } - } + GameRegistry.addRecipe(magicWandStack, " x", " y ", "z ", 'x', magicCrystalStack, 'y', stickStack, 'z', + goldNuggetStack); + GameRegistry.addRecipe(spellBookStack, " x ", "xyx", " x ", 'x', magicCrystalStack, 'y', bookStack); + GameRegistry.addRecipe(arcaneWorkbenchStack, "vwv", "xyx", "zzz", 'v', goldNuggetStack, 'w', purpleCarpetStack, + 'x', magicCrystalStack, 'y', lapisBlockStack, 'z', stoneStack); + GameRegistry.addRecipe(manaFlaskStack, "yyy", "yxy", "yyy", 'x', bottleStack, 'y', magicCrystalStack); + GameRegistry.addRecipe(transportationStoneStack, " x ", "xyx", " x ", 'x', stoneStack, 'y', magicCrystalStack); + GameRegistry.addRecipe(hatStack, "yyy", "y y", 'y', silkStack); + GameRegistry.addRecipe(robeStack, "y y", "yyy", "yyy", 'y', silkStack); + GameRegistry.addRecipe(leggingsStack, "yyy", "y y", "y y", 'y', silkStack); + GameRegistry.addRecipe(bootsStack, "y y", "y y", 'y', silkStack); + GameRegistry.addRecipe(silkStack1, " x ", "xyx", " x ", 'x', stringStack, 'y', magicCrystalStack); + GameRegistry.addRecipe(crystalBlockStack, "zzz", "zzz", "zzz", 'z', magicCrystalStack); + + GameRegistry.addShapelessRecipe(wizardHandbookStack, bookStack, magicCrystalStack); + GameRegistry.addShapelessRecipe(magicCrystalStack1, crystalFlowerStack); + GameRegistry.addShapelessRecipe(magicCrystalStack2, crystalBlockStack); + if(Wizardry.settings.firebombIsCraftable) GameRegistry.addShapelessRecipe(firebombStack, bottleStack, + gunpowderStack, blazePowderStack, blazePowderStack); + if(Wizardry.settings.poisonBombIsCraftable) GameRegistry.addShapelessRecipe(poisonBombStack, bottleStack, + gunpowderStack, spiderEyeStack, spiderEyeStack); + if(Wizardry.settings.smokeBombIsCraftable) + GameRegistry.addShapelessRecipe(smokeBombStack, bottleStack, gunpowderStack, coalStack, coalStack); + if(Wizardry.settings.useAlternateScrollRecipe){ + GameRegistry.addShapelessRecipe(scrollStack, paperStack, stringStack, magicCrystalStack); + }else{ + GameRegistry.addShapelessRecipe(scrollStack, paperStack, stringStack); + } + + // Mana flask recipes + ItemStack miscWandStack; + + for(Element element : Element.values()){ + for(Tier tier : Tier.values()){ + miscWandStack = new ItemStack(WizardryUtilities.getWand(tier, element), 1, + OreDictionary.WILDCARD_VALUE); + GameRegistry.addShapelessRecipe(miscWandStack, miscWandStack, manaFlaskStack); + } + } + + ItemStack miscArmourStack; + + for(Element element : Element.values()){ + for(EntityEquipmentSlot slot : WizardryUtilities.ARMOUR_SLOTS){ + miscArmourStack = new ItemStack(WizardryUtilities.getArmour(element, slot), 1, + OreDictionary.WILDCARD_VALUE); + GameRegistry.addShapelessRecipe(miscArmourStack, miscArmourStack, manaFlaskStack); + } + } } } diff --git a/src/main/java/electroblob/wizardry/registry/WizardrySounds.java b/src/main/java/electroblob/wizardry/registry/WizardrySounds.java index d006add1..f9a2b90f 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardrySounds.java +++ b/src/main/java/electroblob/wizardry/registry/WizardrySounds.java @@ -8,8 +8,9 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; /** - * Class responsible for defining, storing and registering all of wizardry's sound events. For some reason, these - * worked in the beta versions despite not being registered... + * Class responsible for defining, storing and registering all of wizardry's sound events. For some reason, these worked + * in the beta versions despite not being registered... + * * @author Electroblob * @since Wizardry 2.1 */ @@ -36,13 +37,13 @@ public final class WizardrySounds { public static final SoundEvent SPELL_LOOP_WIND = createSound("wind"); public static final SoundEvent SPELL_EARTHQUAKE = createSound("rumble"); public static final SoundEvent SPELL_FORCE = createSound("force"); - + /** Trick borrowed from the Twilight Forest, makes things neater. */ public static SoundEvent createSound(String name){ // All the setRegistryName methods delegate to this one, it doesn't matter which you use. return new SoundEvent(new ResourceLocation(Wizardry.MODID, name)).setRegistryName(name); } - + @SubscribeEvent public static void register(RegistryEvent.Register event){ event.getRegistry().register(SPELL_SPARK); diff --git a/src/main/java/electroblob/wizardry/registry/WizardryTabs.java b/src/main/java/electroblob/wizardry/registry/WizardryTabs.java index 6eeb9fc6..73486429 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardryTabs.java +++ b/src/main/java/electroblob/wizardry/registry/WizardryTabs.java @@ -14,11 +14,13 @@ import electroblob.wizardry.spell.Spell; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; /** * Class responsible for defining and storing all of wizardry's creative tabs. Also handles sorting of the items. + * * @author Electroblob * @since Wizardry 2.1 */ @@ -32,13 +34,13 @@ public final class WizardryTabs { @Override @SideOnly(Side.CLIENT) - public Item getTabIconItem() { - return WizardryItems.wizard_handbook; + public ItemStack getTabIconItem(){ + return new ItemStack(WizardryItems.wizard_handbook); } @Override @SideOnly(Side.CLIENT) - public void displayAllRelevantItems(List items) { + public void displayAllRelevantItems(NonNullList items){ super.displayAllRelevantItems(items); Collections.sort(items, itemSorter); } @@ -47,25 +49,25 @@ public final class WizardryTabs { @Override @SideOnly(Side.CLIENT) - public Item getTabIconItem() { - return WizardryItems.spell_book; + public ItemStack getTabIconItem(){ + return new ItemStack(WizardryItems.spell_book); } @Override @SideOnly(Side.CLIENT) - public void displayAllRelevantItems(List items) { + public void displayAllRelevantItems(NonNullList items){ super.displayAllRelevantItems(items); Collections.sort(items, spellItemSorter); } @Override - public boolean hasSearchBar() { + public boolean hasSearchBar(){ return true; } @Override @SideOnly(Side.CLIENT) - public String getBackgroundImageName() { + public String getBackgroundImageName(){ return "item_search.png"; } }; @@ -74,85 +76,44 @@ public final class WizardryTabs { public static void sort(){ List orderedItemList = Arrays.asList( - - Item.getItemFromBlock(WizardryBlocks.arcane_workbench), - Item.getItemFromBlock(WizardryBlocks.crystal_ore), - Item.getItemFromBlock(WizardryBlocks.crystal_block), - Item.getItemFromBlock(WizardryBlocks.crystal_flower), - Item.getItemFromBlock(WizardryBlocks.transportation_stone), - WizardryItems.magic_crystal, - WizardryItems.magic_wand, - WizardryItems.apprentice_wand, - WizardryItems.advanced_wand, - WizardryItems.master_wand, - WizardryItems.arcane_tome, - WizardryItems.wizard_handbook, - WizardryItems.basic_fire_wand, - WizardryItems.basic_ice_wand, - WizardryItems.basic_lightning_wand, - WizardryItems.basic_necromancy_wand, - WizardryItems.basic_earth_wand, - WizardryItems.basic_sorcery_wand, - WizardryItems.basic_healing_wand, - WizardryItems.smoke_bomb, - WizardryItems.firebomb, - WizardryItems.poison_bomb, - WizardryItems.blank_scroll, - WizardryItems.identification_scroll, - WizardryItems.mana_flask, - WizardryItems.storage_upgrade, - WizardryItems.siphon_upgrade, - WizardryItems.condenser_upgrade, - WizardryItems.range_upgrade, - WizardryItems.duration_upgrade, - WizardryItems.cooldown_upgrade, - WizardryItems.blast_upgrade, - WizardryItems.attunement_upgrade, - WizardryItems.magic_silk, - WizardryItems.armour_upgrade, - WizardryItems.wizard_hat, - WizardryItems.wizard_robe, - WizardryItems.wizard_leggings, - WizardryItems.wizard_boots, - WizardryItems.wizard_hat_fire, - WizardryItems.wizard_robe_fire, - WizardryItems.wizard_leggings_fire, - WizardryItems.wizard_boots_fire, - WizardryItems.wizard_hat_ice, - WizardryItems.wizard_robe_ice, - WizardryItems.wizard_leggings_ice, - WizardryItems.wizard_boots_ice, - WizardryItems.wizard_hat_lightning, - WizardryItems.wizard_robe_lightning, - WizardryItems.wizard_leggings_lightning, - WizardryItems.wizard_boots_lightning, - WizardryItems.wizard_hat_necromancy, - WizardryItems.wizard_robe_necromancy, - WizardryItems.wizard_leggings_necromancy, - WizardryItems.wizard_boots_necromancy, - WizardryItems.wizard_hat_earth, - WizardryItems.wizard_robe_earth, - WizardryItems.wizard_leggings_earth, - WizardryItems.wizard_boots_earth, - WizardryItems.wizard_hat_sorcery, - WizardryItems.wizard_robe_sorcery, - WizardryItems.wizard_leggings_sorcery, - WizardryItems.wizard_boots_sorcery, - WizardryItems.wizard_hat_healing, - WizardryItems.wizard_robe_healing, - WizardryItems.wizard_leggings_healing, - WizardryItems.wizard_boots_healing); - itemSorter = Ordering.explicit(orderedItemList).onResultOf(new Function() { + Item.getItemFromBlock(WizardryBlocks.arcane_workbench), + Item.getItemFromBlock(WizardryBlocks.crystal_ore), Item.getItemFromBlock(WizardryBlocks.crystal_block), + Item.getItemFromBlock(WizardryBlocks.crystal_flower), + Item.getItemFromBlock(WizardryBlocks.transportation_stone), WizardryItems.magic_crystal, + WizardryItems.magic_wand, WizardryItems.apprentice_wand, WizardryItems.advanced_wand, + WizardryItems.master_wand, WizardryItems.arcane_tome, WizardryItems.wizard_handbook, + WizardryItems.basic_fire_wand, WizardryItems.basic_ice_wand, WizardryItems.basic_lightning_wand, + WizardryItems.basic_necromancy_wand, WizardryItems.basic_earth_wand, WizardryItems.basic_sorcery_wand, + WizardryItems.basic_healing_wand, WizardryItems.smoke_bomb, WizardryItems.firebomb, + WizardryItems.poison_bomb, WizardryItems.blank_scroll, WizardryItems.identification_scroll, + WizardryItems.mana_flask, WizardryItems.storage_upgrade, WizardryItems.siphon_upgrade, + WizardryItems.condenser_upgrade, WizardryItems.range_upgrade, WizardryItems.duration_upgrade, + WizardryItems.cooldown_upgrade, WizardryItems.blast_upgrade, WizardryItems.attunement_upgrade, + WizardryItems.magic_silk, WizardryItems.armour_upgrade, WizardryItems.wizard_hat, + WizardryItems.wizard_robe, WizardryItems.wizard_leggings, WizardryItems.wizard_boots, + WizardryItems.wizard_hat_fire, WizardryItems.wizard_robe_fire, WizardryItems.wizard_leggings_fire, + WizardryItems.wizard_boots_fire, WizardryItems.wizard_hat_ice, WizardryItems.wizard_robe_ice, + WizardryItems.wizard_leggings_ice, WizardryItems.wizard_boots_ice, WizardryItems.wizard_hat_lightning, + WizardryItems.wizard_robe_lightning, WizardryItems.wizard_leggings_lightning, + WizardryItems.wizard_boots_lightning, WizardryItems.wizard_hat_necromancy, + WizardryItems.wizard_robe_necromancy, WizardryItems.wizard_leggings_necromancy, + WizardryItems.wizard_boots_necromancy, WizardryItems.wizard_hat_earth, WizardryItems.wizard_robe_earth, + WizardryItems.wizard_leggings_earth, WizardryItems.wizard_boots_earth, WizardryItems.wizard_hat_sorcery, + WizardryItems.wizard_robe_sorcery, WizardryItems.wizard_leggings_sorcery, + WizardryItems.wizard_boots_sorcery, WizardryItems.wizard_hat_healing, WizardryItems.wizard_robe_healing, + WizardryItems.wizard_leggings_healing, WizardryItems.wizard_boots_healing); + + itemSorter = Ordering.explicit(orderedItemList).onResultOf(new Function(){ @Override - public Item apply(ItemStack input) { + public Item apply(ItemStack input){ return input.getItem(); } }); spellItemSorter = new Comparator(){ @Override - public int compare(ItemStack stack1, ItemStack stack2) { + public int compare(ItemStack stack1, ItemStack stack2){ if((stack1.getItem() instanceof ItemSpellBook && stack2.getItem() instanceof ItemSpellBook) || (stack1.getItem() instanceof ItemScroll && stack2.getItem() instanceof ItemScroll)){ diff --git a/src/main/java/electroblob/wizardry/spell/Agility.java b/src/main/java/electroblob/wizardry/spell/Agility.java index db01f4a4..cdd36fb3 100644 --- a/src/main/java/electroblob/wizardry/spell/Agility.java +++ b/src/main/java/electroblob/wizardry/spell/Agility.java @@ -18,29 +18,32 @@ import net.minecraft.world.World; public class Agility extends Spell { - public Agility() { + public Agility(){ super(Tier.APPRENTICE, 20, Element.SORCERY, "agility", SpellType.UTILITY, 40, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ // 1.10 allows the particles to be completely hidden. - caster.addPotionEffect(new PotionEffect(MobEffects.SPEED, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 1, false, false)); - caster.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 1, false, false)); - - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + caster.addPotionEffect(new PotionEffect(MobEffects.SPEED, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 1, false, false)); + caster.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 1, false, false)); + + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); if(world.isRemote){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.6f, 0.6f, 1.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 0.6f, 0.6f, 1.0f); } } - - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Arc.java b/src/main/java/electroblob/wizardry/spell/Arc.java index 372911d4..de264c95 100644 --- a/src/main/java/electroblob/wizardry/spell/Arc.java +++ b/src/main/java/electroblob/wizardry/spell/Arc.java @@ -27,38 +27,46 @@ import net.minecraft.world.World; // be useful for future reference. public class Arc extends Spell { - public Arc() { + public Arc(){ super(Tier.BASIC, 5, Element.LIGHTNING, "arc", SpellType.ATTACK, 15, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 8*modifiers.get(WizardryItems.range_upgrade), 4.0f); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 8 * modifiers.get(WizardryItems.range_upgrade), 4.0f); if(rayTrace != null && rayTrace.entityHit != null && rayTrace.entityHit instanceof EntityLivingBase){ - + Entity target = rayTrace.entityHit; - + if(!world.isRemote){ EntityArc arc = new EntityArc(world); - arc.setEndpointCoords(caster.posX, caster.posY + 1, caster.posZ, - target.posX, target.posY + target.height/2, target.posZ); - world.spawnEntityInWorld(arc); + arc.setEndpointCoords(caster.posX, caster.posY + 1, caster.posZ, target.posX, + target.posY + target.height / 2, target.posZ); + world.spawnEntity(arc); }else{ - for(int i=0;i<8;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); - world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0); + for(int i = 0; i < 8; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + target.posX + world.rand.nextFloat() - 0.5, + target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1, + target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); + world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + world.rand.nextFloat() - 0.5, + target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1, + target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0); } } - + // This is a lot neater than it was, thanks to the damage type system. if(MagicDamage.isEntityImmune(DamageType.SHOCK, target)){ - if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted())); + if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(), + this.getNameForTranslationFormatted())); }else{ - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 3.0f * modifiers.get(SpellModifiers.DAMAGE)); + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), + 3.0f * modifiers.get(SpellModifiers.DAMAGE)); } - + caster.swingArm(hand); target.playSound(WizardrySounds.SPELL_SPARK, 1.0F, world.rand.nextFloat() * 0.4F + 1.5F); return true; @@ -66,40 +74,46 @@ public class Arc extends Spell { return false; } - + @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ EntityArc arc = new EntityArc(world); - arc.setEndpointCoords(caster.posX, caster.posY + 1, caster.posZ, - target.posX, target.posY + target.height/2, target.posZ); - world.spawnEntityInWorld(arc); + arc.setEndpointCoords(caster.posX, caster.posY + 1, caster.posZ, target.posX, + target.posY + target.height / 2, target.posZ); + world.spawnEntity(arc); }else{ - for(int i=0;i<8;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); - world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0); + for(int i = 0; i < 8; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + target.posX + world.rand.nextFloat() - 0.5, + target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1, + target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); + world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + world.rand.nextFloat() - 0.5, + target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1, + target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0); } } // What's great about the damage type system is that, because I don't need to know if the creature resisted // the damage here, I can simply call this without having to check for immunities at all. - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 3.0f * modifiers.get(SpellModifiers.DAMAGE)); + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), + 3.0f * modifiers.get(SpellModifiers.DAMAGE)); caster.swingArm(hand); target.playSound(WizardrySounds.SPELL_SPARK, 1.0F, world.rand.nextFloat() * 0.4F + 1.5F); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/ArcaneJammer.java b/src/main/java/electroblob/wizardry/spell/ArcaneJammer.java index 163e2f42..8fa1cb14 100644 --- a/src/main/java/electroblob/wizardry/spell/ArcaneJammer.java +++ b/src/main/java/electroblob/wizardry/spell/ArcaneJammer.java @@ -28,60 +28,70 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @Mod.EventBusSubscriber public class ArcaneJammer extends Spell { - public ArcaneJammer() { + public ArcaneJammer(){ super(Tier.ADVANCED, 30, Element.HEALING, "arcane_jammer", SpellType.ATTACK, 50, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ Vec3d look = caster.getLookVec(); - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){ - - EntityLivingBase entity = (EntityLivingBase) rayTrace.entityHit; + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLivingBase){ + + EntityLivingBase entity = (EntityLivingBase)rayTrace.entityHit; if(entity instanceof EntityWizard) caster.addStat(WizardryAchievements.jam_wizard); - + if(!world.isRemote){ - entity.addPotionEffect(new PotionEffect(WizardryPotions.arcane_jammer, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0)); + entity.addPotionEffect(new PotionEffect(WizardryPotions.arcane_jammer, + (int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0)); } } if(world.isRemote){ - for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ - double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), 0.9f, 0.3f, 0.7f); + for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ + double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 12 + world.rand.nextInt(8), 0.9f, 0.3f, 0.7f); } } caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_DEFLECTION, 0.7F, world.rand.nextFloat() * 0.4F + 0.8F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_DEFLECTION, 0.7F, + world.rand.nextFloat() * 0.4F + 0.8F); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ if(target != null){ if(!world.isRemote){ - target.addPotionEffect(new PotionEffect(WizardryPotions.arcane_jammer, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0)); + target.addPotionEffect(new PotionEffect(WizardryPotions.arcane_jammer, + (int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0)); } - + if(world.isRemote){ - double dx = (target.posX - caster.posX)/caster.getDistanceToEntity(target); - double dy = (target.posY - caster.posY)/caster.getDistanceToEntity(target); - double dz = (target.posZ - caster.posZ)/caster.getDistanceToEntity(target); - - for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ + double dx = (target.posX - caster.posX) / caster.getDistanceToEntity(target); + double dy = (target.posY - caster.posY) / caster.getDistanceToEntity(target); + double dz = (target.posZ - caster.posZ) / caster.getDistanceToEntity(target); - double x1 = caster.posX + dx*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + dz*i/2 + world.rand.nextFloat()/5 - 0.1f; + for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), 0.9f, 0.3f, 0.7f); + double x1 = caster.posX + dx * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy * i / 2 + world.rand.nextFloat() / 5 + - 0.1f; + double z1 = caster.posZ + dz * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 12 + world.rand.nextInt(8), 0.9f, 0.3f, 0.7f); } } caster.swingArm(hand); @@ -95,7 +105,7 @@ public class ArcaneJammer extends Spell { public boolean canBeCastByNPCs(){ return true; } - + @SubscribeEvent public static void onSpellCastPreEvent(SpellCastEvent.Pre event){ // Arcane jammer prevents spell casting. diff --git a/src/main/java/electroblob/wizardry/spell/ArrowRain.java b/src/main/java/electroblob/wizardry/spell/ArrowRain.java index b8c8f210..69e25a9a 100644 --- a/src/main/java/electroblob/wizardry/spell/ArrowRain.java +++ b/src/main/java/electroblob/wizardry/spell/ArrowRain.java @@ -16,7 +16,7 @@ import net.minecraft.world.World; public class ArrowRain extends Spell { - public ArrowRain() { + public ArrowRain(){ super(Tier.MASTER, 75, Element.SORCERY, "arrow_rain", SpellType.ATTACK, 300, EnumAction.NONE, false); } @@ -26,26 +26,30 @@ public class ArrowRain extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - RayTraceResult rayTrace = WizardryUtilities.rayTrace(20*modifiers.get(WizardryItems.range_upgrade), world, caster, false); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + RayTraceResult rayTrace = WizardryUtilities.rayTrace(20 * modifiers.get(WizardryItems.range_upgrade), world, + caster, false); + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){ if(!world.isRemote){ double x = rayTrace.hitVec.xCoord; double y = rayTrace.hitVec.yCoord; double z = rayTrace.hitVec.zCoord; - // Moves the entity back towards the caster a bit, so the area of effect is better centred on the position. + // Moves the entity back towards the caster a bit, so the area of effect is better centred on the + // position. // 3.0d is the distance to move the entity back towards the caster. double dx = caster.posX - x; double dz = caster.posZ - z; - double distRatio = 3.0d/Math.sqrt(dx*dx + dz*dz); - x += dx*distRatio; - z += dz*distRatio; - - EntityArrowRain arrowrain = new EntityArrowRain(world, x, y + 5, z, caster, (int)(120*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE)); + double distRatio = 3.0d / Math.sqrt(dx * dx + dz * dz); + x += dx * distRatio; + z += dz * distRatio; + + EntityArrowRain arrowrain = new EntityArrowRain(world, x, y + 5, z, caster, + (int)(120 * modifiers.get(WizardryItems.duration_upgrade)), + modifiers.get(SpellModifiers.DAMAGE)); arrowrain.rotationYaw = caster.rotationYawHead; - world.spawnEntityInWorld(arrowrain); + world.spawnEntity(arrowrain); } caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_SUMMONING, 1.0F, 1.0F); diff --git a/src/main/java/electroblob/wizardry/spell/Banish.java b/src/main/java/electroblob/wizardry/spell/Banish.java index 8bf92bec..6fb35f67 100644 --- a/src/main/java/electroblob/wizardry/spell/Banish.java +++ b/src/main/java/electroblob/wizardry/spell/Banish.java @@ -23,137 +23,150 @@ import net.minecraft.world.World; public class Banish extends Spell { - public Banish() { + public Banish(){ super(Tier.APPRENTICE, 15, Element.NECROMANCY, "banish", SpellType.ATTACK, 40, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + Vec3d look = caster.getLookVec(); - - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); - - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){ - - EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit; - - double radius = (8 + world.rand.nextDouble()*8) * modifiers.get(WizardryItems.range_upgrade); - double angle = world.rand.nextDouble()*Math.PI*2; - - int x = MathHelper.floor_double(target.posX + Math.sin(angle)*radius); - int z = MathHelper.floor_double(target.posZ - Math.cos(angle)*radius); - int y = WizardryUtilities.getNearestFloorLevel(world, new BlockPos(x, (int)caster.getEntityBoundingBox().minY, z), (int)radius); - + + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); + + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLivingBase){ + + EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit; + + double radius = (8 + world.rand.nextDouble() * 8) * modifiers.get(WizardryItems.range_upgrade); + double angle = world.rand.nextDouble() * Math.PI * 2; + + int x = MathHelper.floor(target.posX + Math.sin(angle) * radius); + int z = MathHelper.floor(target.posZ - Math.cos(angle) * radius); + int y = WizardryUtilities.getNearestFloorLevel(world, + new BlockPos(x, (int)caster.getEntityBoundingBox().minY, z), (int)radius); + if(world.isRemote){ - for(int i=0;i<10;i++){ + for(int i = 0; i < 10; i++){ double dx1 = target.posX; - double dy1 = target.getEntityBoundingBox().minY + target.height*world.rand.nextFloat(); + double dy1 = target.getEntityBoundingBox().minY + target.height * world.rand.nextFloat(); double dz1 = target.posZ; - world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); + world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5, + world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); } } - + if(y > -1){ - + // This means stuff like snow layers is ignored, meaning when on snow-covered ground the caster does // not teleport 1 block above the ground. if(!world.getBlockState(new BlockPos(x, y, z)).getMaterial().blocksMovement()){ y--; } - - if(world.getBlockState(new BlockPos(x, y + 1, z)).getMaterial().blocksMovement() || world.getBlockState(new BlockPos(x, y + 2, z)).getMaterial().blocksMovement()){ + + if(world.getBlockState(new BlockPos(x, y + 1, z)).getMaterial().blocksMovement() + || world.getBlockState(new BlockPos(x, y + 2, z)).getMaterial().blocksMovement()){ return false; } - + if(!world.isRemote){ target.setPositionAndUpdate(x + 0.5, y + 1, z + 0.5); } - + target.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f); } } - + if(world.isRemote){ - for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ - double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; + for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ + double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; world.spawnParticle(EnumParticleTypes.PORTAL, x1, y1 - 0.5, z1, 0.0d, 0.0d, 0.0d); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.2f, 0.0f, 0.2f); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, + 0.2f, 0.0f, 0.2f); } } - + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f); caster.swingArm(hand); return true; } - - @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - - if(target != null){ - - double radius = (8 + world.rand.nextDouble()*8) * modifiers.get(WizardryItems.range_upgrade); - double angle = world.rand.nextDouble()*Math.PI*2; - - int x = MathHelper.floor_double(target.posX + Math.sin(angle)*radius); - int z = MathHelper.floor_double(target.posZ - Math.cos(angle)*radius); - int y = WizardryUtilities.getNearestFloorLevel(world, new BlockPos(x, (int)caster.getEntityBoundingBox().minY, z), (int)radius); - - if(world.isRemote){ - - double dx = (target.posX - caster.posX)/caster.getDistanceToEntity(target); - double dy = (target.posY - caster.posY)/caster.getDistanceToEntity(target); - double dz = (target.posZ - caster.posZ)/caster.getDistanceToEntity(target); - - for(int i=1; i<25; i+=2){ - double x1 = caster.posX + dx*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + dz*i/2 + world.rand.nextFloat()/5 - 0.1f; + @Override + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + + if(target != null){ + + double radius = (8 + world.rand.nextDouble() * 8) * modifiers.get(WizardryItems.range_upgrade); + double angle = world.rand.nextDouble() * Math.PI * 2; + + int x = MathHelper.floor(target.posX + Math.sin(angle) * radius); + int z = MathHelper.floor(target.posZ - Math.cos(angle) * radius); + int y = WizardryUtilities.getNearestFloorLevel(world, + new BlockPos(x, (int)caster.getEntityBoundingBox().minY, z), (int)radius); + + if(world.isRemote){ + + double dx = (target.posX - caster.posX) / caster.getDistanceToEntity(target); + double dy = (target.posY - caster.posY) / caster.getDistanceToEntity(target); + double dz = (target.posZ - caster.posZ) / caster.getDistanceToEntity(target); + + for(int i = 1; i < 25; i += 2){ + + double x1 = caster.posX + dx * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy * i / 2 + world.rand.nextFloat() / 5 + - 0.1f; + double z1 = caster.posZ + dz * i / 2 + world.rand.nextFloat() / 5 - 0.1f; world.spawnParticle(EnumParticleTypes.PORTAL, x1, y1 - 0.5, z1, 0.0d, 0.0d, 0.0d); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.2f, 0.0f, 0.2f); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 0, 0.2f, 0.0f, 0.2f); } - - for(int i=0;i<10;i++){ + + for(int i = 0; i < 10; i++){ double dx1 = target.posX; - double dy1 = target.getEntityBoundingBox().minY + target.height*world.rand.nextFloat(); + double dy1 = target.getEntityBoundingBox().minY + target.height * world.rand.nextFloat(); double dz1 = target.posZ; - world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); + world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5, + world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); } } - + if(y > -1){ - + // This means stuff like snow layers is ignored, meaning when on snow-covered ground the caster does // not teleport 1 block above the ground. if(!world.getBlockState(new BlockPos(x, y, z)).getMaterial().blocksMovement()){ y--; } - - if(world.getBlockState(new BlockPos(x, y + 1, z)).getMaterial().blocksMovement() || world.getBlockState(new BlockPos(x, y + 2, z)).getMaterial().blocksMovement()){ + + if(world.getBlockState(new BlockPos(x, y + 1, z)).getMaterial().blocksMovement() + || world.getBlockState(new BlockPos(x, y + 2, z)).getMaterial().blocksMovement()){ return false; } - + if(!world.isRemote){ target.setPositionAndUpdate(x + 0.5, y + 1, z + 0.5); } - + target.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f); } } - + caster.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f); caster.swingArm(hand); return true; } - + @Override public boolean canBeCastByNPCs(){ return true; } - + } diff --git a/src/main/java/electroblob/wizardry/spell/BlackHole.java b/src/main/java/electroblob/wizardry/spell/BlackHole.java index 3cfcd267..6f70a016 100644 --- a/src/main/java/electroblob/wizardry/spell/BlackHole.java +++ b/src/main/java/electroblob/wizardry/spell/BlackHole.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class BlackHole extends Spell { - public BlackHole() { + public BlackHole(){ super(Tier.MASTER, 150, Element.SORCERY, "black_hole", SpellType.ATTACK, 400, EnumAction.NONE, false); } @@ -27,33 +27,38 @@ public class BlackHole extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - RayTraceResult rayTrace = WizardryUtilities.rayTrace(10*modifiers.get(WizardryItems.range_upgrade), world, caster, false); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + RayTraceResult rayTrace = WizardryUtilities.rayTrace(10 * modifiers.get(WizardryItems.range_upgrade), world, + caster, false); + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){ - + // This demonstrates beautifully the elegance of BlockPos. In 1.7.10 this required a 50-line long switch // statement and a flag variable; now it only needs a few lines. BlockPos pos = new BlockPos(rayTrace.hitVec).offset(rayTrace.sideHit); - + if(world.isAirBlock(pos)){ - + if(!world.isRemote){ - world.spawnEntityInWorld(new EntityBlackHole(world, pos.getX()+0.5, pos.getY()-1+0.5, pos.getZ()+0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE))); + world.spawnEntity(new EntityBlackHole(world, pos.getX() + 0.5, pos.getY() - 1 + 0.5, + pos.getZ() + 0.5, caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), + modifiers.get(SpellModifiers.DAMAGE))); } - + caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 2.0f, 0.7f); return true; } - + }else{ - int x = (int) (Math.floor(caster.posX) + caster.getLookVec().xCoord*8); - int y = (int) (Math.floor(caster.posY) + caster.eyeHeight + caster.getLookVec().yCoord*8); - int z = (int) (Math.floor(caster.posZ) + caster.getLookVec().zCoord*8); + int x = (int)(Math.floor(caster.posX) + caster.getLookVec().xCoord * 8); + int y = (int)(Math.floor(caster.posY) + caster.eyeHeight + caster.getLookVec().yCoord * 8); + int z = (int)(Math.floor(caster.posZ) + caster.getLookVec().zCoord * 8); if(!world.isRemote){ - world.spawnEntityInWorld(new EntityBlackHole(world, x, y, z, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE))); + world.spawnEntity(new EntityBlackHole(world, x, y, z, caster, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), + modifiers.get(SpellModifiers.DAMAGE))); } caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 2.0f, 0.7f); @@ -62,5 +67,4 @@ public class BlackHole extends Spell { return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Blink.java b/src/main/java/electroblob/wizardry/spell/Blink.java index 3353d686..85fee81c 100644 --- a/src/main/java/electroblob/wizardry/spell/Blink.java +++ b/src/main/java/electroblob/wizardry/spell/Blink.java @@ -21,114 +21,122 @@ import net.minecraft.world.World; public class Blink extends Spell { - public Blink() { + public Blink(){ super(Tier.APPRENTICE, 15, Element.SORCERY, "blink", SpellType.UTILITY, 25, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - RayTraceResult rayTrace = WizardryUtilities.rayTrace(25*modifiers.get(WizardryItems.range_upgrade), world, caster, false); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + RayTraceResult rayTrace = WizardryUtilities.rayTrace(25 * modifiers.get(WizardryItems.range_upgrade), world, + caster, false); + // It's worth noting that on the client side, the cast() method only gets called if the server side // cast method succeeded, so you need not check any conditions for spawning particles. if(world.isRemote){ - for(int i=0;i<10;i++){ + for(int i = 0; i < 10; i++){ double dx = caster.posX; - double dy = caster.getEntityBoundingBox().minY + 2*world.rand.nextFloat(); + double dy = caster.getEntityBoundingBox().minY + 2 * world.rand.nextFloat(); double dz = caster.posZ; // For portal particles, velocity is not velocity but the offset where they start, then drift to // the actual position given. - world.spawnParticle(EnumParticleTypes.PORTAL, dx, dy, dz, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); + world.spawnParticle(EnumParticleTypes.PORTAL, dx, dy, dz, world.rand.nextDouble() - 0.5, + world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); } } - + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){ - + BlockPos pos = rayTrace.getBlockPos(); - + // Can't teleport onto the ceiling. if(rayTrace.sideHit == EnumFacing.DOWN) return false; - + // This means stuff like snow layers is ignored, meaning when on snow-covered ground the player does // not teleport 1 block above the ground. if(rayTrace.sideHit == EnumFacing.UP && !world.getBlockState(pos).getMaterial().blocksMovement()){ pos = pos.down(); } - + pos = rayTrace.getBlockPos().offset(rayTrace.sideHit); - + // Prevents the player from teleporting into blocks and suffocating. - if(world.getBlockState(pos).getMaterial().blocksMovement() || world.getBlockState(pos.up()).getMaterial().blocksMovement()){ + if(world.getBlockState(pos).getMaterial().blocksMovement() + || world.getBlockState(pos.up()).getMaterial().blocksMovement()){ return false; } - + // Plays before and after so it is heard from both positions WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f); - + if(!world.isRemote) caster.setPositionAndUpdate(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); - + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f); caster.swingArm(hand); return true; } - + return false; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ - double angle = Math.atan2(target.posZ - caster.posZ, target.posX - caster.posX) + world.rand.nextDouble()*Math.PI; - double radius = caster.getDistance(target.posX, target.getEntityBoundingBox().minY, target.posZ) + world.rand.nextDouble()*3.0d; - - int x = MathHelper.floor_double(target.posX + Math.sin(angle)*radius); - int z = MathHelper.floor_double(target.posZ - Math.cos(angle)*radius); + double angle = Math.atan2(target.posZ - caster.posZ, target.posX - caster.posX) + + world.rand.nextDouble() * Math.PI; + double radius = caster.getDistance(target.posX, target.getEntityBoundingBox().minY, target.posZ) + + world.rand.nextDouble() * 3.0d; + + int x = MathHelper.floor(target.posX + Math.sin(angle) * radius); + int z = MathHelper.floor(target.posZ - Math.cos(angle) * radius); int y = WizardryUtilities.getNearestFloorLevel(world, new BlockPos(caster), (int)radius); - + // It's worth noting that on the client side, the cast() method only gets called if the server side // cast method succeeded, so you need not check any conditions for spawning particles. - + // For some reason, the wizard version spwans the particles where the wizard started if(world.isRemote){ - for(int i=0;i<10;i++){ + for(int i = 0; i < 10; i++){ double dx1 = caster.posX; - double dy1 = caster.getEntityBoundingBox().minY + caster.height*world.rand.nextFloat(); + double dy1 = caster.getEntityBoundingBox().minY + caster.height * world.rand.nextFloat(); double dz1 = caster.posZ; - world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); + world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5, + world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); } } - + if(y > -1){ - + // This means stuff like snow layers is ignored, meaning when on snow-covered ground the caster does // not teleport 1 block above the ground. if(!world.getBlockState(new BlockPos(x, y, z)).getMaterial().blocksMovement()){ y--; } - - if(world.getBlockState(new BlockPos(x, y + 1, z)).getMaterial().blocksMovement() || world.getBlockState(new BlockPos(x, y + 2, z)).getMaterial().blocksMovement()){ + + if(world.getBlockState(new BlockPos(x, y + 1, z)).getMaterial().blocksMovement() + || world.getBlockState(new BlockPos(x, y + 2, z)).getMaterial().blocksMovement()){ return false; } // Plays before and after so it is heard from both positions caster.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f); - + if(!world.isRemote){ caster.setPositionAndUpdate(x + 0.5, y + 1, z + 0.5); } - + caster.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f); caster.swingArm(hand); return true; } - + return false; } - + @Override - public boolean canBeCastByNPCs() { + public boolean canBeCastByNPCs(){ return true; } - + } diff --git a/src/main/java/electroblob/wizardry/spell/Blizzard.java b/src/main/java/electroblob/wizardry/spell/Blizzard.java index 8f2066db..ec894d7d 100644 --- a/src/main/java/electroblob/wizardry/spell/Blizzard.java +++ b/src/main/java/electroblob/wizardry/spell/Blizzard.java @@ -18,7 +18,7 @@ import net.minecraft.world.World; public class Blizzard extends Spell { - public Blizzard() { + public Blizzard(){ super(Tier.ADVANCED, 40, Element.ICE, "blizzard", SpellType.ATTACK, 100, EnumAction.NONE, false); } @@ -28,17 +28,20 @@ public class Blizzard extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - RayTraceResult rayTrace = WizardryUtilities.rayTrace(20*modifiers.get(WizardryItems.range_upgrade), world, caster, false); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + RayTraceResult rayTrace = WizardryUtilities.rayTrace(20 * modifiers.get(WizardryItems.range_upgrade), world, + caster, false); + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){ if(!world.isRemote){ double x = rayTrace.hitVec.xCoord; double y = rayTrace.hitVec.yCoord; double z = rayTrace.hitVec.zCoord; - EntityBlizzard blizzard = new EntityBlizzard(world, x, y+0.5, z, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(blizzard); + EntityBlizzard blizzard = new EntityBlizzard(world, x, y + 0.5, z, caster, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(blizzard); } caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, 1.0F); @@ -46,30 +49,33 @@ public class Blizzard extends Spell { } return false; } - + @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ double x = target.posX; double y = target.posY; double z = target.posZ; - EntityBlizzard blizzard = new EntityBlizzard(world, x, y+0.5, z, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(blizzard); + EntityBlizzard blizzard = new EntityBlizzard(world, x, y + 0.5, z, caster, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(blizzard); } caster.swingArm(hand); caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, 1.0F); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; } - + } diff --git a/src/main/java/electroblob/wizardry/spell/Bubble.java b/src/main/java/electroblob/wizardry/spell/Bubble.java index c9c425d1..64e59ee6 100644 --- a/src/main/java/electroblob/wizardry/spell/Bubble.java +++ b/src/main/java/electroblob/wizardry/spell/Bubble.java @@ -25,72 +25,86 @@ import net.minecraft.world.World; public class Bubble extends Spell { - public Bubble() { + public Bubble(){ super(Tier.APPRENTICE, 15, Element.EARTH, "bubble", SpellType.ATTACK, 20, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ Vec3d look = caster.getLookVec(); - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){ - EntityLivingBase entity = (EntityLivingBase) rayTrace.entityHit; + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLivingBase){ + EntityLivingBase entity = (EntityLivingBase)rayTrace.entityHit; if(!world.isRemote){ - entity.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), 1.0f * modifiers.get(SpellModifiers.DAMAGE)); + entity.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), + 1.0f * modifiers.get(SpellModifiers.DAMAGE)); // Deprecated in favour of entity riding method - //entity.addPotionEffect(new PotionEffect(Wizardry.bubblePotion, 200, 0)); - EntityBubble entitybubble = new EntityBubble(world, entity.posX, entity.posY, entity.posZ, caster, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), false, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(entitybubble); + // entity.addPotionEffect(new PotionEffect(Wizardry.bubblePotion, 200, 0)); + EntityBubble entitybubble = new EntityBubble(world, entity.posX, entity.posY, entity.posZ, caster, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade)), false, + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(entitybubble); entity.startRiding(entitybubble); } } if(world.isRemote){ - for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ - double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; + for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ + double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; world.spawnParticle(EnumParticleTypes.WATER_SPLASH, x1, y1, z1, 0.0d, 0.0d, 0.0d); Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_BUBBLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0); } } caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_GENERIC_SWIM, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 0.5F, world.rand.nextFloat() * 0.2F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_GENERIC_SWIM, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 0.5F, + world.rand.nextFloat() * 0.2F + 1.0F); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ if(target != null){ if(!world.isRemote){ - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), 1.0f * modifiers.get(SpellModifiers.DAMAGE)); + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), + 1.0f * modifiers.get(SpellModifiers.DAMAGE)); // Deprecated in favour of entity riding method - //entity.addPotionEffect(new PotionEffect(Wizardry.bubblePotion, 200, 0)); - EntityBubble entitybubble = new EntityBubble(world, target.posX, target.posY, target.posZ, caster, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), false, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(entitybubble); + // entity.addPotionEffect(new PotionEffect(Wizardry.bubblePotion, 200, 0)); + EntityBubble entitybubble = new EntityBubble(world, target.posX, target.posY, target.posZ, caster, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade)), false, + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(entitybubble); target.startRiding(entitybubble); } if(world.isRemote){ - double dx = (target.posX - caster.posX)/caster.getDistanceToEntity(target); - double dy = (target.posY - caster.posY)/caster.getDistanceToEntity(target); - double dz = (target.posZ - caster.posZ)/caster.getDistanceToEntity(target); - - for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ + double dx = (target.posX - caster.posX) / caster.getDistanceToEntity(target); + double dy = (target.posY - caster.posY) / caster.getDistanceToEntity(target); + double dz = (target.posZ - caster.posZ) / caster.getDistanceToEntity(target); - double x1 = caster.posX + dx*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + dz*i/2 + world.rand.nextFloat()/5 - 0.1f; + for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ + + double x1 = caster.posX + dx * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy * i / 2 + world.rand.nextFloat() / 5 + - 0.1f; + double z1 = caster.posZ + dz * i / 2 + world.rand.nextFloat() / 5 - 0.1f; world.spawnParticle(EnumParticleTypes.WATER_SPLASH, x1, y1, z1, 0.0d, 0.0d, 0.0d); - Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_BUBBLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0); + Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_BUBBLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 0); } } caster.swingArm(hand); diff --git a/src/main/java/electroblob/wizardry/spell/ChainLightning.java b/src/main/java/electroblob/wizardry/spell/ChainLightning.java index 1b678ba5..a80dab10 100644 --- a/src/main/java/electroblob/wizardry/spell/ChainLightning.java +++ b/src/main/java/electroblob/wizardry/spell/ChainLightning.java @@ -26,105 +26,142 @@ import net.minecraft.world.World; public class ChainLightning extends Spell { - public ChainLightning() { + public ChainLightning(){ super(Tier.ADVANCED, 25, Element.LIGHTNING, "chain_lightning", SpellType.ATTACK, 50, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + // First shot has range 10 (this is the only range affected by upgrades) and does 5 hearts of damage. // Chains to up to 5 secondary targets within a range of 5 of the primary target, and then to up to 2 // tertiary targets per secondary target within a range of 5 of that. Secondary targets are dealt 4 hearts // of damage; tertiary targets are dealt 3 hearts of damage. - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade), 8.0f); - + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade), 8.0f); + // Anything can be attacked with the initial arc, because the player has control over where it goes. If they // hit a minion or an ally, it's their problem! if(rayTrace != null && rayTrace.entityHit != null && rayTrace.entityHit instanceof EntityLivingBase){ - + Entity target = rayTrace.entityHit; - + if(!world.isRemote){ EntityArc arc = new EntityArc(world); - arc.setEndpointCoords(caster.posX, caster.posY + caster.height/2, caster.posZ, - target.posX, target.posY + target.height/2, target.posZ); - world.spawnEntityInWorld(arc); + arc.setEndpointCoords(caster.posX, caster.posY + caster.height / 2, caster.posZ, target.posX, + target.posY + target.height / 2, target.posZ); + world.spawnEntity(arc); }else{ - for(int i=0;i<8;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); - world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0); + for(int i = 0; i < 8; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + target.posX + world.rand.nextFloat() - 0.5, + target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1, + target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); + world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + world.rand.nextFloat() - 0.5, + target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1, + target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0); } } - + target.playSound(WizardrySounds.SPELL_SPARK, 1.0F, world.rand.nextFloat() * 0.4F + 1.5F); - + if(MagicDamage.isEntityImmune(DamageType.SHOCK, target)){ - if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted())); + if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(), + this.getNameForTranslationFormatted())); }else{ - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 10.0f * modifiers.get(SpellModifiers.DAMAGE)); + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), + 10.0f * modifiers.get(SpellModifiers.DAMAGE)); } - + // Secondary chaining effect double seekerRange = 5.0d; - List secondaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, target.posX, target.posY + target.height/2, target.posZ, world); + List secondaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, + target.posX, target.posY + target.height / 2, target.posZ, world); + + for(int i = 0; i < Math.min(secondaryTargets.size(), 5); i++){ - for(int i=0; i tertiaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height/2, secondaryTarget.posZ, world); + List tertiaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, + secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height / 2, + secondaryTarget.posZ, world); + + for(int j = 0; j < Math.min(tertiaryTargets.size(), 2); j++){ - for(int j=0;j targets = WizardryUtilities.getEntitiesWithinRadius(3.0d*modifiers.get(WizardryItems.blast_upgrade), (rayTrace.hitVec.xCoord+0.5), (rayTrace.hitVec.yCoord+0.5), (rayTrace.hitVec.zCoord+0.5), world); - for(int i=0;i targets = WizardryUtilities.getEntitiesWithinRadius( + 3.0d * modifiers.get(WizardryItems.blast_upgrade), (rayTrace.hitVec.xCoord + 0.5), + (rayTrace.hitVec.yCoord + 0.5), (rayTrace.hitVec.zCoord + 0.5), world); + for(int i = 0; i < targets.size(); i++){ targets.get(i).attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.BLAST), // Damage decreases with distance but cannot be less than 0, naturally. - Math.max(12.0f - (float)((EntityLivingBase)targets.get(i)).getDistance((rayTrace.hitVec.xCoord+0.5), (rayTrace.hitVec.yCoord+0.5), (rayTrace.hitVec.zCoord+0.5))*4, 0) * modifiers.get(SpellModifiers.DAMAGE)); + Math.max(12.0f - (float)((EntityLivingBase)targets.get(i)).getDistance( + (rayTrace.hitVec.xCoord + 0.5), (rayTrace.hitVec.yCoord + 0.5), + (rayTrace.hitVec.zCoord + 0.5)) * 4, 0) * modifiers.get(SpellModifiers.DAMAGE)); } } if(world.isRemote){ - double dx = (rayTrace.hitVec.xCoord+0.5) - caster.posX; - double dy = (rayTrace.hitVec.yCoord+0.5) - WizardryUtilities.getPlayerEyesPos(caster); - double dz = (rayTrace.hitVec.zCoord+0.5) - caster.posZ; - world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, (rayTrace.hitVec.xCoord+0.5), (rayTrace.hitVec.yCoord+0.5), (rayTrace.hitVec.zCoord+0.5), 0, 0, 0); - for(int i=1;i<5;i++){ - world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0); - world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0); + double dx = (rayTrace.hitVec.xCoord + 0.5) - caster.posX; + double dy = (rayTrace.hitVec.yCoord + 0.5) - WizardryUtilities.getPlayerEyesPos(caster); + double dz = (rayTrace.hitVec.zCoord + 0.5) - caster.posZ; + world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, (rayTrace.hitVec.xCoord + 0.5), + (rayTrace.hitVec.yCoord + 0.5), (rayTrace.hitVec.zCoord + 0.5), 0, 0, 0); + for(int i = 1; i < 5; i++){ + world.spawnParticle(EnumParticleTypes.FLAME, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0); + world.spawnParticle(EnumParticleTypes.FLAME, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0); } } - world.playSound(caster, (rayTrace.hitVec.xCoord+0.5), (rayTrace.hitVec.yCoord+0.5), (rayTrace.hitVec.zCoord+0.5), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F); + world.playSound(caster, (rayTrace.hitVec.xCoord + 0.5), (rayTrace.hitVec.yCoord + 0.5), + (rayTrace.hitVec.zCoord + 0.5), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, + (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F); caster.swingArm(hand); return true; } @@ -60,15 +74,18 @@ public class Detonate extends Spell { } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ if(target != null){ if(!world.isRemote){ - List targets = WizardryUtilities.getEntitiesWithinRadius(3.0d, target.posX, target.posY, target.posZ, world); - for(int i=0;i targets = WizardryUtilities.getEntitiesWithinRadius(3.0d, target.posX, + target.posY, target.posZ, world); + for(int i = 0; i < targets.size(); i++){ targets.get(i).attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.BLAST), // Damage decreases with distance but cannot be less than 0, naturally. - Math.max(12.0f - (float)((EntityLivingBase)targets.get(i)).getDistance(target.posX, target.posY, target.posZ)*4, 0) * modifiers.get(SpellModifiers.DAMAGE)); + Math.max(12.0f - (float)((EntityLivingBase)targets.get(i)).getDistance(target.posX, + target.posY, target.posZ) * 4, 0) * modifiers.get(SpellModifiers.DAMAGE)); } } @@ -77,13 +94,21 @@ public class Detonate extends Spell { double dy = target.posY - (caster.posY + caster.getEyeHeight()); double dz = target.posZ - caster.posZ; world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, target.posX, target.posY, target.posZ, 0, 0, 0); - for(int i=1;i<5;i++){ - world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + caster.getEyeHeight() + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0); - world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + caster.getEyeHeight() + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0); + for(int i = 1; i < 5; i++){ + world.spawnParticle(EnumParticleTypes.FLAME, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + caster.posY + caster.getEyeHeight() + (i * (dy / 5)) + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0); + world.spawnParticle(EnumParticleTypes.FLAME, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + caster.posY + caster.getEyeHeight() + (i * (dy / 5)) + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0); } } // Player is null here because the sound was not caused by a player. - world.playSound(null, target.posX, target.posY, target.posZ, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F); + world.playSound(null, target.posX, target.posY, target.posZ, SoundEvents.ENTITY_GENERIC_EXPLODE, + SoundCategory.BLOCKS, 4.0F, + (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F); caster.swingArm(hand); return true; } diff --git a/src/main/java/electroblob/wizardry/spell/Diamondflesh.java b/src/main/java/electroblob/wizardry/spell/Diamondflesh.java index a35d6339..32175e6a 100644 --- a/src/main/java/electroblob/wizardry/spell/Diamondflesh.java +++ b/src/main/java/electroblob/wizardry/spell/Diamondflesh.java @@ -18,33 +18,36 @@ import net.minecraft.world.World; public class Diamondflesh extends Spell { - public Diamondflesh() { + public Diamondflesh(){ super(Tier.MASTER, 100, Element.HEALING, "diamondflesh", SpellType.DEFENCE, 300, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 4, false, false)); + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 4, false, false)); if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.0f, 0.5f, 1.0f); - - x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 0.0f, 0.5f, 1.0f); + + x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.6f, 0.7f, 0.9f); - + z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 0.6f, 0.7f, 0.9f); + } } - - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Earthquake.java b/src/main/java/electroblob/wizardry/spell/Earthquake.java index 05df72ee..b712f6ac 100644 --- a/src/main/java/electroblob/wizardry/spell/Earthquake.java +++ b/src/main/java/electroblob/wizardry/spell/Earthquake.java @@ -18,44 +18,46 @@ import net.minecraft.world.World; public class Earthquake extends Spell { - public Earthquake() { + public Earthquake(){ super(Tier.MASTER, 75, Element.EARTH, "earthquake", SpellType.ATTACK, 250, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(caster.onGround){ - + if(!world.isRemote){ - world.spawnEntityInWorld(new EntityEarthquake(world, caster.posX, caster.getEntityBoundingBox().minY, caster.posZ, - caster, (int)(20*modifiers.get(WizardryItems.blast_upgrade)), modifiers.get(SpellModifiers.DAMAGE))); + world.spawnEntity(new EntityEarthquake(world, caster.posX, caster.getEntityBoundingBox().minY, + caster.posZ, caster, (int)(20 * modifiers.get(WizardryItems.blast_upgrade)), + modifiers.get(SpellModifiers.DAMAGE))); }else{ - - world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, caster.posX, caster.getEntityBoundingBox().minY + 0.1, caster.posZ, 0, 0, 0); - + + world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, caster.posX, + caster.getEntityBoundingBox().minY + 0.1, caster.posZ, 0, 0, 0); + double particleX, particleZ; - - for(int i=0;i<40;i++){ - - particleX = caster.posX - 1.0d + 2*world.rand.nextDouble(); - particleZ = caster.posZ - 1.0d + 2*world.rand.nextDouble(); - + + for(int i = 0; i < 40; i++){ + + particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble(); + particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble(); + IBlockState block = WizardryUtilities.getBlockEntityIsStandingOn(caster); if(block != null){ world.spawnParticle(EnumParticleTypes.BLOCK_DUST, particleX, caster.getEntityBoundingBox().minY, - particleZ, particleX - caster.posX, 0, particleZ - caster.posZ, Block.getStateId(block)); + particleZ, particleX - caster.posX, 0, particleZ - caster.posZ, + Block.getStateId(block)); } } } WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_EARTHQUAKE, 2, 1); caster.swingArm(hand); - + return true; } return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Entrapment.java b/src/main/java/electroblob/wizardry/spell/Entrapment.java index 054a04f8..53c95ec7 100644 --- a/src/main/java/electroblob/wizardry/spell/Entrapment.java +++ b/src/main/java/electroblob/wizardry/spell/Entrapment.java @@ -24,70 +24,84 @@ import net.minecraft.world.World; public class Entrapment extends Spell { - public Entrapment() { + public Entrapment(){ super(Tier.ADVANCED, 35, Element.NECROMANCY, "entrapment", SpellType.ATTACK, 75, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + Vec3d look = caster.getLookVec(); - - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); - - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){ - EntityLivingBase entity = (EntityLivingBase) rayTrace.entityHit; + + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); + + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLivingBase){ + EntityLivingBase entity = (EntityLivingBase)rayTrace.entityHit; if(!world.isRemote){ - entity.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), 1.0f * modifiers.get(SpellModifiers.DAMAGE)); - - EntityBubble entitybubble = new EntityBubble(world, entity.posX, entity.posY, entity.posZ, caster, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), true, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(entitybubble); + entity.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), + 1.0f * modifiers.get(SpellModifiers.DAMAGE)); + + EntityBubble entitybubble = new EntityBubble(world, entity.posX, entity.posY, entity.posZ, caster, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade)), true, + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(entitybubble); entity.startRiding(entitybubble); } } if(world.isRemote){ - for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ - double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; + for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ + double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; world.spawnParticle(EnumParticleTypes.PORTAL, x1, y1 - 0.5, z1, 0.0d, 0.0d, 0.0d); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, + 0.1f, 0.0f, 0.0f); } } caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SHOOT, 1.0F, world.rand.nextFloat() * 0.3F + 0.7F); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SHOOT, 1.0F, + world.rand.nextFloat() * 0.3F + 0.7F); return true; } - + @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ if(!world.isRemote){ - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), 1.0f * modifiers.get(SpellModifiers.DAMAGE)); + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), + 1.0f * modifiers.get(SpellModifiers.DAMAGE)); // Deprecated in favour of entity riding method - //entity.addPotionEffect(new PotionEffect(Wizardry.bubblePotion, 200, 0)); - EntityBubble entitybubble = new EntityBubble(world, target.posX, target.posY, target.posZ, caster, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), true, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(entitybubble); + // entity.addPotionEffect(new PotionEffect(Wizardry.bubblePotion, 200, 0)); + EntityBubble entitybubble = new EntityBubble(world, target.posX, target.posY, target.posZ, caster, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade)), true, + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(entitybubble); target.startRiding(entitybubble); } if(world.isRemote){ - double dx = (target.posX - caster.posX)/caster.getDistanceToEntity(target); - double dy = (target.posY - caster.posY)/caster.getDistanceToEntity(target); - double dz = (target.posZ - caster.posZ)/caster.getDistanceToEntity(target); - - for(int i=1; i<25; i+=2){ + double dx = (target.posX - caster.posX) / caster.getDistanceToEntity(target); + double dy = (target.posY - caster.posY) / caster.getDistanceToEntity(target); + double dz = (target.posZ - caster.posZ) / caster.getDistanceToEntity(target); - double x1 = caster.posX + dx*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + dz*i/2 + world.rand.nextFloat()/5 - 0.1f; + for(int i = 1; i < 25; i += 2){ + + double x1 = caster.posX + dx * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy * i / 2 + world.rand.nextFloat() / 5 + - 0.1f; + double z1 = caster.posZ + dz * i / 2 + world.rand.nextFloat() / 5 - 0.1f; world.spawnParticle(EnumParticleTypes.PORTAL, x1, y1 - 0.5, z1, 0.0d, 0.0d, 0.0d); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 0, 0.1f, 0.0f, 0.0f); } } caster.swingArm(hand); @@ -97,7 +111,7 @@ public class Entrapment extends Spell { return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/FireResistance.java b/src/main/java/electroblob/wizardry/spell/FireResistance.java index cabe587e..d4c85af3 100644 --- a/src/main/java/electroblob/wizardry/spell/FireResistance.java +++ b/src/main/java/electroblob/wizardry/spell/FireResistance.java @@ -20,47 +20,53 @@ import net.minecraft.world.World; public class FireResistance extends Spell { - public FireResistance() { + public FireResistance(){ super(Tier.ADVANCED, 20, Element.FIRE, "fire_resistance", SpellType.DEFENCE, 80, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ - caster.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0, false, false)); + caster.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0, false, false)); if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 0.5f, 0.0f); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 1.0f, 0.5f, 0.0f); } } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return true; } - + @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) { - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + // Like witches, wizards who have this spell will only cast it if they are on fire. if(caster.isBurning() && !caster.isPotionActive(MobEffects.FIRE_RESISTANCE)){ - - caster.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0, false, false)); - + + caster.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0, false, false)); + if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)caster.posY + caster.getEyeHeight() - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 0.5f, 0.0f); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 1.0f, 0.5f, 0.0f); } } caster.playSound(WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); return true; } - + return false; } diff --git a/src/main/java/electroblob/wizardry/spell/FireSigil.java b/src/main/java/electroblob/wizardry/spell/FireSigil.java index 4b452a4a..0fe7115a 100644 --- a/src/main/java/electroblob/wizardry/spell/FireSigil.java +++ b/src/main/java/electroblob/wizardry/spell/FireSigil.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class FireSigil extends Spell { - public FireSigil() { + public FireSigil(){ super(Tier.APPRENTICE, 10, Element.FIRE, "fire_sigil", SpellType.ATTACK, 20, EnumAction.NONE, false); } @@ -27,17 +27,19 @@ public class FireSigil extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - RayTraceResult rayTrace = WizardryUtilities.rayTrace(10*modifiers.get(WizardryItems.range_upgrade), world, caster, false); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + RayTraceResult rayTrace = WizardryUtilities.rayTrace(10 * modifiers.get(WizardryItems.range_upgrade), world, + caster, false); + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK && rayTrace.sideHit == EnumFacing.UP){ if(!world.isRemote){ double x = rayTrace.hitVec.xCoord; double y = rayTrace.hitVec.yCoord; double z = rayTrace.hitVec.zCoord; - EntityFireSigil firesigil = new EntityFireSigil(world, x, y, z, caster, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(firesigil); + EntityFireSigil firesigil = new EntityFireSigil(world, x, y, z, caster, + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(firesigil); } caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ITEM_FLINTANDSTEEL_USE, 1.0F, 1.0F); @@ -46,5 +48,4 @@ public class FireSigil extends Spell { return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Fireball.java b/src/main/java/electroblob/wizardry/spell/Fireball.java index 8fcfe1c7..d88b6a34 100644 --- a/src/main/java/electroblob/wizardry/spell/Fireball.java +++ b/src/main/java/electroblob/wizardry/spell/Fireball.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class Fireball extends Spell { - public Fireball() { + public Fireball(){ super(Tier.APPRENTICE, 10, Element.FIRE, "fireball", SpellType.ATTACK, 15, EnumAction.NONE, false); // Does 2.5 hearts of damage and 5 seconds of fire, for reference. } @@ -28,20 +28,17 @@ public class Fireball extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ Vec3d look = caster.getLookVec(); if(!world.isRemote){ EntitySmallFireball fireball = new EntitySmallFireball(world, caster, 1, 1, 1); - fireball.setPosition( - caster.posX + look.xCoord, - caster.posY + look.yCoord + 1.3, - caster.posZ + look.zCoord); + fireball.setPosition(caster.posX + look.xCoord, caster.posY + look.yCoord + 1.3, caster.posZ + look.zCoord); fireball.accelerationX = look.xCoord * 0.1; fireball.accelerationY = look.yCoord * 0.1; fireball.accelerationZ = look.zCoord * 0.1; - world.spawnEntityInWorld(fireball); + world.spawnEntity(fireball); } WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1); @@ -50,27 +47,29 @@ public class Fireball extends Spell { } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - + EntitySmallFireball fireball = new EntitySmallFireball(world, caster, 1, 1, 1); - + double dx = target.posX - caster.posX; - double dy = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) - (caster.posY + (double)(caster.height / 2.0F)); - double dz = target.posZ - caster.posZ; - - fireball.accelerationX = dx/caster.getDistanceToEntity(target) * 0.1; - fireball.accelerationY = dy/caster.getDistanceToEntity(target) * 0.1; - fireball.accelerationZ = dz/caster.getDistanceToEntity(target) * 0.1; - - fireball.setPosition(caster.posX, caster.posY + caster.getEyeHeight(), caster.posZ); - - world.spawnEntityInWorld(fireball); + double dy = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) + - (caster.posY + (double)(caster.height / 2.0F)); + double dz = target.posZ - caster.posZ; + + fireball.accelerationX = dx / caster.getDistanceToEntity(target) * 0.1; + fireball.accelerationY = dy / caster.getDistanceToEntity(target) * 0.1; + fireball.accelerationZ = dz / caster.getDistanceToEntity(target) * 0.1; + + fireball.setPosition(caster.posX, caster.posY + caster.getEyeHeight(), caster.posZ); + + world.spawnEntity(fireball); } - + caster.playSound(SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1); caster.swingArm(hand); return true; diff --git a/src/main/java/electroblob/wizardry/spell/Firebolt.java b/src/main/java/electroblob/wizardry/spell/Firebolt.java index 5053ea0e..f81804b1 100644 --- a/src/main/java/electroblob/wizardry/spell/Firebolt.java +++ b/src/main/java/electroblob/wizardry/spell/Firebolt.java @@ -16,7 +16,7 @@ import net.minecraft.world.World; public class Firebolt extends Spell { - public Firebolt() { + public Firebolt(){ super(Tier.APPRENTICE, 10, Element.FIRE, "firebolt", SpellType.ATTACK, 10, EnumAction.NONE, false); } @@ -26,40 +26,41 @@ public class Firebolt extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ EntityFirebolt firebolt = new EntityFirebolt(world, caster, modifiers.get(SpellModifiers.DAMAGE)); firebolt.motionX *= 2.5; firebolt.motionY *= 2.5; firebolt.motionZ *= 2.5; - world.spawnEntityInWorld(firebolt); + world.spawnEntity(firebolt); } - + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1); caster.swingArm(hand); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ EntityFirebolt firebolt = new EntityFirebolt(world, caster, modifiers.get(SpellModifiers.DAMAGE)); firebolt.directTowards(target, 2.5f); - world.spawnEntityInWorld(firebolt); + world.spawnEntity(firebolt); } caster.playSound(SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1); caster.swingArm(hand); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/Firebomb.java b/src/main/java/electroblob/wizardry/spell/Firebomb.java index 8db08672..6a95a583 100644 --- a/src/main/java/electroblob/wizardry/spell/Firebomb.java +++ b/src/main/java/electroblob/wizardry/spell/Firebomb.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class Firebomb extends Spell { - public Firebomb() { + public Firebomb(){ super(Tier.APPRENTICE, 15, Element.FIRE, "firebomb", SpellType.ATTACK, 25, EnumAction.NONE, false); } @@ -27,37 +27,41 @@ public class Firebomb extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ - EntityFirebomb firebomb = new EntityFirebomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade)); - world.spawnEntityInWorld(firebomb); + EntityFirebomb firebomb = new EntityFirebomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), + modifiers.get(WizardryItems.blast_upgrade)); + world.spawnEntity(firebomb); } - + caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, + 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - EntityFirebomb firebomb = new EntityFirebomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade)); + EntityFirebomb firebomb = new EntityFirebomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), + modifiers.get(WizardryItems.blast_upgrade)); firebomb.directTowards(target, 1.5f); - world.spawnEntityInWorld(firebomb); + world.spawnEntity(firebomb); } - + caster.swingArm(hand); caster.playSound(SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/Fireskin.java b/src/main/java/electroblob/wizardry/spell/Fireskin.java index efd847be..20f4497f 100644 --- a/src/main/java/electroblob/wizardry/spell/Fireskin.java +++ b/src/main/java/electroblob/wizardry/spell/Fireskin.java @@ -18,7 +18,7 @@ import net.minecraft.world.World; public class Fireskin extends Spell { - public Fireskin() { + public Fireskin(){ super(Tier.ADVANCED, 40, Element.FIRE, "fireskin", SpellType.DEFENCE, 250, EnumAction.BOW, false); } @@ -28,40 +28,43 @@ public class Fireskin extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + // Cannot be cast when it has already been cast if(!caster.isPotionActive(WizardryPotions.fireskin)){ if(!world.isRemote){ - caster.addPotionEffect(new PotionEffect(WizardryPotions.fireskin, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0)); + caster.addPotionEffect(new PotionEffect(WizardryPotions.fireskin, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0)); } WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1); return true; } return false; } - + @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) { - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ // Cannot be cast when it has already been cast if(!caster.isPotionActive(WizardryPotions.fireskin)){ if(!world.isRemote){ - caster.addPotionEffect(new PotionEffect(WizardryPotions.fireskin, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0)); + caster.addPotionEffect(new PotionEffect(WizardryPotions.fireskin, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0)); } caster.playSound(SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1); return true; } return false; } - + return false; } @Override - public boolean canBeCastByNPCs() { + public boolean canBeCastByNPCs(){ return true; } - + } diff --git a/src/main/java/electroblob/wizardry/spell/Firestorm.java b/src/main/java/electroblob/wizardry/spell/Firestorm.java index e6481dc6..16f575f9 100644 --- a/src/main/java/electroblob/wizardry/spell/Firestorm.java +++ b/src/main/java/electroblob/wizardry/spell/Firestorm.java @@ -25,47 +25,59 @@ import net.minecraft.world.World; public class Firestorm extends Spell { - public Firestorm() { + public Firestorm(){ super(Tier.MASTER, 15, Element.FIRE, "firestorm", SpellType.ATTACK, 0, EnumAction.NONE, true); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + Vec3d look = caster.getLookVec(); - - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); - - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){ - - EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit; - + + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); + + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLivingBase){ + + EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit; + if(!MagicDamage.isEntityImmune(DamageType.FIRE, target)){ target.setFire(10); - WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.FIRE), 6.0f * modifiers.get(SpellModifiers.DAMAGE)); + WizardryUtilities.attackEntityWithoutKnockback(target, + MagicDamage.causeDirectMagicDamage(caster, DamageType.FIRE), + 6.0f * modifiers.get(SpellModifiers.DAMAGE)); }else{ - if(!world.isRemote && ticksInUse == 1) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted())); + if(!world.isRemote && ticksInUse == 1) caster.sendMessage(new TextComponentTranslation("spell.resist", + target.getName(), this.getNameForTranslationFormatted())); } - + }else if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){ - + BlockPos pos = rayTrace.getBlockPos().offset(rayTrace.sideHit); - + if(world.isAirBlock(pos)){ if(!world.isRemote){ world.setBlockState(pos, Blocks.FIRE.getDefaultState()); } } } - + if(world.isRemote){ - for(int i=0; i<40; i++){ + for(int i = 0; i < 40; i++){ // I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet! - double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()*0.6f - 0.3f; - double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()*0.4f - 0.2f; - double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()*0.6f - 0.3f; - Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, look.xCoord*modifiers.get(WizardryItems.range_upgrade), look.yCoord*modifiers.get(WizardryItems.range_upgrade), look.zCoord*modifiers.get(WizardryItems.range_upgrade), 0, 3 + world.rand.nextFloat(), 0, 0); - Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, look.xCoord*modifiers.get(WizardryItems.range_upgrade), look.yCoord*modifiers.get(WizardryItems.range_upgrade), look.zCoord*modifiers.get(WizardryItems.range_upgrade), 0, 3 + world.rand.nextFloat(), 0, 0); + double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() * 0.6f - 0.3f; + double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() * 0.4f - 0.2f; + double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() * 0.6f - 0.3f; + Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, + look.xCoord * modifiers.get(WizardryItems.range_upgrade), + look.yCoord * modifiers.get(WizardryItems.range_upgrade), + look.zCoord * modifiers.get(WizardryItems.range_upgrade), 0, 3 + world.rand.nextFloat(), 0, 0); + Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, + look.xCoord * modifiers.get(WizardryItems.range_upgrade), + look.yCoord * modifiers.get(WizardryItems.range_upgrade), + look.zCoord * modifiers.get(WizardryItems.range_upgrade), 0, 3 + world.rand.nextFloat(), 0, 0); } } if(ticksInUse % 16 == 0){ @@ -75,5 +87,4 @@ public class Firestorm extends Spell { return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/FlameRay.java b/src/main/java/electroblob/wizardry/spell/FlameRay.java index 63b81f58..aab00990 100644 --- a/src/main/java/electroblob/wizardry/spell/FlameRay.java +++ b/src/main/java/electroblob/wizardry/spell/FlameRay.java @@ -24,36 +24,48 @@ import net.minecraft.world.World; public class FlameRay extends Spell { - public FlameRay() { + public FlameRay(){ super(Tier.APPRENTICE, 5, Element.FIRE, "flame_ray", SpellType.ATTACK, 0, EnumAction.NONE, true); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + Vec3d look = caster.getLookVec(); - - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); - - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){ - - EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit; - + + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); + + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLivingBase){ + + EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit; + if(!MagicDamage.isEntityImmune(DamageType.FIRE, target)){ target.setFire(10); - WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.FIRE), 3.0f * modifiers.get(SpellModifiers.DAMAGE)); + WizardryUtilities.attackEntityWithoutKnockback(target, + MagicDamage.causeDirectMagicDamage(caster, DamageType.FIRE), + 3.0f * modifiers.get(SpellModifiers.DAMAGE)); }else{ - if(!world.isRemote && ticksInUse == 1) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted())); + if(!world.isRemote && ticksInUse == 1) caster.sendMessage(new TextComponentTranslation("spell.resist", + target.getName(), this.getNameForTranslationFormatted())); } } if(world.isRemote){ - for(int i=0; i<20; i++){ + for(int i = 0; i < 20; i++){ // I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet! - double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, look.xCoord*modifiers.get(WizardryItems.range_upgrade), look.yCoord*modifiers.get(WizardryItems.range_upgrade), look.zCoord*modifiers.get(WizardryItems.range_upgrade), 0); - Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, look.xCoord*modifiers.get(WizardryItems.range_upgrade), look.yCoord*modifiers.get(WizardryItems.range_upgrade), look.zCoord*modifiers.get(WizardryItems.range_upgrade), 0); + double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, + look.xCoord * modifiers.get(WizardryItems.range_upgrade), + look.yCoord * modifiers.get(WizardryItems.range_upgrade), + look.zCoord * modifiers.get(WizardryItems.range_upgrade), 0); + Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, + look.xCoord * modifiers.get(WizardryItems.range_upgrade), + look.yCoord * modifiers.get(WizardryItems.range_upgrade), + look.zCoord * modifiers.get(WizardryItems.range_upgrade), 0); } } if(ticksInUse % 16 == 0){ @@ -62,23 +74,34 @@ public class FlameRay extends Spell { } return true; } - + @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) { - - Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ).normalize(); - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + + Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ) + .normalize(); + if(target != null){ target.setFire(10); - WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.FIRE), 3.0f * modifiers.get(SpellModifiers.DAMAGE)); + WizardryUtilities.attackEntityWithoutKnockback(target, + MagicDamage.causeDirectMagicDamage(caster, DamageType.FIRE), + 3.0f * modifiers.get(SpellModifiers.DAMAGE)); } if(world.isRemote){ - for(int i=0; i<20; i++){ - double x1 = caster.posX + vec.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + vec.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, vec.xCoord*modifiers.get(WizardryItems.range_upgrade), vec.yCoord*modifiers.get(WizardryItems.range_upgrade), vec.zCoord*modifiers.get(WizardryItems.range_upgrade), 0); - Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, vec.xCoord*modifiers.get(WizardryItems.range_upgrade), vec.yCoord*modifiers.get(WizardryItems.range_upgrade), vec.zCoord*modifiers.get(WizardryItems.range_upgrade), 0); + for(int i = 0; i < 20; i++){ + double x1 = caster.posX + vec.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord * i / 2 + world.rand.nextFloat() / 5 + - 0.1f; + double z1 = caster.posZ + vec.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, + vec.xCoord * modifiers.get(WizardryItems.range_upgrade), + vec.yCoord * modifiers.get(WizardryItems.range_upgrade), + vec.zCoord * modifiers.get(WizardryItems.range_upgrade), 0); + Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, + vec.xCoord * modifiers.get(WizardryItems.range_upgrade), + vec.yCoord * modifiers.get(WizardryItems.range_upgrade), + vec.zCoord * modifiers.get(WizardryItems.range_upgrade), 0); } } if(ticksInUse % 16 == 0){ @@ -87,7 +110,7 @@ public class FlameRay extends Spell { } return true; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/FlamingAxe.java b/src/main/java/electroblob/wizardry/spell/FlamingAxe.java index f09d5f6a..b320de52 100644 --- a/src/main/java/electroblob/wizardry/spell/FlamingAxe.java +++ b/src/main/java/electroblob/wizardry/spell/FlamingAxe.java @@ -17,33 +17,34 @@ import net.minecraft.world.World; public class FlamingAxe extends Spell { - public FlamingAxe() { + public FlamingAxe(){ super(Tier.ADVANCED, 45, Element.FIRE, "flaming_axe", SpellType.UTILITY, 50, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ ItemStack flamingaxe = new ItemStack(WizardryItems.flaming_axe); - + IConjuredItem.setDurationMultiplier(flamingaxe, modifiers.get(WizardryItems.duration_upgrade)); - if(!WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.flaming_axe) && ConjureBow.conjureItemInInventory(caster, flamingaxe)){ + if(!WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.flaming_axe) + && ConjureBow.conjureItemInInventory(caster, flamingaxe)){ if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); - double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); + double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + + world.rand.nextFloat()); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); world.spawnParticle(EnumParticleTypes.FLAME, x1, y1, z1, 0, 0, 0); } } - + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1); return true; } return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/FlamingWeapon.java b/src/main/java/electroblob/wizardry/spell/FlamingWeapon.java index d5fa4a94..f347d6e5 100644 --- a/src/main/java/electroblob/wizardry/spell/FlamingWeapon.java +++ b/src/main/java/electroblob/wizardry/spell/FlamingWeapon.java @@ -23,45 +23,49 @@ import net.minecraft.world.World; public class FlamingWeapon extends Spell { - public FlamingWeapon() { + public FlamingWeapon(){ super(Tier.ADVANCED, 35, Element.FIRE, "flaming_weapon", SpellType.UTILITY, 70, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ // Won't work if the weapon already has the enchantment - if(WizardData.get(caster) != null && WizardData.get(caster).getImbuementDuration(WizardryEnchantments.flaming_weapon) <= 0){ + if(WizardData.get(caster) != null + && WizardData.get(caster).getImbuementDuration(WizardryEnchantments.flaming_weapon) <= 0){ for(ItemStack stack : WizardryUtilities.getPrioritisedHotbarAndOffhand(caster)){ - if(stack != null){ + if((stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow) + && !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.flaming_weapon)){ + // The enchantment level as determined by the damage multiplier. The + 0.5f is so that + // weird float processing doesn't incorrectly round it down. + stack.addEnchantment(WizardryEnchantments.flaming_weapon, + modifiers.get(SpellModifiers.DAMAGE) == 1.0f ? 1 + : (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f) + / Constants.DAMAGE_INCREASE_PER_TIER + 0.5f)); - if((stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow) && !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.flaming_weapon)){ - // The enchantment level as determined by the damage multiplier. The + 0.5f is so that - // weird float processing doesn't incorrectly round it down. - stack.addEnchantment(WizardryEnchantments.flaming_weapon, modifiers.get(SpellModifiers.DAMAGE) == 1.0f ? 1 : (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f)/Constants.DAMAGE_INCREASE_PER_TIER + 0.5f)); + WizardData.get(caster).setImbuementDuration(WizardryEnchantments.flaming_weapon, + (int)(900 * modifiers.get(WizardryItems.duration_upgrade))); - WizardData.get(caster).setImbuementDuration(WizardryEnchantments.flaming_weapon, (int)(900*modifiers.get(WizardryItems.duration_upgrade))); - - if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); - double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.9f, 0.7f, 1.0f); - } + if(world.isRemote){ + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); + double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + + world.rand.nextFloat()); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 0.9f, 0.7f, 1.0f); } - - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f); - return true; - } + + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f); + return true; + } } } return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Flight.java b/src/main/java/electroblob/wizardry/spell/Flight.java index b4cf6c68..345216fb 100644 --- a/src/main/java/electroblob/wizardry/spell/Flight.java +++ b/src/main/java/electroblob/wizardry/spell/Flight.java @@ -20,24 +20,31 @@ public class Flight extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!caster.isInWater() && !caster.isElytraFlying()){ // The division thingy checks if the look direction is the opposite way to the velocity. If this is the // case then the velocity should be added regardless of the player's current speed. - if((Math.abs(caster.motionX) < 0.6 || caster.motionX/caster.getLookVec().xCoord < 0) - && (Math.abs(caster.motionZ) < 0.6 || caster.motionZ/caster.getLookVec().zCoord < 0)){ - caster.addVelocity(caster.getLookVec().xCoord/20, 0, caster.getLookVec().zCoord/20); + if((Math.abs(caster.motionX) < 0.6 || caster.motionX / caster.getLookVec().xCoord < 0) + && (Math.abs(caster.motionZ) < 0.6 || caster.motionZ / caster.getLookVec().zCoord < 0)){ + caster.addVelocity(caster.getLookVec().xCoord / 20, 0, caster.getLookVec().zCoord / 20); } - // y velocity is handled separately to stop the player from falling from the sky when they reach maximum horizontal speed. - if(Math.abs(caster.motionY) < 0.6 || caster.motionY/caster.getLookVec().yCoord < 0){ - caster.motionY += caster.getLookVec().yCoord/20 + 0.075; + // y velocity is handled separately to stop the player from falling from the sky when they reach maximum + // horizontal speed. + if(Math.abs(caster.motionY) < 0.6 || caster.motionY / caster.getLookVec().yCoord < 0){ + caster.motionY += caster.getLookVec().yCoord / 20 + 0.075; } caster.fallDistance = 0.0f; } if(world.isRemote){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX - 1 + world.rand.nextDouble()*2, WizardryUtilities.getPlayerEyesPos(caster) - 0.5f + world.rand.nextDouble(), caster.posZ - 1 + world.rand.nextDouble()*2, 0, -0.1F, 0, 15, 0.8f, 1.0f, 0.5f); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX - 1 + world.rand.nextDouble()*2, WizardryUtilities.getPlayerEyesPos(caster) - 0.5f + world.rand.nextDouble(), caster.posZ - 1 + world.rand.nextDouble()*2, 0, -0.1F, 0, 15, 1.0f, 1.0f, 1.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + caster.posX - 1 + world.rand.nextDouble() * 2, + WizardryUtilities.getPlayerEyesPos(caster) - 0.5f + world.rand.nextDouble(), + caster.posZ - 1 + world.rand.nextDouble() * 2, 0, -0.1F, 0, 15, 0.8f, 1.0f, 0.5f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + caster.posX - 1 + world.rand.nextDouble() * 2, + WizardryUtilities.getPlayerEyesPos(caster) - 0.5f + world.rand.nextDouble(), + caster.posZ - 1 + world.rand.nextDouble() * 2, 0, -0.1F, 0, 15, 1.0f, 1.0f, 1.0f); } if(ticksInUse % 24 == 0){ WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ENDERDRAGON_FLAP, 0.5F, 1.0f); @@ -45,5 +52,4 @@ public class Flight extends Spell { return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/FontOfMana.java b/src/main/java/electroblob/wizardry/spell/FontOfMana.java index e6377b76..cbe2ef35 100644 --- a/src/main/java/electroblob/wizardry/spell/FontOfMana.java +++ b/src/main/java/electroblob/wizardry/spell/FontOfMana.java @@ -20,36 +20,42 @@ import net.minecraft.world.World; public class FontOfMana extends Spell { - public FontOfMana() { + public FontOfMana(){ super(Tier.MASTER, 100, Element.HEALING, "font_of_mana", SpellType.UTILITY, 250, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - List targets = WizardryUtilities.getEntitiesWithinRadius(5*modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world, EntityPlayer.class); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + List targets = WizardryUtilities.getEntitiesWithinRadius( + 5 * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world, + EntityPlayer.class); + for(EntityPlayer target : targets){ if(WizardryUtilities.isPlayerAlly(caster, target) || target == caster){ - // Damage multiplier can only ever be 1 or 1.6 for master spells, so there's little point in actually calculating this. - target.addPotionEffect(new PotionEffect(WizardryPotions.font_of_mana, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE) > 1 ? 1 : 0)); + // Damage multiplier can only ever be 1 or 1.6 for master spells, so there's little point in actually + // calculating this. + target.addPotionEffect(new PotionEffect(WizardryPotions.font_of_mana, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), + modifiers.get(SpellModifiers.DAMAGE) > 1 ? 1 : 0)); } } - + if(world.isRemote){ - for(int i=0;i<100*modifiers.get(WizardryItems.blast_upgrade);i++){ - double radius = (1 + world.rand.nextDouble()*4)*modifiers.get(WizardryItems.blast_upgrade); - double angle = world.rand.nextDouble()*Math.PI*2; - float hue = world.rand.nextFloat()*0.4f; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX + radius*Math.cos(angle), caster.getEntityBoundingBox().minY, caster.posZ + radius*Math.sin(angle), - 0, 0.03, 0, 50, 1, 1-hue, 0.6f+hue); + for(int i = 0; i < 100 * modifiers.get(WizardryItems.blast_upgrade); i++){ + double radius = (1 + world.rand.nextDouble() * 4) * modifiers.get(WizardryItems.blast_upgrade); + double angle = world.rand.nextDouble() * Math.PI * 2; + float hue = world.rand.nextFloat() * 0.4f; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + caster.posX + radius * Math.cos(angle), caster.getEntityBoundingBox().minY, + caster.posZ + radius * Math.sin(angle), 0, 0.03, 0, 50, 1, 1 - hue, 0.6f + hue); } } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/FontOfVitality.java b/src/main/java/electroblob/wizardry/spell/FontOfVitality.java index 1056b526..e951008c 100644 --- a/src/main/java/electroblob/wizardry/spell/FontOfVitality.java +++ b/src/main/java/electroblob/wizardry/spell/FontOfVitality.java @@ -18,36 +18,40 @@ import net.minecraft.world.World; public class FontOfVitality extends Spell { - public FontOfVitality() { + public FontOfVitality(){ super(Tier.MASTER, 75, Element.HEALING, "font_of_vitality", SpellType.DEFENCE, 300, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ - caster.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, (int)(1200*modifiers.get(WizardryItems.duration_upgrade)), 1, false, false)); - caster.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 1, false, false)); + caster.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, + (int)(1200 * modifiers.get(WizardryItems.duration_upgrade)), 1, false, false)); + caster.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, + (int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 1, false, false)); if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 0.6f, 0.7f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 1.0f, 0.6f, 0.7f); - x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); + z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 0.8f, 0.3f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 1.0f, 0.8f, 0.3f); } } - - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/ForceArrow.java b/src/main/java/electroblob/wizardry/spell/ForceArrow.java index 05cd68eb..f052b43f 100644 --- a/src/main/java/electroblob/wizardry/spell/ForceArrow.java +++ b/src/main/java/electroblob/wizardry/spell/ForceArrow.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class ForceArrow extends Spell { - public ForceArrow() { + public ForceArrow(){ super(Tier.APPRENTICE, 15, Element.SORCERY, "force_arrow", SpellType.ATTACK, 20, EnumAction.NONE, false); } @@ -27,36 +27,40 @@ public class ForceArrow extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ - EntityForceArrow forceArrow = new EntityForceArrow(world, caster, 1*modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(forceArrow); + EntityForceArrow forceArrow = new EntityForceArrow(world, caster, + 1 * modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(forceArrow); } - + caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_FORCE, 1.0f, 1.2f + world.rand.nextFloat()*0.2f); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_FORCE, 1.0f, + 1.2f + world.rand.nextFloat() * 0.2f); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - EntityForceArrow forceArrow = new EntityForceArrow(world, caster, target, 1*modifiers.get(WizardryItems.range_upgrade), 2, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(forceArrow); + EntityForceArrow forceArrow = new EntityForceArrow(world, caster, target, + 1 * modifiers.get(WizardryItems.range_upgrade), 2, modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(forceArrow); } - + caster.swingArm(hand); - caster.playSound(WizardrySounds.SPELL_FORCE, 1.0f, 1.2f + world.rand.nextFloat()*0.2f); + caster.playSound(WizardrySounds.SPELL_FORCE, 1.0f, 1.2f + world.rand.nextFloat() * 0.2f); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/ForceOrb.java b/src/main/java/electroblob/wizardry/spell/ForceOrb.java index 30ee52a4..5db4e5fa 100644 --- a/src/main/java/electroblob/wizardry/spell/ForceOrb.java +++ b/src/main/java/electroblob/wizardry/spell/ForceOrb.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class ForceOrb extends Spell { - public ForceOrb() { + public ForceOrb(){ super(Tier.ADVANCED, 20, Element.SORCERY, "force_orb", SpellType.ATTACK, 20, EnumAction.NONE, false); } @@ -27,37 +27,41 @@ public class ForceOrb extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ - EntityForceOrb forceOrb = new EntityForceOrb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade)); - world.spawnEntityInWorld(forceOrb); + EntityForceOrb forceOrb = new EntityForceOrb(world, caster, modifiers.get(SpellModifiers.DAMAGE), + modifiers.get(WizardryItems.blast_upgrade)); + world.spawnEntity(forceOrb); } - + caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, + 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - EntityForceOrb forceOrb = new EntityForceOrb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade)); + EntityForceOrb forceOrb = new EntityForceOrb(world, caster, modifiers.get(SpellModifiers.DAMAGE), + modifiers.get(WizardryItems.blast_upgrade)); forceOrb.directTowards(target, 1.5f); - world.spawnEntityInWorld(forceOrb); + world.spawnEntity(forceOrb); } - + caster.swingArm(hand); caster.playSound(SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/Forcefield.java b/src/main/java/electroblob/wizardry/spell/Forcefield.java index 0b366bd1..eea373b9 100644 --- a/src/main/java/electroblob/wizardry/spell/Forcefield.java +++ b/src/main/java/electroblob/wizardry/spell/Forcefield.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class Forcefield extends Spell { - public Forcefield() { + public Forcefield(){ super(Tier.ADVANCED, 45, Element.HEALING, "forcefield", SpellType.DEFENCE, 200, EnumAction.BOW, false); } @@ -27,43 +27,47 @@ public class Forcefield extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(caster.onGround){ if(!world.isRemote){ - EntityForcefield forcefield = new EntityForcefield(world, caster.posX, caster.posY, caster.posZ, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(forcefield); + EntityForcefield forcefield = new EntityForcefield(world, caster.posX, caster.posY, caster.posZ, caster, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(forcefield); } WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION_LARGE, 1.0f, 1.0f); return true; } - + return false; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ // Wizards can no longer cast forcefield when they are inside one - if(caster.onGround && world.getEntitiesWithinAABB(EntityForcefield.class, caster.getEntityBoundingBox()).isEmpty()){ + if(caster.onGround + && world.getEntitiesWithinAABB(EntityForcefield.class, caster.getEntityBoundingBox()).isEmpty()){ if(!world.isRemote){ - EntityForcefield forcefield = new EntityForcefield(world, caster.posX, caster.posY, caster.posZ, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(forcefield); + EntityForcefield forcefield = new EntityForcefield(world, caster.posX, caster.posY, caster.posZ, + caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(forcefield); } caster.playSound(WizardrySounds.SPELL_CONJURATION_LARGE, 1.0f, 1.0f); return true; } - + return false; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; } - + } diff --git a/src/main/java/electroblob/wizardry/spell/ForestsCurse.java b/src/main/java/electroblob/wizardry/spell/ForestsCurse.java index 68612acd..33487073 100644 --- a/src/main/java/electroblob/wizardry/spell/ForestsCurse.java +++ b/src/main/java/electroblob/wizardry/spell/ForestsCurse.java @@ -23,42 +23,54 @@ import net.minecraft.world.World; public class ForestsCurse extends Spell { - public ForestsCurse() { + public ForestsCurse(){ super(Tier.MASTER, 75, Element.EARTH, "forests_curse", SpellType.ATTACK, 200, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - List targets = WizardryUtilities.getEntitiesWithinRadius(5.0d*modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + List targets = WizardryUtilities.getEntitiesWithinRadius( + 5.0d * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world); + for(EntityLivingBase target : targets){ - if(WizardryUtilities.isValidTarget(caster, target) && !MagicDamage.isEntityImmune(DamageType.POISON, target)){ - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.POISON), 4.0f * modifiers.get(SpellModifiers.DAMAGE)); - target.addPotionEffect(new PotionEffect(MobEffects.POISON, (int)(140*modifiers.get(WizardryItems.duration_upgrade)), 2)); - target.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, (int)(140*modifiers.get(WizardryItems.duration_upgrade)), 2)); - target.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, (int)(140*modifiers.get(WizardryItems.duration_upgrade)), 2)); + if(WizardryUtilities.isValidTarget(caster, target) + && !MagicDamage.isEntityImmune(DamageType.POISON, target)){ + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.POISON), + 4.0f * modifiers.get(SpellModifiers.DAMAGE)); + target.addPotionEffect(new PotionEffect(MobEffects.POISON, + (int)(140 * modifiers.get(WizardryItems.duration_upgrade)), 2)); + target.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, + (int)(140 * modifiers.get(WizardryItems.duration_upgrade)), 2)); + target.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, + (int)(140 * modifiers.get(WizardryItems.duration_upgrade)), 2)); } } - + if(world.isRemote){ - for(int i=0;i<50*modifiers.get(WizardryItems.blast_upgrade);i++){ - double radius = (1 + world.rand.nextDouble()*4)*modifiers.get(WizardryItems.blast_upgrade); - double angle = world.rand.nextDouble()*Math.PI*2; - float brightness = world.rand.nextFloat()/4; - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, caster.posX + radius*Math.cos(angle), WizardryUtilities.getPlayerEyesPos(caster) + 0.5, caster.posZ + radius*Math.sin(angle), - 0, -0.2, 0, 0, 0.05f+brightness, 0.2f+brightness, 0.0f); - brightness = world.rand.nextFloat()/4; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX + radius*Math.cos(angle), WizardryUtilities.getPlayerEyesPos(caster) + 0.5, caster.posZ + radius*Math.sin(angle), - 0, -0.05, 0, 50, 0.1f+brightness, 0.2f+brightness, 0.0f); - Wizardry.proxy.spawnParticle(WizardryParticleType.LEAF, world, caster.posX + radius*Math.cos(angle), WizardryUtilities.getPlayerEyesPos(caster) + 0.5, caster.posZ + radius*Math.sin(angle), 0, -0.01, 0, 40 + world.rand.nextInt(12)); + for(int i = 0; i < 50 * modifiers.get(WizardryItems.blast_upgrade); i++){ + double radius = (1 + world.rand.nextDouble() * 4) * modifiers.get(WizardryItems.blast_upgrade); + double angle = world.rand.nextDouble() * Math.PI * 2; + float brightness = world.rand.nextFloat() / 4; + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, + caster.posX + radius * Math.cos(angle), WizardryUtilities.getPlayerEyesPos(caster) + 0.5, + caster.posZ + radius * Math.sin(angle), 0, -0.2, 0, 0, 0.05f + brightness, 0.2f + brightness, + 0.0f); + brightness = world.rand.nextFloat() / 4; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + caster.posX + radius * Math.cos(angle), WizardryUtilities.getPlayerEyesPos(caster) + 0.5, + caster.posZ + radius * Math.sin(angle), 0, -0.05, 0, 50, 0.1f + brightness, 0.2f + brightness, + 0.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.LEAF, world, caster.posX + radius * Math.cos(angle), + WizardryUtilities.getPlayerEyesPos(caster) + 0.5, caster.posZ + radius * Math.sin(angle), 0, + -0.01, 0, 40 + world.rand.nextInt(12)); } } - - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Freeze.java b/src/main/java/electroblob/wizardry/spell/Freeze.java index 01b289cc..67335b87 100644 --- a/src/main/java/electroblob/wizardry/spell/Freeze.java +++ b/src/main/java/electroblob/wizardry/spell/Freeze.java @@ -30,84 +30,112 @@ import net.minecraft.world.World; public class Freeze extends Spell { - public Freeze() { + public Freeze(){ super(Tier.BASIC, 5, Element.ICE, "freeze", SpellType.ATTACK, 10, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ // Entity ray trace is done first because block ray trace passes through entities; if it was the other // way round, entities would only be hit when there were no blocks in range behind them. - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){ - - EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit; - - if(target instanceof EntityBlaze || target instanceof EntityMagmaCube || target instanceof EntityBlazeMinion){ - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST), 3.0f * modifiers.get(SpellModifiers.DAMAGE)); + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLivingBase){ + + EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit; + + if(target instanceof EntityBlaze || target instanceof EntityMagmaCube + || target instanceof EntityBlazeMinion){ + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST), + 3.0f * modifiers.get(SpellModifiers.DAMAGE)); } - + if(MagicDamage.isEntityImmune(DamageType.FROST, target)){ - if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted())); + if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(), + this.getNameForTranslationFormatted())); }else{ - target.addPotionEffect(new PotionEffect(WizardryPotions.frost, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), 1)); + target.addPotionEffect(new PotionEffect(WizardryPotions.frost, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade)), 1)); } - + if(target.isBurning()){ target.extinguish(); } if(world.isRemote){ double dx = target.posX - caster.posX; - double dy = (target.getEntityBoundingBox().minY + target.height/2) - WizardryUtilities.getPlayerEyesPos(caster); + double dy = (target.getEntityBoundingBox().minY + target.height / 2) + - WizardryUtilities.getPlayerEyesPos(caster); double dz = target.posZ - caster.posZ; - for(int i=1;i<5;i++){ - float brightness = 0.5f + (world.rand.nextFloat()/2); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f); - Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, -0.02, 0, 40 + world.rand.nextInt(10)); + for(int i = 1; i < 5; i++){ + float brightness = 0.5f + (world.rand.nextFloat() / 2); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0.0d, 0.0d, 0.0d, + 12 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, -0.02, 0, + 40 + world.rand.nextInt(10)); } } caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.2F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, + world.rand.nextFloat() * 0.4F + 1.2F); return true; }else{ - rayTrace = WizardryUtilities.rayTrace(10*modifiers.get(WizardryItems.range_upgrade), world, caster, true); + rayTrace = WizardryUtilities.rayTrace(10 * modifiers.get(WizardryItems.range_upgrade), world, caster, true); // Gets block the player is looking at and sets to ice or covers with snow as necessary // Note how the block is set on the server side only (kinda obvious really) but the particles are // spawned on the client side only. if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){ - + BlockPos pos = rayTrace.getBlockPos(); - + if(world.getBlockState(pos).getBlock() == Blocks.WATER && !world.isRemote){ world.setBlockState(pos, Blocks.ICE.getDefaultState()); }else if(world.getBlockState(pos).getBlock() == Blocks.LAVA && !world.isRemote){ world.setBlockState(pos, Blocks.OBSIDIAN.getDefaultState()); }else if(world.getBlockState(pos).getBlock() == Blocks.FLOWING_LAVA && !world.isRemote){ world.setBlockState(pos, Blocks.COBBLESTONE.getDefaultState()); - }else if(rayTrace.sideHit == EnumFacing.UP && !world.isRemote && world.isSideSolid(pos, EnumFacing.UP) && WizardryUtilities.canBlockBeReplaced(world, pos.up())){ + }else if(rayTrace.sideHit == EnumFacing.UP && !world.isRemote && world.isSideSolid(pos, EnumFacing.UP) + && WizardryUtilities.canBlockBeReplaced(world, pos.up())){ world.setBlockState(pos.up(), Blocks.SNOW_LAYER.getDefaultState()); } - + if(world.isRemote){ - + double dx = pos.getX() + 0.5 - caster.posX; double dy = pos.getY() + 0.5 - WizardryUtilities.getPlayerEyesPos(caster); double dz = pos.getZ() + 0.5 - caster.posZ; - - for(int i=1;i<5;i++){ - float brightness = 0.5f + (world.rand.nextFloat()/2); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0.0d, 0.0d, 0.0d, 20 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 20 + world.rand.nextInt(8), 1.0f, 1.0f, 1.0f); + + for(int i = 1; i < 5; i++){ + float brightness = 0.5f + (world.rand.nextFloat() / 2); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0.0d, 0.0d, 0.0d, + 20 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0, + 20 + world.rand.nextInt(8), 1.0f, 1.0f, 1.0f); } } - + caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.2F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, + world.rand.nextFloat() * 0.4F + 1.2F); return true; } } @@ -115,16 +143,20 @@ public class Freeze extends Spell { } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - - if(target instanceof EntityBlaze || target instanceof EntityMagmaCube || target instanceof EntityBlazeMinion){ - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST), 3.0f * modifiers.get(SpellModifiers.DAMAGE)); + + if(target instanceof EntityBlaze || target instanceof EntityMagmaCube + || target instanceof EntityBlazeMinion){ + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST), + 3.0f * modifiers.get(SpellModifiers.DAMAGE)); } - + if(!world.isRemote && !MagicDamage.isEntityImmune(DamageType.FROST, target)){ - target.addPotionEffect(new PotionEffect(WizardryPotions.frost, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), 1)); + target.addPotionEffect(new PotionEffect(WizardryPotions.frost, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade)), 1)); } if(target.isBurning()){ @@ -133,12 +165,21 @@ public class Freeze extends Spell { if(world.isRemote){ double dx = target.posX - caster.posX; - double dy = (target.getEntityBoundingBox().minY + target.height/2) - (caster.posY + caster.getEyeHeight()); + double dy = (target.getEntityBoundingBox().minY + target.height / 2) + - (caster.posY + caster.getEyeHeight()); double dz = target.posZ - caster.posZ; - for(int i=1;i<5;i++){ - float brightness = 0.5f + (world.rand.nextFloat()/2); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + caster.getEyeHeight() + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f); - Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + caster.getEyeHeight() + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, -0.02, 0, 40 + world.rand.nextInt(10)); + for(int i = 1; i < 5; i++){ + float brightness = 0.5f + (world.rand.nextFloat() / 2); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + caster.posY + caster.getEyeHeight() + (i * (dy / 5)) + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0.0d, 0.0d, 0.0d, + 12 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + caster.posY + caster.getEyeHeight() + (i * (dy / 5)) + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, -0.02, 0, + 40 + world.rand.nextInt(10)); } } @@ -146,10 +187,10 @@ public class Freeze extends Spell { caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.2F); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/FreezingWeapon.java b/src/main/java/electroblob/wizardry/spell/FreezingWeapon.java index 911be3f4..3c85b63d 100644 --- a/src/main/java/electroblob/wizardry/spell/FreezingWeapon.java +++ b/src/main/java/electroblob/wizardry/spell/FreezingWeapon.java @@ -23,49 +23,55 @@ import net.minecraft.world.World; public class FreezingWeapon extends Spell { - /** The NBT tag name for storing the level of frost enchantment in the arrow's tag compound. (There's nothing - * stopping you from using this elsewhere to shoot freezing arrows if you want to...) */ + /** + * The NBT tag name for storing the level of frost enchantment in the arrow's tag compound. (There's nothing + * stopping you from using this elsewhere to shoot freezing arrows if you want to...) + */ public static final String FREEZING_ARROW_NBT_KEY = "frostLevel"; - public FreezingWeapon() { + public FreezingWeapon(){ super(Tier.ADVANCED, 35, Element.ICE, "freezing_weapon", SpellType.UTILITY, 70, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ // Won't work if the weapon already has the enchantment - if(WizardData.get(caster) != null && WizardData.get(caster).getImbuementDuration(WizardryEnchantments.freezing_weapon) <= 0){ + if(WizardData.get(caster) != null + && WizardData.get(caster).getImbuementDuration(WizardryEnchantments.freezing_weapon) <= 0){ for(ItemStack stack : WizardryUtilities.getPrioritisedHotbarAndOffhand(caster)){ - if(stack != null){ + if((stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow) + && !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.freezing_weapon)){ + // The enchantment level as determined by the damage multiplier. The + 0.5f is so that + // weird float processing doesn't incorrectly round it down. + stack.addEnchantment(WizardryEnchantments.freezing_weapon, + modifiers.get(SpellModifiers.DAMAGE) == 1.0f ? 1 + : (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f) + / Constants.DAMAGE_INCREASE_PER_TIER + 0.5f)); - if((stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow) && !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.freezing_weapon)){ - // The enchantment level as determined by the damage multiplier. The + 0.5f is so that - // weird float processing doesn't incorrectly round it down. - stack.addEnchantment(WizardryEnchantments.freezing_weapon, modifiers.get(SpellModifiers.DAMAGE) == 1.0f ? 1 : (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f)/Constants.DAMAGE_INCREASE_PER_TIER + 0.5f)); + WizardData.get(caster).setImbuementDuration(WizardryEnchantments.freezing_weapon, + (int)(900 * modifiers.get(WizardryItems.duration_upgrade))); - WizardData.get(caster).setImbuementDuration(WizardryEnchantments.freezing_weapon, (int)(900*modifiers.get(WizardryItems.duration_upgrade))); - - if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); - double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.9f, 0.7f, 1.0f); - } + if(world.isRemote){ + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); + double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + + world.rand.nextFloat()); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 0.9f, 0.7f, 1.0f); } - - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f); - return true; - } + + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f); + return true; + } } } return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/FrostAxe.java b/src/main/java/electroblob/wizardry/spell/FrostAxe.java index 1d48473e..c997425a 100644 --- a/src/main/java/electroblob/wizardry/spell/FrostAxe.java +++ b/src/main/java/electroblob/wizardry/spell/FrostAxe.java @@ -18,33 +18,35 @@ import net.minecraft.world.World; public class FrostAxe extends Spell { - public FrostAxe() { + public FrostAxe(){ super(Tier.ADVANCED, 45, Element.ICE, "frost_axe", SpellType.UTILITY, 50, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ ItemStack frostaxe = new ItemStack(WizardryItems.frost_axe); - + IConjuredItem.setDurationMultiplier(frostaxe, modifiers.get(WizardryItems.duration_upgrade)); - if(!WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.frost_axe) && ConjureBow.conjureItemInInventory(caster, frostaxe)){ + if(!WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.frost_axe) + && ConjureBow.conjureItemInInventory(caster, frostaxe)){ if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); - double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, x1, y1, z1, 0, -0.02d, 0, 40 + world.rand.nextInt(10)); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); + double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + + world.rand.nextFloat()); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, x1, y1, z1, 0, -0.02d, 0, + 40 + world.rand.nextInt(10)); } } - + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0f, 1.0f); return true; } return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/FrostRay.java b/src/main/java/electroblob/wizardry/spell/FrostRay.java index 10897960..4b6ad049 100644 --- a/src/main/java/electroblob/wizardry/spell/FrostRay.java +++ b/src/main/java/electroblob/wizardry/spell/FrostRay.java @@ -27,48 +27,64 @@ import net.minecraft.world.World; public class FrostRay extends Spell { - public FrostRay() { + public FrostRay(){ super(Tier.APPRENTICE, 5, Element.ICE, "frost_ray", SpellType.ATTACK, 0, EnumAction.NONE, true); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ Vec3d look = caster.getLookVec(); - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){ + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLivingBase){ - EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit; + EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit; if(target.isBurning()){ target.extinguish(); } if(MagicDamage.isEntityImmune(DamageType.FROST, target)){ - if(!world.isRemote && ticksInUse == 1) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted())); + if(!world.isRemote && ticksInUse == 1) caster.sendMessage(new TextComponentTranslation("spell.resist", + target.getName(), this.getNameForTranslationFormatted())); }else{ // For frost ray the entity can move slightly, unlike freeze. - target.addPotionEffect(new PotionEffect(WizardryPotions.frost, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), 0)); + target.addPotionEffect(new PotionEffect(WizardryPotions.frost, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade)), 0)); float baseDamage = target instanceof EntityBlaze || target instanceof EntityMagmaCube ? 6.0f : 3.0f; - WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST), baseDamage * modifiers.get(SpellModifiers.DAMAGE)); + WizardryUtilities.attackEntityWithoutKnockback(target, + MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST), + baseDamage * modifiers.get(SpellModifiers.DAMAGE)); } } if(world.isRemote){ - for(int i=0; i<20; i++){ - double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, look.xCoord*modifiers.get(WizardryItems.range_upgrade), look.yCoord*modifiers.get(WizardryItems.range_upgrade), look.zCoord*modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 0.4f, 0.6f, 1.0f); + for(int i = 0; i < 20; i++){ + double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, + look.xCoord * modifiers.get(WizardryItems.range_upgrade), + look.yCoord * modifiers.get(WizardryItems.range_upgrade), + look.zCoord * modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 0.4f, + 0.6f, 1.0f); - x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, look.xCoord*modifiers.get(WizardryItems.range_upgrade), look.yCoord*modifiers.get(WizardryItems.range_upgrade), look.zCoord*modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 1.0f, 1.0f, 1.0f); + x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, + look.xCoord * modifiers.get(WizardryItems.range_upgrade), + look.yCoord * modifiers.get(WizardryItems.range_upgrade), + look.zCoord * modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 1.0f, + 1.0f, 1.0f); } } @@ -80,11 +96,13 @@ public class FrostRay extends Spell { } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) { + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ if(target != null){ - - Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ).normalize(); + + Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ) + .normalize(); if(target.isBurning()){ target.extinguish(); @@ -92,24 +110,37 @@ public class FrostRay extends Spell { if(!MagicDamage.isEntityImmune(DamageType.FROST, target)){ // For frost ray the entity can move slightly, unlike freeze. - target.addPotionEffect(new PotionEffect(WizardryPotions.frost, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), 0)); + target.addPotionEffect(new PotionEffect(WizardryPotions.frost, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade)), 0)); float baseDamage = target instanceof EntityBlaze || target instanceof EntityMagmaCube ? 6.0f : 3.0f; - WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST), baseDamage * modifiers.get(SpellModifiers.DAMAGE)); + WizardryUtilities.attackEntityWithoutKnockback(target, + MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST), + baseDamage * modifiers.get(SpellModifiers.DAMAGE)); } if(world.isRemote){ - for(int i=0; i<20; i++){ - double x1 = caster.posX + vec.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + vec.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, vec.xCoord*modifiers.get(WizardryItems.range_upgrade), vec.yCoord*modifiers.get(WizardryItems.range_upgrade), vec.zCoord*modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 0.4f, 0.6f, 1.0f); + for(int i = 0; i < 20; i++){ + double x1 = caster.posX + vec.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + double z1 = caster.posZ + vec.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, + vec.xCoord * modifiers.get(WizardryItems.range_upgrade), + vec.yCoord * modifiers.get(WizardryItems.range_upgrade), + vec.zCoord * modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 0.4f, + 0.6f, 1.0f); - x1 = caster.posX + vec.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - z1 = caster.posZ + vec.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, vec.xCoord*modifiers.get(WizardryItems.range_upgrade), vec.yCoord*modifiers.get(WizardryItems.range_upgrade), vec.zCoord*modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 1.0f, 1.0f, 1.0f); + x1 = caster.posX + vec.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord * i / 2 + world.rand.nextFloat() / 5 + - 0.1f; + z1 = caster.posZ + vec.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, + vec.xCoord * modifiers.get(WizardryItems.range_upgrade), + vec.yCoord * modifiers.get(WizardryItems.range_upgrade), + vec.zCoord * modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 1.0f, + 1.0f, 1.0f); } } @@ -117,15 +148,15 @@ public class FrostRay extends Spell { if(ticksInUse == 0) caster.playSound(WizardrySounds.SPELL_ICE, 0.5F, 1.0f); caster.playSound(WizardrySounds.SPELL_LOOP_ICE, 0.5F, 1.0f); } - + return true; } - + return false; } - + @Override - public boolean canBeCastByNPCs() { + public boolean canBeCastByNPCs(){ return true; } diff --git a/src/main/java/electroblob/wizardry/spell/FrostSigil.java b/src/main/java/electroblob/wizardry/spell/FrostSigil.java index 5423e9e8..2d3802ae 100644 --- a/src/main/java/electroblob/wizardry/spell/FrostSigil.java +++ b/src/main/java/electroblob/wizardry/spell/FrostSigil.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class FrostSigil extends Spell { - public FrostSigil() { + public FrostSigil(){ super(Tier.APPRENTICE, 10, Element.ICE, "frost_sigil", SpellType.ATTACK, 20, EnumAction.NONE, false); } @@ -27,17 +27,19 @@ public class FrostSigil extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - RayTraceResult rayTrace = WizardryUtilities.rayTrace(10*modifiers.get(WizardryItems.range_upgrade), world, caster, false); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + RayTraceResult rayTrace = WizardryUtilities.rayTrace(10 * modifiers.get(WizardryItems.range_upgrade), world, + caster, false); + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK && rayTrace.sideHit == EnumFacing.UP){ if(!world.isRemote){ double x = rayTrace.hitVec.xCoord; double y = rayTrace.hitVec.yCoord; double z = rayTrace.hitVec.zCoord; - EntityFrostSigil frostsigil = new EntityFrostSigil(world, x, y, z, caster, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(frostsigil); + EntityFrostSigil frostsigil = new EntityFrostSigil(world, x, y, z, caster, + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(frostsigil); } caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, 1.0F); @@ -46,5 +48,4 @@ public class FrostSigil extends Spell { return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Glide.java b/src/main/java/electroblob/wizardry/spell/Glide.java index 45fa88d7..2f54bc29 100644 --- a/src/main/java/electroblob/wizardry/spell/Glide.java +++ b/src/main/java/electroblob/wizardry/spell/Glide.java @@ -15,32 +15,37 @@ import net.minecraft.world.World; public class Glide extends Spell { - public Glide() { + public Glide(){ super(Tier.ADVANCED, 5, Element.EARTH, "glide", SpellType.UTILITY, 0, EnumAction.NONE, true); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(caster.motionY < -0.1 && !caster.isInWater()){ caster.motionY = -0.1; if(Math.abs(caster.motionX) < 0.4 && Math.abs(caster.motionZ) < 0.4){ - caster.addVelocity(caster.getLookVec().xCoord/8, 0, caster.getLookVec().zCoord/8); - //entityplayer.moveEntity(entityplayer.motionX*10, 0, entityplayer.motionZ*10); + caster.addVelocity(caster.getLookVec().xCoord / 8, 0, caster.getLookVec().zCoord / 8); + // entityplayer.moveEntity(entityplayer.motionX*10, 0, entityplayer.motionZ*10); } caster.fallDistance = 0.0f; } - + if(world.isRemote){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX - 0.25d + world.rand.nextDouble()/2, WizardryUtilities.getPlayerEyesPos(caster) - 1.5f + world.rand.nextDouble(), caster.posZ - 0.25d + world.rand.nextDouble()/2, 0, -0.1F, 0, 15, 1.0f, 1.0f, 1.0f); - Wizardry.proxy.spawnParticle(WizardryParticleType.LEAF, world, caster.posX - 0.25d + world.rand.nextDouble()/2, WizardryUtilities.getPlayerEyesPos(caster) - 1.5f + world.rand.nextDouble(), caster.posZ - 0.25d + world.rand.nextDouble()/2, 0, -0.03, 0, 20); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + caster.posX - 0.25d + world.rand.nextDouble() / 2, + WizardryUtilities.getPlayerEyesPos(caster) - 1.5f + world.rand.nextDouble(), + caster.posZ - 0.25d + world.rand.nextDouble() / 2, 0, -0.1F, 0, 15, 1.0f, 1.0f, 1.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.LEAF, world, + caster.posX - 0.25d + world.rand.nextDouble() / 2, + WizardryUtilities.getPlayerEyesPos(caster) - 1.5f + world.rand.nextDouble(), + caster.posZ - 0.25d + world.rand.nextDouble() / 2, 0, -0.03, 0, 20); } - + if(ticksInUse % 24 == 0){ WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ITEM_ELYTRA_FLYING, 0.5F, 1.0f); } return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/GreaterFireball.java b/src/main/java/electroblob/wizardry/spell/GreaterFireball.java index 93414391..e70ebb7c 100644 --- a/src/main/java/electroblob/wizardry/spell/GreaterFireball.java +++ b/src/main/java/electroblob/wizardry/spell/GreaterFireball.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class GreaterFireball extends Spell { - public GreaterFireball() { + public GreaterFireball(){ super(Tier.ADVANCED, 20, Element.FIRE, "greater_fireball", SpellType.ATTACK, 30, EnumAction.NONE, false); } @@ -27,20 +27,17 @@ public class GreaterFireball extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ Vec3d look = caster.getLookVec(); if(!world.isRemote){ EntityLargeFireball fireball = new EntityLargeFireball(world, caster, 1, 1, 1); - fireball.setPosition( - caster.posX + look.xCoord, - caster.posY + look.yCoord + 1.3, - caster.posZ + look.zCoord); + fireball.setPosition(caster.posX + look.xCoord, caster.posY + look.yCoord + 1.3, caster.posZ + look.zCoord); fireball.accelerationX = look.xCoord * 0.1; fireball.accelerationY = look.yCoord * 0.1; fireball.accelerationZ = look.zCoord * 0.1; - world.spawnEntityInWorld(fireball); + world.spawnEntity(fireball); } WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1); @@ -49,25 +46,27 @@ public class GreaterFireball extends Spell { } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - + EntityLargeFireball fireball = new EntityLargeFireball(world, caster, 1, 1, 1); - + double dx = target.posX - caster.posX; - double dy = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) - (caster.posY + (double)(caster.height / 2.0F)); - double dz = target.posZ - caster.posZ; - - fireball.accelerationX = dx/caster.getDistanceToEntity(target) * 0.1; - fireball.accelerationY = dy/caster.getDistanceToEntity(target) * 0.1; - fireball.accelerationZ = dz/caster.getDistanceToEntity(target) * 0.1; - - fireball.setPosition(caster.posX, caster.posY + caster.getEyeHeight(), caster.posZ); - - world.spawnEntityInWorld(fireball); + double dy = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) + - (caster.posY + (double)(caster.height / 2.0F)); + double dz = target.posZ - caster.posZ; + + fireball.accelerationX = dx / caster.getDistanceToEntity(target) * 0.1; + fireball.accelerationY = dy / caster.getDistanceToEntity(target) * 0.1; + fireball.accelerationZ = dz / caster.getDistanceToEntity(target) * 0.1; + + fireball.setPosition(caster.posX, caster.posY + caster.getEyeHeight(), caster.posZ); + + world.spawnEntity(fireball); } caster.playSound(SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1); diff --git a/src/main/java/electroblob/wizardry/spell/GreaterHeal.java b/src/main/java/electroblob/wizardry/spell/GreaterHeal.java index df20a7dc..5664cb3b 100644 --- a/src/main/java/electroblob/wizardry/spell/GreaterHeal.java +++ b/src/main/java/electroblob/wizardry/spell/GreaterHeal.java @@ -17,46 +17,51 @@ import net.minecraft.world.World; public class GreaterHeal extends Spell { - public GreaterHeal() { + public GreaterHeal(){ super(Tier.ADVANCED, 15, Element.HEALING, "greater_heal", SpellType.DEFENCE, 40, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ if(caster.shouldHeal()){ - caster.heal((int)(8*modifiers.get(SpellModifiers.DAMAGE))); + caster.heal((int)(8 * modifiers.get(SpellModifiers.DAMAGE))); if(world.isRemote){ - for(int i=0; i<10; i++){ - double dx = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); - double dy = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double dz = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, dx, dy, dz, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f); + for(int i = 0; i < 10; i++){ + double dx = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); + double dy = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + + world.rand.nextFloat()); + double dz = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, dx, dy, dz, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f); } } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return true; } return false; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(caster.getHealth() < caster.getMaxHealth()){ - caster.heal((int)(8*modifiers.get(SpellModifiers.DAMAGE))); + caster.heal((int)(8 * modifiers.get(SpellModifiers.DAMAGE))); if(world.isRemote){ - for(int i=0; i<10; i++){ - double dx = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double dx = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double dy = (double)((float)caster.posY + caster.getEyeHeight() - 0.5F + world.rand.nextFloat()); - double dz = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, dx, dy, dz, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f); + double dz = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, dx, dy, dz, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f); } } caster.playSound(WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); return true; } - + return false; } diff --git a/src/main/java/electroblob/wizardry/spell/GroupHeal.java b/src/main/java/electroblob/wizardry/spell/GroupHeal.java index 939ef998..2324a906 100644 --- a/src/main/java/electroblob/wizardry/spell/GroupHeal.java +++ b/src/main/java/electroblob/wizardry/spell/GroupHeal.java @@ -20,16 +20,17 @@ import net.minecraft.world.World; public class GroupHeal extends Spell { - public GroupHeal() { + public GroupHeal(){ super(Tier.ADVANCED, 35, Element.HEALING, "group_heal", SpellType.DEFENCE, 150, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ boolean flag = false; - List targets = WizardryUtilities.getEntitiesWithinRadius(5*modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world); + List targets = WizardryUtilities.getEntitiesWithinRadius( + 5 * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world); for(EntityLivingBase target : targets){ @@ -39,43 +40,50 @@ public class GroupHeal extends Spell { if(((EntityPlayer)target).shouldHeal()){ - target.heal((int)(6*modifiers.get(SpellModifiers.DAMAGE))); + target.heal((int)(6 * modifiers.get(SpellModifiers.DAMAGE))); if(world.isRemote){ - for(int i=0; i<10; i++){ - double d0 = (double)((float)target.posX + world.rand.nextFloat()*2 - 1.0F); - double d1 = (double)((float)WizardryUtilities.getPlayerEyesPos((EntityPlayer)target) - 0.5F + world.rand.nextFloat()); - double d2 = (double)((float)target.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f); + for(int i = 0; i < 10; i++){ + double d0 = (double)((float)target.posX + world.rand.nextFloat() * 2 - 1.0F); + double d1 = (double)((float)WizardryUtilities.getPlayerEyesPos((EntityPlayer)target) + - 0.5F + world.rand.nextFloat()); + double d2 = (double)((float)target.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, + 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f); } } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); flag = true; } } - - // Now also works on summoned creatures + + // Now also works on summoned creatures }else if(target instanceof ISummonedCreature){ EntityLivingBase summoner = ((ISummonedCreature)target).getCaster(); - if(summoner == caster || (summoner instanceof EntityPlayer && WizardryUtilities.isPlayerAlly(caster, (EntityPlayer)summoner))){ + if(summoner == caster || (summoner instanceof EntityPlayer + && WizardryUtilities.isPlayerAlly(caster, (EntityPlayer)summoner))){ if(target.getHealth() < target.getMaxHealth()){ - - target.heal((int)(6*modifiers.get(SpellModifiers.DAMAGE))); + + target.heal((int)(6 * modifiers.get(SpellModifiers.DAMAGE))); if(world.isRemote){ - for(int i=0; i<10; i++){ - double d0 = (double)((float)target.posX + world.rand.nextFloat()*2 - 1.0F); - double d1 = (double)((float)WizardryUtilities.getPlayerEyesPos((EntityPlayer)target) - 0.5F + world.rand.nextFloat()); - double d2 = (double)((float)target.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f); + for(int i = 0; i < 10; i++){ + double d0 = (double)((float)target.posX + world.rand.nextFloat() * 2 - 1.0F); + double d1 = (double)((float)WizardryUtilities.getPlayerEyesPos((EntityPlayer)target) + - 0.5F + world.rand.nextFloat()); + double d2 = (double)((float)target.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, + 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f); } } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); flag = true; } } @@ -85,5 +93,4 @@ public class GroupHeal extends Spell { return flag; } - } diff --git a/src/main/java/electroblob/wizardry/spell/GrowthAura.java b/src/main/java/electroblob/wizardry/spell/GrowthAura.java index 7e52855e..390c6603 100644 --- a/src/main/java/electroblob/wizardry/spell/GrowthAura.java +++ b/src/main/java/electroblob/wizardry/spell/GrowthAura.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class GrowthAura extends Spell { - public GrowthAura() { + public GrowthAura(){ super(Tier.APPRENTICE, 20, Element.EARTH, "growth_aura", SpellType.UTILITY, 50, EnumAction.NONE, false); } @@ -27,16 +27,17 @@ public class GrowthAura extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ boolean flag = false; - for(int i=-2; i<1; i++){ + for(int i = -2; i < 1; i++){ - for(int j=-1; j<2; j++){ + for(int j = -1; j < 2; j++){ int x = (int)caster.posX + i; - int y = WizardryUtilities.getNearestFloorLevelC(world, new BlockPos(caster.posX + i, caster.posY, caster.posZ + j), 2) - 1; + int y = WizardryUtilities.getNearestFloorLevelC(world, + new BlockPos(caster.posX + i, caster.posY, caster.posZ + j), 2) - 1; int z = (int)caster.posZ + j; BlockPos pos = new BlockPos(x, y, z); @@ -67,9 +68,9 @@ public class GrowthAura extends Spell { } } - if(flag) WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + if(flag) WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return flag; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Hailstorm.java b/src/main/java/electroblob/wizardry/spell/Hailstorm.java index 7dc8ee73..b61a1be7 100644 --- a/src/main/java/electroblob/wizardry/spell/Hailstorm.java +++ b/src/main/java/electroblob/wizardry/spell/Hailstorm.java @@ -16,7 +16,7 @@ import net.minecraft.world.World; public class Hailstorm extends Spell { - public Hailstorm() { + public Hailstorm(){ super(Tier.MASTER, 75, Element.ICE, "hailstorm", SpellType.ATTACK, 300, EnumAction.NONE, false); } @@ -26,26 +26,30 @@ public class Hailstorm extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - RayTraceResult rayTrace = WizardryUtilities.rayTrace(20*modifiers.get(WizardryItems.range_upgrade), world, caster, false); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + RayTraceResult rayTrace = WizardryUtilities.rayTrace(20 * modifiers.get(WizardryItems.range_upgrade), world, + caster, false); + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){ if(!world.isRemote){ double x = rayTrace.hitVec.xCoord; double y = rayTrace.hitVec.yCoord; double z = rayTrace.hitVec.zCoord; - // Moves the entity back towards the caster a bit, so the area of effect is better centred on the position. + // Moves the entity back towards the caster a bit, so the area of effect is better centred on the + // position. // 3.0d is the distance to move the entity back towards the caster. double dx = caster.posX - x; double dz = caster.posZ - z; - double distRatio = 3.0d/Math.sqrt(dx*dx + dz*dz); - x += dx*distRatio; - z += dz*distRatio; - - EntityHailstorm hailstorm = new EntityHailstorm(world, x, y + 5, z, caster, (int)(120*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE)); + double distRatio = 3.0d / Math.sqrt(dx * dx + dz * dz); + x += dx * distRatio; + z += dz * distRatio; + + EntityHailstorm hailstorm = new EntityHailstorm(world, x, y + 5, z, caster, + (int)(120 * modifiers.get(WizardryItems.duration_upgrade)), + modifiers.get(SpellModifiers.DAMAGE)); hailstorm.rotationYaw = caster.rotationYawHead; - world.spawnEntityInWorld(hailstorm); + world.spawnEntity(hailstorm); } caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, 1.0F); diff --git a/src/main/java/electroblob/wizardry/spell/Heal.java b/src/main/java/electroblob/wizardry/spell/Heal.java index 8a7044e3..f3bdad94 100644 --- a/src/main/java/electroblob/wizardry/spell/Heal.java +++ b/src/main/java/electroblob/wizardry/spell/Heal.java @@ -17,50 +17,56 @@ import net.minecraft.world.World; public class Heal extends Spell { - public Heal() { + public Heal(){ super(Tier.BASIC, 5, Element.HEALING, "heal", SpellType.DEFENCE, 20, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ if(caster.shouldHeal()){ - caster.heal((int)(4*modifiers.get(SpellModifiers.DAMAGE))); + caster.heal((int)(4 * modifiers.get(SpellModifiers.DAMAGE))); if(world.isRemote){ - for(int i=0; i<10; i++){ - double d0 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); - // Apparently the client side spawns the particles 1 block higher than it should... hence the - 0.5F. - double d1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double d2 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f); + for(int i = 0; i < 10; i++){ + double d0 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); + // Apparently the client side spawns the particles 1 block higher than it should... hence the - + // 0.5F. + double d1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + + world.rand.nextFloat()); + double d2 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f); } } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return true; } return false; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(caster.getHealth() < caster.getMaxHealth()){ - caster.heal((int)(4*modifiers.get(SpellModifiers.DAMAGE))); + caster.heal((int)(4 * modifiers.get(SpellModifiers.DAMAGE))); if(world.isRemote){ - for(int i=0; i<10; i++){ - double dx = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double dx = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double dy = (double)((float)caster.posY + caster.getEyeHeight() - 0.5F + world.rand.nextFloat()); - double dz = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, dx, dy, dz, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f); + double dz = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, dx, dy, dz, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f); } } caster.playSound(WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); return true; } - + return false; } diff --git a/src/main/java/electroblob/wizardry/spell/HealAlly.java b/src/main/java/electroblob/wizardry/spell/HealAlly.java index 3ab49587..cb4c13c9 100644 --- a/src/main/java/electroblob/wizardry/spell/HealAlly.java +++ b/src/main/java/electroblob/wizardry/spell/HealAlly.java @@ -18,30 +18,34 @@ import net.minecraft.world.World; public class HealAlly extends Spell { - public HealAlly() { + public HealAlly(){ super(Tier.APPRENTICE, 10, Element.HEALING, "heal_ally", SpellType.DEFENCE, 20, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade), 8.0f); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade), 8.0f); if(rayTrace != null && rayTrace.entityHit != null && rayTrace.entityHit instanceof EntityLivingBase){ EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit; if(target.getHealth() < target.getMaxHealth()){ - target.heal((int)(5*modifiers.get(SpellModifiers.DAMAGE))); - + target.heal((int)(5 * modifiers.get(SpellModifiers.DAMAGE))); + if(world.isRemote){ - for(int i=0; i<10; i++){ - double d0 = (double)((float)target.posX + world.rand.nextFloat()*2 - 1.0F); - // Apparently the client side spawns the particles 1 block higher than it should... hence the - 0.5F. - double d1 = (double)((float)target.getEntityBoundingBox().minY + target.height - 0.5f + world.rand.nextFloat()); - double d2 = (double)((float)target.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f); + for(int i = 0; i < 10; i++){ + double d0 = (double)((float)target.posX + world.rand.nextFloat() * 2 - 1.0F); + // Apparently the client side spawns the particles 1 block higher than it should... hence the - + // 0.5F. + double d1 = (double)((float)target.getEntityBoundingBox().minY + target.height - 0.5f + + world.rand.nextFloat()); + double d2 = (double)((float)target.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f); } } - + caster.swingArm(hand); target.playSound(WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); return true; @@ -50,5 +54,4 @@ public class HealAlly extends Spell { return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/HealingAura.java b/src/main/java/electroblob/wizardry/spell/HealingAura.java index bcd6ea61..d3a9844e 100644 --- a/src/main/java/electroblob/wizardry/spell/HealingAura.java +++ b/src/main/java/electroblob/wizardry/spell/HealingAura.java @@ -15,7 +15,7 @@ import net.minecraft.world.World; public class HealingAura extends Spell { - public HealingAura() { + public HealingAura(){ super(Tier.ADVANCED, 35, Element.HEALING, "healing_aura", SpellType.DEFENCE, 150, EnumAction.BOW, false); } @@ -25,37 +25,43 @@ public class HealingAura extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(caster.onGround){ if(!world.isRemote){ - EntityHealAura healaura = new EntityHealAura(world, caster.posX, caster.posY, caster.posZ, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(healaura); + EntityHealAura healaura = new EntityHealAura(world, caster.posX, caster.posY, caster.posZ, caster, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(healaura); } return true; } return false; } - + @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) { + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ if(target != null){ - if(caster.onGround && world.getEntitiesWithinAABB(EntityHealAura.class, caster.getEntityBoundingBox()).isEmpty()){ + if(caster.onGround + && world.getEntitiesWithinAABB(EntityHealAura.class, caster.getEntityBoundingBox()).isEmpty()){ if(!world.isRemote){ - EntityHealAura healaura = new EntityHealAura(world, caster.posX, caster.posY, caster.posZ, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(healaura); + EntityHealAura healaura = new EntityHealAura(world, caster.posX, caster.posY, caster.posZ, caster, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(healaura); } return true; } return false; } - + return false; } - + @Override - public boolean canBeCastByNPCs() { + public boolean canBeCastByNPCs(){ return true; } diff --git a/src/main/java/electroblob/wizardry/spell/HomingSpark.java b/src/main/java/electroblob/wizardry/spell/HomingSpark.java index 65ed1d64..074658e2 100644 --- a/src/main/java/electroblob/wizardry/spell/HomingSpark.java +++ b/src/main/java/electroblob/wizardry/spell/HomingSpark.java @@ -16,7 +16,7 @@ import net.minecraft.world.World; public class HomingSpark extends Spell { - public HomingSpark() { + public HomingSpark(){ super(Tier.APPRENTICE, 10, Element.LIGHTNING, "homing_spark", SpellType.ATTACK, 20, EnumAction.NONE, false); } @@ -26,35 +26,37 @@ public class HomingSpark extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ EntitySpark spark = new EntitySpark(world, caster, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(spark); - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); + world.spawnEntity(spark); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F, + 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); } caster.swingArm(hand); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ EntitySpark spark = new EntitySpark(world, caster, modifiers.get(SpellModifiers.DAMAGE)); spark.directTowards(target, 0.5f); - world.spawnEntityInWorld(spark); + world.spawnEntity(spark); caster.playSound(WizardrySounds.SPELL_CONJURATION, 1.0F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); } caster.swingArm(hand); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/IceAge.java b/src/main/java/electroblob/wizardry/spell/IceAge.java index 8f57ee59..ba9cef99 100644 --- a/src/main/java/electroblob/wizardry/spell/IceAge.java +++ b/src/main/java/electroblob/wizardry/spell/IceAge.java @@ -24,10 +24,10 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class IceAge extends Spell { - + private static final int baseDuration = 1200; - public IceAge() { + public IceAge(){ super(Tier.MASTER, 70, Element.ICE, "ice_age", SpellType.ATTACK, 250, EnumAction.BOW, false); } @@ -37,73 +37,90 @@ public class IceAge extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - List targets = WizardryUtilities.getEntitiesWithinRadius(7*modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + List targets = WizardryUtilities.getEntitiesWithinRadius( + 7 * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world); + for(EntityLivingBase target : targets){ if(WizardryUtilities.isValidTarget(caster, target)){ if(!world.isRemote){ if(target instanceof EntityBlaze || target instanceof EntityMagmaCube){ - // These have been removed for the time being because they cause the entity to sink into the floor when it breaks out. - //target.attackEntityFrom(WizardryUtilities.causePlayerMagicDamage(entityplayer), 8.0f * modifiers.get(SpellModifiers.DAMAGE)); + // These have been removed for the time being because they cause the entity to sink into the + // floor when it breaks out. + // target.attackEntityFrom(WizardryUtilities.causePlayerMagicDamage(entityplayer), 8.0f * + // modifiers.get(SpellModifiers.DAMAGE)); }else{ - //target.attackEntityFrom(WizardryUtilities.causePlayerMagicDamage(entityplayer), 4.0f * modifiers.get(SpellModifiers.DAMAGE)); + // target.attackEntityFrom(WizardryUtilities.causePlayerMagicDamage(entityplayer), 4.0f * + // modifiers.get(SpellModifiers.DAMAGE)); } if(target.isBurning()){ target.extinguish(); } if(target instanceof EntityBlaze) caster.addStat(WizardryAchievements.freeze_blaze, 1); - + if(target instanceof EntityLiving){ - + // Stops the entity looking red while frozen and the resulting z-fighting target.hurtTime = 0; - + BlockPos pos = new BlockPos(target); - + // Short mobs such as spiders and pigs - if((target.height < 1.2 || target.isChild()) && WizardryUtilities.canBlockBeReplaced(world, pos)){ + if((target.height < 1.2 || target.isChild()) + && WizardryUtilities.canBlockBeReplaced(world, pos)){ world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState()); if(world.getTileEntity(pos) instanceof TileEntityStatue){ - ((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart((EntityLiving) target, 1, 1); - ((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade))); + ((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart((EntityLiving)target, 1, + 1); + ((TileEntityStatue)world.getTileEntity(pos)).setLifetime( + (int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade))); } target.setDead(); target.playSound(WizardrySounds.SPELL_FREEZE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F); } // Normal sized mobs like zombies and skeletons - else if(target.height < 2.5 && WizardryUtilities.canBlockBeReplaced(world, pos) && WizardryUtilities.canBlockBeReplaced(world, pos.up())){ + else if(target.height < 2.5 && WizardryUtilities.canBlockBeReplaced(world, pos) + && WizardryUtilities.canBlockBeReplaced(world, pos.up())){ world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState()); if(world.getTileEntity(pos) instanceof TileEntityStatue){ - ((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart((EntityLiving) target, 1, 2); - ((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade))); + ((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart((EntityLiving)target, 1, + 2); + ((TileEntityStatue)world.getTileEntity(pos)).setLifetime( + (int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade))); } - + world.setBlockState(pos.up(), WizardryBlocks.ice_statue.getDefaultState()); if(world.getTileEntity(pos.up()) instanceof TileEntityStatue){ - ((TileEntityStatue)world.getTileEntity(pos.up())).setCreatureAndPart((EntityLiving) target, 2, 2); + ((TileEntityStatue)world.getTileEntity(pos.up())) + .setCreatureAndPart((EntityLiving)target, 2, 2); } target.setDead(); target.playSound(WizardrySounds.SPELL_FREEZE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F); } // Tall mobs like endermen - else if(WizardryUtilities.canBlockBeReplaced(world, pos) && WizardryUtilities.canBlockBeReplaced(world, pos.up()) && WizardryUtilities.canBlockBeReplaced(world, pos.up(2))){ + else if(WizardryUtilities.canBlockBeReplaced(world, pos) + && WizardryUtilities.canBlockBeReplaced(world, pos.up()) + && WizardryUtilities.canBlockBeReplaced(world, pos.up(2))){ world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState()); if(world.getTileEntity(pos) instanceof TileEntityStatue){ - ((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart((EntityLiving) target, 1, 3); - ((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade))); + ((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart((EntityLiving)target, 1, + 3); + ((TileEntityStatue)world.getTileEntity(pos)).setLifetime( + (int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade))); } - + world.setBlockState(pos.up(), WizardryBlocks.ice_statue.getDefaultState()); if(world.getTileEntity(pos.up()) instanceof TileEntityStatue){ - ((TileEntityStatue)world.getTileEntity(pos.up())).setCreatureAndPart((EntityLiving) target, 2, 3); + ((TileEntityStatue)world.getTileEntity(pos.up())) + .setCreatureAndPart((EntityLiving)target, 2, 3); } - + world.setBlockState(pos.up(2), WizardryBlocks.ice_statue.getDefaultState()); if(world.getTileEntity(pos.up(2)) instanceof TileEntityStatue){ - ((TileEntityStatue)world.getTileEntity(pos.up(2))).setCreatureAndPart((EntityLiving) target, 3, 3); + ((TileEntityStatue)world.getTileEntity(pos.up(2))) + .setCreatureAndPart((EntityLiving)target, 3, 3); } target.setDead(); target.playSound(WizardrySounds.SPELL_FREEZE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F); @@ -113,19 +130,19 @@ public class IceAge extends Spell { } } if(!world.isRemote){ - for(int i=-7; i<8; i++){ - for(int j=-7; j<8; j++){ - + for(int i = -7; i < 8; i++){ + for(int j = -7; j < 8; j++){ + BlockPos pos = new BlockPos(caster).add(i, 0, j); - + int y = WizardryUtilities.getNearestFloorLevelB(world, new BlockPos(pos), 7); - + pos = new BlockPos(pos.getX(), y, pos.getZ()); - + double dist = caster.getDistance((int)caster.posX + i, y, (int)caster.posZ + j); - + // Randomised with weighting so that the nearer the block the more likely it is to be snowed. - if(y != -1 && world.rand.nextInt((int)dist*2 + 1) < 7 && dist < 8){ + if(y != -1 && world.rand.nextInt((int)dist * 2 + 1) < 7 && dist < 8){ if(world.getBlockState(pos.down()) == Blocks.WATER.getDefaultState()){ world.setBlockState(pos.down(), Blocks.ICE.getDefaultState()); }else if(world.getBlockState(pos.down()) == Blocks.LAVA.getDefaultState()){ diff --git a/src/main/java/electroblob/wizardry/spell/IceCharge.java b/src/main/java/electroblob/wizardry/spell/IceCharge.java index c419b374..231d78b7 100644 --- a/src/main/java/electroblob/wizardry/spell/IceCharge.java +++ b/src/main/java/electroblob/wizardry/spell/IceCharge.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class IceCharge extends Spell { - public IceCharge() { + public IceCharge(){ super(Tier.ADVANCED, 20, Element.ICE, "ice_charge", SpellType.ATTACK, 30, EnumAction.NONE, false); } @@ -27,37 +27,41 @@ public class IceCharge extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ - EntityIceCharge icecharge = new EntityIceCharge(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade)); - world.spawnEntityInWorld(icecharge); + EntityIceCharge icecharge = new EntityIceCharge(world, caster, modifiers.get(SpellModifiers.DAMAGE), + modifiers.get(WizardryItems.blast_upgrade)); + world.spawnEntity(icecharge); } - + caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.4F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, + world.rand.nextFloat() * 0.4F + 1.4F); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - EntityIceCharge icecharge = new EntityIceCharge(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade)); + EntityIceCharge icecharge = new EntityIceCharge(world, caster, modifiers.get(SpellModifiers.DAMAGE), + modifiers.get(WizardryItems.blast_upgrade)); icecharge.directTowards(target, 1.5f); - world.spawnEntityInWorld(icecharge); + world.spawnEntity(icecharge); } - + caster.swingArm(hand); caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.4F); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/IceLance.java b/src/main/java/electroblob/wizardry/spell/IceLance.java index dcef7c07..88c36745 100644 --- a/src/main/java/electroblob/wizardry/spell/IceLance.java +++ b/src/main/java/electroblob/wizardry/spell/IceLance.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class IceLance extends Spell { - public IceLance() { + public IceLance(){ super(Tier.ADVANCED, 20, Element.ICE, "ice_lance", SpellType.ATTACK, 20, EnumAction.NONE, false); } @@ -27,34 +27,38 @@ public class IceLance extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ - EntityIceLance iceLance = new EntityIceLance(world, caster, 2*modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(iceLance); + EntityIceLance iceLance = new EntityIceLance(world, caster, 2 * modifiers.get(WizardryItems.range_upgrade), + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(iceLance); } caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, + world.rand.nextFloat() * 0.4F + 0.8F); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - EntityIceLance iceLance = new EntityIceLance(world, caster, target, 2*modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(iceLance); + EntityIceLance iceLance = new EntityIceLance(world, caster, target, + 2 * modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(iceLance); } caster.swingArm(hand); caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/IceShard.java b/src/main/java/electroblob/wizardry/spell/IceShard.java index ddda2a1d..79c4f1b7 100644 --- a/src/main/java/electroblob/wizardry/spell/IceShard.java +++ b/src/main/java/electroblob/wizardry/spell/IceShard.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class IceShard extends Spell { - public IceShard() { + public IceShard(){ super(Tier.APPRENTICE, 10, Element.ICE, "ice_shard", SpellType.ATTACK, 10, EnumAction.NONE, false); } @@ -27,34 +27,38 @@ public class IceShard extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ - EntityIceShard iceShard = new EntityIceShard(world, caster, 2*modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(iceShard); + EntityIceShard iceShard = new EntityIceShard(world, caster, 2 * modifiers.get(WizardryItems.range_upgrade), + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(iceShard); } caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.4F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, + world.rand.nextFloat() * 0.4F + 1.4F); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - EntityIceShard iceShard = new EntityIceShard(world, caster, target, 2*modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(iceShard); + EntityIceShard iceShard = new EntityIceShard(world, caster, target, + 2 * modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(iceShard); } caster.swingArm(hand); caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.4F); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/IceShroud.java b/src/main/java/electroblob/wizardry/spell/IceShroud.java index 85843dc1..88a933d9 100644 --- a/src/main/java/electroblob/wizardry/spell/IceShroud.java +++ b/src/main/java/electroblob/wizardry/spell/IceShroud.java @@ -18,7 +18,7 @@ import net.minecraft.world.World; public class IceShroud extends Spell { - public IceShroud() { + public IceShroud(){ super(Tier.ADVANCED, 40, Element.ICE, "ice_shroud", SpellType.DEFENCE, 250, EnumAction.BOW, false); } @@ -28,39 +28,43 @@ public class IceShroud extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + // Cannot be cast when it has already been cast if(!caster.isPotionActive(WizardryPotions.ice_shroud)){ if(!world.isRemote){ - caster.addPotionEffect(new PotionEffect(WizardryPotions.ice_shroud, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0)); + caster.addPotionEffect(new PotionEffect(WizardryPotions.ice_shroud, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0)); } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.4F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, + world.rand.nextFloat() * 0.4F + 1.4F); return true; } return false; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) { - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ // Cannot be cast when it has already been cast if(!caster.isPotionActive(WizardryPotions.ice_shroud)){ if(!world.isRemote){ - caster.addPotionEffect(new PotionEffect(WizardryPotions.ice_shroud, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0)); + caster.addPotionEffect(new PotionEffect(WizardryPotions.ice_shroud, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0)); } caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.4F); return true; } return false; } - + return false; } - + @Override - public boolean canBeCastByNPCs() { + public boolean canBeCastByNPCs(){ return true; } diff --git a/src/main/java/electroblob/wizardry/spell/IceSpikes.java b/src/main/java/electroblob/wizardry/spell/IceSpikes.java index 95325e0f..61010bf9 100644 --- a/src/main/java/electroblob/wizardry/spell/IceSpikes.java +++ b/src/main/java/electroblob/wizardry/spell/IceSpikes.java @@ -21,7 +21,7 @@ import net.minecraft.world.World; public class IceSpikes extends Spell { - public IceSpikes() { + public IceSpikes(){ super(Tier.ADVANCED, 30, Element.ICE, "ice_spikes", SpellType.ATTACK, 75, EnumAction.NONE, false); } @@ -31,64 +31,70 @@ public class IceSpikes extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - RayTraceResult rayTrace = WizardryUtilities.rayTrace(20*modifiers.get(WizardryItems.range_upgrade), world, caster, false); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + RayTraceResult rayTrace = WizardryUtilities.rayTrace(20 * modifiers.get(WizardryItems.range_upgrade), world, + caster, false); + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK && rayTrace.sideHit == EnumFacing.UP){ - + if(!world.isRemote){ - + double x = rayTrace.hitVec.xCoord; double y = rayTrace.hitVec.yCoord; double z = rayTrace.hitVec.zCoord; - - for(int i=0; i<(int)(18*modifiers.get(WizardryItems.blast_upgrade)); i++){ - - float angle = (float)(world.rand.nextFloat()*Math.PI*2); - double radius = 0.5 + world.rand.nextDouble()*2*modifiers.get(WizardryItems.blast_upgrade); - - double x1 = x + radius*MathHelper.sin(angle); - double z1 = z + radius*MathHelper.cos(angle); - double y1 = WizardryUtilities.getNearestFloorLevel(world, new BlockPos(MathHelper.floor_double(x1), (int)y, MathHelper.floor_double(z1)), 2) - 1; - + + for(int i = 0; i < (int)(18 * modifiers.get(WizardryItems.blast_upgrade)); i++){ + + float angle = (float)(world.rand.nextFloat() * Math.PI * 2); + double radius = 0.5 + world.rand.nextDouble() * 2 * modifiers.get(WizardryItems.blast_upgrade); + + double x1 = x + radius * MathHelper.sin(angle); + double z1 = z + radius * MathHelper.cos(angle); + double y1 = WizardryUtilities.getNearestFloorLevel(world, + new BlockPos(MathHelper.floor(x1), (int)y, MathHelper.floor(z1)), 2) - 1; + if(y1 > -1){ - EntityIceSpike icespike = new EntityIceSpike(world, x1, y1, z1, caster, 30 + world.rand.nextInt(15), modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(icespike); + EntityIceSpike icespike = new EntityIceSpike(world, x1, y1, z1, caster, + 30 + world.rand.nextInt(15), modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(icespike); } } } - + caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, 1.0F); return true; } return false; } - + @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - + double x = target.posX; double y = target.posY; double z = target.posZ; - - for(int i=0; i<(int)(18*modifiers.get(WizardryItems.blast_upgrade)); i++){ - - float angle = (float)(world.rand.nextFloat()*Math.PI*2); - double radius = 0.5 + world.rand.nextDouble()*2*modifiers.get(WizardryItems.blast_upgrade); - - double x1 = x + radius*MathHelper.sin(angle); - double z1 = z + radius*MathHelper.cos(angle); - double y1 = WizardryUtilities.getNearestFloorLevel(world, new BlockPos(MathHelper.floor_double(x1), (int)y, MathHelper.floor_double(z1)), 2) - 1; - + + for(int i = 0; i < (int)(18 * modifiers.get(WizardryItems.blast_upgrade)); i++){ + + float angle = (float)(world.rand.nextFloat() * Math.PI * 2); + double radius = 0.5 + world.rand.nextDouble() * 2 * modifiers.get(WizardryItems.blast_upgrade); + + double x1 = x + radius * MathHelper.sin(angle); + double z1 = z + radius * MathHelper.cos(angle); + double y1 = WizardryUtilities.getNearestFloorLevel(world, + new BlockPos(MathHelper.floor(x1), (int)y, MathHelper.floor(z1)), 2) - 1; + if(y1 > -1){ - EntityIceSpike icespike = new EntityIceSpike(world, x1, y1, z1, caster, 30 + world.rand.nextInt(15), modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(icespike); + EntityIceSpike icespike = new EntityIceSpike(world, x1, y1, z1, caster, + 30 + world.rand.nextInt(15), modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(icespike); } } } @@ -96,13 +102,13 @@ public class IceSpikes extends Spell { caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, 1.0F); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; } - + } diff --git a/src/main/java/electroblob/wizardry/spell/IceStatue.java b/src/main/java/electroblob/wizardry/spell/IceStatue.java index 1928421a..a8d4a43a 100644 --- a/src/main/java/electroblob/wizardry/spell/IceStatue.java +++ b/src/main/java/electroblob/wizardry/spell/IceStatue.java @@ -26,27 +26,29 @@ public class IceStatue extends Spell { private static final int baseDuration = 400; - public IceStatue() { + public IceStatue(){ super(Tier.APPRENTICE, 15, Element.ICE, "ice_statue", SpellType.ATTACK, 40, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ Vec3d look = caster.getLookVec(); - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLiving && !world.isRemote){ + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLiving && !world.isRemote){ + + EntityLiving target = (EntityLiving)rayTrace.entityHit; - EntityLiving target = (EntityLiving) rayTrace.entityHit; - BlockPos pos = new BlockPos(target); if(target.isBurning()){ target.extinguish(); } - + // Stops the entity looking red while frozen and the resulting z-fighting target.hurtTime = 0; @@ -57,17 +59,20 @@ public class IceStatue extends Spell { world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState()); if(world.getTileEntity(pos) instanceof TileEntityStatue){ ((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart(target, 1, 1); - ((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade))); + ((TileEntityStatue)world.getTileEntity(pos)) + .setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade))); } target.setDead(); target.playSound(WizardrySounds.SPELL_FREEZE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F); } // Normal sized mobs like zombies and skeletons - else if(target.height < 2.5 && WizardryUtilities.canBlockBeReplaced(world, pos) && WizardryUtilities.canBlockBeReplaced(world, pos.up())){ + else if(target.height < 2.5 && WizardryUtilities.canBlockBeReplaced(world, pos) + && WizardryUtilities.canBlockBeReplaced(world, pos.up())){ world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState()); if(world.getTileEntity(pos) instanceof TileEntityStatue){ ((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart(target, 1, 2); - ((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade))); + ((TileEntityStatue)world.getTileEntity(pos)) + .setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade))); } world.setBlockState(pos.up(), WizardryBlocks.ice_statue.getDefaultState()); @@ -78,11 +83,14 @@ public class IceStatue extends Spell { target.playSound(WizardrySounds.SPELL_FREEZE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F); } // Tall mobs like endermen and iron golems - else if(WizardryUtilities.canBlockBeReplaced(world, pos) && WizardryUtilities.canBlockBeReplaced(world, pos.up()) && WizardryUtilities.canBlockBeReplaced(world, pos.up(2))){ + else if(WizardryUtilities.canBlockBeReplaced(world, pos) + && WizardryUtilities.canBlockBeReplaced(world, pos.up()) + && WizardryUtilities.canBlockBeReplaced(world, pos.up(2))){ world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState()); if(world.getTileEntity(pos) instanceof TileEntityStatue){ ((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart(target, 1, 3); - ((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade))); + ((TileEntityStatue)world.getTileEntity(pos)) + .setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade))); } world.setBlockState(pos.up(), WizardryBlocks.ice_statue.getDefaultState()); @@ -99,22 +107,25 @@ public class IceStatue extends Spell { } } if(world.isRemote){ - for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ - float brightness = 0.5f + (world.rand.nextFloat()/2); + for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ + float brightness = 0.5f + (world.rand.nextFloat() / 2); - double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; + double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f); - Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, x1, y1, z1, 0.0d, -0.02d, 0.0d, 20 + world.rand.nextInt(10)); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 12 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, x1, y1, z1, 0.0d, -0.02d, 0.0d, + 20 + world.rand.nextInt(10)); } } caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.2F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, + world.rand.nextFloat() * 0.4F + 1.2F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Ignite.java b/src/main/java/electroblob/wizardry/spell/Ignite.java index 2807a570..4919a001 100644 --- a/src/main/java/electroblob/wizardry/spell/Ignite.java +++ b/src/main/java/electroblob/wizardry/spell/Ignite.java @@ -23,48 +23,64 @@ import net.minecraft.world.World; public class Ignite extends Spell { - public Ignite() { + public Ignite(){ super(Tier.BASIC, 5, Element.FIRE, "ignite", SpellType.ATTACK, 10, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ // Entity ray trace is done first because block ray trace passes through entities; if it was the other // way round, entities would only be hit when there were no blocks in range behind them. - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){ + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLivingBase){ - EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit; + EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit; if(MagicDamage.isEntityImmune(DamageType.FIRE, target)){ - if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted())); + if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(), + this.getNameForTranslationFormatted())); }else{ - target.setFire((int)(10*modifiers.get(WizardryItems.duration_upgrade))); + target.setFire((int)(10 * modifiers.get(WizardryItems.duration_upgrade))); } if(world.isRemote){ double dx = target.posX - caster.posX; - double dy = (target.getEntityBoundingBox().minY + target.height/2) - WizardryUtilities.getPlayerEyesPos(caster); + double dy = (target.getEntityBoundingBox().minY + target.height / 2) + - WizardryUtilities.getPlayerEyesPos(caster); double dz = target.posZ - caster.posZ; // i starts at 1 so that particles are not spawned in the player's head. - for(int i=1;i<5;i++){ - //WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0); - //WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0); - world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0); - world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0); + for(int i = 1; i < 5; i++){ + // WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + // + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + + // (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0); + // WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + // + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + + // (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0); + world.spawnParticle(EnumParticleTypes.FLAME, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0); + world.spawnParticle(EnumParticleTypes.FLAME, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0); } } caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ITEM_FLINTANDSTEEL_USE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ITEM_FLINTANDSTEEL_USE, 1.0F, + world.rand.nextFloat() * 0.4F + 0.8F); return true; }else{ - rayTrace = WizardryUtilities.rayTrace(10*modifiers.get(WizardryItems.range_upgrade), world, caster, false); + rayTrace = WizardryUtilities.rayTrace(10 * modifiers.get(WizardryItems.range_upgrade), world, caster, + false); // Gets block the player is looking at and sets the appropriate surrounding air block to fire. // Note how the block is set on the server side only (kinda obvious really) but the particles are @@ -77,21 +93,30 @@ public class Ignite extends Spell { if(!world.isRemote){ world.setBlockState(pos, Blocks.FIRE.getDefaultState()); } - + if(world.isRemote){ - + double dx = pos.getX() + 0.5 - caster.posX; double dy = pos.getY() + 0.5 - WizardryUtilities.getPlayerEyesPos(caster); double dz = pos.getZ() + 0.5 - caster.posZ; - - for(int i=1;i<5;i++){ - world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0); - world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0); + + for(int i = 1; i < 5; i++){ + world.spawnParticle(EnumParticleTypes.FLAME, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0); + world.spawnParticle(EnumParticleTypes.FLAME, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0); } } - + caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ITEM_FLINTANDSTEEL_USE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ITEM_FLINTANDSTEEL_USE, 1.0F, + world.rand.nextFloat() * 0.4F + 0.8F); return true; } } @@ -100,22 +125,35 @@ public class Ignite extends Spell { } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ if(target != null){ - if(!MagicDamage.isEntityImmune(DamageType.FIRE, target)) target.setFire((int)(10*modifiers.get(WizardryItems.duration_upgrade))); + if(!MagicDamage.isEntityImmune(DamageType.FIRE, target)) + target.setFire((int)(10 * modifiers.get(WizardryItems.duration_upgrade))); if(world.isRemote){ double dx = target.posX - caster.posX; - double dy = (target.getEntityBoundingBox().minY + target.height/2) - (caster.posY + caster.getEyeHeight()); + double dy = (target.getEntityBoundingBox().minY + target.height / 2) + - (caster.posY + caster.getEyeHeight()); double dz = target.posZ - caster.posZ; // i starts at 1 so that particles are not spawned in the player's head. - for(int i=1;i<5;i++){ - //WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0); - //WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0); - world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + caster.getEyeHeight() + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0); - world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + caster.getEyeHeight() + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0); + for(int i = 1; i < 5; i++){ + // WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + // + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + + // (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0); + // WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + // + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + + // (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0); + world.spawnParticle(EnumParticleTypes.FLAME, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + caster.posY + caster.getEyeHeight() + (i * (dy / 5)) + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0); + world.spawnParticle(EnumParticleTypes.FLAME, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + caster.posY + caster.getEyeHeight() + (i * (dy / 5)) + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0); } } diff --git a/src/main/java/electroblob/wizardry/spell/ImbueWeapon.java b/src/main/java/electroblob/wizardry/spell/ImbueWeapon.java index f2dbbcf6..88e8b5b5 100644 --- a/src/main/java/electroblob/wizardry/spell/ImbueWeapon.java +++ b/src/main/java/electroblob/wizardry/spell/ImbueWeapon.java @@ -23,54 +23,62 @@ import net.minecraft.world.World; public class ImbueWeapon extends Spell { - public ImbueWeapon() { + public ImbueWeapon(){ super(Tier.APPRENTICE, 20, Element.SORCERY, "imbue_weapon", SpellType.UTILITY, 50, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ // Won't work if the weapon already has the enchantment if(WizardData.get(caster) != null){ for(ItemStack stack : WizardryUtilities.getPrioritisedHotbarAndOffhand(caster)){ - if(stack != null){ + if(stack.getItem() instanceof ItemSword + && !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.magic_sword) + && WizardData.get(caster).getImbuementDuration(WizardryEnchantments.magic_sword) <= 0){ + // The enchantment level as determined by the damage multiplier. The + 0.5f is so that + // weird float processing doesn't incorrectly round it down. + stack.addEnchantment(WizardryEnchantments.magic_sword, modifiers.get(SpellModifiers.DAMAGE) == 1.0f + ? 1 + : (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f) / Constants.DAMAGE_INCREASE_PER_TIER + + 0.5f)); + WizardData.get(caster).setImbuementDuration(WizardryEnchantments.magic_sword, + (int)(900 * modifiers.get(WizardryItems.duration_upgrade))); - if(stack.getItem() instanceof ItemSword && !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.magic_sword) - && WizardData.get(caster).getImbuementDuration(WizardryEnchantments.magic_sword) <= 0){ - // The enchantment level as determined by the damage multiplier. The + 0.5f is so that - // weird float processing doesn't incorrectly round it down. - stack.addEnchantment(WizardryEnchantments.magic_sword, modifiers.get(SpellModifiers.DAMAGE) == 1.0f ? 1 : (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f)/Constants.DAMAGE_INCREASE_PER_TIER + 0.5f)); - WizardData.get(caster).setImbuementDuration(WizardryEnchantments.magic_sword, (int)(900*modifiers.get(WizardryItems.duration_upgrade))); + }else if(stack.getItem() instanceof ItemBow + && !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.magic_bow) + && WizardData.get(caster).getImbuementDuration(WizardryEnchantments.magic_bow) <= 0){ + // The enchantment level as determined by the damage multiplier. The + 0.5f is so that + // weird float processing doesn't incorrectly round it down. + stack.addEnchantment(WizardryEnchantments.magic_bow, modifiers.get(SpellModifiers.DAMAGE) == 1.0f + ? 1 + : (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f) / Constants.DAMAGE_INCREASE_PER_TIER + + 0.5f)); + WizardData.get(caster).setImbuementDuration(WizardryEnchantments.magic_bow, + (int)(900 * modifiers.get(WizardryItems.duration_upgrade))); - }else if(stack.getItem() instanceof ItemBow && !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.magic_bow) - && WizardData.get(caster).getImbuementDuration(WizardryEnchantments.magic_bow) <= 0){ - // The enchantment level as determined by the damage multiplier. The + 0.5f is so that - // weird float processing doesn't incorrectly round it down. - stack.addEnchantment(WizardryEnchantments.magic_bow, modifiers.get(SpellModifiers.DAMAGE) == 1.0f ? 1 : (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f)/Constants.DAMAGE_INCREASE_PER_TIER + 0.5f)); - WizardData.get(caster).setImbuementDuration(WizardryEnchantments.magic_bow, (int)(900*modifiers.get(WizardryItems.duration_upgrade))); - - }else{ - continue; - } - - if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); - double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.9f, 0.7f, 1.0f); - } - } - - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f); - return true; + }else{ + continue; } + + if(world.isRemote){ + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); + double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + + world.rand.nextFloat()); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 0.9f, 0.7f, 1.0f); + } + } + + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f); + return true; } } return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Intimidate.java b/src/main/java/electroblob/wizardry/spell/Intimidate.java index 941a9193..d82d25fb 100644 --- a/src/main/java/electroblob/wizardry/spell/Intimidate.java +++ b/src/main/java/electroblob/wizardry/spell/Intimidate.java @@ -35,16 +35,18 @@ public class Intimidate extends Spell { /** The NBT tag name for storing the feared entity's UUID in the target's tag compound. */ public static final String NBT_KEY = "fearedEntity"; - public Intimidate() { + public Intimidate(){ super(Tier.APPRENTICE, 20, Element.NECROMANCY, "intimidate", SpellType.ATTACK, 100, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ if(!world.isRemote){ - List entities = WizardryUtilities.getEntitiesWithinRadius(8*modifiers.get(WizardryItems.range_upgrade), caster.posX, caster.posY, caster.posZ, world, EntityCreature.class); + List entities = WizardryUtilities.getEntitiesWithinRadius( + 8 * modifiers.get(WizardryItems.range_upgrade), caster.posX, caster.posY, caster.posZ, world, + EntityCreature.class); for(EntityCreature target : entities){ @@ -53,16 +55,17 @@ public class Intimidate extends Spell { NBTTagCompound entityNBT = target.getEntityData(); if(entityNBT != null) entityNBT.setUniqueId(NBT_KEY, caster.getUniqueID()); - ((EntityLiving)target).addPotionEffect(new PotionEffect(WizardryPotions.fear, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0)); + ((EntityLiving)target).addPotionEffect(new PotionEffect(WizardryPotions.fear, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0)); } - + }else{ - for(int i=0; i<30; i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, caster.posX - 1 + world.rand.nextDouble()*2, - caster.getEntityBoundingBox().minY + 1.5 + world.rand.nextDouble()*0.5, - caster.posZ - 1 + world.rand.nextDouble()*2, - 0, 0, 0, 0, 0.9f, 0.1f, 0.0f); + for(int i = 0; i < 30; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, + caster.posX - 1 + world.rand.nextDouble() * 2, + caster.getEntityBoundingBox().minY + 1.5 + world.rand.nextDouble() * 0.5, + caster.posZ - 1 + world.rand.nextDouble() * 2, 0, 0, 0, 0, 0.9f, 0.1f, 0.0f); } } WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ENDERDRAGON_GROWL, 1.0f, 1.0f); @@ -72,6 +75,7 @@ public class Intimidate extends Spell { /** * Finds a random position away from the caster and sets the given target's AI path to that location. Defined here * so it can be used both in the spell itself and in the potion effect (event handler). + * * @param target The entity running away * @param caster The entity that is being run away from * @return True if a new path was found and set, false if not. @@ -80,15 +84,17 @@ public class Intimidate extends Spell { if(target.getDistanceToEntity(caster) < 16){ - Vec3d Vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(target, 16, 7, new Vec3d(caster.posX, caster.posY, caster.posZ)); + Vec3d Vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(target, 16, 7, + new Vec3d(caster.posX, caster.posY, caster.posZ)); - if (Vec3d == null){ + if(Vec3d == null){ return false; }else{ - // In both cases it is necessary to check if the entity already has a path so it doesn't change direction + // In both cases it is necessary to check if the entity already has a path so it doesn't change + // direction // every tick, unless that path is towards the caster. - //Path path = target.getNavigator().getPathToXYZ(Vec3d.xCoord, Vec3d.yCoord, Vec3d.zCoord); + // Path path = target.getNavigator().getPathToXYZ(Vec3d.xCoord, Vec3d.yCoord, Vec3d.zCoord); boolean flag = true; @@ -99,24 +105,25 @@ public class Intimidate extends Spell { // Has a built in mind trick effect because for whatever reason this makes it work with skeletons. target.setAttackTarget(null); - if(flag) return target.getNavigator().tryMoveToXYZ(Vec3d.xCoord, Vec3d.yCoord, Vec3d.zCoord, 1.25);//target.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue()); + if(flag) return target.getNavigator().tryMoveToXYZ(Vec3d.xCoord, Vec3d.yCoord, Vec3d.zCoord, 1.25);// target.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue()); } } return false; } - + @SubscribeEvent public static void onLivingUpdateEvent(LivingUpdateEvent event){ - - if(event.getEntityLiving().isPotionActive(WizardryPotions.fear) && event.getEntityLiving() instanceof EntityCreature){ + + if(event.getEntityLiving().isPotionActive(WizardryPotions.fear) + && event.getEntityLiving() instanceof EntityCreature){ NBTTagCompound entityNBT = event.getEntityLiving().getEntityData(); EntityCreature creature = (EntityCreature)event.getEntityLiving(); if(entityNBT != null && entityNBT.hasKey(NBT_KEY)){ - Entity caster = WizardryUtilities.getEntityByUUID(creature.worldObj, entityNBT.getUniqueId(NBT_KEY)); + Entity caster = WizardryUtilities.getEntityByUUID(creature.world, entityNBT.getUniqueId(NBT_KEY)); if(caster instanceof EntityLivingBase){ Intimidate.runAway(creature, (EntityLivingBase)caster); diff --git a/src/main/java/electroblob/wizardry/spell/InvigoratingPresence.java b/src/main/java/electroblob/wizardry/spell/InvigoratingPresence.java index b4cbc77d..71cf0216 100644 --- a/src/main/java/electroblob/wizardry/spell/InvigoratingPresence.java +++ b/src/main/java/electroblob/wizardry/spell/InvigoratingPresence.java @@ -20,35 +20,40 @@ import net.minecraft.world.World; public class InvigoratingPresence extends Spell { - public InvigoratingPresence() { - super(Tier.APPRENTICE, 30, Element.HEALING, "invigorating_presence", SpellType.UTILITY, 60, EnumAction.BOW, false); + public InvigoratingPresence(){ + super(Tier.APPRENTICE, 30, Element.HEALING, "invigorating_presence", SpellType.UTILITY, 60, EnumAction.BOW, + false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - List targets = WizardryUtilities.getEntitiesWithinRadius(5*modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world, EntityPlayer.class); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + List targets = WizardryUtilities.getEntitiesWithinRadius( + 5 * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world, + EntityPlayer.class); + for(EntityPlayer target : targets){ if(WizardryUtilities.isPlayerAlly(caster, target) || target == caster){ // Strength 2 for 45 seconds. - target.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, (int)(900*modifiers.get(WizardryItems.duration_upgrade)), 1, false, false)); + target.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, + (int)(900 * modifiers.get(WizardryItems.duration_upgrade)), 1, false, false)); } } - + if(world.isRemote){ - for(int i=0;i<50*modifiers.get(WizardryItems.blast_upgrade);i++){ - double radius = (1 + world.rand.nextDouble()*4)*modifiers.get(WizardryItems.blast_upgrade); - double angle = world.rand.nextDouble()*Math.PI*2; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX + radius*Math.cos(angle), caster.getEntityBoundingBox().minY, caster.posZ + radius*Math.sin(angle), - 0, 0.03, 0, 50, 1, 0.2f, 0.2f); + for(int i = 0; i < 50 * modifiers.get(WizardryItems.blast_upgrade); i++){ + double radius = (1 + world.rand.nextDouble() * 4) * modifiers.get(WizardryItems.blast_upgrade); + double angle = world.rand.nextDouble() * Math.PI * 2; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + caster.posX + radius * Math.cos(angle), caster.getEntityBoundingBox().minY, + caster.posZ + radius * Math.sin(angle), 0, 0.03, 0, 50, 1, 0.2f, 0.2f); } } - - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Invisibility.java b/src/main/java/electroblob/wizardry/spell/Invisibility.java index a26836d2..ed70f40c 100644 --- a/src/main/java/electroblob/wizardry/spell/Invisibility.java +++ b/src/main/java/electroblob/wizardry/spell/Invisibility.java @@ -20,40 +20,46 @@ import net.minecraft.world.World; public class Invisibility extends Spell { - public Invisibility() { + public Invisibility(){ super(Tier.ADVANCED, 35, Element.SORCERY, "invisibility", SpellType.UTILITY, 200, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ - caster.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0, false, false)); + caster.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0, false, false)); if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.7f, 1.0f, 1.0f); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 0.7f, 1.0f, 1.0f); } } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ if(!caster.isPotionActive(MobEffects.INVISIBILITY)){ - caster.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0, false, false)); + caster.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0, false, false)); if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)caster.posY + caster.getEyeHeight() - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.7f, 1.0f, 1.0f); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 0.7f, 1.0f, 1.0f); } } caster.playSound(WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); diff --git a/src/main/java/electroblob/wizardry/spell/InvokeWeather.java b/src/main/java/electroblob/wizardry/spell/InvokeWeather.java index 98fd97c6..9f0a3152 100644 --- a/src/main/java/electroblob/wizardry/spell/InvokeWeather.java +++ b/src/main/java/electroblob/wizardry/spell/InvokeWeather.java @@ -18,27 +18,27 @@ import net.minecraft.world.World; public class InvokeWeather extends Spell { - public InvokeWeather() { + public InvokeWeather(){ super(Tier.ADVANCED, 30, Element.LIGHTNING, "invoke_weather", SpellType.UTILITY, 100, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ if(caster.dimension == 0){ - + if(!world.isRemote){ // TODO: Backport these changes. int standardWeatherTime = (300 + (new Random()).nextInt(600)) * 20; if(world.isRaining()){ - caster.addChatComponentMessage(new TextComponentTranslation("spell.invoke_weather.sun")); + caster.sendMessage(new TextComponentTranslation("spell.invoke_weather.sun")); world.getWorldInfo().setCleanWeatherTime(standardWeatherTime); world.getWorldInfo().setRainTime(0); world.getWorldInfo().setThunderTime(0); world.getWorldInfo().setRaining(false); world.getWorldInfo().setThundering(false); }else{ - caster.addChatComponentMessage(new TextComponentTranslation("spell.invoke_weather.rain")); + caster.sendMessage(new TextComponentTranslation("spell.invoke_weather.rain")); world.getWorldInfo().setCleanWeatherTime(0); world.getWorldInfo().setRainTime(standardWeatherTime); world.getWorldInfo().setThunderTime(standardWeatherTime); @@ -47,21 +47,22 @@ public class InvokeWeather extends Spell { world.getWorldInfo().setThundering(world.rand.nextInt(3) == 0); } } - + if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); - double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.5f, 0.7f, 1.0f); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); + double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + + world.rand.nextFloat()); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 0.5f, 0.7f, 1.0f); } } - + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_LIGHTNING_THUNDER, 0.5F, 1.0f); return true; } return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Ironflesh.java b/src/main/java/electroblob/wizardry/spell/Ironflesh.java index 0997439b..acbbff3c 100644 --- a/src/main/java/electroblob/wizardry/spell/Ironflesh.java +++ b/src/main/java/electroblob/wizardry/spell/Ironflesh.java @@ -20,41 +20,47 @@ import net.minecraft.world.World; public class Ironflesh extends Spell { - public Ironflesh() { + public Ironflesh(){ super(Tier.ADVANCED, 30, Element.HEALING, "ironflesh", SpellType.DEFENCE, 100, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ - caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 2, false, false)); + caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 2, false, false)); if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.4f, 0.5f, 0.6f); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 0.4f, 0.5f, 0.6f); } } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ if(!caster.isPotionActive(MobEffects.RESISTANCE)){ - caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 2, false, false)); + caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 2, false, false)); if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)caster.posY + caster.getEyeHeight() - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.4f, 0.5f, 0.6f); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 0.4f, 0.5f, 0.6f); } } diff --git a/src/main/java/electroblob/wizardry/spell/Leap.java b/src/main/java/electroblob/wizardry/spell/Leap.java index 49c2265c..44028c75 100644 --- a/src/main/java/electroblob/wizardry/spell/Leap.java +++ b/src/main/java/electroblob/wizardry/spell/Leap.java @@ -14,34 +14,33 @@ import net.minecraft.world.World; public class Leap extends Spell { - public Leap() { + public Leap(){ super(Tier.BASIC, 10, Element.EARTH, "leap", SpellType.UTILITY, 20, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(caster.onGround){ - + caster.motionY = 0.65 * modifiers.get(SpellModifiers.DAMAGE); - caster.addVelocity(caster.getLookVec().xCoord*0.3, 0, caster.getLookVec().zCoord*0.3); - + caster.addVelocity(caster.getLookVec().xCoord * 0.3, 0, caster.getLookVec().zCoord * 0.3); + if(world.isRemote){ - for(int i=0; i<10; i++){ + for(int i = 0; i < 10; i++){ double x = (double)(caster.posX + world.rand.nextFloat() - 0.5F); double y = (double)(caster.getEntityBoundingBox().minY); double z = (double)(caster.posZ + world.rand.nextFloat() - 0.5F); world.spawnParticle(EnumParticleTypes.CLOUD, x, y, z, 0, 0, 0); } } - + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ENDERDRAGON_FLAP, 0.5F, 1.0f); caster.swingArm(hand); return true; } - + return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Levitation.java b/src/main/java/electroblob/wizardry/spell/Levitation.java index cc67b263..03907a3a 100644 --- a/src/main/java/electroblob/wizardry/spell/Levitation.java +++ b/src/main/java/electroblob/wizardry/spell/Levitation.java @@ -20,14 +20,17 @@ public class Levitation extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + caster.fallDistance = 0; caster.motionY = caster.motionY < 0.5d ? caster.motionY + 0.1d : caster.motionY; - + if(world.isRemote){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX - 0.25d + world.rand.nextDouble()/2, WizardryUtilities.getPlayerEyesPos(caster) - 1.5f, caster.posZ - 0.25d + world.rand.nextDouble()/2, 0, -0.1F, 0, 15, 0.5f, 1.0f, 0.7f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + caster.posX - 0.25d + world.rand.nextDouble() / 2, + WizardryUtilities.getPlayerEyesPos(caster) - 1.5f, + caster.posZ - 0.25d + world.rand.nextDouble() / 2, 0, -0.1F, 0, 15, 0.5f, 1.0f, 0.7f); } if(ticksInUse % 24 == 0 && world.isRemote){ Wizardry.proxy.playMovingSound(caster, WizardrySounds.SPELL_LOOP_SPARKLE, 0.5F, 1.0f, false); @@ -35,5 +38,4 @@ public class Levitation extends Spell { return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/LifeDrain.java b/src/main/java/electroblob/wizardry/spell/LifeDrain.java index cd2368b6..1a596523 100644 --- a/src/main/java/electroblob/wizardry/spell/LifeDrain.java +++ b/src/main/java/electroblob/wizardry/spell/LifeDrain.java @@ -22,37 +22,44 @@ import net.minecraft.world.World; public class LifeDrain extends Spell { - public LifeDrain() { + public LifeDrain(){ super(Tier.APPRENTICE, 10, Element.NECROMANCY, "life_drain", SpellType.ATTACK, 0, EnumAction.NONE, true); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ Vec3d look = caster.getLookVec(); - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); + + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLivingBase){ + + EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit; - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){ - - EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit; - if(ticksInUse % 12 == 0){ - WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), 2.0f * modifiers.get(SpellModifiers.DAMAGE)); + WizardryUtilities.attackEntityWithoutKnockback(target, + MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), + 2.0f * modifiers.get(SpellModifiers.DAMAGE)); caster.heal(1); } } if(world.isRemote){ - for(int i=5; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ + for(int i = 5; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ // I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet! - double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - //world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord); + double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + // world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord); if(i % 5 == 0){ - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 0, 0.1f, 0.0f, 0.0f); } - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, -0.05*look.xCoord*i, -0.05*look.yCoord*i, -0.05*look.zCoord*i, 8 + world.rand.nextInt(6), 0.5f, 0.0f, 0.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, -0.05 * look.xCoord * i, + -0.05 * look.yCoord * i, -0.05 * look.zCoord * i, 8 + world.rand.nextInt(6), 0.5f, 0.0f, 0.0f); } } if(ticksInUse % 18 == 0){ @@ -63,39 +70,46 @@ public class LifeDrain extends Spell { } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) { - - Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ).normalize(); + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + + Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ) + .normalize(); if(target != null){ if(ticksInUse % 12 == 0){ - WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), 2.0f * modifiers.get(SpellModifiers.DAMAGE)); + WizardryUtilities.attackEntityWithoutKnockback(target, + MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), + 2.0f * modifiers.get(SpellModifiers.DAMAGE)); caster.heal(1); } } if(world.isRemote){ - for(int i=5; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ + for(int i = 5; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ // I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet! - double x1 = caster.posX + vec.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + vec.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - //world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord); + double x1 = caster.posX + vec.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord * i / 2 + world.rand.nextFloat() / 5 + - 0.1f; + double z1 = caster.posZ + vec.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + // world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord); if(i % 5 == 0){ - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 0, 0.1f, 0.0f, 0.0f); } - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, -0.05*vec.xCoord*i, -0.05*vec.yCoord*i, -0.05*vec.zCoord*i, 8 + world.rand.nextInt(6), 0.5f, 0.0f, 0.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, -0.05 * vec.xCoord * i, + -0.05 * vec.yCoord * i, -0.05 * vec.zCoord * i, 8 + world.rand.nextInt(6), 0.5f, 0.0f, 0.0f); } } if(ticksInUse % 18 == 0){ if(ticksInUse == 0) caster.playSound(WizardrySounds.SPELL_SUMMONING, 1.0F, 0.6f); caster.playSound(WizardrySounds.SPELL_LOOP_CRACKLE, 2.0F, 1.0f); } - + return true; } - + @Override - public boolean canBeCastByNPCs() { + public boolean canBeCastByNPCs(){ return true; } diff --git a/src/main/java/electroblob/wizardry/spell/Light.java b/src/main/java/electroblob/wizardry/spell/Light.java index 96d056c8..4e67453c 100644 --- a/src/main/java/electroblob/wizardry/spell/Light.java +++ b/src/main/java/electroblob/wizardry/spell/Light.java @@ -18,7 +18,7 @@ import net.minecraft.world.World; public class Light extends Spell { - public Light() { + public Light(){ super(Tier.BASIC, 5, Element.SORCERY, "light", SpellType.UTILITY, 15, EnumAction.NONE, false); } @@ -28,41 +28,43 @@ public class Light extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + RayTraceResult rayTrace = WizardryUtilities.rayTrace(4, world, caster, false); - + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){ - + BlockPos pos = rayTrace.getBlockPos().offset(rayTrace.sideHit); - + if(world.isAirBlock(pos)){ - + if(!world.isRemote){ world.setBlockState(pos, WizardryBlocks.magic_light.getDefaultState()); if(world.getTileEntity(pos) instanceof TileEntityTimer){ - ((TileEntityTimer)world.getTileEntity(pos)).setLifetime((int)(600*modifiers.get(WizardryItems.duration_upgrade))); + ((TileEntityTimer)world.getTileEntity(pos)) + .setLifetime((int)(600 * modifiers.get(WizardryItems.duration_upgrade))); } } - + caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f); return true; } }else{ - - int x = (int) (Math.floor(caster.posX) + caster.getLookVec().xCoord*4); - int y = (int) (Math.floor(caster.posY) + caster.eyeHeight + caster.getLookVec().yCoord*4); - int z = (int) (Math.floor(caster.posZ) + caster.getLookVec().zCoord*4); - + + int x = (int)(Math.floor(caster.posX) + caster.getLookVec().xCoord * 4); + int y = (int)(Math.floor(caster.posY) + caster.eyeHeight + caster.getLookVec().yCoord * 4); + int z = (int)(Math.floor(caster.posZ) + caster.getLookVec().zCoord * 4); + BlockPos pos = new BlockPos(x, y, z); - + if(world.isAirBlock(pos)){ - //world.playSound(x, y, z, "sound.ambient.cave.cave", 1.0f, 1.5f, false); + // world.playSound(x, y, z, "sound.ambient.cave.cave", 1.0f, 1.5f, false); if(!world.isRemote){ world.setBlockState(pos, WizardryBlocks.magic_light.getDefaultState()); if(world.getTileEntity(pos) instanceof TileEntityTimer){ - ((TileEntityTimer)world.getTileEntity(pos)).setLifetime((int)(600*modifiers.get(WizardryItems.duration_upgrade))); + ((TileEntityTimer)world.getTileEntity(pos)) + .setLifetime((int)(600 * modifiers.get(WizardryItems.duration_upgrade))); } } caster.swingArm(hand); @@ -73,5 +75,4 @@ public class Light extends Spell { return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/LightningArrow.java b/src/main/java/electroblob/wizardry/spell/LightningArrow.java index 423fb35e..0940bc3b 100644 --- a/src/main/java/electroblob/wizardry/spell/LightningArrow.java +++ b/src/main/java/electroblob/wizardry/spell/LightningArrow.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class LightningArrow extends Spell { - public LightningArrow() { + public LightningArrow(){ super(Tier.APPRENTICE, 15, Element.LIGHTNING, "lightning_arrow", SpellType.ATTACK, 20, EnumAction.NONE, false); } @@ -27,36 +27,40 @@ public class LightningArrow extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ - EntityLightningArrow lightningArrow = new EntityLightningArrow(world, caster, 2*modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(lightningArrow); + EntityLightningArrow lightningArrow = new EntityLightningArrow(world, caster, + 2 * modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(lightningArrow); } - + caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LIGHTNING, 1.0F, world.rand.nextFloat() * 0.3F + 1.3F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LIGHTNING, 1.0F, + world.rand.nextFloat() * 0.3F + 1.3F); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - EntityLightningArrow lightningArrow = new EntityLightningArrow(world, caster, target, 2*modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(lightningArrow); + EntityLightningArrow lightningArrow = new EntityLightningArrow(world, caster, target, + 2 * modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(lightningArrow); } - + caster.swingArm(hand); caster.playSound(WizardrySounds.SPELL_LIGHTNING, 1.0F, world.rand.nextFloat() * 0.3F + 1.3F); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/LightningBolt.java b/src/main/java/electroblob/wizardry/spell/LightningBolt.java index ae7e1d28..9dcc53a9 100644 --- a/src/main/java/electroblob/wizardry/spell/LightningBolt.java +++ b/src/main/java/electroblob/wizardry/spell/LightningBolt.java @@ -24,11 +24,11 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @Mod.EventBusSubscriber public class LightningBolt extends Spell { - + /** The NBT key used to store the UUID of the player that summoned the lightning bolt. Used for achievements. */ public static final String NBT_KEY = "summoningPlayer"; - public LightningBolt() { + public LightningBolt(){ super(Tier.ADVANCED, 40, Element.LIGHTNING, "lightning_bolt", SpellType.ATTACK, 80, EnumAction.NONE, false); } @@ -38,72 +38,75 @@ public class LightningBolt extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + RayTraceResult rayTrace = WizardryUtilities.rayTrace(200, world, caster, false); - + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){ - + BlockPos pos = rayTrace.getBlockPos(); - - // Not sure why it is up 1 but it has to be for canBlockSeeSky to work properly. + + // Not sure why it is up 1 but it has to be for canBlockSeeSky to work properly. // TODO: Remove this requirement? - if(world.canBlockSeeSky(pos.up())){ - - if(!world.isRemote){ - EntityLightningBolt entitylightning = new EntityLightningBolt(world, pos.getX(), pos.getY(), pos.getZ(), false); - world.addWeatherEffect(entitylightning); - - // Code for eventhandler recognition; for achievements and such like. Left in for future use. - NBTTagCompound entityNBT = entitylightning.getEntityData(); - entityNBT.setUniqueId(NBT_KEY, caster.getUniqueID()); - } - - caster.swingArm(hand); - return true; - } - } - - return false; + if(world.canBlockSeeSky(pos.up())){ + + if(!world.isRemote){ + EntityLightningBolt entitylightning = new EntityLightningBolt(world, pos.getX(), pos.getY(), + pos.getZ(), false); + world.addWeatherEffect(entitylightning); + + // Code for eventhandler recognition; for achievements and such like. Left in for future use. + NBTTagCompound entityNBT = entitylightning.getEntityData(); + entityNBT.setUniqueId(NBT_KEY, caster.getUniqueID()); + } + + caster.swingArm(hand); + return true; + } + } + + return false; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ int x = (int)target.posX; - int y = (int)target.posY; - int z = (int)target.posZ; + int y = (int)target.posY; + int z = (int)target.posZ; - // Not sure why it is up 1 but it has to be for canBlockSeeSky to work properly. + // Not sure why it is up 1 but it has to be for canBlockSeeSky to work properly. // TODO: Remove this requirement? - if(world.canBlockSeeSky(new BlockPos(x, y, z))){ - - if(!world.isRemote){ - EntityLightningBolt entitylightning = new EntityLightningBolt(world, x, y, z, false); - world.addWeatherEffect(entitylightning); - } - - caster.swingArm(hand); - return true; - } + if(world.canBlockSeeSky(new BlockPos(x, y, z))){ + + if(!world.isRemote){ + EntityLightningBolt entitylightning = new EntityLightningBolt(world, x, y, z, false); + world.addWeatherEffect(entitylightning); + } + + caster.swingArm(hand); + return true; + } } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; } - + @SubscribeEvent public static void onEntityStruckByLightningEvent(EntityStruckByLightningEvent event){ if(event.getLightning().getEntityData() != null && event.getLightning().getEntityData().hasKey(NBT_KEY)){ - EntityPlayer player = (EntityPlayer)WizardryUtilities.getEntityByUUID(event.getLightning().worldObj, event.getLightning().getEntityData().getUniqueId("summoningPlayer")); + EntityPlayer player = (EntityPlayer)WizardryUtilities.getEntityByUUID(event.getLightning().world, + event.getLightning().getEntityData().getUniqueId("summoningPlayer")); if(event.getEntity() instanceof EntityCreeper){ player.addStat(WizardryAchievements.charge_creeper); diff --git a/src/main/java/electroblob/wizardry/spell/LightningDisc.java b/src/main/java/electroblob/wizardry/spell/LightningDisc.java index fe0d5f18..ef01f4f3 100644 --- a/src/main/java/electroblob/wizardry/spell/LightningDisc.java +++ b/src/main/java/electroblob/wizardry/spell/LightningDisc.java @@ -16,7 +16,7 @@ import net.minecraft.world.World; public class LightningDisc extends Spell { - public LightningDisc() { + public LightningDisc(){ super(Tier.ADVANCED, 25, Element.LIGHTNING, "lightning_disc", SpellType.ATTACK, 60, EnumAction.NONE, false); } @@ -26,37 +26,41 @@ public class LightningDisc extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ - EntityLightningDisc lightningdisc = new EntityLightningDisc(world, caster, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(lightningdisc); + EntityLightningDisc lightningdisc = new EntityLightningDisc(world, caster, + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(lightningdisc); } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LIGHTNING, 1.0F, world.rand.nextFloat() * 0.3F + 0.8F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LIGHTNING, 1.0F, + world.rand.nextFloat() * 0.3F + 0.8F); caster.swingArm(hand); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - EntityLightningDisc lightningdisc = new EntityLightningDisc(world, caster, modifiers.get(SpellModifiers.DAMAGE)); + EntityLightningDisc lightningdisc = new EntityLightningDisc(world, caster, + modifiers.get(SpellModifiers.DAMAGE)); lightningdisc.directTowards(target, 1.2f); - world.spawnEntityInWorld(lightningdisc); + world.spawnEntity(lightningdisc); } caster.playSound(WizardrySounds.SPELL_LIGHTNING, 1.0F, world.rand.nextFloat() * 0.3F + 0.8F); caster.swingArm(hand); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/LightningHammer.java b/src/main/java/electroblob/wizardry/spell/LightningHammer.java index a7408c2e..6bf29e29 100644 --- a/src/main/java/electroblob/wizardry/spell/LightningHammer.java +++ b/src/main/java/electroblob/wizardry/spell/LightningHammer.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class LightningHammer extends Spell { - public LightningHammer() { + public LightningHammer(){ super(Tier.MASTER, 100, Element.LIGHTNING, "lightning_hammer", SpellType.ATTACK, 300, EnumAction.BOW, false); } @@ -27,35 +27,37 @@ public class LightningHammer extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - RayTraceResult rayTrace = WizardryUtilities.rayTrace(40*modifiers.get(WizardryItems.range_upgrade), world, caster, false); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + RayTraceResult rayTrace = WizardryUtilities.rayTrace(40 * modifiers.get(WizardryItems.range_upgrade), world, + caster, false); + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){ BlockPos pos = rayTrace.getBlockPos(); - // Not sure why it is +1 but it has to be to work properly. - if(world.canBlockSeeSky(pos.up())){ - + // Not sure why it is +1 but it has to be to work properly. + if(world.canBlockSeeSky(pos.up())){ + if(!world.isRemote){ - - EntityHammer hammer = new EntityHammer(world, pos.getX()+0.5, pos.getY()+50, pos.getZ()+0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE)); - + + EntityHammer hammer = new EntityHammer(world, pos.getX() + 0.5, pos.getY() + 50, pos.getZ() + 0.5, + caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), + modifiers.get(SpellModifiers.DAMAGE)); + hammer.motionX = 0; hammer.motionY = -2; hammer.motionZ = 0; - - world.spawnEntityInWorld(hammer); + + world.spawnEntity(hammer); } - + caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_SUMMONING, 3.0f, 1.0f); return true; - } + } } return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/LightningPulse.java b/src/main/java/electroblob/wizardry/spell/LightningPulse.java index f180b10d..85fb7b49 100644 --- a/src/main/java/electroblob/wizardry/spell/LightningPulse.java +++ b/src/main/java/electroblob/wizardry/spell/LightningPulse.java @@ -23,7 +23,7 @@ import net.minecraft.world.World; public class LightningPulse extends Spell { - public LightningPulse() { + public LightningPulse(){ super(Tier.ADVANCED, 25, Element.LIGHTNING, "lightning_pulse", SpellType.ATTACK, 75, EnumAction.NONE, false); } @@ -33,26 +33,28 @@ public class LightningPulse extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(caster.onGround){ - - List targets = WizardryUtilities.getEntitiesWithinRadius(3.0d*modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world); - + + List targets = WizardryUtilities.getEntitiesWithinRadius( + 3.0d * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world); + for(EntityLivingBase target : targets){ if(WizardryUtilities.isValidTarget(caster, target)){ // Damage is 4 hearts no matter where the target is. - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 8 * modifiers.get(SpellModifiers.DAMAGE)); - + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), + 8 * modifiers.get(SpellModifiers.DAMAGE)); + if(!world.isRemote){ - + double dx = target.posX - caster.posX; double dz = target.posZ - caster.posZ; // Normalises the velocity. - double vectorLength = MathHelper.sqrt_double(dx*dx + dz*dz); + double vectorLength = MathHelper.sqrt(dx * dx + dz * dz); dx /= vectorLength; dz /= vectorLength; - + target.motionX = 0.8 * dx; target.motionY = 0; target.motionZ = 0.8 * dz; @@ -65,8 +67,10 @@ public class LightningPulse extends Spell { } } if(!world.isRemote){ - EntityLightningPulse lightningpulse = new EntityLightningPulse(world, caster.posX, caster.getEntityBoundingBox().minY, caster.posZ, caster, 7, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(lightningpulse); + EntityLightningPulse lightningpulse = new EntityLightningPulse(world, caster.posX, + caster.getEntityBoundingBox().minY, caster.posZ, caster, 7, + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(lightningpulse); } caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LIGHTNING, 1.0f, 1.0f); @@ -76,5 +80,4 @@ public class LightningPulse extends Spell { return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/LightningRay.java b/src/main/java/electroblob/wizardry/spell/LightningRay.java index b956bd49..eb1f68ec 100644 --- a/src/main/java/electroblob/wizardry/spell/LightningRay.java +++ b/src/main/java/electroblob/wizardry/spell/LightningRay.java @@ -24,114 +24,131 @@ import net.minecraft.world.World; public class LightningRay extends Spell { - public LightningRay() { + public LightningRay(){ super(Tier.APPRENTICE, 5, Element.LIGHTNING, "lightning_ray", SpellType.ATTACK, 0, EnumAction.NONE, true); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade), 2.0f); - - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){ + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade), 2.0f); + + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLivingBase){ Entity target = rayTrace.entityHit; if(!world.isRemote){ // This statement means the arc only spawns every other tick. if(ticksInUse % 2 == 0){ - + EntityArc arc = new EntityArc(world); // The look vec stuff performs a translation on the start point to line it up with the wand. // EDIT: removed due to 1st/3rd person render differences. - arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ, - target.posX, target.posY + target.height/2, target.posZ); - + arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ, target.posX, + target.posY + target.height / 2, target.posZ); + arc.lifetime = 1; - - world.spawnEntityInWorld(arc); + + world.spawnEntity(arc); } - + if(MagicDamage.isEntityImmune(DamageType.SHOCK, target)){ - if(!world.isRemote && ticksInUse == 1) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted())); + if(!world.isRemote && ticksInUse == 1) + caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(), + this.getNameForTranslationFormatted())); }else{ - WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 3.0f * modifiers.get(SpellModifiers.DAMAGE)); + WizardryUtilities.attackEntityWithoutKnockback(target, + MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), + 3.0f * modifiers.get(SpellModifiers.DAMAGE)); } - + }else{ - for(int i=0;i<5;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); - } + for(int i = 0; i < 5; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + target.posX + world.rand.nextFloat() - 0.5, + target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1, + target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); + } } - + if(ticksInUse == 1){ WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LIGHTNING, 1.0F, 1.0f); }else if(ticksInUse > 0 && ticksInUse % 20 == 0){ WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LOOP_LIGHTNING, 1.0F, 1.0f); } - + return true; - + }else{ if(!world.isRemote){ // This statement means the arc only spawns every other tick. if(ticksInUse % 2 == 0){ - + EntityArc arc = new EntityArc(world); - + arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ, - caster.posX + caster.getLookVec().xCoord * 8, caster.posY + caster.eyeHeight + caster.getLookVec().yCoord * 8, caster.posZ + caster.getLookVec().zCoord * 8); - + caster.posX + caster.getLookVec().xCoord * 8, + caster.posY + caster.eyeHeight + caster.getLookVec().yCoord * 8, + caster.posZ + caster.getLookVec().zCoord * 8); + arc.lifetime = 1; - - world.spawnEntityInWorld(arc); + + world.spawnEntity(arc); } } - + if(ticksInUse == 1){ WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LIGHTNING, 1.0F, 1.0f); }else if(ticksInUse > 0 && ticksInUse % 20 == 0){ WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LOOP_LIGHTNING, 1.0F, 1.0f); } - + return true; } } - + @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ if(!world.isRemote){ // This statement means the arc only spawns every other tick. if(ticksInUse % 2 == 0){ - + EntityArc arc = new EntityArc(world); // The look vec stuff performs a translation on the start point to line it up with the wand. // EDIT: removed due to 1st/3rd person render differences. - arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ, - target.posX, target.posY + target.height/2, target.posZ); - + arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ, target.posX, + target.posY + target.height / 2, target.posZ); + arc.lifetime = 1; - - world.spawnEntityInWorld(arc); + + world.spawnEntity(arc); } - - WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 3.0f * modifiers.get(SpellModifiers.DAMAGE)); - + + WizardryUtilities.attackEntityWithoutKnockback(target, + MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), + 3.0f * modifiers.get(SpellModifiers.DAMAGE)); + }else{ - for(int i=0;i<5;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); - } + for(int i = 0; i < 5; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + target.posX + world.rand.nextFloat() - 0.5, + target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1, + target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); + } } - + if(ticksInUse == 1){ caster.playSound(WizardrySounds.SPELL_LIGHTNING, 1.0F, 1.0f); }else if(ticksInUse > 0 && ticksInUse % 20 == 0){ caster.playSound(WizardrySounds.SPELL_LOOP_LIGHTNING, 1.0F, 1.0f); } - + return true; } - + return false; } diff --git a/src/main/java/electroblob/wizardry/spell/LightningSigil.java b/src/main/java/electroblob/wizardry/spell/LightningSigil.java index 831a1189..1463e2ca 100644 --- a/src/main/java/electroblob/wizardry/spell/LightningSigil.java +++ b/src/main/java/electroblob/wizardry/spell/LightningSigil.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class LightningSigil extends Spell { - public LightningSigil() { + public LightningSigil(){ super(Tier.APPRENTICE, 10, Element.LIGHTNING, "lightning_sigil", SpellType.ATTACK, 20, EnumAction.NONE, false); } @@ -27,20 +27,22 @@ public class LightningSigil extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - RayTraceResult rayTrace = WizardryUtilities.rayTrace(10*modifiers.get(WizardryItems.range_upgrade), world, caster, false); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + RayTraceResult rayTrace = WizardryUtilities.rayTrace(10 * modifiers.get(WizardryItems.range_upgrade), world, + caster, false); + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK && rayTrace.sideHit == EnumFacing.UP){ - + if(!world.isRemote){ double x = rayTrace.hitVec.xCoord; double y = rayTrace.hitVec.yCoord; double z = rayTrace.hitVec.zCoord; - EntityLightningSigil lightningsigil = new EntityLightningSigil(world, x, y, z, caster, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(lightningsigil); + EntityLightningSigil lightningsigil = new EntityLightningSigil(world, x, y, z, caster, + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(lightningsigil); } - + caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F, 0.3F); return true; @@ -48,5 +50,4 @@ public class LightningSigil extends Spell { return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/LightningWeb.java b/src/main/java/electroblob/wizardry/spell/LightningWeb.java index 3b654be1..805058b2 100644 --- a/src/main/java/electroblob/wizardry/spell/LightningWeb.java +++ b/src/main/java/electroblob/wizardry/spell/LightningWeb.java @@ -25,56 +25,65 @@ import net.minecraft.world.World; public class LightningWeb extends Spell { - public LightningWeb() { + public LightningWeb(){ super(Tier.MASTER, 15, Element.LIGHTNING, "lightning_web", SpellType.ATTACK, 0, EnumAction.NONE, true); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade), 2.0f); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade), 2.0f); + + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLivingBase){ - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){ - Entity target = rayTrace.entityHit; - + if(!world.isRemote){ - + // This statement means the arc only spawns every other tick. if(ticksInUse % 2 == 0){ EntityArc arc = new EntityArc(world); // The look vec stuff performs a translation on the start point to line it up with the wand. // EDIT: removed due to 1st/3rd person render differences. - arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ, - target.posX, target.posY + target.height/2, target.posZ); + arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ, target.posX, + target.posY + target.height / 2, target.posZ); arc.lifetime = 1; - world.spawnEntityInWorld(arc); + world.spawnEntity(arc); } - + if(MagicDamage.isEntityImmune(DamageType.SHOCK, target)){ - if(!world.isRemote && ticksInUse == 1) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted())); + if(!world.isRemote && ticksInUse == 1) + caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(), + this.getNameForTranslationFormatted())); }else{ // This motion stuff removes knockback, which is desirable for continuous spells. double motionX = target.motionX; double motionY = target.motionY; double motionZ = target.motionZ; - - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 5.0f * modifiers.get(SpellModifiers.DAMAGE)); - + + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), + 5.0f * modifiers.get(SpellModifiers.DAMAGE)); + target.motionX = motionX; target.motionY = motionY; target.motionZ = motionZ; } }else{ - for(int i=0;i<5;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); + for(int i = 0; i < 5; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + target.posX + world.rand.nextFloat() - 0.5, + target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1, + target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); } } // Secondary chaining effect double seekerRange = 5.0d; - List secondaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, target.posX, target.posY + target.height/2, target.posZ, world); + List secondaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, + target.posX, target.posY + target.height / 2, target.posZ, world); // This is a MUCH better way of filtering the secondary targets! secondaryTargets.remove(target); if(secondaryTargets.size() > 5) secondaryTargets = secondaryTargets.subList(0, 5); @@ -87,35 +96,45 @@ public class LightningWeb extends Spell { // This statement means the arc only spawns every other tick. if(ticksInUse % 2 == 0){ EntityArc arc = new EntityArc(world); - arc.setEndpointCoords(target.posX, target.posY + 1.2, target.posZ, - secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height/2, secondaryTarget.posZ); + arc.setEndpointCoords(target.posX, target.posY + 1.2, target.posZ, secondaryTarget.posX, + secondaryTarget.posY + secondaryTarget.height / 2, secondaryTarget.posZ); arc.lifetime = 1; - world.spawnEntityInWorld(arc); + world.spawnEntity(arc); } - + if(MagicDamage.isEntityImmune(DamageType.SHOCK, secondaryTarget)){ - if(!world.isRemote && ticksInUse == 1) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", secondaryTarget.getName(), this.getNameForTranslationFormatted())); + if(!world.isRemote && ticksInUse == 1) + caster.sendMessage(new TextComponentTranslation("spell.resist", + secondaryTarget.getName(), this.getNameForTranslationFormatted())); }else{ // This motion stuff removes knockback, which is desirable for continuous spells. double motionX = secondaryTarget.motionX; double motionY = secondaryTarget.motionY; double motionZ = secondaryTarget.motionZ; - - secondaryTarget.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 4.0f * modifiers.get(SpellModifiers.DAMAGE)); - + + secondaryTarget.attackEntityFrom( + MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), + 4.0f * modifiers.get(SpellModifiers.DAMAGE)); + secondaryTarget.motionX = motionX; secondaryTarget.motionY = motionY; secondaryTarget.motionZ = motionZ; } }else{ - for(int i=0;i<5;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, secondaryTarget.posX + world.rand.nextFloat() - 0.5, secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height/2 + world.rand.nextFloat()*2 - 1, secondaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); + for(int i = 0; i < 5; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + secondaryTarget.posX + world.rand.nextFloat() - 0.5, + secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height / 2 + + world.rand.nextFloat() * 2 - 1, + secondaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); } } // Tertiary chaining effect - List tertiaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height/2, secondaryTarget.posZ, world); + List tertiaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, + secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height / 2, + secondaryTarget.posZ, world); tertiaryTargets.remove(target); tertiaryTargets.removeAll(secondaryTargets); if(tertiaryTargets.size() > 2) tertiaryTargets = tertiaryTargets.subList(0, 2); @@ -128,29 +147,38 @@ public class LightningWeb extends Spell { // This statement means the arc only spawns every other tick. if(ticksInUse % 2 == 0){ EntityArc arc = new EntityArc(world); - arc.setEndpointCoords(secondaryTarget.posX, secondaryTarget.posY + 1.2, secondaryTarget.posZ, - tertiaryTarget.posX, tertiaryTarget.posY + tertiaryTarget.height/2, tertiaryTarget.posZ); + arc.setEndpointCoords(secondaryTarget.posX, secondaryTarget.posY + 1.2, + secondaryTarget.posZ, tertiaryTarget.posX, + tertiaryTarget.posY + tertiaryTarget.height / 2, tertiaryTarget.posZ); arc.lifetime = 1; - world.spawnEntityInWorld(arc); + world.spawnEntity(arc); } - + if(MagicDamage.isEntityImmune(DamageType.SHOCK, tertiaryTarget)){ - if(!world.isRemote && ticksInUse == 1) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", tertiaryTarget.getName(), this.getNameForTranslationFormatted())); + if(!world.isRemote && ticksInUse == 1) + caster.sendMessage(new TextComponentTranslation("spell.resist", + tertiaryTarget.getName(), this.getNameForTranslationFormatted())); }else{ // This motion stuff removes knockback, which is desirable for continuous spells. double motionX = tertiaryTarget.motionX; double motionY = tertiaryTarget.motionY; double motionZ = tertiaryTarget.motionZ; - - tertiaryTarget.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 3.0f * modifiers.get(SpellModifiers.DAMAGE)); - + + tertiaryTarget.attackEntityFrom( + MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), + 3.0f * modifiers.get(SpellModifiers.DAMAGE)); + tertiaryTarget.motionX = motionX; tertiaryTarget.motionY = motionY; tertiaryTarget.motionZ = motionZ; } }else{ - for(int i=0;i<5;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, tertiaryTarget.posX + world.rand.nextFloat() - 0.5, tertiaryTarget.getEntityBoundingBox().minY + tertiaryTarget.height/2 + world.rand.nextFloat()*2 - 1, tertiaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); + for(int i = 0; i < 5; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + tertiaryTarget.posX + world.rand.nextFloat() - 0.5, + tertiaryTarget.getEntityBoundingBox().minY + tertiaryTarget.height / 2 + + world.rand.nextFloat() * 2 - 1, + tertiaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); } } } @@ -163,7 +191,7 @@ public class LightningWeb extends Spell { }else if(ticksInUse > 0 && ticksInUse % 20 == 0){ WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LOOP_LIGHTNING, 1.0F, 1.0f); } - + return true; }else{ @@ -172,10 +200,12 @@ public class LightningWeb extends Spell { if(ticksInUse % 2 == 0){ EntityArc arc = new EntityArc(world); arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ, - caster.posX + caster.getLookVec().xCoord * 8, caster.posY + caster.eyeHeight + caster.getLookVec().yCoord * 8, caster.posZ + caster.getLookVec().zCoord * 8); + caster.posX + caster.getLookVec().xCoord * 8, + caster.posY + caster.eyeHeight + caster.getLookVec().yCoord * 8, + caster.posZ + caster.getLookVec().zCoord * 8); arc.lifetime = 1; - //arc.setOffset(entityplayer.getLookVec().zCoord * 0.5, entityplayer.getLookVec().xCoord * 0.5); - world.spawnEntityInWorld(arc); + // arc.setOffset(entityplayer.getLookVec().zCoord * 0.5, entityplayer.getLookVec().xCoord * 0.5); + world.spawnEntity(arc); } } @@ -189,5 +219,4 @@ public class LightningWeb extends Spell { } } - } diff --git a/src/main/java/electroblob/wizardry/spell/MagicMissile.java b/src/main/java/electroblob/wizardry/spell/MagicMissile.java index 9cb083e3..1b42bc93 100644 --- a/src/main/java/electroblob/wizardry/spell/MagicMissile.java +++ b/src/main/java/electroblob/wizardry/spell/MagicMissile.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class MagicMissile extends Spell { - public MagicMissile() { + public MagicMissile(){ super(Tier.BASIC, 5, Element.MAGIC, "magic_missile", SpellType.ATTACK, 10, EnumAction.NONE, false); } @@ -27,41 +27,45 @@ public class MagicMissile extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ - EntityMagicMissile magicMissile = new EntityMagicMissile(world, caster, 2*modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(magicMissile); + EntityMagicMissile magicMissile = new EntityMagicMissile(world, caster, + 2 * modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(magicMissile); } - + caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_MAGIC, 1.0F, world.rand.nextFloat() * 0.4F + 1.2F); - + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_MAGIC, 1.0F, + world.rand.nextFloat() * 0.4F + 1.2F); + return true; } - + @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - EntityMagicMissile magicMissile = new EntityMagicMissile(world, caster, target, 2*modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(magicMissile); + EntityMagicMissile magicMissile = new EntityMagicMissile(world, caster, target, + 2 * modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(magicMissile); } - + caster.swingArm(hand); caster.playSound(WizardrySounds.SPELL_MAGIC, 1.0F, world.rand.nextFloat() * 0.4F + 1.2F); - + return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; } - + } diff --git a/src/main/java/electroblob/wizardry/spell/Metamorphosis.java b/src/main/java/electroblob/wizardry/spell/Metamorphosis.java index abfceedc..f1eb6e29 100644 --- a/src/main/java/electroblob/wizardry/spell/Metamorphosis.java +++ b/src/main/java/electroblob/wizardry/spell/Metamorphosis.java @@ -18,7 +18,7 @@ import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.monster.EntitySlime; import net.minecraft.entity.monster.EntitySpider; -import net.minecraft.entity.monster.SkeletonType; +import net.minecraft.entity.monster.EntityWitherSkeleton; import net.minecraft.entity.passive.EntityBat; import net.minecraft.entity.passive.EntityChicken; import net.minecraft.entity.passive.EntityCow; @@ -33,93 +33,84 @@ import net.minecraft.world.World; public class Metamorphosis extends Spell { - public Metamorphosis() { + public Metamorphosis(){ super(Tier.APPRENTICE, 15, Element.NECROMANCY, "metamorphosis", SpellType.UTILITY, 30, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + Vec3d look = caster.getLookVec(); - - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); - + + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); + if(rayTrace != null && rayTrace.entityHit != null && rayTrace.entityHit instanceof EntityLivingBase){ - + Entity entityHit = rayTrace.entityHit; double xPos = entityHit.posX; double yPos = entityHit.posY; double zPos = entityHit.posZ; - + EntityLiving newEntity = null; - boolean flag = false; - + + // IDEA: Interaction with husks/strays? + // TODO: Replace with a bimap or something. if(entityHit instanceof EntityPig){ newEntity = new EntityPigZombie(world); - } - else if(entityHit instanceof EntityPigZombie){ + }else if(entityHit instanceof EntityPigZombie){ newEntity = new EntityPig(world); - } - else if(entityHit instanceof EntitySkeleton){ - // IDEA: Interaction with husks/strays? - if(((EntitySkeleton)entityHit).getSkeletonType() == SkeletonType.NORMAL){ - ((EntitySkeleton)entityHit).setSkeletonType(SkeletonType.WITHER); - }else{ - ((EntitySkeleton)entityHit).setSkeletonType(SkeletonType.NORMAL); - } - flag = true; - } - else if(entityHit instanceof EntityCow && !(entityHit instanceof EntityMooshroom)){ + }else if(entityHit instanceof EntitySkeleton){ + newEntity = new EntityWitherSkeleton(world); + }else if(entityHit instanceof EntityWitherSkeleton){ + newEntity = new EntitySkeleton(world); + }else if(entityHit instanceof EntityCow && !(entityHit instanceof EntityMooshroom)){ newEntity = new EntityMooshroom(world); - } - else if(entityHit instanceof EntityMooshroom){ + }else if(entityHit instanceof EntityMooshroom){ newEntity = new EntityCow(world); - } - else if(entityHit instanceof EntityChicken){ + }else if(entityHit instanceof EntityChicken){ newEntity = new EntityBat(world); - } - else if(entityHit instanceof EntityBat){ + }else if(entityHit instanceof EntityBat){ newEntity = new EntityChicken(world); - } - else if(entityHit instanceof EntitySlime && !(entityHit instanceof EntityMagmaCube)){ + }else if(entityHit instanceof EntitySlime && !(entityHit instanceof EntityMagmaCube)){ newEntity = new EntityMagmaCube(world); - } - else if(entityHit instanceof EntityMagmaCube){ + }else if(entityHit instanceof EntityMagmaCube){ newEntity = new EntitySlime(world); - } - else if(entityHit instanceof EntitySpider && !(entityHit instanceof EntityCaveSpider)){ + }else if(entityHit instanceof EntitySpider && !(entityHit instanceof EntityCaveSpider)){ newEntity = new EntityCaveSpider(world); - } - else if(entityHit instanceof EntityCaveSpider){ + }else if(entityHit instanceof EntityCaveSpider){ newEntity = new EntitySpider(world); } - - if(newEntity != null || flag){ - + + if(newEntity != null){ + if(!world.isRemote && newEntity != null){ - //Transfers attributes from the old entity to the new one. - newEntity.setHealth(((EntityLiving)entityHit).getHealth()); - //newEntity.writeToNBT(entityHit.getEntityData()); - - entityHit.setDead(); - newEntity.setPosition(xPos, yPos, zPos); - world.spawnEntityInWorld(newEntity); + // Transfers attributes from the old entity to the new one. + newEntity.setHealth(((EntityLiving)entityHit).getHealth()); + // newEntity.writeToNBT(entityHit.getEntityData()); + + entityHit.setDead(); + newEntity.setPosition(xPos, yPos, zPos); + world.spawnEntity(newEntity); } if(world.isRemote){ - for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ + for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ // I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet! - double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - //world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), 0.2f, 0.0f, 0.1f); + double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + // world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 12 + world.rand.nextInt(8), 0.2f, 0.0f, 0.1f); + } + for(int i = 0; i < 5; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, xPos, yPos, zPos, 0.0d, + 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f); } - for(int i=0;i<5;i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, xPos, yPos, zPos, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f); - } } - + caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_DEFLECTION, 0.5F, 0.8f); return true; @@ -128,5 +119,4 @@ public class Metamorphosis extends Spell { return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Meteor.java b/src/main/java/electroblob/wizardry/spell/Meteor.java index af6c4aa3..073d9ba6 100644 --- a/src/main/java/electroblob/wizardry/spell/Meteor.java +++ b/src/main/java/electroblob/wizardry/spell/Meteor.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class Meteor extends Spell { - public Meteor() { + public Meteor(){ super(Tier.MASTER, 100, Element.FIRE, "meteor", SpellType.ATTACK, 200, EnumAction.NONE, false); } @@ -27,29 +27,30 @@ public class Meteor extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - RayTraceResult rayTrace = WizardryUtilities.rayTrace(40*modifiers.get(WizardryItems.range_upgrade), world, caster, false); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + RayTraceResult rayTrace = WizardryUtilities.rayTrace(40 * modifiers.get(WizardryItems.range_upgrade), world, + caster, false); + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){ BlockPos pos = rayTrace.getBlockPos(); - // Not sure why it is +1 but it has to be to work properly. - if(world.canBlockSeeSky(pos.up())){ - + // Not sure why it is +1 but it has to be to work properly. + if(world.canBlockSeeSky(pos.up())){ + if(!world.isRemote){ - EntityMeteor meteor = new EntityMeteor(world, pos.getX(), pos.getY() + 50, pos.getZ(), modifiers.get(WizardryItems.blast_upgrade)); - world.spawnEntityInWorld(meteor); + EntityMeteor meteor = new EntityMeteor(world, pos.getX(), pos.getY() + 50, pos.getZ(), + modifiers.get(WizardryItems.blast_upgrade)); + world.spawnEntity(meteor); } caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_SUMMONING, 3.0f, 1.0f); return true; - } + } } return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/MindControl.java b/src/main/java/electroblob/wizardry/spell/MindControl.java index 356d58e2..cc6ff184 100644 --- a/src/main/java/electroblob/wizardry/spell/MindControl.java +++ b/src/main/java/electroblob/wizardry/spell/MindControl.java @@ -26,26 +26,29 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; -import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @Mod.EventBusSubscriber public class MindControl extends Spell { - /** The NBT tag name for storing the controlling entity's UUID in the target's tag compound. Defined here in case - * it changes. */ + /** + * The NBT tag name for storing the controlling entity's UUID in the target's tag compound. Defined here in case it + * changes. + */ public static final String NBT_KEY = "controllingEntity"; - public MindControl() { + public MindControl(){ super(Tier.ADVANCED, 40, Element.NECROMANCY, "mind_control", SpellType.ATTACK, 150, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 8*modifiers.get(WizardryItems.range_upgrade)); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 8 * modifiers.get(WizardryItems.range_upgrade)); if(rayTrace != null && rayTrace.entityHit != null && rayTrace.entityHit instanceof EntityLivingBase){ @@ -54,7 +57,8 @@ public class MindControl extends Spell { if(!world.isRemote){ if(!canControl(target)){ // Adds a message saying that the player/boss entity/wizard resisted mind control - if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted())); + if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist", + target.getName(), this.getNameForTranslationFormatted())); }else if(target instanceof EntityLiving){ @@ -66,18 +70,21 @@ public class MindControl extends Spell { NBTTagCompound entityNBT = target.getEntityData(); if(entityNBT != null) entityNBT.setUniqueId(NBT_KEY, caster.getUniqueID()); - ((EntityLiving)target).addPotionEffect(new PotionEffect(WizardryPotions.mind_control, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0)); + ((EntityLiving)target).addPotionEffect(new PotionEffect(WizardryPotions.mind_control, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0)); } }else{ - for(int i=0; i<10; i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, target.posX - 0.25 + world.rand.nextDouble()*0.5, - target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + world.rand.nextDouble()*0.5, - target.posZ - 0.25 + world.rand.nextDouble()*0.5, - 0, 0, 0, 0, 0.8f, 0.2f, 1.0f); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, target.posX - 0.25 + world.rand.nextDouble()*0.5, - target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + world.rand.nextDouble()*0.5, - target.posZ - 0.25 + world.rand.nextDouble()*0.5, - 0, 0, 0, 0, 0.2f, 0.04f, 0.25f); + for(int i = 0; i < 10; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, + target.posX - 0.25 + world.rand.nextDouble() * 0.5, + target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + + world.rand.nextDouble() * 0.5, + target.posZ - 0.25 + world.rand.nextDouble() * 0.5, 0, 0, 0, 0, 0.8f, 0.2f, 1.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, + target.posX - 0.25 + world.rand.nextDouble() * 0.5, + target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + + world.rand.nextDouble() * 0.5, + target.posZ - 0.25 + world.rand.nextDouble() * 0.5, 0, 0, 0, 0, 0.2f, 0.04f, 0.25f); } } target.playSound(WizardrySounds.SPELL_SUMMONING, 1.0f, 1.0f); @@ -88,7 +95,8 @@ public class MindControl extends Spell { } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) { + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ if(target != null){ if(!world.isRemote){ @@ -102,18 +110,21 @@ public class MindControl extends Spell { NBTTagCompound entityNBT = target.getEntityData(); if(entityNBT != null) entityNBT.setUniqueId(NBT_KEY, caster.getUniqueID()); - ((EntityLiving)target).addPotionEffect(new PotionEffect(WizardryPotions.mind_control, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0)); + ((EntityLiving)target).addPotionEffect(new PotionEffect(WizardryPotions.mind_control, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0)); } }else{ - for(int i=0; i<10; i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, target.posX - 0.25 + world.rand.nextDouble()*0.5, - target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + world.rand.nextDouble()*0.5, - target.posZ - 0.25 + world.rand.nextDouble()*0.5, - 0, 0, 0, 0, 0.8f, 0.2f, 1.0f); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, target.posX - 0.25 + world.rand.nextDouble()*0.5, - target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + world.rand.nextDouble()*0.5, - target.posZ - 0.25 + world.rand.nextDouble()*0.5, - 0, 0, 0, 0, 0.2f, 0.04f, 0.25f); + for(int i = 0; i < 10; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, + target.posX - 0.25 + world.rand.nextDouble() * 0.5, + target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + + world.rand.nextDouble() * 0.5, + target.posZ - 0.25 + world.rand.nextDouble() * 0.5, 0, 0, 0, 0, 0.8f, 0.2f, 1.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, + target.posX - 0.25 + world.rand.nextDouble() * 0.5, + target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + + world.rand.nextDouble() * 0.5, + target.posZ - 0.25 + world.rand.nextDouble() * 0.5, 0, 0, 0, 0, 0.2f, 0.04f, 0.25f); } } target.playSound(WizardrySounds.SPELL_SUMMONING, 1.0f, 1.0f); @@ -135,9 +146,10 @@ public class MindControl extends Spell { } /** - * Finds the nearest creature to the given target which it is allowed to attack according to the given caster - * and sets it as the target's attack target. Handles both new and old AI and takes follow range into account. - * Defined here so it can be used both in the spell itself and in the potion effect (event handler). + * Finds the nearest creature to the given target which it is allowed to attack according to the given caster and + * sets it as the target's attack target. Handles both new and old AI and takes follow range into account. Defined + * here so it can be used both in the spell itself and in the potion effect (event handler). + * * @param target The entity being mind controlled * @param caster The entity doing the controlling * @param world The world to look for targets in @@ -179,7 +191,8 @@ public class MindControl extends Spell { public static void onLivingUpdateEvent(LivingUpdateEvent event){ // This was added because something got changed in the AI classes which means LivingSetAttackTargetEvent doesn't // get fired when I want it to... so I'm firing it myself. - if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_control) && event.getEntityLiving() instanceof EntityLiving + if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_control) + && event.getEntityLiving() instanceof EntityLiving && ((EntityLiving)event.getEntityLiving()).getAttackTarget() != null && !((EntityLiving)event.getEntityLiving()).getAttackTarget().isEntityAlive()) ((EntityLiving)event.getEntityLiving()).setAttackTarget(null); // Causes the event to be fired @@ -188,20 +201,23 @@ public class MindControl extends Spell { @SubscribeEvent public static void onLivingSetAttackTargetEvent(LivingSetAttackTargetEvent event){ - if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_control) && MindControl.canControl(event.getEntityLiving())){ + if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_control) + && MindControl.canControl(event.getEntityLiving())){ NBTTagCompound entityNBT = event.getEntityLiving().getEntityData(); if(entityNBT != null && entityNBT.hasKey(MindControl.NBT_KEY + "Most")){ - Entity caster = WizardryUtilities.getEntityByUUID(event.getEntity().worldObj, entityNBT.getUniqueId(MindControl.NBT_KEY)); + Entity caster = WizardryUtilities.getEntityByUUID(event.getEntity().world, + entityNBT.getUniqueId(MindControl.NBT_KEY)); // If the target that the event tried to set is already a valid mind control target, nothing happens. if(event.getTarget() != null && WizardryUtilities.isValidTarget(caster, event.getTarget())) return; if(caster instanceof EntityLivingBase){ - if(MindControl.findMindControlTarget((EntityLiving)event.getEntityLiving(), (EntityLivingBase)caster, event.getEntity().worldObj)){ + if(MindControl.findMindControlTarget((EntityLiving)event.getEntityLiving(), + (EntityLivingBase)caster, event.getEntity().world)){ // If it worked, skip setting the target to null. return; } diff --git a/src/main/java/electroblob/wizardry/spell/MindTrick.java b/src/main/java/electroblob/wizardry/spell/MindTrick.java index d9cab649..d7edc970 100644 --- a/src/main/java/electroblob/wizardry/spell/MindTrick.java +++ b/src/main/java/electroblob/wizardry/spell/MindTrick.java @@ -27,14 +27,15 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @Mod.EventBusSubscriber public class MindTrick extends Spell { - public MindTrick() { + public MindTrick(){ super(Tier.BASIC, 10, Element.NECROMANCY, "mind_trick", SpellType.ATTACK, 40, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 8*modifiers.get(WizardryItems.range_upgrade)); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 8 * modifiers.get(WizardryItems.range_upgrade)); if(rayTrace != null && rayTrace.entityHit != null && rayTrace.entityHit instanceof EntityLivingBase){ @@ -44,19 +45,22 @@ public class MindTrick extends Spell { if(target instanceof EntityPlayer){ - target.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0)); + target.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, + (int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0)); }else if(target instanceof EntityLiving){ ((EntityLiving)target).setAttackTarget(null); - target.addPotionEffect(new PotionEffect(WizardryPotions.mind_trick, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0)); + target.addPotionEffect(new PotionEffect(WizardryPotions.mind_trick, + (int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0)); } }else{ - for(int i=0; i<10; i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, target.posX - 0.25 + world.rand.nextDouble()*0.5, - target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + world.rand.nextDouble()*0.5, - target.posZ - 0.25 + world.rand.nextDouble()*0.5, - 0, 0, 0, 0, 0.8f, 0.2f, 1.0f); + for(int i = 0; i < 10; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, + target.posX - 0.25 + world.rand.nextDouble() * 0.5, + target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + + world.rand.nextDouble() * 0.5, + target.posZ - 0.25 + world.rand.nextDouble() * 0.5, 0, 0, 0, 0, 0.8f, 0.2f, 1.0f); } } @@ -68,26 +72,30 @@ public class MindTrick extends Spell { } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) { + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ if(target != null){ if(!world.isRemote){ if(target instanceof EntityPlayer){ - target.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0)); + target.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, + (int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0)); }else if(target instanceof EntityLiving){ ((EntityLiving)target).setAttackTarget(null); - target.addPotionEffect(new PotionEffect(WizardryPotions.mind_trick, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0)); + target.addPotionEffect(new PotionEffect(WizardryPotions.mind_trick, + (int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0)); } }else{ - for(int i=0; i<10; i++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, target.posX - 0.25 + world.rand.nextDouble()*0.5, - target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + world.rand.nextDouble()*0.5, - target.posZ - 0.25 + world.rand.nextDouble()*0.5, - 0, 0, 0, 0, 0.8f, 0.2f, 1.0f); + for(int i = 0; i < 10; i++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, + target.posX - 0.25 + world.rand.nextDouble() * 0.5, + target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + + world.rand.nextDouble() * 0.5, + target.posZ - 0.25 + world.rand.nextDouble() * 0.5, 0, 0, 0, 0, 0.8f, 0.2f, 1.0f); } } @@ -99,7 +107,7 @@ public class MindTrick extends Spell { } @Override - public boolean canBeCastByNPCs() { + public boolean canBeCastByNPCs(){ return true; } @@ -107,7 +115,8 @@ public class MindTrick extends Spell { public static void onLivingAttackEvent(LivingAttackEvent event){ if(event.getSource() != null && event.getSource().getEntity() instanceof EntityLivingBase){ // Cancels the mind trick effect if the creature takes damage - // This has been moved to within an (event.getSource().getEntity() instanceof EntityLivingBase) check so it doesn't + // This has been moved to within an (event.getSource().getEntity() instanceof EntityLivingBase) check so it + // doesn't // crash the game with a ConcurrentModificationException. If you think about it, mind trick only ought to be // cancelled if something attacks the entity since potions, drowning, cacti etc. don't affect the targeting. if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_trick)){ @@ -120,7 +129,9 @@ public class MindTrick extends Spell { public static void onLivingSetAttackTargetEvent(LivingSetAttackTargetEvent event){ // Mind trick // If the target is null already, no need to set it to null, or infinite loops will occur. - if((event.getEntityLiving().isPotionActive(WizardryPotions.mind_trick) || event.getEntityLiving().isPotionActive(WizardryPotions.fear)) && event.getEntityLiving() instanceof EntityLiving && event.getTarget() != null){ + if((event.getEntityLiving().isPotionActive(WizardryPotions.mind_trick) + || event.getEntityLiving().isPotionActive(WizardryPotions.fear)) + && event.getEntityLiving() instanceof EntityLiving && event.getTarget() != null){ ((EntityLiving)event.getEntityLiving()).setAttackTarget(null); } } diff --git a/src/main/java/electroblob/wizardry/spell/None.java b/src/main/java/electroblob/wizardry/spell/None.java index 12566e04..23d16860 100644 --- a/src/main/java/electroblob/wizardry/spell/None.java +++ b/src/main/java/electroblob/wizardry/spell/None.java @@ -9,12 +9,14 @@ import net.minecraft.item.EnumAction; import net.minecraft.util.EnumHand; import net.minecraft.world.World; -/** This class represents a blank spell used to fill empty slots on wands. It is unobtainable in-game, except via +/** + * This class represents a blank spell used to fill empty slots on wands. It is unobtainable in-game, except via * commands, and does nothing when the player attempts to cast it. Its instance can be referenced directly using - * {@link electroblob.wizardry.registry.Spells#none WizardryRegistry.none}*/ + * {@link electroblob.wizardry.registry.Spells#none WizardryRegistry.none} + */ public class None extends Spell { - public None() { + public None(){ super(Tier.BASIC, 0, Element.MAGIC, "none", SpellType.UTILITY, 0, EnumAction.NONE, false); } @@ -24,9 +26,8 @@ public class None extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Oakflesh.java b/src/main/java/electroblob/wizardry/spell/Oakflesh.java index cb2f5fd6..0f35c253 100644 --- a/src/main/java/electroblob/wizardry/spell/Oakflesh.java +++ b/src/main/java/electroblob/wizardry/spell/Oakflesh.java @@ -20,41 +20,47 @@ import net.minecraft.world.World; public class Oakflesh extends Spell { - public Oakflesh() { + public Oakflesh(){ super(Tier.APPRENTICE, 20, Element.HEALING, "oakflesh", SpellType.DEFENCE, 50, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ - caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 1, false, false)); + caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 1, false, false)); if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.6f, 0.5f, 0.4f); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 0.6f, 0.5f, 0.4f); } } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ if(!caster.isPotionActive(MobEffects.RESISTANCE)){ - caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 1, false, false)); + caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 1, false, false)); if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)caster.posY + caster.getEyeHeight() - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.6f, 0.5f, 0.4f); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 0.6f, 0.5f, 0.4f); } } diff --git a/src/main/java/electroblob/wizardry/spell/Petrify.java b/src/main/java/electroblob/wizardry/spell/Petrify.java index 4dd4cf24..c3f788c4 100644 --- a/src/main/java/electroblob/wizardry/spell/Petrify.java +++ b/src/main/java/electroblob/wizardry/spell/Petrify.java @@ -21,49 +21,56 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; public class Petrify extends Spell { - + private static final int baseDuration = 900; - - /** The NBT tag name for storing the petrified flag in the target's tag compound. Defined here in case it changes. */ + + /** + * The NBT tag name for storing the petrified flag in the target's tag compound. Defined here in case it changes. + */ public static final String NBT_KEY = "petrified"; - public Petrify() { + public Petrify(){ super(Tier.ADVANCED, 40, Element.SORCERY, "petrify", SpellType.ATTACK, 100, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ Vec3d look = caster.getLookVec(); - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); + + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLiving && !world.isRemote){ + + EntityLiving target = (EntityLiving)rayTrace.entityHit; - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLiving && !world.isRemote){ - - EntityLiving target = (EntityLiving) rayTrace.entityHit; - if(target.deathTime > 0) return false; BlockPos pos = new BlockPos(target); target.extinguish(); - - //Short mobs such as spiders and pigs + + // Short mobs such as spiders and pigs if((target.height < 1.2 || target.isChild()) && WizardryUtilities.canBlockBeReplaced(world, pos)){ world.setBlockState(pos, WizardryBlocks.petrified_stone.getDefaultState()); if(world.getTileEntity(pos) instanceof TileEntityStatue){ ((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart(target, 1, 1); - ((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade))); + ((TileEntityStatue)world.getTileEntity(pos)) + .setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade))); } target.getEntityData().setBoolean(NBT_KEY, true); target.setDead(); } - //Normal sized mobs like zombies and skeletons - else if(target.height < 2.5 && WizardryUtilities.canBlockBeReplaced(world, pos) && WizardryUtilities.canBlockBeReplaced(world, pos.up())){ + // Normal sized mobs like zombies and skeletons + else if(target.height < 2.5 && WizardryUtilities.canBlockBeReplaced(world, pos) + && WizardryUtilities.canBlockBeReplaced(world, pos.up())){ world.setBlockState(pos, WizardryBlocks.petrified_stone.getDefaultState()); if(world.getTileEntity(pos) instanceof TileEntityStatue){ ((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart(target, 1, 2); - ((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade))); + ((TileEntityStatue)world.getTileEntity(pos)) + .setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade))); } world.setBlockState(pos.up(), WizardryBlocks.petrified_stone.getDefaultState()); @@ -73,12 +80,15 @@ public class Petrify extends Spell { target.getEntityData().setBoolean(NBT_KEY, true); target.setDead(); } - //Tall mobs like endermen - else if(WizardryUtilities.canBlockBeReplaced(world, pos) && WizardryUtilities.canBlockBeReplaced(world, pos.up()) && WizardryUtilities.canBlockBeReplaced(world, pos.up(2))){ + // Tall mobs like endermen + else if(WizardryUtilities.canBlockBeReplaced(world, pos) + && WizardryUtilities.canBlockBeReplaced(world, pos.up()) + && WizardryUtilities.canBlockBeReplaced(world, pos.up(2))){ world.setBlockState(pos, WizardryBlocks.petrified_stone.getDefaultState()); if(world.getTileEntity(pos) instanceof TileEntityStatue){ ((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart(target, 1, 3); - ((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade))); + ((TileEntityStatue)world.getTileEntity(pos)) + .setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade))); } world.setBlockState(pos.up(), WizardryBlocks.petrified_stone.getDefaultState()); @@ -95,20 +105,23 @@ public class Petrify extends Spell { } } if(world.isRemote){ - for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ + for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ // I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet! - double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - //world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.1f, 0.1f); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), 0.2f, 0.2f, 0.2f); + double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + // world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, + 0.1f, 0.1f, 0.1f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 12 + world.rand.nextInt(8), 0.2f, 0.2f, 0.2f); } } caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/PhaseStep.java b/src/main/java/electroblob/wizardry/spell/PhaseStep.java index a99034ce..f2f284b2 100644 --- a/src/main/java/electroblob/wizardry/spell/PhaseStep.java +++ b/src/main/java/electroblob/wizardry/spell/PhaseStep.java @@ -19,62 +19,69 @@ import net.minecraft.world.World; public class PhaseStep extends Spell { - public PhaseStep() { + public PhaseStep(){ super(Tier.ADVANCED, 35, Element.SORCERY, "phase_step", SpellType.UTILITY, 40, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + // Phase step does not gain range from range multiplier, instead it increases the thickness // of the wall you can teleport through. RayTraceResult rayTrace = WizardryUtilities.rayTrace(5, world, caster, false); - + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){ BlockPos pos = new BlockPos(rayTrace.getBlockPos().getX(), (int)caster.posY, rayTrace.getBlockPos().getZ()); // The maximum wall thickness as determined by the range multiplier. The + 0.5f is so that // weird float processing doesn't incorrectly round it down. - int maxThickness = 1 + (int)((modifiers.get(WizardryItems.range_upgrade) - 1)/Constants.RANGE_INCREASE_PER_LEVEL + 0.5f); - + int maxThickness = 1 + + (int)((modifiers.get(WizardryItems.range_upgrade) - 1) / Constants.RANGE_INCREASE_PER_LEVEL + + 0.5f); + if(rayTrace.sideHit.getAxis().isHorizontal()){ // i represents how far the player needs to teleport to get through the wall for(int i = 0; i <= maxThickness; i++){ - - BlockPos pos1 = pos.offset(rayTrace.sideHit.getOpposite(), i); - - // Prevents the player from teleporting through unbreakable blocks, so they cannot cheat in other mods' mazes and dungeons. - if((WizardryUtilities.isBlockUnbreakable(world, pos1) || WizardryUtilities.isBlockUnbreakable(world, pos1.up())) && !Wizardry.settings.teleportThroughUnbreakableBlocks) return false; - if(!world.getBlockState(pos1).getMaterial().blocksMovement() && !world.getBlockState(pos1.up()).getMaterial().blocksMovement()){ - + BlockPos pos1 = pos.offset(rayTrace.sideHit.getOpposite(), i); + + // Prevents the player from teleporting through unbreakable blocks, so they cannot cheat in other + // mods' mazes and dungeons. + if((WizardryUtilities.isBlockUnbreakable(world, pos1) + || WizardryUtilities.isBlockUnbreakable(world, pos1.up())) + && !Wizardry.settings.teleportThroughUnbreakableBlocks) + return false; + + if(!world.getBlockState(pos1).getMaterial().blocksMovement() + && !world.getBlockState(pos1.up()).getMaterial().blocksMovement()){ + if(!world.isRemote){ caster.setPositionAndUpdate(pos1.getX() + 0.5, caster.posY, pos1.getZ() + 0.5); } - + caster.swingArm(hand); return true; } } } } - + // This is here because the conditions are false on the client for whatever reason. (see the Javadoc for cast() // for an explanation) if(world.isRemote){ - for(int i=0;i<10;i++){ + for(int i = 0; i < 10; i++){ double dx1 = caster.posX; - double dy1 = WizardryUtilities.getPlayerEyesPos(caster) - 1.5 + 2*world.rand.nextFloat(); + double dy1 = WizardryUtilities.getPlayerEyesPos(caster) - 1.5 + 2 * world.rand.nextFloat(); double dz1 = caster.posZ; - world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); + world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5, + world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); } WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f); } - + return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/PlagueOfDarkness.java b/src/main/java/electroblob/wizardry/spell/PlagueOfDarkness.java index 252868a7..4559ca53 100644 --- a/src/main/java/electroblob/wizardry/spell/PlagueOfDarkness.java +++ b/src/main/java/electroblob/wizardry/spell/PlagueOfDarkness.java @@ -26,47 +26,53 @@ import net.minecraft.world.World; public class PlagueOfDarkness extends Spell { - public PlagueOfDarkness() { + public PlagueOfDarkness(){ super(Tier.MASTER, 75, Element.NECROMANCY, "plague_of_darkness", SpellType.ATTACK, 200, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - List targets = WizardryUtilities.getEntitiesWithinRadius(5.0d*modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + List targets = WizardryUtilities.getEntitiesWithinRadius( + 5.0d * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world); + for(EntityLivingBase target : targets){ - if(WizardryUtilities.isValidTarget(caster, target) && !MagicDamage.isEntityImmune(DamageType.WITHER, target)){ - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.WITHER), 8.0f * modifiers.get(SpellModifiers.DAMAGE)); - target.addPotionEffect(new PotionEffect(MobEffects.WITHER, (int)(140*modifiers.get(WizardryItems.duration_upgrade)), 2)); + if(WizardryUtilities.isValidTarget(caster, target) + && !MagicDamage.isEntityImmune(DamageType.WITHER, target)){ + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.WITHER), + 8.0f * modifiers.get(SpellModifiers.DAMAGE)); + target.addPotionEffect(new PotionEffect(MobEffects.WITHER, + (int)(140 * modifiers.get(WizardryItems.duration_upgrade)), 2)); } } if(world.isRemote){ double particleX, particleZ; - for(int i=0;i<40*modifiers.get(WizardryItems.blast_upgrade);i++){ - particleX = caster.posX - 1.0d + 2*world.rand.nextDouble(); - particleZ = caster.posZ - 1.0d + 2*world.rand.nextDouble(); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, particleX, WizardryUtilities.getPlayerEyesPos(caster) - 1.5, particleZ, - particleX - caster.posX, 0, particleZ - caster.posZ, 0, 0.1f, 0.0f, 0.0f); - particleX = caster.posX - 1.0d + 2*world.rand.nextDouble(); - particleZ = caster.posZ - 1.0d + 2*world.rand.nextDouble(); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, particleX, WizardryUtilities.getPlayerEyesPos(caster) - 1.5, particleZ, - particleX - caster.posX, 0, particleZ - caster.posZ, 30, 0.1f, 0.0f, 0.05f); - particleX = caster.posX - 1.0d + 2*world.rand.nextDouble(); - particleZ = caster.posZ - 1.0d + 2*world.rand.nextDouble(); - + for(int i = 0; i < 40 * modifiers.get(WizardryItems.blast_upgrade); i++){ + particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble(); + particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble(); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, particleX, + WizardryUtilities.getPlayerEyesPos(caster) - 1.5, particleZ, particleX - caster.posX, 0, + particleZ - caster.posZ, 0, 0.1f, 0.0f, 0.0f); + particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble(); + particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble(); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, particleX, + WizardryUtilities.getPlayerEyesPos(caster) - 1.5, particleZ, particleX - caster.posX, 0, + particleZ - caster.posZ, 30, 0.1f, 0.0f, 0.05f); + particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble(); + particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble(); + IBlockState block = WizardryUtilities.getBlockEntityIsStandingOn(caster); - + if(block != null){ - world.spawnParticle(EnumParticleTypes.BLOCK_DUST, particleX, caster.getEntityBoundingBox().minY, particleZ, - particleX - caster.posX, 0, particleZ - caster.posZ, Block.getStateId(block)); + world.spawnParticle(EnumParticleTypes.BLOCK_DUST, particleX, caster.getEntityBoundingBox().minY, + particleZ, particleX - caster.posX, 0, particleZ - caster.posZ, Block.getStateId(block)); } } } caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_DEATH, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_DEATH, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/PocketFurnace.java b/src/main/java/electroblob/wizardry/spell/PocketFurnace.java index 76f70f58..2df1e2b8 100644 --- a/src/main/java/electroblob/wizardry/spell/PocketFurnace.java +++ b/src/main/java/electroblob/wizardry/spell/PocketFurnace.java @@ -16,57 +16,57 @@ import net.minecraft.world.World; public class PocketFurnace extends Spell { - public PocketFurnace() { + public PocketFurnace(){ super(Tier.APPRENTICE, 30, Element.FIRE, "pocket_furnace", SpellType.UTILITY, 40, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + int usesLeft = 5; - + ItemStack stack, result; - - for(int i=0; i 0; i++){ - + + for(int i = 0; i < caster.inventory.getSizeInventory() && usesLeft > 0; i++){ + stack = caster.inventory.getStackInSlot(i); - - if(stack != null){ + + if(!stack.isEmpty()){ result = FurnaceRecipes.instance().getSmeltingResult(stack); - + if(result != null){ - if(stack.stackSize <= usesLeft){ - ItemStack stack2 = new ItemStack(result.getItem(), stack.stackSize, result.getItemDamage()); + if(stack.getCount() <= usesLeft){ + ItemStack stack2 = new ItemStack(result.getItem(), stack.getCount(), result.getItemDamage()); if(WizardryUtilities.doesPlayerHaveItem(caster, result.getItem())){ caster.inventory.addItemStackToInventory(stack2); caster.inventory.setInventorySlotContents(i, null); }else{ caster.inventory.setInventorySlotContents(i, stack2); } - usesLeft -= stack.stackSize; + usesLeft -= stack.getCount(); }else{ caster.inventory.decrStackSize(i, usesLeft); - caster.inventory.addItemStackToInventory(new ItemStack(result.getItem(), usesLeft, result.getItemDamage())); + caster.inventory.addItemStackToInventory( + new ItemStack(result.getItem(), usesLeft, result.getItemDamage())); usesLeft = 0; } } } } - + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, 1, 0.75f); - + if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); world.spawnParticle(EnumParticleTypes.FLAME, x1, y1, z1, 0, 0.01F, 0); } } - + return usesLeft < 5; } - } diff --git a/src/main/java/electroblob/wizardry/spell/PocketWorkbench.java b/src/main/java/electroblob/wizardry/spell/PocketWorkbench.java index bcb5ce53..9f047445 100644 --- a/src/main/java/electroblob/wizardry/spell/PocketWorkbench.java +++ b/src/main/java/electroblob/wizardry/spell/PocketWorkbench.java @@ -15,7 +15,7 @@ import net.minecraft.world.World; public class PocketWorkbench extends Spell { - public PocketWorkbench() { + public PocketWorkbench(){ super(Tier.APPRENTICE, 30, Element.SORCERY, "pocket_workbench", SpellType.UTILITY, 40, EnumAction.BOW, false); } @@ -25,11 +25,12 @@ public class PocketWorkbench extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ // TODO: Investigate possible item duplication bug with this spell. So far I have been unable to recreate it. if(!world.isRemote){ - caster.openGui(Wizardry.instance, WizardryGuiHandler.PORTABLE_CRAFTING, world, (int)caster.posX, (int)caster.posY, (int)caster.posZ); + caster.openGui(Wizardry.instance, WizardryGuiHandler.PORTABLE_CRAFTING, world, (int)caster.posX, + (int)caster.posY, (int)caster.posZ); } WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1, 1); diff --git a/src/main/java/electroblob/wizardry/spell/Poison.java b/src/main/java/electroblob/wizardry/spell/Poison.java index 9a69bc38..ce37e0d1 100644 --- a/src/main/java/electroblob/wizardry/spell/Poison.java +++ b/src/main/java/electroblob/wizardry/spell/Poison.java @@ -25,70 +25,85 @@ import net.minecraft.world.World; public class Poison extends Spell { - public Poison() { + public Poison(){ super(Tier.APPRENTICE, 10, Element.EARTH, "poison", SpellType.ATTACK, 20, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ Vec3d look = caster.getLookVec(); - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){ - EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit; + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLivingBase){ + EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit; // Has no effect on undead or spiders. if(MagicDamage.isEntityImmune(DamageType.POISON, target)){ - if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted())); + if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(), + this.getNameForTranslationFormatted())); }else{ - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.POISON), 1.0f * modifiers.get(SpellModifiers.DAMAGE)); - target.addPotionEffect(new PotionEffect(MobEffects.POISON, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), 1)); + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.POISON), + 1.0f * modifiers.get(SpellModifiers.DAMAGE)); + target.addPotionEffect(new PotionEffect(MobEffects.POISON, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade)), 1)); } } if(world.isRemote){ - for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ + for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ // I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet! - double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - //world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.3f, 0.7f, 0.0f); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), 0.1f, 0.4f, 0.0f); + double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + // world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, + 0.3f, 0.7f, 0.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 12 + world.rand.nextInt(8), 0.1f, 0.4f, 0.0f); } } caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + // Has no effect on undead or spiders. if(!MagicDamage.isEntityImmune(DamageType.POISON, target) && !world.isRemote){ - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.POISON), 1.0f * modifiers.get(SpellModifiers.DAMAGE)); - target.addPotionEffect(new PotionEffect(MobEffects.POISON, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), 1)); + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.POISON), + 1.0f * modifiers.get(SpellModifiers.DAMAGE)); + target.addPotionEffect(new PotionEffect(MobEffects.POISON, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade)), 1)); } - - if(world.isRemote){ - - double dx = (target.posX - caster.posX)/caster.getDistanceToEntity(target); - double dy = (target.posY - caster.posY)/caster.getDistanceToEntity(target); - double dz = (target.posZ - caster.posZ)/caster.getDistanceToEntity(target); - - for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ - - double x1 = caster.posX + dx*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + dz*i/2 + world.rand.nextFloat()/5 - 0.1f; - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.3f, 0.7f, 0.0f); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), 0.1f, 0.4f, 0.0f); + if(world.isRemote){ + + double dx = (target.posX - caster.posX) / caster.getDistanceToEntity(target); + double dy = (target.posY - caster.posY) / caster.getDistanceToEntity(target); + double dz = (target.posZ - caster.posZ) / caster.getDistanceToEntity(target); + + for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ + + double x1 = caster.posX + dx * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy * i / 2 + world.rand.nextFloat() / 5 + - 0.1f; + double z1 = caster.posZ + dz * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 0, 0.3f, 0.7f, 0.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 12 + world.rand.nextInt(8), 0.1f, 0.4f, 0.0f); } } @@ -96,10 +111,10 @@ public class Poison extends Spell { caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/PoisonBomb.java b/src/main/java/electroblob/wizardry/spell/PoisonBomb.java index 3ee00729..d4e51911 100644 --- a/src/main/java/electroblob/wizardry/spell/PoisonBomb.java +++ b/src/main/java/electroblob/wizardry/spell/PoisonBomb.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class PoisonBomb extends Spell { - public PoisonBomb() { + public PoisonBomb(){ super(Tier.APPRENTICE, 15, Element.EARTH, "poison_bomb", SpellType.ATTACK, 25, EnumAction.NONE, false); } @@ -27,37 +27,41 @@ public class PoisonBomb extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ - EntityPoisonBomb poisonbomb = new EntityPoisonBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade)); - world.spawnEntityInWorld(poisonbomb); + EntityPoisonBomb poisonbomb = new EntityPoisonBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), + modifiers.get(WizardryItems.blast_upgrade)); + world.spawnEntity(poisonbomb); } - + caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, + 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - EntityPoisonBomb poisonbomb = new EntityPoisonBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade)); + EntityPoisonBomb poisonbomb = new EntityPoisonBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), + modifiers.get(WizardryItems.blast_upgrade)); poisonbomb.directTowards(target, 1.5f); - world.spawnEntityInWorld(poisonbomb); + world.spawnEntity(poisonbomb); } - + caster.swingArm(hand); caster.playSound(SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/ReplenishHunger.java b/src/main/java/electroblob/wizardry/spell/ReplenishHunger.java index bf9983a6..e9939d35 100644 --- a/src/main/java/electroblob/wizardry/spell/ReplenishHunger.java +++ b/src/main/java/electroblob/wizardry/spell/ReplenishHunger.java @@ -15,30 +15,32 @@ import net.minecraft.world.World; public class ReplenishHunger extends Spell { - public ReplenishHunger() { + public ReplenishHunger(){ super(Tier.APPRENTICE, 10, Element.HEALING, "replenish_hunger", SpellType.UTILITY, 30, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(caster.getFoodStats().needFood()){ - int foodAmount = (int)(6*modifiers.get(SpellModifiers.DAMAGE)); + int foodAmount = (int)(6 * modifiers.get(SpellModifiers.DAMAGE)); // Fixed issue #6: Changed to addStats, since setFoodLevel is client-side only - caster.getFoodStats().addStats(foodAmount, foodAmount*0.1f); + caster.getFoodStats().addStats(foodAmount, foodAmount * 0.1f); if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); - double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 0.7f, 0.3f); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); + double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + + world.rand.nextFloat()); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 1.0f, 0.7f, 0.3f); } } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return true; } return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/RingOfFire.java b/src/main/java/electroblob/wizardry/spell/RingOfFire.java index e4f1bd84..1d95f216 100644 --- a/src/main/java/electroblob/wizardry/spell/RingOfFire.java +++ b/src/main/java/electroblob/wizardry/spell/RingOfFire.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class RingOfFire extends Spell { - public RingOfFire() { + public RingOfFire(){ super(Tier.ADVANCED, 30, Element.FIRE, "ring_of_fire", SpellType.ATTACK, 100, EnumAction.BOW, false); } @@ -27,12 +27,14 @@ public class RingOfFire extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(caster.onGround){ if(!world.isRemote){ - EntityFireRing firering = new EntityFireRing(world, caster.posX, caster.posY, caster.posZ, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(firering); + EntityFireRing firering = new EntityFireRing(world, caster.posX, caster.posY, caster.posZ, caster, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(firering); } WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1); @@ -42,13 +44,17 @@ public class RingOfFire extends Spell { } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - if(caster.onGround && world.getEntitiesWithinAABB(EntityFireRing.class, caster.getEntityBoundingBox()).isEmpty()){ + if(caster.onGround + && world.getEntitiesWithinAABB(EntityFireRing.class, caster.getEntityBoundingBox()).isEmpty()){ if(!world.isRemote){ - EntityFireRing firering = new EntityFireRing(world, caster.posX, caster.posY, caster.posZ, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(firering); + EntityFireRing firering = new EntityFireRing(world, caster.posX, caster.posY, caster.posZ, caster, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), + modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(firering); } caster.playSound(SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1); @@ -56,10 +62,10 @@ public class RingOfFire extends Spell { } return false; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/ShadowWard.java b/src/main/java/electroblob/wizardry/spell/ShadowWard.java index 01132024..e190198d 100644 --- a/src/main/java/electroblob/wizardry/spell/ShadowWard.java +++ b/src/main/java/electroblob/wizardry/spell/ShadowWard.java @@ -6,10 +6,10 @@ import electroblob.wizardry.constants.Tier; import electroblob.wizardry.item.ItemWand; import electroblob.wizardry.util.IElementalDamage; import electroblob.wizardry.util.MagicDamage; +import electroblob.wizardry.util.MagicDamage.DamageType; import electroblob.wizardry.util.SpellModifiers; import electroblob.wizardry.util.WandHelper; import electroblob.wizardry.util.WizardryUtilities; -import electroblob.wizardry.util.MagicDamage.DamageType; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; @@ -25,18 +25,19 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @Mod.EventBusSubscriber public class ShadowWard extends Spell { - public ShadowWard() { + public ShadowWard(){ super(Tier.ADVANCED, 10, Element.NECROMANCY, "shadow_ward", SpellType.DEFENCE, 0, EnumAction.BLOCK, true); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ if(world.isRemote){ - double dx = -1 + 2*world.rand.nextFloat(); + double dx = -1 + 2 * world.rand.nextFloat(); double dy = -1 + world.rand.nextFloat(); - double dz = -1 + 2*world.rand.nextFloat(); - world.spawnParticle(EnumParticleTypes.PORTAL, caster.posX, WizardryUtilities.getPlayerEyesPos(caster), caster.posZ, dx, dy, dz); + double dz = -1 + 2 * world.rand.nextFloat(); + world.spawnParticle(EnumParticleTypes.PORTAL, caster.posX, WizardryUtilities.getPlayerEyesPos(caster), + caster.posZ, dx, dy, dz); } if(ticksInUse % 50 == 0){ @@ -54,12 +55,17 @@ public class ShadowWard extends Spell { if(wand != null && wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof ShadowWard && !event.getSource().isUnblockable() - && !(event.getSource() instanceof IElementalDamage && ((IElementalDamage)event.getSource()).isRetaliatory())){ + && !(event.getSource() instanceof IElementalDamage + && ((IElementalDamage)event.getSource()).isRetaliatory())){ event.setCanceled(true); // Now we can preserve the original daage source (sort of) as long as we make it retaliatory. - event.getEntityLiving().attackEntityFrom(MagicDamage.causeDirectMagicDamage(event.getSource().getEntity(), DamageType.MAGIC, true), event.getAmount()/2); - ((EntityLivingBase)event.getSource().getEntity()).attackEntityFrom(MagicDamage.causeDirectMagicDamage(event.getEntityLiving(), DamageType.MAGIC, true), event.getAmount()/2); + event.getEntityLiving().attackEntityFrom( + MagicDamage.causeDirectMagicDamage(event.getSource().getEntity(), DamageType.MAGIC, true), + event.getAmount() / 2); + ((EntityLivingBase)event.getSource().getEntity()).attackEntityFrom( + MagicDamage.causeDirectMagicDamage(event.getEntityLiving(), DamageType.MAGIC, true), + event.getAmount() / 2); } } } diff --git a/src/main/java/electroblob/wizardry/spell/Shield.java b/src/main/java/electroblob/wizardry/spell/Shield.java index 518cbe22..0b974fff 100644 --- a/src/main/java/electroblob/wizardry/spell/Shield.java +++ b/src/main/java/electroblob/wizardry/spell/Shield.java @@ -17,19 +17,19 @@ import net.minecraft.world.World; public class Shield extends Spell { - public Shield() { + public Shield(){ super(Tier.APPRENTICE, 5, Element.HEALING, "shield", SpellType.DEFENCE, 0, EnumAction.BLOCK, true); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 10, 0, false, false)); - + if(WizardData.get(caster).shield == null){ WizardData.get(caster).shield = new EntityShield(world, caster); if(!world.isRemote){ - world.spawnEntityInWorld(WizardData.get(caster).shield); + world.spawnEntity(WizardData.get(caster).shield); } } if(ticksInUse == 0){ @@ -38,5 +38,4 @@ public class Shield extends Spell { return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Shockwave.java b/src/main/java/electroblob/wizardry/spell/Shockwave.java index 1f48a728..83845bc6 100644 --- a/src/main/java/electroblob/wizardry/spell/Shockwave.java +++ b/src/main/java/electroblob/wizardry/spell/Shockwave.java @@ -26,32 +26,34 @@ import net.minecraft.world.World; public class Shockwave extends Spell { - public Shockwave() { + public Shockwave(){ super(Tier.MASTER, 65, Element.SORCERY, "shockwave", SpellType.ATTACK, 150, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - List targets = WizardryUtilities.getEntitiesWithinRadius(5.0d*modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world); - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + List targets = WizardryUtilities.getEntitiesWithinRadius( + 5.0d * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world); + for(EntityLivingBase target : targets){ if(WizardryUtilities.isValidTarget(caster, target)){ // Damage increases closer to player up to a maximum of 4 hearts (at 1 block distance). - float damage = Math.min(8.0f/target.getDistanceToEntity(caster), 8.0f); - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.BLAST), damage * modifiers.get(SpellModifiers.DAMAGE)); - + float damage = Math.min(8.0f / target.getDistanceToEntity(caster), 8.0f); + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.BLAST), + damage * modifiers.get(SpellModifiers.DAMAGE)); + if(!world.isRemote){ - + // Entity speed increases closer to the player to a maximum of 3 (at 1 block distance). // This is the entity's speed compared to its distance from the player. Used for a similar triangles // based x, y and z speed calculation. - double velocityFactor = Math.min(5/target.getDistanceSqToEntity(caster), 3.0d); - + double velocityFactor = Math.min(5 / target.getDistanceSqToEntity(caster), 3.0d); + double dx = target.posX - caster.posX; double dy = target.posY + 1 - caster.posY; double dz = target.posZ - caster.posZ; - + target.motionX = velocityFactor * dx; target.motionY = velocityFactor * dy; target.motionZ = velocityFactor * dz; @@ -64,29 +66,32 @@ public class Shockwave extends Spell { } } if(world.isRemote){ - + double particleX, particleZ; - for(int i=0;i<40;i++){ - particleX = caster.posX - 1.0d + 2*world.rand.nextDouble(); - particleZ = caster.posZ - 1.0d + 2*world.rand.nextDouble(); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, particleX, WizardryUtilities.getPlayerEyesPos(caster) - 1.5, particleZ, - particleX - caster.posX, 0, particleZ - caster.posZ, 30, 0.8f, 0.8f, 1.0f); - particleX = caster.posX - 1.0d + 2*world.rand.nextDouble(); - particleZ = caster.posZ - 1.0d + 2*world.rand.nextDouble(); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, particleX, WizardryUtilities.getPlayerEyesPos(caster) - 1.5, particleZ, - particleX - caster.posX, 0, particleZ - caster.posZ, 30, 0.9f, 0.9f, 0.9f); - particleX = caster.posX - 1.0d + 2*world.rand.nextDouble(); - particleZ = caster.posZ - 1.0d + 2*world.rand.nextDouble(); - + for(int i = 0; i < 40; i++){ + particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble(); + particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble(); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, particleX, + WizardryUtilities.getPlayerEyesPos(caster) - 1.5, particleZ, particleX - caster.posX, 0, + particleZ - caster.posZ, 30, 0.8f, 0.8f, 1.0f); + particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble(); + particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble(); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, particleX, + WizardryUtilities.getPlayerEyesPos(caster) - 1.5, particleZ, particleX - caster.posX, 0, + particleZ - caster.posZ, 30, 0.9f, 0.9f, 0.9f); + particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble(); + particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble(); + IBlockState block = WizardryUtilities.getBlockEntityIsStandingOn(caster); - + if(block != null){ - world.spawnParticle(EnumParticleTypes.BLOCK_DUST, particleX, caster.getEntityBoundingBox().minY, particleZ, - particleX - caster.posX, 0, particleZ - caster.posZ, Block.getStateId(block)); + world.spawnParticle(EnumParticleTypes.BLOCK_DUST, particleX, caster.getEntityBoundingBox().minY, + particleZ, particleX - caster.posX, 0, particleZ - caster.posZ, Block.getStateId(block)); } } - - world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, caster.posX, caster.getEntityBoundingBox().minY + 0.1, caster.posZ, 0, 0, 0); + + world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, caster.posX, + caster.getEntityBoundingBox().minY + 0.1, caster.posZ, 0, 0, 0); } caster.swingArm(hand); @@ -95,5 +100,4 @@ public class Shockwave extends Spell { return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/SilverfishSwarm.java b/src/main/java/electroblob/wizardry/spell/SilverfishSwarm.java index bd7ae7bc..d626418e 100644 --- a/src/main/java/electroblob/wizardry/spell/SilverfishSwarm.java +++ b/src/main/java/electroblob/wizardry/spell/SilverfishSwarm.java @@ -16,7 +16,7 @@ import net.minecraft.world.World; public class SilverfishSwarm extends Spell { - public SilverfishSwarm() { + public SilverfishSwarm(){ super(Tier.MASTER, 80, Element.EARTH, "silverfish_swarm", SpellType.MINION, 300, EnumAction.BOW, false); } @@ -26,20 +26,22 @@ public class SilverfishSwarm extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ if(!world.isRemote){ - for(int i=0;i<20;i++){ + for(int i = 0; i < 20; i++){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 3, 6); // The spell instantly fails if no space was found (see javadoc for the above method). if(pos == null) return false; - - EntitySilverfishMinion silverfish = new EntitySilverfishMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(silverfish); + + EntitySilverfishMinion silverfish = new EntitySilverfishMinion(world, pos.getX() + 0.5, pos.getY(), + pos.getZ() + 0.5, caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(silverfish); } } - - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.BLOCK_FIRE_EXTINGUISH, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.BLOCK_FIRE_EXTINGUISH, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); // Can't possibly get this far if nothing was spawned. return true; } diff --git a/src/main/java/electroblob/wizardry/spell/SixthSense.java b/src/main/java/electroblob/wizardry/spell/SixthSense.java index f6505a75..b33ac6c9 100644 --- a/src/main/java/electroblob/wizardry/spell/SixthSense.java +++ b/src/main/java/electroblob/wizardry/spell/SixthSense.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class SixthSense extends Spell { - public SixthSense() { + public SixthSense(){ super(Tier.APPRENTICE, 20, Element.EARTH, "sixth_sense", SpellType.UTILITY, 100, EnumAction.BOW, false); } @@ -27,15 +27,17 @@ public class SixthSense extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + // Cannot be cast when it has already been cast if(!world.isRemote){ - caster.addPotionEffect(new PotionEffect(WizardryPotions.sixth_sense, (int)(400*modifiers.get(WizardryItems.duration_upgrade)), (int)((modifiers.get(WizardryItems.range_upgrade)-1f)/Constants.RANGE_INCREASE_PER_LEVEL))); + caster.addPotionEffect(new PotionEffect(WizardryPotions.sixth_sense, + (int)(400 * modifiers.get(WizardryItems.duration_upgrade)), + (int)((modifiers.get(WizardryItems.range_upgrade) - 1f) / Constants.RANGE_INCREASE_PER_LEVEL))); } - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SHOOT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SHOOT, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Slime.java b/src/main/java/electroblob/wizardry/spell/Slime.java index 6d9d5346..edad24c4 100644 --- a/src/main/java/electroblob/wizardry/spell/Slime.java +++ b/src/main/java/electroblob/wizardry/spell/Slime.java @@ -27,45 +27,50 @@ import net.minecraft.world.World; public class Slime extends Spell { - public Slime() { + public Slime(){ super(Tier.ADVANCED, 20, Element.EARTH, "slime", SpellType.ATTACK, 50, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + Vec3d look = caster.getLookVec(); - - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 8*modifiers.get(WizardryItems.range_upgrade)); - + + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 8 * modifiers.get(WizardryItems.range_upgrade)); + if(rayTrace != null && rayTrace.entityHit != null && rayTrace.entityHit instanceof EntityLivingBase){ - + EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit; - + if(target instanceof EntitySlime){ - if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted())); + if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(), + this.getNameForTranslationFormatted())); }else if(!(target instanceof EntityMagicSlime)){ - + if(target instanceof EntitySkeleton) caster.addStat(WizardryAchievements.slime_skeleton); - + if(!world.isRemote){ - EntityMagicSlime slime = new EntityMagicSlime(world, caster, target, (int)(200*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(slime); + EntityMagicSlime slime = new EntityMagicSlime(world, caster, target, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(slime); } } } if(world.isRemote){ - for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ - double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; + for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ + double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; world.spawnParticle(EnumParticleTypes.SLIME, x1, y1, z1, 0.0d, 0.0d, 0.0d); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.2f, 0.8f, 0.1f); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, + 0.2f, 0.8f, 0.1f); } } - + caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SLIME_ATTACK, 1.0F, 0.5F); WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, 1.0F); @@ -73,42 +78,46 @@ public class Slime extends Spell { } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null && !(target instanceof EntitySlime) && !(target instanceof EntityMagicSlime)){ - + if(!world.isRemote){ - EntityMagicSlime slime = new EntityMagicSlime(world, caster, target, (int)(200*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(slime); + EntityMagicSlime slime = new EntityMagicSlime(world, caster, target, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(slime); } - + if(world.isRemote){ - - double dx = (target.posX - caster.posX)/caster.getDistanceToEntity(target); - double dy = (target.posY - caster.posY)/caster.getDistanceToEntity(target); - double dz = (target.posZ - caster.posZ)/caster.getDistanceToEntity(target); - - for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ - - double x1 = caster.posX + dx*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + dz*i/2 + world.rand.nextFloat()/5 - 0.1f; + + double dx = (target.posX - caster.posX) / caster.getDistanceToEntity(target); + double dy = (target.posY - caster.posY) / caster.getDistanceToEntity(target); + double dz = (target.posZ - caster.posZ) / caster.getDistanceToEntity(target); + + for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ + + double x1 = caster.posX + dx * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy * i / 2 + world.rand.nextFloat() / 5 + - 0.1f; + double z1 = caster.posZ + dz * i / 2 + world.rand.nextFloat() / 5 - 0.1f; world.spawnParticle(EnumParticleTypes.SLIME, x1, y1, z1, 0.0d, 0.0d, 0.0d); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.2f, 0.8f, 0.1f); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 0, 0.2f, 0.8f, 0.1f); } } - + caster.swingArm(hand); caster.playSound(SoundEvents.ENTITY_SLIME_ATTACK, 1.0F, 0.5F); caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, 1.0F); return true; - + } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/SmokeBomb.java b/src/main/java/electroblob/wizardry/spell/SmokeBomb.java index 6a71a532..c10a4b5b 100644 --- a/src/main/java/electroblob/wizardry/spell/SmokeBomb.java +++ b/src/main/java/electroblob/wizardry/spell/SmokeBomb.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class SmokeBomb extends Spell { - public SmokeBomb() { + public SmokeBomb(){ super(Tier.BASIC, 10, Element.FIRE, "smoke_bomb", SpellType.ATTACK, 20, EnumAction.NONE, false); } @@ -27,37 +27,41 @@ public class SmokeBomb extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ - EntitySmokeBomb smokebomb = new EntitySmokeBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade)); - world.spawnEntityInWorld(smokebomb); + EntitySmokeBomb smokebomb = new EntitySmokeBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), + modifiers.get(WizardryItems.blast_upgrade)); + world.spawnEntity(smokebomb); } - + caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, + 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - EntitySmokeBomb smokebomb = new EntitySmokeBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade)); + EntitySmokeBomb smokebomb = new EntitySmokeBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), + modifiers.get(WizardryItems.blast_upgrade)); smokebomb.directTowards(target, 1.5f); - world.spawnEntityInWorld(smokebomb); + world.spawnEntity(smokebomb); } - + caster.swingArm(hand); caster.playSound(SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/Snare.java b/src/main/java/electroblob/wizardry/spell/Snare.java index 6d1b4815..d8a5f262 100644 --- a/src/main/java/electroblob/wizardry/spell/Snare.java +++ b/src/main/java/electroblob/wizardry/spell/Snare.java @@ -21,21 +21,23 @@ import net.minecraft.world.World; public class Snare extends Spell { - public Snare() { + public Snare(){ super(Tier.BASIC, 10, Element.EARTH, "snare", SpellType.ATTACK, 10, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ - RayTraceResult rayTrace = WizardryUtilities.rayTrace(10*modifiers.get(WizardryItems.range_upgrade), world, caster, true); + RayTraceResult rayTrace = WizardryUtilities.rayTrace(10 * modifiers.get(WizardryItems.range_upgrade), world, + caster, true); // Gets block the player is looking at and places snare if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){ BlockPos pos = rayTrace.getBlockPos(); - if(rayTrace.sideHit == EnumFacing.UP && world.isSideSolid(pos, EnumFacing.UP) && WizardryUtilities.canBlockBeReplaced(world, pos.up())){ + if(rayTrace.sideHit == EnumFacing.UP && world.isSideSolid(pos, EnumFacing.UP) + && WizardryUtilities.canBlockBeReplaced(world, pos.up())){ if(!world.isRemote){ world.setBlockState(pos.up(), WizardryBlocks.snare.getDefaultState()); @@ -43,24 +45,34 @@ public class Snare extends Spell { } double dx = pos.getX() + 0.5 - caster.posX; - double dy = pos.getY() + 1.5 - (caster.posY + caster.height/2); + double dy = pos.getY() + 1.5 - (caster.posY + caster.height / 2); double dz = pos.getZ() + 0.5 - caster.posZ; if(world.isRemote){ - for(int i=1;i<5;i++){ - float brightness = world.rand.nextFloat()/4; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0.0d, 0.0d, 0.0d, 20 + world.rand.nextInt(8), brightness, brightness + 0.1f, 0.0f); - Wizardry.proxy.spawnParticle(WizardryParticleType.LEAF, world, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, -0.01, 0, 40 + world.rand.nextInt(10)); + for(int i = 1; i < 5; i++){ + float brightness = world.rand.nextFloat() / 4; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0.0d, 0.0d, 0.0d, + 20 + world.rand.nextInt(8), brightness, brightness + 0.1f, 0.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.LEAF, world, + caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5, + WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + + world.rand.nextFloat() / 5, + caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, -0.01, 0, + 40 + world.rand.nextInt(10)); } } - + caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.BLOCK_GRASS_PLACE, 1.0F, world.rand.nextFloat() * 0.4F + 1.2F); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.BLOCK_GRASS_PLACE, 1.0F, + world.rand.nextFloat() * 0.4F + 1.2F); return true; } } return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Snowball.java b/src/main/java/electroblob/wizardry/spell/Snowball.java index c5aed5ab..3fc36fb7 100644 --- a/src/main/java/electroblob/wizardry/spell/Snowball.java +++ b/src/main/java/electroblob/wizardry/spell/Snowball.java @@ -14,7 +14,7 @@ import net.minecraft.world.World; public class Snowball extends Spell { - public Snowball() { + public Snowball(){ super(Tier.BASIC, 1, Element.ICE, "snowball", SpellType.ATTACK, 1, EnumAction.NONE, false); } @@ -24,18 +24,18 @@ public class Snowball extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ EntitySnowball snowball = new EntitySnowball(world, caster); - snowball.setHeadingFromThrower(caster, caster.rotationPitch, caster.rotationYaw, 0.0f, 1.5f, 1.0f); - world.spawnEntityInWorld(snowball); + snowball.setHeadingFromThrower(caster, caster.rotationPitch, caster.rotationYaw, 0.0f, 1.5f, 1.0f); + world.spawnEntity(snowball); } - - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); + + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, + 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); caster.swingArm(hand); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/SparkBomb.java b/src/main/java/electroblob/wizardry/spell/SparkBomb.java index e0c55295..b8adbdb5 100644 --- a/src/main/java/electroblob/wizardry/spell/SparkBomb.java +++ b/src/main/java/electroblob/wizardry/spell/SparkBomb.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class SparkBomb extends Spell { - public SparkBomb() { + public SparkBomb(){ super(Tier.APPRENTICE, 15, Element.LIGHTNING, "spark_bomb", SpellType.ATTACK, 25, EnumAction.NONE, false); } @@ -27,37 +27,41 @@ public class SparkBomb extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ - EntitySparkBomb sparkBomb = new EntitySparkBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade)); - world.spawnEntityInWorld(sparkBomb); + EntitySparkBomb sparkBomb = new EntitySparkBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), + modifiers.get(WizardryItems.blast_upgrade)); + world.spawnEntity(sparkBomb); } - + caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, + 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - EntitySparkBomb sparkBomb = new EntitySparkBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade)); + EntitySparkBomb sparkBomb = new EntitySparkBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), + modifiers.get(WizardryItems.blast_upgrade)); sparkBomb.directTowards(target, 1.5f); - world.spawnEntityInWorld(sparkBomb); + world.spawnEntity(sparkBomb); } - + caster.swingArm(hand); caster.playSound(SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/SpectralPathway.java b/src/main/java/electroblob/wizardry/spell/SpectralPathway.java index f544ffb3..db2b3c59 100644 --- a/src/main/java/electroblob/wizardry/spell/SpectralPathway.java +++ b/src/main/java/electroblob/wizardry/spell/SpectralPathway.java @@ -20,7 +20,7 @@ import net.minecraft.world.World; public class SpectralPathway extends Spell { - public SpectralPathway() { + public SpectralPathway(){ super(Tier.ADVANCED, 40, Element.SORCERY, "spectral_pathway", SpellType.UTILITY, 300, EnumAction.BOW, false); } @@ -30,39 +30,42 @@ public class SpectralPathway extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + // Won't work if caster is airborne or if they are already on a bridge (prevents infinite bridges) if(WizardryUtilities.getBlockEntityIsStandingOn(caster).getBlock() == Blocks.AIR || WizardryUtilities.getBlockEntityIsStandingOn(caster).getBlock() == WizardryBlocks.spectral_block){ return false; } - + EnumFacing direction = caster.getHorizontalFacing(); - + boolean flag = false; if(!world.isRemote){ - + int baseLength = 15; - + // Gets the coordinates of the nearest block intersection to the player's feet. // Remember that a block always takes the coordinates of its northwestern corner. - BlockPos origin = new BlockPos(Math.round(caster.posX), (int)caster.getEntityBoundingBox().minY-1, Math.round(caster.posZ)); - + BlockPos origin = new BlockPos(Math.round(caster.posX), (int)caster.getEntityBoundingBox().minY - 1, + Math.round(caster.posZ)); + int startPoint = direction.getAxisDirection() == AxisDirection.POSITIVE ? -1 : 0; - - for(int i=0; i<(int)(baseLength*modifiers.get(WizardryItems.range_upgrade)); i++){ + + for(int i = 0; i < (int)(baseLength * modifiers.get(WizardryItems.range_upgrade)); i++){ // If either a block gets placed or one has already been placed, flag is set to true. - flag = placePathwayBlockIfPossible(world, origin.offset(direction, startPoint + i), modifiers.get(WizardryItems.duration_upgrade)) || flag; + flag = placePathwayBlockIfPossible(world, origin.offset(direction, startPoint + i), + modifiers.get(WizardryItems.duration_upgrade)) || flag; flag = placePathwayBlockIfPossible(world, origin.offset(direction, startPoint + i) // Moves the BlockPos minus one block perpendicular to direction. - .offset(EnumFacing.getFacingFromAxis(AxisDirection.NEGATIVE, direction.rotateY().getAxis())), modifiers.get(WizardryItems.duration_upgrade)) || flag; + .offset(EnumFacing.getFacingFromAxis(AxisDirection.NEGATIVE, direction.rotateY().getAxis())), + modifiers.get(WizardryItems.duration_upgrade)) || flag; } } // TODO: There may be some client/server discrepancies here. WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION_LARGE, 1.0f, 1.0f); - + return flag; } @@ -70,11 +73,11 @@ public class SpectralPathway extends Spell { if(WizardryUtilities.canBlockBeReplacedB(world, pos)){ world.setBlockState(pos, WizardryBlocks.spectral_block.getDefaultState()); if(world.getTileEntity(pos) instanceof TileEntityTimer){ - ((TileEntityTimer)world.getTileEntity(pos)).setLifetime((int)(1200*durationMultiplier)); + ((TileEntityTimer)world.getTileEntity(pos)).setLifetime((int)(1200 * durationMultiplier)); } return true; } return false; } - + } diff --git a/src/main/java/electroblob/wizardry/spell/Spell.java b/src/main/java/electroblob/wizardry/spell/Spell.java index 594f1ef2..09fcea30 100644 --- a/src/main/java/electroblob/wizardry/spell/Spell.java +++ b/src/main/java/electroblob/wizardry/spell/Spell.java @@ -29,49 +29,53 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; /** - * Generic spell class which is the superclass to all spells in wizardry. When extending this class, you must do - * the following: + * Generic spell class which is the superclass to all spells in wizardry. When extending this class, you must do the + * following: + *

    + * - Have a constructor which passes all necessary constants into the super constructor. I define the constants here so + * that the constructor for an individual spell has no parameters, but you may prefer to pass in the parameters when the + * spell is registered, so all the mana costs etc. are in one place like a sort of sandbox. *

    - * - Have a constructor which passes all necessary constants into the super constructor. I define the constants here - * so that the constructor for an individual spell has no parameters, but you may prefer to pass in the parameters when - * the spell is registered, so all the mana costs etc. are in one place like a sort of sandbox. - *

    * - Implement the {@link Spell#cast(World, EntityPlayer, EnumHand, int, SpellModifiers)} method, in which you should * execute the code that makes the spell work, and return true or false depending on whether the spell succeeded and * therefore whether mana should be used up. *

    * - Register the spell using {@link RegistryEvent.Register}, with {@link Spell} as the type parameter. Each spell - * should have a single instance, like blocks and items. - * As of Wizardry 2.1, spells use the Forge registry system. Related methods such as {@link Spell#id()} and - * {@link Spell#get(int)} have been re-routed to use this system, leaving minimal external changes. Note also that - * the constructor automatically sets the registry name for you, though you may change it afterwards if necessary. + * should have a single instance, like blocks and items. As of Wizardry 2.1, spells use the Forge registry system. + * Related methods such as {@link Spell#id()} and {@link Spell#get(int)} have been re-routed to use this system, leaving + * minimal external changes. Note also that the constructor automatically sets the registry name for you, though you may + * change it afterwards if necessary. *

    - * Also note that you can override some other methods from this class. For example, to add a - * specific kind of formatting to a spell name or description, you can override {@link Spell#getDisplayName()}, + * Also note that you can override some other methods from this class. For example, to add a specific kind of formatting + * to a spell name or description, you can override {@link Spell#getDisplayName()}, * {@link Spell#getDisplayNameWithFormatting()} or {@link Spell#getDescription()} and append the formatting code (though * you will have to call super() to get the name itself, since the unlocalised name is private). See * {@link SummonShadowWraith#getDescription()} for an example. *


    - * This class is also home to some useful static methods for interacting with the spell registry:

    - * {@link Spell#get(int)} gets a spell instance from its integer id, which corresponds to the metadata of its spell book.
    + * This class is also home to some useful static methods for interacting with the spell registry: + *

    + * {@link Spell#get(int)} gets a spell instance from its integer id, which corresponds to the metadata of its spell + * book.
    * {@link Spell#get(String)} gets a spell instance from its unlocalised name.
    * {@link Spell#getSpells(Predicate)} returns a list of spell instances the match the given {@link Predicate}.
    * {@link Spell#getTotalSpellCount()} returns the total number of registered spells. *


    * Spell implements the {@link Comparable} interface, and as such, any collection of spells can be sorted. Spells are * sorted by increasing tier (see {@link Tier}), from novice to master. Within each tier, spells are sorted by element, - * the order of which is as defined in {@link Element} (i.e. magic, fire, ice, lightning, necromancy, earth, sorcery, healing). + * the order of which is as defined in {@link Element} (i.e. magic, fire, ice, lightning, necromancy, earth, sorcery, + * healing). *
    + * * @since Wizardry 1.0 * @see electroblob.wizardry.item.ItemSpellBook ItemSpellBook * @see electroblob.wizardry.item.ItemScroll ItemScroll * @see Spells */ public abstract class Spell extends IForgeRegistryEntry.Impl implements Comparable { - + /** Forge registry-based replacement for the internal spells list. */ public static IForgeRegistry registry; - + /** The tier this spell belongs to. */ public final Tier tier; /** Mana cost of the spell. If it is a continuous spell the cost is per second. */ @@ -88,52 +92,59 @@ public abstract class Spell extends IForgeRegistryEntry.Impl implements C public final EnumAction action; /** Whether or not the spell is continuous (keeps going as long as the mouse button is held) */ public final boolean isContinuous; - + /** ResourceLocation of the spell icon. */ private final ResourceLocation icon; /** Mod ID of the mod that added this spell; defaults to {@link Wizardry#MODID} if not specified. */ private final String modID; - - /** False if the spell has been disabled in the config file, true otherwise. This is now encapsulated to stop it - * being fiddled with. */ - private boolean isEnabled = true; - + /** - * This constructor should be called from any subclasses, either feeding in the constants directly or through - * their own constructor from wherever the spell is registered. This is the constructor for wizardry's own spells; - * spells added by other mods should use {@link Spell#Spell(Tier, int, Element, String, SpellType, int, EnumAction, boolean, String)}. + * False if the spell has been disabled in the config file, true otherwise. This is now encapsulated to stop it + * being fiddled with. + */ + private boolean isEnabled = true; + + /** + * This constructor should be called from any subclasses, either feeding in the constants directly or through their + * own constructor from wherever the spell is registered. This is the constructor for wizardry's own spells; spells + * added by other mods should use + * {@link Spell#Spell(Tier, int, Element, String, SpellType, int, EnumAction, boolean, String)}. + * * @param tier The tier this spell belongs to. - * @param cost The amount of mana used to cast the spell. If this is a continuous spell, it represents mana cost - * per second and should be a multiple of 5. + * @param cost The amount of mana used to cast the spell. If this is a continuous spell, it represents mana cost per + * second and should be a multiple of 5. * @param element The element this spell belongs to. * @param name The registry name of the spell. This will also be the name of the icon file. The spell's - * unlocalised name will be a resource location with the format [modid]:[name]. + * unlocalised name will be a resource location with the format [modid]:[name]. * @param cooldown The cooldown time for this spell in ticks. * @param action The vanilla usage action to be displayed when casting this spell. * @param isContinuous Whether this spell is continuous, meaning you cast it for a length of time by holding the - * right mouse button. + * right mouse button. */ - public Spell(Tier tier, int cost, Element element, String name, SpellType type, int cooldown, EnumAction action, boolean isContinuous){ + public Spell(Tier tier, int cost, Element element, String name, SpellType type, int cooldown, EnumAction action, + boolean isContinuous){ this(tier, cost, element, name, type, cooldown, action, isContinuous, Wizardry.MODID); } - + /** - * This constructor should be called from any subclasses, either feeding in the constants directly or through - * their own constructor from wherever the spell is registered. + * This constructor should be called from any subclasses, either feeding in the constants directly or through their + * own constructor from wherever the spell is registered. + * * @param tier The tier this spell belongs to. - * @param cost The amount of mana used to cast the spell. If this is a continuous spell, it represents mana cost - * per second and should be a multiple of 5. + * @param cost The amount of mana used to cast the spell. If this is a continuous spell, it represents mana cost per + * second and should be a multiple of 5. * @param element The element this spell belongs to. * @param name The registry name of the spell, excluding the mod id. This will also be the name of the icon - * file. The spell's unlocalised name will be a resource location with the format [modid]:[name]. + * file. The spell's unlocalised name will be a resource location with the format [modid]:[name]. * @param cooldown The cooldown time for this spell in ticks. * @param action The vanilla usage action to be displayed when casting this spell (see {@link}EnumAction) * @param isContinuous Whether this spell is continuous, meaning you cast it for a length of time by holding the - * right mouse button. - * @param modID The mod id of the mod that added this spell. This allows wizardry to use the correct file - * path for the spell icon, and also more generally to distinguish between original and addon spells. + * right mouse button. + * @param modID The mod id of the mod that added this spell. This allows wizardry to use the correct file path for + * the spell icon, and also more generally to distinguish between original and addon spells. */ - public Spell(Tier tier, int cost, Element element, String name, SpellType type, int cooldown, EnumAction action, boolean isContinuous, String modID){ + public Spell(Tier tier, int cost, Element element, String name, SpellType type, int cooldown, EnumAction action, + boolean isContinuous, String modID){ this.tier = tier; this.cost = cost; this.element = element; @@ -146,154 +157,189 @@ public abstract class Spell extends IForgeRegistryEntry.Impl implements C this.unlocalisedName = this.getRegistryName().toString(); this.icon = new ResourceLocation(this.modID, "textures/spells/" + name + ".png"); } - + /** * Casts the spell. Each subclass must override this method and within it execute the code to make the spell work. - * Returns a boolean so that the main onItemRightClick or onUsingItemTick method can check if the spell - * was actually cast or whether a spell specific condition caused it not to be (for example, heal won't work if the player is on + * Returns a boolean so that the main onItemRightClick or onUsingItemTick method can check if the spell was actually + * cast or whether a spell specific condition caused it not to be (for example, heal won't work if the player is on * full health), preventing unfair drain of mana. *

    - * Each spell must return true when it works or the spell will not use up mana. Note that (!world.isRemote) does not count - * as a condition; return true should be outside it - in other words, return a value on both the client and the server. + * Each spell must return true when it works or the spell will not use up mana. Note that (!world.isRemote) does not + * count as a condition; return true should be outside it - in other words, return a value on both the client and + * the server. *

    - * It's worth noting that on the client side, this method only gets called if the server side - * cast() method succeeded, so you can put any particle spawning code outside of any success conditions if there - * are discrepancies between client and server. - * @param world A reference to the world object. Again this is for convenience, you can also use caster.worldObj. + * It's worth noting that on the client side, this method only gets called if the server side cast() method + * succeeded, so you can put any particle spawning code outside of any success conditions if there are discrepancies + * between client and server. + * + * @param world A reference to the world object. Again this is for convenience, you can also use caster.world. * @param caster The EntityPlayer that cast the spell. - * @param hand The hand that is holding the item used to cast the spell. If no item was used, this will be the main hand. - * @param ticksInUse The number of ticks the spell has already been cast for. For all non-continuous spells, this is 0 and - * is not used. For continuous spells, it is passed in as the maximum use duration of the item minus the count parameter in - * onUsingItemTick and therefore it increases by 1 each tick. - * @param modifiers A {@link SpellModifiers} object containing the modifiers that have been applied to the spell. See - * the javadoc for that class for more information. If no modifiers are required, pass in {@code new SpellModifiers()}. + * @param hand The hand that is holding the item used to cast the spell. If no item was used, this will be the main + * hand. + * @param ticksInUse The number of ticks the spell has already been cast for. For all non-continuous spells, this is + * 0 and is not used. For continuous spells, it is passed in as the maximum use duration of the item minus + * the count parameter in onUsingItemTick and therefore it increases by 1 each tick. + * @param modifiers A {@link SpellModifiers} object containing the modifiers that have been applied to the spell. + * See the javadoc for that class for more information. If no modifiers are required, pass in + * {@code new SpellModifiers()}. * @return True if the spell succeeded and mana should be used up, false if not. */ - public abstract boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers); - - /** Casts the spell, but with an EntityLiving as the caster. Each subclass can optionally override this method and - * within it execute the code to make the spell work. Returns a boolean to allow whatever calls this method to check if the spell - * was actually cast or whether a spell specific condition caused it not to be (for example, heal won't work if the caster is on - * full health). + public abstract boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, + SpellModifiers modifiers); + + /** + * Casts the spell, but with an EntityLiving as the caster. Each subclass can optionally override this method and + * within it execute the code to make the spell work. Returns a boolean to allow whatever calls this method to check + * if the spell was actually cast or whether a spell specific condition caused it not to be (for example, heal won't + * work if the caster is on full health). *

    - * This method is intended for use by NPCs (see {@link EntityWizard}) so that they can cast spells. Override it if you want - * a spell to be cast by wizards. Note that you must also override {@link Spell#canBeCastByNPCs()} to return true to allow wizards - * to select the spell. For some spells, this method may well be exactly the same as the regular cast method; for - * others it won't be - for example, projectile-based spells are normally done using the player's look vector, but - * NPCs need to use a target-based method instead. + * This method is intended for use by NPCs (see {@link EntityWizard}) so that they can cast spells. Override it if + * you want a spell to be cast by wizards. Note that you must also override {@link Spell#canBeCastByNPCs()} to + * return true to allow wizards to select the spell. For some spells, this method may well be exactly the same as + * the regular cast method; for others it won't be - for example, projectile-based spells are normally done using + * the player's look vector, but NPCs need to use a target-based method instead. *

    - * Each spell must return true when it works. Note that (!world.isRemote) does not count as a condition; return true should be outside - * it - in other words, return a value on both the client and the server. + * Each spell must return true when it works. Note that (!world.isRemote) does not count as a condition; return true + * should be outside it - in other words, return a value on both the client and the server. *

    - * It's worth noting that on the client side, this method only gets called if the server side - * cast() method succeeded, so you can put any particle spawning code outside of any success conditions if there - * are discrepancies between client and server. - * @param world A reference to the world object. This is for convenience, you can also use caster.worldObj. + * It's worth noting that on the client side, this method only gets called if the server side cast() method + * succeeded, so you can put any particle spawning code outside of any success conditions if there are discrepancies + * between client and server. + * + * @param world A reference to the world object. This is for convenience, you can also use caster.world. * @param caster The EntityLiving that cast the spell. - * @param hand The hand that is holding the item used to cast the spell. This will almost certainly be the main hand. - * @param ticksInUse The number of ticks the spell has already been cast for. For all non-continuous spells, this is 0 and - * is not used. + * @param hand The hand that is holding the item used to cast the spell. This will almost certainly be the main + * hand. + * @param ticksInUse The number of ticks the spell has already been cast for. For all non-continuous spells, this is + * 0 and is not used. * @param target The EntityLivingBase that is targeted by the spell. May be null in some cases. - * @param modifiers A {@link SpellModifiers} object containing the modifiers that have been applied to the spell. See - * the javadoc for that class for more information. If no modifiers are required, pass in {@code new SpellModifiers()}. + * @param modifiers A {@link SpellModifiers} object containing the modifiers that have been applied to the spell. + * See the javadoc for that class for more information. If no modifiers are required, pass in + * {@code new SpellModifiers()}. * @return True if the spell succeeded, false if not. Returns false by default. */ - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ return false; } - - /** Whether NPCs such as wizards can cast this spell. If you have overridden {@link Spell#cast(World, EntityLiving, EnumHand, int, EntityLivingBase, SpellModifiers)}, - * you should override this to return true. */ + + /** + * Whether NPCs such as wizards can cast this spell. If you have overridden + * {@link Spell#cast(World, EntityLiving, EnumHand, int, EntityLivingBase, SpellModifiers)}, you should override + * this to return true. + */ public boolean canBeCastByNPCs(){ return false; } - - /** Whether this spell requires a packet to be sent when it is cast. Returns true by default, but can be overridden + + /** + * Whether this spell requires a packet to be sent when it is cast. Returns true by default, but can be overridden * to return false if the spell's cast() method does not use any code that must be executed client-side (i.e. * particle spawning). Does nothing for continuous spells, because they never need to send packets. *

    * If in doubt, leave this method as is; it is purely an optimisation. - * @return false if the spell code should only be run on the server and the client of the player casting it
    - * true if the spell code should be run on the server and all clients in the dimension */ - // Edit: Turns out that swingItem() actually sends packets to all nearby clients, but not the client doing the swinging. + * + * @return false if the spell code should only be run on the server and the client of the player casting + * it
    + * true if the spell code should be run on the server and all clients in the dimension + */ + // Edit: Turns out that swingItem() actually sends packets to all nearby clients, but not the client doing the + // swinging. // Also, now I think about it, this method isn't going to make the slightest bit of difference to the item usage // actions since setItemInUse() is called in ItemWand, not the spell class - so the only thing that matters here is // the particles. public boolean doesSpellRequirePacket(){ return true; } - - /** Returns this spell's id number, which now corresponds to its position in the spell registry. - * Returns -1 if the spell has not been registered. */ + + /** + * Returns this spell's id number, which now corresponds to its position in the spell registry. Returns -1 if the + * spell has not been registered. + */ // This is final so nothing can override it, because that would cause all kinds of problems! public final int id(){ return registry.getValues().indexOf(this); } - - /** Returns the mod ID for this spell, which should be the ID of the mod that added it. The mod ID is - * used to tell wizardry which filepath to use for the spell's icon. As of Wizardry 1.2, the field itself is - * private, but this getter is provided for external use (though it is never called in the main Wizardry mod). */ + + /** + * Returns the mod ID for this spell, which should be the ID of the mod that added it. The mod ID is used to tell + * wizardry which filepath to use for the spell's icon. As of Wizardry 1.2, the field itself is private, but this + * getter is provided for external use (though it is never called in the main Wizardry mod). + */ public final String getModID(){ return modID; } - + /** Returns the ResourceLocation for this spell's icon. */ public final ResourceLocation getIcon(){ return icon; } - /** Returns the unlocalised name of the spell, without any prefixes or suffixes, e.g. "flame_ray". This should - * only be used for translation purposes. */ + /** + * Returns the unlocalised name of the spell, without any prefixes or suffixes, e.g. "flame_ray". This should + * only be used for translation purposes. + */ public final String getUnlocalisedName(){ return unlocalisedName; } - + /* The general idea with translation is to use net.minecraft.client.resources.I18n directly on the client side (and * just prepend formatting codes where necessary), and to use TextComponentTranslation on the server (setting the * style as necessary). TextComponentTranslation effectively stores what needs to be translated, without actually * translating it. If, for whatever reason, you need to supply an ITextComponent but don't want it translated * (perhaps a name?), you can use TextComponentString, which will simply keep the raw string it is given. */ - /** Returns the translated display name of the spell, without formatting (i.e. not coloured). Client-side only! - * On the server side, use {@link TextComponentTranslation} (see {@link Spell#getNameForTranslation()}). */ + /** + * Returns the translated display name of the spell, without formatting (i.e. not coloured). Client-side + * only! On the server side, use {@link TextComponentTranslation} (see {@link Spell#getNameForTranslation()}). + */ @SideOnly(Side.CLIENT) public String getDisplayName(){ return net.minecraft.client.resources.I18n.format("spell." + unlocalisedName); } - - /** Returns a {@code TextComponentTranslation} which will be translated to the display name of the spell, without - * formatting (i.e. not coloured). */ + + /** + * Returns a {@code TextComponentTranslation} which will be translated to the display name of the spell, without + * formatting (i.e. not coloured). + */ public TextComponentTranslation getNameForTranslation(){ return new TextComponentTranslation("spell." + unlocalisedName); } - /** Returns the translated display name of the spell, with formatting (i.e. coloured). Client-side only! - * On the server side, use {@link TextComponentTranslation} (see {@link Spell#getNameForTranslationFormatted()}). */ + /** + * Returns the translated display name of the spell, with formatting (i.e. coloured). Client-side only! On + * the server side, use {@link TextComponentTranslation} (see {@link Spell#getNameForTranslationFormatted()}). + */ @SideOnly(Side.CLIENT) public String getDisplayNameWithFormatting(){ - return this.element.getFormattingCode() + net.minecraft.client.resources.I18n.format("spell." + unlocalisedName); + return this.element.getFormattingCode() + + net.minecraft.client.resources.I18n.format("spell." + unlocalisedName); } - - /** Returns a {@code TextComponentTranslation} which will be translated to the display name of the spell, with - * formatting (i.e. coloured). */ + + /** + * Returns a {@code TextComponentTranslation} which will be translated to the display name of the spell, with + * formatting (i.e. coloured). + */ public ITextComponent getNameForTranslationFormatted(){ return new TextComponentTranslation("spell." + unlocalisedName).setStyle(this.element.getColour()); } - /** Returns the translated description of the spell, without formatting. Client-side only! You should not - * need to use this on the server side. */ + /** + * Returns the translated description of the spell, without formatting. Client-side only! You should not need + * to use this on the server side. + */ @SideOnly(Side.CLIENT) public String getDescription(){ return net.minecraft.client.resources.I18n.format("spell." + unlocalisedName + ".desc"); } /** Returns whether the spell is enabled in the config. */ - public final boolean isEnabled() { + public final boolean isEnabled(){ return isEnabled; } /** Sets whether the spell is enabled or not. */ - public final void setEnabled(boolean isEnabled) { + public final void setEnabled(boolean isEnabled){ this.isEnabled = isEnabled; } @@ -301,7 +347,7 @@ public abstract class Spell extends IForgeRegistryEntry.Impl implements C // they will remain in the order they were registered. @Override public final int compareTo(Spell spell){ - + if(this.tier.ordinal() > spell.tier.ordinal()){ return 1; }else if(this.tier.ordinal() < spell.tier.ordinal()){ @@ -316,21 +362,26 @@ public abstract class Spell extends IForgeRegistryEntry.Impl implements C } } } - - // ================================================ Static methods ================================================== - - /** Returns the total number of registered spells, excluding the 'None' spell. Returns the same number that would - * be returned by Spell.getSpells(Spell.allSpells).size(), but this method is more efficient. */ + + // ================================================ Static methods + // ================================================== + + /** + * Returns the total number of registered spells, excluding the 'None' spell. Returns the same number that would be + * returned by Spell.getSpells(Spell.allSpells).size(), but this method is more efficient. + */ public static int getTotalSpellCount(){ return registry.getValues().size() - 1; } - - /** Gets a spell instance from its integer id, which now corresponds to its id in the spell registry. - * If the given id has no spell (i.e. is less than 0 or greater than the total number of spells - 1) - * then it will return the {@link None} spell. + + /** + * Gets a spell instance from its integer id, which now corresponds to its id in the spell registry. If the given id + * has no spell (i.e. is less than 0 or greater than the total number of spells - 1) then it will return the + * {@link None} spell. *

    - * If you are calling this from inside a loop in which you are iterating through the spells, there is - * probably a better way; see {@link Spell#getSpells(Predicate)}. */ + * If you are calling this from inside a loop in which you are iterating through the spells, there is probably a + * better way; see {@link Spell#getSpells(Predicate)}. + */ public static Spell get(int id){ if(id < 0 || id >= registry.getValues().size()){ return Spells.none; @@ -338,16 +389,19 @@ public abstract class Spell extends IForgeRegistryEntry.Impl implements C Spell spell = registry.getValues().get(id); return spell == null ? Spells.none : spell; } - - /** Returns the spell with the given registry name, or null if no such spell exists. + + /** + * Returns the spell with the given registry name, or null if no such spell exists. + * * @param name The registry name of the spell, in the form [mod id]:[spell name]. If no mod id is specified, it - * defaults to {@link Wizardry#MODID}. */ + * defaults to {@link Wizardry#MODID}. + */ public static Spell get(String name){ ResourceLocation key = new ResourceLocation(name); if(key.getResourceDomain().equals("minecraft")) key = new ResourceLocation(Wizardry.MODID, name); return registry.getValue(key); } - + /** Returns a list of all registered spells' registry names, excluding the 'none' spell. Used in commands. */ public static String[] getSpellNames(){ // Maybe it would be better to store all of this statically? @@ -356,7 +410,7 @@ public abstract class Spell extends IForgeRegistryEntry.Impl implements C // Streams! return keys.stream().map(ResourceLocation::toString).toArray(String[]::new); } - + /** * Returns a list containing all spells matching the given {@link Predicate}. The returned list is separate from the * internal spells list; any changes you make to the returned list will have no effect on wizardry since the @@ -365,48 +419,53 @@ public abstract class Spell extends IForgeRegistryEntry.Impl implements C *

    * {@link Spell#allSpells} will allow all spells to be returned
    * {@link Spell#enabledSpells} will filter out any spells that are disabled in the config
    - * {@link Spell#npcSpells} will only allow enabled spells that can be cast by NPCs (see {@link Spell#canBeCastByNPCs()})
    + * {@link Spell#npcSpells} will only allow enabled spells that can be cast by NPCs (see + * {@link Spell#canBeCastByNPCs()})
    * {@link Spell#nonContinuousSpells} will filter out continuous spells but not disabled spells
    * {@link Spell.TierElementFilter} will only allow enabled spells of the specified tier and element * * @param filter A Predicate<Spell> that the returned spells must satisfy. * - * @return A local, modifiable list of spells matching the given predicate. Note that this list may be empty. - * */ + * @return A local, modifiable list of spells matching the given predicate. Note that this list may be + * empty. + */ public static List getSpells(Predicate filter){ - + ArrayList spells = new ArrayList(1); - + for(Spell spell : registry.getValues()){ if(filter.test(spell) && spell != Spells.none) spells.add(spell); } - + return spells; } - + /** Predicate which allows all spells. */ public static Predicate allSpells = s -> true; - + /** Predicate which allows all enabled spells. */ public static Predicate enabledSpells = Spell::isEnabled; - + /** Predicate which allows all non-continuous spells, even those that have been disabled. */ public static Predicate nonContinuousSpells = s -> !s.isContinuous; - + /** Predicate which allows all enabled spells for which {@link Spell#canBeCastByNPCs()} returns true. */ public static Predicate npcSpells = s -> s.isEnabled() && s.canBeCastByNPCs(); - - /** Predicate which allows all enabled spells of the given tier and element (create an instance of this class - * each time you want to use it). This is somewhat useless now that Wizardry uses Java 8, but it is more readable - * than a lambda expression and you don't need to remember to check that the spell is enabled every time. */ + + /** + * Predicate which allows all enabled spells of the given tier and element (create an instance of this class each + * time you want to use it). This is somewhat useless now that Wizardry uses Java 8, but it is more readable than a + * lambda expression and you don't need to remember to check that the spell is enabled every time. + */ public static class TierElementFilter implements Predicate { - + private Tier tier; private Element element; - - /** + + /** * Creates a new TierElementFilter that checks for the given tier and element. Does not allow spells that have * been disabled in the config. + * * @param tier The EnumTier to check for. Pass in null to allow all tiers. * @param element The EnumElement to check for. Pass in null to allow all elements. */ @@ -414,9 +473,9 @@ public abstract class Spell extends IForgeRegistryEntry.Impl implements C this.tier = tier; this.element = element; } - + @Override - public boolean test(Spell spell) { + public boolean test(Spell spell){ return spell.isEnabled() && (this.tier == null || spell.tier == this.tier) && (this.element == null || spell.element == this.element); } diff --git a/src/main/java/electroblob/wizardry/spell/SpiderSwarm.java b/src/main/java/electroblob/wizardry/spell/SpiderSwarm.java index a7c6a90a..fbb9d926 100644 --- a/src/main/java/electroblob/wizardry/spell/SpiderSwarm.java +++ b/src/main/java/electroblob/wizardry/spell/SpiderSwarm.java @@ -18,7 +18,7 @@ import net.minecraft.world.World; public class SpiderSwarm extends Spell { - public SpiderSwarm() { + public SpiderSwarm(){ super(Tier.ADVANCED, 45, Element.EARTH, "spider_swarm", SpellType.MINION, 200, EnumAction.BOW, false); } @@ -28,35 +28,39 @@ public class SpiderSwarm extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ if(!world.isRemote){ - for(int i=0;i<5;i++){ + for(int i = 0; i < 5; i++){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 3, 6); // The spell instantly fails if no space was found (see javadoc for the above method). if(pos == null) return false; - - EntitySpiderMinion spider = new EntitySpiderMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(spider); + + EntitySpiderMinion spider = new EntitySpiderMinion(world, pos.getX() + 0.5, pos.getY(), + pos.getZ() + 0.5, caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(spider); } } - - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.BLOCK_FIRE_EXTINGUISH, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.BLOCK_FIRE_EXTINGUISH, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); // Can't possibly get this far if nothing was spawned. return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) { - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(!world.isRemote){ - for(int i=0;i<5;i++){ + for(int i = 0; i < 5; i++){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 3, 6); // The spell instantly fails if no space was found (see javadoc for the above method). if(pos == null) return false; - - EntitySpiderMinion spider = new EntitySpiderMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(spider); + + EntitySpiderMinion spider = new EntitySpiderMinion(world, pos.getX() + 0.5, pos.getY(), + pos.getZ() + 0.5, caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(spider); } } diff --git a/src/main/java/electroblob/wizardry/spell/StaticAura.java b/src/main/java/electroblob/wizardry/spell/StaticAura.java index 851c260f..b04cc612 100644 --- a/src/main/java/electroblob/wizardry/spell/StaticAura.java +++ b/src/main/java/electroblob/wizardry/spell/StaticAura.java @@ -18,7 +18,7 @@ import net.minecraft.world.World; public class StaticAura extends Spell { - public StaticAura() { + public StaticAura(){ super(Tier.ADVANCED, 40, Element.LIGHTNING, "static_aura", SpellType.DEFENCE, 250, EnumAction.BOW, false); } @@ -28,39 +28,43 @@ public class StaticAura extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + // Cannot be cast when it has already been cast if(!caster.isPotionActive(WizardryPotions.static_aura)){ if(!world.isRemote){ - caster.addPotionEffect(new PotionEffect(WizardryPotions.static_aura, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0)); + caster.addPotionEffect(new PotionEffect(WizardryPotions.static_aura, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0)); } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_SPARK, 1.0F, world.rand.nextFloat() * 0.4F + 1.4F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_SPARK, 1.0F, + world.rand.nextFloat() * 0.4F + 1.4F); return true; } return false; } - + @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) { - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ // Cannot be cast when it has already been cast if(!caster.isPotionActive(WizardryPotions.static_aura)){ if(!world.isRemote){ - caster.addPotionEffect(new PotionEffect(WizardryPotions.static_aura, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0)); + caster.addPotionEffect(new PotionEffect(WizardryPotions.static_aura, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0)); } caster.playSound(WizardrySounds.SPELL_SPARK, 1.0F, world.rand.nextFloat() * 0.4F + 1.4F); return true; } return false; } - + return false; } - + @Override - public boolean canBeCastByNPCs() { + public boolean canBeCastByNPCs(){ return true; } diff --git a/src/main/java/electroblob/wizardry/spell/SummonBlaze.java b/src/main/java/electroblob/wizardry/spell/SummonBlaze.java index 3882eae8..9a67355b 100644 --- a/src/main/java/electroblob/wizardry/spell/SummonBlaze.java +++ b/src/main/java/electroblob/wizardry/spell/SummonBlaze.java @@ -18,7 +18,7 @@ import net.minecraft.world.World; public class SummonBlaze extends Spell { - public SummonBlaze() { + public SummonBlaze(){ super(Tier.ADVANCED, 40, Element.FIRE, "summon_blaze", SpellType.MINION, 200, EnumAction.BOW, false); } @@ -28,33 +28,37 @@ public class SummonBlaze extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - if(!world.isRemote){ - - BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); - if(pos == null) return false; - - EntityBlazeMinion blaze = new EntityBlazeMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(blaze); - } - - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_AMBIENT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); - return true; - } - - @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ if(!world.isRemote){ - + BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - - EntityBlazeMinion blaze = new EntityBlazeMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(blaze); + + EntityBlazeMinion blaze = new EntityBlazeMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, + caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(blaze); } - + + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_AMBIENT, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); + return true; + } + + @Override + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + + if(!world.isRemote){ + + BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); + if(pos == null) return false; + + EntityBlazeMinion blaze = new EntityBlazeMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, + caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(blaze); + } + caster.playSound(SoundEvents.ENTITY_WITHER_AMBIENT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); return true; } diff --git a/src/main/java/electroblob/wizardry/spell/SummonIceGiant.java b/src/main/java/electroblob/wizardry/spell/SummonIceGiant.java index 26e986f8..00fdc4bf 100644 --- a/src/main/java/electroblob/wizardry/spell/SummonIceGiant.java +++ b/src/main/java/electroblob/wizardry/spell/SummonIceGiant.java @@ -18,34 +18,36 @@ import net.minecraft.world.World; public class SummonIceGiant extends Spell { - public SummonIceGiant() { + public SummonIceGiant(){ super(Tier.MASTER, 100, Element.ICE, "summon_ice_giant", SpellType.MINION, 400, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - + if(!world.isRemote){ - - EntityIceGiant icegiant = new EntityIceGiant(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(icegiant); + + EntityIceGiant icegiant = new EntityIceGiant(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, + (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(icegiant); } if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)pos.getX() + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)pos.getX() + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)pos.getY() + 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)pos.getZ() + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0, 0, 48 + world.rand.nextInt(12), 0.6f, 0.6f, 1.0f); + double z1 = (double)((float)pos.getZ() + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0, 0, + 48 + world.rand.nextInt(12), 0.6f, 0.6f, 1.0f); } } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.1F + 0.2F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, + world.rand.nextFloat() * 0.1F + 0.2F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/SummonIceWraith.java b/src/main/java/electroblob/wizardry/spell/SummonIceWraith.java index 6f914344..83571178 100644 --- a/src/main/java/electroblob/wizardry/spell/SummonIceWraith.java +++ b/src/main/java/electroblob/wizardry/spell/SummonIceWraith.java @@ -18,7 +18,7 @@ import net.minecraft.world.World; public class SummonIceWraith extends Spell { - public SummonIceWraith() { + public SummonIceWraith(){ super(Tier.ADVANCED, 40, Element.ICE, "summon_ice_wraith", SpellType.MINION, 200, EnumAction.BOW, false); } @@ -28,31 +28,35 @@ public class SummonIceWraith extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ - + BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - - EntityIceWraith iceWraith = new EntityIceWraith(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(iceWraith); + + EntityIceWraith iceWraith = new EntityIceWraith(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, + caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(iceWraith); } - - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_AMBIENT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_AMBIENT, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ if(!world.isRemote){ - + BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - - EntityIceWraith iceWraith = new EntityIceWraith(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(iceWraith); + + EntityIceWraith iceWraith = new EntityIceWraith(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, + caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(iceWraith); } caster.playSound(SoundEvents.ENTITY_WITHER_AMBIENT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); return true; diff --git a/src/main/java/electroblob/wizardry/spell/SummonIronGolem.java b/src/main/java/electroblob/wizardry/spell/SummonIronGolem.java index 4f510f4d..d7f48844 100644 --- a/src/main/java/electroblob/wizardry/spell/SummonIronGolem.java +++ b/src/main/java/electroblob/wizardry/spell/SummonIronGolem.java @@ -17,34 +17,35 @@ import net.minecraft.world.World; public class SummonIronGolem extends Spell { - public SummonIronGolem() { + public SummonIronGolem(){ super(Tier.MASTER, 175, Element.SORCERY, "summon_iron_golem", SpellType.MINION, 400, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - + if(!world.isRemote){ EntityIronGolem golem = new EntityIronGolem(world); golem.setPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); - world.spawnEntityInWorld(golem); + world.spawnEntity(golem); } - - for(int i=0; i<10; i++){ - double x1 = (double)((float)pos.getX() + world.rand.nextFloat()*2 - 1.0F); + + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)pos.getX() + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)pos.getY() + 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)pos.getZ() + world.rand.nextFloat()*2 - 1.0F); + double z1 = (double)((float)pos.getZ() + world.rand.nextFloat() * 2 - 1.0F); if(world.isRemote){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0, 0, 48 + world.rand.nextInt(12), 0.6f, 0.6f, 1.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0, 0, + 48 + world.rand.nextInt(12), 0.6f, 0.6f, 1.0f); } } - - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/SummonLightningWraith.java b/src/main/java/electroblob/wizardry/spell/SummonLightningWraith.java index 6c74adf1..0baff375 100644 --- a/src/main/java/electroblob/wizardry/spell/SummonLightningWraith.java +++ b/src/main/java/electroblob/wizardry/spell/SummonLightningWraith.java @@ -18,8 +18,9 @@ import net.minecraft.world.World; public class SummonLightningWraith extends Spell { - public SummonLightningWraith() { - super(Tier.ADVANCED, 40, Element.LIGHTNING, "summon_lightning_wraith", SpellType.MINION, 200, EnumAction.BOW, false); + public SummonLightningWraith(){ + super(Tier.ADVANCED, 40, Element.LIGHTNING, "summon_lightning_wraith", SpellType.MINION, 200, EnumAction.BOW, + false); } @Override @@ -28,30 +29,34 @@ public class SummonLightningWraith extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ - + BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - - EntityLightningWraith lightningWraith = new EntityLightningWraith(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(lightningWraith); + + EntityLightningWraith lightningWraith = new EntityLightningWraith(world, pos.getX() + 0.5, pos.getY(), + pos.getZ() + 0.5, caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(lightningWraith); } - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_AMBIENT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_AMBIENT, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(!world.isRemote){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - - EntityLightningWraith lightningWraith = new EntityLightningWraith(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(lightningWraith); + + EntityLightningWraith lightningWraith = new EntityLightningWraith(world, pos.getX() + 0.5, pos.getY(), + pos.getZ() + 0.5, caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(lightningWraith); } caster.playSound(SoundEvents.ENTITY_WITHER_AMBIENT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); return true; diff --git a/src/main/java/electroblob/wizardry/spell/SummonPhoenix.java b/src/main/java/electroblob/wizardry/spell/SummonPhoenix.java index 5dc24a07..c74b39d9 100644 --- a/src/main/java/electroblob/wizardry/spell/SummonPhoenix.java +++ b/src/main/java/electroblob/wizardry/spell/SummonPhoenix.java @@ -16,7 +16,7 @@ import net.minecraft.world.World; public class SummonPhoenix extends Spell { - public SummonPhoenix() { + public SummonPhoenix(){ super(Tier.MASTER, 150, Element.FIRE, "summon_phoenix", SpellType.MINION, 400, EnumAction.BOW, false); } @@ -26,21 +26,21 @@ public class SummonPhoenix extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - + EntityPhoenix phoenix = new EntityPhoenix(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, - (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(phoenix); + (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(phoenix); } - - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_AMBIENT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_AMBIENT, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/SummonShadowWraith.java b/src/main/java/electroblob/wizardry/spell/SummonShadowWraith.java index 621cfeab..6f00f8f2 100644 --- a/src/main/java/electroblob/wizardry/spell/SummonShadowWraith.java +++ b/src/main/java/electroblob/wizardry/spell/SummonShadowWraith.java @@ -18,8 +18,9 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class SummonShadowWraith extends Spell { - public SummonShadowWraith() { - super(Tier.MASTER, 100, Element.NECROMANCY, "summon_shadow_wraith", SpellType.MINION, 400, EnumAction.BOW, false); + public SummonShadowWraith(){ + super(Tier.MASTER, 100, Element.NECROMANCY, "summon_shadow_wraith", SpellType.MINION, 400, EnumAction.BOW, + false); } @Override @@ -28,23 +29,25 @@ public class SummonShadowWraith extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - - EntityShadowWraith shadowWraith = new EntityShadowWraith(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(shadowWraith); + + EntityShadowWraith shadowWraith = new EntityShadowWraith(world, pos.getX() + 0.5, pos.getY(), + pos.getZ() + 0.5, caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(shadowWraith); } - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_AMBIENT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_AMBIENT, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); return true; } - + @SideOnly(Side.CLIENT) @Override - public String getDescription(){ + public String getDescription(){ return "\u00A7k" + super.getDescription(); } diff --git a/src/main/java/electroblob/wizardry/spell/SummonSkeleton.java b/src/main/java/electroblob/wizardry/spell/SummonSkeleton.java index 7c086e9f..68bcbcf1 100644 --- a/src/main/java/electroblob/wizardry/spell/SummonSkeleton.java +++ b/src/main/java/electroblob/wizardry/spell/SummonSkeleton.java @@ -21,7 +21,7 @@ import net.minecraft.world.World; public class SummonSkeleton extends Spell { - public SummonSkeleton() { + public SummonSkeleton(){ super(Tier.APPRENTICE, 15, Element.NECROMANCY, "summon_skeleton", SpellType.MINION, 50, EnumAction.BOW, false); } @@ -31,34 +31,37 @@ public class SummonSkeleton extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - - EntitySkeletonMinion skeleton = new EntitySkeletonMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); + + EntitySkeletonMinion skeleton = new EntitySkeletonMinion(world, pos.getX() + 0.5, pos.getY(), + pos.getZ() + 0.5, caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); skeleton.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.BOW)); skeleton.setDropChance(EntityEquipmentSlot.MAINHAND, 0.0f); - world.spawnEntityInWorld(skeleton); + world.spawnEntity(skeleton); } WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_SUMMONING, 7.0f, 0.6f); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(!world.isRemote){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - - EntitySkeletonMinion skeleton = new EntitySkeletonMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); + + EntitySkeletonMinion skeleton = new EntitySkeletonMinion(world, pos.getX() + 0.5, pos.getY(), + pos.getZ() + 0.5, caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); skeleton.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.BOW)); skeleton.setDropChance(EntityEquipmentSlot.MAINHAND, 0.0f); - world.spawnEntityInWorld(skeleton); + world.spawnEntity(skeleton); } caster.playSound(WizardrySounds.SPELL_SUMMONING, 7.0f, 0.6f); return true; diff --git a/src/main/java/electroblob/wizardry/spell/SummonSkeletonLegion.java b/src/main/java/electroblob/wizardry/spell/SummonSkeletonLegion.java index 69a373ff..02defe38 100644 --- a/src/main/java/electroblob/wizardry/spell/SummonSkeletonLegion.java +++ b/src/main/java/electroblob/wizardry/spell/SummonSkeletonLegion.java @@ -19,8 +19,9 @@ import net.minecraft.world.World; public class SummonSkeletonLegion extends Spell { - public SummonSkeletonLegion() { - super(Tier.MASTER, 100, Element.NECROMANCY, "summon_skeleton_legion", SpellType.MINION, 400, EnumAction.BOW, false); + public SummonSkeletonLegion(){ + super(Tier.MASTER, 100, Element.NECROMANCY, "summon_skeleton_legion", SpellType.MINION, 400, EnumAction.BOW, + false); } @Override @@ -29,47 +30,49 @@ public class SummonSkeletonLegion extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ if(!world.isRemote){ // Archers - for(int i=0;i<3;i++){ + for(int i = 0; i < 3; i++){ // This is all so much neater now thanks to this method. BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 3, 6); // The spell instantly fails if no space was found (see javadoc for the above method). if(pos == null) return false; - - EntitySkeletonMinion skeleton = new EntitySkeletonMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(1200*modifiers.get(WizardryItems.duration_upgrade))); + + EntitySkeletonMinion skeleton = new EntitySkeletonMinion(world, pos.getX() + 0.5, pos.getY(), + pos.getZ() + 0.5, caster, (int)(1200 * modifiers.get(WizardryItems.duration_upgrade))); skeleton.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.BOW)); skeleton.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(Items.CHAINMAIL_HELMET)); skeleton.setItemStackToSlot(EntityEquipmentSlot.CHEST, new ItemStack(Items.CHAINMAIL_CHESTPLATE)); skeleton.setDropChance(EntityEquipmentSlot.MAINHAND, 0.0f); skeleton.setDropChance(EntityEquipmentSlot.HEAD, 0.0f); skeleton.setDropChance(EntityEquipmentSlot.CHEST, 0.0f); - world.spawnEntityInWorld(skeleton); + world.spawnEntity(skeleton); } // Swordsmen - for(int i=0;i<3;i++){ - + for(int i = 0; i < 3; i++){ + BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 3, 6); // The spell instantly fails if no space was found (see javadoc for the above method). if(pos == null) return false; - - EntitySkeletonMinion skeleton = new EntitySkeletonMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(1200*modifiers.get(WizardryItems.duration_upgrade))); + + EntitySkeletonMinion skeleton = new EntitySkeletonMinion(world, pos.getX() + 0.5, pos.getY(), + pos.getZ() + 0.5, caster, (int)(1200 * modifiers.get(WizardryItems.duration_upgrade))); skeleton.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SWORD)); skeleton.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(Items.CHAINMAIL_HELMET)); skeleton.setItemStackToSlot(EntityEquipmentSlot.CHEST, new ItemStack(Items.CHAINMAIL_CHESTPLATE)); skeleton.setDropChance(EntityEquipmentSlot.MAINHAND, 0.0f); skeleton.setDropChance(EntityEquipmentSlot.HEAD, 0.0f); skeleton.setDropChance(EntityEquipmentSlot.CHEST, 0.0f); - world.spawnEntityInWorld(skeleton); + world.spawnEntity(skeleton); } } - + // Can't possibly get this far if nothing was spawned. - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/SummonSnowGolem.java b/src/main/java/electroblob/wizardry/spell/SummonSnowGolem.java index 7867c74a..06c71eee 100644 --- a/src/main/java/electroblob/wizardry/spell/SummonSnowGolem.java +++ b/src/main/java/electroblob/wizardry/spell/SummonSnowGolem.java @@ -17,32 +17,33 @@ import net.minecraft.world.World; public class SummonSnowGolem extends Spell { - public SummonSnowGolem() { + public SummonSnowGolem(){ super(Tier.APPRENTICE, 15, Element.ICE, "summon_snow_golem", SpellType.MINION, 20, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - + if(!world.isRemote){ EntitySnowman snowman = new EntitySnowman(world); snowman.setPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); - world.spawnEntityInWorld(snowman); + world.spawnEntity(snowman); } - for(int i=0; i<10; i++){ - double x1 = (double)((float)pos.getX() + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)pos.getX() + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)pos.getY() + 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)pos.getZ() + world.rand.nextFloat()*2 - 1.0F); + double z1 = (double)((float)pos.getZ() + world.rand.nextFloat() * 2 - 1.0F); if(world.isRemote){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.6f, 0.6f, 1.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 0.6f, 0.6f, 1.0f); } } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/SummonSpiritHorse.java b/src/main/java/electroblob/wizardry/spell/SummonSpiritHorse.java index 277bc15c..359e2b45 100644 --- a/src/main/java/electroblob/wizardry/spell/SummonSpiritHorse.java +++ b/src/main/java/electroblob/wizardry/spell/SummonSpiritHorse.java @@ -16,7 +16,7 @@ import net.minecraft.world.World; public class SummonSpiritHorse extends Spell { - public SummonSpiritHorse() { + public SummonSpiritHorse(){ super(Tier.ADVANCED, 50, Element.EARTH, "summon_spirit_horse", SpellType.MINION, 150, EnumAction.BOW, false); } @@ -26,28 +26,28 @@ public class SummonSpiritHorse extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + WizardData properties = WizardData.get(caster); - + if(!properties.hasSpiritHorse){ if(!world.isRemote){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - + EntitySpiritHorse horse = new EntitySpiritHorse(world); horse.setPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); horse.setTamedBy(caster); horse.setHorseSaddled(true); - world.spawnEntityInWorld(horse); + world.spawnEntity(horse); } properties.hasSpiritHorse = true; - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return true; } return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/SummonSpiritWolf.java b/src/main/java/electroblob/wizardry/spell/SummonSpiritWolf.java index a7285484..4d0ce4c3 100644 --- a/src/main/java/electroblob/wizardry/spell/SummonSpiritWolf.java +++ b/src/main/java/electroblob/wizardry/spell/SummonSpiritWolf.java @@ -16,7 +16,7 @@ import net.minecraft.world.World; public class SummonSpiritWolf extends Spell { - public SummonSpiritWolf() { + public SummonSpiritWolf(){ super(Tier.APPRENTICE, 25, Element.EARTH, "summon_spirit_wolf", SpellType.MINION, 100, EnumAction.BOW, false); } @@ -26,24 +26,25 @@ public class SummonSpiritWolf extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + WizardData properties = WizardData.get(caster); - + if(!properties.hasSpiritWolf){ if(!world.isRemote){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - + EntitySpiritWolf wolf = new EntitySpiritWolf(world); wolf.setPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); wolf.setTamed(true); wolf.setOwnerId(caster.getUniqueID()); - world.spawnEntityInWorld(wolf); + world.spawnEntity(wolf); } properties.hasSpiritWolf = true; - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return true; } return false; diff --git a/src/main/java/electroblob/wizardry/spell/SummonStormElemental.java b/src/main/java/electroblob/wizardry/spell/SummonStormElemental.java index 2e61aa45..ed41e623 100644 --- a/src/main/java/electroblob/wizardry/spell/SummonStormElemental.java +++ b/src/main/java/electroblob/wizardry/spell/SummonStormElemental.java @@ -16,8 +16,9 @@ import net.minecraft.world.World; public class SummonStormElemental extends Spell { - public SummonStormElemental() { - super(Tier.MASTER, 100, Element.LIGHTNING, "summon_storm_elemental", SpellType.MINION, 400, EnumAction.BOW, false); + public SummonStormElemental(){ + super(Tier.MASTER, 100, Element.LIGHTNING, "summon_storm_elemental", SpellType.MINION, 400, EnumAction.BOW, + false); } @Override @@ -26,17 +27,19 @@ public class SummonStormElemental extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - - EntityStormElemental stormElemental = new EntityStormElemental(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(stormElemental); + + EntityStormElemental stormElemental = new EntityStormElemental(world, pos.getX() + 0.5, pos.getY(), + pos.getZ() + 0.5, caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(stormElemental); } - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_AMBIENT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_AMBIENT, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); return true; } } diff --git a/src/main/java/electroblob/wizardry/spell/SummonWitherSkeleton.java b/src/main/java/electroblob/wizardry/spell/SummonWitherSkeleton.java index d8b6c22a..58372589 100644 --- a/src/main/java/electroblob/wizardry/spell/SummonWitherSkeleton.java +++ b/src/main/java/electroblob/wizardry/spell/SummonWitherSkeleton.java @@ -3,14 +3,13 @@ package electroblob.wizardry.spell; import electroblob.wizardry.constants.Element; import electroblob.wizardry.constants.SpellType; import electroblob.wizardry.constants.Tier; -import electroblob.wizardry.entity.living.EntitySkeletonMinion; +import electroblob.wizardry.entity.living.EntityWitherSkeletonMinion; import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.registry.WizardrySounds; import electroblob.wizardry.util.SpellModifiers; import electroblob.wizardry.util.WizardryUtilities; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.SkeletonType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.EntityEquipmentSlot; @@ -22,8 +21,9 @@ import net.minecraft.world.World; public class SummonWitherSkeleton extends Spell { - public SummonWitherSkeleton() { - super(Tier.ADVANCED, 35, Element.NECROMANCY, "summon_wither_skeleton", SpellType.MINION, 150, EnumAction.BOW, false); + public SummonWitherSkeleton(){ + super(Tier.ADVANCED, 35, Element.NECROMANCY, "summon_wither_skeleton", SpellType.MINION, 150, EnumAction.BOW, + false); } @Override @@ -32,36 +32,37 @@ public class SummonWitherSkeleton extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - - EntitySkeletonMinion skeleton = new EntitySkeletonMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - skeleton.setSkeletonType(SkeletonType.WITHER); + + EntityWitherSkeletonMinion skeleton = new EntityWitherSkeletonMinion(world, pos.getX() + 0.5, pos.getY(), + pos.getZ() + 0.5, caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); skeleton.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.STONE_SWORD)); skeleton.setDropChance(EntityEquipmentSlot.MAINHAND, 0.0f); - world.spawnEntityInWorld(skeleton); + world.spawnEntity(skeleton); } WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_SUMMONING, 7.0f, 0.6f); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ if(!world.isRemote){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - - EntitySkeletonMinion skeleton = new EntitySkeletonMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - skeleton.setSkeletonType(SkeletonType.WITHER); + + EntityWitherSkeletonMinion skeleton = new EntityWitherSkeletonMinion(world, pos.getX() + 0.5, pos.getY(), + pos.getZ() + 0.5, caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); skeleton.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.STONE_SWORD)); skeleton.setDropChance(EntityEquipmentSlot.MAINHAND, 0.0f); - world.spawnEntityInWorld(skeleton); + world.spawnEntity(skeleton); } caster.playSound(WizardrySounds.SPELL_SUMMONING, 7.0f, 0.6f); return true; diff --git a/src/main/java/electroblob/wizardry/spell/SummonZombie.java b/src/main/java/electroblob/wizardry/spell/SummonZombie.java index 21718a87..8e8e684f 100644 --- a/src/main/java/electroblob/wizardry/spell/SummonZombie.java +++ b/src/main/java/electroblob/wizardry/spell/SummonZombie.java @@ -18,7 +18,7 @@ import net.minecraft.world.World; public class SummonZombie extends Spell { - public SummonZombie() { + public SummonZombie(){ super(Tier.BASIC, 10, Element.NECROMANCY, "summon_zombie", SpellType.MINION, 40, EnumAction.BOW, false); } @@ -28,29 +28,32 @@ public class SummonZombie extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - EntityZombieMinion zombie = new EntityZombieMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(zombie); + EntityZombieMinion zombie = new EntityZombieMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, + caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(zombie); } WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_SUMMONING, 7.0f, 0.6f); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(!world.isRemote){ BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 4); if(pos == null) return false; - - EntityZombieMinion zombie = new EntityZombieMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade))); - world.spawnEntityInWorld(zombie); + + EntityZombieMinion zombie = new EntityZombieMinion(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, + caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade))); + world.spawnEntity(zombie); } caster.playSound(WizardrySounds.SPELL_SUMMONING, 7.0f, 0.6f); return true; diff --git a/src/main/java/electroblob/wizardry/spell/Telekinesis.java b/src/main/java/electroblob/wizardry/spell/Telekinesis.java index d46608ea..f1e3b6f0 100644 --- a/src/main/java/electroblob/wizardry/spell/Telekinesis.java +++ b/src/main/java/electroblob/wizardry/spell/Telekinesis.java @@ -22,7 +22,7 @@ import net.minecraft.world.World; public class Telekinesis extends Spell { - public Telekinesis() { + public Telekinesis(){ super(Tier.BASIC, 5, Element.SORCERY, "telekinesis", SpellType.UTILITY, 5, EnumAction.NONE, false); } @@ -32,18 +32,19 @@ public class Telekinesis extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 8*modifiers.get(WizardryItems.range_upgrade), 3.0f); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 8 * modifiers.get(WizardryItems.range_upgrade), 3.0f); if(rayTrace != null && rayTrace.entityHit != null){ if(rayTrace.entityHit instanceof EntityItem){ Entity entityHit = rayTrace.entityHit; - entityHit.motionX = (caster.posX - entityHit.posX)/6; - entityHit.motionY = (caster.posY + caster.eyeHeight - entityHit.posY)/6; - entityHit.motionZ = (caster.posZ - entityHit.posZ)/6; + entityHit.motionX = (caster.posX - entityHit.posX) / 6; + entityHit.motionY = (caster.posY + caster.eyeHeight - entityHit.posY) / 6; + entityHit.motionZ = (caster.posZ - entityHit.posZ) / 6; entityHit.playSound(WizardrySounds.SPELL_CONJURATION, 1.0F, 1.0f); caster.swingArm(hand); return true; @@ -57,10 +58,10 @@ public class Telekinesis extends Spell { if(!world.isRemote){ EntityItem item = target.entityDropItem(target.getHeldItemMainhand(), 0.0f); // Makes the item move towards the caster - item.motionX = (caster.posX - target.posX)/20; - item.motionZ = (caster.posZ - target.posZ)/20; + item.motionX = (caster.posX - target.posX) / 20; + item.motionZ = (caster.posZ - target.posZ) / 20; } - + target.setHeldItem(EnumHand.MAIN_HAND, null); target.playSound(WizardrySounds.SPELL_CONJURATION, 1.0F, 1.0f); @@ -69,12 +70,13 @@ public class Telekinesis extends Spell { } } } - + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){ - + IBlockState blockstate = world.getBlockState(new BlockPos(rayTrace.getBlockPos())); - - if(blockstate.getBlock().onBlockActivated(world, rayTrace.getBlockPos(), blockstate, caster, hand, null, rayTrace.sideHit, 0, 0, 0)){ + + if(blockstate.getBlock().onBlockActivated(world, rayTrace.getBlockPos(), blockstate, caster, hand, + rayTrace.sideHit, 0, 0, 0)){ WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F, 1.0f); caster.swingArm(hand); return true; @@ -83,19 +85,20 @@ public class Telekinesis extends Spell { return false; } - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ if(target instanceof EntityPlayer && target.getHeldItemMainhand() != null){ // IDEA: Disarm the offhand if the mainhand is empty or otherwise harmless? - + if(!world.isRemote){ EntityItem item = target.entityDropItem(target.getHeldItemMainhand(), 0.0f); // Makes the item move towards the caster - item.motionX = (caster.posX - target.posX)/20; - item.motionZ = (caster.posZ - target.posZ)/20; + item.motionX = (caster.posX - target.posX) / 20; + item.motionZ = (caster.posZ - target.posZ) / 20; } - + target.setHeldItem(EnumHand.MAIN_HAND, null); target.playSound(WizardrySounds.SPELL_CONJURATION, 1.0F, 1.0f); diff --git a/src/main/java/electroblob/wizardry/spell/Thunderbolt.java b/src/main/java/electroblob/wizardry/spell/Thunderbolt.java index a146975f..ecdf0762 100644 --- a/src/main/java/electroblob/wizardry/spell/Thunderbolt.java +++ b/src/main/java/electroblob/wizardry/spell/Thunderbolt.java @@ -16,7 +16,7 @@ import net.minecraft.world.World; public class Thunderbolt extends Spell { - public Thunderbolt() { + public Thunderbolt(){ super(Tier.BASIC, 10, Element.LIGHTNING, "thunderbolt", SpellType.ATTACK, 15, EnumAction.NONE, false); } @@ -26,37 +26,40 @@ public class Thunderbolt extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ if(!world.isRemote){ EntityThunderbolt thunderbolt = new EntityThunderbolt(world, caster, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(thunderbolt); + world.spawnEntity(thunderbolt); } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 0.8F, world.rand.nextFloat() * 0.2F + 0.8F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 0.8F, + world.rand.nextFloat() * 0.2F + 0.8F); caster.swingArm(hand); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - EntityThunderbolt thunderbolt = new EntityThunderbolt(world, caster, modifiers.get(SpellModifiers.DAMAGE)); + EntityThunderbolt thunderbolt = new EntityThunderbolt(world, caster, + modifiers.get(SpellModifiers.DAMAGE)); thunderbolt.directTowards(target, 2.5f); - world.spawnEntityInWorld(thunderbolt); + world.spawnEntity(thunderbolt); } caster.playSound(WizardrySounds.SPELL_ICE, 0.8F, world.rand.nextFloat() * 0.2F + 0.8F); caster.swingArm(hand); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/Thunderstorm.java b/src/main/java/electroblob/wizardry/spell/Thunderstorm.java index b1992941..3a3e88a5 100644 --- a/src/main/java/electroblob/wizardry/spell/Thunderstorm.java +++ b/src/main/java/electroblob/wizardry/spell/Thunderstorm.java @@ -25,95 +25,121 @@ import net.minecraft.world.World; public class Thunderstorm extends Spell { - public Thunderstorm() { + public Thunderstorm(){ super(Tier.MASTER, 100, Element.LIGHTNING, "thunderstorm", SpellType.ATTACK, 250, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(world.canBlockSeeSky(new BlockPos(caster))){ - - for(int r=0; r<10; r++){ - - double radius = 4 + world.rand.nextDouble()*6*modifiers.get(WizardryItems.blast_upgrade); - double angle = world.rand.nextDouble()*Math.PI*2; - - double x = caster.posX + radius*Math.cos(angle); - double z = caster.posZ + radius*Math.sin(angle); - double y = WizardryUtilities.getNearestFloorLevel(world, new BlockPos(x, caster.posY, z), 10); - - if(!world.isRemote){ - EntityLightningBolt entitylightning = new EntityLightningBolt(world, x, y, z, false); - world.addWeatherEffect(entitylightning); - } - - // Code for eventhandler recognition; for achievements and such like. Left in for future use. - //NBTTagCompound entityNBT = entitylightning.getEntityData(); - //entityNBT.setInteger("summoningPlayer", entityplayer.entityId); - - // Secondary chaining effect + + for(int r = 0; r < 10; r++){ + + double radius = 4 + world.rand.nextDouble() * 6 * modifiers.get(WizardryItems.blast_upgrade); + double angle = world.rand.nextDouble() * Math.PI * 2; + + double x = caster.posX + radius * Math.cos(angle); + double z = caster.posZ + radius * Math.sin(angle); + double y = WizardryUtilities.getNearestFloorLevel(world, new BlockPos(x, caster.posY, z), 10); + + if(!world.isRemote){ + EntityLightningBolt entitylightning = new EntityLightningBolt(world, x, y, z, false); + world.addWeatherEffect(entitylightning); + } + + // Code for eventhandler recognition; for achievements and such like. Left in for future use. + // NBTTagCompound entityNBT = entitylightning.getEntityData(); + // entityNBT.setInteger("summoningPlayer", entityplayer.entityId); + + // Secondary chaining effect double seekerRange = 10.0d; - - List secondaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, x, y+1, z, world); - + + List secondaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, x, + y + 1, z, world); + // For this spell there is no limit to the amount of secondary targets! for(EntityLivingBase secondaryTarget : secondaryTargets){ - + if(WizardryUtilities.isValidTarget(caster, secondaryTarget)){ - + if(!world.isRemote){ EntityArc arc = new EntityArc(world); - arc.setEndpointCoords(x, y+1, z, - secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height/2, secondaryTarget.posZ); - world.spawnEntityInWorld(arc); + arc.setEndpointCoords(x, y + 1, z, secondaryTarget.posX, + secondaryTarget.posY + secondaryTarget.height / 2, secondaryTarget.posZ); + world.spawnEntity(arc); }else{ - for(int j=0;j<8;j++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, secondaryTarget.posX + world.rand.nextFloat() - 0.5, secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height/2 + world.rand.nextFloat()*2 - 1, secondaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); - world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, secondaryTarget.posX + world.rand.nextFloat() - 0.5, secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height/2 + world.rand.nextFloat()*2 - 1, secondaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0); - } + for(int j = 0; j < 8; j++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + secondaryTarget.posX + world.rand.nextFloat() - 0.5, + secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height / 2 + + world.rand.nextFloat() * 2 - 1, + secondaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); + world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, + secondaryTarget.posX + world.rand.nextFloat() - 0.5, + secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height / 2 + + world.rand.nextFloat() * 2 - 1, + secondaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0); + } } - - secondaryTarget.playSound(WizardrySounds.SPELL_SPARK, 1.0F, world.rand.nextFloat() * 0.4F + 1.5F); - - secondaryTarget.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 10.0f * modifiers.get(SpellModifiers.DAMAGE)); - - //Tertiary chaining effect - - List tertiaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height/2, secondaryTarget.posZ, world); - - for(int j=0; j tertiaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, + secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height / 2, + secondaryTarget.posZ, world); + + for(int j = 0; j < Math.min(tertiaryTargets.size(), 3); j++){ + EntityLivingBase tertiaryTarget = (EntityLivingBase)tertiaryTargets.get(j); - - if(!secondaryTargets.contains(tertiaryTarget) && WizardryUtilities.isValidTarget(caster, tertiaryTarget)){ - + + if(!secondaryTargets.contains(tertiaryTarget) + && WizardryUtilities.isValidTarget(caster, tertiaryTarget)){ + if(!world.isRemote){ EntityArc arc = new EntityArc(world); - arc.setEndpointCoords(secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height/2, secondaryTarget.posZ, - tertiaryTarget.posX, tertiaryTarget.posY + tertiaryTarget.height/2, tertiaryTarget.posZ); - world.spawnEntityInWorld(arc); + arc.setEndpointCoords(secondaryTarget.posX, + secondaryTarget.posY + secondaryTarget.height / 2, secondaryTarget.posZ, + tertiaryTarget.posX, tertiaryTarget.posY + tertiaryTarget.height / 2, + tertiaryTarget.posZ); + world.spawnEntity(arc); }else{ - for(int k=0;k<8;k++){ - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, tertiaryTarget.posX + world.rand.nextFloat() - 0.5, tertiaryTarget.getEntityBoundingBox().minY + tertiaryTarget.height/2 + world.rand.nextFloat()*2 - 1, tertiaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); - world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, tertiaryTarget.posX + world.rand.nextFloat() - 0.5, tertiaryTarget.getEntityBoundingBox().minY + tertiaryTarget.height/2 + world.rand.nextFloat()*2 - 1, tertiaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0); - } + for(int k = 0; k < 8; k++){ + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, + tertiaryTarget.posX + world.rand.nextFloat() - 0.5, + tertiaryTarget.getEntityBoundingBox().minY + tertiaryTarget.height / 2 + + world.rand.nextFloat() * 2 - 1, + tertiaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3); + world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, + tertiaryTarget.posX + world.rand.nextFloat() - 0.5, + tertiaryTarget.getEntityBoundingBox().minY + tertiaryTarget.height / 2 + + world.rand.nextFloat() * 2 - 1, + tertiaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0); + } } - - tertiaryTarget.playSound(WizardrySounds.SPELL_SPARK, 1.0F, world.rand.nextFloat() * 0.4F + 1.5F); - - tertiaryTarget.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 8.0f * modifiers.get(SpellModifiers.DAMAGE)); + + tertiaryTarget.playSound(WizardrySounds.SPELL_SPARK, 1.0F, + world.rand.nextFloat() * 0.4F + 1.5F); + + tertiaryTarget.attackEntityFrom( + MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), + 8.0f * modifiers.get(SpellModifiers.DAMAGE)); } } } } - } - - return true; + } + + return true; } - - return false; + + return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Tornado.java b/src/main/java/electroblob/wizardry/spell/Tornado.java index c0f60744..051dd858 100644 --- a/src/main/java/electroblob/wizardry/spell/Tornado.java +++ b/src/main/java/electroblob/wizardry/spell/Tornado.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class Tornado extends Spell { - public Tornado() { + public Tornado(){ super(Tier.ADVANCED, 35, Element.EARTH, "tornado", SpellType.ATTACK, 80, EnumAction.NONE, false); } @@ -27,43 +27,48 @@ public class Tornado extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ double x = caster.posX + caster.getLookVec().xCoord; double y = caster.posY; double z = caster.posZ + caster.getLookVec().zCoord; - - EntityTornado tornado = new EntityTornado(world, x, y, z, caster, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), caster.getLookVec().xCoord/3, caster.getLookVec().zCoord/3, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(tornado); + + EntityTornado tornado = new EntityTornado(world, x, y, z, caster, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade)), caster.getLookVec().xCoord / 3, + caster.getLookVec().zCoord / 3, modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(tornado); } caster.swingArm(hand); WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, 1.0F); return true; } - + @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ double x = caster.posX + caster.getLookVec().xCoord; double y = caster.posY; double z = caster.posZ + caster.getLookVec().zCoord; - - EntityTornado tornado = new EntityTornado(world, x, y, z, caster, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), caster.getLookVec().xCoord/3, caster.getLookVec().zCoord/3, modifiers.get(SpellModifiers.DAMAGE)); - world.spawnEntityInWorld(tornado); + + EntityTornado tornado = new EntityTornado(world, x, y, z, caster, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade)), caster.getLookVec().xCoord / 3, + caster.getLookVec().zCoord / 3, modifiers.get(SpellModifiers.DAMAGE)); + world.spawnEntity(tornado); } caster.swingArm(hand); caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, 1.0F); - + return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/Transience.java b/src/main/java/electroblob/wizardry/spell/Transience.java index 96d3f1c7..9ada305a 100644 --- a/src/main/java/electroblob/wizardry/spell/Transience.java +++ b/src/main/java/electroblob/wizardry/spell/Transience.java @@ -23,7 +23,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @Mod.EventBusSubscriber public class Transience extends Spell { - public Transience() { + public Transience(){ super(Tier.ADVANCED, 50, Element.HEALING, "transience", SpellType.DEFENCE, 100, EnumAction.BOW, false); } @@ -33,12 +33,14 @@ public class Transience extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ if(!caster.isPotionActive(WizardryPotions.transience)){ if(!world.isRemote){ - caster.addPotionEffect(new PotionEffect(WizardryPotions.transience, (int)(400*modifiers.get(WizardryItems.duration_upgrade)), 0)); - caster.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, (int)(400*modifiers.get(WizardryItems.duration_upgrade)), 0, false, false)); + caster.addPotionEffect(new PotionEffect(WizardryPotions.transience, + (int)(400 * modifiers.get(WizardryItems.duration_upgrade)), 0)); + caster.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, + (int)(400 * modifiers.get(WizardryItems.duration_upgrade)), 0, false, false)); WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f); } return true; @@ -50,7 +52,8 @@ public class Transience extends Spell { public static void onLivingAttackEvent(LivingAttackEvent event){ if(event.getSource() != null){ // Prevents all blockable damage while transience is active - if(event.getEntityLiving().isPotionActive(WizardryPotions.transience) && !event.getSource().isUnblockable()){ + if(event.getEntityLiving().isPotionActive(WizardryPotions.transience) + && !event.getSource().isUnblockable()){ event.setCanceled(true); } // Prevents transient entities from causing any damage @@ -60,7 +63,7 @@ public class Transience extends Spell { } } } - + @SubscribeEvent public static void onBlockPlaceEvent(BlockEvent.PlaceEvent event){ // Prevents transient players from placing blocks diff --git a/src/main/java/electroblob/wizardry/spell/Transportation.java b/src/main/java/electroblob/wizardry/spell/Transportation.java index 23caeaf1..cc686e25 100644 --- a/src/main/java/electroblob/wizardry/spell/Transportation.java +++ b/src/main/java/electroblob/wizardry/spell/Transportation.java @@ -28,12 +28,12 @@ public class Transportation extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + WizardData properties = WizardData.get(caster); // Fixes the sound not playing in first person. if(world.isRemote) WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.BLOCK_PORTAL_TRIGGER, 1.0f, 1.0f); - + // Only works when the caster is in the same dimension. if(properties != null && properties.getTpCountdown() == 0){ if(caster.dimension == properties.getStoneCircleDimension()){ @@ -45,17 +45,19 @@ public class Transportation extends Spell { properties.setTpCountdown(75); return true; }else{ - if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.transportation.missing")); + if(!world.isRemote) + caster.sendMessage(new TextComponentTranslation("spell.transportation.missing")); } }else{ - if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.transportation.undefined")); + if(!world.isRemote) + caster.sendMessage(new TextComponentTranslation("spell.transportation.undefined")); } }else{ - if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.transportation.wrongdimension")); + if(!world.isRemote) + caster.sendMessage(new TextComponentTranslation("spell.transportation.wrongdimension")); } } return false; } - } diff --git a/src/main/java/electroblob/wizardry/spell/VanishingBox.java b/src/main/java/electroblob/wizardry/spell/VanishingBox.java index 85bc13b6..76bf97ee 100644 --- a/src/main/java/electroblob/wizardry/spell/VanishingBox.java +++ b/src/main/java/electroblob/wizardry/spell/VanishingBox.java @@ -14,7 +14,7 @@ import net.minecraft.world.World; public class VanishingBox extends Spell { - public VanishingBox() { + public VanishingBox(){ super(Tier.ADVANCED, 45, Element.SORCERY, "vanishing_box", SpellType.UTILITY, 70, EnumAction.BOW, false); } @@ -24,20 +24,20 @@ public class VanishingBox extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + if(!world.isRemote){ - + InventoryEnderChest enderchest = caster.getInventoryEnderChest(); - + if(enderchest != null){ caster.displayGUIChest(enderchest); } } - + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.BLOCK_ENDERCHEST_OPEN, 1, 1); - + return true; } - + } diff --git a/src/main/java/electroblob/wizardry/spell/WallOfFrost.java b/src/main/java/electroblob/wizardry/spell/WallOfFrost.java index 285719bf..004d45c2 100644 --- a/src/main/java/electroblob/wizardry/spell/WallOfFrost.java +++ b/src/main/java/electroblob/wizardry/spell/WallOfFrost.java @@ -21,71 +21,83 @@ import net.minecraft.world.World; public class WallOfFrost extends Spell { - public WallOfFrost() { + public WallOfFrost(){ super(Tier.MASTER, 15, Element.ICE, "wall_of_frost", SpellType.UTILITY, 0, EnumAction.NONE, true); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + // IDEA: Use frosted ice instead of ice statue - + Vec3d look = caster.getLookVec(); - - RayTraceResult rayTrace = WizardryUtilities.rayTrace(10*modifiers.get(WizardryItems.range_upgrade), world, caster, true); - + + RayTraceResult rayTrace = WizardryUtilities.rayTrace(10 * modifiers.get(WizardryItems.range_upgrade), world, + caster, true); + if(rayTrace != null && !world.isRemote){ - + BlockPos pos = rayTrace.getBlockPos(); - - // Stops the ice being placed floating above snow and grass. Directions other than up included for completeness. + + // Stops the ice being placed floating above snow and grass. Directions other than up included for + // completeness. if(WizardryUtilities.canBlockBeReplaced(world, pos)){ // Moves the blockpos back into the block pos = pos.offset(rayTrace.sideHit.getOpposite()); } - - if(caster.getDistance(pos.getX(), pos.getY(), pos.getZ()) > 2 && world.getBlockState(pos).getBlock() != WizardryBlocks.ice_statue){ - + + if(caster.getDistance(pos.getX(), pos.getY(), pos.getZ()) > 2 + && world.getBlockState(pos).getBlock() != WizardryBlocks.ice_statue){ + pos = pos.offset(rayTrace.sideHit); - + if(WizardryUtilities.canBlockBeReplaced(world, pos)){ world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState()); } - + // Builds a 2 block high wall if it hits the ground if(rayTrace.sideHit == EnumFacing.UP){ pos = pos.offset(rayTrace.sideHit); - + if(WizardryUtilities.canBlockBeReplaced(world, pos)){ world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState()); } } } } - - for(int i=0; i<20; i++){ - + + for(int i = 0; i < 20; i++){ + if(world.isRemote){ - - double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, look.xCoord*modifiers.get(WizardryItems.range_upgrade), look.yCoord*modifiers.get(WizardryItems.range_upgrade), look.zCoord*modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 0.4f, 0.6f, 1.0f); - - x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, look.xCoord*modifiers.get(WizardryItems.range_upgrade), look.yCoord*modifiers.get(WizardryItems.range_upgrade), look.zCoord*modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 1.0f, 1.0f, 1.0f); + + double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, + look.xCoord * modifiers.get(WizardryItems.range_upgrade), + look.yCoord * modifiers.get(WizardryItems.range_upgrade), + look.zCoord * modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 0.4f, + 0.6f, 1.0f); + + x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, + look.xCoord * modifiers.get(WizardryItems.range_upgrade), + look.yCoord * modifiers.get(WizardryItems.range_upgrade), + look.zCoord * modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 1.0f, + 1.0f, 1.0f); } } - + if(ticksInUse % 12 == 0){ if(ticksInUse == 0) WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 0.5F, 1.0f); WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LOOP_ICE, 0.5F, 1.0f); } - + return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/WaterBreathing.java b/src/main/java/electroblob/wizardry/spell/WaterBreathing.java index c132a85b..8effe686 100644 --- a/src/main/java/electroblob/wizardry/spell/WaterBreathing.java +++ b/src/main/java/electroblob/wizardry/spell/WaterBreathing.java @@ -18,25 +18,27 @@ import net.minecraft.world.World; public class WaterBreathing extends Spell { - public WaterBreathing() { + public WaterBreathing(){ super(Tier.ADVANCED, 30, Element.EARTH, "water_breathing", SpellType.UTILITY, 250, EnumAction.BOW, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - - caster.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, (int)(1200*modifiers.get(WizardryItems.duration_upgrade)), 0, false, false)); + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + + caster.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, + (int)(1200 * modifiers.get(WizardryItems.duration_upgrade)), 0, false, false)); if(world.isRemote){ - for(int i=0; i<10; i++){ - double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F); + for(int i = 0; i < 10; i++){ + double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F); double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat()); - double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.3f, 0.3f, 1.0f); + double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, + 48 + world.rand.nextInt(12), 0.3f, 0.3f, 1.0f); } } - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, + world.rand.nextFloat() * 0.4F + 1.0F); return true; } - } diff --git a/src/main/java/electroblob/wizardry/spell/Whirlwind.java b/src/main/java/electroblob/wizardry/spell/Whirlwind.java index 9a76561c..f90607c4 100644 --- a/src/main/java/electroblob/wizardry/spell/Whirlwind.java +++ b/src/main/java/electroblob/wizardry/spell/Whirlwind.java @@ -20,77 +20,90 @@ import net.minecraft.world.World; public class Whirlwind extends Spell { - public Whirlwind() { + public Whirlwind(){ super(Tier.APPRENTICE, 10, Element.EARTH, "whirlwind", SpellType.DEFENCE, 15, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); if(rayTrace != null && rayTrace.entityHit instanceof EntityLivingBase){ - EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit; - + EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit; + if(!world.isRemote){ - + target.motionX = caster.getLookVec().xCoord * 2; target.motionY = caster.getLookVec().yCoord * 2 + 1; target.motionZ = caster.getLookVec().zCoord * 2; - + // Player motion is handled on that player's client so needs packets if(target instanceof EntityPlayerMP){ ((EntityPlayerMP)target).connection.sendPacket(new SPacketEntityVelocity(target)); } } - + if(world.isRemote){ - for(int i=0; i<10; i++){ - double x2 = (double)(caster.posX + world.rand.nextFloat() - 0.5F + caster.getLookVec().xCoord*caster.getDistanceToEntity(target)*0.5); - double y2 = (double)(WizardryUtilities.getPlayerEyesPos(caster) + world.rand.nextFloat() - 0.5F + caster.getLookVec().yCoord*caster.getDistanceToEntity(target)*0.5); - double z2 = (double)(caster.posZ + world.rand.nextFloat() - 0.5F + caster.getLookVec().zCoord*caster.getDistanceToEntity(target)*0.5); - world.spawnParticle(EnumParticleTypes.CLOUD, x2, y2, z2, caster.getLookVec().xCoord, caster.getLookVec().yCoord, caster.getLookVec().zCoord); - //Minecraft.getMinecraft().effectRenderer.addEffect(new EntitySparkleFX(world, x2, y2, z2, entityplayer.getLookVec().xCoord, entityplayer.getLookVec().yCoord, entityplayer.getLookVec().zCoord, null, 1.0f, 1.0f, 0.8f, 10)); + for(int i = 0; i < 10; i++){ + double x2 = (double)(caster.posX + world.rand.nextFloat() - 0.5F + + caster.getLookVec().xCoord * caster.getDistanceToEntity(target) * 0.5); + double y2 = (double)(WizardryUtilities.getPlayerEyesPos(caster) + world.rand.nextFloat() - 0.5F + + caster.getLookVec().yCoord * caster.getDistanceToEntity(target) * 0.5); + double z2 = (double)(caster.posZ + world.rand.nextFloat() - 0.5F + + caster.getLookVec().zCoord * caster.getDistanceToEntity(target) * 0.5); + world.spawnParticle(EnumParticleTypes.CLOUD, x2, y2, z2, caster.getLookVec().xCoord, + caster.getLookVec().yCoord, caster.getLookVec().zCoord); + // Minecraft.getMinecraft().effectRenderer.addEffect(new EntitySparkleFX(world, x2, y2, z2, + // entityplayer.getLookVec().xCoord, entityplayer.getLookVec().yCoord, + // entityplayer.getLookVec().zCoord, null, 1.0f, 1.0f, 0.8f, 10)); } } caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 0.8F, world.rand.nextFloat() * 0.2F + 0.6F); + WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 0.8F, + world.rand.nextFloat() * 0.2F + 0.6F); return true; } return false; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ target.motionX = caster.getLookVec().xCoord * 2; target.motionY = caster.getLookVec().yCoord * 2 + 1; target.motionZ = caster.getLookVec().zCoord * 2; - + // Player motion is handled on that player's client so needs packets if(target instanceof EntityPlayerMP){ ((EntityPlayerMP)target).connection.sendPacket(new SPacketEntityVelocity(target)); } } if(world.isRemote){ - for(int i=0; i<10; i++){ - double x2 = (double)(caster.posX + world.rand.nextFloat() - 0.5F + caster.getLookVec().xCoord*caster.getDistanceToEntity(target)*0.5); - double y2 = (double)(caster.posY + caster.getEyeHeight() + world.rand.nextFloat() - 0.5F + caster.getLookVec().yCoord*caster.getDistanceToEntity(target)*0.5); - double z2 = (double)(caster.posZ + world.rand.nextFloat() - 0.5F + caster.getLookVec().zCoord*caster.getDistanceToEntity(target)*0.5); - world.spawnParticle(EnumParticleTypes.CLOUD, x2, y2, z2, caster.getLookVec().xCoord, caster.getLookVec().yCoord, caster.getLookVec().zCoord); + for(int i = 0; i < 10; i++){ + double x2 = (double)(caster.posX + world.rand.nextFloat() - 0.5F + + caster.getLookVec().xCoord * caster.getDistanceToEntity(target) * 0.5); + double y2 = (double)(caster.posY + caster.getEyeHeight() + world.rand.nextFloat() - 0.5F + + caster.getLookVec().yCoord * caster.getDistanceToEntity(target) * 0.5); + double z2 = (double)(caster.posZ + world.rand.nextFloat() - 0.5F + + caster.getLookVec().zCoord * caster.getDistanceToEntity(target) * 0.5); + world.spawnParticle(EnumParticleTypes.CLOUD, x2, y2, z2, caster.getLookVec().xCoord, + caster.getLookVec().yCoord, caster.getLookVec().zCoord); } } caster.swingArm(hand); caster.playSound(WizardrySounds.SPELL_ICE, 0.8F, world.rand.nextFloat() * 0.2F + 0.6F); return true; } - + return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/spell/Wither.java b/src/main/java/electroblob/wizardry/spell/Wither.java index 878cf0bb..8819c3cf 100644 --- a/src/main/java/electroblob/wizardry/spell/Wither.java +++ b/src/main/java/electroblob/wizardry/spell/Wither.java @@ -25,76 +25,89 @@ import net.minecraft.world.World; public class Wither extends Spell { - public Wither() { + public Wither(){ super(Tier.APPRENTICE, 10, Element.NECROMANCY, "wither", SpellType.ATTACK, 20, EnumAction.NONE, false); } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ Vec3d look = caster.getLookVec(); - RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade)); + RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, + 10 * modifiers.get(WizardryItems.range_upgrade)); + + if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY + && rayTrace.entityHit instanceof EntityLivingBase){ + + EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit; - if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){ - - EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit; - // Has no effect on withers or wither skeletons. if(MagicDamage.isEntityImmune(DamageType.WITHER, target)){ - if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted())); + if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(), + this.getNameForTranslationFormatted())); }else{ - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.WITHER), 1.0f * modifiers.get(SpellModifiers.DAMAGE)); - target.addPotionEffect(new PotionEffect(MobEffects.WITHER, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), 1)); + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.WITHER), + 1.0f * modifiers.get(SpellModifiers.DAMAGE)); + target.addPotionEffect(new PotionEffect(MobEffects.WITHER, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade)), 1)); } } if(world.isRemote){ - for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ + for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ // I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet! // This is a test for lining up the ray with the wand tip. Not sure if I like it or not. - /* - Vec3d origin = Wizardry.proxy.getWandTipPosition(caster); - double x1 = origin.xCoord + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = origin.yCoord + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = origin.zCoord + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - */ - double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f; - //world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord); - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), 0.1f, 0.0f, 0.05f); + /* Vec3d origin = Wizardry.proxy.getWandTipPosition(caster); double x1 = origin.xCoord + look.xCoord*i/2 + * + world.rand.nextFloat()/5 - 0.1f; double y1 = origin.yCoord + look.yCoord*i/2 + + * world.rand.nextFloat()/5 - 0.1f; double z1 = origin.zCoord + look.zCoord*i/2 + + * world.rand.nextFloat()/5 - 0.1f; */ + double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2 + + world.rand.nextFloat() / 5 - 0.1f; + double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + // world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord); + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, + 0.1f, 0.0f, 0.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 12 + world.rand.nextInt(8), 0.1f, 0.0f, 0.05f); } } caster.swingArm(hand); - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_HURT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_HURT, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); return true; } @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ if(target != null){ // Has no effect on withers or wither skeletons. if(!MagicDamage.isEntityImmune(DamageType.WITHER, target) && !world.isRemote){ - target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.WITHER), 1.0f * modifiers.get(SpellModifiers.DAMAGE)); - target.addPotionEffect(new PotionEffect(MobEffects.WITHER, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), 1)); + target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.WITHER), + 1.0f * modifiers.get(SpellModifiers.DAMAGE)); + target.addPotionEffect(new PotionEffect(MobEffects.WITHER, + (int)(200 * modifiers.get(WizardryItems.duration_upgrade)), 1)); } - + if(world.isRemote){ - double dx = (target.posX - caster.posX)/caster.getDistanceToEntity(target); - double dy = (target.posY - caster.posY)/caster.getDistanceToEntity(target); - double dz = (target.posZ - caster.posZ)/caster.getDistanceToEntity(target); - - for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){ + double dx = (target.posX - caster.posX) / caster.getDistanceToEntity(target); + double dy = (target.posY - caster.posY) / caster.getDistanceToEntity(target); + double dz = (target.posZ - caster.posZ) / caster.getDistanceToEntity(target); - double x1 = caster.posX + dx*i/2 + world.rand.nextFloat()/5 - 0.1f; - double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy*i/2 + world.rand.nextFloat()/5 - 0.1f; - double z1 = caster.posZ + dz*i/2 + world.rand.nextFloat()/5 - 0.1f; + for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){ - Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f); - Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), 0.1f, 0.0f, 0.05f); + double x1 = caster.posX + dx * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy * i / 2 + world.rand.nextFloat() / 5 + - 0.1f; + double z1 = caster.posZ + dz * i / 2 + world.rand.nextFloat() / 5 - 0.1f; + + Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 0, 0.1f, 0.0f, 0.0f); + Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, + 12 + world.rand.nextInt(8), 0.1f, 0.0f, 0.05f); } } caster.swingArm(hand); diff --git a/src/main/java/electroblob/wizardry/spell/WitherSkull.java b/src/main/java/electroblob/wizardry/spell/WitherSkull.java index ce0f642e..7a967170 100644 --- a/src/main/java/electroblob/wizardry/spell/WitherSkull.java +++ b/src/main/java/electroblob/wizardry/spell/WitherSkull.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; public class WitherSkull extends Spell { - public WitherSkull() { + public WitherSkull(){ super(Tier.ADVANCED, 20, Element.NECROMANCY, "wither_skull", SpellType.ATTACK, 30, EnumAction.NONE, false); } @@ -27,46 +27,47 @@ public class WitherSkull extends Spell { } @Override - public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) { - + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + Vec3d look = caster.getLookVec(); - + if(!world.isRemote){ EntityWitherSkull witherskull = new EntityWitherSkull(world, caster, 1, 1, 1); - witherskull.setPosition( - caster.posX + look.xCoord, - caster.posY + look.yCoord + 1.3, + witherskull.setPosition(caster.posX + look.xCoord, caster.posY + look.yCoord + 1.3, caster.posZ + look.zCoord); witherskull.accelerationX = look.xCoord * 0.1; witherskull.accelerationY = look.yCoord * 0.1; witherskull.accelerationZ = look.zCoord * 0.1; - world.spawnEntityInWorld(witherskull); - WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SHOOT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); + world.spawnEntity(witherskull); + WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SHOOT, 1.0F, + world.rand.nextFloat() * 0.2F + 1.0F); } caster.swingArm(hand); return true; } - + @Override - public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ - + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, + SpellModifiers modifiers){ + if(target != null){ - + if(!world.isRemote){ - + EntityWitherSkull witherskull = new EntityWitherSkull(world, caster, 1, 1, 1); - + double dx = target.posX - caster.posX; - double dy = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) - (caster.posY + (double)(caster.height / 2.0F)); - double dz = target.posZ - caster.posZ; - - witherskull.accelerationX = dx/caster.getDistanceToEntity(target) * 0.1; - witherskull.accelerationY = dy/caster.getDistanceToEntity(target) * 0.1; - witherskull.accelerationZ = dz/caster.getDistanceToEntity(target) * 0.1; - - witherskull.setPosition(caster.posX, caster.posY + caster.getEyeHeight(), caster.posZ); - - world.spawnEntityInWorld(witherskull); + double dy = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) + - (caster.posY + (double)(caster.height / 2.0F)); + double dz = target.posZ - caster.posZ; + + witherskull.accelerationX = dx / caster.getDistanceToEntity(target) * 0.1; + witherskull.accelerationY = dy / caster.getDistanceToEntity(target) * 0.1; + witherskull.accelerationZ = dz / caster.getDistanceToEntity(target) * 0.1; + + witherskull.setPosition(caster.posX, caster.posY + caster.getEyeHeight(), caster.posZ); + + world.spawnEntity(witherskull); caster.playSound(SoundEvents.ENTITY_WITHER_SHOOT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F); } @@ -76,7 +77,7 @@ public class WitherSkull extends Spell { return false; } - + @Override public boolean canBeCastByNPCs(){ return true; diff --git a/src/main/java/electroblob/wizardry/tileentity/ContainerArcaneWorkbench.java b/src/main/java/electroblob/wizardry/tileentity/ContainerArcaneWorkbench.java index 6e0f4e55..f5cebc03 100644 --- a/src/main/java/electroblob/wizardry/tileentity/ContainerArcaneWorkbench.java +++ b/src/main/java/electroblob/wizardry/tileentity/ContainerArcaneWorkbench.java @@ -34,19 +34,20 @@ public class ContainerArcaneWorkbench extends Container { /** The arcane workbench tile entity associated with this container. */ public TileEntityArcaneWorkbench tileentity; - public static final ResourceLocation EMPTY_SLOT_CRYSTAL = new ResourceLocation(Wizardry.MODID, "gui/empty_slot_crystal"); - public static final ResourceLocation EMPTY_SLOT_UPGRADE = new ResourceLocation(Wizardry.MODID, "gui/empty_slot_upgrade"); + public static final ResourceLocation EMPTY_SLOT_CRYSTAL = new ResourceLocation(Wizardry.MODID, + "gui/empty_slot_crystal"); + public static final ResourceLocation EMPTY_SLOT_UPGRADE = new ResourceLocation(Wizardry.MODID, + "gui/empty_slot_upgrade"); public static final int CRYSTAL_SLOT = 8; public static final int WAND_SLOT = 9; public static final int UPGRADE_SLOT = 10; - + private static final int[][][] SPELL_BOOK_SLOT_COORDS = { {{80, 22}, {121, 51}, {106, 98}, {54, 98}, {39, 51}, {-999, -999}, {-999, -999}, {-999, -999}}, {{80, 22}, {117, 43}, {117, 85}, {80, 106}, {43, 85}, {43, 43}, {-999, -999}, {-999, -999}}, {{80, 22}, {113, 38}, {121, 74}, {98, 102}, {62, 102}, {39, 74}, {47, 38}, {-999, -999}}, - {{80, 22}, {111, 33}, {122, 64}, {111, 95}, {80, 106}, {49, 95}, {38, 64}, {49, 33}} - }; + {{80, 22}, {111, 33}, {122, 64}, {111, 95}, {80, 106}, {49, 95}, {38, 64}, {49, 33}}}; public ContainerArcaneWorkbench(IInventory inventory, TileEntityArcaneWorkbench tileentity){ @@ -54,12 +55,12 @@ public class ContainerArcaneWorkbench extends Container { ItemStack wand = tileentity.getStackInSlot(WAND_SLOT); - for(int i=0; i<8; i++){ + for(int i = 0; i < 8; i++){ this.addSlotToContainer(new SlotItemList(tileentity, i, -999, -999, 1, WizardryItems.spell_book)); } this.addSlotToContainer(new SlotItemList(tileentity, CRYSTAL_SLOT, 8, 88, 64, WizardryItems.magic_crystal)) - .setBackgroundName(EMPTY_SLOT_CRYSTAL.toString()); + .setBackgroundName(EMPTY_SLOT_CRYSTAL.toString()); this.addSlotToContainer(new SlotWandArmour(tileentity, WAND_SLOT, 80, 64, this)); @@ -68,7 +69,7 @@ public class ContainerArcaneWorkbench extends Container { upgrades.add(WizardryItems.armour_upgrade); this.addSlotToContainer(new SlotItemList(tileentity, UPGRADE_SLOT, 8, 106, 1, upgrades.toArray(new Item[0]))) - .setBackgroundName(EMPTY_SLOT_UPGRADE.toString()); + .setBackgroundName(EMPTY_SLOT_UPGRADE.toString()); for(int x = 0; x < 9; x++){ this.addSlotToContainer(new Slot(inventory, x, 8 + x * 18, 196)); @@ -85,7 +86,7 @@ public class ContainerArcaneWorkbench extends Container { @Override public boolean canInteractWith(EntityPlayer player){ - return this.tileentity.isUseableByPlayer(player); + return this.tileentity.isUsableByPlayer(player); } /** Called from the central wand/armour slot when its item is changed or removed. */ @@ -94,21 +95,21 @@ public class ContainerArcaneWorkbench extends Container { if(slotNumber == WAND_SLOT){ - if(stack == null || (!(stack.getItem() instanceof ItemWand) && stack.getItem() != WizardryItems.blank_scroll)){ + if(!(stack.getItem() instanceof ItemWand) && stack.getItem() != WizardryItems.blank_scroll){ // If the stack has been removed - for(int i=0; i

    - * In the future, there is scope for an entirely standalone mod based on this idea. Perhaps 'Elemental Damage' could be - * a config-only mod which allows its users to define any number of specific damage types, then give any creature a +/** + * As of wizardry 1.1, this class has replaced the damagesource-related methods in WizardryUtilities, allowing a + * {@link DamageType} to be specified with the damage. The main reason for this is so that damage sources can fit with + * the vanilla behaviour on armour enchantments and such like whilst still being classified as wizardry damage for the + * purposes of friendly fire, etc. + *

    + * In the future, there is scope for an entirely standalone mod based on this idea. Perhaps 'Elemental Damage' could + * be a config-only mod which allows its users to define any number of specific damage types, then give any creature a * resistance, immunity or vulnerability to each, as well as being able to specify the sources for each type, such as * enchantments, potions, specific items, certain entities, even particular situations and string damagesource names - * from other mods. - * + * from other mods. + * * @see IndirectMagicDamage * @see IElementalDamage * @since Wizardry 1.1 - * @author Electroblob */ + * @author Electroblob + */ public class MagicDamage extends EntityDamageSource implements IElementalDamage { - + /** The name of the damagesource for direct magic damage from the wizardry mod. */ public static final String DIRECT_MAGIC_DAMAGE = "wizardryMagic"; /** The name of the damagesource for indirect magic damage from the wizardry mod. */ public static final String INDIRECT_MAGIC_DAMAGE = "indirectWizardryMagic"; // Technically, I don't need to specify that the classes in this map must extend entity, but it's good practice to. private static final Map, DamageType[]> immunityMapping = new HashMap, DamageType[]>(); - + private final DamageType type; private final boolean isRetaliatory; - - /** A simple set of constants for the types of damage. The names are deliberately different to those in EnumElement - * to avoid confusion. All types are classified as magic damage in the vanilla system, so witches are resistant to them. */ + + /** + * A simple set of constants for the types of damage. The names are deliberately different to those in EnumElement + * to avoid confusion. All types are classified as magic damage in the vanilla system, so witches are resistant to + * them. + */ public enum DamageType { /** Generic magic damage from the wizardry mod. Like vanilla magic damage, except it doesn't bypass armour. */ MAGIC, - /** Fire damage from the wizardry mod. Counts as fire damage in the vanilla system, so is blocked by any mobs that - * are immune to fire and entities with the fire resistance effect. */ + /** + * Fire damage from the wizardry mod. Counts as fire damage in the vanilla system, so is blocked by any mobs + * that are immune to fire and entities with the fire resistance effect. + */ FIRE, /** Frost (ice) damage from the wizardry mod. Snow golems, ice wraiths and ice giants are immune. */ FROST, @@ -87,15 +94,17 @@ public class MagicDamage extends EntityDamageSource implements IElementalDamage WITHER, /** Poison damage from the wizardry mod. Spiders, cave spiders and undead mobs are immune. */ POISON, - /** [NYI] Force damage from the wizardry mod. Insubstantial creatures (ghast, shadow wraith, etc.) are immune. */ + /** + * [NYI] Force damage from the wizardry mod. Insubstantial creatures (ghast, shadow wraith, etc.) are immune. + */ FORCE, /** Blast damage from the wizardry mod. Affected by the blast protection enchantment. */ BLAST, /** [NYI] Radiant damage from the wizardry mod. */ RADIANT; } - - static { + + static{ // Of course, the entities that are immune to fire already are since there's a vanilla system for that, but // they're included here anyway for completeness and in case anyone wants to check if an entity is immune to // an unspecified element for reasons other than dealing damage. @@ -113,6 +122,7 @@ public class MagicDamage extends EntityDamageSource implements IElementalDamage setEntityImmunities(EntityIceGiant.class, DamageType.FROST); setEntityImmunities(EntityLightningWraith.class, DamageType.SHOCK); setEntityImmunities(EntityShadowWraith.class, DamageType.WITHER); + setEntityImmunities(EntityWitherSkeleton.class, DamageType.WITHER); setEntityImmunities(EntitySpider.class, DamageType.POISON); setEntityImmunities(EntitySpiderMinion.class, DamageType.POISON); setEntityImmunities(EntityCaveSpider.class, DamageType.POISON); @@ -130,35 +140,29 @@ public class MagicDamage extends EntityDamageSource implements IElementalDamage if(type == DamageType.FIRE) this.setFireDamage(); if(type == DamageType.BLAST) this.setExplosion(); } - - /** Returns true if the given entity is immune to the given damage type according to the entity immunity mappings, + + /** + * Returns true if the given entity is immune to the given damage type according to the entity immunity mappings, * false otherwise. When you want to check for resistances, check this method rather than just checking the result * of attackEntityFrom, since that could return false for all sorts of reasons besides immunities. However, if you - * don't need to know whether the damage succeeded or not, there's no point in checking this method. A common use - * of this method is to check for immunity and if so display the "[mob] resisted [spell]" chat message. See - * {@link electroblob.wizardry.spell.Arc Arc} for a good example of this, and also of when not to use it. */ + * don't need to know whether the damage succeeded or not, there's no point in checking this method. A common use of + * this method is to check for immunity and if so display the "[mob] resisted [spell]" chat message. See + * {@link electroblob.wizardry.spell.Arc Arc} for a good example of this, and also of when not to use it. + */ public static boolean isEntityImmune(DamageType type, Entity entity){ - // Because Mojang, in their infinite wisdom, did not make wither skeletons their own separate class (despite the - // fact that cave spiders are), I have to test for this manually. Realistically, no mod author would be stupid - // enough to put two entities in one class, so this should be the only time I ever have to do this. - if(type == DamageType.WITHER && entity instanceof EntitySkeleton - // Don't need to check EntitySkeletonMinion separately any more because it now extends EntitySkeleton. - && ((EntitySkeleton)entity).getSkeletonType() == SkeletonType.WITHER){ - return true; - } - + if(type == DamageType.FIRE && entity.isImmuneToFire()) return true; - + DamageType[] immunities = MagicDamage.immunityMapping.get(entity.getClass()); - + return immunities != null && Arrays.asList(immunities).contains(type); } - + /** Registers the given type of entity as immune to all of the passed in damage types. */ public static void setEntityImmunities(Class entityType, DamageType... immunities){ immunityMapping.put(entityType, immunities); } - + /** Adds the passed in damage type to the list of damage types to which the given entity is immune. */ public static void addEntityImmunity(Class entityType, DamageType immunity){ List immunities = Arrays.asList(immunityMapping.get(entityType)); @@ -169,45 +173,47 @@ public class MagicDamage extends EntityDamageSource implements IElementalDamage /** * Returns a DamageSource called "wizardryMagic" with the given entity as the caster. Use in preference to vanilla - * types to allow things to distinguish between magic and regular melee/swords. Unlike DamageSource.magic, it does + * types to allow things to distinguish between magic and regular melee/swords. Unlike DamageSource.MAGIC, it does * not bypass armour and has a player as the source (rather than nothing). It is still classed as magic damage (for * the record, all this does in vanilla is make witches 85% resistant to it - but that seems kinda right anyway). * isRetaliatory defaults to false. *

    - * Now that this is its own class, this static method is largely redundant, but it's not worth refactoring the entire - * mod just to get rid of this method and use the constructor instead. + * Now that this is its own class, this static method is largely redundant, but it's not worth refactoring the + * entire mod just to get rid of this method and use the constructor instead. + * * @param caster The player or other living entity causing the damage * @param type The type that this damage belongs to; used for resistances and wand perks. Use - * {@link DamageType#MAGIC} for regular, non-elemental magic damage (sometimes you might not want an element - * even though the spell has one - for example, not all necromancy spells are 'withery', so some of them might - * reasonably affect creatures that are ususally immune to wither effects). + * {@link DamageType#MAGIC} for regular, non-elemental magic damage (sometimes you might not want an element + * even though the spell has one - for example, not all necromancy spells are 'withery', so some of them + * might reasonably affect creatures that are ususally immune to wither effects). * @return A damagesource object of type EntityDamageSource */ public static DamageSource causeDirectMagicDamage(Entity caster, DamageType type){ return causeDirectMagicDamage(caster, type, false); } - + /** * Returns a DamageSource called "wizardryMagic" with the given entity as the caster. Use in preference to vanilla - * types to allow things to distinguish between magic and regular melee/swords. Unlike DamageSource.magic, it does + * types to allow things to distinguish between magic and regular melee/swords. Unlike DamageSource.MAGIC, it does * not bypass armour and has a player as the source (rather than nothing). It is still classed as magic damage (for * the record, all this does in vanilla is make witches 85% resistant to it - but that seems kinda right anyway). *

    - * Now that this is its own class, this static method is largely redundant, but it's not worth refactoring the entire - * mod just to get rid of this method and use the constructor instead. + * Now that this is its own class, this static method is largely redundant, but it's not worth refactoring the + * entire mod just to get rid of this method and use the constructor instead. + * * @param caster The player or other living entity causing the damage * @param type The type that this damage belongs to; used for resistances and wand perks. Use - * {@link DamageType#MAGIC} for regular, non-elemental magic damage (sometimes you might not want an element - * even though the spell has one - for example, not all necromancy spells are 'withery', so some of them might - * reasonably affect creatures that are ususally immune to wither effects). - * @param isRetaliatory whether this damage source came from a retaliatory attack; prevents infinite loops - * occurring when two entities damage each other with retaliatory effects. + * {@link DamageType#MAGIC} for regular, non-elemental magic damage (sometimes you might not want an element + * even though the spell has one - for example, not all necromancy spells are 'withery', so some of them + * might reasonably affect creatures that are ususally immune to wither effects). + * @param isRetaliatory whether this damage source came from a retaliatory attack; prevents infinite loops occurring + * when two entities damage each other with retaliatory effects. * @return A damagesource object of type EntityDamageSource */ public static DamageSource causeDirectMagicDamage(Entity caster, DamageType type, boolean isRetaliatory){ return new MagicDamage(DIRECT_MAGIC_DAMAGE, caster, type, isRetaliatory); } - + /** * Returns a DamageSource called "indirectWizardryMagic" with the player as the caster. Use in preference to vanilla * types to allow things to distinguish between magic and regular arrows/throwables. Unlike @@ -215,39 +221,42 @@ public class MagicDamage extends EntityDamageSource implements IElementalDamage * record, all this does in vanilla is make witches 85% resistant to it - but that seems kinda right anyway). * isRetaliatory defaults to false. *

    - * Now that this is its own class, this static method is largely redundant, but it's not worth refactoring the entire - * mod just to get rid of this method and use the constructor instead. + * Now that this is its own class, this static method is largely redundant, but it's not worth refactoring the + * entire mod just to get rid of this method and use the constructor instead. + * * @param magic The entity that actually caused the damage * @param caster The player or other living entity that cast the spell originally * @param type The type that this damage belongs to; used for resistances and wand perks. Use - * {@link DamageType#MAGIC} for regular, non-elemental magic damage (sometimes you might not want an element - * even though the spell has one - for example, not all necromancy spells are 'withery', so some of them might - * reasonably affect creatures that are ususally immune to wither effects). + * {@link DamageType#MAGIC} for regular, non-elemental magic damage (sometimes you might not want an element + * even though the spell has one - for example, not all necromancy spells are 'withery', so some of them + * might reasonably affect creatures that are ususally immune to wither effects). * @return A damagesource object of type EntityDamageSourceIndirect */ public static DamageSource causeIndirectMagicDamage(Entity magic, Entity caster, DamageType type){ return causeIndirectMagicDamage(magic, caster, type, false); } - + /** * Returns a DamageSource called "indirectWizardryMagic" with the player as the caster. Use in preference to vanilla * types to allow things to distinguish between magic and regular arrows/throwables. Unlike * DamageSource.causeIndirectMagicDamage, it does not bypass armour. It is still classed as magic damage (for the * record, all this does in vanilla is make witches 85% resistant to it - but that seems kinda right anyway). *

    - * Now that this is its own class, this static method is largely redundant, but it's not worth refactoring the entire - * mod just to get rid of this method and use the constructor instead. + * Now that this is its own class, this static method is largely redundant, but it's not worth refactoring the + * entire mod just to get rid of this method and use the constructor instead. + * * @param magic The entity that actually caused the damage * @param caster The player or other living entity that cast the spell originally * @param type The type that this damage belongs to; used for resistances and wand perks. Use - * {@link DamageType#MAGIC} for regular, non-elemental magic damage (sometimes you might not want an element - * even though the spell has one - for example, not all necromancy spells are 'withery', so some of them might - * reasonably affect creatures that are ususally immune to wither effects). - * @param isRetaliatory whether this damage source came from a retaliatory attack; prevents infinite loops - * occurring when two entities damage each other with retaliatory effects. + * {@link DamageType#MAGIC} for regular, non-elemental magic damage (sometimes you might not want an element + * even though the spell has one - for example, not all necromancy spells are 'withery', so some of them + * might reasonably affect creatures that are ususally immune to wither effects). + * @param isRetaliatory whether this damage source came from a retaliatory attack; prevents infinite loops occurring + * when two entities damage each other with retaliatory effects. * @return A damagesource object of type EntityDamageSourceIndirect */ - public static DamageSource causeIndirectMagicDamage(Entity magic, Entity caster, DamageType type, boolean isRetaliatory){ + public static DamageSource causeIndirectMagicDamage(Entity magic, Entity caster, DamageType type, + boolean isRetaliatory){ return new IndirectMagicDamage(INDIRECT_MAGIC_DAMAGE, magic, caster, type, isRetaliatory); } diff --git a/src/main/java/electroblob/wizardry/util/MinionDamage.java b/src/main/java/electroblob/wizardry/util/MinionDamage.java index 987baf88..e308327e 100644 --- a/src/main/java/electroblob/wizardry/util/MinionDamage.java +++ b/src/main/java/electroblob/wizardry/util/MinionDamage.java @@ -12,21 +12,22 @@ import net.minecraft.util.text.TextComponentTranslation; * display the minion's name rather than the caster's. The event handler deals with all damage dealt by summoned * creatures, so it's very unlikely that this will be needed anywhere else. If for some reason it is, note that * knockback has to be removed and re-applied after the damage is dealt. + * * @author Electroblob * @since Wizardry 1.2 * @see IndirectMinionDamage */ public class MinionDamage extends IndirectMagicDamage { - public MinionDamage(String name, Entity minion, Entity caster, DamageType type, boolean isRetaliatory) { + public MinionDamage(String name, Entity minion, Entity caster, DamageType type, boolean isRetaliatory){ super(name, minion, caster, type, isRetaliatory); } - + @Override - public ITextComponent getDeathMessage(EntityLivingBase victim) { + public ITextComponent getDeathMessage(EntityLivingBase victim){ ITextComponent itextcomponent = this.damageSourceEntity.getDisplayName(); - String key = "death.attack." + this.damageType; - return new TextComponentTranslation(key, victim.getDisplayName(), itextcomponent); + String key = "death.attack." + this.damageType; + return new TextComponentTranslation(key, victim.getDisplayName(), itextcomponent); } } diff --git a/src/main/java/electroblob/wizardry/util/SpellModifiers.java b/src/main/java/electroblob/wizardry/util/SpellModifiers.java index 996b6fd6..8e840226 100644 --- a/src/main/java/electroblob/wizardry/util/SpellModifiers.java +++ b/src/main/java/electroblob/wizardry/util/SpellModifiers.java @@ -12,21 +12,22 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fml.common.network.ByteBufUtils; /** - * Object that wraps any number of spell modifiers into one, allowing for expandability within the Spell#cast - * methods. This class is essentially a glorified {@link Map} which can be written to and read from a {@link ByteBuf}. - * It is possible to calculate spell modifiers from wand NBT within the cast methods, but this is cumbersome and does - * not allow the modifiers to be sent to the client, which is sometimes necessary (for example, detonate needs to know - * about range modifiers on the client side or the particles wouldn't show outside of the base range). + * Object that wraps any number of spell modifiers into one, allowing for expandability within the Spell#cast methods. + * This class is essentially a glorified {@link Map} which can be written to and read from a {@link ByteBuf}. It is + * possible to calculate spell modifiers from wand NBT within the cast methods, but this is cumbersome and does not + * allow the modifiers to be sent to the client, which is sometimes necessary (for example, detonate needs to know about + * range modifiers on the client side or the particles wouldn't show outside of the base range). *

    - * Most external interaction with SpellModifiers objects will be in {@link SpellCastEvent.Pre}, where you can add additional - * modifiers to them if desired for use with your own spells, or modify the existing ones. If you have added a wand - * upgrade, this is not done automatically for you; you will have to do it yourself (for the simple reason that - * not all wand upgrades affect spells). SpellModifiers objects are mutable, so you can simply change the values - * they contain to modify the spell. + * Most external interaction with SpellModifiers objects will be in {@link SpellCastEvent.Pre}, where you can add + * additional modifiers to them if desired for use with your own spells, or modify the existing ones. If you have added + * a wand upgrade, this is not done automatically for you; you will have to do it yourself (for the simple reason + * that not all wand upgrades affect spells). SpellModifiers objects are mutable, so you can simply change the + * values they contain to modify the spell. *

    * To use a SpellModifiers object within the Spell.cast methods, simply retrieve the desired multiplier - * using {@link SpellModifiers#get(Item)} for wand upgrades, or {@link SpellModifiers#get(String)} if the multiplier - * is not from a wand upgrade. + * using {@link SpellModifiers#get(Item)} for wand upgrades, or {@link SpellModifiers#get(String)} if the multiplier is + * not from a wand upgrade. + * * @author Electroblob * @since Wizardry 1.2 * @see WandHelper @@ -36,45 +37,49 @@ import net.minecraftforge.fml.common.network.ByteBufUtils; // would mean they have to be registered, and part of the point of SpellModifiers is that they can be added to on the // fly. public final class SpellModifiers { - + /** Constant string identifier for the damage modifier. All the other modifiers in Wizardry have items. */ public static final String DAMAGE = "damage"; private Map multiplierMap; private Map syncedMultiplierMap; - - /** Creates an empty SpellModifiers object. All calls to get(...) on an empty SpellModifiers object - * will return a value of 1. */ + + /** + * Creates an empty SpellModifiers object. All calls to get(...) on an empty SpellModifiers object will + * return a value of 1. + */ public SpellModifiers(){ multiplierMap = new HashMap(); syncedMultiplierMap = new HashMap(); } - + /** - * Adds the given multiplier to this SpellModifiers object, using the string identifier that the given wand - * upgrade item was registered with. + * Adds the given multiplier to this SpellModifiers object, using the string identifier that the given wand upgrade + * item was registered with. + * * @throws IllegalArgumentException if the given item is not a registered special wand upgrade. * @param upgrade The upgrade item the multiplier corresponds to. * @param multiplier The multiplier value, with 1 being default. Usage of modifiers is up to individual spells to - * implement. + * implement. * @param needsSyncing Whether this multiplier should be synchronised with the client via packets. Only set this - * to true if particles will be spawned which need to know the value of the multiplier. + * to true if particles will be spawned which need to know the value of the multiplier. * @return The SpellModifiers object, allowing this method to be chained onto the constructor. */ public SpellModifiers set(Item upgrade, float multiplier, boolean needsSyncing){ this.set(WandHelper.getIdentifier(upgrade), multiplier, needsSyncing); return this; } - + /** * Adds the given multiplier to this SpellModifiers object, using the given string key. In most cases, the * multiplier will correspond to a wand upgrade, in which case use {@link SpellModifiers#set(Item, float, boolean)} * instead. + * * @param key The key used to identify the multiplier. * @param multiplier The multiplier value, with 1 being default. Usage of modifiers is up to individual spells to - * implement. + * implement. * @param needsSyncing Whether this multiplier should be synchronised with the client via packets. Only set this - * to true if particles will be spawned which depend on the multiplier. + * to true if particles will be spawned which depend on the multiplier. * @return The SpellModifiers object, allowing this method to be chained onto the constructor. */ public SpellModifiers set(String key, float multiplier, boolean needsSyncing){ @@ -82,38 +87,44 @@ public final class SpellModifiers { if(needsSyncing) syncedMultiplierMap.put(key, multiplier); return this; } - - /** Returns the multiplier corresponding to the given wand upgrade item, or 1 if no multiplier was stored. - * @throws IllegalArgumentException if the given item is not a registered special wand upgrade. */ + + /** + * Returns the multiplier corresponding to the given wand upgrade item, or 1 if no multiplier was stored. + * + * @throws IllegalArgumentException if the given item is not a registered special wand upgrade. + */ public float get(Item upgrade){ return get(WandHelper.getIdentifier(upgrade)); } - - /** Returns the multiplier corresponding to the given string key, or 1 if no multiplier was stored. In most cases, - * the multiplier will correspond to a wand upgrade, in which case use {@link SpellModifiers#get(Item)} - * instead. */ + + /** + * Returns the multiplier corresponding to the given string key, or 1 if no multiplier was stored. In most cases, + * the multiplier will correspond to a wand upgrade, in which case use {@link SpellModifiers#get(Item)} instead. + */ public float get(String key){ Float value = multiplierMap.get(key); // Must check for null before unboxing, and if it is null, return the default 1. return value == null ? 1 : value; } - - /** Returns an unmodifiable map of the modifiers stored in this SpellModifiers object. Useful for iterating through - * the modifiers. */ + + /** + * Returns an unmodifiable map of the modifiers stored in this SpellModifiers object. Useful for iterating through + * the modifiers. + */ public Map getModifiers(){ return Collections.unmodifiableMap(this.multiplierMap); } - + /** Removes all modifiers from this SpellModifiers object, effectively resetting them all to 1. */ public void reset(){ this.multiplierMap.clear(); this.syncedMultiplierMap.clear(); } - + /** Reads this SpellModifiers object from the given ByteBuf. */ public void read(ByteBuf buf){ int entryCount = buf.readInt(); - for(int i=0; i{damage:1.5, range:2}

    - * Note that needsSyncing is set to true for all returned modifiers. */ + + /** + * Creates a new SpellModifiers object from the given NBTTagCompound. The NBTTagCompound should have 1 or more float + * tags, which will be stored as modifiers under the same name as the tag. For example, the following NBT tag (in + * command syntax) will create a SpellModifiers object with a damage modifier of 1.5 and a range modifier of 2: + *

    + * {damage:1.5, range:2} + *

    + * Note that needsSyncing is set to true for all returned modifiers. + */ public static SpellModifiers fromNBT(NBTTagCompound nbt){ SpellModifiers modifiers = new SpellModifiers(); for(String key : nbt.getKeySet()){ diff --git a/src/main/java/electroblob/wizardry/util/WandHelper.java b/src/main/java/electroblob/wizardry/util/WandHelper.java index 15c0466b..d21aa8ac 100644 --- a/src/main/java/electroblob/wizardry/util/WandHelper.java +++ b/src/main/java/electroblob/wizardry/util/WandHelper.java @@ -11,29 +11,32 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -/** Much like {@link net.minecraft.enchantment.EnchantmentHelper EnchantmentHelper}, this class has some static methods +/** + * Much like {@link net.minecraft.enchantment.EnchantmentHelper EnchantmentHelper}, this class has some static methods * which allow cleaner and more concise interaction with the wand NBT data, which is quite a complex structure. Such - * interaction previously resulted in rather verbose and repetitive code which was hard to read and even harder to debug! - * For example, this class allowed {@link electroblob.wizardry.item.ItemWand ItemWand} to be shortened by about 80 lines. - * In addition, by having all the various null checks and array size checks in one place, the chance of accidental errors - * due to forgetting to check these things is greatly reduced. + * interaction previously resulted in rather verbose and repetitive code which was hard to read and even harder to + * debug! For example, this class allowed {@link electroblob.wizardry.item.ItemWand ItemWand} to be shortened by about + * 80 lines. In addition, by having all the various null checks and array size checks in one place, the chance of + * accidental errors due to forgetting to check these things is greatly reduced. *

    * Note that these methods contain no game logic at all; they are purely for interacting with the NBT data. Conversely, * you should never need to access the wand's NBT data directly when using this class, but the keys are public in the * unlikely case that this is necessary. *

    * Also note that none of the methods in this class actually check that the given ItemStack contains an ItemWand; you - * can, for example, pass in a stack of snowballs without causing problems, but that is of course pointless! However, - * if you have your own spell casting item (which doesn't extend ItemWand), this setup means you can still use this class + * can, for example, pass in a stack of snowballs without causing problems, but that is of course pointless! However, if + * you have your own spell casting item (which doesn't extend ItemWand), this setup means you can still use this class * to manage its NBT structure. *

    - * All get methods in this class return some kind of default if the passed-in wand stack has no nbt data. - * See individual method descriptions for more details.
    - * All set methods in this class create a new nbt data for the passed-in wand if it has none, before doing + * All get methods in this class return some kind of default if the passed-in wand stack has no nbt data. See + * individual method descriptions for more details.
    + * All set methods in this class create a new nbt data for the passed-in wand if it has none, before doing * whatever else they do. + * * @see electroblob.wizardry.item.ItemWand ItemWand * @see electroblob.wizardry.packet.PacketControlInput PacketControlInput - * @since Wizardry 1.1 */ + * @since Wizardry 1.1 + */ public final class WandHelper { // NBT tag keys @@ -44,7 +47,7 @@ public final class WandHelper { private static final HashMap upgradeMap = new HashMap(); - static { + static{ upgradeMap.put(WizardryItems.condenser_upgrade, "condenser"); upgradeMap.put(WizardryItems.storage_upgrade, "storage"); upgradeMap.put(WizardryItems.siphon_upgrade, "siphon"); @@ -55,9 +58,11 @@ public final class WandHelper { upgradeMap.put(WizardryItems.attunement_upgrade, "attunement"); } - /** Returns an array containing the spells currently bound to the given wand. As of Wizardry 1.1, this array is not + /** + * Returns an array containing the spells currently bound to the given wand. As of Wizardry 1.1, this array is not * always the same size; it can be anywhere between 5 and 8 (inclusive) in length. If the wand has no spell data, - * returns an array of length 0. */ + * returns an array of length 0. + */ public static Spell[] getSpells(ItemStack wand){ Spell[] spells = new Spell[0]; @@ -68,7 +73,7 @@ public final class WandHelper { spells = new Spell[spellIDs.length]; - for(int i=0; i= numberOfSpells - 1){ @@ -124,36 +132,38 @@ public final class WandHelper { }else{ selectedSpell++; } - + wand.getTagCompound().setInteger(SELECTED_SPELL_KEY, selectedSpell); - + } } - + /** Selects the previous spell in this wand's list of spells. */ public static void selectPreviousSpell(ItemStack wand){ - + // 5 here because if the spell array doesn't exist, the wand can't possibly have attunement upgrades if(getSpells(wand).length < 0) setSpells(wand, new Spell[5]); // This cannot possibly be null here, and yet I am getting an NPE... if(wand.getTagCompound() != null){ - + int numberOfSpells = getSpells(wand).length; int selectedSpell = wand.getTagCompound().getInteger(SELECTED_SPELL_KEY); - + if(selectedSpell <= 0){ selectedSpell = numberOfSpells - 1; }else{ selectedSpell--; } - + wand.getTagCompound().setInteger(SELECTED_SPELL_KEY, selectedSpell); } } - /** Returns an array of the cooldowns for each spell bound to the given wand. As of Wizardry 1.1, this array is not + /** + * Returns an array of the cooldowns for each spell bound to the given wand. As of Wizardry 1.1, this array is not * always the same size; it can be anywhere between 5 and 8 (inclusive) in length. If the wand has no cooldown data, - * returns an array of length 0. */ + * returns an array of length 0. + */ public static int[] getCooldowns(ItemStack wand){ int[] cooldowns = new int[0]; @@ -182,7 +192,7 @@ public final class WandHelper { // If there are no cooldowns, it is assumed that they are all zero and therefore nothing needs to be done. if(cooldowns.length == 0) return; - for(int i=0; i 0) cooldowns[i]--; } @@ -215,8 +225,10 @@ public final class WandHelper { setCooldowns(wand, cooldowns); } - /** Returns the number of upgrades of the given type that have been applied to the given wand, or 0 if the wand has - * no upgrade data or the given item is not a valid wand upgrade. */ + /** + * Returns the number of upgrades of the given type that have been applied to the given wand, or 0 if the wand has + * no upgrade data or the given item is not a valid wand upgrade. + */ public static int getUpgradeLevel(ItemStack wand, Item upgrade){ String key = upgradeMap.get(upgrade); @@ -229,8 +241,10 @@ public final class WandHelper { } - /** Returns the total number of upgrades that have been applied to the given wand, or 0 if the wand has no upgrade - * data. */ + /** + * Returns the total number of upgrades that have been applied to the given wand, or 0 if the wand has no upgrade + * data. + */ public static int getTotalUpgrades(ItemStack wand){ int totalUpgrades = 0; @@ -242,13 +256,16 @@ public final class WandHelper { return totalUpgrades; } - /** Applies the given upgrade to the given wand, or in other words increases the level for that upgrade by 1. This - * does not account for the individual or total upgrade stack limits. */ + /** + * Applies the given upgrade to the given wand, or in other words increases the level for that upgrade by 1. This + * does not account for the individual or total upgrade stack limits. + */ public static void applyUpgrade(ItemStack wand, Item upgrade){ if(wand.getTagCompound() == null) wand.setTagCompound((new NBTTagCompound())); - if(!wand.getTagCompound().hasKey(UPGRADES_KEY)) wand.getTagCompound().setTag(UPGRADES_KEY, new NBTTagCompound()); + if(!wand.getTagCompound().hasKey(UPGRADES_KEY)) + wand.getTagCompound().setTag(UPGRADES_KEY, new NBTTagCompound()); NBTTagCompound upgrades = wand.getTagCompound().getCompoundTag(UPGRADES_KEY); @@ -258,35 +275,42 @@ public final class WandHelper { wand.getTagCompound().setTag(UPGRADES_KEY, upgrades); } - + /** Returns true if the given item is a valid special wand upgrade. */ public static boolean isWandUpgrade(Item upgrade){ return upgradeMap.containsKey(upgrade); } - + /** Returns an unmodifiable set of all the items which are valid special wand upgrades. */ public static Set getSpecialUpgrades(){ return Collections.unmodifiableSet(WandHelper.upgradeMap.keySet()); } - - /** Package-protected getter for the identifier that corresponds to the given item, used only in the + + /** + * Package-protected getter for the identifier that corresponds to the given item, used only in the * {@link SpellModifiers} class. Internal to Wizardry. - * @throws IllegalArgumentException if the given item is not a registered special wand upgrade.*/ + * + * @throws IllegalArgumentException if the given item is not a registered special wand upgrade. + */ static String getIdentifier(Item upgrade){ - if(!isWandUpgrade(upgrade)) throw new IllegalArgumentException("Tried to get a wand upgrade key for an item" - + "that is not a registered special wand upgrade."); + if(!isWandUpgrade(upgrade)) throw new IllegalArgumentException( + "Tried to get a wand upgrade key for an item" + "that is not a registered special wand upgrade."); return upgradeMap.get(upgrade); } - - /** Registers a special upgrade with wizardry. Not used in the base mod, but I've put it here to make it easy - * for add-ons to add new wand upgrades. + + /** + * Registers a special upgrade with wizardry. Not used in the base mod, but I've put it here to make it easy for + * add-ons to add new wand upgrades. + * * @param upgrade The wand upgrade item * @param identifier A unique string, used as a key for wand nbt tags - * @throws IllegalArgumentException if the passed in identifier is already used for another wand upgrade */ + * @throws IllegalArgumentException if the passed in identifier is already used for another wand upgrade + */ public static void registerSpecialUpgrade(Item upgrade, String identifier){ // Throwing an exception is the best thing to do here, since if a duplicate was allowed weird things would // happen later with wand NBT. - if(upgradeMap.containsValue(identifier)) throw new IllegalArgumentException("Duplicate wand upgrade identifier: " + identifier); + if(upgradeMap.containsValue(identifier)) + throw new IllegalArgumentException("Duplicate wand upgrade identifier: " + identifier); upgradeMap.put(upgrade, identifier); } } diff --git a/src/main/java/electroblob/wizardry/util/WizardryParticleType.java b/src/main/java/electroblob/wizardry/util/WizardryParticleType.java index 53093f2c..2be30685 100644 --- a/src/main/java/electroblob/wizardry/util/WizardryParticleType.java +++ b/src/main/java/electroblob/wizardry/util/WizardryParticleType.java @@ -1,19 +1,9 @@ package electroblob.wizardry.util; -/** Enum constants representing the different types of particle added by wizardry. This was renamed from the previous - * EnumParticleType in the 1.10.2 port to avoid confusion with the vanilla version, EnumParticleTypes. */ +/** + * Enum constants representing the different types of particle added by wizardry. This was renamed from the previous + * EnumParticleType in the 1.10.2 port to avoid confusion with the vanilla version, EnumParticleTypes. + */ public enum WizardryParticleType { - BLIZZARD, - BRIGHT_DUST, - DARK_MAGIC, - DUST, - ICE, - LEAF, - MAGIC_BUBBLE, - MAGIC_FIRE, - PATH, - SNOW, - SPARK, - SPARKLE, - SPARKLE_ROTATING + BLIZZARD, BRIGHT_DUST, DARK_MAGIC, DUST, ICE, LEAF, MAGIC_BUBBLE, MAGIC_FIRE, PATH, SNOW, SPARK, SPARKLE, SPARKLE_ROTATING } diff --git a/src/main/java/electroblob/wizardry/util/WizardryPathFinder.java b/src/main/java/electroblob/wizardry/util/WizardryPathFinder.java index 2a431b38..62db6b2c 100644 --- a/src/main/java/electroblob/wizardry/util/WizardryPathFinder.java +++ b/src/main/java/electroblob/wizardry/util/WizardryPathFinder.java @@ -15,124 +15,128 @@ import net.minecraft.pathfinding.PathPoint; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; -/** Minecraft's pathfinder refused to play nicely, so I 'borrowed' its code and fiddled with it. Currently this is only - * used for the {@link Clairvoyance} spell. */ +/** + * Minecraft's pathfinder refused to play nicely, so I 'borrowed' its code and fiddled with it. Currently this is only + * used for the {@link Clairvoyance} spell. + */ public class WizardryPathFinder { - - /** The path being generated */ - private final PathHeap path = new PathHeap(); - private final Set closedSet = Sets.newHashSet(); - /** Selection of path points to add to the path */ - private final PathPoint[] pathOptions = new PathPoint[32]; - private final NodeProcessor nodeProcessor; - public WizardryPathFinder(NodeProcessor processor){ - this.nodeProcessor = processor; - } - - @Nullable - public Path findPath(IBlockAccess world, EntityLiving entity, BlockPos destination, float range){ - return this.findPath(world, entity, (double)((float)destination.getX() + 0.5F), (double)((float)destination.getY() + 0.5F), (double)((float)destination.getZ() + 0.5F), range); - } + /** The path being generated */ + private final PathHeap path = new PathHeap(); + private final Set closedSet = Sets.newHashSet(); + /** Selection of path points to add to the path */ + private final PathPoint[] pathOptions = new PathPoint[32]; + private final NodeProcessor nodeProcessor; - @Nullable - private Path findPath(IBlockAccess world, EntityLiving entity, double x, double y, double z, float range){ - this.path.clearPath(); - this.nodeProcessor.initProcessor(world, entity); - PathPoint pathpoint = this.nodeProcessor.getStart(); - PathPoint pathpoint1 = this.nodeProcessor.getPathPointToCoords(x, y, z); - Path path = this.findPath(pathpoint, pathpoint1, range); - this.nodeProcessor.postProcess(); - return path; - } + public WizardryPathFinder(NodeProcessor processor){ + this.nodeProcessor = processor; + } - @Nullable - private Path findPath(PathPoint start, PathPoint end, float range){ - - start.totalPathDistance = 0.0F; - start.distanceToNext = start.distanceManhattan(end); - start.distanceToTarget = start.distanceToNext; - this.path.clearPath(); - this.closedSet.clear(); - this.path.addPoint(start); - PathPoint pathpoint = start; - int i = 0; + @Nullable + public Path findPath(IBlockAccess world, EntityLiving entity, BlockPos destination, float range){ + return this.findPath(world, entity, (double)((float)destination.getX() + 0.5F), + (double)((float)destination.getY() + 0.5F), (double)((float)destination.getZ() + 0.5F), range); + } - while(!this.path.isPathEmpty()){ - - ++i; + @Nullable + private Path findPath(IBlockAccess world, EntityLiving entity, double x, double y, double z, float range){ + this.path.clearPath(); + this.nodeProcessor.initProcessor(world, entity); + PathPoint pathpoint = this.nodeProcessor.getStart(); + PathPoint pathpoint1 = this.nodeProcessor.getPathPointToCoords(x, y, z); + Path path = this.findPath(pathpoint, pathpoint1, range); + this.nodeProcessor.postProcess(); + return path; + } - // This is the offending line - timeout limit changed from 200 to 5000. - if(i >= 5000){ - break; - } + @Nullable + private Path findPath(PathPoint start, PathPoint end, float range){ - PathPoint pathpoint1 = this.path.dequeue(); + start.totalPathDistance = 0.0F; + start.distanceToNext = start.distanceManhattan(end); + start.distanceToTarget = start.distanceToNext; + this.path.clearPath(); + this.closedSet.clear(); + this.path.addPoint(start); + PathPoint pathpoint = start; + int i = 0; - if(pathpoint1.equals(end)){ - pathpoint = end; - break; - } + while(!this.path.isPathEmpty()){ - if(pathpoint1.distanceManhattan(end) < pathpoint.distanceManhattan(end)){ - pathpoint = pathpoint1; - } + ++i; - pathpoint1.visited = true; - int j = this.nodeProcessor.findPathOptions(this.pathOptions, pathpoint1, end, range); + // This is the offending line - timeout limit changed from 200 to 5000. + if(i >= 5000){ + break; + } - for(int k = 0; k < j; ++k){ - - PathPoint pathpoint2 = this.pathOptions[k]; - float f = pathpoint1.distanceManhattan(pathpoint2); - pathpoint2.distanceFromOrigin = pathpoint1.distanceFromOrigin + f; - pathpoint2.cost = f + pathpoint2.costMalus; - float f1 = pathpoint1.totalPathDistance + pathpoint2.cost; + PathPoint pathpoint1 = this.path.dequeue(); - if(pathpoint2.distanceFromOrigin < range && (!pathpoint2.isAssigned() || f1 < pathpoint2.totalPathDistance)){ - - pathpoint2.previous = pathpoint1; - pathpoint2.totalPathDistance = f1; - pathpoint2.distanceToNext = pathpoint2.distanceManhattan(end) + pathpoint2.costMalus; + if(pathpoint1.equals(end)){ + pathpoint = end; + break; + } - if(pathpoint2.isAssigned()){ - this.path.changeDistance(pathpoint2, pathpoint2.totalPathDistance + pathpoint2.distanceToNext); - }else{ - pathpoint2.distanceToTarget = pathpoint2.totalPathDistance + pathpoint2.distanceToNext; - this.path.addPoint(pathpoint2); - } - } - } - } + if(pathpoint1.distanceManhattan(end) < pathpoint.distanceManhattan(end)){ + pathpoint = pathpoint1; + } - if(pathpoint == start){ - return null; - }else{ - Path path = this.createEntityPath(start, pathpoint); - return path; - } - } + pathpoint1.visited = true; + int j = this.nodeProcessor.findPathOptions(this.pathOptions, pathpoint1, end, range); - /** - * Returns a new PathEntity for a given start and end point - */ - private Path createEntityPath(PathPoint start, PathPoint end){ - - int i = 1; + for(int k = 0; k < j; ++k){ - for(PathPoint pathpoint = end; pathpoint.previous != null; pathpoint = pathpoint.previous){ - ++i; - } + PathPoint pathpoint2 = this.pathOptions[k]; + float f = pathpoint1.distanceManhattan(pathpoint2); + pathpoint2.distanceFromOrigin = pathpoint1.distanceFromOrigin + f; + pathpoint2.cost = f + pathpoint2.costMalus; + float f1 = pathpoint1.totalPathDistance + pathpoint2.cost; - PathPoint[] points = new PathPoint[i]; - PathPoint pathpoint1 = end; - --i; + if(pathpoint2.distanceFromOrigin < range + && (!pathpoint2.isAssigned() || f1 < pathpoint2.totalPathDistance)){ - for(points[i] = end; pathpoint1.previous != null; points[i] = pathpoint1){ - pathpoint1 = pathpoint1.previous; - --i; - } + pathpoint2.previous = pathpoint1; + pathpoint2.totalPathDistance = f1; + pathpoint2.distanceToNext = pathpoint2.distanceManhattan(end) + pathpoint2.costMalus; - return new Path(points); - } + if(pathpoint2.isAssigned()){ + this.path.changeDistance(pathpoint2, pathpoint2.totalPathDistance + pathpoint2.distanceToNext); + }else{ + pathpoint2.distanceToTarget = pathpoint2.totalPathDistance + pathpoint2.distanceToNext; + this.path.addPoint(pathpoint2); + } + } + } + } + + if(pathpoint == start){ + return null; + }else{ + Path path = this.createEntityPath(start, pathpoint); + return path; + } + } + + /** + * Returns a new PathEntity for a given start and end point + */ + private Path createEntityPath(PathPoint start, PathPoint end){ + + int i = 1; + + for(PathPoint pathpoint = end; pathpoint.previous != null; pathpoint = pathpoint.previous){ + ++i; + } + + PathPoint[] points = new PathPoint[i]; + PathPoint pathpoint1 = end; + --i; + + for(points[i] = end; pathpoint1.previous != null; points[i] = pathpoint1){ + pathpoint1 = pathpoint1.previous; + --i; + } + + return new Path(points); + } } \ No newline at end of file diff --git a/src/main/java/electroblob/wizardry/util/WizardryUtilities.java b/src/main/java/electroblob/wizardry/util/WizardryUtilities.java index a1cfb659..189a02b2 100644 --- a/src/main/java/electroblob/wizardry/util/WizardryUtilities.java +++ b/src/main/java/electroblob/wizardry/util/WizardryUtilities.java @@ -43,6 +43,7 @@ import net.minecraft.network.datasync.DataParameter; import net.minecraft.server.MinecraftServer; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumFacing; +import net.minecraft.util.NonNullList; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.AxisAlignedBB; @@ -55,7 +56,8 @@ import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -/** This class contains some useful static methods for use anywhere - items, entities, spells, events, blocks, etc. +/** + * This class contains some useful static methods for use anywhere - items, entities, spells, events, blocks, etc. * Broadly speaking, these fall into the following categories: *

    * - In-world utilities (position calculating, retrieving entities, etc.)
    @@ -64,35 +66,41 @@ import net.minecraftforge.fml.relauncher.SideOnly; * - NBT and data storage utilities
    * - Interaction with the ally designation system
    * - Loot and weighting utilities + * * @see CommonProxy * @see WandHelper * @since Wizardry 1.0 - * @author Electroblob */ + * @author Electroblob + */ public final class WizardryUtilities { - - /** Constant which is simply an array of the four armour slots. (Could've sworn this exists somewhere in - * vanilla, but I can't find it anywhere...) */ + + /** + * Constant which is simply an array of the four armour slots. (Could've sworn this exists somewhere in vanilla, but + * I can't find it anywhere...) + */ public static final EntityEquipmentSlot[] ARMOUR_SLOTS; /** Changed to a constant in wizardry 2.1, since this is a lot more efficient. */ private static final DataParameter POWERED; - - static { + + static{ // The list of slots needs to be mutable. - List slots = new ArrayList(Arrays.asList(EntityEquipmentSlot.values())); + List slots = new ArrayList( + Arrays.asList(EntityEquipmentSlot.values())); slots.removeIf(slot -> slot.getSlotType() != Type.ARMOR); ARMOUR_SLOTS = slots.toArray(new EntityEquipmentSlot[0]); - + // Null is passed in deliberately since POWERED is a static field. POWERED = ReflectionHelper.getPrivateValue(EntityCreeper.class, null, "POWERED", "field_184714_b"); } - + // SECTION Block/Entity/World Utilities // =============================================================================================================== /** - * Returns whether the block at the given coordinates can be replaced by another one (works as if a block is being placed by a player). - * True for air, liquids, vines, tall grass and snow layers but not for flowers, signs etc. + * Returns whether the block at the given coordinates can be replaced by another one (works as if a block is being + * placed by a player). True for air, liquids, vines, tall grass and snow layers but not for flowers, signs etc. * This is a shortcut for world.getBlockState(pos).getMaterial().isReplaceable(). + * * @see WizardryUtilities#canBlockBeReplacedB(World, BlockPos) */ public static boolean canBlockBeReplaced(World world, BlockPos pos){ @@ -100,9 +108,10 @@ public final class WizardryUtilities { } /** - * Returns whether the block at the given coordinates can be replaced by another one (works as if a block is being placed by a player) - * and is not a liquid. - * True for air, vines, tall grass and snow layers but not for flowers, signs etc. or any liquids. + * Returns whether the block at the given coordinates can be replaced by another one (works as if a block is being + * placed by a player) and is not a liquid. True for air, vines, tall grass and snow layers but not for flowers, + * signs etc. or any liquids. + * * @see WizardryUtilities#canBlockBeReplaced(World, BlockPos) */ public static boolean canBlockBeReplacedB(World world, BlockPos pos){ @@ -111,153 +120,169 @@ public final class WizardryUtilities { /** * Returns whether the block at the given coordinates is unbreakable in survival mode. In vanilla this is true for - * bedrock and end portal frame, for example. - * This is a shortcut for world.getBlockState(pos).getBlockHardness(world, pos) == -1.0f. - * Not much of a shortcut any more, since block ids have been phased out. + * bedrock and end portal frame, for example. This is a shortcut for + * world.getBlockState(pos).getBlockHardness(world, pos) == -1.0f. Not much of a shortcut any more, since block ids + * have been phased out. */ public static boolean isBlockUnbreakable(World world, BlockPos pos){ - return world.isAirBlock(new BlockPos(pos)) ? false : world.getBlockState(pos).getBlockHardness(world, pos) == -1.0f; + return world.isAirBlock(new BlockPos(pos)) ? false + : world.getBlockState(pos).getBlockHardness(world, pos) == -1.0f; } - + /** * Finds the nearest floor level to the given y coord within the range specified at the given x and z coords. - * Liquids and other blocks that cannot be built on top of do not count, but stuff like signs does. - * (Technically any block is allowed to be the floor according to the code, but seeing as it searches upwards and - * non-solid blocks usually need a supporting block, the floor is likely to always be solid). + * Liquids and other blocks that cannot be built on top of do not count, but stuff like signs does. (Technically any + * block is allowed to be the floor according to the code, but seeing as it searches upwards and non-solid blocks + * usually need a supporting block, the floor is likely to always be solid). + * * @param world * @param x The x coordinate to search in * @param y The y coordinate to search from * @param z The z coordinate to search in * @param range The maximum distance from the given y coordinate to search. - * @return The y coordinate of the closest floor level, or -1 if there is none. Returns the actual level of the floor - * as would be seen in the debug screen when the player is standing on it. + * @return The y coordinate of the closest floor level, or -1 if there is none. Returns the actual level of the + * floor as would be seen in the debug screen when the player is standing on it. * @see WizardryUtilities#getNearestFloorLevelB(World, BlockPos, int) */ public static int getNearestFloorLevel(World world, BlockPos pos, int range){ - + int yCoord = -2; for(int i = -range; i <= range; i++){ - // The last bit determines whether the block found to be a suitable floor is closer than the previous one found. - if(world.isSideSolid(pos.up(i), EnumFacing.UP) && (world.isAirBlock(pos.up(i+1)) || !world.isSideSolid(pos.up(i+1), EnumFacing.UP)) - && (i < yCoord-pos.getY() || yCoord == -2)){ + // The last bit determines whether the block found to be a suitable floor is closer than the previous one + // found. + if(world.isSideSolid(pos.up(i), EnumFacing.UP) + && (world.isAirBlock(pos.up(i + 1)) || !world.isSideSolid(pos.up(i + 1), EnumFacing.UP)) + && (i < yCoord - pos.getY() || yCoord == -2)){ + yCoord = pos.getY() + i; + } + } + return yCoord + 1; + } + + /** + * Finds the nearest floor level to the given y coord within the range specified at the given x and z coords. Only + * works if the block above the floor is actually air and the floor is solid or a liquid. + * + * @param world + * @param x The x coordinate to search in + * @param y The y coordinate to search from + * @param z The z coordinate to search in + * @param range The maximum distance from the given y coordinate to search. + * @return The y coordinate of the closest floor level, or -1 if there is none. Returns the actual level of the + * floor as would be seen in the debug screen when the player is standing on it. + * @see WizardryUtilities#getNearestFloorLevel(World, BlockPos, int) + */ + public static int getNearestFloorLevelB(World world, BlockPos pos, int range){ + int yCoord = -2; + for(int i = -range; i <= range; i++){ + if(world.isAirBlock(new BlockPos(pos.up(i + 1))) + && (world.getBlockState(pos.up(i)).getMaterial().isLiquid() + || world.isSideSolid(pos.up(i), EnumFacing.UP)) + && (i < yCoord - pos.getY() || yCoord == -2)){ + // The last bit determines whether the block found to be a suitable floor is closer than the previous + // one found. yCoord = pos.getY() + i; } } return yCoord + 1; } - /** - * Finds the nearest floor level to the given y coord within the range specified at the given x and z coords. - * Only works if the block above the floor is actually air and the floor is solid or a liquid. - * @param world - * @param x The x coordinate to search in - * @param y The y coordinate to search from - * @param z The z coordinate to search in - * @param range The maximum distance from the given y coordinate to search. - * @return The y coordinate of the closest floor level, or -1 if there is none. Returns the actual level of the floor - * as would be seen in the debug screen when the player is standing on it. - * @see WizardryUtilities#getNearestFloorLevel(World, BlockPos, int) - */ - public static int getNearestFloorLevelB(World world, BlockPos pos, int range){ - int yCoord = -2; - for(int i = -range; i <= range; i++){ - if(world.isAirBlock(new BlockPos(pos.up(i+1))) && (world.getBlockState(pos.up(i)).getMaterial().isLiquid() || world.isSideSolid(pos.up(i), EnumFacing.UP)) - && (i < yCoord-pos.getY() || yCoord == -2)){ - // The last bit determines whether the block found to be a suitable floor is closer than the previous one found. - yCoord = pos.getY() + i; - } - } - return yCoord + 1; - } - /** * Finds the nearest floor level to the given y coord within the range specified at the given x and z coords. * Everything that is not air is treated as floor, even stuff that can't be walked on. + * * @param world * @param x The x coordinate to search in * @param y The y coordinate to search from * @param z The z coordinate to search in * @param range The maximum distance from the given y coordinate to search. - * @return The y coordinate of the closest floor level, or -1 if there is none. Returns the actual level of the floor - * as would be seen in the debug screen when the player is standing on it. + * @return The y coordinate of the closest floor level, or -1 if there is none. Returns the actual level of the + * floor as would be seen in the debug screen when the player is standing on it. * @see WizardryUtilities#getNearestFloorLevel(World, BlockPos, int) */ public static int getNearestFloorLevelC(World world, BlockPos pos, int range){ int yCoord = -2; for(int i = -range; i <= range; i++){ - if(world.isAirBlock(new BlockPos(pos.up(i+1))) && (i < yCoord-pos.getY() || yCoord == -2)){ - // The last bit determines whether the block found to be a suitable floor is closer than the previous one found. + if(world.isAirBlock(new BlockPos(pos.up(i + 1))) && (i < yCoord - pos.getY() || yCoord == -2)){ + // The last bit determines whether the block found to be a suitable floor is closer than the previous + // one found. yCoord = pos.getY() + i; } } return yCoord + 1; } - + /** - * Gets a random position on the ground near the player within the specified horizontal and vertical ranges. Used - * to find a position to spawn entities in summoning spells. + * Gets a random position on the ground near the player within the specified horizontal and vertical ranges. Used to + * find a position to spawn entities in summoning spells. + * * @param entity The entity around which to search * @param horizontalRange The maximum number of blocks on the x or z axis the returned position can be from the - * given entity. The number of operations performed by this method is proportional to the square of this - * parameter, so for performance reasons it is recommended that it does not exceed around 10. + * given entity. The number of operations performed by this method is proportional to the square of this + * parameter, so for performance reasons it is recommended that it does not exceed around 10. * @param verticalRange The maximum number of blocks on the y axis the returned position can be from the given - * entity - * @return A BlockPos with the coordinates of the block directly above the ground at the position found, or null - * if none were found within range. Importantly, since this method checks all possible positions within - * range (i.e. randomness only occurs when deciding between the possible positions), if it returns null once - * then it will always return null given the same circumstances and parameters. What this means is that you can - * (and should) immediately stop trying to cast a summoning spell if this returns null. + * entity + * @return A BlockPos with the coordinates of the block directly above the ground at the position found, or null if + * none were found within range. Importantly, since this method checks all possible positions within + * range (i.e. randomness only occurs when deciding between the possible positions), if it returns null once + * then it will always return null given the same circumstances and parameters. What this means is that you + * can (and should) immediately stop trying to cast a summoning spell if this returns null. */ @Nullable public static BlockPos findNearbyFloorSpace(Entity entity, int horizontalRange, int verticalRange){ - - World world = entity.worldObj; + + World world = entity.world; List possibleLocations = new ArrayList(); BlockPos origin = new BlockPos(entity); - + for(int x = -horizontalRange; x <= horizontalRange; x++){ for(int z = -horizontalRange; z <= horizontalRange; z++){ int y = WizardryUtilities.getNearestFloorLevel(world, origin.add(x, 0, z), verticalRange); if(y > -1) possibleLocations.add(new BlockPos(origin.getX() + x, y, origin.getZ() + z)); } } - + if(possibleLocations.isEmpty()){ return null; }else{ return possibleLocations.get(world.rand.nextInt(possibleLocations.size())); } - + } /** - * Gets the blockstate of the block the specified entity is standing on. Uses {@link MathHelper#floor_double(double)} because casting to int will not - * return the correct coordinate when x or z is negative. + * Gets the blockstate of the block the specified entity is standing on. Uses + * {@link MathHelper#floor_double(double)} because casting to int will not return the correct coordinate when x or z + * is negative. */ public static IBlockState getBlockEntityIsStandingOn(Entity entity){ - BlockPos pos = new BlockPos(MathHelper.floor_double(entity.posX), (int)entity.getEntityBoundingBox().minY-1, MathHelper.floor_double(entity.posZ)); - return entity.worldObj.getBlockState(pos); + BlockPos pos = new BlockPos(MathHelper.floor(entity.posX), (int)entity.getEntityBoundingBox().minY - 1, + MathHelper.floor(entity.posZ)); + return entity.world.getBlockState(pos); } /** * Shorthand for {@link WizardryUtilities#getEntitiesWithinRadius(double, double, double, double, World, Class)} * with EntityLivingBase as the entity type. This is by far the most common use for that method, which is why this * shorthand exists. + * * @param radius The search radius * @param x The x coordinate to search around * @param y The y coordinate to search around * @param z The z coordinate to search around * @param world The world to search in */ - public static List getEntitiesWithinRadius(double radius, double x, double y, double z, World world){ + public static List getEntitiesWithinRadius(double radius, double x, double y, double z, + World world){ return getEntitiesWithinRadius(radius, x, y, z, world, EntityLivingBase.class); } /** - * Returns all entities of the specified type within the specified radius of the given coordinates. This is different to using - * a raw AABB because a raw AABB will search in a cube volume rather than a sphere. - * Note that this does not exclude any entities; if any specific entities are to be excluded this must be - * checked when iterating through the list. + * Returns all entities of the specified type within the specified radius of the given coordinates. This is + * different to using a raw AABB because a raw AABB will search in a cube volume rather than a sphere. Note that + * this does not exclude any entities; if any specific entities are to be excluded this must be checked when + * iterating through the list. + * * @see {@link WizardryUtilities#getEntitiesWithinRadius(double, double, double, double, World)} * @param radius The search radius * @param x The x coordinate to search around @@ -266,10 +291,11 @@ public final class WizardryUtilities { * @param world The world to search in * @param entityType The class of entity to search for; pass in Entity.class for all entities */ - public static List getEntitiesWithinRadius(double radius, double x, double y, double z, World world, Class entityType){ + public static List getEntitiesWithinRadius(double radius, double x, double y, double z, + World world, Class entityType){ AxisAlignedBB aabb = new AxisAlignedBB(x - radius, y - radius, z - radius, x + radius, y + radius, z + radius); List entityList = world.getEntitiesWithinAABB(entityType, aabb); - for(int i=0;i radius){ entityList.remove(i); } @@ -278,15 +304,16 @@ public final class WizardryUtilities { } /** - * Gets an entity from its UUID. Note that you should check this isn't null. If the UUID is known to belong - * to an EntityPlayer, use the more efficient {@link World#getPlayerEntityByUUID(UUID)} instead. + * Gets an entity from its UUID. Note that you should check this isn't null. If the UUID is known to belong to an + * EntityPlayer, use the more efficient {@link World#getPlayerEntityByUUID(UUID)} instead. + * * @param world The world the entity is in * @param id The entity's UUID * @return The Entity that has the given UUID, or null if no such entity exists in the specified world. */ @Nullable public static Entity getEntityByUUID(World world, UUID id){ - + for(Entity entity : world.loadedEntityList){ // This is a perfect example of where you need to use .equals() and not ==. For most applications, // this was unnoticeable until world reload because the UUID instance or entity instance is stored. @@ -297,98 +324,123 @@ public final class WizardryUtilities { } return null; } - + // No point allowing anything other than players for these methods since other entities can use Entity#playSound. - - /** Shortcut for {@link World#playSound(EntityPlayer, double, double, double, SoundEvent, SoundCategory, float, float)} - * where the player is null but the x, y and z coordinates are those of the passed in player. Use in preference to - * {@link EntityPlayer#playSound(SoundEvent, float, float)} if there are client-server discrepancies. */ - public static void playSoundAtPlayer(EntityPlayer player, SoundEvent sound, SoundCategory category, float volume, float pitch){ - player.worldObj.playSound(null, player.posX, player.posY, player.posZ, sound, category, volume, pitch); - } - - /** See {@link WizardryUtilities#playSoundAtPlayer(EntityPlayer, SoundEvent, SoundCategory, float, float)}. Category - * defaults to {@link SoundCategory#PLAYERS}. */ - public static void playSoundAtPlayer(EntityPlayer player, SoundEvent sound, float volume, float pitch){ - player.worldObj.playSound(null, player.posX, player.posY, player.posZ, sound, SoundCategory.PLAYERS, volume, pitch); - } - + /** - * Returns the entity riding the given entity, or null if there is none. Allows for neater code now that - * entities have a list of passengers, because it is necessary to check that the list is not null or empty first. + * Shortcut for + * {@link World#playSound(EntityPlayer, double, double, double, SoundEvent, SoundCategory, float, float)} where the + * player is null but the x, y and z coordinates are those of the passed in player. Use in preference to + * {@link EntityPlayer#playSound(SoundEvent, float, float)} if there are client-server discrepancies. + */ + public static void playSoundAtPlayer(EntityPlayer player, SoundEvent sound, SoundCategory category, float volume, + float pitch){ + player.world.playSound(null, player.posX, player.posY, player.posZ, sound, category, volume, pitch); + } + + /** + * See {@link WizardryUtilities#playSoundAtPlayer(EntityPlayer, SoundEvent, SoundCategory, float, float)}. Category + * defaults to {@link SoundCategory#PLAYERS}. + */ + public static void playSoundAtPlayer(EntityPlayer player, SoundEvent sound, float volume, float pitch){ + player.world.playSound(null, player.posX, player.posY, player.posZ, sound, SoundCategory.PLAYERS, volume, + pitch); + } + + /** + * Returns the entity riding the given entity, or null if there is none. Allows for neater code now that entities + * have a list of passengers, because it is necessary to check that the list is not null or empty first. */ @Nullable public static Entity getRider(Entity entity){ - return entity.getPassengers() != null && !entity.getPassengers().isEmpty() ? entity.getPassengers().get(0) : null; + return entity.getPassengers() != null && !entity.getPassengers().isEmpty() ? entity.getPassengers().get(0) + : null; } - + /** * Attacks the given entity with the given damage source and amount, but preserving the entity's original velocity - * instead of applying knockback, as would happen with {@link EntityLivingBase#attackEntityFrom(DamageSource, float)} - * (More accurately, calls that method as normal and then resets the entity's velocity to what it was before). - * Handy for when you need to damage an entity repeatedly in a short space of time. + * instead of applying knockback, as would happen with + * {@link EntityLivingBase#attackEntityFrom(DamageSource, float)} (More accurately, calls that method as normal + * and then resets the entity's velocity to what it was before). Handy for when you need to damage an entity + * repeatedly in a short space of time. + * * @param entity The entity to attack * @param source The source of the damage * @param amount The amount of damage to apply * @return True if the attack succeeded, false if not. */ public static boolean attackEntityWithoutKnockback(Entity entity, DamageSource source, float amount){ - double vx = entity.motionX; double vy = entity.motionY; double vz = entity.motionZ; + double vx = entity.motionX; + double vy = entity.motionY; + double vz = entity.motionZ; boolean succeeded = entity.attackEntityFrom(source, amount); - entity.motionX = vx; entity.motionY = vy; entity.motionZ = vz; + entity.motionX = vx; + entity.motionY = vy; + entity.motionZ = vz; return succeeded; } - + /** * Applies the standard (non-enchanted) amount of knockback to the given target, using the same calculation as * {@link EntityLivingBase#attackEntityFrom(DamageSource, float)}. Use in conjunction with * {@link WizardryUtilities#attackEntityWithoutKnockback(Entity, DamageSource, float)} to change the source of * knockback for an attack. + * * @param attacker The entity that caused the knockback; the target will be pushed away from this entity. * @param target The entity to be knocked back. */ public static void applyStandardKnockback(Entity attacker, EntityLivingBase target){ double dx = attacker.posX - target.posX; - double dz; - for(dz = attacker.posZ - target.posZ; dx * dx + dz * dz < 1.0E-4D; dz = (Math.random() - Math.random()) * 0.01D){ - dx = (Math.random() - Math.random()) * 0.01D; - } - // The first argument is never used. + double dz; + for(dz = attacker.posZ - target.posZ; dx * dx + dz * dz < 1.0E-4D; dz = (Math.random() - Math.random()) + * 0.01D){ + dx = (Math.random() - Math.random()) * 0.01D; + } + // The first argument is never used. target.knockBack(null, 0.4f, dx, dz); } - + // Just what benefit does having posY be the eye position on the first person client actually give? /** * Gets the y coordinate of the given player's eyes. This is to cover an inconsistency between the value of * EntityPlayer.posY on the first person client and everywhere else; in first person (i.e. when - * Minecraft.getMinecraft().thePlayer == player) player.posY is the eye position, but everywhere else it is the - * feet position. This is intended for use when spawning particles, since this is the only situation where the + * Minecraft.getMinecraft().player == player) player.posY is the eye position, but everywhere else it is the feet + * position. This is intended for use when spawning particles, since this is the only situation where the * discrepancy is likely to matter. *

    - * As of Wizardry 1.2, this is just a shorthand for:

    + * As of Wizardry 1.2, this is just a shorthand for: + *

    *

    player.getEntityBoundingBox().minY + player.getEyeHeight()
    */ public static double getPlayerEyesPos(EntityPlayer player){ return player.getEntityBoundingBox().minY + player.getEyeHeight(); } - - /** Returns a list of the itemstacks in the given player's hotbar. Defined here for convenience and to - * centralise the (unfortunately unavoidable) use of hardcoded numbers to reference the inventory slots. The - * returned list is a modifiable copy of part of the player's inventory stack list; as such, changes to the list - * are not written through to the player's inventory. However, the ItemStack instances themselves are not - * copied, so changes to any of their fields (size, metadata...) will change those in the player's inventory. - * @since Wizardry 1.2 */ + + /** + * Returns a list of the itemstacks in the given player's hotbar. Defined here for convenience and to centralise the + * (unfortunately unavoidable) use of hardcoded numbers to reference the inventory slots. The returned list is a + * modifiable copy of part of the player's inventory stack list; as such, changes to the list are not written + * through to the player's inventory. However, the ItemStack instances themselves are not copied, so changes to any + * of their fields (size, metadata...) will change those in the player's inventory. + * + * @since Wizardry 1.2 + */ public static List getHotbar(EntityPlayer player){ - return new ArrayList(Arrays.asList(player.inventory.mainInventory).subList(0, 9)); + NonNullList hotbar = NonNullList.create(); + hotbar.addAll(player.inventory.mainInventory.subList(0, 9)); + return hotbar; } - - /** Returns a list of the itemstacks in the given player's hotbar and offhand, sorted into the following order: - * main hand, offhand, rest of hotbar left-to-right. The returned list is a modifiable copy of part of the player's + + /** + * Returns a list of the itemstacks in the given player's hotbar and offhand, sorted into the following order: main + * hand, offhand, rest of hotbar left-to-right. The returned list is a modifiable copy of part of the player's * inventory stack list; as such, changes to the list are not written through to the player's inventory. * However, the ItemStack instances themselves are not copied, so changes to any of their fields (size, metadata...) * will change those in the player's inventory. - * @since Wizardry 1.2 */ + * + * @since Wizardry 1.2 + */ public static List getPrioritisedHotbarAndOffhand(EntityPlayer player){ List hotbar = WizardryUtilities.getHotbar(player); // Adds the offhand item to the beginning of the list so it is processed before the hotbar @@ -398,45 +450,51 @@ public final class WizardryUtilities { hotbar.add(0, player.getHeldItemMainhand()); return hotbar; } - - /** Tests whether the specified player has any of the specified item in their entire inventory, including armour - * slots and offhand. */ + + /** + * Tests whether the specified player has any of the specified item in their entire inventory, including armour + * slots and offhand. + */ public static boolean doesPlayerHaveItem(EntityPlayer player, Item item){ - + for(ItemStack stack : player.inventory.mainInventory){ - if(stack != null && stack.getItem() == item){ + if(stack.getItem() == item){ return true; } } - + for(ItemStack stack : player.inventory.armorInventory){ - if(stack != null && stack.getItem() == item){ + if(stack.getItem() == item){ return true; } } - + for(ItemStack stack : player.inventory.offHandInventory){ - if(stack != null && stack.getItem() == item){ + if(stack.getItem() == item){ return true; } } - + return false; } - - /** Checks if the given player is opped on the given server. If the server is a singleplayer or LAN server, this - * means they have cheats enabled. */ + + /** + * Checks if the given player is opped on the given server. If the server is a singleplayer or LAN server, this + * means they have cheats enabled. + */ public static boolean isPlayerOp(EntityPlayer player, MinecraftServer server){ return server.getPlayerList().getOppedPlayers().getEntry(player.getGameProfile()) != null; } - - /** Turns the given creeper into a charged creeper. In 1.10, this requires reflection since the DataManager keys - * are private. (You could call {@link EntityCreeper#onStruckByLightning(...)} and then heal it and - * extinguish it, but that's a bit awkward.) */ + + /** + * Turns the given creeper into a charged creeper. In 1.10, this requires reflection since the DataManager keys are + * private. (You could call {@link EntityCreeper#onStruckByLightning(...)} and then heal it and extinguish + * it, but that's a bit awkward.) + */ public static void chargeCreeper(EntityCreeper creeper){ creeper.getDataManager().set(POWERED, true); } - + // SECTION Raytracing // =============================================================================================================== @@ -445,7 +503,7 @@ public final class WizardryUtilities { */ @Nullable public static RayTraceResult rayTrace(double range, World world, EntityLivingBase entity, boolean hitLiquids){ - + Vec3d start = new Vec3d(entity.posX, entity.getEntityBoundingBox().minY + entity.getEyeHeight(), entity.posZ); Vec3d look = entity.getLookVec(); Vec3d end = start.addVector(look.xCoord * range, look.yCoord * range, look.zCoord * range); @@ -468,12 +526,15 @@ public final class WizardryUtilities { double dz = entity.getLookVec().zCoord * range; HashSet hashset = new HashSet(1); hashset.add(entity); - return WizardryUtilities.tracePath(world, (float)entity.posX, (float)(entity.getEntityBoundingBox().minY + entity.getEyeHeight()), (float)entity.posZ, (float)(entity.posX + dx), (float)(entity.posY + entity.getEyeHeight() + dy), (float)(entity.posZ + dz), 1.0f, hashset, false); + return WizardryUtilities.tracePath(world, (float)entity.posX, + (float)(entity.getEntityBoundingBox().minY + entity.getEyeHeight()), (float)entity.posZ, + (float)(entity.posX + dx), (float)(entity.posY + entity.getEyeHeight() + dy), (float)(entity.posZ + dz), + 1.0f, hashset, false); } /** - * Helper method which does a rayTrace for entities from a entity's eye level in the direction they are looking - * with a specified range and radius, using the tracePath method. Tidies up the code a bit. + * Helper method which does a rayTrace for entities from a entity's eye level in the direction they are looking with + * a specified range and radius, using the tracePath method. Tidies up the code a bit. * * @param world * @param entity @@ -482,18 +543,22 @@ public final class WizardryUtilities { * @return */ @Nullable - public static RayTraceResult standardEntityRayTrace(World world, EntityLivingBase entity, double range, float borderSize){ + public static RayTraceResult standardEntityRayTrace(World world, EntityLivingBase entity, double range, + float borderSize){ double dx = entity.getLookVec().xCoord * range; double dy = entity.getLookVec().yCoord * range; double dz = entity.getLookVec().zCoord * range; HashSet hashset = new HashSet(1); hashset.add(entity); - return WizardryUtilities.tracePath(world, (float)entity.posX, (float)(entity.getEntityBoundingBox().minY + entity.getEyeHeight()), (float)entity.posZ, (float)(entity.posX + dx), (float)(entity.posY + entity.getEyeHeight() + dy), (float)(entity.posZ + dz), borderSize, hashset, false); + return WizardryUtilities.tracePath(world, (float)entity.posX, + (float)(entity.getEntityBoundingBox().minY + entity.getEyeHeight()), (float)entity.posZ, + (float)(entity.posX + dx), (float)(entity.posY + entity.getEyeHeight() + dy), (float)(entity.posZ + dz), + borderSize, hashset, false); } /** - * Method for ray tracing entities (the useless default method doesn't work, despite EnumHitType having an ENTITY field...) - * You can also use this for seeking. + * Method for ray tracing entities (the useless default method doesn't work, despite EnumHitType having an ENTITY + * field...) You can also use this for seeking. * * @param world * @param x startX @@ -504,74 +569,72 @@ public final class WizardryUtilities { * @param tz endZ * @param borderSize extra area to examine around line for entities * @param excluded any excluded entities (the player, etc) - * @return a RayTraceResult of either the block hit (no entity hit), the entity hit (hit an entity), or null for nothing hit + * @return a RayTraceResult of either the block hit (no entity hit), the entity hit (hit an entity), or null for + * nothing hit */ @Nullable - public static RayTraceResult tracePath(World world, float x, float y, float z, float tx, float ty, float tz, float borderSize, HashSet excluded, boolean collideablesOnly){ + public static RayTraceResult tracePath(World world, float x, float y, float z, float tx, float ty, float tz, + float borderSize, HashSet excluded, boolean collideablesOnly){ Vec3d startVec = new Vec3d(x, y, z); - //Vec3d lookVec = new Vec3d(tx-x, ty-y, tz-z); + // Vec3d lookVec = new Vec3d(tx-x, ty-y, tz-z); Vec3d endVec = new Vec3d(tx, ty, tz); float minX = x < tx ? x : tx; float minY = y < ty ? y : ty; float minZ = z < tz ? z : tz; float maxX = x > tx ? x : tx; - float maxY = y > ty ? y : ty; + float maxY = y > ty ? y : ty; float maxZ = z > tz ? z : tz; - AxisAlignedBB bb = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ).expand(borderSize, borderSize, borderSize); - List allEntities = world.getEntitiesWithinAABBExcludingEntity(null, bb); + AxisAlignedBB bb = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ).expand(borderSize, borderSize, + borderSize); + List allEntities = world.getEntitiesWithinAABBExcludingEntity(null, bb); RayTraceResult blockHit = world.rayTraceBlocks(startVec, endVec); startVec = new Vec3d(x, y, z); endVec = new Vec3d(tx, ty, tz); - float maxDistance = (float) endVec.distanceTo(startVec); - if(blockHit!=null) - { - maxDistance = (float) blockHit.hitVec.distanceTo(startVec); - } + float maxDistance = (float)endVec.distanceTo(startVec); + if(blockHit != null){ + maxDistance = (float)blockHit.hitVec.distanceTo(startVec); + } Entity closestHitEntity = null; float closestHit = maxDistance; float currentHit = 0.f; AxisAlignedBB entityBb;// = ent.getBoundingBox(); RayTraceResult intercept; - for(Entity ent : allEntities) - { - if((ent.canBeCollidedWith() || !collideablesOnly) && ((excluded != null && !excluded.contains(ent)) || excluded == null)) - { - float entBorder = ent.getCollisionBorderSize(); + for(Entity ent : allEntities){ + if((ent.canBeCollidedWith() || !collideablesOnly) + && ((excluded != null && !excluded.contains(ent)) || excluded == null)){ + float entBorder = ent.getCollisionBorderSize(); entityBb = ent.getEntityBoundingBox(); - if(entityBb!=null) - { + if(entityBb != null){ entityBb = entityBb.expand(entBorder, entBorder, entBorder); intercept = entityBb.calculateIntercept(startVec, endVec); - if(intercept!=null) - { - currentHit = (float) intercept.hitVec.distanceTo(startVec); - if(currentHit < closestHit || currentHit==0) - { + if(intercept != null){ + currentHit = (float)intercept.hitVec.distanceTo(startVec); + if(currentHit < closestHit || currentHit == 0){ closestHit = currentHit; closestHitEntity = ent; } - } + } } } - } - if(closestHitEntity!=null) - { + } + if(closestHitEntity != null){ blockHit = new RayTraceResult(closestHitEntity); } return blockHit; } - + // SECTION Rendering and GUIs // =============================================================================================================== - + // Doesn't seem right to put this in the proxies since it should only ever be called from client-side code, and I'm // not about to make a whole separate utilities class just for one method. Fully qualified names it is! /** * [Client-side only] Draws a textured rectangle, taking the size of the image and the bit needed into * account, unlike {@link net.minecraft.client.gui.Gui#drawTexturedModalRect(int, int, int, int, int, int) - * Gui.drawTexturedModalRect(int, int, int, int, int, int)}, which is harcoded for only 256x256 textures. Also - * handy for custom potion icons. + * Gui.drawTexturedModalRect(int, int, int, int, int, int)}, which is harcoded for only 256x256 textures. Also handy + * for custom potion icons. + * * @param x The x position of the rectangle * @param y The y position of the rectangle * @param u The x position of the top left corner of the section of the image wanted @@ -582,64 +645,76 @@ public final class WizardryUtilities { * @param textureHeight The height of the actual image. */ @SideOnly(Side.CLIENT) - public static void drawTexturedRect(int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight){ - - float f = 1F / (float)textureWidth; - float f1 = 1F / (float)textureHeight; - - // Essentially the same as getting the tessellator. For most code, you'll want the tessellator AND the vertexbuffer - // stored in local variables. - net.minecraft.client.renderer.VertexBuffer buffer = net.minecraft.client.renderer.Tessellator.getInstance().getBuffer(); - // Equivalent of tessellator.startDrawingQuads() - buffer.begin(org.lwjgl.opengl.GL11.GL_QUADS, net.minecraft.client.renderer.vertex.DefaultVertexFormats.POSITION_TEX); - // Equivalent of tessellator.addVertex() - buffer.pos((double)(x), (double)(y + height), 0).tex((double)((float)(u) * f), (double)((float)(v + height) * f1)).endVertex(); - buffer.pos((double)(x + width), (double)(y + height), 0).tex((double)((float)(u + width) * f), (double)((float)(v + height) * f1)).endVertex(); - buffer.pos((double)(x + width), (double)(y), 0).tex((double)((float)(u + width) * f), (double)((float)(v) * f1)).endVertex(); - buffer.pos((double)(x), (double)(y), 0).tex((double)((float)(u) * f), (double)((float)(v) * f1)).endVertex(); - // Exactly the same as before. - net.minecraft.client.renderer.Tessellator.getInstance().draw(); + public static void drawTexturedRect(int x, int y, int u, int v, int width, int height, int textureWidth, + int textureHeight){ + + float f = 1F / (float)textureWidth; + float f1 = 1F / (float)textureHeight; + + // Essentially the same as getting the tessellator. For most code, you'll want the tessellator AND the + // vertexbuffer + // stored in local variables. + net.minecraft.client.renderer.VertexBuffer buffer = net.minecraft.client.renderer.Tessellator.getInstance() + .getBuffer(); + // Equivalent of tessellator.startDrawingQuads() + buffer.begin(org.lwjgl.opengl.GL11.GL_QUADS, + net.minecraft.client.renderer.vertex.DefaultVertexFormats.POSITION_TEX); + // Equivalent of tessellator.addVertex() + buffer.pos((double)(x), (double)(y + height), 0) + .tex((double)((float)(u) * f), (double)((float)(v + height) * f1)).endVertex(); + buffer.pos((double)(x + width), (double)(y + height), 0) + .tex((double)((float)(u + width) * f), (double)((float)(v + height) * f1)).endVertex(); + buffer.pos((double)(x + width), (double)(y), 0).tex((double)((float)(u + width) * f), (double)((float)(v) * f1)) + .endVertex(); + buffer.pos((double)(x), (double)(y), 0).tex((double)((float)(u) * f), (double)((float)(v) * f1)).endVertex(); + // Exactly the same as before. + net.minecraft.client.renderer.Tessellator.getInstance().draw(); } - - /** Shorthand for {@link WizardryUtilities#drawTexturedRect(int, int, int, int, int, int, int, int)} which draws - * the entire texture (u and v are set to 0 and textureWidth and textureHeight are the same as width and height). */ + + /** + * Shorthand for {@link WizardryUtilities#drawTexturedRect(int, int, int, int, int, int, int, int)} which draws the + * entire texture (u and v are set to 0 and textureWidth and textureHeight are the same as width and height). + */ @SideOnly(Side.CLIENT) public static void drawTexturedRect(int x, int y, int width, int height){ drawTexturedRect(x, y, 0, 0, width, height, width, height); } - + // SECTION NBT and Data Storage // =============================================================================================================== - + /** * Verifies that the given string is a valid string representation of a UUID. More specifically, returns true if and - * only if the given string is not null and matches the regular expression:

    + * only if the given string is not null and matches the regular expression: + *

    *

    /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/

    - * which is the regex equivalent of the standard string representation of a UUID as described in {@link UUID#toString()}. - * This method is intended to be used as a check to prevent an {@link IllegalArgumentException} from occurring when - * calling {@link UUID#fromString(String)}. + * which is the regex equivalent of the standard string representation of a UUID as described in + * {@link UUID#toString()}. This method is intended to be used as a check to prevent an + * {@link IllegalArgumentException} from occurring when calling {@link UUID#fromString(String)}. + * * @param string The string to be checked * @return Whether the given string is a valid string representation of a UUID * @deprecated UUIDs can now be stored in NBT directly; use that in preference to storing them as strings. */ @Deprecated public static boolean verifyUUIDString(String string){ - return string != null && string.matches("/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/"); + return string != null + && string.matches("/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/"); } - - /** Generic method that stores any Map to an NBTTagList, given two functions that convert the key and value - * types in that map to subclasses of NBTBase. For what it's worth, there is very little point in using this unless - * you can use something more concise than an anonymous class to do the conversion. A lambda expression, or better, - * a method reference, would fit nicely. For example, take ExtendedPlayer's use of this to store conjured item - * durations: + + /** + * Generic method that stores any Map to an NBTTagList, given two functions that convert the key and value types in + * that map to subclasses of NBTBase. For what it's worth, there is very little point in using this unless you can + * use something more concise than an anonymous class to do the conversion. A lambda expression, or better, a method + * reference, would fit nicely. For example, take ExtendedPlayer's use of this to store conjured item durations: *

    * properties.setTag("conjuredItems", WizardryUtilities.mapToNBT(this.conjuredItemDurations, * item -> new NBTTagInt(Item.getIdFromItem((Item)item)), NBTTagInt::new)); *

    - * This is a lot nicer than simply iterating through the map, because for that you need to use the entry list, - * which introduces local variables that aren't really necessary. Notice that, since the values V in the map are - * simply Integer objects, a simple constructor reference to NBTTagInt::new can be used instead of a lambda - * expression (the Integer is auto-unboxed to int). + * This is a lot nicer than simply iterating through the map, because for that you need to use the entry list, which + * introduces local variables that aren't really necessary. Notice that, since the values V in the map are simply + * Integer objects, a simple constructor reference to NBTTagInt::new can be used instead of a lambda expression (the + * Integer is auto-unboxed to int). * * @param The type of key stored in the given Map. * @param The type of value stored in the given Map. @@ -652,28 +727,34 @@ public final class WizardryUtilities { * @param valueTagName The tag name to use for the value tags. * @return An NBTTagList that represents the given Map. */ - public static NBTTagList mapToNBT(Map map, Function keyFunction, Function valueFunction, String keyTagName, String valueTagName){ - + public static NBTTagList mapToNBT(Map map, + Function keyFunction, Function valueFunction, String keyTagName, String valueTagName){ + NBTTagList tagList = new NBTTagList(); - + for(Entry entry : map.entrySet()){ NBTTagCompound mapping = new NBTTagCompound(); mapping.setTag(keyTagName, keyFunction.apply(entry.getKey())); mapping.setTag(valueTagName, valueFunction.apply(entry.getValue())); tagList.appendTag(mapping); } - + return tagList; } - - /** See {@link WizardryUtilities#mapToNBT(Map, Function, Function, String, String)}; this version is for when the - * names of the individual key/value tags are unimportant (they default to "key" and "value" respectively). */ - public static NBTTagList mapToNBT(Map map, Function keyFunction, Function valueFunction){ + + /** + * See {@link WizardryUtilities#mapToNBT(Map, Function, Function, String, String)}; this version is for when the + * names of the individual key/value tags are unimportant (they default to "key" and "value" respectively). + */ + public static NBTTagList mapToNBT(Map map, + Function keyFunction, Function valueFunction){ return mapToNBT(map, keyFunction, valueFunction, "key", "value"); } - - /** Generic method that reads a Map from an NBTTagList, given two functions that convert the key and value tag types - * into the key and value types in the returned map. The given NBTTagList remains unchanged after calling this method. + + /** + * Generic method that reads a Map from an NBTTagList, given two functions that convert the key and value tag types + * into the key and value types in the returned map. The given NBTTagList remains unchanged after calling this + * method. * * @param The type of key stored in the returned Map. * @param The type of value stored in the returned Map. @@ -681,7 +762,8 @@ public final class WizardryUtilities { * @param The subtype of NBTBase that the values are stored as. * @param tagList The NBTTagList to be converted. This must be a list of compound tags. * @param keyFunction A Function that converts the generic NBTBase tags in the list to keys of type K for the map. - * @param valueFunction A Function that converts the generic NBTBase tags in the list to values of type V for the map. + * @param valueFunction A Function that converts the generic NBTBase tags in the list to values of type V for the + * map. * @param keyTagName The tag name used for the key tags. * @param valueTagName The tag name used for the value tags. * @return A Map containing the keys and values stored in the given NBTTagList. Can be empty, but not null. @@ -689,38 +771,50 @@ public final class WizardryUtilities { * @see WizardryUtilities#mapToNBT(Map, Function, Function, String, String) */ @SuppressWarnings("unchecked") // Intentional, because throwing an exception is appropriate here. - public static Map NBTToMap(NBTTagList tagList, Function keyFunction, Function valueFunction, String keyTagName, String valueTagName){ - + public static Map NBTToMap(NBTTagList tagList, + Function keyFunction, Function valueFunction, String keyTagName, String valueTagName){ + Map map = new HashMap(); - - for(int i=0; i Map NBTToMap(NBTTagList tagList, Function keyFunction, Function valueFunction){ + + /** + * See {@link WizardryUtilities#NBTToMap(NBTTagList, Function, Function, String, String)}; this version is for when + * the names of the individual key/value tags are unimportant (they default to "key" and "value" respectively). + */ + public static Map NBTToMap(NBTTagList tagList, + Function keyFunction, Function valueFunction){ return NBTToMap(tagList, keyFunction, valueFunction, "key", "value"); } - /** Generic method that stores any Collection to an NBTTagList, given a function that converts the elements in - * that collection to subclasses of NBTBase. For what it's worth, there is very little point in using this unless - * you can use something more concise than an anonymous class to do the conversion. A lambda expression, or better, - * a method reference, would fit nicely. + /** + * Generic method that stores any Collection to an NBTTagList, given a function that converts the elements in that + * collection to subclasses of NBTBase. For what it's worth, there is very little point in using this unless you can + * use something more concise than an anonymous class to do the conversion. A lambda expression, or better, a method + * reference, would fit nicely. * * @param The type of element stored in the given Collection. * @param The NBT tag type that the elements will be converted to. @@ -729,30 +823,31 @@ public final class WizardryUtilities { * @return An NBTTagList that represents the given Collection. */ public static NBTTagList listToNBT(Collection list, Function function){ - + NBTTagList tagList = new NBTTagList(); // If the collection is ordered, it will preserve the order, even though we don't know what type it is yet. for(E element : list){ tagList.appendTag(function.apply(element)); } - + return tagList; } - - /** Generic method that reads a Collection from an NBTTagList, given a function that converts the element tag - * types to the element types in the returned collection. The given NBTTagList remains unchanged after calling this + + /** + * Generic method that reads a Collection from an NBTTagList, given a function that converts the element tag types + * to the element types in the returned collection. The given NBTTagList remains unchanged after calling this * method. Unless the target variable for this method is of type Collection, you will need to create a new * collection containing the elements in the returned collection via that collection's constructor (e.g. {@code new - * HashSet(collection)}). Although this method returns a Collection rather than any of its subtypes, it - * uses an ArrayList internally to guarantee the order of the elements in the returned collection is the same - * as the order in which they were stored. As such, you may safely cast to List should you wish. + * HashSet(collection)}). Although this method returns a Collection rather than any of its subtypes, it uses + * an ArrayList internally to guarantee the order of the elements in the returned collection is the same as the + * order in which they were stored. As such, you may safely cast to List should you wish. * * @param The type of element stored in the returned Collection. * @param The subtype of NBTBase that the elements are stored as. * @param tagList The NBTTagList to be converted. * @param function A Function that converts the generic NBTBase tags in the list to elements for the collection. - * Chances are you will need to cast the NBTBase tag to whichever NBT tag type you are expecting in order to - * access the appropriate getter method. + * Chances are you will need to cast the NBTBase tag to whichever NBT tag type you are expecting in order to + * access the appropriate getter method. * @return A Collection containing the elements stored in the given NBTTagList. Can be empty, but not null. * @throws ClassCastException If the tags are not of the expected type. */ @@ -762,43 +857,51 @@ public final class WizardryUtilities { // perfectly reasonable in this context). Collection list = new ArrayList(); // The original tag list should remain unchanged, hence the copy. - NBTTagList tagList2 = (NBTTagList) tagList.copy(); - + NBTTagList tagList2 = (NBTTagList)tagList.copy(); + while(!tagList2.hasNoTags()){ NBTBase tag = tagList2.removeTag(0); // Why oh why is NBTTagList not parametrised? It even has a tagType field, so it must know! - try { list.add(function.apply((T)tag)); } catch (ClassCastException e){ - Wizardry.logger.error("Error when reading list from NBT: unexpected tag type " + NBTBase.NBT_TYPES[tag.getId()], e); + try{ + list.add(function.apply((T)tag)); + }catch (ClassCastException e){ + Wizardry.logger.error( + "Error when reading list from NBT: unexpected tag type " + NBTBase.NBT_TYPES[tag.getId()], e); } } - + return list; - + } - - // TODO: Backport: It has recently become apparent that storing UUIDs as strings is not good practice, so backport these two + + // TODO: Backport: It has recently become apparent that storing UUIDs as strings is not good practice, so backport + // these two // methods to 1.7.10 and replace tag.setUniqueId and tag.getUniqueId with their respective contents from 1.10.2. - - /** Returns an NBTTagCompound which contains only the given UUID, stored using - * {@link NBTTagCompound#setUniqueId(String, UUID)}. Allows for neater storage to NBTTagLists. */ + + /** + * Returns an NBTTagCompound which contains only the given UUID, stored using + * {@link NBTTagCompound#setUniqueId(String, UUID)}. Allows for neater storage to NBTTagLists. + */ public static NBTTagCompound UUIDtoTagCompound(UUID id){ NBTTagCompound tag = new NBTTagCompound(); tag.setUniqueId("uuid", id); return tag; } - - /** Wrapper for {@link NBTTagCompound#getUniqueId(String)} which converts an NBTTagCompound directly to a UUID. - * Intended to be used as the inverse of {@link WizardryUtilities#UUIDtoTagCompound(UUID)}.*/ + + /** + * Wrapper for {@link NBTTagCompound#getUniqueId(String)} which converts an NBTTagCompound directly to a UUID. + * Intended to be used as the inverse of {@link WizardryUtilities#UUIDtoTagCompound(UUID)}. + */ public static UUID tagCompoundToUUID(NBTTagCompound tag){ return tag.getUniqueId("uuid"); } - + // SECTION Ally Designation System // =============================================================================================================== - + /** - * Returns whether the given target can be attacked by the given attacker. It is up to the caller of this method - * to work out what this means; it doesn't necessarily mean the target is completely immune (for example, revenge + * Returns whether the given target can be attacked by the given attacker. It is up to the caller of this method to + * work out what this means; it doesn't necessarily mean the target is completely immune (for example, revenge * targeting might reasonably bypass this). This method is intended for use where the damage is indirect and/or * unavoidable; direct attacks should not check this method. Currently this means the following situations check * this method: @@ -810,29 +913,28 @@ public final class WizardryUtilities { * - Any lightning chaining effects
    * - Any projectiles which seek targets *

    - * Also note that the friendly fire option is dealt with - * in the event handler. This method acts as a sort of wrapper for all the ADS stuff in {@link WizardData}; more - * details about the ally designation system can be found there. + * Also note that the friendly fire option is dealt with in the event handler. This method acts as a sort of wrapper + * for all the ADS stuff in {@link WizardData}; more details about the ally designation system can be found there. * * @param attacker The entity that cast the spell originally * @param target The entity being attacked * * @return False under any of the following circumstances, true otherwise: - *

    - * - Either entity is null - *

    - * - The target is the attacker (this isn't as stupid as it sounds - anything with an AoE might cause this to be - * true, as can summoned creatures) - *

    - * - The target and the attacker are both players and the target is an ally of the attacker (but the - * attacker need not be an ally of the target) - *

    - * - The target is a creature that was summoned/controlled by the attacker or by an ally of the attacker. + *

    + * - Either entity is null + *

    + * - The target is the attacker (this isn't as stupid as it sounds - anything with an AoE might cause this + * to be true, as can summoned creatures) + *

    + * - The target and the attacker are both players and the target is an ally of the attacker (but the + * attacker need not be an ally of the target) + *

    + * - The target is a creature that was summoned/controlled by the attacker or by an ally of the attacker. */ public static boolean isValidTarget(Entity attacker, Entity target){ if(attacker == null || target == null) return false; - + // Tests whether the target is the attacker if(target == attacker) return false; @@ -847,12 +949,13 @@ public final class WizardryUtilities { NBTTagCompound entityNBT = target.getEntityData(); if(entityNBT != null && entityNBT.hasKey(MindControl.NBT_KEY)){ - if(attacker == WizardryUtilities.getEntityByUUID(target.worldObj, entityNBT.getUniqueId(MindControl.NBT_KEY))){ + if(attacker == WizardryUtilities.getEntityByUUID(target.world, + entityNBT.getUniqueId(MindControl.NBT_KEY))){ return false; } } } - + // Ally section if(attacker instanceof EntityPlayer && WizardData.get((EntityPlayer)attacker) != null){ @@ -865,19 +968,23 @@ public final class WizardryUtilities { }else if(target instanceof ISummonedCreature){ // Tests whether the target is a creature that was summoned by an ally of the attacker if(((ISummonedCreature)target).getCaster() instanceof EntityPlayer - && WizardData.get((EntityPlayer)attacker).isPlayerAlly((EntityPlayer)((ISummonedCreature)target).getCaster())){ + && WizardData.get((EntityPlayer)attacker) + .isPlayerAlly((EntityPlayer)((ISummonedCreature)target).getCaster())){ return false; } - - }else if(target instanceof EntityLiving && ((EntityLivingBase)target).isPotionActive(WizardryPotions.mind_control)){ + + }else if(target instanceof EntityLiving + && ((EntityLivingBase)target).isPotionActive(WizardryPotions.mind_control)){ // Tests whether the target is a creature that was mind controlled by an ally of the attacker NBTTagCompound entityNBT = target.getEntityData(); - + if(entityNBT != null && entityNBT.hasKey(MindControl.NBT_KEY)){ - - Entity controller = WizardryUtilities.getEntityByUUID(target.worldObj, entityNBT.getUniqueId(MindControl.NBT_KEY)); - - if(controller instanceof EntityPlayer && WizardData.get((EntityPlayer)attacker).isPlayerAlly((EntityPlayer)controller)){ + + Entity controller = WizardryUtilities.getEntityByUUID(target.world, + entityNBT.getUniqueId(MindControl.NBT_KEY)); + + if(controller instanceof EntityPlayer + && WizardData.get((EntityPlayer)attacker).isPlayerAlly((EntityPlayer)controller)){ return false; } } @@ -888,7 +995,7 @@ public final class WizardryUtilities { } /** Helper method for testing if the second player is an ally of the first player. Makes the code neater. */ - public static boolean isPlayerAlly(EntityPlayer allyOf, EntityPlayer possibleAlly) { + public static boolean isPlayerAlly(EntityPlayer allyOf, EntityPlayer possibleAlly){ WizardData properties = WizardData.get(allyOf); @@ -896,7 +1003,7 @@ public final class WizardryUtilities { return false; } - + // SECTION Loot and Weighting // =============================================================================================================== @@ -908,13 +1015,12 @@ public final class WizardryUtilities { } /** - * Helper method which gets a spell id according to the standard weighting. The tier is a weighted random value; - * the actual spell within that tier is completely random. Will not return the id of a spell which has been - * disabled in the config. This is for simple stuff like chests and drops; more complex generators like wizard - * trades don't use this method. + * Helper method which gets a spell id according to the standard weighting. The tier is a weighted random value; the + * actual spell within that tier is completely random. Will not return the id of a spell which has been disabled in + * the config. This is for simple stuff like chests and drops; more complex generators like wizard trades don't use + * this method. *

    - * For reference, the standard weighting is as follows: - * Basic: 60%, Apprentice: 25%, Advanced: 10%, Master: 5% + * For reference, the standard weighting is as follows: Basic: 60%, Apprentice: 25%, Advanced: 10%, Master: 5% * * @param random An instance of {@link Random} to use for RNG * @param nonContinuous Whether the spells must be non-continuous (used for scrolls) @@ -936,33 +1042,36 @@ public final class WizardryUtilities { // Finds a random spell in the list and returns its id. return spells.get(random.nextInt(spells.size())).id(); } - - // TODO: These methods need a rethink. What are we trying to achieve with them? Should each use case look in the same - // pool of items? For example, might we (or someone else) want to have a wand which can generate in chests, but is - // not used by wizards? - - // I reckon this should be strictly for cases where we only ever want the standard wand set, i.e. wizards' gear, etc. + + // TODO: These methods need a rethink. What are we trying to achieve with them? Should each use case look in the + // same pool of items? For example, might we (or someone else) want to have a wand which can generate in chests, but + // is not used by wizards? + + // I reckon this should be strictly for cases where we only ever want the standard wand set, i.e. wizards' gear, + // etc. /** - * Helper method to return the appropriate armour item based on element and slot. As of Wizardry 2.1, this uses - * the immutable map stored in {@link WizardryItems#ARMOUR_MAP}. - * Currently used to iterate through armour for registering charging recipes and for chest generation. + * Helper method to return the appropriate armour item based on element and slot. As of Wizardry 2.1, this uses the + * immutable map stored in {@link WizardryItems#ARMOUR_MAP}. Currently used to iterate through armour for + * registering charging recipes and for chest generation. + * * @param element The EnumElement of the armour required. Null will be converted to {@link Element#MAGIC}. * @param slot EntityEquipmentSlot of the armour piece required * @return The armour item which corresponds to the given element and slot, or null if no such item exists. * @throws IllegalArgumentException if the given slot is not an armour slot. */ public static Item getArmour(Element element, EntityEquipmentSlot slot){ - if(slot == null || slot.getSlotType() != Type.ARMOR) throw new IllegalArgumentException("Must be a valid armour slot"); + if(slot == null || slot.getSlotType() != Type.ARMOR) + throw new IllegalArgumentException("Must be a valid armour slot"); if(element == null) element = Element.MAGIC; return WizardryItems.ARMOUR_MAP.get(ImmutablePair.of(slot, element)); } /** - * Helper method to return the appropriate wand based on tier and element.As of Wizardry 2.1, this uses - * the immutable map stored in {@link WizardryItems#WAND_MAP}. - * Currently used in the packet handler for upgrading wands, for chest generation and to iterate through - * wands for charging recipes. + * Helper method to return the appropriate wand based on tier and element.As of Wizardry 2.1, this uses the + * immutable map stored in {@link WizardryItems#WAND_MAP}. Currently used in the packet handler for upgrading wands, + * for chest generation and to iterate through wands for charging recipes. + * * @param tier The tier of the wand required. * @param element The element of the wand required. Null will be converted to {@link Element#MAGIC}. * @return The wand item which corresponds to the given element and slot, or null if no such item exists. diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 528e8735..51b52d3c 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -2,7 +2,7 @@ { "modid" : "wizardry", "name" : "Electroblob's Wizardry", - "version" : "2.1.0", + "version" : "3.1.0", "url" : "https://minecraft.curseforge.com/projects/electroblobs-wizardry", "credits" : "Made by Electroblob", "authors" : [ diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta new file mode 100644 index 00000000..96898838 --- /dev/null +++ b/src/main/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "Resources for Electroblob's Wizardry", + "pack_format": 3 + } +}