本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingEntityUseItemEvent.Start方法的典型用法代码示例。如果您正苦于以下问题:Java LivingEntityUseItemEvent.Start方法的具体用法?Java LivingEntityUseItemEvent.Start怎么用?Java LivingEntityUseItemEvent.Start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.living.LivingEntityUseItemEvent
的用法示例。
在下文中一共展示了LivingEntityUseItemEvent.Start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: eatApple
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void eatApple(LivingEntityUseItemEvent.Start event) {
if (event.getItem().getItem() != Items.GOLDEN_APPLE || !(event.getEntityLiving() instanceof EntityPlayer)) {
return;
}
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
if (ConfigHandler.antiCheatMode && event.getItem().getItemDamage() == 1) {
player.sendMessage(new TextComponentTranslation("message.uhcreloaded.apple.enchanted"));
event.setCanceled(true);
return;
}
if (!event.getItem().hasTagCompound()) {
return;
}
NBTTagCompound tag = event.getItem().getTagCompound();
if (tag.getBoolean("golden_skull")) {
player.addPotionEffect(new PotionEffect(
MobEffects.HEALTH_BOOST, 1, ConfigHandler.healAmountSkull - 4
));
}
}
示例2: startUse
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void startUse(LivingEntityUseItemEvent.Start 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(32);
}
}
}
示例3: onBowStartDraw
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOW)
public void onBowStartDraw(LivingEntityUseItemEvent.Start use){
if(use.getDuration() > 1 && BattlegearUtils.isBow(use.getItem().getItem())){
int lvl = mods.battlegear2.api.EnchantmentHelper.getEnchantmentLevel(BaseEnchantment.bowCharge, use.getItem());
if(lvl > 0){
use.setDuration(use.getDuration()- lvl*20000);
if(use.getDuration() <=0){
use.setDuration(1);
}
}
}
}
示例4: onLivingEntityUseItemEventStart
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.NORMAL)
public void onLivingEntityUseItemEventStart(LivingEntityUseItemEvent.Start event){
// System.out.println("Item: " + event.getItem().getUnlocalizedName());
the_item = event.getItem().getUnlocalizedName();
}
示例5: onItemUseStart
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; //导入方法依赖的package包/类
public static int onItemUseStart(EntityLivingBase entity, ItemStack item, int duration)
{
LivingEntityUseItemEvent event = new LivingEntityUseItemEvent.Start(entity, item, duration);
return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getDuration();
}
示例6: onItemUse
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemUse(LivingEntityUseItemEvent.Start event)
{
stopItemUse(event);
}