1- using MiNET . Sounds ;
2- using MiNET . Utils . Vectors ;
1+ using MiNET . Utils . Vectors ;
32using MiNET . Worlds ;
43
54namespace MiNET . Blocks
65{
76 public abstract class PressurePlateBase : Block
87 {
98 public virtual int RedstoneSignal { get ; set ; }
9+ private BlockCoordinates [ ] cord = [ ] ;
1010
1111 protected PressurePlateBase ( int id ) : base ( id )
1212 {
@@ -30,33 +30,20 @@ public override void BreakBlock(Level level, BlockFace face, bool silent = false
3030 public override void OnTick ( Level level , bool isRandom )
3131 {
3232 if ( isRandom ) { return ; }
33- BlockCoordinates cord = Coordinates . BlockDown ( ) ;
3433 var entities = level . GetSpawnedPlayers ( ) ;
34+ cord = [ Coordinates . BlockNorth ( ) , Coordinates . BlockSouth ( ) , Coordinates . BlockEast ( ) , Coordinates . BlockWest ( ) , Coordinates . BlockDown ( ) ] ;
3535 foreach ( var entity in entities )
3636 {
37- if ( ( int ) entity . KnownPosition . X == Coordinates . X && ( int ) entity . KnownPosition . Y == Coordinates . Y && ( int ) entity . KnownPosition . Z == Coordinates . Z )
37+ if ( ( int ) ( entity . KnownPosition . X < 0 ? entity . KnownPosition . X - 1 : entity . KnownPosition . X ) == Coordinates . X && ( int ) entity . KnownPosition . Y == Coordinates . Y && ( int ) ( entity . KnownPosition . Z < 0 ? entity . KnownPosition . Z - 1 : entity . KnownPosition . Z ) == Coordinates . Z )
3838 {
3939 if ( RedstoneSignal == 0 )
4040 {
4141 RedstoneSignal = 15 ;
4242 level . SetBlock ( this ) ;
4343 level . BroadcastSound ( Coordinates , LevelSoundEventType . PressurePlateOn ) ;
44- for ( int i = 0 ; i < 5 ; i ++ )
44+ foreach ( BlockCoordinates bCord in cord )
4545 {
46- if ( i == 0 ) { cord = this . Coordinates . BlockNorth ( ) ; }
47- if ( i == 1 ) { cord = this . Coordinates . BlockSouth ( ) ; }
48- if ( i == 2 ) { cord = this . Coordinates . BlockWest ( ) ; }
49- if ( i == 3 ) { cord = this . Coordinates . BlockEast ( ) ; }
50- if ( i == 4 ) { cord = this . Coordinates . BlockDown ( ) ; }
51- var blockk = level . GetBlock ( cord ) ;
52- if ( blockk is RedstoneLamp ) { level . SetBlock ( new LitRedstoneLamp { Coordinates = new BlockCoordinates ( cord ) } ) ; }
53- if ( blockk is WoodenDoor ) { level . SetBlock ( new WoodenDoor { Direction = blockk . GetDirection ( ) , Coordinates = new BlockCoordinates ( cord ) , OpenBit = true } ) ; var sound = new Sound ( ( short ) LevelEventType . SoundOpenDoor , Coordinates ) ; sound . Spawn ( level ) ; }
54- if ( blockk is SpruceDoor ) { level . SetBlock ( new SpruceDoor { Direction = blockk . GetDirection ( ) , Coordinates = new BlockCoordinates ( cord ) , OpenBit = true } ) ; var sound = new Sound ( ( short ) LevelEventType . SoundOpenDoor , Coordinates ) ; sound . Spawn ( level ) ; }
55- if ( blockk is BirchDoor ) { level . SetBlock ( new BirchDoor { Direction = blockk . GetDirection ( ) , Coordinates = new BlockCoordinates ( cord ) , OpenBit = true } ) ; var sound = new Sound ( ( short ) LevelEventType . SoundOpenDoor , Coordinates ) ; sound . Spawn ( level ) ; }
56- if ( blockk is JungleDoor ) { level . SetBlock ( new JungleDoor { Direction = blockk . GetDirection ( ) , Coordinates = new BlockCoordinates ( cord ) , OpenBit = true } ) ; var sound = new Sound ( ( short ) LevelEventType . SoundOpenDoor , Coordinates ) ; sound . Spawn ( level ) ; }
57- if ( blockk is AcaciaDoor ) { level . SetBlock ( new AcaciaDoor { Direction = blockk . GetDirection ( ) , Coordinates = new BlockCoordinates ( cord ) , OpenBit = true } ) ; var sound = new Sound ( ( short ) LevelEventType . SoundOpenDoor , Coordinates ) ; sound . Spawn ( level ) ; }
58- if ( blockk is DarkOakDoor ) { level . SetBlock ( new DarkOakDoor { Direction = blockk . GetDirection ( ) , Coordinates = new BlockCoordinates ( cord ) , OpenBit = true } ) ; var sound = new Sound ( ( short ) LevelEventType . SoundOpenDoor , Coordinates ) ; sound . Spawn ( level ) ; }
59- if ( blockk is IronDoor ) { level . SetBlock ( new IronDoor { Direction = blockk . GetDirection ( ) , Coordinates = new BlockCoordinates ( cord ) , OpenBit = true } ) ; var sound = new Sound ( ( short ) LevelEventType . SoundOpenDoor , Coordinates ) ; sound . Spawn ( level ) ; }
46+ RedstoneController . signal ( level , bCord , true ) ;
6047 }
6148 }
6249 }
@@ -65,22 +52,9 @@ public override void OnTick(Level level, bool isRandom)
6552 RedstoneSignal = 0 ;
6653 level . SetBlock ( this ) ;
6754 level . BroadcastSound ( Coordinates , LevelSoundEventType . PressurePlateOff ) ;
68- for ( int i = 0 ; i < 5 ; i ++ )
55+ foreach ( BlockCoordinates bCord in cord )
6956 {
70- if ( i == 0 ) { cord = this . Coordinates . BlockNorth ( ) ; }
71- if ( i == 1 ) { cord = this . Coordinates . BlockSouth ( ) ; }
72- if ( i == 2 ) { cord = this . Coordinates . BlockWest ( ) ; }
73- if ( i == 3 ) { cord = this . Coordinates . BlockEast ( ) ; }
74- if ( i == 4 ) { cord = this . Coordinates . BlockDown ( ) ; }
75- var blockk = level . GetBlock ( cord ) ;
76- if ( blockk is LitRedstoneLamp ) { level . SetBlock ( new RedstoneLamp { Coordinates = new BlockCoordinates ( cord ) } ) ; }
77- if ( blockk is WoodenDoor ) { level . SetBlock ( new WoodenDoor { Direction = blockk . GetDirection ( ) , Coordinates = new BlockCoordinates ( cord ) , OpenBit = false } ) ; var sound = new Sound ( ( short ) LevelEventType . SoundOpenDoor , Coordinates ) ; sound . Spawn ( level ) ; }
78- if ( blockk is SpruceDoor ) { level . SetBlock ( new SpruceDoor { Direction = blockk . GetDirection ( ) , Coordinates = new BlockCoordinates ( cord ) , OpenBit = false } ) ; var sound = new Sound ( ( short ) LevelEventType . SoundOpenDoor , Coordinates ) ; sound . Spawn ( level ) ; }
79- if ( blockk is BirchDoor ) { level . SetBlock ( new BirchDoor { Direction = blockk . GetDirection ( ) , Coordinates = new BlockCoordinates ( cord ) , OpenBit = false } ) ; var sound = new Sound ( ( short ) LevelEventType . SoundOpenDoor , Coordinates ) ; sound . Spawn ( level ) ; }
80- if ( blockk is JungleDoor ) { level . SetBlock ( new JungleDoor { Direction = blockk . GetDirection ( ) , Coordinates = new BlockCoordinates ( cord ) , OpenBit = false } ) ; var sound = new Sound ( ( short ) LevelEventType . SoundOpenDoor , Coordinates ) ; sound . Spawn ( level ) ; }
81- if ( blockk is AcaciaDoor ) { level . SetBlock ( new AcaciaDoor { Direction = blockk . GetDirection ( ) , Coordinates = new BlockCoordinates ( cord ) , OpenBit = false } ) ; var sound = new Sound ( ( short ) LevelEventType . SoundOpenDoor , Coordinates ) ; sound . Spawn ( level ) ; }
82- if ( blockk is DarkOakDoor ) { level . SetBlock ( new DarkOakDoor { Direction = blockk . GetDirection ( ) , Coordinates = new BlockCoordinates ( cord ) , OpenBit = false } ) ; var sound = new Sound ( ( short ) LevelEventType . SoundOpenDoor , Coordinates ) ; sound . Spawn ( level ) ; }
83- if ( blockk is IronDoor ) { level . SetBlock ( new IronDoor { Direction = blockk . GetDirection ( ) , Coordinates = new BlockCoordinates ( cord ) , OpenBit = false } ) ; var sound = new Sound ( ( short ) LevelEventType . SoundOpenDoor , Coordinates ) ; sound . Spawn ( level ) ; }
57+ RedstoneController . signal ( level , bCord , false ) ;
8458 }
8559 }
8660 }
0 commit comments