Add CustomItem & CustomTile
This commit is contained in:
parent
a615957d36
commit
c80d61216b
@ -38,6 +38,8 @@ add_library(mods SHARED
|
||||
# extend
|
||||
src/extend/Screen.cpp
|
||||
src/extend/DynamicTexture.cpp
|
||||
src/extend/Item.cpp
|
||||
src/extend/Tile.cpp
|
||||
# options
|
||||
src/options/options.cpp
|
||||
src/options/ui.cpp
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
#include <symbols/minecraft.h>
|
||||
|
||||
// Duplicate VTable
|
||||
template <typename T>
|
||||
T *extend_dup_vtable(T *vtable) {
|
||||
@ -65,6 +67,8 @@ auto extend_struct(auto&&... args) -> decltype(Self::allocate()) {
|
||||
protected: \
|
||||
virtual ~Custom##name() = default; \
|
||||
public:
|
||||
#include "Screen.h"
|
||||
#include "DynamicTexture.h"
|
||||
#include "internal/Screen.h"
|
||||
#include "internal/DynamicTexture.h"
|
||||
#include "internal/Item.h"
|
||||
#include "internal/Tile.h"
|
||||
#undef CREATE_HELPER
|
@ -1,8 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <symbols/minecraft.h>
|
||||
|
||||
// Custom Screen
|
||||
// Custom Animated Texture
|
||||
CREATE_HELPER(DynamicTexture)
|
||||
// Functions
|
||||
virtual void tick() = 0;
|
15
mods/include/mods/extend/internal/Item.h
Normal file
15
mods/include/mods/extend/internal/Item.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
// Custom Item
|
||||
CREATE_HELPER(Item)
|
||||
// Functions
|
||||
virtual std::string getDescriptionId(const ItemInstance *item_instance);
|
||||
virtual int getIcon(int auxiliary);
|
||||
virtual int useOn(ItemInstance *item_instance, Player *player, Level *level, int x, int y, int z, int hit_side, float hit_x, float hit_y, float hit_z);
|
||||
virtual int getUseDuration(ItemInstance *item_instance);
|
||||
virtual ItemInstance useTimeDepleted(ItemInstance *item_instance, Level *level, Player *player);
|
||||
virtual int getUseAnimation();
|
||||
virtual bool isFood();
|
||||
virtual ItemInstance *use(ItemInstance *item_instance, Level *level, Player *player);
|
||||
virtual ItemInstance *getCraftingRemainingItem(ItemInstance *item_instance);
|
||||
};
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <symbols/minecraft.h>
|
||||
|
||||
// Custom Screen
|
||||
CREATE_HELPER(Screen)
|
||||
// Functions
|
18
mods/include/mods/extend/internal/Tile.h
Normal file
18
mods/include/mods/extend/internal/Tile.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
// Custom Tile
|
||||
CREATE_HELPER(Tile)
|
||||
// Functions
|
||||
virtual std::string getDescriptionId();
|
||||
virtual int getTexture3(LevelSource *level, int x, int y, int z, int face);
|
||||
virtual int getTexture2(int face, int data);
|
||||
virtual bool isSolidRender();
|
||||
virtual int getRenderLayer();
|
||||
virtual bool isCubeShaped();
|
||||
virtual void updateShape(LevelSource *level, int x, int y, int z);
|
||||
virtual void updateDefaultShape();
|
||||
virtual AABB *getAABB(Level *level, int x, int y, int z);
|
||||
virtual int use(Level *level, int x, int y, int z, Player *player);
|
||||
virtual bool shouldRenderFace(LevelSource *level_source, int x, int y, int z, int face);
|
||||
virtual int getColor(LevelSource *level_source, int x, int y, int z);
|
||||
};
|
43
mods/src/extend/Item.cpp
Normal file
43
mods/src/extend/Item.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
#include "internal.h"
|
||||
|
||||
// Easily Create Custom Items
|
||||
ItemInstance *CustomItem::getCraftingRemainingItem(ItemInstance *item_instance) {
|
||||
return Item_vtable::base->getCraftingRemainingItem(self, item_instance);
|
||||
}
|
||||
std::string CustomItem::getDescriptionId(const ItemInstance *item_instance) {
|
||||
return Item_vtable::base->getDescriptionId(self, item_instance);
|
||||
}
|
||||
int CustomItem::getIcon(const int auxiliary) {
|
||||
return Item_vtable::base->getIcon(self, auxiliary);
|
||||
}
|
||||
int CustomItem::getUseAnimation() {
|
||||
return Item_vtable::base->getUseAnimation(self);
|
||||
}
|
||||
int CustomItem::getUseDuration(ItemInstance *item_instance) {
|
||||
return Item_vtable::base->getUseDuration(self, item_instance);
|
||||
}
|
||||
bool CustomItem::isFood() {
|
||||
return Item_vtable::base->isFood(self);
|
||||
}
|
||||
ItemInstance *CustomItem::use(ItemInstance *item_instance, Level *level, Player *player) {
|
||||
return Item_vtable::base->use(self, item_instance, level, player);
|
||||
}
|
||||
int CustomItem::useOn(ItemInstance *item_instance, Player *player, Level *level, const int x, const int y, const int z, const int hit_side, const float hit_x, const float hit_y, const float hit_z) {
|
||||
return Item_vtable::base->useOn(self, item_instance, player, level, x, y, z, hit_side, hit_x, hit_y, hit_z);
|
||||
}
|
||||
ItemInstance CustomItem::useTimeDepleted(ItemInstance *item_instance, Level *level, Player *player) {
|
||||
return Item_vtable::base->useTimeDepleted(self, item_instance, level, player);
|
||||
}
|
||||
|
||||
// VTable
|
||||
SETUP_VTABLE(Item)
|
||||
PATCH_VTABLE(getCraftingRemainingItem);
|
||||
PATCH_VTABLE(getDescriptionId);
|
||||
PATCH_VTABLE(getIcon);
|
||||
PATCH_VTABLE(getUseAnimation);
|
||||
PATCH_VTABLE(getUseDuration);
|
||||
PATCH_VTABLE(isFood);
|
||||
PATCH_VTABLE(useOn);
|
||||
PATCH_VTABLE(use);
|
||||
PATCH_VTABLE(useTimeDepleted);
|
||||
}
|
55
mods/src/extend/Tile.cpp
Normal file
55
mods/src/extend/Tile.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include "internal.h"
|
||||
|
||||
// Easily Create Custom Tiles
|
||||
AABB *CustomTile::getAABB(Level *level, const int x, const int y, const int z) {
|
||||
return Tile_vtable::base->getAABB(self, level, x, y, z);
|
||||
}
|
||||
int CustomTile::getColor(LevelSource *level_source, const int x, const int y, const int z) {
|
||||
return Tile_vtable::base->getColor(self, level_source, x, y, z);
|
||||
}
|
||||
std::string CustomTile::getDescriptionId() {
|
||||
return Tile_vtable::base->getDescriptionId(self);
|
||||
}
|
||||
int CustomTile::getRenderLayer() {
|
||||
return Tile_vtable::base->getRenderLayer(self);
|
||||
}
|
||||
int CustomTile::getTexture2(const int face, const int data) {
|
||||
return Tile_vtable::base->getTexture2(self, face, data);
|
||||
}
|
||||
int CustomTile::getTexture3(LevelSource *level, const int x, const int y, const int z, const int face) {
|
||||
return Tile_vtable::base->getTexture3(self, level, x, y, z, face);
|
||||
}
|
||||
bool CustomTile::isCubeShaped() {
|
||||
return Tile_vtable::base->isCubeShaped(self);
|
||||
}
|
||||
bool CustomTile::isSolidRender() {
|
||||
return Tile_vtable::base->isSolidRender(self);
|
||||
}
|
||||
bool CustomTile::shouldRenderFace(LevelSource *level_source, const int x, const int y, const int z, const int face) {
|
||||
return Tile_vtable::base->shouldRenderFace(self, level_source, x, y, z, face);
|
||||
}
|
||||
void CustomTile::updateDefaultShape() {
|
||||
Tile_vtable::base->updateDefaultShape(self);
|
||||
}
|
||||
void CustomTile::updateShape(LevelSource *level, const int x, const int y, const int z) {
|
||||
Tile_vtable::base->updateShape(self, level, x, y, z);
|
||||
}
|
||||
int CustomTile::use(Level *level, const int x, const int y, const int z, Player *player) {
|
||||
return Tile_vtable::base->use(self, level, x, y, z, player);
|
||||
}
|
||||
|
||||
// VTable
|
||||
SETUP_VTABLE(Tile)
|
||||
PATCH_VTABLE(getAABB);
|
||||
PATCH_VTABLE(getColor);
|
||||
PATCH_VTABLE(getDescriptionId);
|
||||
PATCH_VTABLE(getRenderLayer);
|
||||
PATCH_VTABLE(getTexture2);
|
||||
PATCH_VTABLE(getTexture3);
|
||||
PATCH_VTABLE(isCubeShaped);
|
||||
PATCH_VTABLE(isSolidRender);
|
||||
PATCH_VTABLE(shouldRenderFace);
|
||||
PATCH_VTABLE(updateDefaultShape);
|
||||
PATCH_VTABLE(updateShape);
|
||||
PATCH_VTABLE(use);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user