Jump to content

Recommended Posts

Posted

I'd like to move the camera freely away from player.

The solution i found is to create a dummy entity to set in minecraft.setCameraEntity(myEntity).

So i extended Entity:

public class Cameraman extends Entity {

	public Cameraman(EntityType<Cameraman> p_19870_, Level p_19871_) {
		super(p_19870_, p_19871_);
	}

	@Override
	protected void defineSynchedData() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void readAdditionalSaveData(CompoundTag p_20052_) {
		// TODO Auto-generated method stub

	}

	@Override
	protected void addAdditionalSaveData(CompoundTag p_20139_) {
		// TODO Auto-generated method stub

	}

}

then registered entity type:

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

	public static final RegistryObject<EntityType<Cameraman>> MY_ENTITY_TYPE = ENTITY_TYPES.register("cameraman", () -> EntityType.Builder.of(Cameraman::new, MobCategory.MISC).build(MODID + ":cameraman"));

	public static Cameraman cameraman;

and finally i try to instantiate my entity:

	// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
	@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
	public static class ClientModEvents {
		@SubscribeEvent
		public static void onClientSetup(FMLClientSetupEvent event) {
			//both not working
			//cameraman = MY_ENTITY_TYPE.get().create(Minecraft.getInstance().level);
			cameraman = new Cameraman(MY_ENTITY_TYPE.get(), Minecraft.getInstance().level);
		}
	}

The result is: Exception message: java.lang.NullPointerException: Registry Object not present: giacomos_prova:cameraman

It seems that i sould register the cameraman entity. How is it done?

  • 2 weeks later...

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.