Jump to content

[1.16.5] .isSprinting() does not work when player is riding horse


DillaSyx

Recommended Posts

So I added a custom horse like entity which extends HorseEntity.

I want that the horse makes a fire trail if sprinting. The fire trail currenlty is triggered when inside livingTick() when gallopTime is high enough, just like the gallopSound.

I tried using the .isSprinting() on player and on the entity, but both doesn't seem like to work.

Is there a way to check if the player on the horse is sprinting, couldn't find anything that works in this case?

    public void livingTick() {

        if (!this.world.isRemote) {
            if (this.isBeingRidden()) {
                if (this.getControllingPassenger() instanceof LivingEntity) {
                    LivingEntity passenger = (LivingEntity) this.getControllingPassenger();

                    if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, this)) {
                        return;
                    }

                    int i, j, k;
                    BlockState blockstate = Blocks.FIRE.getDefaultState();

                    for(int l = 0; l < 4; ++l) {
                        i = MathHelper.floor(this.getPosX() + (double)((float)(l % 2 * 2 - 1) * 0.25F));
                        j = MathHelper.floor(this.getPosY());
                        k = MathHelper.floor(this.getPosZ() + (double)((float)(l / 2 % 2 * 2 - 1) * 0.25F));

                        BlockPos blockpos = new BlockPos(i, j, k);

                      	// TODO: CHANGE this.gallopTime > 5 && this.gallopTime % 3 == 0 TO .isSprinting() or similar
                        if (this.world.isAirBlock(blockpos) && blockstate.isValidPosition(this.world, blockpos) && this.gallopTime > 5 && this.gallopTime % 3 == 0) {
                          
                            this.world.setBlockState(blockpos, blockstate);
                        }
                    }
                }
            }
        }

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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