Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.3] Dedicated Server Crash on Start


jstN0body
 Share

Recommended Posts

I can't run my mod on a dedicated server because of this? Is there any way to fix this?

java.lang.RuntimeException: Attempted to load class net/minecraft/client/renderer/entity/PlayerRenderer for invalid dist DEDICATED_SERVER
        at net.minecraftforge.fml.loading.RuntimeDistCleaner.processClassWithFlags(RuntimeDistCleaner.java:71) ~[forge.jar:34.1] {}
        at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:85) ~[modlauncher-7.0.1.jar:?] {}
        at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:119) ~[modlauncher-7.0.1.jar:?] {}
        at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:256) ~[modlauncher-7.0.1.jar:?] {}
        at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:135) ~[modlauncher-7.0.1.jar:?] {re:classloading}
        at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:97) ~[modlauncher-7.0.1.jar:?] {re:classloading}
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_271] {}
        at java.lang.Class.getDeclaredConstructors0(Native Method) ~[?:1.8.0_271] {}
        at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) ~[?:1.8.0_271] {}
        at java.lang.Class.getConstructor0(Unknown Source) ~[?:1.8.0_271] {}
        at java.lang.Class.getConstructor(Unknown Source) ~[?:1.8.0_271] {}
        at net.minecraftforge.eventbus.api.EventListenerHelper.computeListenerList(EventListenerHelper.java:96) ~[eventbus-3.0.3-service.jar:?] {}
        at net.minecraftforge.eventbus.api.EventListenerHelper.getListenerListInternal(EventListenerHelper.java:63) ~[eventbus-3.0.3-service.jar:?] {}
        at net.minecraftforge.eventbus.api.EventListenerHelper.getListenerList(EventListenerHelper.java:48) ~[eventbus-3.0.3-service.jar:?] {}
        at net.minecraftforge.eventbus.EventBus.addToListeners(EventBus.java:263) ~[eventbus-3.0.3-service.jar:?] {}
        at net.minecraftforge.eventbus.EventBus.register(EventBus.java:256) ~[eventbus-3.0.3-service.jar:?] {}
        at net.minecraftforge.eventbus.EventBus.registerListener(EventBus.java:150) ~[eventbus-3.0.3-service.jar:?] {}
        at net.minecraftforge.eventbus.EventBus.lambda$null$6(EventBus.java:98) ~[eventbus-3.0.3-service.jar:?] {}
        at java.util.Optional.ifPresent(Unknown Source) ~[?:1.8.0_271] {}
        at net.minecraftforge.eventbus.EventBus.lambda$registerObject$7(EventBus.java:98) ~[eventbus-3.0.3-service.jar:?] {}
        at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source) ~[?:1.8.0_271] {}
        at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) ~[?:1.8.0_271] {}
        at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source) ~[?:1.8.0_271] {}
        at java.util.stream.AbstractPipeline.copyInto(Unknown Source) ~[?:1.8.0_271] {}
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) ~[?:1.8.0_271] {}
        at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source) ~[?:1.8.0_271] {}
        at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source) ~[?:1.8.0_271] {}
        at java.util.stream.AbstractPipeline.evaluate(Unknown Source) ~[?:1.8.0_271] {}
        at java.util.stream.ReferencePipeline.forEach(Unknown Source) ~[?:1.8.0_271] {}
        at net.minecraftforge.eventbus.EventBus.registerObject(EventBus.java:94) ~[eventbus-3.0.3-service.jar:?] {}
        at net.minecraftforge.eventbus.EventBus.register(EventBus.java:120) ~[eventbus-3.0.3-service.jar:?] {}
        at com.github.jstN0body.shrinkmod.SizeMod.<init>(SizeMod.java:58) ~[?:1.0] {re:classloading}
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_271] {}
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_271] {}
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_271] {}
        at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_271] {}
        at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_271] {}
        at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:81) ~[?:34.1] {re:classloading}
        at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$5(ModContainer.java:111) ~[?:?] {re:classloading}
        at java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source) [?:1.8.0_271] {}
        at java.util.concurrent.CompletableFuture$AsyncRun.exec(Unknown Source) [?:1.8.0_271] {}
        at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) [?:1.8.0_271] {}
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source) [?:1.8.0_271] {}
        at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) [?:1.8.0_271] {}
        at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) [?:1.8.0_271] {}
