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