本文整理汇总了Java中cn.nukkit.blockentity.BlockEntityChest类的典型用法代码示例。如果您正苦于以下问题:Java BlockEntityChest类的具体用法?Java BlockEntityChest怎么用?Java BlockEntityChest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlockEntityChest类属于cn.nukkit.blockentity包,在下文中一共展示了BlockEntityChest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: DoubleChestInventory
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
public DoubleChestInventory(BlockEntityChest left, BlockEntityChest right) {
super(null, InventoryType.DOUBLE_CHEST);
this.holder = this;
this.left = left.getRealInventory();
this.right = right.getRealInventory();
Map<Integer, Item> items = new HashMap<>();
// First we add the items from the left chest
for (int idx = 0; idx < this.left.getSize(); idx++) {
if (this.left.getContents().containsKey(idx)) { // Don't forget to skip empty slots!
items.put(idx, this.left.getContents().get(idx));
}
}
// And them the items from the right chest
for (int idx = 0; idx < this.right.getSize(); idx++) {
if (this.right.getContents().containsKey(idx)) { // Don't forget to skip empty slots!
items.put(idx + this.left.getSize(), this.right.getContents().get(idx)); // idx + this.left.getSize() so we don't overlap left chest items
}
}
this.setContents(items);
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:24,代码来源:DoubleChestInventory.java
示例2: registerBlockEntities
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
private void registerBlockEntities() {
BlockEntity.registerBlockEntity(BlockEntity.FURNACE, BlockEntityFurnace.class);
BlockEntity.registerBlockEntity(BlockEntity.CHEST, BlockEntityChest.class);
BlockEntity.registerBlockEntity(BlockEntity.SIGN, BlockEntitySign.class);
BlockEntity.registerBlockEntity(BlockEntity.ENCHANT_TABLE, BlockEntityEnchantTable.class);
BlockEntity.registerBlockEntity(BlockEntity.SKULL, BlockEntitySkull.class);
BlockEntity.registerBlockEntity(BlockEntity.FLOWER_POT, BlockEntityFlowerPot.class);
BlockEntity.registerBlockEntity(BlockEntity.BREWING_STAND, BlockEntityBrewingStand.class);
BlockEntity.registerBlockEntity(BlockEntity.ITEM_FRAME, BlockEntityItemFrame.class);
BlockEntity.registerBlockEntity(BlockEntity.CAULDRON, BlockEntityCauldron.class);
BlockEntity.registerBlockEntity(BlockEntity.ENDER_CHEST, BlockEntityEnderChest.class);
BlockEntity.registerBlockEntity(BlockEntity.BEACON, BlockEntityBeacon.class);
BlockEntity.registerBlockEntity(BlockEntity.SHULKER_BOX, BlockEntityShulkerBox.class);
BlockEntity.registerBlockEntity(BlockEntity.MOB_SPAWNER, BlockEntityMobSpawner.class);
BlockEntity.registerBlockEntity(BlockEntity.DISPENSER, BlockEntityDispenser.class);
BlockEntity.registerBlockEntity(BlockEntity.DROPPER, BlockEntityDropper.class);
BlockEntity.registerBlockEntity(BlockEntity.COMMAND_BLOCK, BlockEntityCommandBlock.class);
BlockEntity.registerBlockEntity(BlockEntity.BANNER, BlockEntityBanner.class);
}
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:20,代码来源:Server.java
示例3: openChestInventory
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)
public void openChestInventory(PlayerInteractEvent event){
if(event.getBlock().getId() == Block.CHEST){
Block block = event.getBlock();
BlockEntityChest chest = (BlockEntityChest) block.getLevel().getBlockEntity(block);
BlockEntityChest chestPair = null;
if(chest.getPair()!=null){
chestPair = chest.getPair();
}
if(chest.namedTag.exist("Owner")){
if(!ChestLocker.getInstance().testPermission(chest,event.getPlayer())) {
event.setCancelled();
event.getPlayer().sendMessage(TextFormat.RED+"[ChestLocker] 你没有打开这个箱子的权限");
}
if(chestPair!=null && !ChestLocker.getInstance().testPermission(chestPair,event.getPlayer())) {
event.setCancelled();
event.getPlayer().sendMessage(TextFormat.RED+"[ChestLocker] 你没有打开这个箱子的相邻箱子的权限");
}
}
}
}
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:26,代码来源:EventListener.java
示例4: onCustomName
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)
public void onCustomName(PlayerInteractEvent event){
if(event.getBlock().getId() == Block.CHEST) {
if (ChestLocker.getInstance().getCustomName().containsKey(event.getPlayer().getName())) {
Block block = event.getBlock();
BlockEntity chestP = event.getBlock().getLevel().getBlockEntity(block);
if(chestP instanceof BlockEntityChest){
BlockEntityChest chest = (BlockEntityChest)chestP;
if(EconomyAPI.getInstance().myMoney(event.getPlayer()) >= 500) {
chest.setName(ChestLocker.getInstance().getCustomName().get(event.getPlayer().getName()));
event.getPlayer().sendMessage("设置成功");
ChestLocker.getInstance().getCustomName().remove(event.getPlayer().getName());
EconomyAPI.getInstance().reduceMoney(event.getPlayer(),500);
}else{
event.getPlayer().sendMessage("你没有足够的金钱");
ChestLocker.getInstance().getCustomName().remove(event.getPlayer().getName());
}
}
}
}
}
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:22,代码来源:EventListener.java
示例5: clearContainerBlockContents
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
@Override
public boolean clearContainerBlockContents(Vector pt) {
BlockEntity block = getLevel().getBlockEntity(setMutable(pt));
if (block == null) {
return false;
}
if (block instanceof InventoryHolder) {
if (block instanceof BlockEntityChest) {
((BlockEntityChest) block).getRealInventory().clearAll();
} else {
((InventoryHolder) block).getInventory().clearAll();
}
return true;
}
return false;
}
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:17,代码来源:NukkitWorld.java
示例6: getWeakPower
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
@Override
public int getWeakPower(BlockFace face) {
int playerCount = 0;
BlockEntity blockEntity = this.level.getBlockEntity(this);
if (blockEntity instanceof BlockEntityChest) {
playerCount = ((BlockEntityChest) blockEntity).getInventory().getViewers().size();
}
return playerCount < 0 ? 0 : playerCount > 15 ? 15 : playerCount;
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:13,代码来源:BlockTrappedChest.java
示例7: onBreak
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
@Override
public boolean onBreak(Item item) {
BlockEntity t = this.getLevel().getBlockEntity(this);
if (t instanceof BlockEntityChest) {
((BlockEntityChest) t).unpair();
}
this.getLevel().setBlock(this, new BlockAir(), true, true);
return true;
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:11,代码来源:BlockChest.java
示例8: getComparatorInputOverride
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
public int getComparatorInputOverride() {
BlockEntity blockEntity = this.level.getBlockEntity(this);
if (blockEntity instanceof BlockEntityChest) {
return ContainerInventory.calculateRedstone(((BlockEntityChest) blockEntity).getInventory());
}
return super.getComparatorInputOverride();
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:10,代码来源:BlockChest.java
示例9: testPermission
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
public boolean testPermission(BlockEntityChest chest,String name) {
if(chest.namedTag.exist("Owner")) {
return Objects.equals(chest.namedTag.getString("Owner"), name) || chest.namedTag.getList("Guest",StringTag.class).getAll().contains(new StringTag("", name));
}else{
return false;
}
}
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:9,代码来源:ChestLocker.java
示例10: CopyChestInformation
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
/**
*
* @param chest1 xD
* @param chest2 xD
* 将chest1的Owner与Guest 信息拷贝到chest2
*/
public void CopyChestInformation(BlockEntityChest chest1,BlockEntityChest chest2){
if(chest1.namedTag.exist("Owner")){
String Owner = chest1.namedTag.getString("Owner");
chest2.namedTag.putString("Owner",Owner);
}
if(chest1.namedTag.exist("Guest")){
ListTag<StringTag> Guest = chest1.namedTag.getList("Guest",StringTag.class);
chest2.namedTag.putList(Guest);
}
}
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:17,代码来源:ChestLocker.java
示例11: onChestLock
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)
public void onChestLock(PlayerInteractEvent event){
if(plugin.getLockSetting().containsKey(event.getPlayer().getName())){
event.setCancelled();
Block block = event.getBlock();
Player player = event.getPlayer();
if(block.getId()==Block.CHEST){
BlockEntity chestP = block.getLevel().getBlockEntity(block);
if(chestP instanceof BlockEntityChest){
BlockEntityChest chest = (BlockEntityChest)chestP;
if(chest.namedTag.contains("Owner")){
if(Objects.equals(player.getName(),ChestLocker.getInstance().getChestOwner(chest))){
player.sendMessage(TextFormat.GRAY+"[ChestLocker] 这个箱子已经被你锁上过了");
}else{
player.sendMessage(TextFormat.GRAY+"[ChestLocker] 这个箱子已经被[ "+ChestLocker.getInstance().getChestOwner(chest)+" ]锁上了,你无法再次锁定");
}
}else{
chest.namedTag.putString("Owner",player.getName());
player.sendMessage(TextFormat.GOLD+"[ChestLocker] 成功锁上箱子,这个箱子的拥有者变更为 [ "+player.getName()+" ]");
if(chest.getPair()!=null){
BlockEntityChest chestPair = chest.getPair();
ChestLocker.getInstance().CopyChestInformation(chest,chestPair);
}
}
//this.plugin.getLogger().info("chest "+chest.namedTag.getAllTags());
//this.plugin.getLogger().info("chestPair "+ chest.namedTag.getAllTags());
plugin.getLockSetting().remove(player.getName());
player.sendMessage(TextFormat.GRAY+"[ChestLocker] 退出锁定箱子模式");
}
}
}
}
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:36,代码来源:EventListener.java
示例12: onUnlockChest
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
@EventHandler
public void onUnlockChest(PlayerInteractEvent event){
if(plugin.getUnLockSetting().containsKey(event.getPlayer().getName())){
event.setCancelled();
Block block = event.getBlock();
Player player = event.getPlayer();
if(block.getId()==Block.CHEST){
BlockEntity chestP = block.getLevel().getBlockEntity(block);
if(chestP instanceof BlockEntityChest){
BlockEntityChest chest = (BlockEntityChest)chestP;
if(Objects.equals(player.getName(),ChestLocker.getInstance().getChestOwner(chest))){
chest.namedTag.remove("Owner");
chest.namedTag.remove("Guest");
for(Player p : chest.getInventory().getViewers()){
chest.getInventory().onClose(p);
}
player.sendMessage(TextFormat.RED+"[ChestLocker] 你以解锁该箱子,并且删除所有共享该箱子的玩家信息");
plugin.getUnLockSetting().remove(player.getName());
player.sendMessage(TextFormat.AQUA+"[ChestLocker] 以退出解锁箱子模式");
}else{
player.sendMessage(TextFormat.YELLOW+"[ChestLocker] 你选择了一个不属于你的箱子,你无法对此进行操作");
}
}
}
}
}
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:29,代码来源:EventListener.java
示例13: onUnshareChest
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
@EventHandler
public void onUnshareChest(PlayerInteractEvent event){
if(plugin.getUnshareSetting().containsKey(event.getPlayer().getName())){
event.setCancelled();
Block block = event.getBlock();
Player player = event.getPlayer();
String unshare = this.plugin.getUnshareSetting().get(player.getName());
if(block.getId()==Block.CHEST){
BlockEntity chestP = block.getLevel().getBlockEntity(block);
if(chestP instanceof BlockEntityChest){
BlockEntityChest chest = (BlockEntityChest) chestP;
if(Objects.equals(chest.namedTag.getString("Owner"),player.getName())){
List<StringTag> list = chest.namedTag.getList("Guest",StringTag.class).getAll();
if(list.contains(new StringTag("",unshare))){
//list.remove(new StringTag("",unshare));
List<StringTag> tag = chest.namedTag.getList("Guest",StringTag.class).getAll();
tag.remove(new StringTag("",unshare));
chest.namedTag.getList("Guest",StringTag.class).setAll(tag);
player.sendMessage(TextFormat.GOLD+"[ChestLocker] 以将 [ "+unshare+" ] 移除出箱子共享列表中");
plugin.getUnshareSetting().remove(unshare);
player.sendMessage(TextFormat.AQUA+"以退出取消箱子共享模式");
}else{
player.sendMessage(TextFormat.GRAY+"[ChestLocker] "+unshare+" 不在这个箱子的共享列表中");
}
}
}
}
}
}
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:32,代码来源:EventListener.java
示例14: DemandChest
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
@EventHandler
public void DemandChest(PlayerInteractEvent event){
if(ChestLocker.getInstance().getDemandChest().containsKey(event.getPlayer().getName())){
if(event.getBlock().getId() == Block.CHEST){
event.setCancelled();
Block block = event.getBlock();
if(block.getLevel().getBlockEntity(block) instanceof BlockEntityChest){
BlockEntityChest chest = (BlockEntityChest) block.getLevel().getBlockEntity(block);
Player p = event.getPlayer();
p.sendMessage(TextFormat.LIGHT_PURPLE+"----------------\n["+block.getName()+"]"+" 箱子信息如下:");
p.sendMessage(TextFormat.LIGHT_PURPLE+"箱子所有者: ["+(chest.namedTag.exist("Owner") ? chest.namedTag.getString("Owner") : "无主")+"]");
if(chest.namedTag.exist("Guest")) {
List<StringTag> list = chest.namedTag.getList("Guest",StringTag.class).getAll();
p.sendMessage(TextFormat.LIGHT_PURPLE+"箱子共享者:");
for (StringTag aList : list) {
p.sendMessage(TextFormat.LIGHT_PURPLE+aList.data);
}
}
p.sendMessage(TextFormat.LIGHT_PURPLE+"----------------");
ChestLocker.getInstance().getDemandChest().remove(event.getPlayer().getName());
}
}else{
event.getPlayer().sendPopup(TextFormat.GRAY+"查询失败,点击的不是箱子");
}
}
}
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:28,代码来源:EventListener.java
示例15: PlaceChest
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)
public void PlaceChest(BlockPlaceEvent event){
Block block = event.getBlock();
if(block.getId() == Block.CHEST)
this.plugin.getServer().getScheduler().scheduleDelayedTask(new PluginTask<ChestLocker>(this.plugin) {
//delay 1tick
@Override
public void onRun(int i) {
try {
if (((BlockEntityChest) block.getLevel().getBlockEntity(block)).getPair() != null) {
BlockEntityChest chestPair = ((BlockEntityChest) block.getLevel().getBlockEntity(block)).getPair();
BlockEntityChest chest = (BlockEntityChest)block.getLevel().getBlockEntity(block);
if (chestPair.namedTag.exist("Owner")) {
if(!Objects.equals(ChestLocker.getInstance().getChestOwner(chest), event.getPlayer().getName())){
block.getLevel().useBreakOn(block);
event.getPlayer().sendMessage(TextFormat.YELLOW + "[ChestLocker] 你无法在这里放置箱子,因为这个箱子所连接的另一个箱子不属于你");
}else{
ChestLocker.getInstance().CopyChestInformation(chestPair,chest);
}
}
}
}catch(Exception ignore){
//ignore
}
}
},1);
}
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:29,代码来源:EventListener.java
示例16: onDestoryChest
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true)
public void onDestoryChest(BlockBreakEvent event){
if(event.getBlock().getId()==Block.CHEST){
Block block = event.getBlock();
if(block.getLevel().getBlockEntity(block) instanceof BlockEntityChest){
BlockEntityChest chest = (BlockEntityChest) block.getLevel().getBlockEntity(block);
if(ChestLocker.getInstance().getChestOwner(chest)!=null && !Objects.equals(ChestLocker.getInstance().getChestOwner(chest),event.getPlayer().getName())){
event.setCancelled();
event.getPlayer().sendMessage(TextFormat.RED+"[ChestLocker] 这个箱子不属于你无法破坏");
}
}
}
}
开发者ID:zzz1999,项目名称:ChestLocker,代码行数:14,代码来源:EventListener.java
示例17: initChest
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
private void initChest(Level lvl, int x, int y, int z, Player p) {
BaseFullChunk chunk = lvl.getChunk(x >> 4, z >> 4);
lvl.setBlockIdAt(x, y, z, Block.CHEST);
cn.nukkit.nbt.tag.CompoundTag nbt = new cn.nukkit.nbt.tag.CompoundTag()
.putList(new cn.nukkit.nbt.tag.ListTag<>("Items"))
.putString("id", BlockEntity.CHEST)
.putInt("x", x)
.putInt("y", y)
.putInt("z", z);
BlockEntityChest e = new BlockEntityChest(chunk, nbt);
lvl.addBlockEntity(e);
e.spawnToAll();
// Items
if (Settings.chestItems.length != 0) {
int count = 0;
for (Item item : Settings.chestItems) {
e.getInventory().setItem(count, item);
count++;
}
} else {
Map<Integer, Item> items = new HashMap<>();
items.put(0, Item.get(Item.ICE, 0, 2));
items.put(1, Item.get(Item.BUCKET, 10, 1));
items.put(2, Item.get(Item.BONE, 0, 2));
items.put(3, Item.get(Item.SUGARCANE, 0, 1));
items.put(4, Item.get(Item.RED_MUSHROOM, 0, 1));
items.put(5, Item.get(Item.BROWN_MUSHROOM, 0, 2));
items.put(6, Item.get(Item.PUMPKIN_SEEDS, 0, 2));
items.put(7, Item.get(Item.MELON, 0, 1));
items.put(8, Item.get(Item.SAPLING, 0, 1));
items.put(9, Item.get(Item.STRING, 0, 12));
items.put(10, Item.get(Item.POISONOUS_POTATO, 0, 32));
e.getInventory().setContents(items);
}
}
开发者ID:TheSolidCrafter,项目名称:ASkyBlock-Nukkit,代码行数:40,代码来源:SchematicHandler.java
示例18: ChestInventory
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
public ChestInventory(BlockEntityChest chest) {
super(chest, InventoryType.CHEST);
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:4,代码来源:ChestInventory.java
示例19: getHolder
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
@Override
public BlockEntityChest getHolder() {
return (BlockEntityChest) this.holder;
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:5,代码来源:ChestInventory.java
示例20: getHolder
import cn.nukkit.blockentity.BlockEntityChest; //导入依赖的package包/类
@Override
public BlockEntityChest getHolder() {
return this.left.getHolder();
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:5,代码来源:DoubleChestInventory.java
注:本文中的cn.nukkit.blockentity.BlockEntityChest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论