[m[1;31m[19:05:24] [main/FATAL] [ne.mi.fm.ModLoader/LOADING]: Failed to complete lifecycle event CONSTRUCT, 1 errors found
[m[32m[19:05:24] [main/INFO] [STDOUT/]: [net.minecraft.crash.CrashReport:func_85057_a:196]: Negative index in crash report handler (16/18)
[m[1;31m[19:05:24] [main/FATAL] [ne.mi.fm.se.ServerModLoader/]: Crash report saved to .\crash-reports\crash-2020-11-09_19.05.24-fml.txt
[m---- Minecraft Crash Report ----
// This doesn't make any sense!

Time: 11/9/20 7:05 PM
Description: Mod loading error has occurred

java.lang.Exception: Mod Loading has failed
        at net.minecraftforge.fml.CrashReportExtender.dumpModLoadingCrashReport(CrashReportExtender.java:85) ~[?:?] {re:classloading}
        at net.minecraftforge.fml.server.ServerModLoader.load(ServerModLoader.java:51) ~[?:?] {re:classloading}
        at net.minecraft.server.Main.main(Main.java:96) ~[?:?] {re:classloading}
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_271] {}
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_271] {}
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_271] {}
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_271] {}
        at net.minecraftforge.fml.loading.FMLServerLaunchProvider.lambda$launchService$0(FMLServerLaunchProvider.java:51) ~[forge.jar:34.1] {}
        at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-7.0.1.jar:?] {}
        at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-7.0.1.jar:?] {}
        at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-7.0.1.jar:?] {}
        at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-7.0.1.jar:?] {}
        at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-7.0.1.jar:?] {}
        at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63) [forge.jar:?] {}
        at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60) [forge.jar:?] {}
        at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) [forge.jar:?] {}

 

Link to comment
Share on other sites

8 minutes ago, poopoodice said:

Attempted to load class net/minecraft/client/renderer/entity/PlayerRenderer for invalid dist DEDICATED_SERVER

https://mcforge.readthedocs.io/en/latest/concepts/sides/

You should also post all your code

Currently reading the docs, here's the code of the class where I'm getting the error just in case:

@Mod(SizeMod.MODID)
public class SizeMod {
    // Directly reference a log4j logger.
    private static final Logger LOGGER = LogManager.getLogger();

    public static final String MODID = "sizemod";
    public static final String VERSION = "1.0.0";

    public static float sizePercentage = 1.0f;


