Jump to content

Recommended Posts

Posted (edited)

I'm trying to create an entity that extends Entity class. I can collide with it, but can't hit or interact with RMB. What is the problem?

 

public class ReliquaryEntity extends Entity {

    public ReliquaryEntity(PlayMessages.SpawnEntity message, Level level) {
        this(LumecoreMod.Entities.RELIQUARY.get(), level);
    }
    public ReliquaryEntity(EntityType<?> type, Level level) {
        super(type, level);
        this.blocksBuilding = true;
    }

    @Override
    public @NotNull Packet<?> getAddEntityPacket() {
        return NetworkHooks.getEntitySpawningPacket(this);
    }

    @Override
    public void defineSynchedData() {
    }

    @Override
    public void readAdditionalSaveData(@NotNull CompoundTag data) {
    }

    @Override
    public void addAdditionalSaveData(@NotNull CompoundTag data) {
    }

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

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

    @Override
    public @NotNull InteractionResult interact(Player player, InteractionHand hand) {
        System.out.println(1);
        this.kill();
        return InteractionResult.SUCCESS;
    }
}


 

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

        public static final RegistryObject<EntityType<ReliquaryEntity>> RELIQUARY = register("reliquary",
                EntityType.Builder.<ReliquaryEntity>of(ReliquaryEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true)
                        .setTrackingRange(64).setUpdateInterval(3).fireImmune().sized(0.6f, 1.8f));

        private static <T extends Entity> RegistryObject<EntityType<T>> register(String name, EntityType.Builder<T> entityTypeBuilder) {
            return ENTITY_TYPES.register(name, () -> entityTypeBuilder.build(name));
        }
    }

 

Edited by FoxBox
Posted

Entity.isPickable() controls whether a ray trace can target your entity.

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.

Posted
  On 11/20/2022 at 1:30 PM, warjort said:

Entity.isPickable() controls whether a ray trace can target your entity.

Expand  

Thanks! 

Also, is everything okay with my registration code? What confuses me is that I have to specify the mob category for a non-living entity. I didn't find any other way to register, only EntityType.Builder

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.