mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-07-15 18:42:34 +00:00
fix(TU31): pistons not updating when they should (#113)
* Fixed pistons not updating when they should
I removed the code that 4J added to make pistons ignore updates because it seems they removed it in later versions for parity with java edition! This allows for 0 tick piston interactions amount other things.
* Update PistonBaseTile.h
I forgot to update the header 🥹
This commit is contained in:
@@ -29,21 +29,12 @@ DWORD PistonBaseTile::tlsIdx = TlsAlloc();
|
||||
// For us, that means that if we create a piston next to another one, then one of them gets two events to createPush, the second of which fails, leaving the
|
||||
// piston in a bad (simultaneously extended & not extended) state.
|
||||
// 4J - ignoreUpdate is a static in java, implementing as TLS here to make thread safe
|
||||
bool PistonBaseTile::ignoreUpdate()
|
||||
{
|
||||
return (TlsGetValue(tlsIdx) != nullptr);
|
||||
}
|
||||
|
||||
void PistonBaseTile::ignoreUpdate(bool set)
|
||||
{
|
||||
TlsSetValue(tlsIdx,(LPVOID)(set?1:0));
|
||||
}
|
||||
//I removed the code for ignoreUpdate so the above comment no longer applies ^.^
|
||||
|
||||
PistonBaseTile::PistonBaseTile(int id, bool isSticky) : Tile(id, Material::piston, isSolidRender() )
|
||||
{
|
||||
// 4J - added initialiser
|
||||
ignoreUpdate(false);
|
||||
|
||||
this->isSticky = isSticky;
|
||||
setSoundType(SOUND_STONE);
|
||||
setDestroyTime(0.5f);
|
||||
@@ -131,7 +122,7 @@ void PistonBaseTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<L
|
||||
{
|
||||
int targetData = getNewFacing(level, x, y, z, dynamic_pointer_cast<Player>(by) );
|
||||
level->setData(x, y, z, targetData, Tile::UPDATE_CLIENTS);
|
||||
if (!level->isClientSide && !ignoreUpdate())
|
||||
if (!level->isClientSide)
|
||||
{
|
||||
checkIfExtend(level, x, y, z);
|
||||
}
|
||||
@@ -139,7 +130,7 @@ void PistonBaseTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<L
|
||||
|
||||
void PistonBaseTile::neighborChanged(Level *level, int x, int y, int z, int type)
|
||||
{
|
||||
if (!level->isClientSide && !ignoreUpdate())
|
||||
if (!level->isClientSide)
|
||||
{
|
||||
checkIfExtend(level, x, y, z);
|
||||
}
|
||||
@@ -147,7 +138,7 @@ void PistonBaseTile::neighborChanged(Level *level, int x, int y, int z, int type
|
||||
|
||||
void PistonBaseTile::onPlace(Level *level, int x, int y, int z)
|
||||
{
|
||||
if (!level->isClientSide && level->getTileEntity(x, y, z) == nullptr && !ignoreUpdate())
|
||||
if (!level->isClientSide && level->getTileEntity(x, y, z) == nullptr)
|
||||
{
|
||||
checkIfExtend(level, x, y, z);
|
||||
}
|
||||
@@ -212,7 +203,6 @@ bool PistonBaseTile::getNeighborSignal(Level *level, int x, int y, int z, int fa
|
||||
|
||||
bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1, int facing)
|
||||
{
|
||||
ignoreUpdate(true);
|
||||
|
||||
if (!level->isClientSide)
|
||||
{
|
||||
@@ -221,12 +211,10 @@ bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1,
|
||||
if (extend && param1 == TRIGGER_CONTRACT)
|
||||
{
|
||||
level->setData(x, y, z, facing | EXTENDED_BIT, UPDATE_CLIENTS);
|
||||
ignoreUpdate(false);
|
||||
return false;
|
||||
}
|
||||
else if (!extend && param1 == TRIGGER_EXTEND)
|
||||
{
|
||||
ignoreUpdate(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -253,7 +241,6 @@ bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1,
|
||||
}
|
||||
if (FourKitBridge::FirePistonExtend(level->dimension->id, x, y, z, facing, pushLength))
|
||||
{
|
||||
ignoreUpdate(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -277,7 +264,6 @@ bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1,
|
||||
}
|
||||
else
|
||||
{
|
||||
ignoreUpdate(false);
|
||||
return false;
|
||||
}
|
||||
PIXEndNamedEvent();
|
||||
@@ -288,7 +274,6 @@ bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1,
|
||||
if (FourKitBridge::FirePistonRetract(level->dimension->id, x, y, z, facing))
|
||||
{
|
||||
level->setData(x, y, z, facing | EXTENDED_BIT, UPDATE_CLIENTS);
|
||||
ignoreUpdate(false);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -353,32 +338,24 @@ bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1,
|
||||
level->setTileAndData(x, y, z, Tile::pistonMovingPiece_Id, blockData, Tile::UPDATE_ALL);
|
||||
level->setTileEntity(x, y, z, PistonMovingPiece::newMovingPieceEntity(block, blockData, facing, false, false));
|
||||
|
||||
ignoreUpdate(false);
|
||||
level->removeTile(twoX, twoY, twoZ);
|
||||
ignoreUpdate(true);
|
||||
}
|
||||
else if (!pistonPiece)
|
||||
{
|
||||
stopSharingIfServer(level, x + Facing::STEP_X[facing], y + Facing::STEP_Y[facing], z + Facing::STEP_Z[facing]); // 4J added
|
||||
ignoreUpdate(false);
|
||||
level->removeTile(x + Facing::STEP_X[facing], y + Facing::STEP_Y[facing], z + Facing::STEP_Z[facing]);
|
||||
ignoreUpdate(true);
|
||||
}
|
||||
PIXEndNamedEvent();
|
||||
}
|
||||
else
|
||||
{
|
||||
stopSharingIfServer(level, x + Facing::STEP_X[facing], y + Facing::STEP_Y[facing], z + Facing::STEP_Z[facing]); // 4J added
|
||||
ignoreUpdate(false);
|
||||
level->removeTile(x + Facing::STEP_X[facing], y + Facing::STEP_Y[facing], z + Facing::STEP_Z[facing]);
|
||||
ignoreUpdate(true);
|
||||
}
|
||||
|
||||
level->playSound(x + 0.5, y + 0.5, z + 0.5, eSoundType_TILE_PISTON_IN, 0.5f, level->random->nextFloat() * 0.15f + 0.6f);
|
||||
}
|
||||
|
||||
ignoreUpdate(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,7 @@ private:
|
||||
|
||||
static DWORD tlsIdx;
|
||||
// 4J - was just a static but implemented with TLS for our version
|
||||
static bool ignoreUpdate();
|
||||
static void ignoreUpdate(bool set);
|
||||
//code removed so the above comment no longer applies
|
||||
|
||||
public:
|
||||
PistonBaseTile(int id, bool isSticky);
|
||||
|
||||
Reference in New Issue
Block a user