public override void OnNeighbourBlockChange(IWorldAccessor world, BlockPos pos, BlockPos neibpos) { BEBehaviorMPAxle bempaxle = world.BlockAccessor.GetBlockEntity(pos)?.GetBehavior <BEBehaviorMPAxle>(); if (bempaxle != null && !BEBehaviorMPAxle.IsAttachedToBlock(world.BlockAccessor, bempaxle.Block, pos)) { bool connected = false; foreach (BlockFacing face in BlockFacing.ALLFACES) { BlockPos npos = pos.AddCopy(face); IMechanicalPowerBlock block = world.BlockAccessor.GetBlock(npos) as IMechanicalPowerBlock; bool prevConnected = connected; if (block != null && block.HasMechPowerConnectorAt(world, pos, face.Opposite) && world.BlockAccessor.GetBlockEntity(pos)?.GetBehavior <BEBehaviorMPBase>()?.disconnected == false) { connected = true; } BlockAngledGears blockagears = block as BlockAngledGears; if (blockagears == null) { continue; } if (blockagears.Facings.Contains(face.Opposite) && blockagears.Facings.Length == 1) { world.BlockAccessor.BreakBlock(npos, null); connected = prevConnected; //undo connected = true in this situation } } if (!connected) { world.BlockAccessor.BreakBlock(pos, null); } } base.OnNeighbourBlockChange(world, pos, neibpos); }
public override void OnNeighbourBlockChange(IWorldAccessor world, BlockPos pos, BlockPos neibpos) { BEBehaviorMPArchimedesScrew bemp = world.BlockAccessor.GetBlockEntity(pos)?.GetBehavior <BEBehaviorMPArchimedesScrew>(); if (bemp != null && !bemp.IsAttachedToBlock()) { foreach (BlockFacing face in BlockFacing.VERTICALS) { BlockAngledGears blockagears = world.BlockAccessor.GetBlock(pos.AddCopy(face)) as BlockAngledGears; if (blockagears == null) { continue; } if (blockagears.Facings.Contains(face.Opposite) && blockagears.Facings.Length == 1) { world.BlockAccessor.BreakBlock(pos.AddCopy(face), null); } } } base.OnNeighbourBlockChange(world, pos, neibpos); }
public override void OnNeighbourBlockChange(IWorldAccessor world, BlockPos pos, BlockPos neibpos) { BEBehaviorMPToggle bemptoggle = world.BlockAccessor.GetBlockEntity(pos)?.GetBehavior <BEBehaviorMPToggle>(); if (bemptoggle != null && !bemptoggle.IsAttachedToBlock()) { foreach (BlockFacing face in BlockFacing.HORIZONTALS) { BlockPos npos = pos.AddCopy(face); BlockAngledGears blockagears = world.BlockAccessor.GetBlock(npos) as BlockAngledGears; if (blockagears == null) { continue; } if (blockagears.Facings.Contains(face.Opposite) && blockagears.Facings.Length == 1) { world.BlockAccessor.BreakBlock(npos, null); } } } base.OnNeighbourBlockChange(world, pos, neibpos); }