当前位置: 首页>>代码示例>>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;未经允许,请勿转载。