use of cn.nukkit.network.protocol.BlockEventPacket in project Nukkit by Nukkit.
the class DoubleChestInventory method onOpen.
@Override
public void onOpen(Player who) {
super.onOpen(who);
this.left.viewers.add(who);
this.right.viewers.add(who);
if (this.getViewers().size() == 1) {
BlockEventPacket pk1 = new BlockEventPacket();
pk1.x = (int) this.left.getHolder().getX();
pk1.y = (int) this.left.getHolder().getY();
pk1.z = (int) this.left.getHolder().getZ();
pk1.case1 = 1;
pk1.case2 = 2;
Level level = this.left.getHolder().getLevel();
if (level != null) {
level.addSound(this.left.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTOPEN);
level.addChunkPacket((int) this.left.getHolder().getX() >> 4, (int) this.left.getHolder().getZ() >> 4, pk1);
}
BlockEventPacket pk2 = new BlockEventPacket();
pk2.x = (int) this.right.getHolder().getX();
pk2.y = (int) this.right.getHolder().getY();
pk2.z = (int) this.right.getHolder().getZ();
pk2.case1 = 1;
pk2.case2 = 2;
level = this.right.getHolder().getLevel();
if (level != null) {
level.addSound(this.right.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTOPEN);
level.addChunkPacket((int) this.right.getHolder().getX() >> 4, (int) this.right.getHolder().getZ() >> 4, pk2);
}
}
}
use of cn.nukkit.network.protocol.BlockEventPacket in project Nukkit by Nukkit.
the class ChestInventory method onOpen.
@Override
public void onOpen(Player who) {
super.onOpen(who);
if (this.getViewers().size() == 1) {
BlockEventPacket pk = new BlockEventPacket();
pk.x = (int) this.getHolder().getX();
pk.y = (int) this.getHolder().getY();
pk.z = (int) this.getHolder().getZ();
pk.case1 = 1;
pk.case2 = 2;
Level level = this.getHolder().getLevel();
if (level != null) {
level.addSound(this.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTOPEN);
level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk);
}
}
}
Aggregations