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


Java LivingDropsEvent.getEntity方法代码示例

本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingDropsEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java LivingDropsEvent.getEntity方法的具体用法?Java LivingDropsEvent.getEntity怎么用?Java LivingDropsEvent.getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.event.entity.living.LivingDropsEvent的用法示例。


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

示例1: onDrops

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onDrops(LivingDropsEvent event) {
	World world = event.getEntity().getEntityWorld();

	if (world.isRemote || !(event.getEntity() instanceof EntityCreature)) {
		return;
	}

	if (event.getSource() == null || event.getSource().getTrueSource() == null){
		return;
	}

	if (!(event.getSource().getTrueSource() instanceof EntityPlayer)) {
		return;
	}

	if (event.getEntity().getTags().contains(NemesisSystem.TAG_NEMESIS)) {
		handleNemesisDrops(event.getDrops(), (EntityCreature) event.getEntity());
	}
}
 
开发者ID:ToroCraft,项目名称:NemesisSystem,代码行数:21,代码来源:DeathHandler.java

示例2: onMobDrops

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onMobDrops(LivingDropsEvent e)
{
    World world = e.getEntity().getEntityWorld();
    Random rng = world.rand;
    if (e.getEntity() instanceof EntitySkeleton) {
        EntitySkeleton skele = (EntitySkeleton) e.getEntity();
        if (skele.getSkeletonType() == 1) {
            if (rng.nextFloat() < 0.20 + (e.getLootingLevel() + 1 * 0.05))
                e.getDrops().add(new EntityItem(world, skele.posX, skele.posY, skele.posZ, new ItemStack(ModItems.MobDust, 1, 0)));
        }
    }

    if (e.getEntity() instanceof EntityCaveSpider) {
        if (rng.nextFloat() < 0.20 + (e.getLootingLevel() + 1 * 0.05))
            e.getDrops().add(new EntityItem(world, e.getEntity().posX, e.getEntity().posY, e.getEntity().posZ, new ItemStack(ModItems.MobDust, 1, 1)));
    }
}
 
开发者ID:GamingsModding,项目名称:LittleThings-old,代码行数:19,代码来源:DustMobDrop.java

示例3: 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
            ));
        }
    }
}
 
开发者ID:AtomicBlom,项目名称:ShearMadness,代码行数:27,代码来源:CommonForgeEventProxy.java

示例4: onWitherDeath

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
@SuppressWarnings("unused")
public void onWitherDeath(LivingDropsEvent event) {
    if(ItemRegistry.getInstance().itemRecord == null) {
        return;
    }
    if(!(event.getEntity() instanceof EntityWither)) {
        return;
    }
    Entity killer = event.getSource().getSourceOfDamage();
    if(event.isRecentlyHit() && killer != null && killer instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) killer;
        ItemStack left = player.getHeldItem(EnumHand.MAIN_HAND);
        ItemStack right = player.getHeldItem(EnumHand.OFF_HAND);
        if(isValidStack(left) && isValidStack(right)) {
            EntityItem drop = new EntityItem(event.getEntity().getEntityWorld(), event.getEntity().posX, event.getEntity().posY+0.5D, event.getEntity().posZ,
                    new ItemStack(ItemRegistry.getInstance().itemRecord));
            event.getDrops().add(drop);
        }
    }
}
 
开发者ID:InfinityRaider,项目名称:3DManeuverGear,代码行数:22,代码来源:EntityLivingHandler.java

示例5: 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)));
}
 
开发者ID:gigaherz,项目名称:Survivalist,代码行数:18,代码来源:StringEventHandling.java

