Skip to content

Commit

Permalink
➕ Add sword item to 1.2.10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
riku1227 committed Feb 27, 2018
1 parent fd4266c commit 24f88ec
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
6 changes: 6 additions & 0 deletions 1.2.10.2/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,31 @@

#include "minecraftpe/item/Item.h"

#include "mod/sword_item.h"

void (*_Item_registerItems)(Item *);
void Item_registerItems(Item * self) {
_Item_registerItems(self);
Item::mItems[1000] = new Item("TestItem",1000 - 256);
//Item::mItemLookupMap.emplace("testitem",std::unique_ptr<Item>(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) {
Expand Down
36 changes: 36 additions & 0 deletions 1.2.10.2/mod/sword_item.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
16 changes: 16 additions & 0 deletions 1.2.10.2/mod/sword_item.h
Original file line number Diff line number Diff line change
@@ -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;
};

0 comments on commit 24f88ec

Please sign in to comment.