当前位置: 首页>>代码示例>>Java>>正文


Java EntityItem类代码示例

本文整理汇总了Java中cn.nukkit.entity.item.EntityItem的典型用法代码示例。如果您正苦于以下问题:Java EntityItem类的具体用法?Java EntityItem怎么用?Java EntityItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EntityItem类属于cn.nukkit.entity.item包,在下文中一共展示了EntityItem类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dropItem

import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
public void dropItem(Vector3 source, Item item, Vector3 motion, int delay) {
    motion = motion == null ? new Vector3(new java.util.Random().nextDouble() * 0.2 - 0.1, 0.2,
            new java.util.Random().nextDouble() * 0.2 - 0.1) : motion;

    CompoundTag itemTag = NBTIO.putItemHelper(item);
    itemTag.setName("Item");

    if (item.getId() > 0 && item.getCount() > 0) {
        EntityItem itemEntity = new EntityItem(
                this.getChunk((int) source.getX() >> 4, (int) source.getZ() >> 4, true),
                new CompoundTag().putList(new ListTag<DoubleTag>("Pos").add(new DoubleTag("", source.getX()))
                        .add(new DoubleTag("", source.getY())).add(new DoubleTag("", source.getZ())))

                        .putList(new ListTag<DoubleTag>("Motion").add(new DoubleTag("", motion.x))
                                .add(new DoubleTag("", motion.y)).add(new DoubleTag("", motion.z)))

                        .putList(new ListTag<FloatTag>("Rotation")
                                .add(new FloatTag("", new java.util.Random().nextFloat() * 360))
                                .add(new FloatTag("", 0)))

                        .putShort("Health", 5).putCompound("Item", itemTag).putShort("PickupDelay", delay));

        itemEntity.spawnToAll();
    }
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:26,代码来源:Level.java

示例2: dropItem

import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
public void dropItem(Vector3 source, Item item, Vector3 motion, boolean dropAround, int delay) {
    if (motion == null) {
        if (dropAround) {
            float f = this.rand.nextFloat() * 0.5f;
            float f1 = this.rand.nextFloat() * ((float) Math.PI * 2);

            motion = new Vector3(-MathHelper.sin(f1) * f, 0.20000000298023224, MathHelper.cos(f1) * f);
        } else {
            motion = new Vector3(new java.util.Random().nextDouble() * 0.2 - 0.1, 0.2,
                    new java.util.Random().nextDouble() * 0.2 - 0.1);
        }
    }

    CompoundTag itemTag = NBTIO.putItemHelper(item);
    itemTag.setName("Item");

    if (item.getId() > 0 && item.getCount() > 0) {
        EntityItem itemEntity = new EntityItem(
                this.getChunk((int) source.getX() >> 4, (int) source.getZ() >> 4, true),
                new CompoundTag().putList(new ListTag<DoubleTag>("Pos").add(new DoubleTag("", source.getX()))
                        .add(new DoubleTag("", source.getY())).add(new DoubleTag("", source.getZ())))

                        .putList(new ListTag<DoubleTag>("Motion").add(new DoubleTag("", motion.x))
                                .add(new DoubleTag("", motion.y)).add(new DoubleTag("", motion.z)))

                        .putList(new ListTag<FloatTag>("Rotation")
                                .add(new FloatTag("", new java.util.Random().nextFloat() * 360))
                                .add(new FloatTag("", 0)))

                        .putShort("Health", 5).putCompound("Item", itemTag).putShort("PickupDelay", delay));

        itemEntity.spawnToAll();
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:35,代码来源:Level.java

示例3: dropItem

import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
public void dropItem(Vector3 source, Item item, Vector3 motion, boolean dropAround, int delay) {
    if (motion == null) {
        if (dropAround) {
            float f = this.rand.nextFloat() * 0.5f;
            float f1 = this.rand.nextFloat() * ((float) Math.PI * 2);

            motion = new Vector3(-MathHelper.sin(f1) * f, 0.20000000298023224, MathHelper.cos(f1) * f);
        } else {
            motion = new Vector3(new java.util.Random().nextDouble() * 0.2 - 0.1, 0.2,
                    new java.util.Random().nextDouble() * 0.2 - 0.1);
        }
    }

    CompoundTag itemTag = NBTIO.putItemHelper(item);
    itemTag.setName("Item");

    if (item.getId() > 0 && item.getCount() > 0) {
        EntityItem itemEntity = new EntityItem(
                this.getChunk((int) source.getX() >> 4, (int) source.getZ() >> 4, true),
                new CompoundTag().putList(new ListTag<DoubleTag>("Pos").add(new DoubleTag("", source.getX()))
                        .add(new DoubleTag("", source.getY())).add(new DoubleTag("", source.getZ())))

                        .putList(new ListTag<DoubleTag>("Motion").add(new DoubleTag("", motion.x))
                                .add(new DoubleTag("", motion.y)).add(new DoubleTag("", motion.z)))

                        .putList(new ListTag<FloatTag>("Rotation")
                                .add(new FloatTag("", new java.util.Random().nextFloat() * 360))
                                .add(new FloatTag("", 0)))

                        .putShort("Health", 5).putCompound("Item", itemTag).putShort("PickupDelay", delay));

        itemEntity.setPickupDelay(delay); //TODO: fix this
        itemEntity.spawnToAll();
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:36,代码来源:Level.java

示例4: onItemPickup

import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
@EventHandler (ignoreCancelled = true)
public void onItemPickup(InventoryPickupItemEvent event){
	if(event.getInventory().getHolder() instanceof Player){
		Player player = (Player) event.getInventory().getHolder();
		EntityItem item = event.getItem();
		
		long now = System.currentTimeMillis();
		Long[] lastPickup = this.manager.getLastPickup(player);
		
		if(lastPickup == null || (lastPickup[1] == item.getId() && now - lastPickup[0] > 2000) || lastPickup[1] != item.getId()){
			Land land;
			if((land = this.provider.findLand(item)) != null && !land.getOption("pickup", false)){
				if(!(land.hasPermission(player) || player.hasPermission("economyland.admin.pickup"))){
					event.setCancelled(true);
					
					if(lastPickup != null && now - lastPickup[0] > 2000){
						player.sendMessage(this.getMessage("pickup-forbidden", new Object[]{
								land.getId(), land.getOwner()
						}));
					}
					
					this.manager.setLastPickup(player, item);
				}
			}
		}else{
			event.setCancelled(true);
		}
	}
}
 
开发者ID:EconomyS,项目名称:EconomyLand,代码行数:30,代码来源:EconomyLand.java

示例5: isItem

import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
public boolean isItem() {
    return this.entity instanceof EntityItem;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:4,代码来源:EntityDespawnEvent.java

示例6: ItemDespawnEvent

import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
public ItemDespawnEvent(EntityItem item) {
    this.entity = item;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:4,代码来源:ItemDespawnEvent.java

示例7: getEntity

import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
@Override
public EntityItem getEntity() {
    return (EntityItem) this.entity;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:5,代码来源:ItemDespawnEvent.java

示例8: ItemSpawnEvent

import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
public ItemSpawnEvent(EntityItem item) {
    this.entity = item;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:4,代码来源:ItemSpawnEvent.java

示例9: InventoryPickupItemEvent

import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
public InventoryPickupItemEvent(Inventory inventory, EntityItem item) {
    super(inventory);
    this.item = item;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:5,代码来源:InventoryPickupItemEvent.java

示例10: getItem

import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
public EntityItem getItem() {
    return item;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:4,代码来源:InventoryPickupItemEvent.java


注:本文中的cn.nukkit.entity.item.EntityItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。