Search in sources :

Example 1 with AxeItem

use of net.minecraft.item.AxeItem in project meteor-client by MeteorDevelopment.

the class Offhand method onTick.

@EventHandler
private void onTick(TickEvent.Pre event) {
    AutoTotem autoTotem = Modules.get().get(AutoTotem.class);
    // Sword Gap
    if ((mc.player.getMainHandStack().getItem() instanceof SwordItem || mc.player.getMainHandStack().getItem() instanceof AxeItem) && swordGap.get())
        currentItem = Item.EGap;
    else // Ca and mining
    if ((Modules.get().isActive(CrystalAura.class) && crystalCa.get()) || mc.interactionManager.isBreakingBlock() && crystalMine.get())
        currentItem = Item.Crystal;
    else
        currentItem = item.get();
    // Checking offhand item
    if (mc.player.getOffHandStack().getItem() != currentItem.item) {
        FindItemResult item = InvUtils.find(itemStack -> itemStack.getItem() == currentItem.item, hotbar.get() ? 0 : 9, 35);
        // No offhand item
        if (!item.found()) {
            if (!sentMessage) {
                warning("Chosen item not found.");
                sentMessage = true;
            }
        } else // Swap to offhand
        if ((isClicking || !rightClick.get()) && !autoTotem.isLocked() && !item.isOffhand()) {
            InvUtils.move().from(item.slot()).toOffhand();
            sentMessage = false;
        }
    } else // If not clicking, set to totem if auto totem is on
    if (!isClicking && rightClick.get()) {
        if (autoTotem.isActive()) {
            FindItemResult totem = InvUtils.find(itemStack -> itemStack.getItem() == Items.TOTEM_OF_UNDYING, hotbar.get() ? 0 : 9, 35);
            if (totem.found() && !totem.isOffhand()) {
                InvUtils.move().from(totem.slot()).toOffhand();
            }
        } else {
            FindItemResult empty = InvUtils.find(ItemStack::isEmpty, hotbar.get() ? 0 : 9, 35);
            if (empty.found())
                InvUtils.move().fromOffhand().to(empty.slot());
        }
    }
}
Also used : Setting(meteordevelopment.meteorclient.settings.Setting) Categories(meteordevelopment.meteorclient.systems.modules.Categories) SettingGroup(meteordevelopment.meteorclient.settings.SettingGroup) Items(net.minecraft.item.Items) KeyAction(meteordevelopment.meteorclient.utils.misc.input.KeyAction) TickEvent(meteordevelopment.meteorclient.events.world.TickEvent) ItemStack(net.minecraft.item.ItemStack) MouseButtonEvent(meteordevelopment.meteorclient.events.meteor.MouseButtonEvent) Module(meteordevelopment.meteorclient.systems.modules.Module) GLFW_MOUSE_BUTTON_RIGHT(org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_RIGHT) BoolSetting(meteordevelopment.meteorclient.settings.BoolSetting) FindItemResult(meteordevelopment.meteorclient.utils.player.FindItemResult) InvUtils(meteordevelopment.meteorclient.utils.player.InvUtils) Modules(meteordevelopment.meteorclient.systems.modules.Modules) SwordItem(net.minecraft.item.SwordItem) EnumSetting(meteordevelopment.meteorclient.settings.EnumSetting) EventHandler(meteordevelopment.orbit.EventHandler) AxeItem(net.minecraft.item.AxeItem) FindItemResult(meteordevelopment.meteorclient.utils.player.FindItemResult) SwordItem(net.minecraft.item.SwordItem) AxeItem(net.minecraft.item.AxeItem) EventHandler(meteordevelopment.orbit.EventHandler)

Example 2 with AxeItem

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

the class EventsHandler method onAttackEntityEvent.

@SubscribeEvent
public static void onAttackEntityEvent(AttackEntityEvent event) {
    if (CQRConfig.mobs.blockCancelledByAxe) {
        PlayerEntity player = event.getEntityPlayer();
        World world = player.world;
        if (!world.isRemote && event.getTarget() instanceof AbstractEntityCQR) {
            AbstractEntityCQR targetCQR = (AbstractEntityCQR) event.getTarget();
            if (targetCQR.canBlockDamageSource(DamageSource.causePlayerDamage(player)) && player.getHeldItemMainhand().getItem() instanceof AxeItem && player.getCooledAttackStrength(0) >= 0.9F) {
                targetCQR.setLastTimeHitByAxeWhileBlocking(targetCQR.ticksExisted);
            }
        }
    }
}
Also used : AbstractEntityCQR(team.cqr.cqrepoured.entity.bases.AbstractEntityCQR) ServerWorld(net.minecraft.world.server.ServerWorld) World(net.minecraft.world.World) AxeItem(net.minecraft.item.AxeItem) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 3 with AxeItem

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

the class EntityCQRWalkerKing method hurt.

