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


Java LivingEntityUseItemEvent.Tick方法代码示例

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


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

示例1: onItemUseFinish

import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemUseFinish(LivingEntityUseItemEvent.Tick event)
{
	if (event.getEntity() instanceof EntityPlayer && !event.getEntity().world.isRemote)
	{
		int useCurrent = event.getDuration();
		if (useCurrent == 1)
		{
			IExPPlayer data = IExPPlayer.of((EntityPlayer) event.getEntity());
			if (data != null)
			{
				PlayerManager.handlePlayerEatenFood((EntityPlayer) event.getEntity(), data, event.getItem());
			}
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:17,代码来源:ExPHandlerServer.java

示例2: decreaseBowUseDuration

import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void decreaseBowUseDuration(LivingEntityUseItemEvent.Tick event) {
	if (event.getItem() == null) {
		return;
	}

	if (event.getItem().getItem() != Items.BOW) {
		return;
	}

	int level = EnchantmentHelper.getEnchantmentLevel(CodingPiratesMod.haste,
			event.getItem());

	switch (level) {
	case 1:
		event.setDuration(event.getDuration() - 1);
		break;
	case 2:
		event.setDuration(event.getDuration() - 2);
		break;
	default:
		break;
	}
}
 
开发者ID:jarryDk,项目名称:MineCraft,代码行数:25,代码来源:EnchantmentArrowFast.java

示例3: onActiveItemUseTick

import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onActiveItemUseTick(LivingEntityUseItemEvent.Tick event) {
    ItemStack stack = event.getItem();
    if (stack.getItem() == TrumpetSkeletonItems.TRUMPET) {
        if (event.getDuration() == stack.getMaxItemUseDuration() - 10) {
            EntityLivingBase user = event.getEntityLiving();
            World world = user.world;

            user.playSound(TrumpetSkeletonSoundEvents.ITEM_TRUMPET_USE, 1.0F, 0.9F + world.rand.nextFloat() * 0.2F);
            if (!world.isRemote) {
                List<EntityLivingBase> spookedEntities = world.getEntitiesWithinAABB(EntityLivingBase.class, user.getEntityBoundingBox().grow(10.0D));
                for (EntityLivingBase spookedEntity : spookedEntities) {
                    if (spookedEntity == user) continue;
                    double deltaX = user.posX - spookedEntity.posX;
                    double deltaZ = user.posZ - spookedEntity.posZ;
                    double distance = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
                    if (distance > 0.25D) {
                        spookedEntity.knockBack(user, 0.5F, deltaX / distance, deltaZ / distance);
                    }
                    spookedEntity.setRevengeTarget(user);
                }
                stack.damageItem(1, user);
            }
        } else if (event.getDuration() <= stack.getMaxItemUseDuration() - 15) {
            event.setCanceled(true);
        }
    }
}
 
开发者ID:JamiesWhiteShirt,项目名称:trumpet-skeleton,代码行数:29,代码来源:TrumpetSkeleton.java

示例4: monitorUse

import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void monitorUse(LivingEntityUseItemEvent.Tick event){
	EntityLivingBase entity = event.getEntityLiving();
	ItemStack stack = event.getItem();
	
	if(!entity.isInsideOfMaterial(Material.WATER)){
		if(ItemStackTools.isValid(stack) && stack.getItem() == Items.GLASS_BOTTLE){
			event.setDuration(-1);
			event.setCanceled(true);
		}
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:13,代码来源:EventHandler.java

示例5: onItemUse

import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemUse (LivingEntityUseItemEvent.Tick event) {

    // Gluttony Charm
    if (event.getEntityLiving() instanceof EntityPlayer && itemGluttonyCharm.hasItem((EntityPlayer) event.getEntityLiving()) && !event.getItem().isEmpty() && event.getItem().getItem() instanceof ItemFood) {
        event.setDuration(0);
    }
}
 
开发者ID:Darkhax-Minecraft,项目名称:Dark-Utilities,代码行数:9,代码来源:FeatureCharms.java

示例6: onItemUseTick

import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; //导入方法依赖的package包/类
public static int onItemUseTick(EntityLivingBase entity, ItemStack item, int duration)
{
    LivingEntityUseItemEvent event = new LivingEntityUseItemEvent.Tick(entity, item, duration);
    return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getDuration();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:6,代码来源:ForgeEventFactory.java

示例7: onItemUse

import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemUse(LivingEntityUseItemEvent.Tick event)
{
	stopItemUse(event);
}
 
开发者ID:murapix,项目名称:Inhuman-Resources,代码行数:6,代码来源:PotionRedstoneNeedle.java


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