From 65b851c460af935d3a203ea900752032991bbf17 Mon Sep 17 00:00:00 2001 From: Zerokyuuni Date: Tue, 10 Sep 2013 10:21:00 -0400 Subject: [PATCH] Tinker and Blade 2: Warconstruct --- src/mods/battlegear2/api/IArrowContainer.java | 55 +++++++ .../battlegear2/api/IArrowContainer2.java | 99 +++++++++++++ src/mods/battlegear2/api/IBackStabbable.java | 14 ++ .../battlegear2/api/IBattlegearWeapon.java | 70 +++++++++ src/mods/battlegear2/api/IDyable.java | 31 ++++ .../battlegear2/api/IExtendedReachWeapon.java | 12 ++ src/mods/battlegear2/api/IHeraldyArmour.java | 11 ++ src/mods/battlegear2/api/IHeraldyItem.java | 77 ++++++++++ .../battlegear2/api/IHitTimeModifier.java | 15 ++ .../battlegear2/api/IPenetrateWeapon.java | 13 ++ src/mods/battlegear2/api/IPotionEffect.java | 23 +++ src/mods/battlegear2/api/IShield.java | 54 +++++++ src/mods/battlegear2/api/ISpecialEffect.java | 16 ++ .../battlegear2/api/OffhandAttackEvent.java | 21 +++ .../battlegear2/api/PlayerEventChild.java | 32 ++++ .../battlegear2/api/QuiverArrowEvent.java | 29 ++++ .../battlegear2/api/QuiverArrowRegistry.java | 42 ++++++ .../api/heraldry/HeraldryData.java | 138 ++++++++++++++++++ .../api/heraldry/IHeraldryItem.java | 59 ++++++++ .../api/quiver/IArrowContainer.java | 55 +++++++ .../api/quiver/IArrowContainer2.java | 99 +++++++++++++ .../api/quiver/QuiverArrowEvent.java | 30 ++++ .../api/quiver/QuiverArrowRegistry.java | 42 ++++++ .../api/weapons/IBackStabbable.java | 14 ++ .../api/weapons/IBattlegearWeapon.java | 70 +++++++++ .../api/weapons/IExtendedReachWeapon.java | 12 ++ .../api/weapons/IHitTimeModifier.java | 15 ++ .../api/weapons/IPenetrateWeapon.java | 13 ++ .../api/weapons/IPotionEffect.java | 23 +++ .../api/weapons/ISpecialEffect.java | 16 ++ .../api/weapons/OffhandAttackEvent.java | 22 +++ src/tconstruct/items/tools/Arrow.java | 5 + src/tconstruct/items/tools/Battleaxe.java | 15 ++ src/tconstruct/items/tools/Chisel.java | 14 ++ src/tconstruct/items/tools/Cleaver.java | 21 +++ src/tconstruct/items/tools/Excavator.java | 20 +++ src/tconstruct/items/tools/Hammer.java | 20 +++ src/tconstruct/items/tools/Hatchet.java | 5 + src/tconstruct/items/tools/LumberAxe.java | 20 +++ src/tconstruct/items/tools/Mattock.java | 20 +++ src/tconstruct/items/tools/Pickaxe.java | 5 + src/tconstruct/items/tools/Scythe.java | 19 +++ src/tconstruct/items/tools/Shortbow.java | 20 +++ src/tconstruct/items/tools/Shovel.java | 5 + src/tconstruct/library/tools/ToolCore.java | 50 ++++++- src/tconstruct/library/tools/Weapon.java | 2 + src/tconstruct/util/PHConstruct.java | 6 + 47 files changed, 1467 insertions(+), 2 deletions(-) create mode 100644 src/mods/battlegear2/api/IArrowContainer.java create mode 100644 src/mods/battlegear2/api/IArrowContainer2.java create mode 100644 src/mods/battlegear2/api/IBackStabbable.java create mode 100644 src/mods/battlegear2/api/IBattlegearWeapon.java create mode 100644 src/mods/battlegear2/api/IDyable.java create mode 100644 src/mods/battlegear2/api/IExtendedReachWeapon.java create mode 100644 src/mods/battlegear2/api/IHeraldyArmour.java create mode 100644 src/mods/battlegear2/api/IHeraldyItem.java create mode 100644 src/mods/battlegear2/api/IHitTimeModifier.java create mode 100644 src/mods/battlegear2/api/IPenetrateWeapon.java create mode 100644 src/mods/battlegear2/api/IPotionEffect.java create mode 100644 src/mods/battlegear2/api/IShield.java create mode 100644 src/mods/battlegear2/api/ISpecialEffect.java create mode 100644 src/mods/battlegear2/api/OffhandAttackEvent.java create mode 100644 src/mods/battlegear2/api/PlayerEventChild.java create mode 100644 src/mods/battlegear2/api/QuiverArrowEvent.java create mode 100644 src/mods/battlegear2/api/QuiverArrowRegistry.java create mode 100644 src/mods/battlegear2/api/heraldry/HeraldryData.java create mode 100644 src/mods/battlegear2/api/heraldry/IHeraldryItem.java create mode 100644 src/mods/battlegear2/api/quiver/IArrowContainer.java create mode 100644 src/mods/battlegear2/api/quiver/IArrowContainer2.java create mode 100644 src/mods/battlegear2/api/quiver/QuiverArrowEvent.java create mode 100644 src/mods/battlegear2/api/quiver/QuiverArrowRegistry.java create mode 100644 src/mods/battlegear2/api/weapons/IBackStabbable.java create mode 100644 src/mods/battlegear2/api/weapons/IBattlegearWeapon.java create mode 100644 src/mods/battlegear2/api/weapons/IExtendedReachWeapon.java create mode 100644 src/mods/battlegear2/api/weapons/IHitTimeModifier.java create mode 100644 src/mods/battlegear2/api/weapons/IPenetrateWeapon.java create mode 100644 src/mods/battlegear2/api/weapons/IPotionEffect.java create mode 100644 src/mods/battlegear2/api/weapons/ISpecialEffect.java create mode 100644 src/mods/battlegear2/api/weapons/OffhandAttackEvent.java diff --git a/src/mods/battlegear2/api/IArrowContainer.java b/src/mods/battlegear2/api/IArrowContainer.java new file mode 100644 index 00000000000..cd77ab2b076 --- /dev/null +++ b/src/mods/battlegear2/api/IArrowContainer.java @@ -0,0 +1,55 @@ +package mods.battlegear2.api; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +@Deprecated +public interface IArrowContainer{ + + /** + * + * @param stack The {@link #ItemStack} representing this item + * @param bow The bow trying to use this container + * @param player The {@link #EntityPlayer} using the bow + * @return true if the item contains at least one arrow + */ + public boolean hasArrowFor(ItemStack stack, ItemStack bow, EntityPlayer player); + /** + * The arrow spawned when bow is used with this non empty container equipped + * @param stack The {@link #ItemStack} representing this item + * @param charge Amount of charge in the bow, ranging from 0.2F to 2.0F + * @param player The {@link #EntityPlayer} using the bow + * @param world + * @return the arrow entity to spawn when bow is used + */ + public EntityArrow getArrowType(ItemStack stack, World world, EntityPlayer player, float charge); + /** + * Action to take after an arrow has been fired + * Usually equal to removing an arrow from the container + * @param player The {@link #EntityPlayer} using the bow + * @param world + * @param stack The {@link #ItemStack} representing this item + * @param bow The bow which fired + * @param arrow the arrow fired + */ + public void onArrowFired(World world, EntityPlayer player, ItemStack stack, ItemStack bow, EntityArrow arrow); + /** + * Called before the arrow is fired from this container + * @param arrowEvent Used to decide bow damage, bow sound and arrow enchantment + */ + public void onPreArrowFired(QuiverArrowEvent arrowEvent); + /** + * Called when the container is put on a crafting bench with vanilla arrows + * @param stack + * @return True to receive {@link #addArrows(ItemStack, int)} + */ + public boolean isCraftableWithArrows(ItemStack stack); + /** + * Crafts the item with vanilla arrows + * @param stack + * @param arrows Number of vanilla arrows on the crafting bench + * @return Number of vanilla arrows that couldn't fit in + */ + public int addArrows(ItemStack stack, int arrows); +} diff --git a/src/mods/battlegear2/api/IArrowContainer2.java b/src/mods/battlegear2/api/IArrowContainer2.java new file mode 100644 index 00000000000..31e7635d010 --- /dev/null +++ b/src/mods/battlegear2/api/IArrowContainer2.java @@ -0,0 +1,99 @@ +package mods.battlegear2.api; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface IArrowContainer2 { + + /** + * Returns the maximum amout of slots in the arrow container + * @param container {@link #ItemStack} representing this item + * @return the amount of slots + */ + public int getSlotCount(ItemStack container); + + /** + * Returns the currently selected slot in the arrow container + * @param container {@link #ItemStack} representing this item + * @return the currently selected slot + */ + public int getSelectedSlot(ItemStack container); + + /** + * Sets the currently selected slot to the given value + * @param container {@link #ItemStack} representing this item + * @param newSlot the new slot index + */ + public void setSelectedSlot(ItemStack container, int newSlot); + + /** + * Returns the itemStack in the currently selected slot + * @param container The {@link #ItemStack} representing this item + * @param slot the slot index + * @return The {@link #ItemStack} in the given slot. + */ + public ItemStack getStackInSlot(ItemStack container, int slot); + + /** + * Sets places the given item stack in the give slot + * @param container {@link #ItemStack} representing this item + * @param slot the slot index + * @param container {@link #ItemStack} representing the new stack + */ + public void setStackInSlot(ItemStack container, int slot, ItemStack stack); + + + /** + * + * @param container The {@link #ItemStack} representing this item + * @param bow The bow trying to use this container + * @param player The {@link #EntityPlayer} using the bow + * @return true if the item contains at least one arrow in the selected slot + */ + public boolean hasArrowFor(ItemStack container, ItemStack bow, EntityPlayer player, int slot); + + /** + * The arrow spawned when bow is used with this non empty container equipped + * @param container The {@link #ItemStack} representing this item + * @param charge Amount of charge in the bow, ranging from 0.2F to 2.0F + * @param player The {@link #EntityPlayer} using the bow + * @param world + * @return the arrow entity to spawn when bow is used + */ + public EntityArrow getArrowType(ItemStack container, World world, EntityPlayer player, float charge); + /** + * Action to take after an arrow has been fired + * Usually equal to removing an arrow from the container + * @param player The {@link #EntityPlayer} using the bow + * @param world + * @param container The {@link #ItemStack} representing this item + * @param bow The bow which fired + * @param arrow the arrow fired + */ + public void onArrowFired(World world, EntityPlayer player, ItemStack container, ItemStack bow, EntityArrow arrow); + /** + * Called before the arrow is fired from this container + * @param arrowEvent Used to decide bow damage, bow sound and arrow enchantment + */ + public void onPreArrowFired(QuiverArrowEvent arrowEvent); + /** + * Called when the container is put on a crafting bench with other items + * @param container The {@link #ItemStack} representing this item + * @param arrowStack The {@link #ItemStack} representing other items + * @return True to receive {@link #addArrows(ItemStack, ItemStack)} + */ + public boolean isCraftableWithArrows(ItemStack contaner, ItemStack arrowStack); + + /** + * Crafts the item with the items from {@link #isCraftableWithArrows(ItemStack, ItemStack)} + * @param container The {@link #ItemStack} representing this item + * @param arrows Another valid item on the crafting bench + * @return Number of arrows that couldn't fit in + */ + public ItemStack addArrows(ItemStack container, ItemStack newStack); + + + +} diff --git a/src/mods/battlegear2/api/IBackStabbable.java b/src/mods/battlegear2/api/IBackStabbable.java new file mode 100644 index 00000000000..021dad123cf --- /dev/null +++ b/src/mods/battlegear2/api/IBackStabbable.java @@ -0,0 +1,14 @@ +package mods.battlegear2.api; + +import net.minecraft.entity.EntityLivingBase; + +public interface IBackStabbable { + + /** + * Action to perform on back stabbing + * @param entityHit + * @param entityHitting + * @return true if it adds an hitting action + */ + public boolean onBackStab(EntityLivingBase entityHit, EntityLivingBase entityHitting); +} diff --git a/src/mods/battlegear2/api/IBattlegearWeapon.java b/src/mods/battlegear2/api/IBattlegearWeapon.java new file mode 100644 index 00000000000..688d6755590 --- /dev/null +++ b/src/mods/battlegear2/api/IBattlegearWeapon.java @@ -0,0 +1,70 @@ +package mods.battlegear2.api; + +import cpw.mods.fml.relauncher.Side; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +public interface IBattlegearWeapon { + + /** + * Returns true if the weapon will allow other weapons to be placed in the partner offhand slot + */ + public boolean willAllowOffhandWeapon(); + + /** + * Will allow shield + */ + public boolean willAllowShield(); + + /** + * Returns true if the weapon be dual wielded in the offhand slot + */ + public boolean isOffhandHandDualWeapon(); + + /** + * Returns true if the weapon should always be sheathed on the back, false if it should be sheathed on the hip + */ + public boolean sheatheOnBack(); + + /** + * Perform any function when the item is held in the offhand and the user right clicks an entity. + * This is generally used to attack an entity with the offhand item. If this is the case the event should + * be canceled to prevent any default right clicking events (Eg Villager Trading) + * + * @param event the OffhandAttackEvent that was generated + * @param mainhandItem the ItemStack currently being held in the right hand + * @param offhandItem the ItemStack currently being held in the left hand + * @return true if the off hand swing animation should be performed + */ + public boolean offhandAttackEntity(OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem); + + /** + * Perform any function when the item is held in the offhand and the user right clicks "Air". + * + * @param event the PlayerInteractEvent that was generated + * @param mainhandItem the ItemStack currently being held in the right hand + * @param offhandItem the ItemStack currently being held in the left hand + * @return true if the off hand swing animation should be performed + */ + public boolean offhandClickAir(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem); + + /** + * Perform any function when the item is held in the offhand and the user right clicks a block. + * Note that this will happen prior to the activation of any activation functions of blocks + * + * @param event the PlayerInteractEvent that was generated + * @param mainhandItem the ItemStack currently being held in the right hand + * @param offhandItem the ItemStack currently being held in the left hand + */ + public boolean offhandClickBlock(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem); + + /** + * Perform any passive effects on each game tick when the item is held in the offhand + * + * @param effectiveSide the effective side the method was called from + * @param mainhandItem the ItemStack currently being held in the right hand + * @param offhandItem the ItemStack currently being held in the left hand + */ + public void performPassiveEffects(Side effectiveSide, ItemStack mainhandItem, ItemStack offhandItem); + +} \ No newline at end of file diff --git a/src/mods/battlegear2/api/IDyable.java b/src/mods/battlegear2/api/IDyable.java new file mode 100644 index 00000000000..a5be9d7ef4f --- /dev/null +++ b/src/mods/battlegear2/api/IDyable.java @@ -0,0 +1,31 @@ +package mods.battlegear2.api; + + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +//This is a tempory fix until we get the heradry system up and running +public interface IDyable { + + /** + * Return whether the specified armor ItemStack has a color. + */ + public boolean hasColor(ItemStack par1ItemStack); + + + /** + * Return the color for the specified armor ItemStack. + */ + public int getColor(ItemStack par1ItemStack); + + public void setColor(ItemStack dyable, int rgb); + + /** + * Remove the color from the specified armor ItemStack. + */ + public void removeColor(ItemStack par1ItemStack); + + public int getDefaultColor(ItemStack par1ItemStack); + + +} diff --git a/src/mods/battlegear2/api/IExtendedReachWeapon.java b/src/mods/battlegear2/api/IExtendedReachWeapon.java new file mode 100644 index 00000000000..a9cefa90642 --- /dev/null +++ b/src/mods/battlegear2/api/IExtendedReachWeapon.java @@ -0,0 +1,12 @@ +package mods.battlegear2.api; + +import net.minecraft.item.ItemStack; + +public interface IExtendedReachWeapon { + /** + * The distance the weapon will hit (note this will ONLY work for main hand weapons) + * @param stack + * @return + */ + public float getReachModifierInBlocks(ItemStack stack); +} diff --git a/src/mods/battlegear2/api/IHeraldyArmour.java b/src/mods/battlegear2/api/IHeraldyArmour.java new file mode 100644 index 00000000000..a32e64a24c7 --- /dev/null +++ b/src/mods/battlegear2/api/IHeraldyArmour.java @@ -0,0 +1,11 @@ +package mods.battlegear2.api; + + +import mods.battlegear2.heraldry.HeraldyPattern; + +public interface IHeraldyArmour extends IHeraldyItem{ + + public String getBaseArmourPath(int armourSlot); + + public String getPatternArmourPath(HeraldyPattern pattern, int armourSlot); +} diff --git a/src/mods/battlegear2/api/IHeraldyItem.java b/src/mods/battlegear2/api/IHeraldyItem.java new file mode 100644 index 00000000000..1f188ee587c --- /dev/null +++ b/src/mods/battlegear2/api/IHeraldyItem.java @@ -0,0 +1,77 @@ +package mods.battlegear2.api; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; + +@Deprecated +public interface IHeraldyItem { + + public enum HeraldyRenderPassess{ + /** + * The first render pass. This will use the items base icon coloured the primary colour + */ + PrimaryColourBase, + /** + * The second render pass. This will use the selected pattern overlayed on top of the base icon with the apropriate colour + */ + SecondaryColourPattern, + /** + * The third render pass. The sigil(s) will be rendered on top of the pattern in the apropriate positions + */ + Sigil, + /** + * Fourth render pass. The items trim icon will be rendered in the secondady colour + */ + SecondaryColourTrim, + /** + * Fifth Render pass, the Items post render icon will be rendered in the default colour + */ + PostRenderIcon + } + + /** + * Returns the "base" icon. This icon will be coloured the primary colour + */ + public Icon getBaseIcon(ItemStack stack); + /** + * Returns the trim icon, This will be coloured the secondary colour + */ + public Icon getTrimIcon(ItemStack stack); + /** + * Returns the post render icon, this Icon will render after all other rendering passess in it's default colour + */ + public Icon getPostRenderIcon(ItemStack stack); + + + /** + * Returns true if the given itemstack has heraldy attached + */ + public boolean hasHeraldry(ItemStack stack); + /** + * Returns the current heraldy code, this will only be called on ItemStacks that have been found to have heraldrybackup using the hasHeraldryMethod + */ + public byte[] getHeraldryCode(ItemStack stack); + + /** + * Saves the given heraldy code in the given stack. It is recommended to use the stacks NBT Tag compound for this + */ + public void setHeraldryCode(ItemStack stack, byte[] code); + + /** + * Removes the heraldy code from the item + */ + public void removeHeraldry(ItemStack item); + + /** + * Returns true if the default renderer should perform the given render pass + */ + public boolean shouldDoPass(HeraldyRenderPassess pass); + + /** + * Returns true if the default renderer should be used. + * If the method returns true, the default renderer will be attached. + * If this method returns false it is the modders responsibility to attach an appropriate renderer + */ + public boolean useDefaultRenderer(); + +} diff --git a/src/mods/battlegear2/api/IHitTimeModifier.java b/src/mods/battlegear2/api/IHitTimeModifier.java new file mode 100644 index 00000000000..dae76ee0548 --- /dev/null +++ b/src/mods/battlegear2/api/IHitTimeModifier.java @@ -0,0 +1,15 @@ +package mods.battlegear2.api; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; + +public interface IHitTimeModifier { + /** + * + * @param entityHit + * @return The amount to modify the hit shield + */ + public int getHitTime(ItemStack stack, EntityLivingBase entityHit); + +} diff --git a/src/mods/battlegear2/api/IPenetrateWeapon.java b/src/mods/battlegear2/api/IPenetrateWeapon.java new file mode 100644 index 00000000000..435fb5d9f12 --- /dev/null +++ b/src/mods/battlegear2/api/IPenetrateWeapon.java @@ -0,0 +1,13 @@ +package mods.battlegear2.api; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; + +public interface IPenetrateWeapon { + /** + * The amount of damage bypassing armor + * @param stack The {@link net.minecraft.item.ItemStack} representative of the item dealing the hit. + * @return the amount of damage that bypasses armour + */ + public int getPenetratingPower(ItemStack stack); +} diff --git a/src/mods/battlegear2/api/IPotionEffect.java b/src/mods/battlegear2/api/IPotionEffect.java new file mode 100644 index 00000000000..94912c809d2 --- /dev/null +++ b/src/mods/battlegear2/api/IPotionEffect.java @@ -0,0 +1,23 @@ +package mods.battlegear2.api; + + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.potion.PotionEffect; + +import java.util.Map; + +public interface IPotionEffect { + + + /** + * Returns a map containing the potion effects to apply to an entity hit by the weapon. Each effect + * has a float value associated with the chance of applying the effect. Note that the "dice roll" only + * occurs once so any value under this roll will be applied. + * + * @param entityHit The entity the effect will be applied to. + * @param entityHitting + * @return A Map of {@link PotionEffect} with chance value ranging from 0 to 1, to be dealt to the entityHit + */ + public Map getEffectsOnHit(EntityLivingBase entityHit, EntityLivingBase entityHitting); + +} diff --git a/src/mods/battlegear2/api/IShield.java b/src/mods/battlegear2/api/IShield.java new file mode 100644 index 00000000000..de9a81bf914 --- /dev/null +++ b/src/mods/battlegear2/api/IShield.java @@ -0,0 +1,54 @@ +package mods.battlegear2.api; + + +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; + +public interface IShield { + + /** + * Gets the decay rate for the stamina bar when the shield is in use. + * The value should be between 0 and 1. The duration of maximum blocking can be calculated + * by 1/decayRate/20. + * + * @param shield The {@link #ItemStack} representing the shield + * @return a value between 0 & 1 representing the decay rate per tick + */ + public float getDecayRate(ItemStack shield); + + /** + * Returns true if the current shield can and should block the given damage source + * + * @param shield The {@link #ItemStack} representing the shield + * @param source The {@link #DamageSource} representing the current damage + * @return true if the shield can block the given damage type + */ + public boolean canBlock(ItemStack shield, DamageSource source); + + /** + * Gets the extra decay rate to the stamina bar when the shield is damaged + * + * @param shield The {@link #ItemStack} representing the shield + * @param amount The amount of damage the shield has absorbed + * @return a value between 0 & 1 representing the decay rate + */ + public float getDamageDecayRate(ItemStack shield, float amount); + + /** + * Returns the block angle in degrees that the shield can block. + * This angle is taken as 0 degrees being directly in front of the player. The shield + * will block between -blockAngle to blockangle + * @param shield The {@link #ItemStack} representing the shield + * @return The maximum angle the shield should be able to block at + */ + public float getBlockAngle(ItemStack shield); + + + /** + * Returns the time a shield bash should take to be preformed. A shield bash will disallow actions + * for the number of ticks given and will knockback an oponent at time/2 + * + * @return The amount of ticks the shield bash animation will play + */ + public int getBashTimer(ItemStack shield); +} diff --git a/src/mods/battlegear2/api/ISpecialEffect.java b/src/mods/battlegear2/api/ISpecialEffect.java new file mode 100644 index 00000000000..ab0d02c18ad --- /dev/null +++ b/src/mods/battlegear2/api/ISpecialEffect.java @@ -0,0 +1,16 @@ +package mods.battlegear2.api; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; + +public interface ISpecialEffect { + /** + * + * @param entityHit The entity the effect will be applied to. + * @param entityHitting + * @return true if it adds an hitting action + */ + public boolean performEffects(EntityLivingBase entityHit, EntityLivingBase entityHitting); +} diff --git a/src/mods/battlegear2/api/OffhandAttackEvent.java b/src/mods/battlegear2/api/OffhandAttackEvent.java new file mode 100644 index 00000000000..3de16f1f676 --- /dev/null +++ b/src/mods/battlegear2/api/OffhandAttackEvent.java @@ -0,0 +1,21 @@ +package mods.battlegear2.api; + +import net.minecraft.entity.Entity; +import net.minecraftforge.event.entity.player.EntityInteractEvent; +import net.minecraftforge.event.entity.player.PlayerEvent; + +public class OffhandAttackEvent extends PlayerEventChild { + + public boolean swingOffhand = true; + public boolean shouldAttack = true; + public EntityInteractEvent event; + + public OffhandAttackEvent(EntityInteractEvent parent) { + super(parent); + this.event = parent; + } + + public Entity getTarget() { + return event.target; + } +} \ No newline at end of file diff --git a/src/mods/battlegear2/api/PlayerEventChild.java b/src/mods/battlegear2/api/PlayerEventChild.java new file mode 100644 index 00000000000..654952c00c7 --- /dev/null +++ b/src/mods/battlegear2/api/PlayerEventChild.java @@ -0,0 +1,32 @@ +package mods.battlegear2.api; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.event.Event.Result; +import net.minecraftforge.event.entity.player.PlayerEvent; + +public class PlayerEventChild extends PlayerEvent{ + + public PlayerEvent parent; + + public PlayerEventChild(PlayerEvent parent) { + super(parent.entityPlayer); + this.parent = parent; + } + + public void setCancelParentEvent(boolean cancel) { + parent.setCanceled(cancel); + } + + @Override + public void setCanceled(boolean cancel) { + super.setCanceled(cancel); + parent.setCanceled(cancel); + } + + @Override + public void setResult(Result value) { + super.setResult(value); + parent.setResult(value); + } +} diff --git a/src/mods/battlegear2/api/QuiverArrowEvent.java b/src/mods/battlegear2/api/QuiverArrowEvent.java new file mode 100644 index 00000000000..df6df620b03 --- /dev/null +++ b/src/mods/battlegear2/api/QuiverArrowEvent.java @@ -0,0 +1,29 @@ +package mods.battlegear2.api; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.player.ArrowLooseEvent; +import net.minecraftforge.event.entity.player.PlayerEvent; + +public class QuiverArrowEvent extends PlayerEventChild{ + + public int bowDamage = 1; + public float bowSoundVolume = 1.0F; + public boolean addEnchantments = true; + public ArrowLooseEvent event; + + public QuiverArrowEvent(ArrowLooseEvent parent) { + super(parent); + this.event = parent; + } + + public ItemStack getBow() + { + return event.bow; + } + + public int getCharge() + { + return event.charge; + } +} diff --git a/src/mods/battlegear2/api/QuiverArrowRegistry.java b/src/mods/battlegear2/api/QuiverArrowRegistry.java new file mode 100644 index 00000000000..8787a2d979c --- /dev/null +++ b/src/mods/battlegear2/api/QuiverArrowRegistry.java @@ -0,0 +1,42 @@ +package mods.battlegear2.api; + +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.item.ItemStack; + +import java.util.Comparator; +import java.util.Map; +import java.util.TreeMap; + +public class QuiverArrowRegistry { + + private static Map> map = new TreeMap>(new StackComparator()); + + public static void addArrowToRegistry(int itemId, int itemMetadata, Class entityArrow){ + ItemStack stack = new ItemStack(itemId, 1, itemMetadata); + map.put(stack, entityArrow); + } + + public static Class getArrowClass(ItemStack stack){ + return map.get(stack); + } + + static class StackComparator implements Comparator { + @Override + public int compare(ItemStack stack, ItemStack stack2) { + + if(stack == stack2){ + return 0; + }else{ + + int idDiff = stack.itemID - stack2.itemID; + if(idDiff != 0){ + return idDiff; + }else + return stack.getItemDamage() - stack2.getItemDamage(); + } + + } + } + + +} diff --git a/src/mods/battlegear2/api/heraldry/HeraldryData.java b/src/mods/battlegear2/api/heraldry/HeraldryData.java new file mode 100644 index 00000000000..46fc6ec7a65 --- /dev/null +++ b/src/mods/battlegear2/api/heraldry/HeraldryData.java @@ -0,0 +1,138 @@ +package mods.battlegear2.api.heraldry; + +import mods.battlegear2.utils.BattlegearUtils; + +import java.io.*; +import java.util.Arrays; + +public class HeraldryData { + + + public static final int RED = 1; + public static final int GREEN = 2; + public static final int BLUE = 3; + + private byte pattern; + private short crest; + private byte crestPosition; + private int[] colours = new int[5]; + + private byte helm; + private byte banner; + + private byte[] byteArray = null; + + public HeraldryData(int pattern, int pattern_col_1, int pattern_col_2, int pattern_col_3, int crest, int crest_col_1, int crest_col_2, int crest_position, int helm, int banner) { + this.pattern = (byte) pattern; + this.crest = (short) crest; + colours = new int[]{pattern_col_1, pattern_col_2, pattern_col_3, crest_col_1, crest_col_2}; + this.crestPosition = (byte) crest_position; + this.helm = (byte) helm; + this.banner = (byte) banner; + } + + public HeraldryData(byte pattern, int pattern_col_1, int pattern_col_2, int pattern_col_3){ + this(pattern, pattern_col_1, pattern_col_2, pattern_col_3, 0, 0, 0,0, 0, 0); + } + + public HeraldryData(byte[] data){ + DataInputStream input = null; + + try{ + input = new DataInputStream(new ByteArrayInputStream(data)); + + pattern = input.readByte();; + crest = input.readShort(); + crestPosition = input.readByte(); + colours= new int[5]; + for(int i = 0; i < colours.length; i++){ + colours[i] = input.readInt(); + } + + helm = input.readByte(); + banner = input.readByte(); + + byteArray = Arrays.copyOf(data, data.length); + + }catch (Exception e){ + e.printStackTrace(); + }finally { + BattlegearUtils.closeStream(input); + } + } + + public static HeraldryData getDefault() { + return new HeraldryData(10, 0xFF000000, 0xFFFFFFFF, 0xFFFFFF00, 0, 0xFF000000, 0xFF000000, 0, 0, 0); + } + + public byte[] getByteArray(){ + + if(byteArray != null){ + return byteArray; + } + + DataOutputStream output = null; + + ByteArrayOutputStream bos = null; + + try{ + bos = new ByteArrayOutputStream(); + output = new DataOutputStream(bos); + + output.writeByte(pattern); + output.writeShort(crest); + output.writeByte(crestPosition); + for(int i = 0; i < 5; i++){ + output.writeInt(colours[i]); + } + + output.writeByte(helm); + output.writeByte(banner); + + return bos.toByteArray(); + } catch (Exception e){ + e.printStackTrace(); + } finally { + BattlegearUtils.closeStream(output); + } + + return null; + } + + public int getColourChanel(int colour, int chanelNo){ + switch (chanelNo){ + case RED: + return (colours[colour] >> 16) & 0xFF; + case GREEN: + return (colours[colour] >> 8) & 0xFF; + case BLUE: + return (colours[colour] >> 0) & 0xFF; + default: + return (colours[colour] >> 16) & 0xFF; + } + } + + public byte getPattern() { + return pattern; + } + + public int getColour(int i) { + return colours[i]; + } + + @Override + public String toString() { + return byteArrayToHex(getByteArray()); + } + + public static String byteArrayToHex(byte[] a) { + StringBuilder sb = new StringBuilder(); + for(byte b: a) + sb.append(String.format("%02x", b&0xff)); + return sb.toString(); + } + + public short getCrest() { + return crest; + } +} diff --git a/src/mods/battlegear2/api/heraldry/IHeraldryItem.java b/src/mods/battlegear2/api/heraldry/IHeraldryItem.java new file mode 100644 index 00000000000..040d1013826 --- /dev/null +++ b/src/mods/battlegear2/api/heraldry/IHeraldryItem.java @@ -0,0 +1,59 @@ +package mods.battlegear2.api.heraldry; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; + +public interface IHeraldryItem { + + public enum HeraldyRenderPassess{ + Pattern, + SecondaryColourTrim, + PostRenderIcon + } + + /** + * Returns the "base" icon. This icon will be coloured the primary colour + */ + public Icon getBaseIcon(ItemStack stack); + /** + * Returns the trim icon, This will be coloured the secondary colour + */ + public Icon getTrimIcon(ItemStack stack); + /** + * Returns the post render icon, this Icon will render after all other rendering passess in it's default colour + */ + public Icon getPostRenderIcon(ItemStack stack); + + + /** + * Returns true if the given itemstack has heraldy attached + */ + public boolean hasHeraldry(ItemStack stack); + /** + * Returns the current heraldy code, this will only be called on ItemStacks that have been found to have heraldry using the hasHeraldryMethod + */ + public byte[] getHeraldry(ItemStack stack); + + /** + * Saves the given heraldry code in the given stack. It is recommended to save the Byte array representation of the crest in the NBT + */ + public void setHeraldry(ItemStack stack, byte[] data); + + /** + * Removes the heraldry code from the item + */ + public void removeHeraldry(ItemStack item); + + /** + * Returns true if the default renderer should perform the given render pass + */ + public boolean shouldDoPass(HeraldyRenderPassess pass); + + /** + * Returns true if the default renderer should be used. + * If the method returns true, the default renderer will be attached. + * If this method returns false it is the modders responsibility to attach an appropriate renderer + */ + public boolean useDefaultRenderer(); + +} diff --git a/src/mods/battlegear2/api/quiver/IArrowContainer.java b/src/mods/battlegear2/api/quiver/IArrowContainer.java new file mode 100644 index 00000000000..fe8c67338fe --- /dev/null +++ b/src/mods/battlegear2/api/quiver/IArrowContainer.java @@ -0,0 +1,55 @@ +package mods.battlegear2.api.quiver; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +@Deprecated +public interface IArrowContainer{ + + /** + * + * @param stack The {@link #ItemStack} representing this item + * @param bow The bow trying to use this container + * @param player The {@link #EntityPlayer} using the bow + * @return true if the item contains at least one arrow + */ + public boolean hasArrowFor(ItemStack stack, ItemStack bow, EntityPlayer player); + /** + * The arrow spawned when bow is used with this non empty container equipped + * @param stack The {@link #ItemStack} representing this item + * @param charge Amount of charge in the bow, ranging from 0.2F to 2.0F + * @param player The {@link #EntityPlayer} using the bow + * @param world + * @return the arrow entity to spawn when bow is used + */ + public EntityArrow getArrowType(ItemStack stack, World world, EntityPlayer player, float charge); + /** + * Action to take after an arrow has been fired + * Usually equal to removing an arrow from the container + * @param player The {@link #EntityPlayer} using the bow + * @param world + * @param stack The {@link #ItemStack} representing this item + * @param bow The bow which fired + * @param arrow the arrow fired + */ + public void onArrowFired(World world, EntityPlayer player, ItemStack stack, ItemStack bow, EntityArrow arrow); + /** + * Called before the arrow is fired from this container + * @param arrowEvent Used to decide bow damage, bow sound and arrow enchantment + */ + public void onPreArrowFired(QuiverArrowEvent arrowEvent); + /** + * Called when the container is put on a crafting bench with vanilla arrows + * @param stack + * @return True to receive {@link #addArrows(ItemStack, int)} + */ + public boolean isCraftableWithArrows(ItemStack stack); + /** + * Crafts the item with vanilla arrows + * @param stack + * @param arrows Number of vanilla arrows on the crafting bench + * @return Number of vanilla arrows that couldn't fit in + */ + public int addArrows(ItemStack stack, int arrows); +} diff --git a/src/mods/battlegear2/api/quiver/IArrowContainer2.java b/src/mods/battlegear2/api/quiver/IArrowContainer2.java new file mode 100644 index 00000000000..9ad1355e43b --- /dev/null +++ b/src/mods/battlegear2/api/quiver/IArrowContainer2.java @@ -0,0 +1,99 @@ +package mods.battlegear2.api.quiver; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface IArrowContainer2 { + + /** + * Returns the maximum amout of slots in the arrow container + * @param container {@link #ItemStack} representing this item + * @return the amount of slots + */ + public int getSlotCount(ItemStack container); + + /** + * Returns the currently selected slot in the arrow container + * @param container {@link #ItemStack} representing this item + * @return the currently selected slot + */ + public int getSelectedSlot(ItemStack container); + + /** + * Sets the currently selected slot to the given value + * @param container {@link #ItemStack} representing this item + * @param newSlot the new slot index + */ + public void setSelectedSlot(ItemStack container, int newSlot); + + /** + * Returns the itemStack in the currently selected slot + * @param container The {@link #ItemStack} representing this item + * @param slot the slot index + * @return The {@link #ItemStack} in the given slot. + */ + public ItemStack getStackInSlot(ItemStack container, int slot); + + /** + * Sets places the given item stack in the give slot + * @param container {@link #ItemStack} representing this item + * @param slot the slot index + * @param container {@link #ItemStack} representing the new stack + */ + public void setStackInSlot(ItemStack container, int slot, ItemStack stack); + + + /** + * + * @param container The {@link #ItemStack} representing this item + * @param bow The bow trying to use this container + * @param player The {@link #EntityPlayer} using the bow + * @return true if the item contains at least one arrow in the selected slot + */ + public boolean hasArrowFor(ItemStack container, ItemStack bow, EntityPlayer player, int slot); + + /** + * The arrow spawned when bow is used with this non empty container equipped + * @param container The {@link #ItemStack} representing this item + * @param charge Amount of charge in the bow, ranging from 0.2F to 2.0F + * @param player The {@link #EntityPlayer} using the bow + * @param world + * @return the arrow entity to spawn when bow is used + */ + public EntityArrow getArrowType(ItemStack container, World world, EntityPlayer player, float charge); + /** + * Action to take after an arrow has been fired + * Usually equal to removing an arrow from the container + * @param player The {@link #EntityPlayer} using the bow + * @param world + * @param container The {@link #ItemStack} representing this item + * @param bow The bow which fired + * @param arrow the arrow fired + */ + public void onArrowFired(World world, EntityPlayer player, ItemStack container, ItemStack bow, EntityArrow arrow); + /** + * Called before the arrow is fired from this container + * @param arrowEvent Used to decide bow damage, bow sound and arrow enchantment + */ + public void onPreArrowFired(QuiverArrowEvent arrowEvent); + /** + * Called when the container is put on a crafting bench with other items + * @param container The {@link #ItemStack} representing this item + * @param arrowStack The {@link #ItemStack} representing other items + * @return True to receive {@link #addArrows(ItemStack, ItemStack)} + */ + public boolean isCraftableWithArrows(ItemStack contaner, ItemStack arrowStack); + + /** + * Crafts the item with the items from {@link #isCraftableWithArrows(ItemStack, ItemStack)} + * @param container The {@link #ItemStack} representing this item + * @param arrows Another valid item on the crafting bench + * @return Number of arrows that couldn't fit in + */ + public ItemStack addArrows(ItemStack container, ItemStack newStack); + + + +} diff --git a/src/mods/battlegear2/api/quiver/QuiverArrowEvent.java b/src/mods/battlegear2/api/quiver/QuiverArrowEvent.java new file mode 100644 index 00000000000..f410261a166 --- /dev/null +++ b/src/mods/battlegear2/api/quiver/QuiverArrowEvent.java @@ -0,0 +1,30 @@ +package mods.battlegear2.api.quiver; + +import mods.battlegear2.api.PlayerEventChild; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.player.ArrowLooseEvent; +import net.minecraftforge.event.entity.player.PlayerEvent; + +public class QuiverArrowEvent extends PlayerEventChild{ + + public int bowDamage = 1; + public float bowSoundVolume = 1.0F; + public boolean addEnchantments = true; + public ArrowLooseEvent event; + + public QuiverArrowEvent(ArrowLooseEvent parent) { + super(parent); + this.event = parent; + } + + public ItemStack getBow() + { + return event.bow; + } + + public int getCharge() + { + return event.charge; + } +} diff --git a/src/mods/battlegear2/api/quiver/QuiverArrowRegistry.java b/src/mods/battlegear2/api/quiver/QuiverArrowRegistry.java new file mode 100644 index 00000000000..072930c2587 --- /dev/null +++ b/src/mods/battlegear2/api/quiver/QuiverArrowRegistry.java @@ -0,0 +1,42 @@ +package mods.battlegear2.api.quiver; + +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.item.ItemStack; + +import java.util.Comparator; +import java.util.Map; +import java.util.TreeMap; + +public class QuiverArrowRegistry { + + private static Map> map = new TreeMap>(new StackComparator()); + + public static void addArrowToRegistry(int itemId, int itemMetadata, Class entityArrow){ + ItemStack stack = new ItemStack(itemId, 1, itemMetadata); + map.put(stack, entityArrow); + } + + public static Class getArrowClass(ItemStack stack){ + return map.get(stack); + } + + static class StackComparator implements Comparator { + @Override + public int compare(ItemStack stack, ItemStack stack2) { + + if(stack == stack2){ + return 0; + }else{ + + int idDiff = stack.itemID - stack2.itemID; + if(idDiff != 0){ + return idDiff; + }else + return stack.getItemDamage() - stack2.getItemDamage(); + } + + } + } + + +} diff --git a/src/mods/battlegear2/api/weapons/IBackStabbable.java b/src/mods/battlegear2/api/weapons/IBackStabbable.java new file mode 100644 index 00000000000..36025eca0d3 --- /dev/null +++ b/src/mods/battlegear2/api/weapons/IBackStabbable.java @@ -0,0 +1,14 @@ +package mods.battlegear2.api.weapons; + +import net.minecraft.entity.EntityLivingBase; + +public interface IBackStabbable { + + /** + * Action to perform on back stabbing + * @param entityHit + * @param entityHitting + * @return true if it adds an hitting action + */ + public boolean onBackStab(EntityLivingBase entityHit, EntityLivingBase entityHitting); +} diff --git a/src/mods/battlegear2/api/weapons/IBattlegearWeapon.java b/src/mods/battlegear2/api/weapons/IBattlegearWeapon.java new file mode 100644 index 00000000000..ccdceb5ebd0 --- /dev/null +++ b/src/mods/battlegear2/api/weapons/IBattlegearWeapon.java @@ -0,0 +1,70 @@ +package mods.battlegear2.api.weapons; + +import cpw.mods.fml.relauncher.Side; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +public interface IBattlegearWeapon { + + /** + * Returns true if the weapon will allow other weapons to be placed in the partner offhand slot + */ + public boolean willAllowOffhandWeapon(); + + /** + * Will allow shield + */ + public boolean willAllowShield(); + + /** + * Returns true if the weapon be dual wielded in the offhand slot + */ + public boolean isOffhandHandDualWeapon(); + + /** + * Returns true if the weapon should always be sheathed on the back, false if it should be sheathed on the hip + */ + public boolean sheatheOnBack(); + + /** + * Perform any function when the item is held in the offhand and the user right clicks an entity. + * This is generally used to attack an entity with the offhand item. If this is the case the event should + * be canceled to prevent any default right clicking events (Eg Villager Trading) + * + * @param event the OffhandAttackEvent that was generated + * @param mainhandItem the ItemStack currently being held in the right hand + * @param offhandItem the ItemStack currently being held in the left hand + * @return true if the off hand swing animation should be performed + */ + public boolean offhandAttackEntity(OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem); + + /** + * Perform any function when the item is held in the offhand and the user right clicks "Air". + * + * @param event the PlayerInteractEvent that was generated + * @param mainhandItem the ItemStack currently being held in the right hand + * @param offhandItem the ItemStack currently being held in the left hand + * @return true if the off hand swing animation should be performed + */ + public boolean offhandClickAir(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem); + + /** + * Perform any function when the item is held in the offhand and the user right clicks a block. + * Note that this will happen prior to the activation of any activation functions of blocks + * + * @param event the PlayerInteractEvent that was generated + * @param mainhandItem the ItemStack currently being held in the right hand + * @param offhandItem the ItemStack currently being held in the left hand + */ + public boolean offhandClickBlock(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem); + + /** + * Perform any passive effects on each game tick when the item is held in the offhand + * + * @param effectiveSide the effective side the method was called from + * @param mainhandItem the ItemStack currently being held in the right hand + * @param offhandItem the ItemStack currently being held in the left hand + */ + public void performPassiveEffects(Side effectiveSide, ItemStack mainhandItem, ItemStack offhandItem); + +} \ No newline at end of file diff --git a/src/mods/battlegear2/api/weapons/IExtendedReachWeapon.java b/src/mods/battlegear2/api/weapons/IExtendedReachWeapon.java new file mode 100644 index 00000000000..fce706042dd --- /dev/null +++ b/src/mods/battlegear2/api/weapons/IExtendedReachWeapon.java @@ -0,0 +1,12 @@ +package mods.battlegear2.api.weapons; + +import net.minecraft.item.ItemStack; + +public interface IExtendedReachWeapon { + /** + * The distance the weapon will hit (note this will ONLY work for main hand weapons) + * @param stack + * @return + */ + public float getReachModifierInBlocks(ItemStack stack); +} diff --git a/src/mods/battlegear2/api/weapons/IHitTimeModifier.java b/src/mods/battlegear2/api/weapons/IHitTimeModifier.java new file mode 100644 index 00000000000..38afe94e47d --- /dev/null +++ b/src/mods/battlegear2/api/weapons/IHitTimeModifier.java @@ -0,0 +1,15 @@ +package mods.battlegear2.api.weapons; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; + +public interface IHitTimeModifier { + /** + * + * @param entityHit + * @return The amount to modify the hit shield + */ + public int getHitTime(ItemStack stack, EntityLivingBase entityHit); + +} diff --git a/src/mods/battlegear2/api/weapons/IPenetrateWeapon.java b/src/mods/battlegear2/api/weapons/IPenetrateWeapon.java new file mode 100644 index 00000000000..ae959c993d9 --- /dev/null +++ b/src/mods/battlegear2/api/weapons/IPenetrateWeapon.java @@ -0,0 +1,13 @@ +package mods.battlegear2.api.weapons; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; + +public interface IPenetrateWeapon { + /** + * The amount of damage bypassing armor + * @param stack The {@link net.minecraft.item.ItemStack} representative of the item dealing the hit. + * @return the amount of damage that bypasses armour + */ + public int getPenetratingPower(ItemStack stack); +} diff --git a/src/mods/battlegear2/api/weapons/IPotionEffect.java b/src/mods/battlegear2/api/weapons/IPotionEffect.java new file mode 100644 index 00000000000..a310ee1764c --- /dev/null +++ b/src/mods/battlegear2/api/weapons/IPotionEffect.java @@ -0,0 +1,23 @@ +package mods.battlegear2.api.weapons; + + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.potion.PotionEffect; + +import java.util.Map; + +public interface IPotionEffect { + + + /** + * Returns a map containing the potion effects to apply to an entity hit by the weapon. Each effect + * has a float value associated with the chance of applying the effect. Note that the "dice roll" only + * occurs once so any value under this roll will be applied. + * + * @param entityHit The entity the effect will be applied to. + * @param entityHitting + * @return A Map of {@link PotionEffect} with chance value ranging from 0 to 1, to be dealt to the entityHit + */ + public Map getEffectsOnHit(EntityLivingBase entityHit, EntityLivingBase entityHitting); + +} diff --git a/src/mods/battlegear2/api/weapons/ISpecialEffect.java b/src/mods/battlegear2/api/weapons/ISpecialEffect.java new file mode 100644 index 00000000000..9f52e9bb95e --- /dev/null +++ b/src/mods/battlegear2/api/weapons/ISpecialEffect.java @@ -0,0 +1,16 @@ +package mods.battlegear2.api.weapons; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; + +public interface ISpecialEffect { + /** + * + * @param entityHit The entity the effect will be applied to. + * @param entityHitting + * @return true if it adds an hitting action + */ + public boolean performEffects(EntityLivingBase entityHit, EntityLivingBase entityHitting); +} diff --git a/src/mods/battlegear2/api/weapons/OffhandAttackEvent.java b/src/mods/battlegear2/api/weapons/OffhandAttackEvent.java new file mode 100644 index 00000000000..273b1d5f81e --- /dev/null +++ b/src/mods/battlegear2/api/weapons/OffhandAttackEvent.java @@ -0,0 +1,22 @@ +package mods.battlegear2.api.weapons; + +import mods.battlegear2.api.PlayerEventChild; +import net.minecraft.entity.Entity; +import net.minecraftforge.event.entity.player.EntityInteractEvent; +import net.minecraftforge.event.entity.player.PlayerEvent; + +public class OffhandAttackEvent extends PlayerEventChild { + + public boolean swingOffhand = true; + public boolean shouldAttack = true; + public EntityInteractEvent event; + + public OffhandAttackEvent(EntityInteractEvent parent) { + super(parent); + this.event = parent; + } + + public Entity getTarget() { + return event.target; + } +} \ No newline at end of file diff --git a/src/tconstruct/items/tools/Arrow.java b/src/tconstruct/items/tools/Arrow.java index 33d03b41a96..27dea1d8e43 100644 --- a/src/tconstruct/items/tools/Arrow.java +++ b/src/tconstruct/items/tools/Arrow.java @@ -225,4 +225,9 @@ else if (power > this.getMaxCharge(stack) * 2 / 3) } } } + + @Override + public boolean isOffhandHandDualWeapon() { + return false; + } } diff --git a/src/tconstruct/items/tools/Battleaxe.java b/src/tconstruct/items/tools/Battleaxe.java index ca11758079b..fe9edb2042c 100644 --- a/src/tconstruct/items/tools/Battleaxe.java +++ b/src/tconstruct/items/tools/Battleaxe.java @@ -300,4 +300,19 @@ public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPl world.playAuxSFX(2001, x, y, z, woodID + (meta << 12)); return super.onBlockStartBreak(stack, x, y, z, player); } + + @Override + public boolean willAllowOffhandWeapon() { + return false; + } + + @Override + public boolean willAllowShield() { + return false; + } + + @Override + public boolean isOffhandHandDualWeapon() { + return false; + } } diff --git a/src/tconstruct/items/tools/Chisel.java b/src/tconstruct/items/tools/Chisel.java index e64a348f0a4..0b012a82d09 100644 --- a/src/tconstruct/items/tools/Chisel.java +++ b/src/tconstruct/items/tools/Chisel.java @@ -226,4 +226,18 @@ public String[] toolCategories () return new String[] { "utility" }; } + @Override + public boolean willAllowOffhandWeapon() { + return false; + } + + @Override + public boolean willAllowShield() { + return false; + } + + @Override + public boolean isOffhandHandDualWeapon() { + return false; + } } diff --git a/src/tconstruct/items/tools/Cleaver.java b/src/tconstruct/items/tools/Cleaver.java index 59d28e69a8d..7d0dc27f8f8 100644 --- a/src/tconstruct/items/tools/Cleaver.java +++ b/src/tconstruct/items/tools/Cleaver.java @@ -3,6 +3,7 @@ import tconstruct.common.TContent; import tconstruct.library.tools.AbilityHelper; import tconstruct.library.tools.Weapon; +import tconstruct.util.PHConstruct; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -161,4 +162,24 @@ public boolean onEntitySwing (EntityLiving entity, ItemStack stack) entity.swingProgressInt /= 2; return false; }*/ + + @Override + public boolean willAllowOffhandWeapon() { + return false; + } + + @Override + public boolean willAllowShield() { + return PHConstruct.isCleaverTwoHanded; + } + + @Override + public boolean isOffhandHandDualWeapon() { + return false; + } + + @Override + public boolean sheatheOnBack() { + return true; + } } diff --git a/src/tconstruct/items/tools/Excavator.java b/src/tconstruct/items/tools/Excavator.java index cc99bdbaca7..d6bd8288985 100644 --- a/src/tconstruct/items/tools/Excavator.java +++ b/src/tconstruct/items/tools/Excavator.java @@ -293,4 +293,24 @@ public float getStrVsBlock (ItemStack stack, Block block, int meta) } return super.getStrVsBlock(stack, block, meta); } + + @Override + public boolean willAllowOffhandWeapon() { + return false; + } + + @Override + public boolean willAllowShield() { + return false; + } + + @Override + public boolean isOffhandHandDualWeapon() { + return false; + } + + @Override + public boolean sheatheOnBack() { + return true; + } } diff --git a/src/tconstruct/items/tools/Hammer.java b/src/tconstruct/items/tools/Hammer.java index 927e13418f9..dc3e2ee367a 100644 --- a/src/tconstruct/items/tools/Hammer.java +++ b/src/tconstruct/items/tools/Hammer.java @@ -399,4 +399,24 @@ public String[] toolCategories () { return new String[] { "weapon", "harvest", "melee", "bludgeoning" }; } + + @Override + public boolean willAllowOffhandWeapon() { + return false; + } + + @Override + public boolean willAllowShield() { + return false; + } + + @Override + public boolean isOffhandHandDualWeapon() { + return false; + } + + @Override + public boolean sheatheOnBack() { + return true; + } } diff --git a/src/tconstruct/items/tools/Hatchet.java b/src/tconstruct/items/tools/Hatchet.java index 2baad903685..d0e3dda6d3c 100644 --- a/src/tconstruct/items/tools/Hatchet.java +++ b/src/tconstruct/items/tools/Hatchet.java @@ -104,4 +104,9 @@ public String getDefaultFolder () { return "axe"; } + + @Override + public boolean isOffhandHandDualWeapon() { + return false; + } } diff --git a/src/tconstruct/items/tools/LumberAxe.java b/src/tconstruct/items/tools/LumberAxe.java index 7e11e124e7c..78119489fd1 100644 --- a/src/tconstruct/items/tools/LumberAxe.java +++ b/src/tconstruct/items/tools/LumberAxe.java @@ -400,4 +400,24 @@ public int durabilityTypeExtra () { return 1; } + + @Override + public boolean willAllowOffhandWeapon() { + return false; + } + + @Override + public boolean willAllowShield() { + return false; + } + + @Override + public boolean isOffhandHandDualWeapon() { + return false; + } + + @Override + public boolean sheatheOnBack() { + return true; + } } diff --git a/src/tconstruct/items/tools/Mattock.java b/src/tconstruct/items/tools/Mattock.java index 47570f57f12..624ed60f24e 100644 --- a/src/tconstruct/items/tools/Mattock.java +++ b/src/tconstruct/items/tools/Mattock.java @@ -140,4 +140,24 @@ private boolean allowCrafting (int head) } return true; } + + @Override + public boolean willAllowOffhandWeapon() { + return false; + } + + @Override + public boolean willAllowShield() { + return false; + } + + @Override + public boolean isOffhandHandDualWeapon() { + return false; + } + + @Override + public boolean sheatheOnBack() { + return true; + } } \ No newline at end of file diff --git a/src/tconstruct/items/tools/Pickaxe.java b/src/tconstruct/items/tools/Pickaxe.java index ce995f877a8..ac2ed5ff345 100644 --- a/src/tconstruct/items/tools/Pickaxe.java +++ b/src/tconstruct/items/tools/Pickaxe.java @@ -68,4 +68,9 @@ public String getDefaultFolder () { return "pickaxe"; } + + @Override + public boolean isOffhandHandDualWeapon() { + return false; + } } diff --git a/src/tconstruct/items/tools/Scythe.java b/src/tconstruct/items/tools/Scythe.java index 080dfc11c99..0a5f986ce64 100644 --- a/src/tconstruct/items/tools/Scythe.java +++ b/src/tconstruct/items/tools/Scythe.java @@ -218,4 +218,23 @@ public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity e return true; } + @Override + public boolean willAllowOffhandWeapon() { + return false; + } + + @Override + public boolean willAllowShield() { + return false; + } + + @Override + public boolean isOffhandHandDualWeapon() { + return false; + } + + @Override + public boolean sheatheOnBack() { + return true; + } } diff --git a/src/tconstruct/items/tools/Shortbow.java b/src/tconstruct/items/tools/Shortbow.java index 90e1654a637..da72a52ae31 100644 --- a/src/tconstruct/items/tools/Shortbow.java +++ b/src/tconstruct/items/tools/Shortbow.java @@ -191,4 +191,24 @@ public String getBowstringName (int type) } //return TConstructRegistry.getMaterial(type).ability(); } + + @Override + public boolean willAllowOffhandWeapon() { + return false; + } + + @Override + public boolean willAllowShield() { + return false; + } + + @Override + public boolean isOffhandHandDualWeapon() { + return false; + } + + @Override + public boolean sheatheOnBack() { + return true; + } } diff --git a/src/tconstruct/items/tools/Shovel.java b/src/tconstruct/items/tools/Shovel.java index bc9d8a22376..255000de542 100644 --- a/src/tconstruct/items/tools/Shovel.java +++ b/src/tconstruct/items/tools/Shovel.java @@ -89,6 +89,11 @@ public String getDefaultFolder () { return "shovel"; } + + @Override + public boolean isOffhandHandDualWeapon() { + return false; + } /*@Override public Icon getIcon (ItemStack stack, int renderPass) diff --git a/src/tconstruct/library/tools/ToolCore.java b/src/tconstruct/library/tools/ToolCore.java index b567d6b26b9..537fe00a389 100644 --- a/src/tconstruct/library/tools/ToolCore.java +++ b/src/tconstruct/library/tools/ToolCore.java @@ -13,6 +13,8 @@ import tconstruct.library.TConstructRegistry; import tconstruct.library.crafting.ToolBuilder; +import mods.battlegear2.api.weapons.IBattlegearWeapon; +import mods.battlegear2.api.weapons.OffhandAttackEvent; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -26,6 +28,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Icon; import net.minecraft.world.World; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -55,7 +58,7 @@ * @see ToolMod */ -public abstract class ToolCore extends Item implements ICustomElectricItem, IBoxable +public abstract class ToolCore extends Item implements ICustomElectricItem, IBoxable, IBattlegearWeapon { protected Random random = new Random(); protected int damageVsEntity; @@ -615,7 +618,7 @@ public float getStrVsBlock (ItemStack stack, Block block, int meta) public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity) { AbilityHelper.onLeftClickEntity(stack, player, entity, this, 0); - return true; + return false; } @Override @@ -937,4 +940,47 @@ public int getItemDamageFromStackForDisplay (ItemStack stack) return tags.getCompoundTag("InfiTool").getInteger("Damage"); } + + @Override + public boolean willAllowOffhandWeapon() { + return true; + } + + @Override + public boolean willAllowShield() { + return true; + } + + @Override + public boolean isOffhandHandDualWeapon() { + return true; + } + + @Override + public boolean sheatheOnBack() { + return false; + } + + @Override + public boolean offhandAttackEntity(OffhandAttackEvent event, + ItemStack mainhandItem, ItemStack offhandItem) { + return true; + } + + @Override + public boolean offhandClickAir(PlayerInteractEvent event, + ItemStack mainhandItem, ItemStack offhandItem) { + return true; + } + + @Override + public boolean offhandClickBlock(PlayerInteractEvent event, + ItemStack mainhandItem, ItemStack offhandItem) { + return true; + } + + @Override + public void performPassiveEffects(Side effectiveSide, + ItemStack mainhandItem, ItemStack offhandItem) { + } } diff --git a/src/tconstruct/library/tools/Weapon.java b/src/tconstruct/library/tools/Weapon.java index ed95c69df40..0f8f5e59542 100644 --- a/src/tconstruct/library/tools/Weapon.java +++ b/src/tconstruct/library/tools/Weapon.java @@ -125,4 +125,6 @@ public String[] toolCategories () public static Material[] web = new Material[] { Material.web }; public static Material[] none = new Material[0]; + + } diff --git a/src/tconstruct/util/PHConstruct.java b/src/tconstruct/util/PHConstruct.java index 07577ba00ac..8f18bf957dd 100644 --- a/src/tconstruct/util/PHConstruct.java +++ b/src/tconstruct/util/PHConstruct.java @@ -361,6 +361,9 @@ public static void initProps (File location) cfgDimBlackList = config.get("DimBlackList", "SlimeIslandDimBlacklist",new int[]{}).getIntList(); slimeIslGenDim0Only = config.get("DimBlackList","GenerateSlimeIslandInDim0Only" , false).getBoolean(false); + //Addon stuff + isCleaverTwoHanded = config.get("Battlegear", "Can Cleavers have shields", true).getBoolean(true); + /* Save the configuration file */ config.save(); @@ -681,4 +684,7 @@ public static void initProps (File location) //dimensionblacklist public static boolean slimeIslGenDim0Only; public static int[] cfgDimBlackList; + + //Addon stuff + public static boolean isCleaverTwoHanded; }