@Override
public boolean hurt(DamageSource source, float amount, boolean sentFromPart) {
    if (source == DamageSource.WITHER) {
        this.heal(amount / 2);
        return true;
    }
    if (source == DamageSource.FALL) {
        return true;
    }
    if (source == DamageSource.IN_WALL && this.hasAttackTarget() && this.isServerWorld()) {
        EntityWalkerKingIllusion illusion = new EntityWalkerKingIllusion(1200, this, this.getWorld());
        illusion.setPos(this.getX(), this.getY(), this.getZ());
        this.level.addFreshEntity(illusion);
        this.teleportBehindEntity(this.getTarget(), true);
        this.canAttack(this.getTarget());
        return false;
    }
    /*
		 * boolean spectralFlag = false;
		 * if (source.getTrueSource() instanceof EntityLivingBase) {
		 * if (EnchantmentHelper.getEnchantmentLevel(CQREnchantments.SPECTRAL, ((EntityLivingBase)
		 * source.getTrueSource()).getHeldItemMainhand()) > 0 ||
		 * EnchantmentHelper.getEnchantmentLevel(CQREnchantments.SPECTRAL, ((EntityLivingBase)
		 * source.getTrueSource()).getHeldItemOffhand()) > 0) {
		 * amount *= 2;
		 * spectralFlag = true;
		 * }
		 * }
		 */
    if (/* !spectralFlag && */
    ((source.getDirectEntity() == null) || !(source.getDirectEntity() instanceof SpectralArrowEntity)) && !CQRConfig.bosses.armorForTheWalkerKing) {
        amount *= 0.5F;
    }
    if (source.getDirectEntity() != null) {
        if (source.getDirectEntity() instanceof SpectralArrowEntity) {
            amount *= 2;
            super.hurt(source, amount, sentFromPart);
            return true;
        }
        if ((source.getDirectEntity() instanceof ThrowableEntity || source.getDirectEntity() instanceof AbstractArrowEntity) && !this.level.isClientSide) {
            // STAB HIM IN THE BACK!!
            this.backStabAttacker(source);
            return false;
        }
    }
    this.handleActivation();
    if (source.getEntity() != null && !this.level.isClientSide) {
        ResourceLocation resLoc = EntityList.getKey(source.getEntity());
        if (resLoc != null) {
            // Start IceAndFire compatibility
            boolean flag = resLoc.getNamespace().equalsIgnoreCase("iceandfire") && CQRConfig.advanced.enableSpecialFeatures;
            if (flag) {
                amount /= 2;
            }
            // End IceAndFire compatibility
            Faction fac = FactionRegistry.instance(this).getFactionOf(source.getEntity());
            boolean dragonFactionFlag = fac != null && (fac.getName().equalsIgnoreCase("DRAGON") || fac.getName().equalsIgnoreCase("DRAGONS"));
            // If we are attacked by a dragon: KILL IT
            if (this.dragonAttackCooldown <= 0 && (dragonFactionFlag || resLoc.getPath().contains("dragon") || resLoc.getPath().contains("wyrm") || resLoc.getPath().contains("wyvern") || flag)) {
                this.dragonAttackCooldown = 80;
                this.handleAttackedByDragon(source.getEntity());
            }
        }
    }
    if (!this.level.isClientSide && source.getEntity() instanceof LivingEntity) {
        // How about killing the one who tries with the axe?
        // Maybe move this whole ability to the king shield itself??
        ItemStack shieldStack = this.getItemBySlot(EquipmentSlotType.OFFHAND);
        if (amount > 0F && this.canBlockDamageSource(source) && shieldStack != null && !shieldStack.isEmpty() && shieldStack.getItem() instanceof ShieldItem) {
            this.playSound(CQRSounds.WALKER_KING_LAUGH, 10.0F, 1.0F);
            if (source.getDirectEntity() instanceof LivingEntity && /* && (source.getImmediateSource() instanceof EntityPlayer) */
            ((LivingEntity) source.getDirectEntity()).getMainHandItem().getItem() instanceof AxeItem) {
                if (DungeonGenUtils.percentageRandom(0.75, this.getRandom())) {
                    Vector3d v = source.getDirectEntity().position().subtract(this.position()).normalize().scale(1.25);
                    v = v.add(0, 0.75, 0);
                    LivingEntity attacker = (LivingEntity) source.getDirectEntity();
                    /*attacker.motionX = v.x;
						attacker.motionY = v.y;
						attacker.motionZ = v.z;
						attacker.velocityChanged = true;*/
                    attacker.setDeltaMovement(v);
                    attacker.hasImpulse = true;
                    this.swing(Hand.OFF_HAND);
                    return false;
                }
            }
        }
        if (this.getRandom().nextDouble() < 0.2 && source.getEntity() != null) {
            // Revenge Attack
            if (this.getRandom().nextDouble() < 0.7) {
                this.canAttack((LivingEntity) source.getEntity());
                this.playSound(CQRSounds.WALKER_KING_LAUGH, 10.0F, 1.0F);
                this.teleportBehindEntity(source.getEntity());
            }
        }
    }
    return super.hurt(source, amount, sentFromPart);
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) EntityWalkerKingIllusion(team.cqr.cqrepoured.entity.misc.EntityWalkerKingIllusion) ShieldItem(net.minecraft.item.ShieldItem) Vector3d(net.minecraft.util.math.vector.Vector3d) SpectralArrowEntity(net.minecraft.entity.projectile.SpectralArrowEntity) ThrowableEntity(net.minecraft.entity.projectile.ThrowableEntity) ResourceLocation(net.minecraft.util.ResourceLocation) ItemStack(net.minecraft.item.ItemStack) AxeItem(net.minecraft.item.AxeItem) AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity) Faction(team.cqr.cqrepoured.faction.Faction) EDefaultFaction(team.cqr.cqrepoured.faction.EDefaultFaction)

