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


Java PlayerDropsEvent.getEntityPlayer方法代码示例

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


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

示例1: addPlayerHeads

import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入方法依赖的package包/类
public void addPlayerHeads(PlayerDropsEvent event){
EntityPlayer player = event.getEntityPlayer();
DamageSource source = event.getSource();
Entity attacker = source.getSourceOfDamage();
   	if(Config.playerHeadType == ItemDropType.NONE)return;
   	if(player == null || player.getEntityWorld() == null)return;
   
   	int rand = player.getEntityWorld().rand.nextInt(Math.max(Config.playerHeadDropChance / fixLooting(event.getLootingLevel()), 1));
   
   	if(Config.playerHeadDropChance < 0 || rand !=0)
   		return;
   	if(Config.playerHeadType == ItemDropType.KILLED){
   		if(attacker == null || !(attacker instanceof EntityPlayer) || attacker instanceof FakePlayer)
   			return;
   	}
   	ItemStack skull = PlayerUtil.createPlayerHead(player);
   	event.getDrops().add(ItemUtil.dropFromPlayer(player, skull, true));
  }
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:19,代码来源:EventHandler.java

示例2: onPlayerDeath

import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent event)
{
	EntityPlayer player = event.getEntityPlayer();
	Item item;
	
	for (int i = 0; i < event.getDrops().size(); i++)
	{
		item = event.getDrops().get(i).getEntityItem().getItem();
		
		if (item != null && (item instanceof ItemSword || item instanceof ItemShield || item instanceof ItemArmor || item instanceof ItemBow))
		{
			ItemStack stack = event.getDrops().get(i).getEntityItem();
			NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
			
			if (nbt != null)
			{
				if (WeaponAttribute.SOUL_BOUND.hasAttribute(nbt) || ArmorAttribute.SOUL_BOUND.hasAttribute(nbt) || BowAttribute.SOUL_BOUND.hasAttribute(nbt) || ShieldAttribute.SOUL_BOUND.hasAttribute(nbt))
				{
					event.getDrops().remove(i);
					player.inventory.addItemStackToInventory(stack);
				}
			}
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Levels,代码行数:27,代码来源:EventSoulBound.java

示例3: onPlayerDeath

import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerDeath(PlayerDropsEvent evt) {
    if (evt.getEntityPlayer() == null || evt.getEntityPlayer() instanceof FakePlayer || evt.isCanceled()) {
        return;
    }
    if(evt.getEntityPlayer().world.getGameRules().getBoolean("keepInventory")) {
        return;
    }

    ListIterator<EntityItem> iter = evt.getDrops().listIterator();
    while (iter.hasNext()) {
        EntityItem ei = iter.next();
        ItemStack item = ei.getEntityItem();
        if(isSoulBound(item)) {
            if (addToPlayerInventory(evt.getEntityPlayer(), item)) {
                Bagginses.analytics.eventDesign("playerDied:Soulbound", Bagginses.analytics.userPrefix());
                iter.remove();
            }
        }
    }

}
 
开发者ID:lorddusk,项目名称:Bagginses,代码行数:23,代码来源:SoulBoundEventHandler.java

示例4: onPlayerDeathLate

import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerDeathLate(PlayerDropsEvent evt) {
  if (evt.getEntityPlayer() == null || evt.getEntityPlayer() instanceof FakePlayer || evt.isCanceled()) {
    return;
  }
  if (evt.getEntityPlayer().world.getGameRules().getBoolean("keepInventory")) {
    return;
  }

  Log.debug("Running onPlayerDeathLate logic for " + evt.getEntityPlayer().getName());

  ListIterator<EntityItem> iter = evt.getDrops().listIterator();
  while (iter.hasNext()) {
    EntityItem ei = iter.next();
    ItemStack item = ei.getEntityItem();
    if (isSoulBound(item)) {
      if (addToPlayerInventory(evt.getEntityPlayer(), item)) {
        iter.remove();
      }
    }
  }

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

示例5: onPlayerDeath

import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent e)
{
    EntityPlayer player = e.getEntityPlayer();
    int x = (int) player.posX;
    int y = (int) player.posY;
    int z = (int) player.posZ;
    int dim = player.dimension;
    player.addChatComponentMessage(new TextComponentTranslation("message.littlethings.deathCoords", x, y, z));
    player.addChatComponentMessage(ITextComponent.Serializer.jsonToComponent(I18n.translateToLocal("message.littlethings.deathLinks")
            .replaceAll("%w%", String.valueOf(dim))
            .replaceAll("%x%", String.valueOf(x))
            .replaceAll("%y%", String.valueOf(y))
            .replaceAll("%z%", String.valueOf(z))));
}
 
开发者ID:GamingsModding,项目名称:LittleThings-old,代码行数:16,代码来源:DisplayDeathCoords.java

示例6: onPlayerDrops

import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerDrops(PlayerDropsEvent event) {
	EntityPlayer player = event.getEntityPlayer();
	if (!player.world.getGameRules().getBoolean("keepInventory")) {
		IInventory inventory = player.getCapability(AlchemyCapabilityLoader.bauble, null);
		if (inventory != null)
			for (int i = 0, len = inventory.getSizeInventory(); i < len; i++) {
				ItemStack item = inventory.removeStackFromSlot(i);
				if (!item.isEmpty())
					event.getDrops().add(InventoryHelper.getEntityItem(player, item));
			}
	}
}
 
开发者ID:NekoCaffeine,项目名称:Alchemy,代码行数:14,代码来源:CapabilityBauble.java

示例7: playerDrops

import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入方法依赖的package包/类
/** Adds yoke and backpack to player death drops. */
@SubscribeEvent
public void playerDrops(PlayerDropsEvent event) {
    
    EntityPlayer player = event.getEntityPlayer();
    ICapPlayer capPlayer = player.getCapability(GeoCaps.CAP_PLAYER, null);
    World world = player.world;
    double x = player.posX;
    double y = player.posY;
    double z = player.posZ;
    List<EntityItem> drops = event.getDrops();
    drops.add(new EntityItem(world, x, y, z, capPlayer.removeBackpack()));
    drops.add(new EntityItem(world, x, y, z, capPlayer.removeYoke()));
}
 
开发者ID:JayAvery,项目名称:geomastery,代码行数:15,代码来源:PlayerEvents.java

示例8: PlayerDropsEvent

import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void PlayerDropsEvent(PlayerDropsEvent event) {
	if (event.getSource().getSourceOfDamage()!=null) {
		if (event.getSource().getSourceOfDamage() instanceof EntityPlayer) {
			//drop essence
			if (RecallItems.dropEssence) {
				EntityPlayer deadPlayer = event.getEntityPlayer();
				ItemPlayerEssence essence = RecallItems.itemPlayerEssence;
				ItemStack essenceStack = new ItemStack(essence);
				essence.setPlayer(essenceStack, deadPlayer);
				event.getEntity().entityDropItem(essenceStack, 0.5F);
			}
		}
	}
}
 
开发者ID:Vanhal,项目名称:Recall-Stones,代码行数:16,代码来源:EventsRecall.java

示例9: onPlayerDrops

import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
public void onPlayerDrops(PlayerDropsEvent event) {
	World world = event.getEntityPlayer().world;
	if (world.isRemote) return;

	if (Config.debugGraves) dumpDebugInfo(event);

	final EntityPlayer player = event.getEntityPlayer();

	if (OpenBlocks.Blocks.grave == null) {
		Log.log(debugLevel(), "OpenBlocks graves disabled, not placing (player '%s')", player);
		return;
	}

	if (player instanceof FakePlayer) {
		Log.debug("'%s' (%s) is a fake player, grave will not be spawned", player, player.getClass());
		return;
	}

	if (event.isCanceled()) {
		Log.warn("Event for player '%s' cancelled, grave will not be spawned", player);
		return;
	}

	final List<EntityItem> drops = event.getDrops();
	if (drops.isEmpty()) {
		Log.log(debugLevel(), "No drops from player '%s', grave will not be spawned'", player);
		return;
	}

	final GameRules gameRules = world.getGameRules();
	if (gameRules.getBoolean("keepInventory") ||
			!gameRules.getBoolean(GameRule.SPAWN_GRAVES)) {
		Log.log(debugLevel(), "Graves disabled by gamerule (player '%s')", player);
		return;
	}

	final GraveDropsEvent dropsEvent = new GraveDropsEvent(player);
	for (EntityItem drop : drops)
		dropsEvent.addItem(drop);

	if (MinecraftForge.EVENT_BUS.post(dropsEvent)) {
		Log.warn("Grave drops event for player '%s' cancelled, grave will not be spawned'", player);
		return;
	}

	final List<EntityItem> graveLoot = Lists.newArrayList();
	drops.clear(); // will be rebuilt based from event

	for (GraveDropsEvent.ItemAction entry : dropsEvent.drops) {
		switch (entry.action) {
			case DELETE:
				if (Config.debugGraves) Log.info("Item %s is going to be deleted", entry.item);
				break;
			case DROP:
				if (Config.debugGraves) Log.info("Item %s is going to be dropped", entry.item);
				drops.add(entry.item);
				break;
			default:
			case STORE:
				graveLoot.add(entry.item);
		}
	}

	if (graveLoot.isEmpty()) {
		Log.log(debugLevel(), "No grave drops left for player '%s' after event filtering, grave will not be spawned'", player);
		return;
	}

	if (!tryConsumeGrave(player, Iterables.concat(graveLoot, drops))) {
		Log.log(debugLevel(), "No grave in drops for player '%s' after firing event, grave will not be spawned'", player);
		drops.addAll(graveLoot); // re-add any loot that would have gone to grave
		return;
	}

	Log.log(debugLevel(), "Scheduling grave placement for player '%s':'%s' with %d item(s) stored and %d item(s) dropped",
			player, player.getGameProfile(), graveLoot.size(), drops.size());

	DelayedActionTickHandler.INSTANCE.addTickCallback(world, new GraveCallable(world, player, graveLoot));
}
 
开发者ID:OpenMods,项目名称:OpenBlocks,代码行数:81,代码来源:PlayerDeathHandler.java


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