本文整理了Java中net.minecraft.entity.Entity.entityDropItem()
方法的一些代码示例,展示了Entity.entityDropItem()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.entityDropItem()
方法的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
方法名:entityDropItem
暂无
代码示例来源:origin: Vazkii/Botania
@Override
public void onUsingTick(ItemStack stack, EntityLivingBase living, int count) {
if(living.world.isRemote)
return;
if(count != getMaxItemUseDuration(stack) && count % 5 == 0) {
int range = 12;
List sheep = living.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(living.posX - range, living.posY - range, living.posZ - range, living.posX + range, living.posY + range, living.posZ + range), Predicates.instanceOf(IShearable.class));
if(sheep.size() > 0) {
for(IShearable target : (List<IShearable>) sheep) {
Entity entity = (Entity) target;
if(target.isShearable(stack, entity.world, new BlockPos(entity))) {
List<ItemStack> drops = target.onSheared(stack, entity.world, new BlockPos(entity), EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack));
for(ItemStack drop : drops) {
entity.entityDropItem(drop, 1.0F);
}
ToolCommons.damageItem(stack, 1, living, MANA_PER_DAMAGE);
break;
}
}
}
}
}
代码示例来源:origin: Silentine/GrimoireOfGaia
public static void dropRandomLootAtEntityPos(World world,
@Nullable EntityPlayer player, Entity entity, boolean entityWasRecentlyHit, ResourceLocation lootTableName,
int rolls) {
List<ItemStack> loot = getLoot(world, player, entityWasRecentlyHit, lootTableName);
for (int i = 0; i < rolls; i++) {
entity.entityDropItem(loot.get(world.rand.nextInt(loot.size())), 0F);
}
}
}
代码示例来源:origin: Mine-and-blade-admin/Battlegear2
@Override
public boolean onHitEntity(Entity entityHit, DamageSource source, float ammount) {
if(!source.getDamageType().equals("piercing.arrow")) {
if(entityHit != this.shootingEntity && entityHit.attackEntityFrom(getPiercingDamage(), ammount)) {
this.playSound(SoundEvents.ENTITY_ARROW_HIT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
}
if (entityHit instanceof IShearable) {
if (((IShearable) entityHit).isShearable(ItemStack.EMPTY, world, new BlockPos(entityHit))) {
List<ItemStack> drops = ((IShearable) entityHit).onSheared(ItemStack.EMPTY, world, new BlockPos(entityHit), 1);
if(!world.isRemote) {
for (ItemStack stack : drops) {
EntityItem ent = entityHit.entityDropItem(stack, 1.0F);
if (ent != null) {
ent.motionY += rand.nextFloat() * 0.05F;
ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
}
}
}
}
}
return true;
}
return false;
}
代码示例来源:origin: Vazkii/Quark
ItemStack copy = stack.copy();
stack.setCount(0);
entityIn.entityDropItem(copy, 0);
代码示例来源:origin: Vazkii/Quark
@SubscribeEvent
public void entityUpdate(LivingUpdateEvent event) {
Entity e = event.getEntity();
if(e instanceof EntityParrot) {
int time = e.getEntityData().getInteger(TAG_EGG_TIMER);
if(time > 0) {
if(time == 1) {
e.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1.0F, (e.world.rand.nextFloat() - e.world.rand.nextFloat()) * 0.2F + 1.0F);
e.entityDropItem(new ItemStack(parrot_egg, 1, getResultingEggColor((EntityParrot) e)), 0);
}
e.getEntityData().setInteger(TAG_EGG_TIMER, time - 1);
}
}
}
代码示例来源:origin: Silentine/GrimoireOfGaia
/**
* Drops a nugget in the world. Will drop Gaia nuggets if no other nuggets are present.
*
* @param entity
* @param i 0 = Iron, 1 = Gold, 2 = Diamond, 3 = Emerald, 4 = Copper, 5 = Silver
*/
public static void dropNugget(Entity entity, int i) {
ItemStack stack = new ItemStack(GaiaItems.SHARD, 1, i);
if (GaiaConfig.DEBUG.oreUnity) {
if (i == 0) {
stack = oreCheck(stack, "nuggetIron");
}
if (i == 1) {
stack = oreCheck(stack, "nuggetGold");
}
if (i == 2) {
stack = oreCheck(stack, "nuggetDiamond");
}
if (i == 3) {
stack = oreCheck(stack, "nuggetEmerald");
}
if (i == 4) {
stack = oreCheck(stack, "nuggetCopper");
}
if (i == 5) {
stack = oreCheck(stack, "nuggetSilver");
}
}
entity.entityDropItem(stack, 0.0F);
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
((EntityLiving) event.getTarget()).writeEntityToNBT(statuette.getTagCompound());
if (!event.getTarget().world.isRemote) {
event.getTarget().entityDropItem(statuette, 1);
内容来源于网络,如有侵权,请联系作者删除!