本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingDropsEvent.getEntityLiving方法的典型用法代码示例。如果您正苦于以下问题:Java LivingDropsEvent.getEntityLiving方法的具体用法?Java LivingDropsEvent.getEntityLiving怎么用?Java LivingDropsEvent.getEntityLiving使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.living.LivingDropsEvent
的用法示例。
在下文中一共展示了LivingDropsEvent.getEntityLiving方法的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)));
}
}
示例2: 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;
}
}
}
}
示例3: 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);
}
}
}
}
}
示例4: 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)));
}
示例5: makeMobRebornTransition
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
private void makeMobRebornTransition(LivingDropsEvent event) {
if (ConfigValues.ALLOWBOSSES) {
if (event.getEntityLiving() instanceof EntityWither || event.getEntityLiving() instanceof EntityDragon) {
makeMobReborn(event);
return;
}
} else if (event.getEntityLiving() instanceof EntityWither || event.getEntityLiving() instanceof EntityDragon)
return;
if (ConfigValues.ALLOWSLIMES) {
if (event.getEntityLiving() instanceof EntitySlime) {
makeMobReborn(event);
return;
}
} else if (event.getEntityLiving() instanceof EntitySlime)
return;
if (ConfigValues.VANILLAONLY) {
if (isVanilla(event.getEntityLiving())) {
makeMobReborn(event);
}
} else {
makeMobReborn(event);
}
}
示例6: createEntity
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
private void createEntity(LivingDropsEvent event) {
//Store
EntityLivingBase entity;
World worldIn = event.getEntityLiving().world;
ResourceLocation sid = EntityList.getKey(event.getEntityLiving());
NBTTagCompound storedData = event.getEntityLiving().getEntityData();
event.getEntityLiving().writeEntityToNBT(storedData);
ItemStack weapon = event.getEntityLiving().getHeldItem(EnumHand.MAIN_HAND);
ItemStack offhand = event.getEntityLiving().getHeldItem(EnumHand.OFF_HAND);
float health = event.getEntityLiving().getMaxHealth();
//Read
entity = (EntityLivingBase) EntityList.createEntityByIDFromName(sid, worldIn);
if (entity == null)
return;
entity.rotationYawHead = entity.rotationYaw;
entity.renderYawOffset = entity.rotationYaw;
storedData.setInteger("Health", (int) health);
entity.readFromNBT(storedData);
entity.setHealth(health);
if (!weapon.isEmpty())
entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, weapon);
if (!offhand.isEmpty())
entity.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, offhand);
entity.setPosition(event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ);
worldIn.spawnEntity(entity);
}
示例7: entityDeathEvent
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void entityDeathEvent(LivingDropsEvent event)
{
if (event.getEntityLiving() instanceof EntityPlayer && claysTortureMode)
{
event.setCanceled(true);
}
else if (event.getEntityLiving() instanceof EntityEnderman && EndermanGriefing.dropCarrying)
{
EntityEnderman entityEnderman = ((EntityEnderman) event.getEntityLiving());
IBlockState state = entityEnderman.getHeldBlockState();
if (state != null && state.getBlock() != Blocks.AIR)
{
ItemStack stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
event.getDrops().add(new EntityItem(entityEnderman.world, entityEnderman.posX, entityEnderman.posY, entityEnderman.posZ, stack));
}
}
}
示例8: 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));
}
}
示例9: onEntityDrop
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityDrop(LivingDropsEvent event) {
EntityLivingBase living = event.getEntityLiving();
if (living == null || living.world == null) return;
Random rand = living.world.rand;
if (living instanceof EntityShulker) {
if (rand.nextFloat() < 1.0f) {
event.getEntityLiving().entityDropItem(ModItems.material.getMaterial("ender_cream", 1 + rand.nextInt(2)), 0);
}
}
}
示例10: onLivingDrops
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onLivingDrops(LivingDropsEvent event) {
EntityLivingBase living = event.getEntityLiving();
if (!(living instanceof EntityPlayer)) {
IInventory inventory = living.getCapability(AlchemyCapabilityLoader.bauble, null);
if (inventory == null)
return;
for (int i = 0, len = inventory.getSizeInventory(); i < len; i++) {
ItemStack item = inventory.removeStackFromSlot(i);
if (!item.isEmpty())
event.getDrops().add(InventoryHelper.getEntityItem(living, item));
}
}
}
示例11: mobDeath
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void mobDeath(LivingDropsEvent event)
{
EntityLivingBase entity = event.getEntityLiving();
//This is called every time a LivingEntityBase dies
Random rand = new Random();
//Checks the dead entity against the ones in the list
for(Object[] o : mobDrops)
{
//This all checks if the entity's localised name or unlocalised name matches the name in the list
//EntityLivingBase entity = event.entityLiving;
String s = EntityList.getEntityString(entity);
if(s == null)
s = "generic";
String mobUnlocName = "entity." + s + ".name";
String mobName = new TextComponentTranslation(mobUnlocName).getUnformattedText();
if(rand.nextFloat() < (Float) o[4]) {
if( (o[0].equals(PASSIVE_WILDCARD) && checkMobName(false, s)) || //Passive vanilla mob
(o[0].equals(AGGRESSIVE_WILDCARD) && checkMobName(true, s)) || //Aggressive vanilla mob
(o[0].equals(ALL_VANILLA_WILDCARD) && (checkMobName(false, s) || checkMobName(true, s))) || //Any vanilla mob
(o[0].equals(ALL_WILDCARD) && entity instanceof EntityLiving) || //Any registered mob
((mobName.equals(o[0]) || mobUnlocName.equals(o[0])))) //Exact mob
{
//Can spawn mob drop!
int min = (Integer) o[2];
int max = (Integer) o[3];
int randQty = rand.nextInt(max) + min;
if (randQty > 0)
event.getEntityLiving().entityDropItem((ItemStack) o[1], 0);
}
}
}
}
示例12: onEntityDrop
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityDrop(LivingDropsEvent event)
{
if (event.getSource().getDamageType().equals("player"))
{
//The essence
if(event.getSource().getEntity() instanceof EntityPlayer)
{
if (event.getEntity() instanceof EntityAnimal)
{
SoulsData.increaseSouls((EntityPlayer) (event.getSource().getEntity()), 1);
}
else if (event.getEntity() instanceof EntityPlayer)
{
int playerSouls = SoulsData.getSouls((EntityPlayer)event.getEntity());
SoulsData.setSouls((EntityPlayer)event.getEntity(), 0);
SoulsData.increaseSouls((EntityPlayer)(event.getSource().getEntity()), playerSouls);
}
else
{
SoulsData.increaseSouls((EntityPlayer) (event.getSource().getEntity()), 2);
}
}
//The item
rand = Math.random();
if (!(event.getEntityLiving() instanceof EntityAnimal))
{
if(event.getEntityLiving().isPotionActive(TombCraft.potionTC))
{
if (rand < 0.50d)
{
event.getEntityLiving().dropItem(ModItems.soul, 1);
}
}
}
}
}
示例13: onLivingDrops
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event)
{
if(!event.getEntityLiving().world.isRemote)
{
for(int i = event.getDrops().size() - 1; i >= 0; i--)
{
if(spawnWolfFromItem(null, event.getDrops().get(i), null))
{
event.getDrops().remove(i);
}
}
}
}
示例14: 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();
}
}
}
}
示例15: onLivingDrops
import net.minecraftforge.event.entity.living.LivingDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event)
{
EntityLivingBase entity = event.getEntityLiving();
if(entity instanceof EntityVillager)
{
VillagerEvent.onVillagerDrops((EntityVillager)entity, event);
}
}