Jump to content

[1.19] Not able to interact with entity


limexplosion7

Recommended Posts

Hello. I'm making a vehicle entity. The class is barebones but I can't get the interact() to work properly. I have a simple print line but it's not being called.

 

Entity class:

Spoiler
// package & imports

@ParametersAreNonnullByDefault
public class CaveSuitEntity extends Entity
{
    public CaveSuitEntity(EntityType<CaveSuitEntity> type, Level level)
    {
        super(type, level);
        blocksBuilding = true;
    }

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

    @Override
    public boolean isPushable()
    {
        return !isVehicle();
    }

    @Override
    public @NotNull InteractionResult interact(Player player, InteractionHand hand)
    {
        System.out.println("Interact test");

        return InteractionResult.PASS;
    }

    @Override
    public @Nullable Entity getControllingPassenger()
    {
        return getFirstPassenger();
    }

    @Override
    protected void defineSynchedData()
    {
    }

    @Override
    protected void readAdditionalSaveData(CompoundTag tag)
    {
    }

    @Override
    protected void addAdditionalSaveData(CompoundTag tag)
    {
    }

    public @NotNull Packet<?> getAddEntityPacket()
    {
        return new ClientboundAddEntityPacket(this);
    }
}

 

 

And the registration if it helps:

Spoiler
// Package & imports

public class LimaTechEntities
{
    private static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, LimaTech.MODID);

    public static void init(IEventBus bus)
    {
        ENTITY_TYPES.register(bus);
    }

    public static List<EntityType<?>> getAllEntityTypes()
    {
        return ENTITY_TYPES.getEntries().stream().map(RegistryObject::get).collect(Collectors.toList());
    }

    public static final RegistryObject<EntityType<CaveSuitEntity>> cave_suit = ENTITY_TYPES.register(LimaTechIds.CAVE_SUIT,
            () -> EntityType.Builder.of(CaveSuitEntity::new, MobCategory.MISC)
                    .sized(1.25f, 2.625f)
                    .clientTrackingRange(10)
                    .fireImmune()
                    .build(LimaTechIds.CAVE_SUIT));

    public static final RegistryObject<EntityType<OrbMineEntity>> orb_mine = ENTITY_TYPES.register(LimaTechIds.ORB_MINE,
            () -> EntityType.Builder.of(OrbMineEntity::new, MobCategory.MISC)
                    .sized(0.4f, 0.4f)
                    .clientTrackingRange(10)
                    .updateInterval(20)
                    .fireImmune()
                    .noSummon()
                    .build(LimaTechIds.ORB_MINE));
}

 

 

Link to comment
Share on other sites

Entity.isPickable() - controls whether the ray trace hits your entity - see GameRenderer.pick()

It is false by default, i.e. it is opt in

You can see which entity is "picked" if you press F3 to show the debug screen.

 

Unless you know what you are doing, I suggest you start with the Boat or Minecart as a reference.

Doing it from scratch and getting it right will be difficult with all the ad hoc policy methods an entity has.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

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.