當前位置: 首頁>>代碼示例>>Java>>正文


Java LivingDropsEvent類代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.living.LivingDropsEvent的典型用法代碼示例。如果您正苦於以下問題:Java LivingDropsEvent類的具體用法?Java LivingDropsEvent怎麽用?Java LivingDropsEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LivingDropsEvent類屬於net.minecraftforge.event.entity.living包,在下文中一共展示了LivingDropsEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: dropClay

import net.minecraftforge.event.entity.living.LivingDropsEvent; //導入依賴的package包/類
@SubscribeEvent
public void dropClay(LivingDropsEvent event) {
    EntityLivingBase deadEntity = event.getEntityLiving();
    World world = deadEntity.getEntityWorld();
    BlockPos position = deadEntity.getPosition();
    double x = position.getX();
    double y = position.getY();
    double z = position.getZ();
    if (deadEntity instanceof EntityWitherSkeleton) {
        if (world.rand.nextInt(10) == 5) {
            event.getDrops().add(new EntityItem(world, x, y, z, new ItemStack(Items.CLAY_BALL)));
        }
    } else if (deadEntity instanceof EntityDragon || deadEntity instanceof EntityWither) {
        event.getDrops().add(new EntityItem(world, x, y, z, new ItemStack(Items.CLAY_BALL)));
    }
}
 
開發者ID:elifoster,項目名稱:MakeClayValuableAgain,代碼行數:17,代碼來源:ClayProgressionImprovements.java

示例2: getPlayer

import net.minecraftforge.event.entity.living.LivingDropsEvent; //導入依賴的package包/類
public static EntityPlayer getPlayer(Event event)
{
	if(event instanceof LivingEvent && ((LivingEvent)event).getEntity() instanceof EntityPlayer)
		return (EntityPlayer)((LivingEvent)event).getEntity();
	if(event instanceof RenderGameOverlayEvent || event instanceof RenderWorldLastEvent || event instanceof ClientTickEvent)
		return HarshenCastle.proxy.getPlayer();
	if(event instanceof PlayerTickEvent)
		return ((PlayerTickEvent)event).player;
	if(event instanceof PlayerEvent)
		return ((PlayerEvent)event).player;
	if(event instanceof net.minecraftforge.event.entity.player.PlayerEvent)
		return ((net.minecraftforge.event.entity.player.PlayerEvent)event).getEntityPlayer();
	if(event instanceof PlayerPunchedEvent)
		return ((PlayerPunchedEvent)event).attacker;
	if(event instanceof LivingDropsEvent && isSourceFromPlayer(((LivingDropsEvent)event).getSource()))
		return getPlayerFromSource(((LivingDropsEvent)event).getSource());
	return null;
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:19,代碼來源:HarshenUtils.java

示例3: onLivingDropsEvent

import net.minecraftforge.event.entity.living.LivingDropsEvent; //導入依賴的package包/類
@SubscribeEvent
public static void onLivingDropsEvent(LivingDropsEvent event) {
	if (ConfigHandler.dropMoney && !(event.getEntityLiving() instanceof EntityPlayer) && event.getEntityLiving() instanceof IMob && event.getEntityLiving().getEntityWorld().isRemote == false) {
		if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityPlayer && !(event.getSource().getTrueSource() instanceof FakePlayer)) {
			CurrencyUtils.dropMoneyAmount(event.getEntityLiving().getMaxHealth() / ConfigHandler.mobDivisionValue, event.getEntityLiving().getEntityWorld(), event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ);
			return;
		}

		if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityArrow) {
			EntityArrow arrow = (EntityArrow) event.getSource().getTrueSource();
			if (arrow.shootingEntity instanceof EntityPlayer && !(arrow.shootingEntity instanceof FakePlayer)) {
				CurrencyUtils.dropMoneyAmount(event.getEntityLiving().getMaxHealth() / ConfigHandler.mobDivisionValue, event.getEntityLiving().getEntityWorld(), event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ);
				return;
			}
		}
	}
}
 
開發者ID:Zundrel,項目名稱:Never-Enough-Currency,代碼行數:18,代碼來源:ModEventHandler.java

