本文整理汇总了Java中net.minecraftforge.event.entity.player.AttackEntityEvent类的典型用法代码示例。如果您正苦于以下问题:Java AttackEntityEvent类的具体用法?Java AttackEntityEvent怎么用?Java AttackEntityEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttackEntityEvent类属于net.minecraftforge.event.entity.player包,在下文中一共展示了AttackEntityEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
}
开发者ID:the-realest-stu,项目名称:Adventurers-Toolbox,代码行数:21,代码来源:SpecialToolAbilityHandler.java
示例2: playerTick
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入依赖的package包/类
@SubscribeEvent
public void playerTick(AttackEntityEvent attackEvent)
{
Entity target = attackEvent.getTarget();
EntityLivingBase attacker = attackEvent.getEntityLiving();
if(attacker == null || target == null)
return;
World world = attacker.getEntityWorld();
BlockPos pos = EntityUtil.getEntityFloor(target,2);
if(!world.isRemote)
{
IBlockState state = world.getBlockState(pos);
if(isChopBlock(state) && isSuitableWeapon(attacker.getHeldItemMainhand()))
{
attacker.addPotionEffect(new PotionEffect(MobEffects.STRENGTH,200));
attacker.addPotionEffect(new PotionEffect(MobEffects.HUNGER,200));
splatter(world,pos,1);
}
}
}
开发者ID:DaedalusGame,项目名称:BetterWithAddons,代码行数:22,代码来源:ButcherHandler.java
示例3: onAttack
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入依赖的package包/类
@SubscribeEvent
public void onAttack(AttackEntityEvent event) {
if (!event.getEntityLiving().getHeldItemMainhand().isEmpty()) {
if (disabledItems.contains(event.getEntityLiving().getHeldItemMainhand().getItem())) {
event.setCanceled(true);
if (event.getTarget().canBeAttackedWithItem()) {
if (!event.getTarget().hitByEntity(event.getEntity())) {
event.getEntityPlayer().setLastAttackedEntity(event.getTarget());
event.getEntityPlayer().world.playSound((EntityPlayer) null, event.getEntityPlayer().posX, event.getEntityPlayer().posY, event.getEntityPlayer().posZ, SoundEvents.ENTITY_PLAYER_ATTACK_WEAK, event.getEntityPlayer().getSoundCategory(), 1.0F, 1.0F);
event.getTarget().attackEntityFrom(DamageSource.causePlayerDamage(event.getEntityPlayer()), event.getEntityPlayer().getCooledAttackStrength(1F));
event.getEntityPlayer().addExhaustion(0.1F);
}
}
}
}
}
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:17,代码来源:EventHandler.java
示例4: onAttackEntity
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入依赖的package包/类
@SubscribeEvent
public void onAttackEntity(AttackEntityEvent ev)
{
if (!ev.getTarget().isImmuneToFire() && !ev.getTarget().world.isRemote)
{
ItemStack stack = ev.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND);
if (stack.getCount() > 0 && stack.getItem() instanceof ItemBlock)
{
ItemBlock b = (ItemBlock) stack.getItem();
Block bl = b.getBlock();
if (bl == Blocks.TORCH)
{
ev.getTarget().setFire(2);
if (rnd.nextFloat() > 0.25)
{
stack.grow(-1);
if (stack.getCount() <= 0)
{
ev.getEntityPlayer().inventory.setInventorySlotContents(ev.getEntityPlayer().inventory.currentItem, ItemStack.EMPTY);
}
}
}
}
}
}
开发者ID:gigaherz,项目名称:Survivalist,代码行数:26,代码来源:TorchFireEventHandling.java
示例5: 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));
}
}
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:24,代码来源:EnchantVenom.java
示例6: onAttack
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入依赖的package包/类
@SubscribeEvent
public void onAttack(AttackEntityEvent event){
if(event.entityPlayer != null && event.entityPlayer.getHeldItem() != null)
if(event.entityPlayer.getHeldItem().hasTagCompound())
if(event.entityPlayer.getHeldItem().getTagCompound().hasKey("Fidelis"))
{
String fidelisID = event.entityPlayer.getHeldItem().getTagCompound().getString("Fidelis");
if(event.entityPlayer.getGameProfile().getId().toString().equals(fidelisID))
return;
else if(fidelisID.equals(""))
{
event.entityPlayer.getHeldItem().getTagCompound().setString("Fidelis", event.entityPlayer.getGameProfile().getId().toString());
event.entityPlayer.getHeldItem().getTagCompound().setString("FidelisDisplay", event.entityPlayer.getDisplayName());
}
else
event.setCanceled(true);
}
}
开发者ID:UnderMybrella,项目名称:Fidelis,代码行数:19,代码来源:Fidelis.java
示例7: playerAttackEvent
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入依赖的package包/类
/**
* Makes stick truly a rudimentary weapon TODO add damage to stick info
*
* @param event
*/
@SubscribeEvent(priority = EventPriority.NORMAL)
public void playerAttackEvent(AttackEntityEvent event)
{
EntityPlayer player = event.entityPlayer;
ItemStack itemstack = player.getCurrentEquippedItem();
if (player != null)
{
if (!player.capabilities.disableDamage && itemstack != null)
{
if (OreDictionary.itemMatches(new ItemStack(Items.stick), itemstack, true))
{
event.target.attackEntityFrom(DamageSource.causePlayerDamage(player), 2.0F);
}
}
}
return;
}
开发者ID:VapourDrive,项目名称:HarderStart,代码行数:25,代码来源:HS_PlayerAttackEntity.java
示例8: onEntityAttacked
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入依赖的package包/类
@SubscribeEvent
public void onEntityAttacked(AttackEntityEvent event){
if (event.entityPlayer.worldObj.isRemote)
return;
if (event.target instanceof EntityPlayer)
if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(event.entityPlayer, PermissionsMutex.HARM_PLAYERS, event.target.posX, event.target.posY, event.target.posZ))
event.setCanceled(true);
if (event.target instanceof EntityCreature)
if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(event.entityPlayer, PermissionsMutex.HARM_CREATURES, event.target.posX, event.target.posY, event.target.posZ))
event.setCanceled(true);
if (event.target instanceof EntityMob)
if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(event.entityPlayer, PermissionsMutex.HARM_MONSTERS, event.target.posX, event.target.posY, event.target.posZ))
event.setCanceled(true);
}
开发者ID:Mithion,项目名称:GriefGuardian,代码行数:18,代码来源:ClaimGuardEventHandler.java
示例9: onAttackEntityEvent
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入依赖的package包/类
@ForgeSubscribe
public void onAttackEntityEvent(AttackEntityEvent event)
{
if (!event.entityPlayer.worldObj.isRemote && event.target.getEntityName() != null)
{
player = (EntityPlayer) event.entityPlayer;
stack = player.getCurrentEquippedItem();
if (stack != null && stack.itemID == ItemInfo.ESSENCE_CONTAINER_ID + 256)
{
for (String s : ModItem.essenceNames)
{
if (!usedEssenceContainer && s.equals(event.target.getEntityName()))
{
usedEssenceContainer = true;
entity = s;
}
}
}
else if (stack != null && stack.itemID != ItemInfo.ESSENCE_CONTAINER_ID + 256)
{
usedEssenceContainer = false;
}
}
}
开发者ID:tterrag1098,项目名称:SimpleTransmutations,代码行数:27,代码来源:EntityLivingHandler.java
示例10: emitRedstoneOnEvent
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入依赖的package包/类
@Override
public int emitRedstoneOnEvent(PlayerEvent event, TileEntity sensor, int range) {
if (event instanceof AttackEntityEvent) {
return 15;
}
return 0;
}
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:8,代码来源:PlayerAttackSensor.java
示例11: 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);
}
}
开发者ID:blay09,项目名称:HardcoreRevival,代码行数:11,代码来源:RestrictionHandler.java
示例12: onDamage
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入依赖的package包/类
@SubscribeEvent
public void onDamage(AttackEntityEvent entityEvent) {
if (entityEvent.target instanceof EntityPlayer) {
// Making sure the player isn't fake (Delivery man etc)
if (entityEvent.target.getUniqueID().toString().charAt(14) != '4') {
return;
}
this.lastDamaged = (EntityPlayer) entityEvent.target;
timer = 120;
}
}
开发者ID:boomboompower,项目名称:TextDisplayer,代码行数:14,代码来源:FightingParser.java
示例13: onPlayerAttackTarget
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入依赖的package包/类
public static boolean onPlayerAttackTarget(EntityPlayer player, Entity target)
{
if (MinecraftForge.EVENT_BUS.post(new AttackEntityEvent(player, target))) return false;
ItemStack stack = player.getHeldItemMainhand();
if (stack != null && stack.getItem().onLeftClickEntity(stack, player, target)) return false;
return true;
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:8,代码来源:ForgeHooks.java
示例14: 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));
}
}
}
}
开发者ID:Fararise,项目名称:Possessed,代码行数:15,代码来源:ZombieHandler.java
示例15: 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));
}
}
}
}
开发者ID:Fararise,项目名称:Possessed,代码行数:15,代码来源:SkeletonHandler.java
示例16: onAttackClient
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onAttackClient(AttackEntityEvent event)
{
ClientPlayerBaseMagic p;
p = Main.getPlayerClient();
if (p.getClasse() instanceof ClasseChampion && !event.target.isDead)
{
p.increase_energy(40 + p.getPlayer().worldObj.rand.nextInt(40));
p.last_hit = System.currentTimeMillis();
}
}
开发者ID:GhostMonk3408,项目名称:MidgarCrusade,代码行数:14,代码来源:JoueurEvent.java
示例17: 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);
}
开发者ID:AtomicBlom,项目名称:ShearMadness,代码行数:36,代码来源:CommonForgeEventProxy.java
示例18: 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());
}
}
开发者ID:mchorse,项目名称:blockbuster,代码行数:15,代码来源:ActionHandler.java
示例19: onEvent
import net.minecraftforge.event.entity.player.AttackEntityEvent; //导入依赖的package包/类
@Override
public void onEvent(AttackEntityEvent event) {
if (event.getEntity() instanceof EntityPlayerMP) {
ServerPlayerSettings settings = getPlayerSettings((EntityPlayerMP) event.getEntity());
if (settings.superpunch > 0) {
event.setCanceled(true);
this.attackWithSuperpunch((EntityPlayer) event.getEntity(), event.getTarget(), settings.superpunch);
}
}
}
开发者ID:MrNobody98,项目名称:morecommands,代码行数:12,代码来源:CommandSuperpunch.java
示例20: 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);
}
}
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:14,代码来源:EnchantLifeLeech.java
注:本文中的net.minecraftforge.event.entity.player.AttackEntityEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论