Posted July 9, 20232 yr 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?
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.