示例4: dropEvent

import net.minecraftforge.event.entity.living.LivingDropsEvent; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void dropEvent(LivingDropsEvent event) {
	if (event.entityLiving.worldObj.isRemote)
		return;

	if (EtFuturum.enableSkullDrop)
		dropHead(event.entityLiving, event.source, event.lootingLevel, event.drops);

	Random rand = event.entityLiving.worldObj.rand;
	if (EtFuturum.enableMutton && event.entityLiving instanceof EntitySheep) {
		int amount = rand.nextInt(3) + 1 + rand.nextInt(1 + event.lootingLevel);
		for (int i = 0; i < amount; i++)
			if (event.entityLiving.isBurning())
				addDrop(new ItemStack(ModItems.cooked_mutton), event.entityLiving, event.drops);
			else
				addDrop(new ItemStack(ModItems.raw_mutton), event.entityLiving, event.drops);
	}
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:19,代碼來源:ServerEventHandler.java

示例5: 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

示例6: netherDrop

import net.minecraftforge.event.entity.living.LivingDropsEvent; //導入依賴的package包/類
@SubscribeEvent
public void netherDrop(final LivingDropsEvent event) {
    if (ExtraUtils.divisionSigil != null && event.entityLiving instanceof EntityWither && event.source.getSourceOfDamage() instanceof EntityPlayer && event.entity.worldObj != null && event.entity.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot")) {
        final EntityPlayer player = (EntityPlayer)event.source.getSourceOfDamage();
        NBTTagCompound t = new NBTTagCompound();
        if (player.getEntityData().hasKey("PlayerPersisted")) {
            t = player.getEntityData().getCompoundTag("PlayerPersisted");
        }
        else {
            player.getEntityData().setTag("PlayerPersisted", (NBTBase)t);
        }
        int kills = 0;
        if (t.hasKey("witherKills")) {
            kills = t.getInteger("witherKills");
        }
        ++kills;
        t.setInteger("witherKills", kills);
        if (kills == 1 || !t.hasKey("hasSigil") || event.entity.worldObj.rand.nextInt(10) == 0) {
            final ItemStack item = new ItemStack(ExtraUtils.divisionSigil);
            final EntityItem entityitem = new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, item);
            entityitem.delayBeforeCanPickup = 10;
            event.drops.add(entityitem);
        }
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:26,代碼來源:EventHandlerServer.java

示例7: 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

示例8: onEntityDrops

import net.minecraftforge.event.entity.living.LivingDropsEvent; //導入依賴的package包/類
@SubscribeEvent
   public void onEntityDrops(LivingDropsEvent event)
{
	int alea;
	
	if (event.entityLiving instanceof EntityMob)
		alea = 20;
	else
		alea = 50;
	
	if (event.entityLiving.worldObj.rand.nextInt(alea) < 1 + event.lootingLevel * 2)
	{
		EntityItem e;
		
		e = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, new ItemStack(ItemRegister.getRandomArmor(), 1));
		e = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, new ItemStack(ItemRegistry1.bagdrop, 1));
		
		
		event.drops.add(e);
	}
}
 
開發者ID:GhostMonk3408,項目名稱:MidgarCrusade,代碼行數:22,代碼來源:LivingEntityEvent.java

示例9: 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

示例10: 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);
				}
			}
		}
	}
}
 
開發者ID:Modding-Legacy,項目名稱:Aether-Legacy,代碼行數:25,代碼來源:AetherEventHandler.java

示例11: 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 (event.getEntity() instanceof EntityMob && TinkerUtil.hasTrait(TagUtil.getTagSafe(player.getHeldItemMainhand()), identifier)) {

            int r = random.nextInt(2);
            ItemStack i = null;
            switch (r) {
                case 0:
                    i = new ItemStack(Items.BLAZE_POWDER, random.nextInt(3));
                    break;
                case 1:
                    i = new ItemStack(Items.BLAZE_ROD, random.nextInt(3));
                    break;
                case 2:
                    i = new ItemStack(Items.COAL, random.nextInt(3));
                    break;
            }
            assert i != null;
            event.getDrops().add(0, new EntityItem(w, event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, i));
        }
    }
}
 
