Beispiel #1
0
        /// <summary>
        /// Searches for an air block next to a combustible block
        /// </summary>
        /// <param name="world"></param>
        /// <param name="lavaPos"></param>
        /// <returns>The position of the air block next to a combustible block</returns>
        private FireLocation SearchAreaForAirNextToCombustibleBlock(IWorldAccessor world, BlockPos lavaPos)
        {
            FireLocation combustibleBlockPos = SearchRadiusForAirNextToCombustibleBlock(world, lavaPos, 1, 2);

            if (combustibleBlockPos == null)
            {
                combustibleBlockPos = SearchRadiusForAirNextToCombustibleBlock(world, lavaPos, 2, 3);
                if (combustibleBlockPos == null)
                {
                    combustibleBlockPos = SearchRadiusForAirNextToCombustibleBlock(world, lavaPos, 3, 2);
                }
            }
            return(combustibleBlockPos);
        }
Beispiel #2
0
        public override bool ShouldReceiveServerGameTicks(IWorldAccessor world, BlockPos pos, out object extra)
        {
            if (LiquidLevel == 7)
            {
                FireLocation fireLocation = SearchAreaForAirNextToCombustibleBlock(world, pos);
                if (fireLocation != null)
                {
                    extra = fireLocation;
                    return(true);
                }
            }

            extra = null;
            return(false);
        }
Beispiel #3
0
        public override void OnServerGameTick(IWorldAccessor world, BlockPos pos, object extra = null)
        {
            base.OnServerGameTick(world, pos, extra);

            if (blockFire == null)
            {
                blockFire = world.GetBlock(new AssetLocation("fire"));
            }
            FireLocation fireLocation = (FireLocation)extra;

            world.BlockAccessor.SetBlock(blockFire.BlockId, fireLocation.firePos);
            BlockEntityFire befire = world.BlockAccessor.GetBlockEntity(fireLocation.firePos) as BlockEntityFire;

            if (befire != null)
            {
                befire.Init(fireLocation.facing);
            }
        }