Jump to content

[solved][1.17.1] is it SpriteRenderer substitute?


peanutexexe

Recommended Posts

  • peanutexexe changed the title to [1.17.1] is it SpriteRenderer substitute?

Description: Unexpected error

java.lang.NullPointerException: Cannot invoke "net.minecraft.client.renderer.entity.EntityRenderer.shouldRender(net.minecraft.world.entity.Entity, net.minecraft.client.renderer.culling.Frustum, double, double, double)" because "entityrenderer" is null
    at net.minecraft.client.renderer.entity.EntityRenderDispatcher.shouldRender(EntityRenderDispatcher.java:116) ~[forge-1.17.1-37.0.9_mapped_official_1.17.1-recomp.jar%2373!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.LevelRenderer.renderLevel(LevelRenderer.java:1053) ~[forge-1.17.1-37.0.9_mapped_official_1.17.1-recomp.jar%2373!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.GameRenderer.renderLevel(GameRenderer.java:1049) ~[forge-1.17.1-37.0.9_mapped_official_1.17.1-recomp.jar%2373!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:829) ~[forge-1.17.1-37.0.9_mapped_official_1.17.1-recomp.jar%2373!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1039) ~[forge-1.17.1-37.0.9_mapped_official_1.17.1-recomp.jar%2373!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.run(Minecraft.java:659) ~[forge-1.17.1-37.0.9_mapped_official_1.17.1-recomp.jar%2373!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.main.Main.main(Main.java:186) ~[forge-1.17.1-37.0.9_mapped_official_1.17.1-recomp.jar%2373!:?] {re:classloading,pl:runtimedistcleaner:A}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] {}
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
    at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] {}
    at net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:38) ~[fmlloader-1.17.1-37.0.9.jar%233!:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:84) [bootstraplauncher-0.1.15.jar:?] {}

Link to comment
Share on other sites

I tried code but now error

Description: Mod loading error has occurred

java.lang.Exception: Mod Loading has failed
    at net.minecraftforge.fmllegacy.CrashReportExtender.dumpModLoadingCrashReport(CrashReportExtender.java:69) ~[forge-1.17.1-37.0.12_mapped_official_1.17.1-recomp.jar%2372%2378!:?] {re:classloading}
    at net.minecraftforge.fmlclient.ClientModLoader.completeModLoading(ClientModLoader.java:183) ~[forge-1.17.1-37.0.12_mapped_official_1.17.1-recomp.jar%2372%2378!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.lambda$new$1(Minecraft.java:555) ~[forge-1.17.1-37.0.12_mapped_official_1.17.1-recomp.jar%2373!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.Util.ifElse(Util.java:361) ~[forge-1.17.1-37.0.12_mapped_official_1.17.1-recomp.jar%2373!:?] {re:classloading}
    at net.minecraft.client.Minecraft.lambda$new$2(Minecraft.java:549) ~[forge-1.17.1-37.0.12_mapped_official_1.17.1-recomp.jar%2373!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screens.LoadingOverlay.render(LoadingOverlay.java:135) ~[forge-1.17.1-37.0.12_mapped_official_1.17.1-recomp.jar%2373!:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:873) ~[forge-1.17.1-37.0.12_mapped_official_1.17.1-recomp.jar%2373!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1039) ~[forge-1.17.1-37.0.12_mapped_official_1.17.1-recomp.jar%2373!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.run(Minecraft.java:659) ~[forge-1.17.1-37.0.12_mapped_official_1.17.1-recomp.jar%2373!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.main.Main.main(Main.java:186) ~[forge-1.17.1-37.0.12_mapped_official_1.17.1-recomp.jar%2373!:?] {re:classloading,pl:runtimedistcleaner:A}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] {}
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
    at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] {}
    at net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:38) ~[fmlloader-1.17.1-37.0.12.jar%233!:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.7.jar%238!:?] {}
    at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:84) [bootstraplauncher-0.1.15.jar:?] {}


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
    at net.peanutexe.PMW.PMW.clientSetup(PMW.java:137) ~[%2377!:?] {re:classloading}
-- MOD pmw --
Details:
    Mod File: main
    Failure message: Example Mod (pmw) encountered an error during the sided_setup event phase
        java.lang.ClassCastException: class net.minecraft.client.model.geom.EntityModelSet cannot be cast to class net.minecraft.client.renderer.entity.EntityRendererProvider (net.minecraft.client.model.geom.EntityModelSet and net.minecraft.client.renderer.entity.EntityRendererProvider are in module [email protected] of loader 'TRANSFORMER' @3fc05ea2)
    Mod Version: 0.0NONE
    Mod Issue URL: NOT PROVIDED
    Exception message: java.lang.ClassCastException: class net.minecraft.client.model.geom.EntityModelSet cannot be cast to class net.minecraft.client.renderer.entity.EntityRendererProvider (net.minecraft.client.model.geom.EntityModelSet and net.minecraft.client.renderer.entity.EntityRendererProvider are in module [email protected] of loader 'TRANSFORMER' @3fc05ea2)
Stacktrace:
    at net.peanutexe.PMW.PMW.clientSetup(PMW.java:137) ~[%2377!:?] {re:classloading}
    at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:247) ~[eventbus-5.0.3.jar%237!:?] {}
    at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:239) ~[eventbus-5.0.3.jar%237!:?] {}
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-5.0.3.jar%237!:?] {}
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-5.0.3.jar%237!:?] {}
    at net.minecraftforge.fml.javafmlmod.FMLModContainer.acceptEvent(FMLModContainer.java:120) ~[javafmllanguage-1.17.1-37.0.12.jar%2374!:?] {}
    at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:121) ~[fmlcore-1.17.1-37.0.12.jar%2376!:?] {}
    at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1800) ~[?:?] {}
    at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1792) ~[?:?] {}
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:295) ~[?:?] {}
    at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016) ~[?:?] {}
    at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665) ~[?:?] {}
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598) ~[?:?] {}
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) ~[?:?] {}

 

