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


Java PlayerInteractEvent.EntityInteractSpecific方法代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.player.PlayerInteractEvent.EntityInteractSpecific方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerInteractEvent.EntityInteractSpecific方法的具體用法?Java PlayerInteractEvent.EntityInteractSpecific怎麽用?Java PlayerInteractEvent.EntityInteractSpecific使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.event.entity.player.PlayerInteractEvent的用法示例。


在下文中一共展示了PlayerInteractEvent.EntityInteractSpecific方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onEntityInteractSpecific

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityInteractSpecific(PlayerInteractEvent.EntityInteractSpecific event) {
  if (armorStandSwap) {
    //added for https://www.twitch.tv/darkphan
    if (event.getWorld().isRemote) {
      return;
    } //server side only
    if (event.getTarget() == null || event.getTarget() instanceof EntityArmorStand == false) {
      return;
    }
    EntityArmorStand entityStand = (EntityArmorStand) event.getTarget();
    EntityPlayer player = event.getEntityPlayer();
    if (player.isSneaking() == false) {
      return;
    } //bc when not sneaking, we do the normal single item version
    event.setCanceled(true);//which means we need to now cancel that normal version and do our own
    for (EntityEquipmentSlot slot : armorStandEquipment) {
      ItemStack itemPlayer = player.getItemStackFromSlot(slot);
      ItemStack itemArmorstand = entityStand.getItemStackFromSlot(slot);
      player.setItemStackToSlot(slot, itemArmorstand);
      entityStand.setItemStackToSlot(slot, itemPlayer);
    }
  }
}
 
開發者ID:PrinceOfAmber,項目名稱:Cyclic,代碼行數:25,代碼來源:PlayerAbilitiesModule.java

示例2: onInteractEntitySpecific

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onInteractEntitySpecific(PlayerInteractEvent.EntityInteractSpecific event)
{
	if (event.getEntityPlayer() != null)
	{
		if (event.getEntityPlayer().isPotionActive(ExPPotions.stunned))
		{
			event.setCanceled(true);
		}
	}	
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:12,代碼來源:ExPHandlerServer.java

示例3: onShearEvent

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onShearEvent(PlayerInteractEvent.EntityInteractSpecific event)
{
    if(!InteractionBWM.HARDCORE_SHEARING)
        return;

    World world = event.getWorld();
    BlockPos pos = event.getEntity().getPosition();
    ItemStack tool = event.getItemStack();
    EntityPlayer player = event.getEntityPlayer();
    if(!world.isRemote && event.getTarget() instanceof EntitySheep && tool.getItem() instanceof ItemShears)
    {
        EntitySheep sheep = (EntitySheep) event.getTarget();
        if(!sheep.isShearable(tool,world,pos))
            return;
        java.util.Random rand = new java.util.Random();
        for(ItemStack stack : InteractionBWM.convertShearedWool(sheep.onSheared(tool,world,pos, EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE,tool))))
        {
            EntityItem ent = sheep.entityDropItem(stack, 1.0F);
            ent.motionY += rand.nextFloat() * 0.05F;
            ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
            ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
        }
        tool.damageItem(1, player);
        event.setCanceled(true);
        event.setCancellationResult(EnumActionResult.SUCCESS);
    }
}
 
開發者ID:DaedalusGame,項目名稱:BetterWithAddons,代碼行數:29,代碼來源:HardcoreWoolHandler.java


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