本文整理汇总了Java中net.minecraft.util.EntityDamageSource.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java EntityDamageSource.getEntity方法的具体用法?Java EntityDamageSource.getEntity怎么用?Java EntityDamageSource.getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.EntityDamageSource
的用法示例。
在下文中一共展示了EntityDamageSource.getEntity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityDropLoot
import net.minecraft.util.EntityDamageSource; //导入方法依赖的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);
}
}
}
}
}
示例2: onLivingAttack
import net.minecraft.util.EntityDamageSource; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent evt) {
if (evt.getEntity() instanceof EntityPlayer && evt.getSource() instanceof EntityDamageSource) {
EntityDamageSource source = (EntityDamageSource) evt.getSource();
if (source.getEntity() instanceof EntityPlayer) {
EntityPlayer attacker = (EntityPlayer) source.getEntity();
EntityPlayer damagee = (EntityPlayer) evt.getEntity();
ItemStack attackerBoots = attacker.inventory.armorItemInSlot(0);
ItemStack damageeBoots = damagee.inventory.armorItemInSlot(0);
if (attackerBoots != null && damageeBoots != null && attackerBoots == damageeBoots) {
Item id = damageeBoots.getItem();
if (id == WarsItems.redBoots || id == WarsItems.greenBoots || id == WarsItems.blueBoots || id == WarsItems.yellowBoots) {
evt.setCanceled(true);
}
}
}
}
}
示例3: onEntityDeath
import net.minecraft.util.EntityDamageSource; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityDeath(LivingDeathEvent event) {
if(event.source instanceof EntityDamageSource) {
EntityDamageSource entitySource = (EntityDamageSource) event.source;
if(entitySource.getEntity() instanceof EntityPlayer) {
EntityPlayer killer = (EntityPlayer) entitySource.getEntity();
if(killer.inventory.getCurrentItem() != null) {
if(EnchantmentHelper.getEnchantments(killer.inventory.getCurrentItem()).containsKey(BPEnchantments.vorpal.effectId)) {
int level = EnchantmentHelper.getEnchantmentLevel(BPEnchantments.vorpal.effectId, killer.inventory.getCurrentItem());
if(level == 1) {
if(killer.worldObj.rand.nextInt(6) == 1) {
this.dropHeads(event);
}
} else if(level == 2) {
if(killer.worldObj.rand.nextInt(3) == 1) {
this.dropHeads(event);
}
}
}
}
}
}
}
示例4: onDeath
import net.minecraft.util.EntityDamageSource; //导入方法依赖的package包/类
@ForgeSubscribe
public void onDeath(LivingDeathEvent ev) {
if (!(ev.source instanceof EntityDamageSource)){
return;
}
EntityDamageSource eds = (EntityDamageSource)ev.source;
Entity ent = eds.getEntity();
if (!(ent instanceof EntityPlayer)) {
return;
}
EntityPlayer epl = (EntityPlayer)ent;
ItemStack wpn = epl.getHeldItem();
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 0)
{
return;
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 1){
if(ev.entityLiving instanceof EntityDragon){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 1, 0), 0.5F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 2){
if(ev.entityLiving instanceof EntityDragon){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 1, 0), 0.8F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 3){
if(ev.entityLiving instanceof EntityDragon){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 1, 0), 1.0F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 4){
if(ev.entityLiving instanceof EntityDragon){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 2, 0), 0.5F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 5){
if(ev.entityLiving instanceof EntityDragon){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 2, 0), 0.8F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 6){
if(ev.entityLiving instanceof EntityDragon){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 2, 0), 1.0F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 7){
if(ev.entityLiving instanceof EntityDragon){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 3, 0), 0.5F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 8){
if(ev.entityLiving instanceof EntityDragon){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 3, 0), 0.8F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 9){
if(ev.entityLiving instanceof EntityDragon){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 3, 0), 1.0F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 10){
if(ev.entityLiving instanceof EntityDragon){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts.itemID, 4, 0), 0.8F);
}
}
}
示例5: onDeath
import net.minecraft.util.EntityDamageSource; //导入方法依赖的package包/类
@ForgeSubscribe
public void onDeath(LivingDeathEvent ev) {
if (!(ev.source instanceof EntityDamageSource)){
return;
}
EntityDamageSource eds = (EntityDamageSource)ev.source;
Entity ent = eds.getEntity();
if (!(ent instanceof EntityPlayer)) {
return;
}
EntityPlayer epl = (EntityPlayer)ent;
ItemStack wpn = epl.getHeldItem();
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 0)
{
return;
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 1){
if(ev.entityLiving instanceof EntityVillager){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 1, 0), 0.5F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 2){
if(ev.entityLiving instanceof EntityVillager){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 1, 0), 0.8F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 3){
if(ev.entityLiving instanceof EntityVillager){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 1, 0), 1.0F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 4){
if(ev.entityLiving instanceof EntityVillager){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 2, 0), 0.5F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 5){
if(ev.entityLiving instanceof EntityVillager){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 2, 0), 0.8F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 6){
if(ev.entityLiving instanceof EntityVillager){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 2, 0), 1.0F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 7){
if(ev.entityLiving instanceof EntityVillager){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 3, 0), 0.5F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 8){
if(ev.entityLiving instanceof EntityVillager){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 3, 0), 0.8F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 9){
if(ev.entityLiving instanceof EntityVillager){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 3, 0), 1.0F);
}
}
if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 10){
if(ev.entityLiving instanceof EntityVillager){
ev.entityLiving.entityDropItem(new ItemStack(AddedItems.PureHeart.itemID, 4, 0), 0.8F);
}
}
}