From a6a3bfa6f313adba5afe6eb4a0da049a8d641cfc Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Fri, 5 Jun 2015 01:53:14 +0100 Subject: Stuff! --- .../java/darkknight/jewelrycraft/api/Curse.java | 365 ++++++++++++--------- .../jewelrycraft/api/ModifierEffects.java | 214 ++++++------ 2 files changed, 337 insertions(+), 242 deletions(-) (limited to 'src/main/java/darkknight/jewelrycraft/api') diff --git a/src/main/java/darkknight/jewelrycraft/api/Curse.java b/src/main/java/darkknight/jewelrycraft/api/Curse.java index c030aad..bf21a5e 100644 --- a/src/main/java/darkknight/jewelrycraft/api/Curse.java +++ b/src/main/java/darkknight/jewelrycraft/api/Curse.java @@ -1,150 +1,215 @@ -package darkknight.jewelrycraft.api; - -import java.util.ArrayList; -import java.util.Random; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiIngame; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; -import net.minecraftforge.client.event.RenderHandEvent; -import net.minecraftforge.client.event.RenderPlayerEvent; -import net.minecraftforge.event.world.BlockEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class Curse -{ - protected int textureID; - protected String name, description, texturePackName; - protected Random rand = new Random(); - private static ArrayList curses = new ArrayList(); - public static ArrayList availableCurses = new ArrayList(); - - /** - * @param id the ID of the curse - * @param name the name of the curse - * @param texturepack the ID of the pack the texture is located in - */ - protected Curse(String name, int txtID, String texturepack) - { - this.name = name; - this.texturePackName = texturepack; - this.textureID = txtID; - curses.add(this); - availableCurses.add(this); - } - - /** - * @return the name of the curse - */ - public String getName() - { - return name; - } - - /** - * @return the description of the curse - */ - public String getDescription() - { - return description; - } - - public Curse setDescription(String desc) - { - description = desc; - return this; - } - - /** - * @return the texture pack ID - */ - public String getTexturePack() - { - return texturePackName; - } - - /** - * @return the texture ID - */ - public int getTextureID() - { - return textureID; - } - - /** - * @param world - * @param player - */ - public void action(World world, EntityPlayer player) - {} - - /** - * @param world - * @param player - */ - public void playerDeathAction(World world, EntityPlayer player) - {} - - public void entityDeathAction(World world, EntityLivingBase target, EntityPlayer player) - {} - - /** - * @param world - * @param player - */ - public void respawnAction(World world, EntityPlayer player) - {} - - /** - * @param world - * @param player - */ - public void attackedAction(World world, EntityPlayer player) - {} - - /** - * @param world - * @param player - */ - public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) - {} - - public void entityDropItems(EntityPlayer player, Entity target, ArrayList drops) - {} - - @SideOnly(Side.CLIENT) - public void playerRender(EntityPlayer player, RenderPlayerEvent.Specials.Post event) - {} - - @SideOnly(Side.CLIENT) - public void playerHandRender(EntityPlayer player, RenderHandEvent event) - {} - - public void onBlockItemsDrop(EntityPlayer player, BlockEvent.HarvestDropsEvent event) - {} - - public void onBlockDestroyed(EntityPlayer player, BlockEvent.BreakEvent event) - {} - - public boolean itemToss() - { - return false; - } - - public boolean canCurseBeActivated(World world) - { - return true; - } - - /** - * @return - */ - public static ArrayList getCurseList() - { - return curses; - } -} +package darkknight.jewelrycraft.api; + +import java.util.ArrayList; +import java.util.Random; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiIngame; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; +import net.minecraftforge.client.event.RenderHandEvent; +import net.minecraftforge.client.event.RenderPlayerEvent; +import net.minecraftforge.event.world.BlockEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Curse +{ + protected int textureID; + protected String name, description, texturePackName; + protected Random rand = new Random(); + private static ArrayList curses = new ArrayList(); + public static ArrayList availableCurses = new ArrayList(); + + /** + * @param name The name of the curse + * @param txtID The texture ID of it + * @param texturepack The texturepack location + */ + protected Curse(String name, int txtID, String texturepack) + { + this.name = name; + this.texturePackName = texturepack; + this.textureID = txtID; + curses.add(this); + availableCurses.add(this); + } + + /** + * @return The name of the curse + */ + public String getName() + { + return name; + } + + /** + * @return The description of the curse + */ + public String getDescription() + { + return description; + } + + /** + * @param The description of the curse + * @return The class + */ + public Curse setDescription(String desc) + { + description = desc; + return this; + } + + /** + * @return the texture pack ID + */ + public String getTexturePack() + { + return texturePackName; + } + + /** + * @return The texture ID + */ + public int getTextureID() + { + return textureID; + } + + /** + * This runs every tick + * @param world The worldthe player is in + * @param player The cursed player + */ + public void action(World world, EntityPlayer player) + {} + + /** + * This runs when the player dies + * @param world The world the player is in + * @param player The cursed player + */ + public void playerDeathAction(World world, EntityPlayer player) + {} + + /** + * This runs when an entity is killed (whether by a player or other causes) + * @param world The world the player is in + * @param target The entity that died + * @param player The cursed player + */ + public void entityDeathAction(World world, EntityLivingBase target, EntityPlayer player) + {} + + /** + * This runs when the player respawns + * @param world The world the player is in + * @param player The cursed player + */ + public void respawnAction(World world, EntityPlayer player) + {} + + /** + * This runs when a player gets attacked by anything but another player + * @param world The world the player is in + * @param player The cursed player + */ + public void attackedAction(World world, EntityPlayer player) + {} + + /** + * This runs when an entity is attacked by a player (this includes other players) + * @param world The world the player is in + * @param player The player that caused the damage + * @param target The entity damaged + */ + public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) + {} + + /** + * This runs when an item is dropped by an entity + * @param player The cursed player + * @param target The entity that drops the item + * @param drops An array list containing the dropped items + */ + public void entityDropItems(EntityPlayer player, Entity target, ArrayList drops) + {} + + /** + * This is for rendering special things on the player in 3rd person (meaning you won't see this render); + * This will also render in the inventory. + * @param player The cursed player + * @param event The event used for this + */ + @SideOnly(Side.CLIENT) + public void playerRender(EntityPlayer player, RenderPlayerEvent.Specials.Post event) + {} + + /** + * This is for rendering special things on the player in 1st and 3rd person, but not in the player inventory. + * @param player The cursed player + * @param event The event used for this + */ + @SideOnly(Side.CLIENT) + public void playerHandRender(EntityPlayer player, RenderHandEvent event) + {} + + /** + * This runs when a block drops an item (such as breaking a block and dropping itself, or breaking like a Diamond ore and dropping diamonds) + * @param player The cursed player + * @param event The BlockEvent that triggers this + */ + public void onBlockItemsDrop(EntityPlayer player, BlockEvent.HarvestDropsEvent event) + {} + + /** + * This runs when a block is destroyed + * @param player The cursed player + * @param event The BlockEvent that runs this + */ + public void onBlockDestroyed(EntityPlayer player, BlockEvent.BreakEvent event) + {} + + /** + * This determines if the player can toss an item or not (with Q) + * @return True if the player can no longer toss items; False if he can. (by default false) + */ + public boolean itemToss() + { + return false; + } + + /** + * This controls whether a curse can be activated or not (makes it easy to do things like disable certain curses if in hardcore) + * @param world The world the player is in + * @return True for curses to be used; False otherwise (by default true) + */ + public boolean canCurseBeActivated(World world) + { + return true; + } + + /** + * This is the list of all curses + * @return The list of registered curses + */ + public static ArrayList getCurseList() + { + return curses; + } + + /** + * This is the weight of the curse when it chooses it. The lower the value, the less it gets chosen; the higher the value, the higher the chance of it getting picked. + * @param world The world the player is currently in + * @param player The cursed player + * @param random A random class + * @return The weight of the curse (by default 10) + */ + public int weight(World world, EntityPlayer player, Random random) + { + return 10; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/api/ModifierEffects.java b/src/main/java/darkknight/jewelrycraft/api/ModifierEffects.java index 2aa3254..be88d31 100644 --- a/src/main/java/darkknight/jewelrycraft/api/ModifierEffects.java +++ b/src/main/java/darkknight/jewelrycraft/api/ModifierEffects.java @@ -1,92 +1,122 @@ -package darkknight.jewelrycraft.api; - -import java.util.ArrayList; -import java.util.Random; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.DamageSource; -import net.minecraftforge.event.entity.player.PlayerEvent; - -public class ModifierEffects -{ - protected ItemStack modifier; - protected Random rand = new Random(); - protected static ArrayList effects = new ArrayList(); - - /** - * @param modifier - */ - public ModifierEffects(ItemStack modifier) - { - this.modifier = modifier; - effects.add(this); - } - - /** - * @return - */ - public static ArrayList getEffects() - { - return effects; - } - - /** - * @param item - * @param player - * @param jewelry - */ - public void action(ItemStack item, EntityPlayer player, Item jewelry) - {}; - - /** - * @param item - * @param player - * @param target - * @param jewelry - * @return - */ - public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) - { - return false; - } - - /** - * @param item - * @param player - * @param source - * @param jewelry - * @return - */ - public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) - { - return false; - } - - /** - * @param item - * @param player - * @param target - * @param jewelry - * @return - */ - public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) - {} - - /** - * @param item - * @param player - * @param source - * @param jewelry - * @return - */ - public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) - {} - - public void onPlayerDead(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry) - {} - - public void onPlayerRespawn(ItemStack item, PlayerEvent.Clone event, Item jewelry) - {} -} +package darkknight.jewelrycraft.api; + +import java.util.ArrayList; +import java.util.Random; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraftforge.event.entity.player.PlayerEvent; + +public class ModifierEffects +{ + protected ItemStack modifier; + protected Random rand = new Random(); + protected static ArrayList effects = new ArrayList(); + + /** + * @param modifier The item to use as modifier + */ + public ModifierEffects(ItemStack modifier) + { + this.modifier = modifier; + effects.add(this); + } + + /** + * @return The list of all effects registered + */ + public static ArrayList getEffects() + { + return effects; + } + + /** + * @return The ItemStack set as the modifier + */ + public ItemStack getModifier() + { + return modifier; + } + + /** + * This runs every tick + * @param item The ItemStack representing the jewelry that runs the effect + * @param player The player wearing the jewelry wearing a jewelry with this modifier on it + * @param jewelry The actual jewelry item (used by me to determine the type of jewelry so I don't have to call item.getItem() blah blah blah) + */ + public void action(ItemStack item, EntityPlayer player, Item jewelry) + {}; + + /** + * This runs when an entity is attacked. This event can be canceled. + * @param item The ItemStack representing the jewelry that runs the effect + * @param player The player wearing the jewelry wearing a jewelry with this modifier on it + * @param target The attacked entity + * @param jewelry The actual jewelry item (aka item.getItem(), almost) + * @param amount The amount of damage the entity took + * @return The state of the event (true to cancel it, false to not) + */ + public boolean onEntityAttackedCacellable(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) + { + return false; + } + + /** + * This runs when a player gets damaged. This event can be canceled. + * @param item The ItemStack representing the jewelry that runs the effect + * @param player The attacked player wearing a jewelry with this modifier on it + * @param source The source of the damage + * @param jewelry The actual jewelry item (aka item.getItem(), almost) + * @param amount The amount of damage the player took + * @return The state of the event (true to cancel it, false to not) + */ + public boolean onPlayerAttackedCacellable(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) + { + return false; + } + + /** + * This is the same as onEntityAttackedCacellable, but this can not be canceled. + * I recommend using this over onEntityAttackedCacellable, as it is more reliable. + * @param item The ItemStack representing the jewelry that runs the effect + * @param player The player wearing the jewelry wearing a jewelry with this modifier on it + * @param target The attacked entity + * @param jewelry The actual jewelry item (aka item.getItem(), almost) + * @param amount The amount of damage the entity took + */ + public void onEntityAttacked(ItemStack item, EntityPlayer player, Entity target, Item jewelry, float amount) + {} + + /** + * This is just like onPlayerAttackedCacellable, only that this can not be canceled. + * I recommend using this over onPlayerAttackedCacellable, as it is more reliable. + * @param item The ItemStack representing the jewelry that runs the effect + * @param player The attacked player wearing a jewelry with this modifier on it + * @param source The source of the damage + * @param jewelry The actual jewelry item (aka item.getItem(), almost) + * @param amount The amount of damage the player took + */ + public void onPlayerAttacked(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry, float amount) + {} + + /** + * This runs when the player dies + * @param item The ItemStack representing the jewelry that runs the effect + * @param player The player that died wearing a jewelry with this modifier on it + * @param source The source of the killing blow + * @param jewelry The actual jewelry item (aka item.getItem(), almost) + */ + public void onPlayerDead(ItemStack item, EntityPlayer player, DamageSource source, Item jewelry) + {} + + /** + * This runs when the player respawns + * @param item The ItemStack representing the jewelry that runs the effect + * @param event The PlayerEvent that runs when the player respawns (this is also called when a player moves between dimensions) + * @param jewelry The actual jewelry item (aka item.getItem(), almost) + */ + public void onPlayerRespawn(ItemStack item, PlayerEvent.Clone event, Item jewelry) + {} +} -- cgit v1.2.3