    public SizeMod() {


        // 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);
        // Register the doClientStuff method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);


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

    private void setup(final FMLCommonSetupEvent event)
    {
        // some preinit code

    }

    private void doClientStuff(final FMLClientSetupEvent event) {
        // do something that can only be done on the client

    }

    private void enqueueIMC(final InterModEnqueueEvent event)
    {
        // some example code to dispatch IMC to another mod

    }

    private void processIMC(final InterModProcessEvent event)
    {
        // some example code to receive and process InterModComms from other mods

    }

    // You can use SubscribeEvent and let the Event Bus discover methods to call
    @SubscribeEvent
    public void onServerStarting(FMLServerStartingEvent event) {
        ModCommands.register(event.getServer().getCommandManager().getDispatcher());
    }

    @SubscribeEvent
    public void onSizeChange(PlayerEvent.Size event) {

        if (event.getEntity() instanceof PlayerEntity) {
            EntitySize newSize;
            switch (event.getPose()) {
                case CROUCHING:
                    newSize = EntitySize.fixed(0.6f * sizePercentage, 1.5f * sizePercentage);
                    break;

                case SWIMMING:
                case FALL_FLYING:
                    newSize = EntitySize.fixed(0.6f * sizePercentage, 0.6f * sizePercentage);
                    break;

                case SLEEPING:
                    newSize = EntitySize.fixed(0.2f * sizePercentage, 0.2f * sizePercentage);
                    break;

                default:
                    newSize = EntitySize.fixed(0.6f * sizePercentage, 1.8f * sizePercentage);
            }
            event.setNewSize(newSize);
            event.setNewEyeHeight(newSize.height * 0.9f);
        }
    }

    @SubscribeEvent
    public void preRenderPlayer(RenderPlayerEvent.Pre event) {
        event.getMatrixStack().push();
        event.getMatrixStack().scale(sizePercentage, sizePercentage, sizePercentage);
    }

    @SubscribeEvent
    public void postRenderPlayer(RenderPlayerEvent.Post event) {
        event.getMatrixStack().pop();
    }

    @SubscribeEvent
    public void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
        if (!(event.getEntity() instanceof PlayerEntity)) return;

        SizeMod.sizePercentage -= 0.01;
        for (ServerPlayerEntity player : event.getPlayer().getServer().getPlayerList().getPlayers()) {
            player.setBoundingBox(AxisAlignedBB.func_241550_g_(0.6, 1.8, 0.6));
            player.sendStatusMessage(new TranslationTextComponent("Your size is now: " +
                    new DecimalFormat("0.00").format(SizeMod.sizePercentage*100) + "%"), true);
        }
    }

    int hunger;
    float saturation;
    @SubscribeEvent
    public void startPlayerEat(LivingEntityUseItemEvent.Start event) {
        if (event.getItem().isFood() && event.getEntity() instanceof PlayerEntity) {
            PlayerEntity player = (PlayerEntity) event.getEntity();
            FoodStats foodStats = player.getFoodStats();
            hunger = foodStats.getFoodLevel();
            saturation = foodStats.getSaturationLevel();
        }
    }

    @SubscribeEvent
    public void finishPlayerEat(LivingEntityUseItemEvent.Finish event) {
        if (event.getItem().isFood() && event.getEntity() instanceof PlayerEntity) {
            PlayerEntity player = (PlayerEntity) event.getEntity();
            FoodStats foodStats = player.getFoodStats();
            hunger = foodStats.getFoodLevel() - hunger;
            saturation = foodStats.getSaturationLevel() - saturation;
            hunger *= (1 - sizePercentage);
            saturation *= (1 - sizePercentage);
            foodStats.addStats(Math.round(hunger), saturation);
        }
    }

    // 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 static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
            // register a new block here

        }
    }
}

 

Link to comment
Share on other sites

@Mod(SizeMod.MODID)
public class SizeMod {
    // Directly reference a log4j logger.
    private static final Logger LOGGER = LogManager.getLogger();

    public static final String MODID = "sizemod";
    public static final String VERSION = "1.1.2";

    public static float sizePercentage = 1.0f;


    public SizeMod() {

        // 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);
        // Register the doClientStuff method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);

        ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.DISPLAYTEST, () -> Pair.of(() -> FMLNetworkConstants.IGNORESERVERONLY, (a, b) -> true));

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

    private void setup(final FMLCommonSetupEvent event)
    {
        // some preinit code
    }

    private void doClientStuff(final FMLClientSetupEvent event) {
        // do something that can only be done on the client

    }

    private void enqueueIMC(final InterModEnqueueEvent event)
    {
        // some example code to dispatch IMC to another mod
    }

    private void processIMC(final InterModProcessEvent event)
    {
        // some example code to receive and process InterModComms from other mods
    }


    @SubscribeEvent
    public void onServerStarting(FMLServerStartingEvent event) {
        ModCommands.register(event.getServer().getCommandManager().getDispatcher());
    }


