本文整理匯總了Java中net.minecraftforge.event.entity.player.AttackEntityEvent.setCanceled方法的典型用法代碼示例。如果您正苦於以下問題:Java AttackEntityEvent.setCanceled方法的具體用法?Java AttackEntityEvent.setCanceled怎麽用?Java AttackEntityEvent.setCanceled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.event.entity.player.AttackEntityEvent
的用法示例。
在下文中一共展示了AttackEntityEvent.setCanceled方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
}
}
}
}
示例2: 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);
}
}
示例3: 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);
}
示例4: 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);
}
}
示例5: 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);
}
示例6: 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);
}
}
}
示例7: onEntityAttack
import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityAttack(AttackEntityEvent event) {
if (event.entity instanceof EntityAmbientCreature || event.entity instanceof EntityAnimal || event.entity instanceof EntityPlayer) {
EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer;
if (CoreClaim.claimManager.checkEventCancel(event.entityPlayer, (int) event.entity.posX, (int) event.entity.posZ)) {
event.setCanceled(true);
Utils.messageToPlayer(player, EnumChatFormatting.RED + "Oh snap, you are not allowed to harm this entity!");
}
}
}
示例8: on
import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(AttackEntityEvent e) {
EntityPlayer player = e.entityPlayer;
if(!e.target.worldObj.isRemote && e.target instanceof EntityGolemTH
&& player.isSneaking()) {
e.setCanceled(true);
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null && stack.getItem().onLeftClickEntity(stack, player, e.target)
&& e.target.isDead) {
CommonProxy.EVENT_HANDLER_GOLEM.on(new PlaySoundAtEntityEvent(e.target, "thaumcraft:zap", 0.5f, 1.0f));
}
}
}
示例9: onAttackEntity
import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@SuppressWarnings("unused")
@SubscribeEvent
public void onAttackEntity(AttackEntityEvent event) {
if (event.entityPlayer != null &&
event.entityPlayer.getHeldItem() != null &&
ItemWeapon.class.isAssignableFrom(event.entityPlayer.getHeldItem().getItem().getClass())
) {
event.setCanceled(true);
}
}
示例10: attackEntity
import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
/**
* Cancel the attack if the player reach is lowered by some types of items, or if barehanded
* Note: Applies to either hands, since item is hotswap before this event for offhand weapons
* @param event for the player attacking an entity
*/
@SubscribeEvent
public void attackEntity(AttackEntityEvent event){
if(((IBattlePlayer) event.getEntityPlayer()).getSpecialActionTimer() > 0){
event.setCanceled(true);
return;
}
double reachMod = maxReachDistance(event.getEntityPlayer());
if (reachMod < event.getEntityPlayer().getDistanceToEntity(event.getTarget())) {
event.setCanceled(true);
}
}
示例11: AttackEntity
import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void AttackEntity(AttackEntityEvent event) {
if (event.getEntityPlayer().getEntityData().hasKey("renderViewCamera"))
event.setCanceled(true);
}
示例12: hitEntity
import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void hitEntity(AttackEntityEvent event)
{
if (DisabledHandler.isDisabledStack(event.entityPlayer)) event.setCanceled(true);
}