Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.