Jump to content

Recommended Posts

Posted

good days

 

idoo item extending the pickaxe class, but like all the items wen rigth click over a block it does a swing like pickaxe breaking blocks i wanna disable this behaviour i wanna this item to stands still wen rigth or left click,

but du not now what to override

 

 

help??

Posted

It does look like that, but here's how it's used in EntityLivingBase.java:

 

public void swingItem()
    {
        ItemStack stack = this.getHeldItem();

        if (stack != null && stack.getItem() != null)
        {
            Item item = stack.getItem();
            if (item.onEntitySwing(this, stack)) //<-- RIGHT HERE
            {
                return;
            }
        }

        if (!this.isSwingInProgress || this.swingProgressInt >= this.getArmSwingAnimationEnd() / 2 || this.swingProgressInt < 0)
        {
            this.swingProgressInt = -1;
            this.isSwingInProgress = true;

            if (this.worldObj instanceof WorldServer)
            {
                ((WorldServer)this.worldObj).getEntityTracker().func_151247_a(this, new S0BPacketAnimation(this, 0));
            }
        }
    }

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • 2 years later...
Posted (edited)
@Override
public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) {
    return true; //Handled to do not a swing
}

 

But on the Event:

PlayerInteractEvent.LeftClickEmpty event

 still remains an animation where the hand is going down and up.
 

Edited by NoFuchsGavin
  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Well, as usual, it was user error. Naming mismatch in sounds.json.  Please delete this post if you find it necessary. 
    • Hello Forge community.  I'm running into an issue with a mod I'm working on.  To preface, I can call /playsound modId:name music @a and I can hear the sound I registered being played in game. Great!  However, I cannot get it to trigger via my mod code.    Registration: public static final RegistryObject<SoundEvent> A_WORLD_OF_MADNESS = SOUND_EVENTS.register("a_world_of_madness", () -> new SoundEvent(new ResourceLocation("tetheredsouls", "a_world_of_madness")));   Playback: Minecraft mc = Minecraft.getInstance(); if (!(mc.player instanceof LocalPlayer) || mc.level == null) return; LocalPlayer player = (LocalPlayer) mc.player; BlockPos pos = player.blockPosition(); SoundEvent track = ModSounds.A_WORLD_OF_MADNESS.get(); System.out.println(track); System.out.println(pos); System.out.println(player); // play exactly like the tutorial: client-only, at the player's position try { mc.level.playLocalSound( player.getX(), player.getY(), player.getZ(), track, SoundSource.MUSIC, // Or MASTER if needed 1f, 1f, false ); System.out.println("[DEBUG] playSound success: " + track.getLocation()); } catch (Exception e) { System.err.println("[ERROR] Failed to play sound: " + track.getLocation()); e.printStackTrace(); } Sounds.json:   { "theme_of_laura": { "category": "music", "sounds": [ { "name": "tetheredsouls:a_world_of_madness", "stream": true } ] } } Things I have tried: - multiple .ogg files. Short .ogg files (5 seconds, <100KB).  - default minecraft sounds imported from import net.minecraft.sounds.SoundEvents; These work given my code. No idea why these are different.  - playSound() method, as well as several others in past iterations that did not work   I would be forever grateful if somebody could point me in the right direction. I've looked at several mod github repositories and found extremely similar code to what I'm doing. I've also found several threads in this forum that did not solve my issue. I just cannot figure out what I'm doing differently, and why I'm able to queue sounds manually with playsound but the code won't play it (despite confirming the code is being run with the debug statements.)
    • Delete the tensura-reincarnated/common.toml file (config folder)
    • Jesus Christ is God's Son, Jesus died for our sins and rose from the dead to Give us eternal life. Ask Him to also heal your body.
  • Topics

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.