Search in sources :

Example 6 with AxeItem

use of net.minecraft.item.AxeItem in project friends-and-foes by Faboslav.

the class CopperGolemEntity method interactMob.

@Override
public ActionResult interactMob(PlayerEntity player, Hand hand) {
    ItemStack itemStack = player.getStackInHand(hand);
    Item itemInHand = itemStack.getItem();
    boolean interactionResult = false;
    if (itemInHand == Items.COPPER_INGOT) {
        interactionResult = this.tryToInteractMobWithCopperIngot(player, itemStack);
    } else if (itemInHand == Items.HONEYCOMB) {
        interactionResult = this.tryToInteractMobWithHoneycomb(player, itemStack);
    } else if (itemInHand instanceof AxeItem) {
        interactionResult = this.tryToInteractMobWithAxe(player, hand, itemStack);
    }
    if (interactionResult) {
        this.emitGameEvent(GameEvent.MOB_INTERACT, this.getCameraBlockPos());
        return ActionResult.success(this.world.isClient);
    }
    return super.interactMob(player, hand);
}
Also used : Item(net.minecraft.item.Item) AxeItem(net.minecraft.item.AxeItem) ItemStack(net.minecraft.item.ItemStack) AxeItem(net.minecraft.item.AxeItem)

Example 7 with AxeItem

use of net.minecraft.item.AxeItem in project Moonfix by Kingdom-of-Moon.

the class ClientPlayerInteractionManagerMixin method interactBlock.

// makes log strips and grass path actions be ignored unless if player is pressing sneak
@Inject(at = @At("HEAD"), method = "interactBlock", cancellable = true)
private void interactBlock(ClientPlayerEntity player, ClientWorld world, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) {
    if (player.isSneaking())
        return;
    Item item = player.getStackInHand(hand).getItem();
    BlockState block = world.getBlockState(hitResult.getBlockPos());
    boolean path = (boolean) ConfigManager.Config.DIRT_PATH.value && item instanceof ShovelItem && ShovelItemAccessor.getPathStates().containsKey(block.getBlock());
    boolean stripped = (boolean) ConfigManager.Config.STRIPPED_LOGS.value && item instanceof AxeItem && AxeItemAccessor.getStrippedBlocks().containsKey(block.getBlock());
    if (path || stripped) {
        cir.setReturnValue(ActionResult.PASS);
        cir.cancel();
    }
}
Also used : Item(net.minecraft.item.Item) ShovelItem(net.minecraft.item.ShovelItem) AxeItem(net.minecraft.item.AxeItem) BlockState(net.minecraft.block.BlockState) ShovelItem(net.minecraft.item.ShovelItem) AxeItem(net.minecraft.item.AxeItem) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 8 with AxeItem

use of net.minecraft.item.AxeItem in project LevelZ by Globox1997.

the class LevelzGui method getDamageLabel.

private String getDamageLabel(PlayerStatsManager playerStatsManager, PlayerEntity playerEntity) {
    float damage = 0.0F;
    boolean isSword = false;
    Item item = playerEntity.getMainHandStack().getItem();
    if (item instanceof ToolItem) {
        ArrayList<Object> levelList = new ArrayList<Object>();
        if (item instanceof SwordItem) {
            levelList = LevelLists.swordList;
            isSword = true;
        } else if (item instanceof AxeItem)
            levelList = LevelLists.axeList;
        else if (item instanceof HoeItem)
            levelList = LevelLists.hoeList;
        else
            levelList = LevelLists.toolList;
        if (PlayerStatsManager.playerLevelisHighEnough(playerEntity, levelList, ((ToolItem) item).getMaterial().toString().toLowerCase(), false)) {
            if (isSword)
                damage = ((SwordItem) item).getAttackDamage();
            else if (item instanceof MiningToolItem)
                damage = ((MiningToolItem) item).getAttackDamage();
        }
    }
    damage += playerEntity.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE);
    return "" + BigDecimal.valueOf(damage).setScale(2, RoundingMode.HALF_DOWN).floatValue();
}
Also used : Item(net.minecraft.item.Item) MiningToolItem(net.minecraft.item.MiningToolItem) SwordItem(net.minecraft.item.SwordItem) AxeItem(net.minecraft.item.AxeItem) ToolItem(net.minecraft.item.ToolItem) HoeItem(net.minecraft.item.HoeItem) ArrayList(java.util.ArrayList) MiningToolItem(net.minecraft.item.MiningToolItem) SwordItem(net.minecraft.item.SwordItem) AxeItem(net.minecraft.item.AxeItem) HoeItem(net.minecraft.item.HoeItem) MiningToolItem(net.minecraft.item.MiningToolItem) ToolItem(net.minecraft.item.ToolItem)