Example 4 with AxeItem

use of net.minecraft.item.AxeItem in project Biome-Makeover by Lemonszz.

the class AdjudicatorEntityModel method setAngles.

@Override
public void setAngles(E entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
    AnimationHelper.setRotation(leg_left, 0, 0, 0);
    AnimationHelper.setRotation(leg_right, 0, 0, 0);
    AnimationHelper.rotateHead(head, headPitch, headYaw);
    this.body.yaw = 0.0F;
    AnimationHelper.swingLimb(leg_left, leg_right, limbAngle, limbDistance, 1.25F);
    this.arm_right.pitch = MathHelper.cos(limbAngle * 0.6662F + 3.1415927F) * 2.0F * limbDistance * 0.5F;
    this.arm_right.yaw = 0.0F;
    this.arm_right.roll = 0.0F;
    this.arm_left.pitch = MathHelper.cos(limbAngle * 0.6662F) * 2.0F * limbDistance * 0.5F;
    this.arm_left.yaw = 0.0F;
    this.arm_left.roll = 0.0F;
    if (this.riding) {
        arm_right.pitch += -0.63F;
        arm_left.pitch += -0.63F;
        this.leg_right.pitch = -1.4F;
        this.leg_right.yaw = 0.31F;
        this.leg_right.roll = 0.078F;
        this.leg_left.pitch = -1.41F;
        this.leg_left.yaw = -0.31F;
        this.leg_left.roll = -0.078F;
    }
    switch(entity.getState()) {
        case WAITING:
            AnimationHelper.setRotation(head, -0.567232F, 0, 0);
            AnimationHelper.setRotation(arm_left, -0.349066F, 0, -2.53073F);
            AnimationHelper.setRotation(arm_right, -0.349066F, 0, 2.53073F);
            AnimationHelper.setRotation(leg_left, -1.701696F, 0.4799655F, 0);
            AnimationHelper.setRotation(leg_right, -1.309F, -0.0872665F, 0);
            break;
        case SUMMONING:
        case TELEPORT:
            this.arm_right.pitch = MathHelper.cos(animationProgress * 0.6662F) * 0.25F;
            this.arm_left.pitch = MathHelper.cos(animationProgress * 0.6662F) * 0.25F;
            this.arm_right.roll = 2.3561945F;
            this.arm_left.roll = -2.3561945F;
            this.arm_right.yaw = 0.0F;
            this.arm_left.yaw = 0.0F;
            break;
        case FIGHTING:
            if (!entity.getMainHandStack().isEmpty()) {
                Item item = entity.getMainHandStack().getItem();
                if (item instanceof BowItem) {
                    this.arm_right.yaw = -0.1F + this.head.yaw;
                    this.arm_right.pitch = -1.5707964F + this.head.pitch;
                    this.arm_left.pitch = -0.9424779F + this.head.pitch;
                    this.arm_left.yaw = this.head.yaw - 0.4F;
                    this.arm_left.roll = 1.5707964F;
                } else if (item instanceof AxeItem || item instanceof SwordItem) {
                    CrossbowPosing.method_29351(this.arm_right, this.arm_left, entity, this.handSwingProgress, animationProgress);
                }
            } else {
                CrossbowPosing.method_29352(this.arm_left, this.arm_right, true, this.handSwingProgress, animationProgress);
            }
            break;
    }
}
Also used : Item(net.minecraft.item.Item) SwordItem(net.minecraft.item.SwordItem) BowItem(net.minecraft.item.BowItem) AxeItem(net.minecraft.item.AxeItem) BowItem(net.minecraft.item.BowItem) SwordItem(net.minecraft.item.SwordItem) AxeItem(net.minecraft.item.AxeItem)

Example 5 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)

Aggregations

AxeItem (net.minecraft.item.AxeItem)11 ItemStack (net.minecraft.item.ItemStack)5 Item (net.minecraft.item.Item)4 SwordItem (net.minecraft.item.SwordItem)4 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