本文整理汇总了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();
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
}
}
示例5: isItem
import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
public boolean isItem() {
return this.entity instanceof EntityItem;
}
示例6: ItemDespawnEvent
import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
public ItemDespawnEvent(EntityItem item) {
this.entity = item;
}
示例7: getEntity
import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
@Override
public EntityItem getEntity() {
return (EntityItem) this.entity;
}
示例8: ItemSpawnEvent
import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
public ItemSpawnEvent(EntityItem item) {
this.entity = item;
}
示例9: InventoryPickupItemEvent
import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
public InventoryPickupItemEvent(Inventory inventory, EntityItem item) {
super(inventory);
this.item = item;
}
示例10: getItem
import cn.nukkit.entity.item.EntityItem; //导入依赖的package包/类
public EntityItem getItem() {
return item;
}