Posted January 4, 20214 yr Trying to make an entity which extends upon PaintingEntity and PaintingRenderer. Getting a nullPointerException but I cannot for the life of me understand what is null. Code: ModEntities: @ObjectHolder(VanillaBoom.MOD_ID) public class ModEntities { public static final EntityType<PrismarineArrowEntity> PRISMARINE_ARROW = Utils._null(); public static final EntityType<CustomPaintingEntity> CUSTOM_PAINTING = Utils._null(); @Mod.EventBusSubscriber(modid = VanillaBoom.MOD_ID, bus = Bus.MOD) public static class RegistrationHandler { @SubscribeEvent public static void registerEntities(RegistryEvent.Register<EntityType<?>> event) { event.getRegistry().register(build(Names.PRISMARINE_ARROW, EntityType.Builder.<PrismarineArrowEntity>create(PrismarineArrowEntity::new, EntityClassification.MISC).setCustomClientFactory((spawnEntity, world) -> new PrismarineArrowEntity(PRISMARINE_ARROW, world)).size(0.5f, 0.5f))); event.getRegistry().register(build(Names.CUSTOM_PAINTING, EntityType.Builder.<CustomPaintingEntity>create(CustomPaintingEntity::new, EntityClassification.MISC).setCustomClientFactory((spawnEntity, world) -> new CustomPaintingEntity(CUSTOM_PAINTING, world)).size(0.5f, 0.5f))); } private static <T extends Entity> EntityType<T> build(String name, EntityType.Builder<T> builder) { ResourceLocation registryName = new ResourceLocation(VanillaBoom.MOD_ID, name); EntityType<T> entityType = builder.build(registryName.toString()); entityType.setRegistryName(registryName); return entityType; } } } ModRenderers: @Mod.EventBusSubscriber(modid = VanillaBoom.MOD_ID, value = Dist.CLIENT, bus = Bus.MOD) public class ModRenderers { @SubscribeEvent public static void register(FMLClientSetupEvent event) { RenderingRegistry.registerEntityRenderingHandler(ModEntities.PRISMARINE_ARROW, renderManager -> new PrismarineArrowRenderer(renderManager, new ResourceLocation(VanillaBoom.MOD_ID, "textures/entity/prismarine_arrow.png"))); RenderingRegistry.registerEntityRenderingHandler(ModEntities.CUSTOM_PAINTING, renderManager -> new PaintingRenderer(renderManager)); } } CustomPaintingEntity: public class CustomPaintingEntity extends PaintingEntity { public CustomPaintingEntity(EntityType<? extends CustomPaintingEntity> type, World world) { super(type, world); } public CustomPaintingEntity(World world, BlockPos pos, Direction facing) { super(world, pos, facing); } @OnlyIn(Dist.CLIENT) public CustomPaintingEntity(World worldIn, BlockPos pos, Direction facing, PaintingType artIn) { super(worldIn, pos, facing, artIn); } public void updateArt(PaintingType paintingType, Direction facing) { art = paintingType; updateFacingWithBoundingBox(facing); } @Override public void onBroken(@Nullable Entity brokenEntity) { if (world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { playSound(SoundEvents.ENTITY_PAINTING_BREAK, 1.0F, 1.0F); if (brokenEntity instanceof PlayerEntity) { PlayerEntity playerentity = (PlayerEntity) brokenEntity; if (playerentity.abilities.isCreativeMode) { return; } } entityDropItem(getDrop()); } } public Item getDrop() { return ModItems.SKULL_AND_ROSES_PAINTING; } @Override public EntityType<?> getType() { return ModEntities.CUSTOM_PAINTING; } @Override public IPacket<?> createSpawnPacket() { return NetworkHooks.getEntitySpawningPacket(this); } } Crashreport: https://pastebin.com/nfDxk0HV Edited January 4, 20214 yr by Godis_apan My mod for futher awesomeness: http://www.minecraftforum.net/topic/1714396-the-decopack-collection-v010-wip-made-a-signature-new-snapshot-1-screenshots-are-up-small-snapshot-1-is-out-for-147/#entry21250399
January 4, 20214 yr Author You are absolutely right, got it working perfectly now thanks! My mod for futher awesomeness: http://www.minecraftforum.net/topic/1714396-the-decopack-collection-v010-wip-made-a-signature-new-snapshot-1-screenshots-are-up-small-snapshot-1-is-out-for-147/#entry21250399
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.