cn.nukkit.block.BlockEnderChest Java Examples
The following examples show how to use
cn.nukkit.block.BlockEnderChest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlayerEnderChestInventory.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public void onOpen(Player who) { if (who != this.getHolder()) { return; } super.onOpen(who); ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket(); containerOpenPacket.windowId = who.getWindowId(this); containerOpenPacket.type = this.getType().getNetworkType(); BlockEnderChest chest = who.getViewingEnderChest(); if (chest != null) { containerOpenPacket.x = (int) chest.getX(); containerOpenPacket.y = (int) chest.getY(); containerOpenPacket.z = (int) chest.getZ(); } else { containerOpenPacket.x = containerOpenPacket.y = containerOpenPacket.z = 0; } who.dataPacket(containerOpenPacket); this.sendContents(who); if (chest != null && chest.getViewers().size() == 1) { BlockEventPacket blockEventPacket = new BlockEventPacket(); blockEventPacket.x = (int) chest.getX(); blockEventPacket.y = (int) chest.getY(); blockEventPacket.z = (int) chest.getZ(); blockEventPacket.case1 = 1; blockEventPacket.case2 = 2; Level level = this.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_CHEST_OPEN, 1, -1, this.getHolder().add(0.5, 0.5, 0.5)); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, blockEventPacket); } } }
Example #2
Source File: PlayerEnderChestInventory.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public void onClose(Player who) { ContainerClosePacket containerClosePacket = new ContainerClosePacket(); containerClosePacket.windowId = who.getWindowId(this); who.dataPacket(containerClosePacket); super.onClose(who); BlockEnderChest chest = who.getViewingEnderChest(); if (chest != null && chest.getViewers().size() == 1) { BlockEventPacket blockEventPacket = new BlockEventPacket(); blockEventPacket.x = (int) chest.getX(); blockEventPacket.y = (int) chest.getY(); blockEventPacket.z = (int) chest.getZ(); blockEventPacket.case1 = 1; blockEventPacket.case2 = 0; Level level = this.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_CHEST_CLOSED, 1, -1, this.getHolder().add(0.5, 0.5, 0.5)); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, blockEventPacket); } who.setViewingEnderChest(null); } super.onClose(who); }
Example #3
Source File: PlayerEnderChestInventory.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void onOpen(Player who) { if (who != this.getHolder()) { return; } super.onOpen(who); ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket(); containerOpenPacket.windowId = who.getWindowId(this); containerOpenPacket.type = this.getType().getNetworkType(); BlockEnderChest chest = who.getViewingEnderChest(); if (chest != null) { containerOpenPacket.x = (int) chest.getX(); containerOpenPacket.y = (int) chest.getY(); containerOpenPacket.z = (int) chest.getZ(); } else { containerOpenPacket.x = containerOpenPacket.y = containerOpenPacket.z = 0; } who.dataPacket(containerOpenPacket); this.sendContents(who); if (chest != null && chest.getViewers().size() == 1) { BlockEventPacket blockEventPacket = new BlockEventPacket(); blockEventPacket.x = (int) chest.getX(); blockEventPacket.y = (int) chest.getY(); blockEventPacket.z = (int) chest.getZ(); blockEventPacket.case1 = 1; blockEventPacket.case2 = 2; Level level = this.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(this.getHolder().add(0.5, 0.5, 0.5), LevelSoundEventPacket.SOUND_ENDERCHEST_OPEN); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, blockEventPacket); } } }
Example #4
Source File: PlayerEnderChestInventory.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void onClose(Player who) { ContainerClosePacket containerClosePacket = new ContainerClosePacket(); containerClosePacket.windowId = who.getWindowId(this); who.dataPacket(containerClosePacket); super.onClose(who); BlockEnderChest chest = who.getViewingEnderChest(); if (chest != null && chest.getViewers().size() == 1) { BlockEventPacket blockEventPacket = new BlockEventPacket(); blockEventPacket.x = (int) chest.getX(); blockEventPacket.y = (int) chest.getY(); blockEventPacket.z = (int) chest.getZ(); blockEventPacket.case1 = 1; blockEventPacket.case2 = 0; Level level = this.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(this.getHolder().add(0.5, 0.5, 0.5), LevelSoundEventPacket.SOUND_ENDERCHEST_CLOSED); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, blockEventPacket); } who.setViewingEnderChest(null); } super.onClose(who); }
Example #5
Source File: PlayerEnderChestInventory.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void onOpen(Player who) { if (who != this.getHolder()) { return; } super.onOpen(who); ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket(); containerOpenPacket.windowId = who.getWindowId(this); containerOpenPacket.type = this.getType().getNetworkType(); BlockEnderChest chest = who.getViewingEnderChest(); if (chest != null) { containerOpenPacket.x = (int) chest.getX(); containerOpenPacket.y = (int) chest.getY(); containerOpenPacket.z = (int) chest.getZ(); } else { containerOpenPacket.x = containerOpenPacket.y = containerOpenPacket.z = 0; } who.dataPacket(containerOpenPacket); this.sendContents(who); if (chest != null && chest.getViewers().size() == 1) { BlockEventPacket blockEventPacket = new BlockEventPacket(); blockEventPacket.x = (int) chest.getX(); blockEventPacket.y = (int) chest.getY(); blockEventPacket.z = (int) chest.getZ(); blockEventPacket.case1 = 1; blockEventPacket.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, blockEventPacket); } } }
Example #6
Source File: PlayerEnderChestInventory.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void onClose(Player who) { ContainerClosePacket containerClosePacket = new ContainerClosePacket(); containerClosePacket.windowId = who.getWindowId(this); who.dataPacket(containerClosePacket); super.onClose(who); BlockEnderChest chest = who.getViewingEnderChest(); if (chest != null && chest.getViewers().size() == 1) { BlockEventPacket blockEventPacket = new BlockEventPacket(); blockEventPacket.x = (int) chest.getX(); blockEventPacket.y = (int) chest.getY(); blockEventPacket.z = (int) chest.getZ(); blockEventPacket.case1 = 1; blockEventPacket.case2 = 0; Level level = this.getHolder().getLevel(); if (level != null) { level.addSound(this.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTCLOSED); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, blockEventPacket); } who.setViewingEnderChest(null); } super.onClose(who); }