diff --git a/1.2.10.2/main.cpp b/1.2.10.2/main.cpp index c6e4d95..9e463b3 100644 --- a/1.2.10.2/main.cpp +++ b/1.2.10.2/main.cpp @@ -7,6 +7,8 @@ #include "minecraftpe/item/Item.h" +#include "mod/sword_item.h" + void (*_Item_registerItems)(Item *); void Item_registerItems(Item * self) { _Item_registerItems(self); @@ -14,18 +16,22 @@ void Item_registerItems(Item * self) { //Item::mItemLookupMap.emplace("testitem",std::unique_ptr(Item::mItems[1000])); Item::mItems[1000] -> setIsGlint(true); Item::mItems[1000] -> setCategory(CreativeItemCategory::ITEMS); + + Item::mItems[1001] = new SwordItem("SwordItem",1001 - 256); } void (*_Item_initClientData)(Item *); void Item_initClientData(Item * self) { _Item_initClientData(self); Item::mItems[1000] -> setIcon("apple",0); + Item::mItems[1001] -> setIcon("sword",0); } void (*_Item_initCreativeItems)(Item *); void Item_initCreativeItems(Item * self) { _Item_initCreativeItems(self); Item::addCreativeItem(1000,0); + Item::addCreativeItem(1001,0); } JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { diff --git a/1.2.10.2/mod/sword_item.cpp b/1.2.10.2/mod/sword_item.cpp new file mode 100644 index 0000000..923bf45 --- /dev/null +++ b/1.2.10.2/mod/sword_item.cpp @@ -0,0 +1,36 @@ +#include "sword_item.h" + +SwordItem::SwordItem(std::string const& name,int id) : Item(name,id) { + setMaxStackSize(1); + setCategory(CreativeItemCategory::EQUIPMENT); + setMaxDamage(888); + setHandEquipped(); +} + +int SwordItem::getAttackDamage() const { + return 8; +} + +bool SwordItem::canDestroyInCreative() const { + return false; +} + +int SwordItem::getEnchantSlot() const { + return 16; +} + +int SwordItem::getEnchantValue() const { + return 35; +} + +float SwordItem::getDestroySpeed(ItemInstance const& item, Block const& block) const { + return mSword_iron -> getDestroySpeed(item,block); +} + +void SwordItem::hurtEnemy(ItemInstance& item, Mob* mob1, Mob* mob2) const { + //item.hurtAndBreak(1,mob1); +} + +void SwordItem::mineBlock(ItemInstance& item, BlockID blockID, int x, int y, int z, Entity* entity) const { + //item.hurtAndBreak(2,entity); +} \ No newline at end of file diff --git a/1.2.10.2/mod/sword_item.h b/1.2.10.2/mod/sword_item.h new file mode 100644 index 0000000..37f66dc --- /dev/null +++ b/1.2.10.2/mod/sword_item.h @@ -0,0 +1,16 @@ +#pragma once + +#include "minecraftpe/item/Item.h" + +class SwordItem : public Item { +public: + SwordItem(std::string const&,int); + + virtual int getAttackDamage() const; + virtual bool canDestroyInCreative() const; + virtual int getEnchantSlot() const; + virtual int getEnchantValue() const; + virtual float getDestroySpeed(ItemInstance const&, Block const&) const; + virtual void hurtEnemy(ItemInstance&, Mob*, Mob*) const; + virtual void mineBlock(ItemInstance&, BlockID, int, int, int, Entity*) const; +}; \ No newline at end of file