Jump to content

Recommended Posts

Posted

Hi,

I’m trying to make a custom minecart entity but it has some strange behavior: whenever I spawn one on rails, it stutters; it moves for a bit then jumps forward, then moves a bit again and so on. But if the class inherits MinecartEntity, it works as it should.

I don’t understand why.

Here’s how I declare my entity class:

public class TestMinecartEntity extends AbstractMinecartEntity {
  public TestMinecartEntity(EntityType<?> type, World world) {
    super(type, world);
  }

  public TestMinecartEntity(World world, double x, double y, double z) {
    super(ModEntities.TEST_MINECART.get(), world, x, y, z);
  }

  @Override
  public ActionResultType processInitialInteract(PlayerEntity player, Hand hand) {
    if (player.isSecondaryUseActive() || this.isBeingRidden()) {
      return ActionResultType.PASS;
    } else if (!this.world.isRemote) {
      return player.startRiding(this) ? ActionResultType.CONSUME : ActionResultType.PASS;
    } else {
      return ActionResultType.SUCCESS;
    }
  }

  @Override
  public Type getMinecartType() {
    return Type.RIDEABLE;
  }

  @Override
  public IPacket<?> createSpawnPacket() {
    return NetworkHooks.getEntitySpawningPacket(this);
  }
}

The entity type definition:

public class ModEntities {
  public static final RegistryObject<EntityType<TestMinecartEntity>> TEST_MINECART = REGISTER.register(
      "test_minecart",
      () -> EntityType.Builder.<TestMinecartEntity>create(TestMinecartEntity::new, EntityClassification.MISC)
          .size(0.98f, 0.98f)
          .trackingRange(10)
          .updateInterval(10)
          .immuneToFire()
          .build("test_minecart")
  );
}

Am I missing something here? Is there some vanilla code that might cause this behavior?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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