本文整理匯總了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);
}
}