    @SubscribeEvent
    public void onSizeChange(PlayerEvent.Size event) {

        if (event.getEntity() instanceof PlayerEntity) {
            EntitySize newSize;
            switch (event.getPose()) {
                case CROUCHING:
                    newSize = EntitySize.fixed(0.6f * sizePercentage, 1.5f * sizePercentage);
                    break;

                case SWIMMING:
                case FALL_FLYING:
                    newSize = EntitySize.fixed(0.6f * sizePercentage, 0.6f * sizePercentage);
                    break;

                case SLEEPING:
                    newSize = EntitySize.fixed(0.2f * sizePercentage, 0.2f * sizePercentage);
                    break;

                default:
                    newSize = EntitySize.fixed(0.6f * sizePercentage, 1.8f * sizePercentage);
            }
            event.setNewSize(newSize);
            event.setNewEyeHeight(newSize.height * 0.9f);
        }
    }

    @OnlyIn(Dist.CLIENT)
    @SubscribeEvent
    public void preRenderPlayer(RenderPlayerEvent.Pre event) {
        event.getMatrixStack().push();
        event.getMatrixStack().scale(sizePercentage, sizePercentage, sizePercentage);
    }

    @OnlyIn(Dist.CLIENT)
    @SubscribeEvent
    public void postRenderPlayer(RenderPlayerEvent.Post event) {
        event.getMatrixStack().pop();
    }


    @SubscribeEvent
    public void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
        if (!(event.getEntity() instanceof PlayerEntity)) return;

        SizeMod.sizePercentage -= 0.01;
        for (ServerPlayerEntity player : event.getPlayer().getServer().getPlayerList().getPlayers()) {
            player.setBoundingBox(AxisAlignedBB.func_241550_g_(0.6, 1.8, 0.6));
            player.sendStatusMessage(new TranslationTextComponent("Your size is now: " +
                    new DecimalFormat("0.00").format(SizeMod.sizePercentage*100) + "%"), true);
        }
    }

    int hunger;
    float saturation;
    @SubscribeEvent
    public void startPlayerEat(LivingEntityUseItemEvent.Start event) {
        if (event.getItem().isFood() && event.getEntity() instanceof PlayerEntity) {
            PlayerEntity player = (PlayerEntity) event.getEntity();
            FoodStats foodStats = player.getFoodStats();
            hunger = foodStats.getFoodLevel();
            saturation = foodStats.getSaturationLevel();
        }
    }

    @SubscribeEvent
    public void finishPlayerEat(LivingEntityUseItemEvent.Finish event) {
        if (event.getItem().isFood() && event.getEntity() instanceof PlayerEntity) {
            PlayerEntity player = (PlayerEntity) event.getEntity();
            FoodStats foodStats = player.getFoodStats();
            hunger = foodStats.getFoodLevel() - hunger;
            saturation = foodStats.getSaturationLevel() - saturation;
            hunger *= (1 - sizePercentage);
            saturation *= (1 - sizePercentage);
            foodStats.addStats(Math.round(hunger), saturation);
        }
    }

    // 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 static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
            // register a new block here

        }
    }
}

 

Link to comment
Share on other sites

By the way:

This:

On 11/9/2020 at 6:36 PM, jstN0body said:

        // 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);
        // Register the doClientStuff method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);

And this:

Quote

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

Do the exact same thing, just in a different way. @EventBusSubscriber also does this. Th only difference is that there are two different busses (the mod bus and the forge bus) and one of them is for FML events ("life cycle events" which are on the mod event bus) and the rest are for game events (the forge event bus). You should use two different classes for the two different types of events, separating out all the client stuff to another third (and possibly fourth) class.

 

And personally I'd use the @EventBusSubscriber annotation, because then it's very easy to tell what bus a given set of events is for.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Howdy

 

You might get some inspiration from this class, it shows the method I've used to make the example mod work with Dedicated Server:

https://github.com/TheGreyGhost/MinecraftByExample/blob/master/src/main/java/minecraftbyexample/MinecraftByExample.java

 

The key bits are:

 

    
@Mod(MinecraftByExample.MODID)
public class MinecraftByExample {

