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


Java LivingDropsEvent.getLootingLevel方法代码示例

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


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

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

示例2: livingDropsEvent

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void livingDropsEvent(LivingDropsEvent event) {
    Random random = new Random();
    if (event.getSource().getImmediateSource() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getSource().getImmediateSource();
        if (player.inventory.getCurrentItem().getItem() == this.killTool) {
            if (event.getEntityLiving().getClass().isAssignableFrom(this.livingClass) && this.isChild == event.getEntityLiving().isChild()) {
                if (this.vanillaDropChance == -1 ? random.nextInt(100) >= 35 : random.nextInt(100) <= this.vanillaDropChance) {
                    event.getDrops().clear();
                }
                int dropChance = MathHelper.getInt(random, this.dropMin, this.dropMax);
                for (int k = 0; k < dropChance + event.getLootingLevel(); ++k) {
                    if (event.getEntityLiving().isBurning() && this.canDropBurned) {
                        event.getEntityLiving().entityDropItem(this.dropBurning.copy(), 1F);
                    } else {
                        event.getEntityLiving().entityDropItem(this.drop.copy(), 1F);
                    }
                }
            }
        }
    }
}
 
开发者ID:GirafiStudios,项目名称:Culinary-Cultivation,代码行数:23,代码来源:MobDropEvent.java

示例3: getSkullDropChance

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
private double getSkullDropChance(@Nonnull EntityPlayer player, LivingDropsEvent evt) {
  if (isWitherSkeleton(evt)) {
    if (isEquippedAndPowered(player, Config.darkSteelSwordPowerUsePerHit)) {
      return Config.darkSteelSwordWitherSkullChance + (Config.darkSteelSwordWitherSkullLootingModifier * evt.getLootingLevel());
    } else {
      return 0.01;
    }
  }
  float fromWeapon;
  float fromLooting;
  if (isEquippedAndPowered(player, Config.darkSteelSwordPowerUsePerHit)) {
    fromWeapon = Config.darkSteelSwordSkullChance;
    fromLooting = Config.darkSteelSwordSkullLootingModifier * evt.getLootingLevel();
  } else {
    fromWeapon = Config.vanillaSwordSkullChance;
    fromLooting = Config.vanillaSwordSkullLootingModifier * evt.getLootingLevel();
  }
  return fromWeapon + fromLooting;
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:20,代码来源:ItemDarkSteelSword.java

示例4: onLivingDeath

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingDeath(LivingDropsEvent event)
{
    if(!event.getEntityLiving().getEntityWorld().isRemote && (Clef.config.onlyHostileMobSpawn == 0 || event.getEntityLiving() instanceof IMob) && event.getEntityLiving().getRNG().nextFloat() < (Clef.config.mobDropRate / 10000F) * (event.getLootingLevel() + 1))
    {
        ItemStack stack = new ItemStack(Clef.itemInstrument, 1, 0);
        InstrumentLibrary.assignRandomInstrument(stack);
        event.getDrops().add(event.getEntityLiving().entityDropItem(stack, 0F));
    }
}
 
开发者ID:iChun,项目名称:Clef,代码行数:11,代码来源:EventHandlerServer.java

示例5: somethingDied

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void somethingDied(LivingDropsEvent event)
{
	if (!"player".equals(event.getSource().damageType))
	{
		return;
	}

	EntityLivingBase entity = event.getEntityLiving();
	int looting = event.getLootingLevel();
	Random rng = entity.getEntityWorld().rand;

	ItemStack skull = null;

	if (entity instanceof EntityZombieVillager)
	{
		if (rng.nextFloat() < 0.025 + looting * 0.01)
		{
			skull = HEADS.get("minecraft:zombie_villager;" + ((EntityZombieVillager) entity).getForgeProfession().getRegistryName().toString());
		}
	}
	else if (entity instanceof EntityLlama)
	{
		if (rng.nextFloat() < 0.025 + looting * 0.01)
		{
			skull = HEADS.get("minecraft:llama;" + ((EntityLlama) entity).getVariant());
		}
	}
	else if (entity instanceof EntityOcelot)
	{
		if (rng.nextFloat() < 0.05 + looting * 0.02)
		{
			skull = HEADS.get("minecraft:ocelot;" + ((EntityOcelot) entity).getTameSkin());
		}
	}
	else if (entity instanceof EntityRabbit)
	{
		if (rng.nextFloat() < 0.1 + looting * 0.05)
		{
			if ("Toast".equals(entity.getCustomNameTag()))
			{
				skull = HEADS.get("minecraft:rabbit;Toast");
			}
			else
			{
				skull = HEADS.get("minecraft:rabbit;" + ((EntityRabbit) entity).getRabbitType());
			}
		}
	}
	else if (entity instanceof EntityParrot)
	{
		skull = HEADS.get("minecraft:parrot;" + ((EntityParrot) entity).getVariant());
	}
	else if (entity instanceof EntityHorse)
	{
		if (rng.nextFloat() < 0.2 + looting * 0.1)
		{
			skull = HEADS.get("minecraft:horse;" + ((EntityHorse) entity).getHorseVariant() % 256);
		}
	}
	else if (entity instanceof EntityWither)
	{
		skull = WITHER_HEADS.get(entity.getEntityWorld().rand.nextInt(WITHER_HEADS.size()));
	}

	if (skull != null)
	{
		event.getDrops().add(new EntityItem(entity.getEntityWorld(), entity.getPosition().getX(), entity.getPosition().getY(), entity.getPosition().getZ(), skull.copy()));
	}
}
 
开发者ID:DarkMorford,项目名称:BetterThanWeagles,代码行数:71,代码来源:EvenMoreMobHeads.java

示例6: 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));
      }

    }
  }

}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:65,代码来源:ItemDarkSteelSword.java

