mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-06-09 00:22:57 +00:00
SandTile Fix
This commit is contained in:
parent
07fd3222b8
commit
83e8a28913
|
|
@ -5,124 +5,31 @@
|
|||
#include "FireTile.h"
|
||||
#include "net.minecraft.world.h"
|
||||
|
||||
const unsigned int SandTile::SAND_NAMES[SAND_NAMES_LENGTH] = { IDS_TILE_SAND,
|
||||
IDS_TILE_SAND};
|
||||
const unsigned int SandTile::SAND_NAMES[SAND_NAMES_LENGTH] = { IDS_TILE_SAND, IDS_TILE_SAND };
|
||||
const wstring SandTile::TEXTURE_NAMES[] = { L"sand", L"red_sand" };
|
||||
|
||||
const wstring SandTile::TEXTURE_NAMES[] = { L"sand",
|
||||
L"red_sand" };
|
||||
|
||||
bool SandTile::instaFall = false;
|
||||
|
||||
SandTile::SandTile(int type, bool isSolidRender) : Tile(type, Material::sand, isSolidRender)
|
||||
SandTile::SandTile(int type, bool isSolidRender) : HeavyTile(type, Material::sand, isSolidRender)
|
||||
{
|
||||
icons = nullptr;
|
||||
icons = nullptr;
|
||||
}
|
||||
|
||||
int SandTile::getSpawnResourcesAuxValue(int data)
|
||||
{
|
||||
if (data < 0 || data >= SAND_NAMES_LENGTH) data = 0;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void SandTile::onPlace(Level* level, int x, int y, int z)
|
||||
{
|
||||
level->addToTickNextTick(x, y, z, id, getTickDelay(level));
|
||||
}
|
||||
|
||||
void SandTile::neighborChanged(Level* level, int x, int y, int z, int type)
|
||||
{
|
||||
level->addToTickNextTick(x, y, z, id, getTickDelay(level));
|
||||
}
|
||||
|
||||
void SandTile::tick(Level* level, int x, int y, int z, Random* random)
|
||||
{
|
||||
if (!level->isClientSide)
|
||||
{
|
||||
checkSlide(level, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
void SandTile::checkSlide(Level* level, int x, int y, int z)
|
||||
{
|
||||
int x2 = x;
|
||||
int y2 = y;
|
||||
int z2 = z;
|
||||
|
||||
if (level->isNew || !level->hasChunksAt(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (y2 > 0 && isFree(level, x2, y2 - 1, z2))
|
||||
{
|
||||
int r = 32;
|
||||
|
||||
if (instaFall || !level->hasChunksAt(x - r, y - r, z - r, x + r, y + r, z + r))
|
||||
{
|
||||
level->removeTile(x, y, z);
|
||||
while (y > 0 && isFree(level, x, y - 1, z))
|
||||
y--;
|
||||
if (y > 0)
|
||||
{
|
||||
level->setTileAndUpdate(x, y, z, id);
|
||||
}
|
||||
}
|
||||
else if (!level->isClientSide)
|
||||
{
|
||||
// 4J added - don't do anything just now if we can't create any new falling tiles
|
||||
if (!level->newFallingTileAllowed())
|
||||
{
|
||||
level->addToTickNextTick(x, y, z, id, getTickDelay(level));
|
||||
return;
|
||||
}
|
||||
|
||||
shared_ptr<FallingTile> e = std::make_shared<FallingTile>(level, x + 0.5f, y + 0.5f, z + 0.5f, id, level->getData(x, y, z));
|
||||
falling(e);
|
||||
level->addEntity(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SandTile::falling(shared_ptr<FallingTile> entity)
|
||||
{
|
||||
}
|
||||
|
||||
int SandTile::getTickDelay(Level* level)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
bool SandTile::isFree(Level* level, int x, int y, int z)
|
||||
{
|
||||
int t = level->getTile(x, y, z);
|
||||
if (t == 0) return true;
|
||||
if (t == Tile::fire_Id) return true;
|
||||
Material* material = Tile::tiles[t]->material;
|
||||
if (material == Material::water) return true;
|
||||
if (material == Material::lava) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void SandTile::onLand(Level* level, int xt, int yt, int zt, int data)
|
||||
{
|
||||
if (data < 0 || data >= SAND_NAMES_LENGTH) data = 0;
|
||||
return data;
|
||||
}
|
||||
|
||||
Icon* SandTile::getTexture(int face, int data)
|
||||
{
|
||||
if (data < 0 || data >= SAND_NAMES_LENGTH)
|
||||
{
|
||||
data = 0;
|
||||
}
|
||||
return icons[data];
|
||||
if (data < 0 || data >= SAND_NAMES_LENGTH) data = 0;
|
||||
return icons[data];
|
||||
}
|
||||
|
||||
void SandTile::registerIcons(IconRegister* iconRegister)
|
||||
{
|
||||
icons = new Icon * [SAND_NAMES_LENGTH];
|
||||
|
||||
for (int i = 0; i < SAND_NAMES_LENGTH; i++)
|
||||
{
|
||||
icons[i] = iconRegister->registerIcon(TEXTURE_NAMES[i]);
|
||||
}
|
||||
icons = new Icon * [SAND_NAMES_LENGTH];
|
||||
for (int i = 0; i < SAND_NAMES_LENGTH; i++)
|
||||
{
|
||||
icons[i] = iconRegister->registerIcon(TEXTURE_NAMES[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +1,19 @@
|
|||
#pragma once
|
||||
#include "Tile.h"
|
||||
#include "HeavyTile.h"
|
||||
|
||||
class Random;
|
||||
class Level;
|
||||
class FallingTile;
|
||||
|
||||
class SandTile : public Tile
|
||||
class SandTile : public HeavyTile
|
||||
{
|
||||
public:
|
||||
static bool instaFall;
|
||||
static const int RED_SAND = 1;
|
||||
static const int SAND_NAMES_LENGTH = 2;
|
||||
static const unsigned int SAND_NAMES[SAND_NAMES_LENGTH];
|
||||
static const wstring TEXTURE_NAMES[];
|
||||
|
||||
static const int RED_SAND = 1;
|
||||
SandTile(int type, bool isSolidRender = true);
|
||||
virtual int getSpawnResourcesAuxValue(int data) override;
|
||||
virtual Icon* getTexture(int face, int data) override;
|
||||
void registerIcons(IconRegister* iconRegister) override;
|
||||
|
||||
static const int SAND_NAMES_LENGTH = 2;
|
||||
|
||||
static const unsigned int SAND_NAMES[SAND_NAMES_LENGTH];
|
||||
static const wstring TEXTURE_NAMES[];
|
||||
|
||||
SandTile(int type, bool isSolidRender = true);
|
||||
virtual void onPlace(Level* level, int x, int y, int z);
|
||||
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);
|
||||
private:
|
||||
Icon** icons;
|
||||
void checkSlide(Level* level, int x, int y, int z);
|
||||
protected:
|
||||
virtual void falling(shared_ptr<FallingTile> entity);
|
||||
public:
|
||||
virtual int getTickDelay(Level* level);
|
||||
static bool isFree(Level* level, int x, int y, int z);
|
||||
virtual int getSpawnResourcesAuxValue(int data);
|
||||
virtual void onLand(Level* level, int xt, int yt, int zt, int data);
|
||||
virtual Icon* getTexture(int face, int data);
|
||||
void registerIcons(IconRegister* iconRegister);
|
||||
};
|
||||
Icon** icons;
|
||||
};
|
||||
|
|
@ -404,8 +404,26 @@ public:
|
|||
static const int jungle_door_Id = 195;
|
||||
static const int acacia_door_Id = 196;
|
||||
static const int dark_oak_door_Id = 197;
|
||||
|
||||
|
||||
//end_rod 198
|
||||
//chorus_plant 199
|
||||
//chorus_flower 200
|
||||
//purpur_block 201
|
||||
//purpur_pillar 202
|
||||
//purpur_stairs 203
|
||||
//purpur_double_slab 204
|
||||
//purpur_slab 205
|
||||
//end_bricks 206
|
||||
//beetroots 207
|
||||
//grass_path 208
|
||||
//end_gateway 209
|
||||
//frosted_ice 212
|
||||
//magma 213
|
||||
//nether_wart_block 214
|
||||
//red_nether_brick 215
|
||||
//bone_block 216
|
||||
//structure_void 217
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
static Tile *stone;
|
||||
|
|
|
|||
Loading…
Reference in a new issue