mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-26 21:26:38 +01:00
Patch Notes: Blocks + Colored shulker boxes + Concrete powder + Concrete + Glazed terracotta Items + Shulker shell + Iron nugget UI Changes + Added Custom Controls to Keyboard & Mouse, as well as Controller + Added Custom SuperFlat + Added Edit Server Menu + Added Firework Crafting Feature Changes + Host Options + Added Pick Block + Added off-hand slot for maps and arrows. Bug Fixes & changes + TU47: Banner hitbox wrong (and inventory model fixed) + TU47/48: Ice not melting properly + TU48: Dead bushes not dropping sticks + TU48: Guardians and polar bears not dropping cooked fish when on fire + TU48: Bonus chest missing saplings and seeds + TU48: Frosted ice obtainable + TU48: Hoppers not collecting items + TU48: Wither skeletons spawning in 2-high gaps + TU48: End crystals exploding with “TNT Explodes” off + TU48: Tamed ocelots staying hostile + TU48: Signs not placing on tall grass + TU51: Skeleton hitbox wrong + TU53: Fall damage in shallow water + TU53: Squids not spawning in man-made pools + Elytra has been improved to be more accurate to the source material + Removed Spectral Arrow from crafting + Fixed several broken item descriptions + You can no longer cook Pufferfish or Clownfish + Fixed scaling issue with paperdoll and chat + Iron and gold armor can now be smelted into nuggets. + More items can now be used as fuel in a furnace. + Using a firework rocket while gliding with elytra will now give the player a boost. + Changed the color of dyes, wool, carpets, and banners. + Reordered all colored blocks and items in the Creative inventory. Banners now have the same order of colors as all other colored blocks and items. + Fishing rods can now hook on entities without causing knockback or pseudo-damage. + Fixed banner crafting + Fixed Map colors for certain blocks + Fixed Path block height + Fixed String block issues + Fixed Item frame culling. + Fixed Tutorial world NBT/Block State issues + Fixed World Slider + Fixed Enderman AI + Fixed Player animation bug + HUD Flash text changes + Generation accuracy changes + Many other small accuracy changes and fixes
244 lines
5.7 KiB
C++
244 lines
5.7 KiB
C++
#include "stdafx.h"
|
|
#include "net.minecraft.world.item.h"
|
|
#include "net.minecraft.world.level.h"
|
|
#include "net.minecraft.world.level.tile.h"
|
|
#include "net.minecraft.world.phys.h"
|
|
#include "TripWireTile.h"
|
|
|
|
TripWireTile::TripWireTile(int id) : Tile(id, Material::decoration, isSolidRender())
|
|
{
|
|
setShape(0, 0, 0, 1, 2.5f / 16.0f, 1);
|
|
this->setTicking(true);
|
|
}
|
|
|
|
void TripWireTile::createBlockStateDefinition()
|
|
{
|
|
if (!m_blockStateDefinition)
|
|
m_blockStateDefinition = new BlockStateDefinition(this);
|
|
}
|
|
|
|
int TripWireTile::defaultBlockState()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int TripWireTile::convertBlockStateToLegacyData(BlockState *state)
|
|
{
|
|
return state ? (state->value & 0xF) : 0;
|
|
}
|
|
|
|
Tile::BlockState TripWireTile::getBlockState(int data)
|
|
{
|
|
return Tile::BlockState(data & 0xF);
|
|
}
|
|
|
|
Tile::BlockState TripWireTile::getBlockState(LevelSource *level, int x, int y, int z)
|
|
{
|
|
int data = level->getData(x, y, z);
|
|
int state = 0;
|
|
if (shouldConnectTo(level, x, y, z, data, Direction::NORTH)) state |= 0x1;
|
|
if (shouldConnectTo(level, x, y, z, data, Direction::SOUTH)) state |= 0x2;
|
|
if (shouldConnectTo(level, x, y, z, data, Direction::EAST)) state |= 0x4;
|
|
if (shouldConnectTo(level, x, y, z, data, Direction::WEST)) state |= 0x8;
|
|
if ((data & MASK_POWERED) == MASK_POWERED) state |= BLOCKSTATE_POWERED_BIT;
|
|
return Tile::BlockState(state);
|
|
}
|
|
|
|
int TripWireTile::getTickDelay(Level *level)
|
|
{
|
|
// 4J: Increased (x2); quick update caused problems with shared
|
|
// data between client and server.
|
|
return 20; // 10;
|
|
}
|
|
|
|
AABB *TripWireTile::getAABB(Level *level, int x, int y, int z)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
bool TripWireTile::blocksLight()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool TripWireTile::isSolidRender(bool isServerLevel)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool TripWireTile::isCubeShaped()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
int TripWireTile::getRenderLayer()
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
int TripWireTile::getRenderShape()
|
|
{
|
|
return Tile::SHAPE_TRIPWIRE;
|
|
}
|
|
|
|
int TripWireTile::getResource(int data, Random *random, int playerBonusLevel)
|
|
{
|
|
return Item::string_Id;
|
|
}
|
|
|
|
int TripWireTile::cloneTileId(Level *level, int x, int y, int z)
|
|
{
|
|
return Item::string_Id;
|
|
}
|
|
|
|
void TripWireTile::neighborChanged(Level *level, int x, int y, int z, int type)
|
|
{
|
|
}
|
|
|
|
void TripWireTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity)
|
|
{
|
|
int data = level->getData(x, y, z);
|
|
bool attached = (data & MASK_ATTACHED) == MASK_ATTACHED;
|
|
|
|
if (!attached)
|
|
{
|
|
setShape(0, 0, 0, 1, 8.0f / 16.0f, 1);
|
|
}
|
|
else
|
|
{
|
|
setShape(0, 1.0f / 16.0f, 0, 1, 2.5f / 16.0f, 1);
|
|
}
|
|
}
|
|
|
|
void TripWireTile::onPlace(Level *level, int x, int y, int z)
|
|
{
|
|
int data = level->getData(x, y, z) & ~MASK_SUSPENDED;
|
|
level->setData(x, y, z, data, Tile::UPDATE_ALL);
|
|
updateSource(level, x, y, z, data);
|
|
}
|
|
|
|
void TripWireTile::onRemove(Level *level, int x, int y, int z, int id, int data)
|
|
{
|
|
updateSource(level, x, y, z, data | MASK_POWERED);
|
|
}
|
|
|
|
void TripWireTile::playerWillDestroy(Level *level, int x, int y, int z, int data, shared_ptr<Player> player)
|
|
{
|
|
if (level->isClientSide) return;
|
|
|
|
if (player->getSelectedItem() != nullptr && player->getSelectedItem()->id == Item::shears_Id)
|
|
{
|
|
level->setData(x, y, z, data | MASK_DISARMED, Tile::UPDATE_NONE);
|
|
}
|
|
}
|
|
|
|
void TripWireTile::updateSource(Level *level, int x, int y, int z, int data)
|
|
{
|
|
for (int dir = 0; dir < 2; dir++)
|
|
{
|
|
for (int i = 1; i < TripWireSourceTile::WIRE_DIST_MAX; i++)
|
|
{
|
|
int xx = x + Direction::STEP_X[dir] * i;
|
|
int zz = z + Direction::STEP_Z[dir] * i;
|
|
int tile = level->getTile(xx, y, zz);
|
|
|
|
if (tile == Tile::tripwire_hook_Id)
|
|
{
|
|
int sourceDir = level->getData(xx, y, zz) & TripWireSourceTile::MASK_DIR;
|
|
|
|
if (sourceDir == Direction::DIRECTION_OPPOSITE[dir])
|
|
{
|
|
Tile::tripWireSource->calculateState(level, xx, y, zz, tile, level->getData(xx, y, zz), true, i, data);
|
|
}
|
|
|
|
break;
|
|
}
|
|
else if (tile != Tile::tripwire_Id)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void TripWireTile::entityInside(Level *level, int x, int y, int z, shared_ptr<Entity> entity)
|
|
{
|
|
if (level->isClientSide) return;
|
|
|
|
if ((level->getData(x, y, z) & MASK_POWERED) == MASK_POWERED) return;
|
|
|
|
checkPressed(level, x, y, z);
|
|
}
|
|
|
|
void TripWireTile::tick(Level *level, int x, int y, int z, Random *random)
|
|
{
|
|
if (level->isClientSide) return;
|
|
|
|
if ((level->getData(x, y, z) & MASK_POWERED) != MASK_POWERED) return;
|
|
|
|
checkPressed(level, x, y, z);
|
|
}
|
|
|
|
void TripWireTile::checkPressed(Level *level, int x, int y, int z)
|
|
{
|
|
int data = level->getData(x, y, z);
|
|
bool wasPressed = (data & MASK_POWERED) == MASK_POWERED;
|
|
bool shouldBePressed = false;
|
|
|
|
updateShape(level, x, y, z);
|
|
ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
|
|
vector<shared_ptr<Entity> > *entities = level->getEntities(nullptr, AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1));
|
|
if (!entities->empty())
|
|
{
|
|
for (auto& e : *entities)
|
|
{
|
|
if ( e && !e->isIgnoringTileTriggers())
|
|
{
|
|
shouldBePressed = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (shouldBePressed && !wasPressed)
|
|
{
|
|
data |= MASK_POWERED;
|
|
}
|
|
|
|
if (!shouldBePressed && wasPressed)
|
|
{
|
|
data &= ~MASK_POWERED;
|
|
}
|
|
|
|
if (shouldBePressed != wasPressed)
|
|
{
|
|
level->setData(x, y, z, data, Tile::UPDATE_ALL);
|
|
updateSource(level, x, y, z, data);
|
|
}
|
|
|
|
if (shouldBePressed)
|
|
{
|
|
level->addToTickNextTick(x, y, z, id, getTickDelay(level));
|
|
}
|
|
}
|
|
|
|
bool TripWireTile::shouldConnectTo(LevelSource *level, int x, int y, int z, int data, int dir)
|
|
{
|
|
int tx = x + Direction::STEP_X[dir];
|
|
int ty = y;
|
|
int tz = z + Direction::STEP_Z[dir];
|
|
int t = level->getTile(tx, ty, tz);
|
|
|
|
if (t == Tile::tripwire_hook_Id)
|
|
{
|
|
int otherData = level->getData(tx, ty, tz);
|
|
int facing = otherData & TripWireSourceTile::MASK_DIR;
|
|
|
|
return facing == Direction::DIRECTION_OPPOSITE[dir];
|
|
}
|
|
|
|
if (t == Tile::tripwire_Id) return true;
|
|
|
|
return false;
|
|
}
|