開發者ID:TeamFRM,項目名稱:TAIGA,代碼行數:26,代碼來源:TraitGarishly.java

示例12: 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

示例13: onLivingDrops

import net.minecraftforge.event.entity.living.LivingDropsEvent; //導入依賴的package包/類
@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event)
{
	Entity e = event.entity;
	List<EntityItem> drops = event.drops;
	// Remove all drops from cows, sheep and pigs, add carcass drop
	if (e instanceof EntityCow || e instanceof EntityPig || e instanceof EntitySheep)
	{
		EntityAnimal a = (EntityAnimal) e;
		Iterator<EntityItem> it = drops.iterator();
		while (it.hasNext())
		{
			EntityItem i = it.next();
			it.remove();
		}

		if (a.getGrowingAge() == 0)
		{
			if (a instanceof EntityCow) a.dropItem(TanneryItems.bloodyCowCarcass, 1);
			else if (a instanceof EntityPig) a.dropItem(TanneryItems.bloodyPigCarcass, 1);
			else if (a instanceof EntitySheep) a.dropItem(TanneryItems.bloodySheepCarcass, 1);
		}
	}
}
 
開發者ID:hero887,項目名稱:Tannery,代碼行數:25,代碼來源:EntityDropsHandler.java

示例14: onEntityKilled

import net.minecraftforge.event.entity.living.LivingDropsEvent; //導入依賴的package包/類
@SubscribeEvent
public void onEntityKilled(LivingDropsEvent event)
{
	// TODO remove when actual ark creatures are in place and dropping items
	if (event.getEntityLiving().world.isRemote) return;
	Random r = new Random();
	int x = r.nextInt(3) + 1;
	ItemStack meat = new ItemStack(ARKCraftItems.meat_raw, x);
	event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY,
			event.getEntityLiving().posZ, IDecayable.setDecayStart(meat, ARKCraft.proxy.getWorldTime())));
	if (r.nextDouble() < 0.05) event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX,
			event.getEntityLiving().posY, event.getEntityLiving().posZ, IDecayable.setDecayStart(new ItemStack(
					ARKCraftItems.primemeat_raw), ARKCraft.proxy.getWorldTime())));
	if (event.getEntityLiving() instanceof EntitySpider || event.getEntityLiving() instanceof EntitySilverfish
			|| event.getEntityLiving() instanceof EntityEndermite) event.getDrops().add(new EntityItem(
					event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY,
					event.getEntityLiving().posZ, new ItemStack(ARKCraftItems.chitin, r.nextInt(3) + 1)));
	else event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX,
			event.getEntityLiving().posY, event.getEntityLiving().posZ, new ItemStack(ARKCraftItems.hide, r.nextInt(3) + 1)));
}
 
開發者ID:BubbleTrouble14,項目名稱:ARKCraft,代碼行數:21,代碼來源:CommonEventHandler.java

示例15: onEntityLivingDeath

import net.minecraftforge.event.entity.living.LivingDropsEvent; //導入依賴的package包/類
@SubscribeEvent
public void onEntityLivingDeath(LivingDropsEvent event) {
	if (MobRebirth.instance.getHasCustomMobSettings()) {
		if (EntityList.getKey(event.getEntityLiving()) != null)
			if (ArrayUtils.contains(ConfigValues.CUSTOMENTITIES, EntityList.getKey(event.getEntityLiving()).getResourcePath())) {
				if (ConfigValues.REBIRTHFROMNONPLAYERMAP.get(EntityList.getKey(event.getEntityLiving())))
					transition(event);
				else if (event.getSource().getTrueSource() instanceof EntityPlayer)
					transition(event);
				return;
			}
	}
	if (ConfigValues.REBIRTHFROMNONPLAYER)
		transition(event);
	else if (event.getSource().getTrueSource() instanceof EntityPlayer)
		transition(event);
}
 
開發者ID:The-Fireplace-Minecraft-Mods,項目名稱:Mob-Rebirth,代碼行數:18,代碼來源:CommonEvents.java


注:本文中的net.minecraftforge.event.entity.living.LivingDropsEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。