本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingDropsEvent.getDrops方法的典型用法代码示例。如果您正苦于以下问题:Java LivingDropsEvent.getDrops方法的具体用法?Java LivingDropsEvent.getDrops怎么用?Java LivingDropsEvent.getDrops使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.living.LivingDropsEvent
的用法示例。
在下文中一共展示了LivingDropsEvent.getDrops方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLivingDrop
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingDrop(LivingDropsEvent event) {
final Entity entity = event.getEntity();
if (entity.hasCapability(Capability.CHISELED_SHEEP, null)) {
final IChiseledSheepCapability capability = entity.getCapability(Capability.CHISELED_SHEEP, null);
if (capability.isChiseled())
{
final List<EntityItem> drops = event.getDrops();
final ItemStack chiselItemStack = capability.getChiselItemStack();
final Item chiselItem = chiselItemStack.getItem();
drops.removeIf(entityItem -> ItemStackHelper.isStackForBlock(entityItem.getEntityItem(), Blocks.WOOL));
drops.add(new EntityItem(entity.worldObj, entity.posX, entity.posY, entity.posZ, chiselItemStack.copy()));
MinecraftForge.EVENT_BUS.post(new ShearMadnessSheepKilledEvent(
drops,
event.getSource(),
event.getLootingLevel(),
chiselItemStack,
entity
));
}
}
}
示例2: onEntityDropLoot
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityDropLoot(LivingDropsEvent event)
{
if (event.getSource() instanceof EntityDamageSource)
{
EntityLivingBase entity = event.getEntityLiving();
EntityDamageSource source = (EntityDamageSource) event.getSource();
if (source.getEntity() instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) source.getEntity();
ItemStack currentItem = player.inventory.getCurrentItem();
if (currentItem != null && currentItem.getItem() instanceof ItemSkyrootSword && !(entity instanceof EntityPlayer) && !(entity instanceof EntityWither))
{
for (EntityItem items : event.getDrops())
{
EntityItem item = new EntityItem(entity.worldObj, entity.posX, entity.posY, entity.posZ, items.getEntityItem());
entity.worldObj.spawnEntityInWorld(item);
}
}
}
}
}
示例3: entityDrops
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void entityDrops(LivingDropsEvent ev)
{
Entity entity = ev.getEntity();
if (!(entity instanceof EntitySheep))
return;
List<EntityItem> drops = ev.getDrops();
if (drops instanceof ImmutableList)
{
Survivalist.logger.warn("WARNING: Some mod is returning an ImmutableList, replacing drops will NOT be possible.");
return;
}
if (rnd.nextFloat() < 0.25f)
drops.add(new EntityItem(entity.getEntityWorld(), entity.posX, entity.posY, entity.posZ, new ItemStack(Items.STRING)));
}
示例4: onLivingDrops
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@HarshenEvent
public void onLivingDrops(LivingDropsEvent event)
{
if(event.getEntity() instanceof EntityPlayer)
return;
ArrayList<EntityItem> drops = new ArrayList<EntityItem>();
for(EntityItem e : event.getDrops())
if(event.getEntityLiving().getRNG().nextBoolean())
drops.add(new EntityItem(e.world, e.posX, e.posY, e.posZ, e.getItem()));
event.getDrops().addAll(drops);
}
示例5: entityDropEvent
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority= EventPriority.LOWEST)
public void entityDropEvent(LivingDropsEvent e){
if(e.getEntity() instanceof EntityPlayer
&& e.getResult() != Event.Result.DENY
&& !e.getEntity().getEntityWorld().isRemote) {
final EntityPlayer player = (EntityPlayer)e.getEntity();
if(player.isSpectator()) return;
final World w = player.getEntityWorld();
Map<ItemStack,EntityEquipmentSlot> cache = equipmentCache.computeIfAbsent(player, (EntityPlayer p) -> new HashMap<>());
EntityLootableBody corpse = new EntityLootableBody(player);
corpse.forceSpawn = true;
CommandSummon k;
corpse.setUserName(player.getName());
corpse.setRotation(player.rotationYaw);
List<ItemStack> items = new ArrayList<>();
for (EntityItem itemEntity : e.getDrops()) {
ItemStack item = itemEntity.getEntityItem();
if (item != null && cache.containsKey(item)) {
corpse.setItemStackToSlot(cache.get(item),item);
} else {
items.add(item);
}
}
corpse.initializeItems(items.toArray(new ItemStack[0]));
if(LootableBodies.addBonesToCorpse){
corpse.addItem(new ItemStack(Items.BONE,1+w.rand.nextInt(3)));
corpse.addItem(new ItemStack(Items.ROTTEN_FLESH,1+w.rand.nextInt(3)));
}
w.spawnEntity(corpse);
e.getDrops().clear();
}
}
示例6: onGhastDropsTears
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGH)
public void onGhastDropsTears(LivingDropsEvent event) {
if (event.getEntityLiving() instanceof EntityGhast) {
for (EntityItem item : event.getDrops()) {
if (item.getEntityItem().getItem() == Items.GHAST_TEAR) {
event.getEntityLiving().dropItem(Items.GOLD_INGOT, item.getEntityItem().getCount());
item.setDead();
}
}
}
}
示例7: entityDropEvent
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority= EventPriority.LOWEST)
public void entityDropEvent(LivingDropsEvent e){
if(e.getEntity() instanceof EntityPlayer
&& e.getResult() != Event.Result.DENY
&& !e.getEntity().getEntityWorld().isRemote) {
final EntityPlayer player = (EntityPlayer)e.getEntity();
if(player.isSpectator()) return;
final World w = player.getEntityWorld();
Map<ItemStack,EntityEquipmentSlot> cache = equipmentCache.computeIfAbsent(player, (EntityPlayer p) -> new HashMap<>());
EntityLootableBody corpse = new EntityLootableBody(player);
corpse.forceSpawn = true;
CommandSummon k;
corpse.setUserName(player.getName());
corpse.setRotation(player.rotationYaw);
List<ItemStack> items = new ArrayList<>();
for (EntityItem itemEntity : e.getDrops()) {
ItemStack item = itemEntity.getEntityItem();
if (item != null && cache.containsKey(item)) {
corpse.setItemStackToSlot(cache.get(item),item);
} else {
items.add(item);
}
}
corpse.initializeItems(items.toArray(new ItemStack[0]));
if(LootableBodies.addBonesToCorpse){
corpse.addItem(new ItemStack(Items.BONE,1+w.rand.nextInt(3)));
corpse.addItem(new ItemStack(Items.ROTTEN_FLESH,1+w.rand.nextInt(3)));
}
w.spawnEntityInWorld(corpse);
e.getDrops().clear();
}
}
示例8: onVillagerDrops
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
private static void onVillagerDrops(EntityVillager villager, LivingDropsEvent eventDrop)
{
// ドロップするアイテムのリスト
// これにEntityItemを追加することでドロップを追加できる
List<EntityItem> drops = eventDrop.getDrops();
VillagerEvent.dropInventory(drops, villager);
VillagerEvent.dropEmeralds(drops, villager);
DamageSource damage = eventDrop.getSource();
VillagerEvent.dropVillagerBlockSlab(drops, villager, damage);
}
示例9: containsDrop
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
private boolean containsDrop(LivingDropsEvent evt, @Nonnull ItemStack skull) {
for (EntityItem ei : evt.getDrops()) {
if (ei != null && ei.getEntityItem().getItem() == skull.getItem() && ei.getEntityItem().getItemDamage() == skull.getItemDamage()) {
return true;
}
}
return false;
}
示例10: onEntityDrop
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onEntityDrop(LivingDropsEvent evt) {
final Entity entity = evt.getSource().getEntity();
final EntityLivingBase entityLiving = evt.getEntityLiving();
if (!(entity instanceof EntityPlayer) || entityLiving == null) {
return;
}
EntityPlayer player = (EntityPlayer) entity;
// Handle TiC weapons with beheading differently
if (handleBeheadingWeapons(player, evt)) {
return;
}
double skullDropChance = getSkullDropChance(player, evt);
if (player instanceof FakePlayer) {
skullDropChance *= Config.fakePlayerSkullChance;
}
if (Math.random() <= skullDropChance) {
dropSkull(evt, player);
}
// Special handling for ender pearl drops
if (isEquipped(player)) {
ResourceLocation name = EntityList.getKey(entityLiving);
if (entityLiving instanceof EntityEnderman || ENDERZOO_ENDERMINY.equals(name)) {
int numPearls = 0;
double chance = Config.darkSteelSwordEnderPearlDropChance;
while (chance >= 1) {
numPearls++;
chance--;
}
if (chance > 0 && Math.random() <= chance) {
numPearls++;
}
for (int i = 0; i < evt.getLootingLevel(); i++) {
chance = Config.darkSteelSwordEnderPearlDropChancePerLooting;
while (chance >= 1) {
numPearls++;
chance--;
}
if (chance > 0 && Math.random() <= chance) {
numPearls++;
}
}
int existing = 0;
for (EntityItem stack : evt.getDrops()) {
if (stack.getEntityItem().getItem() == Items.ENDER_PEARL) {
existing += stack.getEntityItem().getCount();
}
}
int toDrop = numPearls - existing;
if (toDrop > 0) {
evt.getDrops()
.add(Util.createDrop(player.world, new ItemStack(Items.ENDER_PEARL, toDrop, 0), entityLiving.posX, entityLiving.posY, entityLiving.posZ, false));
}
}
}
}