Example 9 with AxeItem

use of net.minecraft.item.AxeItem in project ChocolateQuestRepoured by TeamChocoQuest.

the class AbstractEntityCQR method hurt.

public boolean hurt(DamageSource source, float amount, boolean sentFromPart) {
    // Start IceAndFire compatibility
    if (CQRConfig.advanced.enableSpecialFeatures && source.getEntity() != null) {
        ResourceLocation resLoc = EntityList.getKey(source.getEntity());
        if (resLoc != null && resLoc.getNamespace().equalsIgnoreCase("iceandfire")) {
            amount *= 0.5F;
        }
    }
    // End IceAndFire compatibility
    // Shoulder entity stuff
    this.spawnShoulderEntities();
    if (this.level.getLevelData().isHardcore()) {
        amount *= 0.7F;
    } else {
        Difficulty difficulty = this.level.getDifficulty();
        if (difficulty == Difficulty.HARD) {
            amount *= 0.8F;
        } else if (difficulty == Difficulty.NORMAL) {
            amount *= 0.9F;
        }
    }
    // End of shoulder entity stuff
    amount = this.handleDamageCap(source, amount);
    if (!this.level.isClientSide && amount > 0.0F && this.canBlockDamageSource(source)) {
        if (source.getDirectEntity() instanceof LivingEntity && !(source.getDirectEntity() instanceof PlayerEntity) && ((LivingEntity) source.getDirectEntity()).getMainHandItem().getItem() instanceof AxeItem) {
            this.lastTickShieldDisabled = this.tickCount;
        } else {
            this.damageBlockedWithShield += amount;
            if (this.damageBlockedWithShield >= CQRConfig.general.damageBlockedByShield) {
                this.damageBlockedWithShield = 0.0F;
                this.lastTickShieldDisabled = this.tickCount;
            }
        }
    }
    boolean flag = super.hurt(source, amount);
    if (flag && CQRConfig.mobs.armorShattersOnMobs) {
        this.handleArmorBreaking();
    }
    return flag;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) Difficulty(net.minecraft.world.Difficulty) ResourceLocation(net.minecraft.util.ResourceLocation) AxeItem(net.minecraft.item.AxeItem) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Example 10 with AxeItem

use of net.minecraft.item.AxeItem in project Architects-Palette-Fabric by Slomaxonical-907.

the class TotemBlock method onUse.

@Override
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockHitResult hit) {
    ItemStack playerItem = player.getStackInHand(handIn);
    if (playerItem.getItem() instanceof AxeItem) {
        BlockState newState = this.totemType.getStrip().getDefaultState().with(FACING, state.get(FACING));
        worldIn.setBlockState(pos, newState, 3);
        playerItem.damage(1, player, (p) -> p.sendToolBreakStatus(handIn));
        worldIn.playSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1, 1);
        /* if (player instanceof ServerPlayerEntity) {
                APCriterion.CARVE_TOTEM.trigger((ServerPlayerEntity) player);
            }*/
        return ActionResult.success(worldIn.isClient);
    }
    return ActionResult.FAIL;
}
Also used : BlockState(net.minecraft.block.BlockState) ItemStack(net.minecraft.item.ItemStack) AxeItem(net.minecraft.item.AxeItem)

Aggregations

AxeItem (net.minecraft.item.AxeItem)12 Item (net.minecraft.item.Item)5 ItemStack (net.minecraft.item.ItemStack)5 SwordItem (net.minecraft.item.SwordItem)5 LivingEntity (net.minecraft.entity.LivingEntity)3 PlayerEntity (net.minecraft.entity.player.PlayerEntity)3 OldBlock (dev.hypnotic.module.render.OldBlock)2 BlockState (net.minecraft.block.BlockState)2 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)2 Items (net.minecraft.item.Items)2 ShieldItem (net.minecraft.item.ShieldItem)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 Lists (com.google.common.collect.Lists)1 FriendManager (dev.hypnotic.config.friends.FriendManager)1 EventTarget (dev.hypnotic.event.EventTarget)1 EventMotionUpdate (dev.hypnotic.event.events.EventMotionUpdate)1 EventRender3D (dev.hypnotic.event.events.EventRender3D)1 EventRenderItem (dev.hypnotic.event.events.EventRenderItem)1 EventSendPacket (dev.hypnotic.event.events.EventSendPacket)1 PlayerMoveC2SPacketAccessor (dev.hypnotic.mixin.PlayerMoveC2SPacketAccessor)1