本文整理汇总了Java中net.minecraftforge.event.entity.player.AttackEntityEvent.getEntityPlayer方法的典型用法代码示例。如果您正苦于以下问题:Java AttackEntityEvent.getEntityPlayer方法的具体用法?Java AttackEntityEvent.getEntityPlayer怎么用?Java AttackEntityEvent.getEntityPlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.player.AttackEntityEvent
的用法示例。
在下文中一共展示了AttackEntityEvent.getEntityPlayer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onWitherBoneAttackEvent
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onWitherBoneAttackEvent(AttackEntityEvent event) {
EntityPlayer player = event.getEntityPlayer();
ItemStack stack = player.getHeldItemMainhand();
boolean flag = false;
if (stack.getItem() instanceof IHaftTool) {
if (IHaftTool.getHaftMat(stack) == ModMaterials.HAFT_WITHER_BONE) {
flag = true;
}
}
if (flag) {
if (player.dimension != DimensionType.NETHER.getId()) {
stack.damageItem(7, player);
}
}
}
示例2: onAttackEntity
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttackEntity(AttackEntityEvent event) {
if (event.getTarget() instanceof EntityLivingBase == false) {
return;
}
EntityLivingBase target = (EntityLivingBase) event.getTarget();
EntityPlayer attacker = event.getEntityPlayer();
ItemStack main = attacker.getHeldItemMainhand();
ItemStack off = attacker.getHeldItemOffhand();
int mainLevel = -1, offLevel = -1;
if (main != null && EnchantmentHelper.getEnchantments(main).containsKey(this)) {
mainLevel = EnchantmentHelper.getEnchantments(main).get(this);
}
if (off != null && EnchantmentHelper.getEnchantments(off).containsKey(this)) {
offLevel = EnchantmentHelper.getEnchantments(off).get(this);
}
int level = Math.max(mainLevel, offLevel);
if (level > 0) {
// we -1 since potion level 1 is Poison II
//so that means enchantment I giving poison I means this
UtilEntity.addOrMergePotionEffect(target, new PotionEffect(MobEffects.POISON, durationTicksPerLevel * level, level - 1));
}
}
示例3: onAttack
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onAttack(AttackEntityEvent event) {
EntityPlayer player = event.getEntityPlayer();
if (player != null && player.getHealth() <= 0f) {
// if(ModConfig.allowUnarmedMelee && player.getHeldItemMainhand().isEmpty()) {
// return;
// }
event.setCanceled(true);
}
}
示例4: onAttackEntity
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttackEntity(AttackEntityEvent event) {
if (event.getTarget() instanceof EntityLivingBase) {
EntityLivingBase target = (EntityLivingBase) event.getTarget();
EntityPlayer player = event.getEntityPlayer();
if (this.isActive(player)) {
PossessivePlayer possessivePlayer = PossessHandler.get(player);
EntityZombie possessing = (EntityZombie) possessivePlayer.getPossessing();
if (possessing.getZombieType() == ZombieType.HUSK) {
target.addPotionEffect(new PotionEffect(MobEffects.HUNGER, 140));
}
}
}
}
示例5: onAttackEntity
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttackEntity(AttackEntityEvent event) {
if (event.getTarget() instanceof EntityLivingBase) {
EntityLivingBase target = (EntityLivingBase) event.getTarget();
EntityPlayer player = event.getEntityPlayer();
if (this.isActive(player)) {
PossessivePlayer possessivePlayer = PossessHandler.get(player);
EntitySkeleton possessing = (EntitySkeleton) possessivePlayer.getPossessing();
if (possessing.getSkeletonType() == SkeletonType.WITHER) {
target.addPotionEffect(new PotionEffect(MobEffects.WITHER, 100, 1));
}
}
}
}
示例6: onAttack
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
@SuppressWarnings("BooleanVariableAlwaysNegated")
@SubscribeEvent(priority = EventPriority.HIGH)
public void onAttack(AttackEntityEvent event)
{
//Process for chiseling a sheep
final Entity sheep = event.getTarget();
if (sheep == null) return;
final EntityPlayer entityPlayer = event.getEntityPlayer();
ItemStack activeStack = entityPlayer.inventory.getCurrentItem();
boolean attackedWithChisel = false;
if (activeStack != null && ChiselLibrary.isChisel(activeStack.getItem()))
{
attackedWithChisel = true;
} else
{
activeStack = entityPlayer.inventory.offHandInventory[0];
if (activeStack != null && ChiselLibrary.isChisel(activeStack.getItem()))
{
attackedWithChisel = true;
}
}
if (!attackedWithChisel)
{
return;
}
if (!sheep.hasCapability(Capability.CHISELED_SHEEP, null)) {
return;
}
event.setCanceled(true);
Chiseling.chiselSheep(sheep, entityPlayer, activeStack);
}
示例7: onPlayerAttack
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
/**
* Event listener for Action.ATTACK
*/
@SubscribeEvent
public void onPlayerAttack(AttackEntityEvent event)
{
EntityPlayer player = event.getEntityPlayer();
List<Action> events = CommonProxy.manager.getActions(player);
if (!player.worldObj.isRemote && events != null && !Blockbuster.proxy.config.record_attack_on_swipe)
{
events.add(new AttackAction());
}
}
示例8: onAttackEntity
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttackEntity(AttackEntityEvent event) {
if (event.getTarget() instanceof EntityLivingBase == false) {
return;
}
// EntityLivingBase target = (EntityLivingBase) event.getTarget();
EntityPlayer attacker = event.getEntityPlayer();
int level = getCurrentLevelTool(attacker);
if (level > 0 && attacker.getHealth() < attacker.getMaxHealth()) {
UtilParticle.spawnParticle(attacker.getEntityWorld(), EnumParticleTypes.HEART, attacker.getPosition().up(2));
attacker.heal(level);
}
}