mirror of
https://github.com/ReMinecraftPE/mcpe.git
synced 2025-01-22 09:11:56 -05:00
* Make Rocket Launcher activate with redstone
* StartMenuScreen: Prevent non cube shaped SHAPE_SOLID blocks from showing up on the title screen logo.
This commit is contained in:
parent
855def5acf
commit
fb050e7847
3 changed files with 49 additions and 9 deletions
|
@ -812,7 +812,7 @@ Tile* TitleTile::getRandomTile(Tile* except1, Tile* except2)
|
|||
|
||||
// If found a tile, check if it can be rendered
|
||||
Tile* pTile = Tile::tiles[id];
|
||||
if (!TileRenderer::canRender(pTile->getRenderShape()))
|
||||
if (!pTile->isCubeShaped())
|
||||
continue;
|
||||
|
||||
if (pTile == except1 || pTile == except2)
|
||||
|
|
|
@ -9,14 +9,16 @@
|
|||
#include "world/level/Level.hpp"
|
||||
#include "world/entity/Rocket.hpp"
|
||||
|
||||
#define STATE_RECHARGING (0x1)
|
||||
#define STATE_POWERED (0x2)
|
||||
|
||||
RocketLauncherTile::RocketLauncherTile(int id) : Tile(id, 16*14+2, Material::wood)
|
||||
{
|
||||
setTicking(true);
|
||||
}
|
||||
|
||||
int RocketLauncherTile::getTexture(int dir, int data)
|
||||
{
|
||||
return data == 1 ? 16*14+3 : 16*14+2;
|
||||
return (data & STATE_RECHARGING) ? 16*14+3 : 16*14+2;
|
||||
}
|
||||
|
||||
AABB* RocketLauncherTile::getAABB(Level*, int x, int y, int z)
|
||||
|
@ -39,26 +41,61 @@ bool RocketLauncherTile::isSolidRender()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool RocketLauncherTile::isSignalSource()
|
||||
{
|
||||
// Not really a signal _source_ per se, but it receives signals
|
||||
return true;
|
||||
}
|
||||
|
||||
int RocketLauncherTile::use(Level* level, int x, int y, int z, Player* player)
|
||||
{
|
||||
if (level->getData(x, y, z) == 1)
|
||||
int data = level->getData(x, y, z);
|
||||
if (data & STATE_RECHARGING)
|
||||
return 1;
|
||||
|
||||
level->setData(x, y, z, 1);
|
||||
level->setData(x, y, z, data | STATE_RECHARGING);
|
||||
|
||||
// spawn a rocket
|
||||
level->addEntity(new Rocket(level, float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f));
|
||||
|
||||
// add a tick so that the rocket launcher will reset
|
||||
level->addToTickNextTick(x, y, z, m_ID, 10);
|
||||
level->addToTickNextTick(x, y, z, m_ID, getTickDelay());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void RocketLauncherTile::tick(Level* level, int x, int y, int z, Random* random)
|
||||
void RocketLauncherTile::neighborChanged(Level* level, int x, int y, int z, int newTile)
|
||||
{
|
||||
if (level->getData(x, y, z) != 1)
|
||||
if (newTile <= 0 || !Tile::tiles[newTile]->isSignalSource())
|
||||
return;
|
||||
|
||||
level->setData(x, y, z, 0);
|
||||
int data = level->getData(x, y, z);
|
||||
|
||||
if (level->hasNeighborSignal(x, y, z))
|
||||
{
|
||||
if (data & (STATE_POWERED | STATE_RECHARGING))
|
||||
return;
|
||||
|
||||
level->setDataNoUpdate(x, y, z, data | STATE_POWERED);
|
||||
use(level, x, y, z, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data & STATE_POWERED)
|
||||
level->setDataNoUpdate(x, y, z, data & ~STATE_POWERED);
|
||||
}
|
||||
}
|
||||
|
||||
void RocketLauncherTile::tick(Level* level, int x, int y, int z, Random* random)
|
||||
{
|
||||
int data = level->getData(x, y, z);
|
||||
if (~data & STATE_RECHARGING)
|
||||
return;
|
||||
|
||||
level->setData(x, y, z, data & ~STATE_RECHARGING);
|
||||
}
|
||||
|
||||
int RocketLauncherTile::getTickDelay()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@ public:
|
|||
int getRenderShape() override;
|
||||
bool isCubeShaped() override;
|
||||
bool isSolidRender() override;
|
||||
bool isSignalSource() override;
|
||||
int use(Level* pLevel, int x, int y, int z, Player* player) override;
|
||||
void neighborChanged(Level*, int x, int y, int z, int newTile) override;
|
||||
void tick(Level*, int, int, int, Random*) override;
|
||||
int getTickDelay() override;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue