本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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);
}
}