Jump to content

Recommended Posts

Posted (edited)

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 by Godis_apan

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.