Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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));
}

 

 

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.