public override bool TryPlaceBlock(IWorldAccessor world, IPlayer byPlayer, ItemStack itemstack, BlockSelection blockSel, ref EnumHandling handled) { if (world is IServerWorldAccessor) { world.RegisterCallbackUnique(OnDelayedWaterUpdateCheck, blockSel.Position, spreadDelay); } return(base.TryPlaceBlock(world, byPlayer, itemstack, blockSel, ref handled)); }
public override void OnNeighourBlockChange(IWorldAccessor world, BlockPos pos, BlockPos neibpos, ref EnumHandling handled) { handled = EnumHandling.PreventDefault; if (world is IServerWorldAccessor) { world.RegisterCallbackUnique(OnDelayedWaterUpdateCheck, pos, spreadDelay); } }
private void SpreadLiquid(ushort blockId, BlockPos pos, IWorldAccessor world) { world.BulkBlockAccessor.SetBlock(blockId, pos); world.RegisterCallbackUnique(OnDelayedWaterUpdateCheck, pos, spreadDelay); Block ourBlock = world.GetBlock(blockId); TryReplaceNearbyLiquidBlocks(ourBlock, pos, world); }
public void TryCollapse(IWorldAccessor world, BlockPos pos) { if (world.Side.IsClient()) { return; } if (FindTotalFriction(world, pos) >= 1.0) { return; } world.RegisterCallbackUnique((vworld, vpos, dt) => { BlockPos dPos = new BlockPos(pos.X, pos.Y - 1, pos.Z); Block dBlock = world.BlockAccessor.GetBlock(dPos); if (dBlock.IsReplacableBy(block)) { util.MoveBlock(pos, dPos); } else { if (dBlock.CollisionBoxes != null && block.CollisionBoxes != null) { double area = 0; double dArea = 0; for (int i = 0; i < dBlock.CollisionBoxes.Length; i++) { dArea += dBlock.CollisionBoxes[i].Area(); } for (int i = 0; i < block.CollisionBoxes.Length; i++) { area += block.CollisionBoxes[i].Area(); } if (dArea < 0.8) { world.BlockAccessor.BreakBlock(pos, null); } else if (area >= dArea) { BeginMove(world, pos); } } else { BeginMove(world, pos); } } }, pos, 30); }
private void ReplaceLiquidBlock(Block liquidBlock, BlockPos pos, IWorldAccessor world) { Block replacementBlock = GetReplacementBlock(liquidBlock, world); if (replacementBlock != null) { world.BulkBlockAccessor.SetBlock(replacementBlock.BlockId, pos); NotifyNeighborsOfBlockChange(pos, world); GenerateSteamParticles(pos, world); world.PlaySoundAt(collisionReplaceSound, pos.X, pos.Y, pos.Z); world.RegisterCallbackUnique(OnDelayedWaterUpdateCheck, pos.UpCopy(), spreadDelay); } }
public void WalkUpdate(IWorldAccessor world, BlockPos pos) { world.RegisterCallbackUnique((iworld, ipos, dt) => { int range = world.Rand.Next(2, 8); world.BlockAccessor.WalkBlocks(ipos.AddCopy(-range), ipos.AddCopy(range), (b, bp) => { if (world.Rand.NextDouble() > 0.5) { world.BulkBlockAccessor.TriggerNeighbourBlockUpdate(bp); } }); world.BulkBlockAccessor.Commit(); }, pos, 1000); }
private void SpreadLiquid(int blockId, BlockPos pos, IWorldAccessor world) { Block block = world.BulkBlockAccessor.GetBlock(pos); if (block.Id != 0 && block.LiquidCode == null) { world.SpawnCubeParticles(pos, new Vec3d(pos.X + 0.5, pos.Y + 0.5, pos.Z + 0.5), 0.7f, 25, 0.75f); world.BulkBlockAccessor.BreakBlock(pos, null); } world.BulkBlockAccessor.SetBlock(blockId, pos); world.RegisterCallbackUnique(OnDelayedWaterUpdateCheck, pos, spreadDelay); Block ourBlock = world.GetBlock(blockId); TryReplaceNearbyLiquidBlocks(ourBlock, pos, world); }