本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingAttackEvent.getEntityLiving方法的典型用法代码示例。如果您正苦于以下问题:Java LivingAttackEvent.getEntityLiving方法的具体用法?Java LivingAttackEvent.getEntityLiving怎么用?Java LivingAttackEvent.getEntityLiving使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.living.LivingAttackEvent
的用法示例。
在下文中一共展示了LivingAttackEvent.getEntityLiving方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLivingAttack
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onLivingAttack(LivingAttackEvent event)
{
/*
* Player attacks a monster OR another player
*/
if (event.getSource().getTrueSource() instanceof EntityPlayer && !event.getSource().getTrueSource().getEntityWorld().isRemote)
{
EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
EntityLivingBase enemy = event.getEntityLiving();
ItemStack stack = player.inventory.getCurrentItem();
PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
if (playerInfo != null && stack != null && stack.getItem() instanceof ItemSword && !(stack.getItem() instanceof ItemLEAdvancedMelee))
{
NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
if (playerInfo.getPlayerLevel() >= nbt.getInteger("Level"))
{
useWeaponAttributes(event.getAmount(), player, enemy, stack, nbt);
}
}
}
}
示例2: onLivingAttackCallback
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.BOTTOM)
public void onLivingAttackCallback(LivingAttackEvent event) {
if (Always.isServer()) {
EntityLivingBase living = event.getEntityLiving(), attacker = event.getSource().getTrueSource() instanceof EntityLivingBase ?
(EntityLivingBase) event.getSource().getTrueSource() : null;
if (isEquipmented(living) && !(living instanceof EntityPlayer && ((EntityPlayer) living).isCreative())) {
living.getCombatTracker().lastDamageTime = living.ticksExisted;
if (living instanceof EntityPlayerMP && !(living instanceof FakePlayer))
AlchemyNetworkHandler.network_wrapper.sendTo(new MessageGuardCallback(-1), (EntityPlayerMP) living);
}
if (attacker != null && isEquipmented(attacker)) {
attacker.setLastAttackedEntity(living);
if (living instanceof EntityPlayerMP && !(living instanceof FakePlayer))
AlchemyNetworkHandler.network_wrapper.sendTo(new MessageGuardCallback(living.getEntityId()), (EntityPlayerMP) attacker);
}
}
}
示例3: attackEvent
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void attackEvent (LivingAttackEvent e) {
if (e.getEntityLiving().getActiveItemStack() == null)
return;
final ItemStack stack = e.getEntityLiving().getActiveItemStack();
if (stack.getItem() instanceof ItemCustomShield && e.getAmount() > 0.0f) {
final int i = 1 + MathHelper.floor(e.getAmount());
stack.damageItem(i, e.getEntityLiving());
if (stack.stackSize <= 0) {
final EnumHand enumhand = e.getEntityLiving().getActiveHand();
if (e.getEntityLiving() instanceof EntityPlayer)
ForgeEventFactory.onPlayerDestroyItem((EntityPlayer) e.getEntityLiving(), stack, enumhand);
e.getEntityLiving().setItemStackToSlot(enumhand == EnumHand.MAIN_HAND ? EntityEquipmentSlot.MAINHAND : EntityEquipmentSlot.OFFHAND, null);
if (e.getEntityLiving().getEntityWorld().isRemote)
e.getEntityLiving().playSound(SoundEvents.BLOCK_ANVIL_BREAK, 0.8F, 0.8F + e.getEntityLiving().getEntityWorld().rand.nextFloat() * 0.4F);
}
}
}
示例4: autoShield
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void autoShield(LivingAttackEvent event) {
if (!(event.getEntityLiving() instanceof EntityPlayer)) return;
if (!(event.getSource().getSourceOfDamage() instanceof EntityArrow)) return;
ItemStack shield = ((EntityPlayer)event.getEntityLiving()).getHeldItemOffhand();
ItemStack emblem = BaublesApi.getBaublesHandler((EntityPlayer)event.getEntityLiving()).getStackInSlot(6);
if (shield == null || emblem == null) return;
if (emblem.getItem() != this || !(shield.getItem() instanceof ItemShield)) return;
shield.attemptDamageItem(1, event.getEntityLiving().worldObj.rand);
event.setCanceled(true);
}
示例5: onLivingAttack
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent e)
{
EntityLivingBase attacked = e.getEntityLiving();
EntityLivingBase attacker = attacked.getAttackingEntity();
if(attacker == null) return;
damageShield(attacked, attacker, e.getAmount());
doAxeStuff(attacked, attacker);
}
示例6: onShieldedAttack
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
/** Damage the advanced shield correctly, as vanilla code only works for the vanilla shield */
@SubscribeEvent
public void onShieldedAttack(LivingAttackEvent e) {
EntityLivingBase guy = e.getEntityLiving();
if(!guy.world.isRemote && guy instanceof EntityPlayer) {
if(e.getAmount() > 0.0F && !guy.getActiveItemStack().isEmpty() && guy.getActiveItemStack().getItem() instanceof ItemShieldAdvanced) {
if(this.canBlockDamageSource((EntityPlayer)guy, e.getSource())) {
this.damageShield((EntityPlayer)guy, e.getAmount());
}
}
}
}
示例7: onAttack
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttack(LivingAttackEvent event) {
if (event.getEntityLiving() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
PossessivePlayer possessivePlayer = PossessHandler.get(player);
if (possessivePlayer != null) {
if (event.getSource().isFireDamage()) {
event.setCanceled(true);
} else {
possessivePlayer.getPossessing().attackEntityFrom(event.getSource(), event.getAmount());
event.setCanceled(true);
if (!player.capabilities.isCreativeMode && !event.getSource().canHarmInCreative() && possessivePlayer.getPossessing().hurtTime <= 0) {
this.playPossessedHurtAnimation(player);
}
}
}
} else {
EntityPlayer possessor = PossessHandler.getPossesor(event.getEntityLiving());
if (possessor != null) {
if (possessor.capabilities.isCreativeMode && !event.getSource().canHarmInCreative()) {
event.setCanceled(true);
} else if (possessor.hurtTime <= 0) {
this.playPossessedHurtAnimation(possessor);
}
}
}
}
示例8: livingAttacked
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void livingAttacked(LivingAttackEvent event) {
if (!event.getEntityLiving().world.isRemote) {
if (!event.isCanceled() && event.getAmount() > 0) {
EntityLivingBase living = event.getEntityLiving();
if (living.isPotionActive(ModPotions.cannonball) && (event.getSource().isExplosion() || event.getSource() == DamageSource.FALL)) {
if (event.getSource() == DamageSource.FALL) //No you don't get to have superbuffs that make you immune to creepers and falldamage.
living.removePotionEffect(ModPotions.cannonball);
event.setCanceled(true);
}
}
}
}
示例9: onPlayerDamaged
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerDamaged(LivingAttackEvent event){
event.getEntityLiving().getEntityWorld();
EntityLivingBase attacked = event.getEntityLiving();
DamageSource source = event.getSource();
int pureCount = getArmorCount(attacked, "pure");
if(getArmorCount(attacked, "red") == 4 || pureCount == 4){
if(source == DamageSource.HOT_FLOOR){
event.setCanceled(true);
}
}
if(getArmorCount(attacked, "dark") == 4 || pureCount == 4){
if(source.getSourceOfDamage() !=null){
Entity toAttack = source.getSourceOfDamage();
toAttack.attackEntityFrom(DamageSource.causeThornsDamage(attacked), EnchantmentThorns.getDamage(5, EntityUtil.rand));
if(toAttack instanceof EntityLivingBase){
EntityLivingBase living = (EntityLivingBase)toAttack;
if(EntityUtil.rand.nextInt(10) == 0){
living.addPotionEffect(new PotionEffect(MobEffects.WITHER, MathHelper.getInt(EntityUtil.rand, 20*3, 20*6), 0));
}
}
}
}
/*if(source == DamageSource.FALL){
BlockPos pos = new BlockPos(attacked).down();
IBlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockLiquid && attacked.posY > pos.getY() + 0.9 && !(world.getBlockState(pos.up()).getBlock().getMaterial(world.getBlockState(pos.up())) == Material.WATER))
{
if(UpgradeItemRecipe.isWaterWalking(attacked.getItemStackFromSlot(EntityEquipmentSlot.FEET))){
world.playSound(null, pos, SoundEvents.ENTITY_PLAYER_SPLASH, SoundCategory.PLAYERS, 1.0F, 1.0F);
event.setCanceled(true);
}
}
}*/
}
示例10: onAttacked
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttacked(LivingAttackEvent event) {
if(event.getSource() != null) {
Entity attacker = event.getSource().getEntity();
if(attacker != null && attacker instanceof EntityMinionWarrior && attacker.getRidingEntity() == event.getEntityLiving())
event.setCanceled(true);
}
}
示例11: onLivingAttack
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent event)
{
if (event.getEntityLiving() instanceof EntityPlayer)
{
PlayerAether playerAether = PlayerAether.get((EntityPlayer) event.getEntityLiving());
if (playerAether != null)
{
event.setCanceled(playerAether.onPlayerAttacked(event.getSource()));
}
}
}
示例12: onLivingAttack
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGH)
public void onLivingAttack(LivingAttackEvent event) {
if (Always.isServer() && isEquipmented(event.getEntityLiving()) && isCDOver(event.getEntityLiving())) {
AlchemyEventSystem.markEventCanceled(event);
EntityLivingBase source = event.getSource().getTrueSource() instanceof EntityLivingBase ? (EntityLivingBase) event.getSource().getTrueSource() : null;
if (source != null)
source.attackEntityFrom(AlchemyDamageSourceLoader.dead_magic, event.getAmount());
EntityLivingBase living = event.getEntityLiving();
living.getCombatTracker().lastDamageTime = living.ticksExisted;
if (living instanceof EntityPlayerMP && !(living instanceof FakePlayer))
AlchemyNetworkHandler.network_wrapper.sendTo(new MessageGuardCallback(-1), (EntityPlayerMP) living);
}
}
示例13: onDamageRender
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onDamageRender(LivingAttackEvent e) {
if (e.getEntityLiving() instanceof EntityPlayer) {
if (e.getSource() == DamageSource.MAGIC) {
e.setCanceled(false);
return;
}
}
}
示例14: onEvent2
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent2(LivingAttackEvent event) {
if (event.getEntityLiving() instanceof EntityPlayerMP && event.getSource().getImmediateSource() instanceof EntityLiving) {
if (getPlayerSettings((EntityPlayerMP) event.getEntityLiving()).disableAttacks.contains(event.getSource().getImmediateSource().getClass())) {
((EntityLiving) event.getSource().getImmediateSource()).setAttackTarget(null);
((EntityLiving) event.getSource().getImmediateSource()).setRevengeTarget(null);
event.setCanceled(true);
}
}
}
示例15: livingAttack
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void livingAttack(LivingAttackEvent event) {
if (!(event.getEntityLiving() instanceof EntityPlayer)) return;
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
if (!player.capabilities.isCreativeMode) return;
PacketCreateTipEntity packet = new PacketCreateTipEntity(player);
ImmortalObjectTip.instance.network.sendToDimension(packet, packet.dim);
}