示例7: invoke

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@Override
public void invoke(Event event)
{
    checkNotNull(event, "event");
    checkArgument(event instanceof LivingDropsEvent,
                  "expected LivingDropsEvent, but got %s.",
                  event.getClass());

    LivingDropsEvent typedEvent = (LivingDropsEvent)event;

    Optional<Item> itemToDrop = this.GetItemToDrop(typedEvent);

    if (!itemToDrop.isPresent())
    {
        // No item to drop = nothing to do.
        return;
    }

    // Mimic the behavior of vanilla Minecraft's algorithm to drop items.
    // Start off by selecting a random number from [min, max] of items.
    // Random.nextInt(n) returns [0, n), so we need to do a bit of fiddling
    // to get what we need.
    Entity entity = typedEvent.getEntity();
    EntityAccessor entityAccessor = new EntityAccessor(entity);
    Random rand = entityAccessor.GetRand().or(this.rand);

    int range = this.maxDropsPerEvent - this.minDropsPerEvent + 1;
    int dropCount = this.minDropsPerEvent + rand.nextInt(range);

    // ... and then add between 0 and (LOOTING LEVEL) more!
    int lootingLevel = typedEvent.getLootingLevel();
    if (lootingLevel > 0)
    {
        int perkBonus = rand.nextInt(lootingLevel + 1);
        dropCount += perkBonus;
    }

    for (int i = 0; i < dropCount; i++)
    {
        // For some reason (guessing it's to avoid dropping a 0-item stack),
        // the vanilla code loops through and drops multiple 1-item stacks.
        EntityItem droppedItem = entity.dropItem(itemToDrop.get(), 1);

        // from browsing the code (and testing it out), it looks like the
        // result will already get added to "drops" as a result of calling
        // dropItem!  so even though it looks really tempting, don't do this
        // explicitly, or we'll just double the loot.
        ////typedEvent.drops.add(droppedItem);
    }
}
 
开发者ID:airbreather,项目名称:airbreathercore,代码行数:51,代码来源:LivingDropsEventHandlerBase.java

示例8: isMatch

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
/**
 * Should return true if this matcher matches the given event
 *
 * @param evt The event to match
 * @return True if it should match; false otherwise
 */
@Override
public BaseMatchResult isMatch(LivingDropsEvent evt, ItemStack drop) {
    return new BaseMatchResult(level <= evt.getLootingLevel());
}
 
开发者ID:legendblade,项目名称:CraftingHarmonics,代码行数:11,代码来源:MinLootingMatcher.java

示例9: isMatch

import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
/**
 * Should return true if this matcher matches the given event
 *
 * @param evt The event to match
 * @return True if it should match; false otherwise
 */
@Override
public BaseMatchResult isMatch(LivingDropsEvent evt, ItemStack drop) {
    return new BaseMatchResult(evt.getLootingLevel() <= level);
}
 
开发者ID:legendblade,项目名称:CraftingHarmonics,代码行数:11,代码来源:MaxLootingMatcher.java


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