Immovable/Unpushable Entity? [Solved somewhat]

Started by TheReallyFatChicken on

Topic category: Help with modding (Java Edition)

Last seen on 22:49, 17. Mar 2021
Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Immovable/Unpushable Entity? [Solved somewhat]
Thu, 07/16/2020 - 17:42 (edited)

So, I was wondering if there's a way to create a block-locked entity that cannot be pushed around. I can easily make it so it doesn't move on its own, but the player can still shove it, which is bad (It's pretty much a demon plant/flower that's supposed to be "rooted down").

Edit: You can have an On Entity Tick Update with Run Command data merge entity @s {NoAI:1}, which makes it immovable but also unable to move at all.

Edited by TheReallyFatChicken on Thu, 07/16/2020 - 17:42
Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If you know how to code,…
Tue, 06/09/2020 - 22:43

If you know how to code, override;

EntityLiving::canBePushed

and set it false.

Last seen on 22:49, 17. Mar 2021
Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I could easily find that,…
Wed, 06/17/2020 - 19:46

I could easily find that, but do I just do EntityLiving::canBePushed:false or something like that? I'm not the best at coding.

 

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
There are two methods that…
Wed, 06/17/2020 - 19:57

There are two methods that you can use to achieve this;

    @Override
    public boolean canBePushed() {
        return false;
    }

    @Override
    public boolean canBeCollidedWith() {
        return false;
    }

The method LivingEntity::canBePushed returns true if you want the entity to push and be pushed by other entities.

 

The method LivingEntity::canBeCollidedWith returns true if you want the entity to not be able to go through the entity.

 

You can use both, it is up to you. Return false if you don't want the above descriptions to happen.

Last seen on 22:49, 17. Mar 2021
Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The first one doesn't seem…
Thu, 07/16/2020 - 14:22

The first one doesn't seem to be working for me.