2026-03-01 12:16:08 +08:00
|
|
|
#pragma once
|
|
|
|
|
#include "EntityTile.h"
|
|
|
|
|
|
|
|
|
|
class Player;
|
|
|
|
|
class Mob;
|
|
|
|
|
class ChunkRebuildData;
|
|
|
|
|
class DispenserTile : public EntityTile
|
|
|
|
|
{
|
|
|
|
|
friend class Tile;
|
|
|
|
|
friend class ChunkRebuildData;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
static const int DISPENSE_ITEM = 0;
|
|
|
|
|
static const int REMOVE_ITEM = 1;
|
|
|
|
|
static const int LEAVE_ITEM = 2;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
static const int FACING_MASK = 0x7;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
Random *random;
|
|
|
|
|
|
|
|
|
|
Icon *iconTop;
|
|
|
|
|
Icon *iconFront;
|
|
|
|
|
Icon *iconFrontVertical;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
DispenserTile(int id);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual int getTickDelay();
|
|
|
|
|
virtual int getResource(int data, Random *random, int playerBonusLevel);
|
|
|
|
|
virtual void onPlace(Level *level, int x, int y, int z);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void recalcLockDir(Level *level, int x, int y, int z);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual Icon *getTexture(int face, int data);
|
|
|
|
|
//@Override
|
|
|
|
|
void registerIcons(IconRegister *iconRegister);
|
|
|
|
|
virtual bool TestUse();
|
2026-03-02 15:58:20 +07:00
|
|
|
virtual bool use(Level *level, int x, int y, int z, std::shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly = false); // 4J added soundOnly param
|
2026-03-01 12:16:08 +08:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void fireArrow(Level *level, int x, int y, int z, Random *random);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual void neighborChanged(Level *level, int x, int y, int z, int type);
|
|
|
|
|
virtual void tick(Level *level, int x, int y, int z, Random *random);
|
2026-03-02 15:58:20 +07:00
|
|
|
virtual std::shared_ptr<TileEntity> newTileEntity(Level *level);
|
|
|
|
|
virtual void setPlacedBy(Level *level, int x, int y, int z, std::shared_ptr<Mob> by);
|
2026-03-01 12:16:08 +08:00
|
|
|
virtual void onRemove(Level *level, int x, int y, int z, int id, int data);
|
|
|
|
|
|
|
|
|
|
private:
|
2026-03-02 15:58:20 +07:00
|
|
|
static void throwItem(Level *level, std::shared_ptr<ItemInstance> item, Random *random, int accuracy, int xd, int zd, double xp, double yp, double zp);
|
|
|
|
|
static int dispenseItem(std::shared_ptr<DispenserTileEntity> trap, Level *level, std::shared_ptr<ItemInstance> item, Random *random, int x, int y, int z, int xd, int zd, double xp, double yp, double zp);
|
2026-03-01 12:16:08 +08:00
|
|
|
};
|