  public MinecraftByExample() {
	// We need to split the registration of events into:
    // 1) "Common" events that are executed on a dedicated server and also on an integrated client + server installation
    // 2) "Client only" events that are not executed on a dedicated server.
    // If you aren't careful to split these into two parts, your mod will crash when installed on a dedicated server
    // It doesn't matter if your client-only code is never actually called; simply referencing the class is often enough to
    //   cause a crash.

    registerCommonEvents();
    DistExecutor.runWhenOn(Dist.CLIENT, () -> MinecraftByExample::registerClientOnlyEvents);
  }
}
  public static void registerCommonEvents() {
    MOD_EVENT_BUS.register(minecraftbyexample.mbe01_block_simple.StartupCommon.class);
  }

  public static void registerClientOnlyEvents() {
    MOD_EVENT_BUS.register(minecraftbyexample.mbe01_block_simple.StartupClientOnly.class);
  }


public class StartupCommon
{
  public static BlockSimple blockSimple;  // this holds the unique instance of your block
  public static BlockItem itemBlockSimple;  // this holds the unique instance of the ItemBlock corresponding to your block

  @SubscribeEvent
  public static void onBlocksRegistration(final RegistryEvent.Register<Block> blockRegisterEvent) {
    blockSimple = (BlockSimple)(new BlockSimple().setRegistryName("minecraftbyexample", "mbe01_block_simple_registry_name"));
    blockRegisterEvent.getRegistry().register(blockSimple);
  }
}
    
public class StartupClientOnly
{
  /**
   * Tell the renderer this is a solid block
   * @param event
   */
  @SubscribeEvent
  public static void onClientSetupEvent(FMLClientSetupEvent event) {
    RenderTypeLookup.setRenderLayer(StartupCommon.blockSimple, RenderType.getSolid());
  }
}

 

Link to comment
Share on other sites

Ok, I moved the render events to a class called Render, but I still have the same problem where I shrink for a split second and go back to normal. It works fine singleplayer, just not on a server. I can however, change my size in singleplayer and then connect to the server and remain that same size. Any ideas on what's happening?

@Mod(SizeMod.MODID)
public class SizeMod {
    // Directly reference a log4j logger.
    private static final Logger LOGGER = LogManager.getLogger();

    public static final String MODID = "sizemod";
    public static final String VERSION = "1.1.2";

    public static float sizePercentage = 1.0f;


    public SizeMod() {

        // 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);
        // Register the doClientStuff method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);

        ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.DISPLAYTEST, () -> Pair.of(() -> FMLNetworkConstants.IGNORESERVERONLY, (a, b) -> true));

        DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> Render::new);

        MinecraftForge.EVENT_BUS.register(this);
    }

    private void setup(final FMLCommonSetupEvent event)
    {
        // some preinit code
    }

    private void doClientStuff(final FMLClientSetupEvent event) {

    }

    private void enqueueIMC(final InterModEnqueueEvent event)
    {
        // some example code to dispatch IMC to another mod
    }

    private void processIMC(final InterModProcessEvent event)
    {
        // some example code to receive and process InterModComms from other mods
    }


    @SubscribeEvent
    public void onServerStarting(FMLServerStartingEvent event) {
        ModCommands.register(event.getServer().getCommandManager().getDispatcher());
    }

    @SubscribeEvent
    public void onSizeChange(PlayerEvent.Size event) {

        if (event.getEntity() instanceof PlayerEntity) {
            EntitySize newSize;
            switch (event.getPose()) {
                case CROUCHING:
                    newSize = EntitySize.fixed(0.6f * sizePercentage, 1.5f * sizePercentage);
                    break;

                case SWIMMING:
                case FALL_FLYING:
                    newSize = EntitySize.fixed(0.6f * sizePercentage, 0.6f * sizePercentage);
                    break;

                case SLEEPING:
                    newSize = EntitySize.fixed(0.2f * sizePercentage, 0.2f * sizePercentage);
                    break;

                default:
                    newSize = EntitySize.fixed(0.6f * sizePercentage, 1.8f * sizePercentage);
            }
            event.setNewSize(newSize);
            event.setNewEyeHeight(newSize.height * 0.9f);
        }
    }


    @SubscribeEvent
    public void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
        if (!(event.getEntity() instanceof PlayerEntity)) return;

        SizeMod.sizePercentage -= 0.01;
        for (ServerPlayerEntity player : event.getPlayer().getServer().getPlayerList().getPlayers()) {
            player.setBoundingBox(AxisAlignedBB.func_241550_g_(0.6, 1.8, 0.6));
            player.sendStatusMessage(new TranslationTextComponent("Your size is now: " +
                    new DecimalFormat("0.00").format(SizeMod.sizePercentage*100) + "%"), true);
        }
    }

    int hunger;
    float saturation;
    @SubscribeEvent
    public void startPlayerEat(LivingEntityUseItemEvent.Start event) {
        if (event.getItem().isFood() && event.getEntity() instanceof PlayerEntity) {
            PlayerEntity player = (PlayerEntity) event.getEntity();
            FoodStats foodStats = player.getFoodStats();
            hunger = foodStats.getFoodLevel();
            saturation = foodStats.getSaturationLevel();
        }
    }

    @SubscribeEvent
    public void finishPlayerEat(LivingEntityUseItemEvent.Finish event) {
        if (event.getItem().isFood() && event.getEntity() instanceof PlayerEntity) {
            PlayerEntity player = (PlayerEntity) event.getEntity();
            FoodStats foodStats = player.getFoodStats();
            hunger = foodStats.getFoodLevel() - hunger;
            saturation = foodStats.getSaturationLevel() - saturation;
            hunger *= (1 - sizePercentage);
            saturation *= (1 - sizePercentage);
            foodStats.addStats(Math.round(hunger), saturation);
        }
    }

    // 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 static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
            // register a new block here

        }
    }
}
public class Render {

    public Render() {
        MinecraftForge.EVENT_BUS.register(this);
    }

    @SubscribeEvent
    public void preRenderPlayer(RenderPlayerEvent.Pre event) {
        event.getMatrixStack().push();
        event.getMatrixStack().scale(SizeMod.sizePercentage, SizeMod.sizePercentage, SizeMod.sizePercentage);
    }

    @SubscribeEvent
    public void postRenderPlayer(RenderPlayerEvent.Post event) {
        event.getMatrixStack().pop();
    }
}

 

