Code to make entities go through solid blocks

Started by Trehmor on

Topic category: Help with Minecraft modding (Java Edition)

Joined Feb 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Code to make entities go through solid blocks

Im trying to add a custom code snippet to a flying mob to make it go through solid blocks like a Vex but it doesnt seem to work.

The code: 
@Override
public void travel(Vec3 movementInput) {
    if (this.isInWater()) {
    } else if (this.isInLava()) {
    } else {
        float friction = 0.91F;
        if (this.onGround) {
            friction = this.level.getBlockState(this.blockPosition().below()).getBlock().getFriction();
        }
        float groundFriction = 0.16277136F / (friction * friction * friction);
        this.moveRelative(this.onGround ? 0.1F * groundFriction : 0.02F, movementInput);
        friction = 0.91F;
        if (this.onGround) {
            friction = this.level.getBlockState(this.blockPosition().below()).getBlock().getFriction();
        }
        this.move(MoverType.SELF, this.getDeltaMovement().multiply((double) friction, 1.0D, (double) friction));
        this.setDeltaMovement(this.getDeltaMovement().scale(1.0D / (double) friction));
    }
}

The error i get:
> Task :compileJava FAILED
C:\Users\JuAnI\MCreatorWorkspaces\Venecocraft\src\main\java\net\mcreator\venecocraft\entity\HijackerEntity.java:121: error: reached end of file while parsing }
^
1 error
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
BUILD FAILED in 2s
1 actionable task: 1 executed

BUILD FAILED
Task completed in 3 seconds

Im trying to add a custom…
Mon, 01/01/2024 - 14:55

Im trying to add a custom code snippet to a flying mob to make it go through solid blocks like a Vex but it doesnt seem to work.

It seems you have too many curly braces in the code. You are closing one statement too much.

If you are not sure how to code Java, I would recommend learning this first before attempting custom code

Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I think that in visual and…
Mon, 02/19/2024 - 15:54

I think that in visual and sounds there is a button to disable collisions.

 Sorry for my english, I am using Google to translate this.