do ya know how to make recoil?

Started by the deadly scorpion on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
do ya know how to make recoil?

Does anyone know how i could add recoil?

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
like from a gun? you have to…
Wed, 07/01/2020 - 11:12

like from a gun? you have to use a global event that changes player's roll/pitch/yaw. but mcreator doesn't have that global trigger in procedures yet. so as of now coding is required.

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Why would you use a "global"…
Wed, 07/01/2020 - 15:30

Why would you use a "global" trigger?? You already have;

Item::onItemRightClick

And we are using a "ranged-item", which should extend Item.

 

And then from there, it is as simple as setting the players rotationPitch;

playerIn.rotationPitch = playerIn.rotationPitch - 10 - new Random().nextInt(5);

The above ^^ could just be put in a custom snippet, however, to follow MCreators dependencies. It should look similar to;

entity.rotationPitch = entity.rotationPitch - 10 - new Random().nextInt(5);

​​​​​​Note: You can do the same with rotationYaw, <- & ->.

Joined Apr 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
where do i add that and how…
Wed, 07/01/2020 - 21:54

where do i add that and how does it work? (sorry, idk anything about coding)

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
entity.rotationPitch =…
Wed, 07/01/2020 - 22:00

entity.rotationPitch = entity.rotationPitch - 10 - new Random().nextInt(5);

Under your ranged item, there is an item right-click function I believe. In the procedure it calls, you can most likely use the snippet above in a custom snippet (under advanced tab). 

 

Note: You may get an "error: can not find symbol", that is most likely due to the Random() class not being found or the entity. If you get this error post full log, and all code used.

Joined Apr 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
thanks a ton for the help…
Wed, 07/01/2020 - 22:09

thanks a ton for the help bro!

Joined Apr 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Executing Gradle task: build…
Wed, 07/01/2020 - 22:16

Executing Gradle task: build
Build info: MCreator 2020.3.22116, forge-1.15.2, 64-bit, 4009 MB, Windows 10, JVM 1.8.0_252, JAVA_HOME: C:\Users\charl\Desktop\acces\mcreator2\MCreator\jdk
> Configure project :
New Dep: net.minecraftforge:forge:1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1
> Task :compileJava
C:\Users\charl\MCreatorWorkspaces\end_of_humanity\src\main\java\net\mcreator\end_of_humanity\procedures\Ak47RangedItemUsedProcedure.java:14: error: cannot find symbol entity.rotationPitch = entity.rotationPitch - 10 - new Random().nextInt(5);
^
symbol: variable entity
location: class Ak47RangedItemUsedProcedure
C:\Users\charl\MCreatorWorkspaces\end_of_humanity\src\main\java\net\mcreator\end_of_humanity\procedures\Ak47RangedItemUsedProcedure.java:14: error: cannot find symbol entity.rotationPitch = entity.rotationPitch - 10 - new Random().nextInt(5);
^
symbol: variable entity
location: class Ak47RangedItemUsedProcedure
2 errors
> Task :compileJava FAILED
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 2m 38s
1 actionable task: 1 executed
BUILD FAILED
Task completed in 171645 milliseconds

 

lol

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yeah, I expected that. That…
Wed, 07/01/2020 - 22:18

Yeah, I expected that. That's the variable, "entity", I will create it. Post all of the code inside the procedure.

Joined Apr 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
package net.mcreator.end_of…
Wed, 07/01/2020 - 22:22

package net.mcreator.end_of_humanity.procedures;

import net.mcreator.end_of_humanity.EndOfHumanityModElements;

import java.util.Random;

@EndOfHumanityModElements.ModElement.Tag
public class Ak47RangedItemUsedProcedure extends EndOfHumanityModElements.ModElement {
    public Ak47RangedItemUsedProcedure(EndOfHumanityModElements instance) {
        super(instance, 35);
    }

    public static void executeProcedure(java.util.HashMap<String, Object> dependencies) {
        entity.rotationPitch = entity.rotationPitch - 10 - new Random().nextInt(5);
    }
}

 

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
package net.mcreator.end_of…
Wed, 07/01/2020 - 22:26

package net.mcreator.end_of_humanity.procedures;

import net.mcreator.end_of_humanity.EndOfHumanityModElements;

import net.minecraft.entity.LivingEntity;

 

import java.util.Random;

@EndOfHumanityModElements.ModElement.Tag
public class Ak47RangedItemUsedProcedure extends EndOfHumanityModElements.ModElement {
    public Ak47RangedItemUsedProcedure(EndOfHumanityModElements instance) {
        super(instance, 35);
    }

    public static void executeProcedure(java.util.HashMap<String, Object> dependencies) {

LivingEntity entity = (LivingEntity) dependencies.get("entity");
        entity.rotationPitch = entity.rotationPitch - 10 - new Random().nextInt(5);
    }
}

 

Note: This code should remain locked.

 

Regarding your above message, I can help, however, I am working on my own mod as well.

Joined Sep 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can you help me with that? I…
Sun, 01/03/2021 - 02:32

Can you help me with that? I am also making a zombie mod.