and Main.java

package net.peanutexe.PMW;

import ca.weblite.objc.Proxy;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Game;
import net.minecraft.client.Minecraft;
import net.minecraft.client.main.GameConfig;
import net.minecraft.client.model.geom.EntityModelSet;
import net.minecraft.client.particle.ParticleEngine;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderBuffers;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.SpriteCoordinateExpander;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.entity.*;
import net.minecraft.client.renderer.entity.layers.RenderLayer;
import net.minecraft.client.renderer.texture.Stitcher;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.PreparableReloadListener;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.Snowball;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.model.ItemLayerModel;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fmlclient.registry.ClientRegistry;
import net.minecraftforge.fmlserverevents.FMLServerStartingEvent;
import net.peanutexe.PMW.Items.Entity.FMJ556En;
import net.peanutexe.PMW.registry.*;
import net.peanutexe.PMW.util.Gun556LeftClickPacket;
import net.peanutexe.PMW.util.PacketHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.awt.image.renderable.RenderContext;
import java.rmi.registry.Registry;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import static com.ibm.icu.lang.UCharacter.GraphemeClusterBreak.T;

// The value here should match an entry in the META-INF/mods.toml file
@Mod("pmw")
public class PMW
{
    // Directly reference a log4j LOGGER.
    public static final Logger LOGGER = LogManager.getLogger();
    public static final String MOD_ID = "pmw";

    public PMW() {
        // Register the setup method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        // Register the enqueueIMC method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
        // Register the processIMC method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);

        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);

        init();


