Jump to content

[1.12.2] How to write a proxy


gomalley411

Recommended Posts

I'm nearly done making my first ever Forge mod, but for some reason I can only run it out of Eclipse. Whenever I try and run it out of the launcher it says that it's unable to connect to the authentication server. I asked around on Reddit and they told me to make sure I wrote my ClientProxy, ServerProxy and CommonProxy classes. What can I do to fix this?

 

Here's my CommonProxy file:

 
 
?
 
Spoiler

package com.example.examplemod;

import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.*;
import net.minecraftforge.event.*;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.*;
import net.minecraftforge.client.model.*;
import net.minecraftforge.client.event.*;

@Mod.EventBusSubscriber
public class CommonProxy {
	
	@SubscribeEvent
	public static void registerRenders(ModelRegistryEvent event) {
		registerRender(ExampleMod.mySword);
	}
	
	private static void registerRender(Item item) {
		ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation (item.getRegistryName(), "inventory"));
	}
	
	@SubscribeEvent
	public static void registerItems(RegistryEvent.Register<Item> event) {
		event.getRegistry().registerAll(ExampleMod.mySword);
	}
}

 

And here's my main mod class:

 
 
 
 
Spoiler


package com.example.examplemod;

import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.logging.log4j.Logger;
import net.minecraftforge.common.util.EnumHelper;

@Mod(modid = ExampleMod.MODID, name = ExampleMod.NAME, version = ExampleMod.VERSION)
public class ExampleMod
{
    public static final String MODID = "sword";
    public static final String NAME = "George's Custom Sword Mod";
    public static final String VERSION = "1.0";

    private static Logger logger;
    
    // New variables
    public static ToolMaterial myToolMaterial;
    public static Item mySword;

    @EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
        logger = event.getModLog();
        
        myToolMaterial = EnumHelper.addToolMaterial("light", 4, 1000000, 2, 10, 10);
        mySword = new CustomSword();
    }

    @EventHandler
    public void init(FMLInitializationEvent event)
    {
        // some example code
        logger.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
    }
}

All this mod does is give you one extra sword in the creative inventory -- that's it. Can someone help?

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I was trying to load some mods for 1.19.4 and yes all of them are right and i think some are interfering with each other and I don't know which ones to remove
    • Minecraft has crashed! net.fabricmc.loader.impl.FormattedException: java.lang.RuntimeException: Mixin transformation of net.minecraft.class_310 failed     at net.fabricmc.loader.impl.FormattedException.ofLocalized(FormattedException.java:63)     at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:472)     at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)     at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) Caused by: java.lang.RuntimeException: Mixin transformation of net.minecraft.class_310 failed     at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.getPostMixinClassByteArray(KnotClassDelegate.java:427)     at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.tryLoadClass(KnotClassDelegate.java:323)     at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.loadClass(KnotClassDelegate.java:218)     at net.fabricmc.loader.impl.launch.knot.KnotClassLoader.loadClass(KnotClassLoader.java:119)     at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)     at net.minecraft.client.main.Main.main(Main.java:207)     at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470)     ... 2 more Caused by: org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:392)     at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:234)     at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClassBytes(MixinTransformer.java:202)     at meteordevelopment.meteorclient.asm.Asm$Transformer.transformClassBytes(Asm.java:102)     at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.getPostMixinClassByteArray(KnotClassDelegate.java:422)     ... 8 more Caused by: org.spongepowered.asm.mixin.injection.throwables.InjectionError: Critical injection failure: Redirector breakBlockCheck(Lnet/minecraft/class_746;)Z in reaper.mixins.json:MinecraftClientMixin from mod reaper failed injection check, (0/1) succeeded. Scanned 1 target(s). Using refmap reaper-refmap.json     at org.spongepowered.asm.mixin.injection.struct.InjectionInfo.postInject(InjectionInfo.java:468)     at org.spongepowered.asm.mixin.transformer.MixinTargetContext.applyInjections(MixinTargetContext.java:1384)     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyInjections(MixinApplicatorStandard.java:1062)     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyMixin(MixinApplicatorStandard.java:402)     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:327)     at org.spongepowered.asm.mixin.transformer.TargetClassContext.apply(TargetClassContext.java:422)     at org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:403)     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:363)     ... 12 more  
    • Did some digging on that specific error and found a reddit post. Someone replied that they fixed it by closing Overwolf, so I went into task manager and closed Overwolf before loading up the game. This seems to have fixed it! I guess the error has something to do with Overwolf then. 
    • I'm struggling so hard to find a way to allow players to use my config file to modify where structures are being created. I have checked for events in the documentation but none of them seem to be of use for this. Why pointing Biome is not enough? Well Certain mods like Lost cities use vanilla generation, causing many structures to spawn in, completely disrupting the dimension generation. Is there a way to control dimensional spawning of structures? Please Im still trying very hard to find how to do this.
    • I'm new to modpack making, but familiar with file management and mod development. I cannot locate which mod is causing the crash. If it's more than one, Im not sure how to locate it. Any clues as to whats causing this? I have read through different possible causes but every thing is different, and none of the solves issues are the solution to my problem. This problem started occurring after adding about 5 mods, but once I removed them, the problem continued. It worked fine before.   Here is the crash report.
  • Topics

×
×
  • Create New...

Important Information

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