Beispiel #1
0
    /* FIXME: slow bc all blocks treated at once.
     * the game has a quick callback that add scheduled block update (run more smoothly - should I do it ?)
     *
     */
    public bool UpdateTick(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
    {
        if (_blockValue.type != Block.blockID)
        {
            return(true);                                           // changed block type
        }
        int  felt    = 0;
        bool changed = Transition(_blockPos, _blockValue);

        if (changed)
        {
            return(true);                       // transformed
        }
        if (gravity > 0)
        {
            felt = TryFall(_blockPos, _blockValue);
        }
        if (changed)
        {
            return(true);                 // felt
        }
        // on liquidV2, don't add any more SD.
        if (dt > 0 && felt <= gravity)
        {
            _world.GetWBT().AddScheduledBlockUpdate(0, _blockPos - felt * Vectors.UnitY, Block.blockID, dt);
        }
        return(true);
    }
Beispiel #2
0
 public void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
 {
     if (!autostart)
     {
         return;
     }
     if (dt > 0)
     {
         if (_blockValue.type == this.Block.blockID && !_world.IsRemote())
         {
             _world.GetWBT().AddScheduledBlockUpdate(0, _blockPos, Block.blockID, dt);
         }
     }
 }
Beispiel #3
0
    public void OnNeighborBlockChange(WorldBase world, int _clrIdx, Vector3i _myBlockPos, BlockValue _myBlockValue,
                                      Vector3i _blockPosThatChanged, BlockValue _newNeighborBlockValue, BlockValue _oldNeighborBlockValue)
    {
        // If I was inserting a new BV wo rotation, the slime would stick below ?
        if (!this.onb)
        {
            return;
        }
        Printer.Log(71, "OnNeighborBlockChange", _myBlockPos, _blockPosThatChanged, this.GetHashCode(), "damage", _myBlockValue.damage);
        if (_myBlockPos.y != _blockPosThatChanged.y + 1)
        {
            return;                                                      // only react to below block
        }
        if (!IsEmpty(_newNeighborBlockValue.Block))
        {
            return;                                                  // only when below is empty
        }
        int felt = TryFall(_myBlockPos, _myBlockValue);

        if (dt > 0 && felt <= gravity)
        {
            world.GetWBT().AddScheduledBlockUpdate(0, _myBlockPos - felt * Vectors.UnitY, Block.blockID, dt);
        }
    }