Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changelog: Updated the compat for the changed api Paladins with hammers and shields, ho!
- Loading branch information
1 parent
2e99697
commit f1473dc
Showing
23 changed files
with
294 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package mods.battlegear2.api; | ||
|
||
import net.minecraft.item.ItemStack; | ||
|
||
public interface IAllowItem { | ||
|
||
/** | ||
* Returns true if the mainhand {@link #ItemStack} allows the offhand {@link #ItemStack} to be placed in the partner offhand slot | ||
*/ | ||
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package mods.battlegear2.api; | ||
|
||
import mods.battlegear2.enchantments.BaseEnchantment; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public interface IEnchantable { | ||
|
||
/** | ||
* If a Battlegear {@link #BaseEnchantment} can be applied to this item, given the {@link #ItemStack} | ||
* @param baseEnchantment | ||
* @param stack | ||
* @return | ||
*/ | ||
public boolean isEnchantable(BaseEnchantment baseEnchantment, ItemStack stack); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package mods.battlegear2.api; | ||
|
||
import cpw.mods.fml.relauncher.Side; | ||
import mods.battlegear2.api.weapons.OffhandAttackEvent; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.event.entity.player.PlayerInteractEvent; | ||
|
||
public interface IOffhandDual { | ||
/** | ||
* Returns true if the item can be dual wielded in the offhand slot | ||
*/ | ||
public boolean isOffhandHandDual(ItemStack off); | ||
|
||
/** | ||
* 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 | ||
* @return true if the off hand swing animation should be performed | ||
*/ | ||
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package mods.battlegear2.api; | ||
|
||
import net.minecraft.item.ItemStack; | ||
|
||
public interface ISheathed { | ||
|
||
/** | ||
* Returns true if the item should always be sheathed on the back, false if it should be sheathed on the hip | ||
* @param item the {@link #ItemStack} to be sheathed | ||
*/ | ||
public boolean sheatheOnBack(ItemStack item); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,12 @@ | ||
package mods.battlegear2.api.weapons; | ||
|
||
import cpw.mods.fml.relauncher.Side; | ||
import mods.battlegear2.api.IAllowItem; | ||
import mods.battlegear2.api.IOffhandDual; | ||
import mods.battlegear2.api.ISheathed; | ||
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); | ||
public interface IBattlegearWeapon extends ISheathed,IOffhandDual,IAllowItem{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package mods.battlegear2.api.weapons; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import mods.battlegear2.utils.BattlegearUtils; | ||
import net.minecraft.item.ItemStack; | ||
/** | ||
* Registry for stacks which will be allowed in battle inventory, | ||
* accessible through {@link #FMLInterModComms} messages. | ||
* Use only if your item is not recognized by default. | ||
* Use of {@link #IBattlegearWeapon} is preferred over this method. | ||
* {@link #NBTTagCompound} are supported. | ||
* @author GotoLink | ||
* | ||
*/ | ||
public class WeaponRegistry { | ||
private static Set<StackHolder> weapons = new HashSet<StackHolder>(); | ||
private static Set<StackHolder> mainHand = new HashSet<StackHolder>(); | ||
private static Set<StackHolder> offHand = new HashSet<StackHolder>(); | ||
/** | ||
* Called by a {@link #IMCMessage} with "Dual" as key, and the {@link #ItemStack} as value | ||
* @param stack registered as dual wieldable | ||
*/ | ||
public static void addDualWeapon(ItemStack stack) { | ||
if(!BattlegearUtils.checkForRightClickFunction(stack.getItem())){ | ||
weapons.add(new StackHolder(stack)); | ||
mainHand.add(new StackHolder(stack)); | ||
offHand.add(new StackHolder(stack)); | ||
} | ||
} | ||
|
||
/** | ||
* Called by a {@link #IMCMessage} with "MainHand" as key, and the {@link #ItemStack} as value | ||
* @param stack registered as wieldable only in main hand | ||
*/ | ||
public static void addTwoHanded(ItemStack stack) { | ||
if(!BattlegearUtils.checkForRightClickFunction(stack.getItem())){ | ||
weapons.add(new StackHolder(stack)); | ||
mainHand.add(new StackHolder(stack)); | ||
} | ||
} | ||
|
||
/** | ||
* Called by a {@link #IMCMessage} with "OffHand" as key, and the {@link #ItemStack} as value | ||
* @param stack registered as wieldable only in main hand | ||
*/ | ||
public static void addOffhandWeapon(ItemStack stack) { | ||
if(!BattlegearUtils.checkForRightClickFunction(stack.getItem())){ | ||
weapons.add(new StackHolder(stack)); | ||
offHand.add(new StackHolder(stack)); | ||
} | ||
} | ||
|
||
public static boolean isWeapon(ItemStack stack) { | ||
return weapons.contains(new StackHolder(stack)); | ||
} | ||
|
||
public static boolean isMainHand(ItemStack stack) { | ||
return mainHand.contains(new StackHolder(stack)); | ||
} | ||
|
||
public static boolean isOffHand(ItemStack stack) { | ||
return offHand.contains(new StackHolder(stack)); | ||
} | ||
|
||
static class StackHolder{ | ||
private ItemStack stack; | ||
|
||
public StackHolder(ItemStack stack){ | ||
this.stack = stack; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = prime + (stack == null ? 0 : stack.itemID ^ stack.stackSize + (stack.hasTagCompound() ? prime*prime ^ stack.getTagCompound().hashCode():0)); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (!(obj instanceof StackHolder)) { | ||
return false; | ||
} | ||
if (!ItemStack.areItemStacksEqual(stack, ((StackHolder) obj).stack)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.