        // Register ourselves for server and other game events we are interested in
        MinecraftForge.EVENT_BUS.register(this);
    }

    @Mod.EventBusSubscriber(modid = PMW.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
    public static class EventListener {
        @SubscribeEvent
        public static void emptyLeftClick(PlayerInteractEvent.LeftClickEmpty event)
        {
            PacketHandler.HANDLER.sendToServer(new Gun556LeftClickPacket());
        }
    }

    private void init() {
        BulletRegistry.init();
        GunRegistry.init();
        EntityList.init();
        HealRegistry.init();
    }

    private void setup(final FMLCommonSetupEvent event) {
        // some preinit code
        LOGGER.info("HELLO FROM PREINIT");
        LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
        PacketHandler.register();
    }

    /*public static final CreativeModeTab Heal_Tab = new CreativeModeTab("heal_tab") {
        @Override
        public ItemStack makeIcon() {
            return new ItemStack(HealRegistry.SALEWA.get());
        }
    };*/

    public static final CreativeModeTab Assault_Tab = new CreativeModeTab("assault_tab") {
        @Override
        public ItemStack makeIcon() {
            return new ItemStack(GunRegistry.HK416.get());
        }
    };

    /*public static final CreativeModeTab Carbine_Tab = new CreativeModeTab("carbine_tab") {
        @Override
        public ItemStack makeIcon() {
            return new ItemStack(GunRegistry.M4A1.get());
        }
    };*/

    public static final CreativeModeTab BulletGroup = new CreativeModeTab("bullet_tab") {
        @Override
        public ItemStack makeIcon() {
            return new ItemStack(BulletRegistry.FMJ556.get());
        }
    };


    private void clientSetup(final FMLClientSetupEvent event) {
        Supplier<Minecraft> minecraft = Minecraft::getInstance;
        EntityRendererProvider<FMJ556En> renderers = (EntityRendererProvider<FMJ556En>) minecraft.get().getEntityModels();
        event.enqueueWork(() -> EntityRenderers.register(EntityList.FMJ556Entity.get(), renderers));
    }

    private void enqueueIMC(final InterModEnqueueEvent event) {
        // some example code to dispatch IMC to another mod
        InterModComms.sendTo("examplemod", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
    }

    private void processIMC(final InterModProcessEvent event) {
        // some example code to receive and process InterModComms from other mods
        LOGGER.info("Got IMC {}", event.getIMCStream().
                map(m->m.getMessageSupplier().get()).
                collect(Collectors.toList()));
    }
    // You can use SubscribeEvent and let the Event Bus discover methods to call
    @SubscribeEvent
    public void onServerStarting(FMLServerStartingEvent event) {
        // do something when the server starts
        LOGGER.info("HELLO from server starting");
    }

    // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
    // Event bus for receiving Registry Events)
    @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
    public static class RegistryEvents {
        @SubscribeEvent
        public void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
            // register a new block here
            LOGGER.info("HELLO from Register Block");
        }
    }
}

FMJ556En.java

package net.peanutexe.PMW.Entity;

import net.minecraft.network.protocol.Packet;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.Item;
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraftforge.fmllegacy.network.NetworkHooks;
import net.peanutexe.PMW.registry.BulletRegistry;
import net.peanutexe.PMW.registry.EntityList;

public class FMJ556En extends ThrowableItemProjectile {
    public static final float BASE_SPEED = 20F;
    public static final int TICKS = 1;

    public FMJ556En(EntityType<FMJ556En> p_37432_, Level world) {
        super(p_37432_, world);
    }

    public FMJ556En(LivingEntity entity, Level world) {
        super(EntityList.FMJ556Entity.get(), entity, world);
    }

    public FMJ556En(double x, double y, double z, Level world) {
        super(EntityList.FMJ556Entity.get(), x, y, z, world);
    }

    @Override
    protected Item getDefaultItem() {
        return BulletRegistry.BULLET_DEFAULT.get().asItem();
    }

    /*@Override
    protected void onImpact(RayTraceResult result) {

        if (result.getType() == RayTraceResult.Type.ENTITY) {
            Entity entity = ((EntityRayTraceResult) result).getEntity();
            int damage = 2;

            entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getEntity()), (float) damage);
        }
        if (!world.isRemote) {
            this.remove();
        }
    }*/

    @Override
    protected void onHit(HitResult p_37260_) {
        if (p_37260_.getType() == HitResult.Type.ENTITY) {
            Entity entity = ((EntityHitResult) p_37260_).getEntity();
            double damage = 1.5;
            entity.hurt(DamageSource.thrown(this, this.getOwner()), (float) damage);
        }
        if (!level.isClientSide) {
            this.remove(true);
        }
    }

    @Override
    public Packet<?> getAddEntityPacket() {
        return NetworkHooks.getEntitySpawningPacket(this);
    }
}

EntityList.java

package net.peanutexe.PMW.registry;

import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fmllegacy.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.peanutexe.PMW.Entity.FMJ556En;
import net.peanutexe.PMW.PMW;

public class EntityList {

    public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, PMW.MOD_ID);

    public static void init() {
        ENTITIES.register(FMLJavaModLoadingContext.get().getModEventBus());
    }

    public static final RegistryObject<EntityType<FMJ556En>> FMJ556Entity = ENTITIES.register(
            "fmj556_en",
            () -> EntityType.Builder
                    .<FMJ556En>of(FMJ556En::new, MobCategory.MISC)
                    .sized(0.25f, 0.25f)
                    .build("fmj556_en"));
}

 

Edited by peanutexexe
Link to comment
Share on other sites

  • peanutexexe changed the title to [solved][1.17.1] is it SpriteRenderer substitute?

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.