Link to comment
Share on other sites

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

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • When i run data i get this error  Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:39)     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53)     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71)     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.Launcher.run(Launcher.java:106)     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.Launcher.main(Launcher.java:77)     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26)     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23)     at cpw.mods.bootstraplauncher@0.1.17/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:90) Caused by: java.lang.reflect.InvocationTargetException     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.base/java.lang.reflect.Method.invoke(Method.java:568)     at MC-BOOTSTRAP/fmlloader@1.18-38.0.16/net.minecraftforge.fml.loading.targets.ForgeDataUserdevLaunchHandler.lambda$launchService$0(ForgeDataUserdevLaunchHandler.java:41)     at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)     ... 7 more Caused by: net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [     fml.modloading.failedtoloadmod ]     at LAYER PLUGIN/fmlcore@1.18-38.0.16/net.minecraftforge.fml.ModLoader.waitForTransition(ModLoader.java:235)     at LAYER PLUGIN/fmlcore@1.18-38.0.16/net.minecraftforge.fml.ModLoader.lambda$dispatchAndHandleError$21(ModLoader.java:200)     at java.base/java.util.Optional.ifPresent(Optional.java:178)     at LAYER PLUGIN/fmlcore@1.18-38.0.16/net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:200)     at LAYER PLUGIN/fmlcore@1.18-38.0.16/net.minecraftforge.fml.ModLoader.lambda$gatherAndInitializeMods$11(ModLoader.java:177)     at java.base/java.lang.Iterable.forEach(Iterable.java:75)     at LAYER PLUGIN/fmlcore@1.18-38.0.16/net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:177)     at TRANSFORMER/forge@38.0.16/net.minecraftforge.data.loading.DatagenModLoader.begin(DatagenModLoader.java:52)     at TRANSFORMER/minecraft@1.18/net.minecraft.data.Main.main(Main.java:65)     ... 13 more Caused by: java.lang.reflect.InvocationTargetException Caused by: net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [ > Task :runData FAILED :runData (Thread[Execution worker for ':',5,main]) completed. Took 38.808 secs. Execution failed for task ':runData'. > Process 'command '/Users/YusufIsmail/Library/Java/JavaVirtualMachines/corretto-17.0.1/Contents/Home/bin/java'' finished with non-zero exit value 1   The full log is  https://gist.github.com/RealYusufIsmail/f598cbf87bee3923f665ec3ebfff1932 and the build.gradle is here https://github.com/Dungeon-Makers/Armour-and-Item/blob/V2/1.18/build.gradle
    • im trying to run a modern rlcraft server but it wont even start. this is the log C:\Users\soto5\Downloads\Modern+RLCraft+Server+Pack-1.12.2-1.5.2\Modern RLCraft Server Pack-1.12.2-1.5.1>java -Xmx4096M -Xms4096M -jar forge.jar nogui A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)         at java.base/java.lang.reflect.Method.invoke(Method.java:567)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:70)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34) Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')         at net.minecraft.launchwrapper.Launch.<init>(Launch.java:34)         at net.minecraft.launchwrapper.Launch.main(Launch.java:28)         ... 6 more    
    • Is there a way to "override" an entity's texture to something else without creating a "dummy" item when using ThrownItemRenderer? I tried creating a Renderer that extends it with a ResourceLocation override but this does not change the entity's 2D texture. Any help would be appreciated. Render class: public class BulletEntityRenderer extends ThrownItemRenderer { private static final ResourceLocation TEXTURE = new ResourceLocation(ExampleMod.MOD_ID, "textures/entity/bullet.png"); public BulletEntityRenderer(EntityRendererProvider.Context context) { super(context); } @Override public ResourceLocation getTextureLocation(Entity entity) { return TEXTURE; } } Render registry: public class ModRender { public static void registerRender() { EntityRenderers.register(ExampleMod.BULLET, BulletEntityRenderer::new); } } Entity class: public class BulletEntity extends ThrowableItemProjectile { private float damage = 12.0F; private int pierceLevel = 0; private int ticksAlive = 0; private final int lifespan = 60; public BulletEntity(EntityType<BulletEntity> type, Level world) { super(type, world); } public BulletEntity(Player player, Level world, float damage, int pierceLevel) { super(ExampleMod.BULLET, player, world); this.damage = damage; this.pierceLevel = pierceLevel; this.setNoGravity(true); } public DamageSource causeBulletDamage(BulletEntity bullet, Entity attacker) { return (new IndirectEntityDamageSource("bullet", bullet, attacker)).setProjectile(); } public void tick() { super.tick(); Vec3 vec3d = this.getDeltaMovement(); double d1 = vec3d.x; double d2 = vec3d.y; double d0 = vec3d.z; if (this.isInWater()) { this.level.addParticle(ParticleTypes.BUBBLE, this.getX(), this.getY(), this.getZ(), -d1, -d2, -d0); } else { this.level.addParticle(ParticleTypes.SMOKE, this.getX(), this.getY(), this.getZ(), -d1, -d2, -d0); } if (ticksAlive > lifespan) { this.discard(); } ticksAlive++; } @Override protected void onHitEntity(EntityHitResult hitResult) { LivingEntity target = (LivingEntity) hitResult.getEntity(); Entity shooter = getOwner(); double armor = target.getArmorValue() * (1 - (0.2 * pierceLevel)); double toughness = target.getAttribute(Attributes.ARMOR_TOUGHNESS).getValue(); float finalDamage = (float) (damage * (1 - (Math.min(20, Math.max((armor / 5), armor - ((4 * damage) / (toughness + 8))))) / 25)); target.hurt(causeBulletDamage(this, shooter).bypassArmor(), finalDamage); } @Override public Item getDefaultItem() { return ModItems.BULLET; } }
    • Which version of Forge did you use? Post debug log
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.