示例6: onLivingDropsEvent

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingDropsEvent(LivingDropsEvent event) {
  Entity entity = event.getEntity();
  World world = entity.getEntityWorld();
  if (nameTagDeath) {
    if (entity.getCustomNameTag() != null && entity.getCustomNameTag() != "") {
      // item stack NBT needs the name enchanted onto it
      if (world.isRemote == false) {
        ItemStack nameTag = UtilNBT.buildEnchantedNametag(entity.getCustomNameTag());
        UtilItemStack.dropItemStackInWorld(world, entity.getPosition(), nameTag);
      }
    }
  }
  if (endermanDrop && entity instanceof EntityEnderman) {
    EntityEnderman mob = (EntityEnderman) entity;
    IBlockState bs = mob.getHeldBlockState();// mob.func_175489_ck();
    if (bs != null && bs.getBlock() != null && world.isRemote == false) {
      UtilItemStack.dropItemStackInWorld(world, mob.getPosition(), bs.getBlock());
    }
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:22,代码来源:MobDropChangesModule.java

示例7: livingDrop

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void livingDrop(LivingDropsEvent event)
{
	Vec3d vec = new Vec3d(event.getEntityLiving().getPosition());
	if(event.getEntity() instanceof EntityIronGolem)
	{
		List<ItemStack> stackList = HarshenUtils.getItemsFromLootTable(event.getEntity().world, HarshenLootTables.golemDrops);
		if(stackList.size() == 1)
			event.getDrops().add(new EntityItem(event.getEntity().world, vec.x, vec.y, vec.z, stackList.get(0)));
	}
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:12,代码来源:HandlerIronHeartDrop.java

示例8: livingDrop

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void livingDrop(LivingDropsEvent event)
{
	Vec3d vec = new Vec3d(event.getEntityLiving().getPosition());
	if(event.getEntity() instanceof EntityZombie)
	{
		List<ItemStack> stackList = HarshenUtils.getItemsFromLootTable(event.getEntity().world, HarshenLootTables.zombieDrops);
		if(stackList.size() == 1)
			event.getDrops().add(new EntityItem(event.getEntity().world, vec.x, vec.y, vec.z, stackList.get(0)));
	}
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:12,代码来源:HandlerZombieEyeDrop.java

示例9: 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);
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:12,代码来源:LootingEarring.java

示例10: onLivingDrops

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void onLivingDrops(LivingDropsEvent event)
{
	if (event.getEntity() != null && event.getEntity() instanceof EntityWitch)
	{
		//NotebookInfo info = ev.getEntityPlayer().getCapability(NotebookInfo.CAP, null);
		if (event.getEntity().world.rand.nextInt(2) == 1)
		{
			event.getDrops().add(new EntityItemFancy(event.getEntity().world, event.getEntity().posX,
					event.getEntity().posY, event.getEntity().posZ, new ItemStack(ModRegistry.ANCIENT_PARCHMENT)));
		}
	}
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:14,代码来源:ModEvents.java

示例11: dropBook

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void dropBook(LivingDropsEvent event) {
	if (!NemesisConfig.DISCOVERY_ENABLED) {
		return;
	}

	if (!(event.getEntity() instanceof EntityMob)) {
		return;
	}

	if (event.getEntity().getTags().contains(TAG_NEMESIS)) {
		return;
	}

	if (!(event.getSource().getTrueSource() instanceof EntityPlayer)) {
		return;
	}

	World world = event.getEntity().getEntityWorld();

	int dropChance = dropChance(event.getEntity());

	if (dropChance != 0 && (dropChance < 0 || world.rand.nextInt(dropChance) != 0)) {
		return;
	}

	BlockPos position = event.getEntity().getPosition();
	event.getDrops().add(new EntityItem(world, position.getX(), position.getY(), position.getZ(), DiscoveryUtil.createUnreadBook()));
}
 
开发者ID:ToroCraft,项目名称:NemesisSystem,代码行数:30,代码来源:DropHandler.java

示例12: sheepDropEvent

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void sheepDropEvent(LivingDropsEvent event)
{
    Entity entity = event.getEntity();
    World world = entity.world;
    if(entity instanceof EntitySheep && !world.isRemote)
    {
        InteractionBWM.convertShearedWoolEntities(event.getDrops());
    }
}
 
开发者ID:DaedalusGame,项目名称:BetterWithAddons,代码行数:11,代码来源:HardcoreWoolHandler.java

示例13: onMobKillDropSkull

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onMobKillDropSkull(LivingDropsEvent e)
{
    if (!e.getSource().isExplosion() && !e.getSource().isFireDamage()) {
        Entity justDied = e.getEntity();
        justDied.getArmorInventoryList().forEach((itemStack -> {
            if (itemStack != null && itemStack.getItem() instanceof ItemSkull && itemStack.getMetadata() == 3) {
                String playerName = "";
                if (itemStack.getTagCompound() != null && itemStack.getTagCompound().hasKey("SkullOwner", 8)) {
                    playerName = itemStack.getTagCompound().getString("SkullOwner");
                }

                if (itemStack.getTagCompound() != null && itemStack.getTagCompound().hasKey("SkullOwner", 10)) {
                    NBTTagCompound nbttagcompound = itemStack.getTagCompound().getCompoundTag("SkullOwner");

                    if (nbttagcompound.hasKey("Name", 8)) {
                        playerName = nbttagcompound.getString("Name");
                    }
                }

                if (Arrays.asList(playerNames).contains(playerName) || Arrays.asList(otherNames).contains(playerName)) {
                    EntityItem ei = new EntityItem(justDied.worldObj, justDied.posX, justDied.posY, justDied.posZ, itemStack);
                    if (e.getDrops().contains(ei))
                        e.getDrops().remove(ei);

                    Random rng = new Random();

                    if (rng.nextDouble() < 0.1) e.getDrops().add(ei);
                }
            }
        }));
    }
}
 
开发者ID:GamingsModding,项目名称:LittleThings-old,代码行数:34,代码来源:FriendsSkulls.java

示例14: onMobDrops

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onMobDrops(LivingDropsEvent event) {
    World w = event.getEntity().getEntityWorld();
    if (random.nextFloat() < 0.05 && !w.isRemote && event.getSource().getTrueSource() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
        if (event.getEntity() instanceof EntityMob && TinkerUtil.hasTrait(TagUtil.getTagSafe(player.getHeldItemMainhand()), identifier)) {
            ItemStack i = new ItemStack(Items.GUNPOWDER, random.nextInt(2));
            event.getDrops().add(0, new EntityItem(w, event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, i));
        }
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:12,代码来源:TraitInstable.java

示例15: onMobDrops

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onMobDrops(LivingDropsEvent event) {
    World w = event.getEntity().getEntityWorld();
    if (!w.isRemote && event.getSource().getTrueSource() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
        if (random.nextFloat() <= 0.9 && event.getEntity() instanceof EntityMob && TinkerUtil.hasTrait(TagUtil.getTagSafe(player.getHeldItemMainhand()), identifier)) {
            event.getDrops().clear();
        }
    }
}
 
开发者ID:TeamFRM,项目名称:TAIGA,代码行数:11,代码来源:TraitHollow.java


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