Turn off hand movement?

Started by squidud on

Topic category: Help with Minecraft modding (Java Edition)

Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Turn off hand movement?

I was working on a mod and I wanted to add a machine gun. It works great and everything, it just looks odd because the player's hand swings the gun every time it shoots. Is there a way to ensure the gun (and player's hand) don't move when shooting the gun?

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This may not be the best way…
Sun, 05/31/2020 - 00:36

This may not be the best way to go about this, but on onItemRightClick your gonna want to return a ActionResult.resultFail(yourItem). This will cancel the "animation". Here is an example I use in one of my mods.

    @Override
    public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
        ItemStack itemStack = playerIn.getHeldItem(handIn);
        if (!worldIn.isRemote)
        {
            LazyOptional<IPlayerHandler> player_cap = playerIn.getCapability(PlayerProvider.CAPABILITY_PLAYER, null);
            IPlayerHandler playerHandler = player_cap.orElse(new PlayerCapability());

            if (itemStack.hasTag() && !itemStack.getTag().getString("entityaffiliation").equalsIgnoreCase(""))
            {
                playerHandler.setPlayerEntityAffiliation(itemStack.getTag().getString("entityaffiliation"));
                playerIn.sendMessage(new StringTextComponent("Added Contract"));
                NetworkLoader.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) playerIn), new PacketPlayerEntityAffiliationSync(playerHandler.returnPlayerEntityAffiliation()));
                NetworkLoader.INSTANCE.sendToServer(new PacketAdvancement("scroll"));
            }
        }
        playerIn.addStat(Stats.ITEM_USED.get(this));
        if (!playerIn.abilities.isCreativeMode) {
            itemStack.shrink(1);
        }
        return ActionResult.resultSuccess(itemStack); THIS IS THE PART THAT IS IMPORTANT
    }

DISREGARD THE OTHER CODE JUST LOOK AT THE RETURN STATEMENT!!!

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
OOPS I forgot that was a…
Sun, 05/31/2020 - 00:37

OOPS I forgot that was a succes return!!! USE THIS INSTEAD: 

return ActionResult.resultFail(itemStack);
Joined Aug 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I think someone should open…
Thu, 07/02/2020 - 23:56

I think someone should open a ticket to make this an option.

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if anybody wants to know, i…
Thu, 07/23/2020 - 07:31

if anybody wants to know, i manage to 'fix' this manually on code (on 2020.4/2020.3):

 

//@Override
        //public UseAction getUseAction(ItemStack stack) {
        //    return UseAction.BOW;
        //}            <-------------- DISABLE THIS PART HERE

        @Override
        public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity entity, Hand hand) {
            entity.setActiveHand(hand);
            return new ActionResult(ActionResultType.FAIL, entity.getHeldItem(hand));        //<------------- Change SUCESS to FAIL here
            
        }

guns dont move when shoting now :)

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Did you not read my first…
Thu, 07/23/2020 - 12:16

Did you not read my first post......................... lol..........

Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Howdy stranger! So how would…
Thu, 08/13/2020 - 02:27

Howdy stranger! So how would one go about inserting this code into a procedure? because as far as I know it only uses code blocks.

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You got to lock the class…
Thu, 08/13/2020 - 14:51

You got to lock the class and change the code there. It's not applicable to do in a procedure.

Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
So I went about adding this…
Wed, 10/28/2020 - 07:54

So I went about adding this script to my mod and I received this;

10 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.3/userguide/command_line_interface.html#se…
BUILD FAILED in 1s
1 actionable task: 1 executed

 

How would one go about fixing this?